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:
authorWade Berrier <wade@mono-cvs.ximian.com>2006-03-27 21:39:11 +0400
committerWade Berrier <wade@mono-cvs.ximian.com>2006-03-27 21:39:11 +0400
commit33ab4bee8e165e330c6abd3385bb09357afd892a (patch)
tree7515ab171a26ef3e6eb0a1c9de8d4df5a15d400e
parenta2109761ebb6d50e387002b45c0afdeade073faa (diff)
parent009188af4bc10445c44724d8bb9f2f467e8fcc53 (diff)
pull from trunk (2 of 2)mono-1-1-13-6
svn path=/branches/mono-1-1-13/mcs/; revision=58604
-rw-r--r--mcs/class/Managed.Windows.Forms/Assembly/AssemblyInfo.cs44
-rw-r--r--mcs/class/Managed.Windows.Forms/Assembly/ChangeLog18
-rw-r--r--mcs/class/Managed.Windows.Forms/Assembly/Locale.cs75
-rw-r--r--mcs/class/Managed.Windows.Forms/ChangeLog864
-rw-r--r--mcs/class/Managed.Windows.Forms/Design84
-rw-r--r--mcs/class/Managed.Windows.Forms/Guidelines58
-rw-r--r--mcs/class/Managed.Windows.Forms/M.gifbin0 -> 6288 bytes
-rw-r--r--mcs/class/Managed.Windows.Forms/Makefile56
-rw-r--r--mcs/class/Managed.Windows.Forms/Notes17
-rw-r--r--mcs/class/Managed.Windows.Forms/README48
-rw-r--r--mcs/class/Managed.Windows.Forms/SWF.csproj2081
-rw-r--r--mcs/class/Managed.Windows.Forms/SWF.sln21
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Resources/ChangeLog106
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Resources/ResXFileRef.cs105
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Resources/ResXNullRef.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceReader.cs300
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceSet.cs63
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceWriter.cs336
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/ChangeLog81
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/ComponentEditorForm.cs76
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/ComponentEditorPage.cs188
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/EventsTab.cs122
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/IUIService.cs51
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/IWindowsFormsEditorService.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/PropertyTab.cs101
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/WindowsFormsComponentEditor.cs64
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/ChangeLog45
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Charcode.cs405
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Charset.cs159
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/CharsetFlags.cs36
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/CharsetType.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/ClassDelegate.cs49
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Color.cs127
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/DestinationDelegate.cs49
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Font.cs201
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/KeyStruct.cs40
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/KeysInit.cs719
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Major.cs67
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Minor.cs765
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/README7
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/RTF.cs883
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/RTFException.cs81
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/StandardCharCode.cs386
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/StandardCharName.cs405
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Style.cs205
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/StyleElement.cs116
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/StyleType.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/TextMap.cs228
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/TokenClass.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/rtf.csproj200
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/rtf.csproj.user48
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/test.cs286
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.resources10
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources533
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleEvents.cs74
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleNavigation.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleObject.cs570
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleRole.cs95
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleSelection.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleStates.cs67
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/AmbientProperties.cs87
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/AnchorStyles.cs42
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Appearance.cs37
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs475
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ApplicationContext.cs92
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ArrangeDirection.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ArrangeStartingPosition.cs37
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/AsyncMethodData.cs43
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/AsyncMethodResult.cs90
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/AutoScaleMode.cs38
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/AxHost.cs830
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/BaseCollection.cs99
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Binding.cs311
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingContext.cs227
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingManagerBase.cs153
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingMemberInfo.cs93
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingsCollection.cs120
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/BootMode.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Border3DSide.cs42
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Border3DStyle.cs45
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/BorderStyle.cs37
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/BoundsSpecified.cs42
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs122
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonBase.cs563
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonBorderStyle.cs38
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonState.cs40
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/CaptionButton.cs37
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/CategoryGridEntry.cs30
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog12067
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/CharacterCasing.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/CheckBox.cs346
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/CheckState.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/CheckedListBox.cs685
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Clipboard.cs142
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColorDepth.cs38
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColorDialog.cs1898
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnClickEventArgs.cs52
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnClickEventHandler.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs207
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeaderStyle.cs36
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnStyle.cs59
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs2017
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBoxStyle.cs37
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/CommonDialog.cs142
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComponentModel.cs54
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContainerControl.cs343
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContentsResizedEventArgs.cs51
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContentsResizedEventHandler.cs31
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContextMenu.cs98
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs4517
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlBindingsCollection.cs144
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlEventArgs.cs48
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlEventHandler.cs32
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlPaint.cs476
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlStyles.cs50
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ConvertEventArgs.cs60
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ConvertEventHandler.cs31
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Copyright40
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/CreateParams.cs126
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/CurrencyManager.cs302
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Cursor.cs729
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/CursorConverter.cs116
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Cursors.cs353
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataFormats.cs215
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs2249
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridBoolColumn.cs384
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridCell.cs85
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridColumnStyle.cs602
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridDrawingLogic.cs617
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridLineStyle.cs33
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridParentRowsLabelStyle.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridPreferredColumnWidthTypeConverter.cs69
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTableStyle.cs937
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBox.cs184
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBoxColumn.cs342
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs2985
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAdvancedBorderStyle.cs154
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAdvancedCellBorderStyle.cs43
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnMode.cs44
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnModeEventArgs.cs53
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnModeEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnsMode.cs43
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnsModeEventArgs.cs47
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnsModeEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeModeEventArgs.cs47
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeModeEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeRowMode.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeRowsMode.cs43
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewBand.cs164
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewBindingCompleteEventArgs.cs49
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewBindingCompleteEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewButtonCell.cs199
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewButtonColumn.cs92
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCell.cs1074
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellBorderStyle.cs47
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellCancelEventArgs.cs55
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellCancelEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellCollection.cs164
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellContextMenuStripNeededEventArgs.cs49
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellContextMenuStripNeededEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellErrorTextNeededEventArgs.cs48
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellErrorTextNeededEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellEventArgs.cs53
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellFormattingEventArgs.cs69
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellFormattingEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellMouseEventArgs.cs53
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellMouseEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellPaintingEventArgs.cs157
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellPaintingEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellParsingEventArgs.cs66
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellParsingEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStateChangedEventArgs.cs53
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStateChangedEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyle.cs286
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyleContentChangedEventArgs.cs53
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyleContentChangedEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyleConverter.cs50
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyleScopes.cs45
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellToolTipTextNeededEventArgs.cs48
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellToolTipTextNeededEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellValidatingEventArgs.cs60
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellValidatingEventHandler.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellValueEventArgs.cs59
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellValueEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCheckBoxCell.cs322
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCheckBoxColumn.cs134
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewClipboardCopyMode.cs40
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumn.cs387
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnCollection.cs237
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnDesignTimeVisibleAttribute.cs75
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnDividerDoubleClickEventArgs.cs47
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnDividerDoubleClickEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnEventArgs.cs47
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnHeaderCell.cs144
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnHeadersHeightSizeMode.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnSortMode.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnStateChangedEventArgs.cs53
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnStateChangedEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewComboBoxCell.cs330
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewComboBoxColumn.cs190
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewComboBoxDisplayStyle.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewComboBoxEditingControl.cs102
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewContentAlignment.cs45
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewDataErrorContexts.cs48
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewDataErrorEventArgs.cs62
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewDataErrorEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewEditMode.cs41
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewEditingControlShowingEventArgs.cs54
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewEditingControlShowingEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewElement.cs110
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewElementStates.cs49
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewHeaderBorderStyle.cs41
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewHeaderCell.cs98
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewHitTestType.cs43
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewImageCell.cs174
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewImageCellLayout.cs40
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewImageColumn.cs94
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewPaintParts.cs46
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRow.cs484
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowCancelEventArgs.cs49
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowCancelEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowCollection.cs434
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowContextMenuStripNeededEventArgs.cs55
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowContextMenuStripNeededEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowDividerDoubleClickEventArgs.cs47
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowDividerDoubleClickEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowErrorTextNeededEventArgs.cs54
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowErrorTextNeededEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowEventArgs.cs47
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeaderCell.cs144
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeadersWidthSizeMode.cs41
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeightInfoNeededEventArgs.cs59
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeightInfoNeededEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeightInfoPushedEventArgs.cs61
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeightInfoPushedEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowPostPaintEventArgs.cs167
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowPostPaintEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowPrePaintEventArgs.cs173
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowPrePaintEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowStateChangedEventArgs.cs53
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowStateChangedEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsAddedEventArgs.cs53
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsAddedEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsDeletedEventArgs.cs53
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsRemovedEventArgs.cs53
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsRemovedEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSelectedCellCollection.cs118
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSelectedColumnCollection.cs104
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSelectedRowCollection.cs104
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSelectionMode.cs41
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSortCompareEventArgs.cs79
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSortCompareEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTextBoxCell.cs176
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTextBoxColumn.cs77
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTextBoxEditingControl.cs117
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTopLeftHeaderCell.cs100
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTriState.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataObject.cs288
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateBoldEventArgs.cs69
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateBoldEventHandler.cs31
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateRangeEventArgs.cs67
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateRangeEventHandler.cs31
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateTimePicker.cs829
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateTimePickerFormat.cs33
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Day.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DialogResult.cs46
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DockStyle.cs41
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DomainUpDown.cs572
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DragAction.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DragDropEffects.cs41
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DragEventArgs.cs97
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DragEventHandler.cs31
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DrawItemEventArgs.cs101
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DrawItemEventHandler.cs32
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DrawItemState.cs44
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DrawMode.cs37
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ErrorBlinkStyle.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ErrorIconAlignment.cs38
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ErrorProvider.cs440
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/FeatureSupport.cs116
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/FileDialog.cs2798
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/FixedSizeTextBox.cs42
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/FlatStyle.cs36
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/FolderBrowserDialog.cs442
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/FontDialog.cs1051
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs1844
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/FormBorderStyle.cs43
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/FormStartPosition.cs40
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/FormWindowState.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/FrameStyle.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/GiveFeedbackEventArgs.cs62
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/GiveFeedbackEventHandler.cs32
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridColumnStylesCollection.cs273
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs167
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridItem.cs120
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridItemCollection.cs141
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridItemType.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridTableStylesCollection.cs237
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridTablesFactory.cs54
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/GroupBox.cs221
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/HScrollBar.cs51
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/HandledMouseEventArgs.cs52
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Help.cs73
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/HelpEventArgs.cs64
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/HelpEventHandler.cs30
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/HelpNavigator.cs38
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/HelpProvider.cs279
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/HorizontalAlignment.cs37
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Hwnd.cs575
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/IButtonControl.cs40
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ICommandExecutor.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/IComponentEditorPageSite.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/IContainerControl.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataGridColumnStyleEditingNotificationService.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataGridEditingService.cs36
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataGridViewEditingCell.cs45
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataGridViewEditingControl.cs57
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataObject.cs53
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/IFeatureSupport.cs37
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/IFileReaderService.cs37
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/IMessageFilter.cs34
-rwxr-xr-xmcs/class/Managed.Windows.Forms/System.Windows.Forms/IRootGridEntry.cs40
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/IWin32Window.cs43
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/IWindowTarget.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageIndexConverter.cs98
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageLayout.cs41
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageList.cs1159
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageListConverter.cs44
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageListStreamer.cs226
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImeMode.cs47
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImplicitHScrollBar.cs47
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImplicitVScrollBar.cs47
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguage.cs137
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageChangedEventArgs.cs72
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageChangedEventHandler.cs31
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageChangingEventArgs.cs74
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageChangingEventHandler.cs31
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageCollection.cs84
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/InternalWindowManager.cs803
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/InvalidateEventArgs.cs49
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/InvalidateEventHandler.cs32
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemActivation.cs40
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemBoundsPortion.cs37
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemChangedEventArgs.cs50
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemChangedEventHandler.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemCheckEventArgs.cs65
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemCheckEventHandler.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemDragEventArgs.cs63
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemDragEventHandler.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyEventArgs.cs111
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyEventHandler.cs33
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyPressEventArgs.cs63
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyPressEventHandler.cs31
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyboardLayouts.cs130
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Keys.cs221
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeysConverter.cs126
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Label.cs657
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/LabelEditEventArgs.cs68
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/LabelEditEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEngine.cs45
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEventArgs.cs56
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEventHandler.cs32
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutSettings.cs41
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/LeftRightAlignment.cs37
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/LibSupport.cs56
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkArea.cs168
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkBehavior.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkClickedEventArgs.cs48
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkClickedEventHandler.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkLabel.cs895
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkLabelLinkClickedEventArgs.cs49
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkLabelLinkClickedEventHandler.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkState.cs41
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListBindingConverter.cs60
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListBox.cs2390
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListControl.cs337
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs2712
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewAlignment.cs37
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs909
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItemConverter.cs97
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MWFCategoryAttribute.cs50
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MWFDescriptionAttribute.cs51
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MainMenu.cs150
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiChildContext.cs695
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs410
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiLayout.cs36
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs256
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MeasureItemEventArgs.cs76
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MeasureItemEventHandler.cs31
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Menu.cs511
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuAPI.cs728
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuGlyph.cs36
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuItem.cs678
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuMerge.cs38
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Message.cs108
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBox.cs516
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBoxButtons.cs43
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBoxDefaultButton.cs40
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBoxIcon.cs45
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBoxOptions.cs41
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MethodInvoker.cs32
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Mime.cs1238
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MimeIcon.cs1114
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MonthCalendar.cs2030
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MouseButtons.cs42
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MouseEventArgs.cs82
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MouseEventHandler.cs32
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/NativeWindow.cs167
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/NavigateEventArgs.cs52
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/NavigateEventHandler.cs32
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/NodeLabelEditEventArgs.cs61
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/NodeLabelEditEventHandler.cs33
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/NotifyIcon.cs379
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/NumericUpDown.cs463
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/OSFeature.cs63
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/OSXStructs.cs514
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/OpacityConverter.cs74
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/OpenFileDialog.cs122
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/OpenTreeNodeEnumerator.cs113
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Orientation.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/OwnerDrawPropertyBag.cs84
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Padding.cs149
-rwxr-xr-xmcs/class/Managed.Windows.Forms/System.Windows.Forms/PageSetupDialog.cs377
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/PaintEventArgs.cs86
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/PaintEventHandler.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Panel.cs125
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/PictureBox.cs427
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/PictureBoxSizeMode.cs37
-rwxr-xr-xmcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintControllerWithStatusDialog.cs129
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintDialog.cs168
-rwxr-xr-xmcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintPreviewControl.cs159
-rwxr-xr-xmcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintPreviewDialog.cs77
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ProgressBar.cs414
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ProgressBarStyle.cs37
-rwxr-xr-xmcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertiesTab.cs77
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGrid.cs1068
-rwxr-xr-xmcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridCommands.cs47
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridEntry.cs18
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridTextBox.cs146
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs758
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyManager.cs141
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertySort.cs41
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyTabChangedEventArgs.cs66
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyTabChangedEventHandler.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyValueChangedEventArgs.cs66
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyValueChangedEventHandler.cs32
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/QueryAccessibilityHelpEventArgs.cs84
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/QueryAccessibilityHelpEventHandler.cs31
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/QueryContinueDragEventArgs.cs71
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/QueryContinueDragEventHandler.cs31
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/QuestionEventArgs.cs52
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/QuestionEventHandler.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/RadioButton.cs333
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs1640
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxFinds.cs38
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxScrollBars.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxSelectionAttribute.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxSelectionTypes.cs38
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxStreamType.cs37
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxWordPunctuations.cs36
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/RightToLeft.cs36
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/RowStyle.cs58
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/SWF.csproj.user48
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/SaveFileDialog.cs102
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Screen.cs181
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollBar.cs1229
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollBars.cs36
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollButton.cs39
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollEventArgs.cs64
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollEventHandler.cs31
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollEventType.cs44
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollableControl.cs663
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/SecurityIDType.cs41
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectedGridItemChangedEventArgs.cs65
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectedGridItemChangedEventHandler.cs32
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectionMode.cs43
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectionRange.cs100
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectionRangeConverter.cs109
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/SendKeys.cs199
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Shortcut.cs187
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeGrip.cs134
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeGripStyle.cs38
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeType.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/SortOrder.cs38
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Splitter.cs749
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/SplitterEventArgs.cs79
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/SplitterEventHandler.cs32
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBar.cs616
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarDrawItemEventArgs.cs57
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarDrawItemEventHandler.cs36
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanel.cs215
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelAutoSize.cs33
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelBorderStyle.cs33
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelClickEventArgs.cs46
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelClickEventHandler.cs32
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelStyle.cs33
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/StructFormat.cs37
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/SystemInformation.cs429
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabAlignment.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabAppearance.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabControl.cs1224
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabDrawMode.cs33
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabPage.cs284
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabSizeMode.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayout.cs45
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanel.cs87
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanelGrowStyle.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutSettings.cs208
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs238
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs1669
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs4727
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextFormatFlags.cs66
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs851
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeClearlooks.cs3405
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeEngine.cs65
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeGtk.cs1593
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeNice.cs1423
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs5452
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThreadExceptionDialog.cs203
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TickStyle.cs40
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Timer.cs149
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBar.cs890
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarAppearance.cs41
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarButton.cs388
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarButtonClickEventArgs.cs57
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarButtonClickEventHandler.cs36
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarButtonStyle.cs42
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarTextAlign.cs40
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolTip.cs453
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TrackBar.cs693
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNode.cs686
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeCollection.cs373
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeConverter.cs54
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeView.cs1571
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewAction.cs35
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewCancelEventArgs.cs52
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewCancelEventHandler.cs31
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewEventArgs.cs51
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewEventHandler.cs30
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewImageIndexConverter.cs45
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/UICues.cs41
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/UICuesEventArgs.cs87
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/UICuesEventHandler.cs32
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/UpDownBase.cs691
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/UpDownEventArgs.cs49
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/UpDownEventHandler.cs31
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/UserControl.cs103
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/VScrollBar.cs77
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/View.cs37
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Win32DnD.cs1097
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11DesktopColors.cs292
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Dnd.cs1170
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Keyboard.cs838
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Structs.cs1602
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/XEventQueue.cs109
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs897
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs320
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs2071
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIStructs.cs812
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs2599
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs4581
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11GTK.cs4778
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources52
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Resources/ChangeLog12
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Resources/CompatTest.cs51
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Resources/CultureTest.cs59
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Resources/WriterTest.cs60
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Resources/compat_1_1.resx81
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Resources/compat_2_0.resx100
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ButtonTest.cs104
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog262
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckBoxEventTest.cs65
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckBoxTest.cs40
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckedListBoxEventTest.cs42
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckedListBoxTest.cs133
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ComboBoxTest.cs326
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ComboBoxTests.cs97
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/Common.cs251
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlEventTest.cs300
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlPaintTest.cs150
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlStyleTest.cs961
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlTest.cs790
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CursorTest.cs29
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridCellTest.cs56
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTableStyleTest.cs270
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTest.cs314
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTextBoxColumnTest.cs105
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewAdvancedBorderStyleTest.cs149
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewBandTest.cs73
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellStyleTest.cs125
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellTest.cs74
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewElementTest.cs57
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewRowTest.cs64
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewTest.cs282
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ErrorProviderTest.cs98
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormEventTest.cs237
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormTest.cs175
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GenerateControlStyleTest.cs129
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridColumnStylesCollectionTest.cs199
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridTableStylesCollectionTest.cs193
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GroupBoxTest.cs40
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ImageListTest.cs94
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/LabelPropertyTest.cs138
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/LabelTest.cs970
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListBoxEventTest.cs65
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListBoxTest.cs353
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewCollectionsTest.cs243
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewEventTest.cs208
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewItemTest.cs88
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewTest.cs136
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MenuItemTest.cs170
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MenuTest.cs86
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MonthCalendarTest.cs166
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/PictureBoxTest.cs82
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ProgressBarTest.cs84
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RadioButtonTest.cs104
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RichTextBoxTest.cs187
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ScrollBarTest.cs1453
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/StatusBarTest.cs75
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TabControlTest.cs87
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TestImageIndexConverter.cs157
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TextBoxTest.cs202
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolBarTest.cs97
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolTipTest.cs71
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TrackBarTest.cs79
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeNodeTest.cs162
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeViewTest.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/bitmaps/a.pngbin0 -> 651 bytes
-rwxr-xr-xmcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/tests-ms.sh28
-rwxr-xr-xmcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/tests.sh29
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/resources/a.curbin0 -> 766 bytes
-rwxr-xr-xmcs/class/Managed.Windows.Forms/build-csproj215
-rw-r--r--mcs/class/Managed.Windows.Forms/resources/ChangeLog53
-rw-r--r--mcs/class/Managed.Windows.Forms/resources/DnDCopy.curbin0 -> 326 bytes
-rw-r--r--mcs/class/Managed.Windows.Forms/resources/DnDLink.curbin0 -> 326 bytes
-rw-r--r--mcs/class/Managed.Windows.Forms/resources/DnDMove.curbin0 -> 326 bytes
-rw-r--r--mcs/class/Managed.Windows.Forms/resources/DnDNo.curbin0 -> 326 bytes
-rw-r--r--mcs/class/Managed.Windows.Forms/resources/SplitterNS.curbin0 -> 326 bytes
-rw-r--r--mcs/class/Managed.Windows.Forms/resources/SplitterWE.curbin0 -> 326 bytes
-rw-r--r--mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.de.resources.prebuiltbin0 -> 141068 bytes
-rw-r--r--mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.de.resx831
-rw-r--r--mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.en.resources.prebuiltbin0 -> 141020 bytes
-rw-r--r--mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.en.resx831
-rw-r--r--mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.resources.prebuiltbin0 -> 145735 bytes
-rw-r--r--mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.resx844
-rw-r--r--mcs/class/Managed.Windows.Forms/resources/create-keyboards.cs2069
-rw-r--r--mcs/class/Managed.Windows.Forms/resources/keyboards.resources.prebuiltbin0 -> 86172 bytes
-rw-r--r--mcs/class/Managed.Windows.Forms/resources/keyboards.resx44
-rw-r--r--mcs/class/Managed.Windows.Forms/samples/Changelog6
-rw-r--r--mcs/class/Managed.Windows.Forms/samples/mailclient.cs280
-rw-r--r--mcs/class/Managed.Windows.Forms/samples/notepad.cs275
-rw-r--r--mcs/class/PEAPI/Assembly/AssemblyInfo.cs30
-rw-r--r--mcs/class/PEAPI/Assembly/ChangeLog6
-rw-r--r--mcs/class/PEAPI/ChangeLog640
-rw-r--r--mcs/class/PEAPI/Code.cs1322
-rw-r--r--mcs/class/PEAPI/Makefile11
-rw-r--r--mcs/class/PEAPI/Metadata.cs5659
-rw-r--r--mcs/class/PEAPI/PEAPI.cs1211
-rw-r--r--mcs/class/PEAPI/PEAPI.dll.sources6
-rw-r--r--mcs/class/PEAPI/README.txt34
-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/ChangeLog326
-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/ChangeLog17
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing.Printing/EnumPrinters.cs42
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing.Printing/PrintFontSample.cs58
-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/ChangeLog73
-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.cs445
-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.cs71
-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/ChangeLog576
-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.cs913
-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.cs355
-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.cs327
-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/ChangeLog424
-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.cs118
-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.cs349
-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.cs432
-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.cs220
-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/ChangeLog74
-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.cs360
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrintingServicesWin32.cs348
-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/ChangeLog112
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Text/FontCollection.cs101
-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.cs90
-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
-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.cs90
-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/ChangeLog2572
-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.cs659
-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.cs233
-rw-r--r--mcs/class/System.Drawing/System.Drawing/FontStyle.cs44
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Graphics.cs2449
-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.cs798
-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.cs644
-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.cs1829
-rw-r--r--mcs/class/System.Drawing/System.Drawing/gdipStructs.cs206
-rw-r--r--mcs/class/System.Drawing/System.Drawing_test.dll.sources57
-rw-r--r--mcs/class/System.Drawing/Test/ChangeLog34
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/ChangeLog24
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/AssemblyInfo.cs58
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/ChangeLog40
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/DrawingTest.cs665
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/DrawingTestHelper.csproj121
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/DrawingTestHelper_java.vmwcsproj30
-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.sln99
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/System.Drawing.Test.sln84
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/AssemblyInfo.cs58
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Bitmap.cs60
-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.cs146
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Brushes.cs367
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/ChangeLog83
-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.cs4079
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/GraphicsPath.cs5694
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/GraphicsPathIterator.cs749
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Image.cs271
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Makefile17
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Pen.cs823
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Pens.cs350
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Region.cs231
-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/ChangeLog73
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/GraphicsPathTest.cs1292
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/LinearGradientBrushTest.cs494
-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.cs532
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Imaging/ChangeLog52
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestBmpCodec.cs162
-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.cs106
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageCodecInfo.cs195
-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/ChangeLog387
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/ColorConverter.cs416
-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.cs138
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/RegionNonRectTest.cs720
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestBitmap.cs557
-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.cs102
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestGraphics.cs310
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestIcon.cs121
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestIconConverter.cs436
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestImage.cs55
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestImageConverter.cs477
-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.cs473
-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.cs551
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestRectangleF.cs190
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestRegion.cs1366
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestSize.cs218
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestSizeConverter.cs480
-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.cs119
-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.csproj541
-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
-rw-r--r--mcs/class/System.Drawing/run-tests.bat52
-rw-r--r--mcs/class/System.Drawing/run-tests.test.bat163
-rw-r--r--mcs/class/System.Drawing/runmonotestfixture.bat1
-rw-r--r--mcs/class/System.Drawing/runtestfixture.bat1
-rw-r--r--mcs/ilasm/.cvsignore4
-rw-r--r--mcs/ilasm/AssemblyInfo.cs8
-rw-r--r--mcs/ilasm/ChangeLog344
-rw-r--r--mcs/ilasm/Driver.cs357
-rw-r--r--mcs/ilasm/Main.cs39
-rw-r--r--mcs/ilasm/Makefile29
-rw-r--r--mcs/ilasm/Report.cs102
-rw-r--r--mcs/ilasm/codegen/.cvsignore1
-rw-r--r--mcs/ilasm/codegen/AssemblyNameStore.cs47
-rw-r--r--mcs/ilasm/codegen/BaseClassRef.cs71
-rw-r--r--mcs/ilasm/codegen/BaseGenericTypeRef.cs42
-rw-r--r--mcs/ilasm/codegen/BaseMethodRef.cs79
-rw-r--r--mcs/ilasm/codegen/BaseTypeRef.cs101
-rw-r--r--mcs/ilasm/codegen/BranchInstr.cs36
-rw-r--r--mcs/ilasm/codegen/CalliInstr.cs56
-rw-r--r--mcs/ilasm/codegen/CatchBlock.cs45
-rw-r--r--mcs/ilasm/codegen/ChangeLog1687
-rw-r--r--mcs/ilasm/codegen/Class.cs169
-rw-r--r--mcs/ilasm/codegen/ClassTable.cs250
-rw-r--r--mcs/ilasm/codegen/CodeGen.cs595
-rw-r--r--mcs/ilasm/codegen/CustomAttr.cs58
-rw-r--r--mcs/ilasm/codegen/DataDef.cs40
-rw-r--r--mcs/ilasm/codegen/DebuggingInfo.cs117
-rw-r--r--mcs/ilasm/codegen/DeclSecurity.cs66
-rw-r--r--mcs/ilasm/codegen/EventDef.cs126
-rw-r--r--mcs/ilasm/codegen/ExternFieldRef.cs60
-rw-r--r--mcs/ilasm/codegen/ExternMethodRef.cs125
-rw-r--r--mcs/ilasm/codegen/ExternTable.cs368
-rw-r--r--mcs/ilasm/codegen/ExternTypeRef.cs160
-rw-r--r--mcs/ilasm/codegen/ExternTypeRefInst.cs139
-rw-r--r--mcs/ilasm/codegen/FaultBlock.cs41
-rw-r--r--mcs/ilasm/codegen/FeatureAttr.cs24
-rw-r--r--mcs/ilasm/codegen/FieldDef.cs173
-rw-r--r--mcs/ilasm/codegen/FieldInstr.cs40
-rw-r--r--mcs/ilasm/codegen/FieldRef.cs50
-rw-r--r--mcs/ilasm/codegen/FieldTable.cs130
-rw-r--r--mcs/ilasm/codegen/FileRef.cs36
-rw-r--r--mcs/ilasm/codegen/FilterBlock.cs43
-rw-r--r--mcs/ilasm/codegen/FinallyBlock.cs41
-rw-r--r--mcs/ilasm/codegen/GenericArguments.cs107
-rw-r--r--mcs/ilasm/codegen/GenericMethodRef.cs46
-rw-r--r--mcs/ilasm/codegen/GenericMethodSig.cs64
-rw-r--r--mcs/ilasm/codegen/GenericParamRef.cs116
-rw-r--r--mcs/ilasm/codegen/GenericParameters.cs212
-rw-r--r--mcs/ilasm/codegen/GenericTypeInst.cs128
-rw-r--r--mcs/ilasm/codegen/GlobalFieldRef.cs47
-rw-r--r--mcs/ilasm/codegen/GlobalMethodRef.cs58
-rw-r--r--mcs/ilasm/codegen/HandlerBlock.cs39
-rw-r--r--mcs/ilasm/codegen/IClassRef.cs33
-rw-r--r--mcs/ilasm/codegen/IFieldRef.cs25
-rw-r--r--mcs/ilasm/codegen/IInstr.cs34
-rw-r--r--mcs/ilasm/codegen/IMethodRef.cs37
-rw-r--r--mcs/ilasm/codegen/ISehClause.cs21
-rw-r--r--mcs/ilasm/codegen/ITypeRef.cs85
-rw-r--r--mcs/ilasm/codegen/InstrBase.cs51
-rw-r--r--mcs/ilasm/codegen/InstrTable.cs313
-rw-r--r--mcs/ilasm/codegen/Instructions.cs291
-rw-r--r--mcs/ilasm/codegen/IntInstr.cs36
-rw-r--r--mcs/ilasm/codegen/LabelInfo.cs63
-rw-r--r--mcs/ilasm/codegen/LdcInstr.cs54
-rw-r--r--mcs/ilasm/codegen/LdstrInstr.cs44
-rw-r--r--mcs/ilasm/codegen/LdtokenInstr.cs60
-rw-r--r--mcs/ilasm/codegen/Local.cs62
-rw-r--r--mcs/ilasm/codegen/Location.cs22
-rw-r--r--mcs/ilasm/codegen/Method.cs280
-rw-r--r--mcs/ilasm/codegen/MethodDef.cs751
-rw-r--r--mcs/ilasm/codegen/MethodInstr.cs41
-rw-r--r--mcs/ilasm/codegen/MethodPointerTypeRef.cs94
-rw-r--r--mcs/ilasm/codegen/MethodRef.cs69
-rw-r--r--mcs/ilasm/codegen/MethodTable.cs228
-rw-r--r--mcs/ilasm/codegen/MiscInstr.cs25
-rw-r--r--mcs/ilasm/codegen/ModifiableType.cs154
-rw-r--r--mcs/ilasm/codegen/Module.cs58
-rw-r--r--mcs/ilasm/codegen/ParamDef.cs106
-rw-r--r--mcs/ilasm/codegen/PeapiTypeRef.cs231
-rw-r--r--mcs/ilasm/codegen/PrimitiveTypeRef.cs108
-rw-r--r--mcs/ilasm/codegen/PropertyDef.cs136
-rw-r--r--mcs/ilasm/codegen/Sentinel.cs50
-rw-r--r--mcs/ilasm/codegen/SimpInstr.cs34
-rw-r--r--mcs/ilasm/codegen/SwitchInstr.cs50
-rw-r--r--mcs/ilasm/codegen/TryBlock.cs49
-rw-r--r--mcs/ilasm/codegen/TypeDef.cs536
-rw-r--r--mcs/ilasm/codegen/TypeInstr.cs37
-rw-r--r--mcs/ilasm/codegen/TypeManager.cs60
-rw-r--r--mcs/ilasm/codegen/TypeRef.cs86
-rw-r--r--mcs/ilasm/codegen/TypeSpecFieldRef.cs54
-rw-r--r--mcs/ilasm/codegen/TypeSpecMethodRef.cs59
-rw-r--r--mcs/ilasm/codegen/Types.cs82
-rw-r--r--mcs/ilasm/errors/ChangeLog19
-rw-r--r--mcs/ilasm/errors/bad-bytearray.il21
-rw-r--r--mcs/ilasm/errors/err-assembly.il12
-rw-r--r--mcs/ilasm/errors/err-field-dup1.il19
-rw-r--r--mcs/ilasm/errors/err-field-dup2.il18
-rw-r--r--mcs/ilasm/errors/err-field-dup3.il21
-rw-r--r--mcs/ilasm/errors/err-field-dup4.il21
-rw-r--r--mcs/ilasm/errors/err-field-dup5.il26
-rw-r--r--mcs/ilasm/errors/err-field-dup6-gen.il22
-rw-r--r--mcs/ilasm/errors/err-field-dup7-gen.il23
-rw-r--r--mcs/ilasm/errors/err-gen-2.il42
-rw-r--r--mcs/ilasm/errors/err-gen-3.il42
-rw-r--r--mcs/ilasm/errors/err-gen-cattr-1.il45
-rw-r--r--mcs/ilasm/errors/err-gen-cattr-2.il53
-rw-r--r--mcs/ilasm/errors/err-gen-cattr-3.il46
-rw-r--r--mcs/ilasm/errors/err-gen-cattr-4.il53
-rw-r--r--mcs/ilasm/errors/err-global.il33
-rw-r--r--mcs/ilasm/errors/err-global2.il32
-rw-r--r--mcs/ilasm/errors/err-invalid-array-bounds.il40
-rw-r--r--mcs/ilasm/errors/error-label-a.il18
-rw-r--r--mcs/ilasm/errors/test-perm_fail-1.il19
-rw-r--r--mcs/ilasm/errors/test-perm_fail-2.il18
-rw-r--r--mcs/ilasm/errors/test-perm_fail-3.il18
-rw-r--r--mcs/ilasm/errors/test-perm_fail-4.il18
-rw-r--r--mcs/ilasm/ilasm.exe.sources81
-rw-r--r--mcs/ilasm/parser/.cvsignore2
-rw-r--r--mcs/ilasm/parser/ChangeLog965
-rw-r--r--mcs/ilasm/parser/ILParser.jay3202
-rw-r--r--mcs/ilasm/parser/ScannerAdapter.cs60
-rw-r--r--mcs/ilasm/scanner/ChangeLog254
-rw-r--r--mcs/ilasm/scanner/ILReader.cs166
-rw-r--r--mcs/ilasm/scanner/ILSyntaxError.cs26
-rw-r--r--mcs/ilasm/scanner/ILTables.cs331
-rw-r--r--mcs/ilasm/scanner/ILToken.cs241
-rw-r--r--mcs/ilasm/scanner/ILTokenizer.cs371
-rw-r--r--mcs/ilasm/scanner/ILTokenizingException.cs30
-rw-r--r--mcs/ilasm/scanner/ITokenStream.cs13
-rw-r--r--mcs/ilasm/scanner/InstrToken.cs105
-rw-r--r--mcs/ilasm/scanner/Location.cs103
-rw-r--r--mcs/ilasm/scanner/NumberHelper.cs221
-rw-r--r--mcs/ilasm/scanner/StringHelper.cs132
-rw-r--r--mcs/ilasm/scanner/StringHelperBase.cs63
-rw-r--r--mcs/ilasm/tests/ChangeLog287
-rw-r--r--mcs/ilasm/tests/assembly.il13
-rw-r--r--mcs/ilasm/tests/dotted-names.il28
-rw-r--r--mcs/ilasm/tests/field-dup-gen2.il34
-rw-r--r--mcs/ilasm/tests/field-dup1.il42
-rw-r--r--mcs/ilasm/tests/gen-1.il69
-rw-r--r--mcs/ilasm/tests/gen-array1.il62
-rw-r--r--mcs/ilasm/tests/gen-array2.il52
-rw-r--r--mcs/ilasm/tests/gen-constraints1.il106
-rw-r--r--mcs/ilasm/tests/gen-dotted-name.il25
-rw-r--r--mcs/ilasm/tests/gen-extern-type.il51
-rw-r--r--mcs/ilasm/tests/gen-field.il79
-rw-r--r--mcs/ilasm/tests/gen-instr1.il48
-rw-r--r--mcs/ilasm/tests/gen-interf-1.il57
-rw-r--r--mcs/ilasm/tests/gen-interf-2.il36
-rw-r--r--mcs/ilasm/tests/gen-local.il49
-rw-r--r--mcs/ilasm/tests/gen-meth1.il65
-rw-r--r--mcs/ilasm/tests/gen-meth2.il49
-rw-r--r--mcs/ilasm/tests/gen-meth3.il36
-rw-r--r--mcs/ilasm/tests/gen-nested.il54
-rw-r--r--mcs/ilasm/tests/gen-nested2.il55
-rw-r--r--mcs/ilasm/tests/gen-nested3.il60
-rw-r--r--mcs/ilasm/tests/gen-recur.il34
-rw-r--r--mcs/ilasm/tests/gen-struct.il47
-rw-r--r--mcs/ilasm/tests/generics-b.il39
-rw-r--r--mcs/ilasm/tests/generics-c.il42
-rw-r--r--mcs/ilasm/tests/generics-d.il59
-rw-r--r--mcs/ilasm/tests/global.il39
-rw-r--r--mcs/ilasm/tests/invalid-field.il34
-rw-r--r--mcs/ilasm/tests/invalid-method.il33
-rw-r--r--mcs/ilasm/tests/nested.il70
-rw-r--r--mcs/ilasm/tests/one.cs39
-rw-r--r--mcs/ilasm/tests/oneg.cs4
-rwxr-xr-xmcs/ilasm/tests/sn.snkbin0 -> 596 bytes
-rw-r--r--mcs/ilasm/tests/test-1.il27
-rw-r--r--mcs/ilasm/tests/test-10.il28
-rw-r--r--mcs/ilasm/tests/test-11.il21
-rw-r--r--mcs/ilasm/tests/test-12.il23
-rw-r--r--mcs/ilasm/tests/test-13.il19
-rw-r--r--mcs/ilasm/tests/test-14.il25
-rw-r--r--mcs/ilasm/tests/test-15.il28
-rw-r--r--mcs/ilasm/tests/test-16.il25
-rw-r--r--mcs/ilasm/tests/test-17.il27
-rw-r--r--mcs/ilasm/tests/test-18.il30
-rw-r--r--mcs/ilasm/tests/test-19.il24
-rw-r--r--mcs/ilasm/tests/test-2.il33
-rw-r--r--mcs/ilasm/tests/test-20.il29
-rw-r--r--mcs/ilasm/tests/test-21.il27
-rw-r--r--mcs/ilasm/tests/test-22.il28
-rw-r--r--mcs/ilasm/tests/test-23.il18
-rw-r--r--mcs/ilasm/tests/test-24.il34
-rw-r--r--mcs/ilasm/tests/test-25.il30
-rw-r--r--mcs/ilasm/tests/test-26.il33
-rw-r--r--mcs/ilasm/tests/test-27.il41
-rw-r--r--mcs/ilasm/tests/test-28.il25
-rw-r--r--mcs/ilasm/tests/test-3.il35
-rw-r--r--mcs/ilasm/tests/test-30.il40
-rw-r--r--mcs/ilasm/tests/test-31.il61
-rw-r--r--mcs/ilasm/tests/test-32.il42
-rw-r--r--mcs/ilasm/tests/test-33.il75
-rw-r--r--mcs/ilasm/tests/test-34.il76
-rw-r--r--mcs/ilasm/tests/test-4.il36
-rw-r--r--mcs/ilasm/tests/test-5.il25
-rw-r--r--mcs/ilasm/tests/test-6.il26
-rw-r--r--mcs/ilasm/tests/test-7.il28
-rw-r--r--mcs/ilasm/tests/test-8.il23
-rw-r--r--mcs/ilasm/tests/test-9.il41
-rw-r--r--mcs/ilasm/tests/test-array-2.il41
-rw-r--r--mcs/ilasm/tests/test-array.il20
-rw-r--r--mcs/ilasm/tests/test-assembly2.il16
-rw-r--r--mcs/ilasm/tests/test-bounded-array.il28
-rw-r--r--mcs/ilasm/tests/test-byref.il39
-rw-r--r--mcs/ilasm/tests/test-cattr-declsec.il109
-rw-r--r--mcs/ilasm/tests/test-comment-a.il38
-rw-r--r--mcs/ilasm/tests/test-data-a.il38
-rw-r--r--mcs/ilasm/tests/test-data-b.il41
-rw-r--r--mcs/ilasm/tests/test-data-c.il41
-rw-r--r--mcs/ilasm/tests/test-field-init.il40
-rw-r--r--mcs/ilasm/tests/test-fixedarray.il15
-rw-r--r--mcs/ilasm/tests/test-gen-meth-a.il29
-rw-r--r--mcs/ilasm/tests/test-int64.il42
-rw-r--r--mcs/ilasm/tests/test-ldcr-bytes.il44
-rw-r--r--mcs/ilasm/tests/test-marshal-array.il32
-rw-r--r--mcs/ilasm/tests/test-marshal.il37
-rw-r--r--mcs/ilasm/tests/test-module-cattr.il60
-rw-r--r--mcs/ilasm/tests/test-nonsealed-valueclass.il7
-rw-r--r--mcs/ilasm/tests/test-override-1.il53
-rw-r--r--mcs/ilasm/tests/test-override-2.il52
-rw-r--r--mcs/ilasm/tests/test-perm_pass-1.il165
-rw-r--r--mcs/ilasm/tests/test-perm_pass-2.il42
-rw-r--r--mcs/ilasm/tests/test-pinvoke-a.il40
-rw-r--r--mcs/ilasm/tests/test-pinvoke-b.il40
-rw-r--r--mcs/ilasm/tests/test-pinvoke.c19
-rw-r--r--mcs/ilasm/tests/test-safearray.il27
-rw-r--r--mcs/ilasm/tests/test-sec-suppress.il36
-rw-r--r--mcs/ilasm/tests/test-seh-a.il76
-rw-r--r--mcs/ilasm/tests/test-seh-b.il75
-rw-r--r--mcs/ilasm/tests/test-seh-c.il76
-rw-r--r--mcs/ilasm/tests/test-seh-d.il92
-rw-r--r--mcs/ilasm/tests/test-seh-e.il100
-rw-r--r--mcs/ilasm/tests/test-sn.il59
-rw-r--r--mcs/ilasm/tests/test-uint.il32
-rw-r--r--mcs/ilasm/tests/two.cs7
1330 files changed, 310754 insertions, 0 deletions
diff --git a/mcs/class/Managed.Windows.Forms/Assembly/AssemblyInfo.cs b/mcs/class/Managed.Windows.Forms/Assembly/AssemblyInfo.cs
new file mode 100644
index 00000000000..2f390520b2a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Assembly/AssemblyInfo.cs
@@ -0,0 +1,44 @@
+//
+// AssemblyInfo.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2003 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Security;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about the System.Windows.Forms 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.Windows.Forms.dll")]
+[assembly: AssemblyDescription("System.Windows.Forms.dll")]
+[assembly: AssemblyConfiguration("Development version")]
+[assembly: AssemblyCompany("MONO development team")]
+[assembly: AssemblyProduct("MONO CLI")]
+[assembly: AssemblyCopyright("(c) 2003 Various Authors")]
+[assembly: AssemblyTrademark("")]
+
+[assembly: CLSCompliant(true)]
+[assembly: ComVisible(false)]
+[assembly: AssemblyDefaultAlias("System.Windows.Forms.dll")]
+[assembly: AssemblyInformationalVersion("0.0.0.1")]
+[assembly: NeutralResourcesLanguage("en-US")]
+
+[assembly: AllowPartiallyTrustedCallers()]
+
+[assembly: AssemblyDelaySign(true)]
+[assembly: AssemblyKeyFile("../ecma.pub")]
diff --git a/mcs/class/Managed.Windows.Forms/Assembly/ChangeLog b/mcs/class/Managed.Windows.Forms/Assembly/ChangeLog
new file mode 100644
index 00000000000..3ab76192247
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Assembly/ChangeLog
@@ -0,0 +1,18 @@
+2005-02-13 Peter Bartok <pbartok@novell.com>
+
+ * Locale.cs: Implemented support for reading resources from
+ the assembly
+
+2004-04-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * Consts.cs: Added
+
+2004-04-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AssemblyInfo.cs: patch by Gert Driesen that makes SWF CLS compliant.
+
+2004-03-15 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * AssemblyInfo.cs: Added
+ * Locale.cs: Added
+ * ChangeLog: Added
diff --git a/mcs/class/Managed.Windows.Forms/Assembly/Locale.cs b/mcs/class/Managed.Windows.Forms/Assembly/Locale.cs
new file mode 100644
index 00000000000..bf47b659fbd
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Assembly/Locale.cs
@@ -0,0 +1,75 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2001-2005 Novell, Inc.
+//
+// Authors:
+// Miguel de Icaza (miguel@ximian.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Globalization;
+using System.Reflection;
+using System.Resources;
+
+namespace System.Windows.Forms {
+ internal sealed class Locale {
+ #region Local Variables
+ private static ResourceManager rm;
+ #endregion // Local Variables
+
+ #region Constructors
+ static Locale () {
+ rm = new ResourceManager("System.Windows.Forms", Assembly.GetExecutingAssembly());
+ }
+ #endregion
+
+ #region Static Properties
+ public static ResourceManager ResourceManager {
+ get {
+ return rm;
+ }
+ }
+
+ #endregion // Static Properties
+
+ #region Static Methods
+ public static string GetText (string msg){
+ string ret;
+
+// This code and behaviour may change without notice. It's a placeholder until I
+// understand how Miguels wants localization of strings done.
+ ret = (string)rm.GetObject(msg);
+ if (ret != null) {
+ return ret;
+ }
+ return msg;
+ }
+
+ public static object GetResource(string name) {
+ return rm.GetObject(name);
+ }
+ #endregion // Static Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/ChangeLog
new file mode 100644
index 00000000000..5e273149076
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/ChangeLog
@@ -0,0 +1,864 @@
+2006-03-21 Jackson Harper <jackson@ximian.com>
+
+ * System.Windows.Forms.dll.resources: Add the keyboard resources.
+
+2006-03-13 Peter Dennis Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Added ProgressBarStyle.cs
+
+2006-03-11 Alexander Olk <alex.olk@googlemail.com>
+
+ * System.Windows.Forms.dll.sources: Removed MimeGenerated.cs
+
+2006-03-09 Jonathan Gilbert <logic@deltaq.org>
+
+ * System.Windows.Forms/AutoScaleMode.cs: Added new file for
+ the 2.0 enumeration.
+ * System.Windows.Forms/ContainerControl.cs: Added stub for
+ AutoScaleMode property; outputs a message to stderr to
+ encourage people familiar with its behaviour to implement
+ it. :-)
+ * System.Windows.Forms/Control.cs: Added stub for AutoScale;
+ outputs a message just like ContainerControl::AutoScaleMode.
+ * System.Windows.Forms.dll.sources: Added AutoScaleMode.cs to
+ the list of files to build.
+
+2006-02-28 Matt Hargett <matt@use.net>
+
+ * System.Windows.Forms_test.dll.sources: Added ComboBoxTests.cs
+
+2006-1-12 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * build-csproj: Fixed so the csproj is usable.
+
+2006-1-12 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * System.Windows.Forms.dll.sources: Added PageSetupDialog.cs.
+
+2006-1-12 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * System.Windows.Forms.dll.sources: Added printing items and *committed* file this time.
+
+2006-1-10 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * System.Windows.Forms.dll.sources: Add PrintPreviewDialog and PrintPreviewControl
+
+2006-1-10 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * System.Windows.Forms.dll.sources: Add PrintControllerWithStatusDialog
+
+2005-12-13 Jackson Harper <jackson@ximian.com>
+
+ * System.Windows.Forms.dll.sources: Add the new internal window
+ managers
+
+2005-12-04 Alexander Olk <alex.olk@googlemail.com>
+
+ * System.Windows.Forms.dll.sources: Added ThemeClearlooks.cs
+
+2005-12-02 Jackson Harper <jackson@ximian.com>
+
+ * System.Windows.Forms.dll.sources: New implicit scrollbars.
+
+2005-12-01 Robert Jordan <robertj@gmx.net>
+
+ * System.Windows.Forms_test.dll.sources: Added
+ System.Resources/CompatTest.cs
+ System.Resources/WriterTest.cs.
+
+2005-12-01 Raja R Harinath <rharinath@novell.com>
+
+ * Makefile (EXTRA_DISTFILES): Add Test/resources/a.cur.
+
+2005-11-30 Robert Jordan <robertj@gmx.net>
+
+ * System.Windows.Forms_test.dll.sources: Added System.Resources/CultureTest.cs
+
+2005-11-12 Pedro Martínez Juliá <pedromj@gmail.com>
+
+ * System.Windows.Forms_test.dll.sources: Added DataGridViewElementTest.cs
+ DataGridViewBandTest.cs DataGridViewCellTest.cs
+ DataGridViewAdvancedBorderStyleTest.cs DataGridViewCellStyleTest.cs
+ DataGridViewRowTest.cs DataGridViewTest.cs
+
+2005-11-09 Peter Dennis Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms_test.dll.sources: Added RichTextBoxTest.cs
+
+2005-11-01 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Makefile, System.Windows.Forms.dll.resources, SWF.csproj: Added
+ DnDLink cursor
+
+2005-10-31 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Makefile: Added new cursors; added dependency rule on
+ cursors to force rebuild when cursors are changed or added
+ * System.Windows.Forms.dll.resources: Added new cursors
+
+2005-10-17 Raja R Harinath <rharinath@novell.com>
+
+ * Makefile (RESOURCES): Distribute newly added cursors.
+
+2005-10-13 Peter Dennis Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.resources: Added cursors
+ * build-csproj: Updated to support resources
+ * SWF.csproj: Updated
+ * System.Windows.Forms.dll.sources: Removed blank line to support
+ build-csproj
+ * System.Windows.Forms_test.dll.sources: Added ControlStyleTest
+
+2005-10-05 Hisham Mardam Bey <hisham.mardambey@gmail.com>
+
+ * Created samples/ directory.
+
+2005-09-30 Peter Dennis Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Added X11DesktopColors.cs
+ * SWF.csproj: Updated
+
+2005-09-28 Hisham Mardam Bey <hisham.mardambey@gmail.com>
+
+ * System.Windows.Forms_test.dll.sources : Added Common.cs
+
+2005-09-27 Kornél Pál <kornelpal@hotmail.com>
+
+ * Makefile: Replaced /codepage with CODEPAGE.
+
+2005-09-20 Ritvik Mayank <mritvik@novell.com>
+
+ * System.Windows.Forms_test.dll.sources : Added pictureBoxTest.cs
+
+2005-09-09 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * System.Windows.Forms.dll.sources: Added IRootGridEntry.cs and PropertyGridCommands.cs
+
+2005-09-09 Hisham Mardam Bey <hisham.mardambey@gmail.com>
+
+ * Test/System.Windows.Forms/LabelTest.cs : More tests.
+
+2005-09-09 Hisham Mardam Bey <hisham.mardambey@gmail.com>
+
+ * Test/System.Windows.Forms/LabelTest.cs : new Label tests (incomplete)
+ * System.Windows.Forms_test.dll.sources : add new tests
+ * System.Windows.Forms/Label.cs : give FlatStyle a default value
+ of FlatStyle.Standard.
+
+2005-09-08 Ritvik Mayank <mritvik@novell.com>
+
+ * System.Windows.Forms_test.dll.sources : added MonthCalendarTest.cs
+
+2005-09-08 Peter Dennis Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Added RichTextBox.cs to build
+ * SWF.csproj: Updated
+
+2005-09-06 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * System.Windows.Forms.dll.sources: Added System.Windows.Forms.PropertiesTab.cs
+
+2005-09-04 Peter Dennis Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Added System.Windows.Forms.RTF
+ subdirectory to build
+ * SWF.csproj: Updated
+
+2005-08-29 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * System.Windows.Forms.dll.sources: Added ThemeNice.cs
+
+2005-08-29 Ritvik Mayank <mritvik@novell.com>
+
+ * System.Windows.Forms_test.dll.sources : added ProgressBarTest.cs,
+ ToolBarTest.cs, ToolTipTest.cs
+
+ RadioButtonTest.cs, ScrollBarTest.cs and StatusBarTest.cs .
+2005-08-25 Atsushi Enomoto <atsushi@ximian.com>
+
+ * Makefile : added /codepage:65001 (otherwise the build gets broken
+ on KeyboardLayout.cs on some non-iso-8859-1 environment).
+
+2005-08-18 Rafael Teixeira <rafaelteixeirabr@hotmail.com>
+ * System.Windows.Forms/TreeView.cs: some spaces to tabs
+ FIX: ToString() was generating exception on empty Nodes
+ (was testing <0 instead of <= 0)
+
+2005-08-16 Ritvik Mayank <mritvik@novell.com>
+
+ * System.Windows.Forms_test.dll.sources : added ImageListTest.cs,
+ RadioButtonTest.cs, ScrollBarTest.cs and StatusBarTest.cs .
+
+2005-08-06 Ritvik Mayank <mritvik@novell.com>
+
+ * System.Windows.Forms_test.dll.sources : sorted and removed test-cases for Form
+ and TextBox as these are still under development.
+
+2005-08-04 Peter Dennis Bartok <pbartok@novell.com>
+
+ * SWF.csproj: Updated
+
+2005-08-02 Ritvik Mayank <mritvik@novell.com>
+
+ * M.gif : used by some of the test-cases
+ * System.Windows.Forms_test.dll.sources : Added test-case for
+ ListView, ComboBox, CheckBox, CheckedList, Form, Menu, GroupBox
+ and ImageList
+
+2005-07-07 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * System.Windows.Forms_test.dll.sources : Added MimeIcon.cs
+
+2005-07-06 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumn.cs: default value
+ * GridColumnStylesCollection.cs: fixes event firing, checking MappingName
+ * GridTableStylesCollection.cs: fixes checking MappingName
+ * DataGridDrawingLogic.cs: fixes drawing logic issues
+ * DataSourceHelper.cs: rewritten to make compatible with more data sources
+ * DataGrid.cs: fixes
+
+
+2005-07-04 Ritvik Mayank <mritvik@novell.com>
+
+ * System.Windows.Forms_test.dll.sources : Added ListBoxTest.cs and
+ ListBoxEventTest.cs for ListBox tests.
+
+2005-06-15 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Added MWFCategoryAttribute.cs and
+ MWFDescriptionAttribute.cs
+ * SWF.csproj: Updated
+
+2005-06-15 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * System.Windows.Forms.dll.sources: Added Mime.cs and
+ MimeGenerated.cs.
+
+2005-06-13 Jackson Harper <jackson@ximian.com>
+
+ * SWF.csproj:
+ * System.Windows.Forms.dll.sources: Add MdiClientContext to the
+ build.
+
+2005-06-13 Ritvik Mayank <mritvik@novell.com>
+
+ * System.Windows.Forms_test.dll.sources : Added TextBoxTest.cs
+ and ButtonTest.cs for TextBox and Button tests respectively.
+
+2005-06-10 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Add ImageListConverter.cs
+ * SWF.csproj: Updated
+
+2005-06-08 Jackson Harper <jackson@ximian.com>
+
+ * Guidelines:
+ * Design: Double buffering is handled at a different level now, so
+ I am removing mention of it. Control developers do not need to
+ know how it works.
+
+2005-06-05 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Add Win32DnD.cs
+ * SWF.csproj: Updated
+
+2005-05-24 Jackson Harper <jackson@ximian.com>
+
+ * System.Windows.Forms.dll.sources: Add X11Dnd.cs
+
+2005-05-24 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Added
+ DataGridPreferredColumnWidthTypeConverter.cs
+ * SWF.csproj: Updated
+
+2005-05-24 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Added Help.cs
+ * SWF.csproj: Updated
+
+2005-05-18 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Added Clipboard.cs
+ * SWF.csproj: Update
+
+2005-05-11 Ritvik Mayank <mritvik@novell.com>
+
+ * System.Windows.Forms_test.dll.sources : Added ControlEventTest.cs
+ for Event Test
+
+2005-05-11 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Added
+ IDataGridEditingService.cs, System.Resources/ResXFileRef.cs,
+ System.Resources/ResXResourceSet.cs
+ * SWF.csproj: Updated
+
+2005-05-10 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Added SecurityIDType.cs,
+ DataObject.cs and DataFormats.cs
+ * SWF.csproj: Update
+
+2005-05-06 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Added Screen.cs, HelpNavigator.cs
+ and HelpProvider.cs
+ * SWF.csproj: Updated
+
+2005-05-05 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Added AxHost.cs,
+ ErrorProvider.cs, RichTextBoxFinds.cs, RichTextBoxScrollBars.cs,
+ RichTextBoxSelectionAttribute.cs, RichTextBoxSelectionTypes.cs,
+ RichTextBoxStreamType.cs, RichTextBoxWordPunctuations.cs
+ * SWF.csproj: Updated
+
+2005-05-02 Ritvik Mayank <mritvik@novell.com>
+
+ * System.Windows.Forms_test.dll.sources : Added ControlTest.cs for Label Test
+
+2005-04-26 Ritvik Mayank <mritvik@novell.com>
+
+ * System.Windows.Forms_test.dll.sources : Added LabelPropertyTest.cs for Label Test
+
+2005-04-25 Jackson Harper <jackson@ximian.com>
+
+ * System.Windows.Forms.dll.sources: Add CursorConvert.cs to the
+ build
+
+2005-04-09 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Added FolderBrowserDialog.cs
+
+2005-03-11 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Added MdiClient.cs
+
+2005-03-10 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Added SaveFileDialog.cs
+
+2005-03-09 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Added MdiClient.cs
+
+2005-02-24 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Removed HandleData.cs
+
+2005-02-22 Jackson Harper <jackson@ximian.com>
+
+ * System.Windows.Forms.dll.sources: Add databinding classes
+
+2005-02-22 Raja R Harinath <rharinath@novell.com>
+
+ * Makefile (EXTRA_DISTFILES): Add 'build-csproj'.
+ (PREBUILT): New rule to copy *.resources to *.resources.prebuilt.
+ (dist-default): Depend on it.
+
+2005-02-18 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Added MethodInvoker.cs,
+ ErrorIconAlignment.cs, MdiLayout.cs, SendKeys.cs
+
+2005-02-18 Raja R Harinath <rharinath@novell.com>
+
+ * Makefile (EXTRA_DISTFILES): Distribute all *.resx and
+ *.resources.prebuilt.
+
+2005-02-17 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Added DateBoldEventHandler.cs,
+ DateBoldEventArgs.cs, UpDownEventHandler.cs, UpDownEventArgs.cs,
+ ContentsResizedEventHandler.cs, ContentsResizedEventArgs.cs
+
+2005-02-15 Peter Bartok <pbartok@novell.com>
+
+ * Makefile: Altered, following Harinath's suggestion of trying to
+ build and handling the failure by copying prebuilt resources in
+ place
+
+2005-02-15 Peter Bartok <pbartok@novell.com>
+
+ * Makefile: Removed resources as automatic target; to build
+ .resource files 'make resources' must be invoked. This removes
+ the libgdiplus installed requirement. Instead, the compiled files
+ are checked in as well.
+
+2005-02-13 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Added SelectionRangeConverter.cs,
+ OpacityConverter.cs, KeysConverter.cs, Hwnd.cs
+ * System.Windows.Forms.dll.resources: Added
+ * Makefile: Added support for generating resources
+
+2005-02-12 Geoff Norton <gnorton@customerdna.com>
+
+ * System.Windows.Forms.dll.sources: Added ResXNullRef.cs
+
+2005-02-03 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.Sources: Added ComponentModel.cs and
+ PropertyGridView.cs
+
+2005-01-30 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * System.Windows.Forms.dll.Sources: Added DateTimePicker.cs and
+ DateTimePickerFormat.cs
+
+2005-01-29 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.Sources: Added ArrangeDirection.cs and
+ ArrangeStartingPosition.cs
+ * SWF.csproj: Updated
+
+2005-01-28 Peter Bartok <pbartok@novell.com>
+
+ * SWF.csproj: Updated with all the latest files
+ * build-csproj: Added, allows to autogenerate SWF.csproj
+ * Makefile: Added rule to automatically call build-csproj (Thanks
+ to Geoff Norton for review and a simpler rule)
+
+2005-01-26 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.Sources: Added GridEntry.cs,
+ GridItem.cs, GridItemCollection.cs, GridItemType.cs,
+ PropertyGrid.cs, PropertySort.cs, PropertyTabChangedEventArgs.cs,
+ PropertyTabChangedEventHandler.cs, PropertyValueChangedEventArgs.cs
+ PropertyValueChangedEventHandler.cs,
+ SelectedGridItemChangedEventArgs.cs,
+ SelectedGridItemChangedEventHandler.cs
+
+2005-01-26 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.Sources: Added NotifyIcon.cs
+
+2005-01-16 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.Sources: Added AccessibleEvents.cs
+
+2005-01-16 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.Sources: Added Cursors.cs
+
+2005-01-11 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.Sources: Added OSXStructs.cs
+
+2005-01-05 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.Sources: Added ICommandExecutor.cs,
+ IDataGridColumnStyleEditingNotificationService.cs,
+ IFeatureSupport.cs, IFileReaderService.cs, AmbientProperties.cs,
+ NavigateEventArgs.cs, NavigateEventHandler.cs, FeatureSupport.cs,
+ OSFeature.cs, ErrorBlinkStyle.cs, ListBindingConverter.cs
+
+2004-12-27 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.Sources: Added
+ System.Windows.Forms.Design/ComponentEditorForm.cs,
+ System.Windows.Forms.Design/ComponentEditorPage.cs,
+ System.Windows.Forms.Design/EventsTab.cs,
+ System.Windows.Forms.Design/IUIService.cs,
+ System.Windows.Forms.Design/IWindowsFormsEditorService.cs,
+ System.Windows.Forms.Design/PropertyTab.cs,
+ System.Windows.Forms.Design/WindowsFormsComponentEditor.cs,
+ ColorDialog.cs, ComboBox.cs, ComboBoxStyle.cs, DataGrid.cs,
+ DataGridLineStyle.cs, DataGridParentRowsLabelStyle.cs,
+ DataGridTableStyle.cs, FontDialog.cs, FileDialog.cs,
+ GridColumnStylesCollection.cs, GridTableStylesCollection.cs,
+ IComponentEditorPageSite.cs, OpenFileDialog, Splitter.cs,
+ SplitterEventArgs.cs, SplitterEventHandler.cs, TextBox.cs
+
+2004-12-24 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * System.Windows.Forms.dll.Sources: Added ComboBox.cs and
+ ComboBoxStyle.cs
+
+2004-12-20 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.Sources: Added CommonDialog.cs
+
+2004-12-16 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.Sources: Added TextBoxBase.cs and
+ TextControl.cs
+
+2004-12-15 Peter Bartok <pbartok@novell.com>
+
+ * Design: Updated to reflect Mac Driver; added mention
+ of System.Drawing patches for MWF support
+
+ * README: Credited Geoff Norton with the Mac driver
+
+2004-12-15 Jackson Harper <jackson@ximian.com>
+
+ * System.Windows.Forms.dll.sources: Add keyboard love to the build.
+
+2004-12-08 Peter Bartok <pbartok@novell.com>
+
+ * SWF.csproj: Added XplatUIOSX.cs to build list
+
+2004-12-07 Geoff Norton <gnorton@customerdna.com>
+
+ * System.Windows.Forms.dll.sources: Add the XplatUIOSX.cs driver.
+
+2004-12-07 Ravindra <rkumar@novell.com>
+
+ * SWF.csproj: Added ThreadExceptionDialog.cs to project and removed
+ some of the components that were added twice. This fixes MWF build on
+ Windows.
+
+2004-12-03 Marek Safar <marek.safar@seznam.cz>
+
+ * System.Windows.Forms.dll.sources: Add ThreadExceptionDialog.cs
+
+2004-12-03 Marek Safar <marek.safar@seznam.cz>
+
+ * Makefile: Added System.Drawing.dll deps for tests.
+
+ * System.Windows.Forms_test.dll.sources: New test files.
+
+2004-12-02 Peter Bartok <pbartok@novell.com>
+
+ * SWF.csproj: Added Jackson's fresly minted TreeView files to
+ build list
+
+2004-12-01 Jackson Harper <jackson@ximian.com>
+
+ * System.Windows.Forms.dll.sources: Add TreeNode love to the build.
+
+2004-11-30 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Removed textbox
+ references, accidentally checked those in, but textbox is
+ not yet ready for primetime
+
+2004-11-29 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.sources: Removed tree
+ additions.
+ I am removing these files as they conflict with already completed
+ work. While it is fantastic to get contributions to MWF, I
+ respectfully ask that everyone please coordinate their contributions
+ through mono-winforms-list or #mono-winforms at this time. We're
+ explicitly avoiding stubbing and don't want controls that don't have
+ their basic functionality implemented in svn. Please also see
+ http://www.mono-project.com/contributing/winforms.html
+
+2004-11-29 Marek Safar <marek.safar@seznam.cz>
+
+ * System.Windows.Forms.dll.sources: Added
+ TreeNode.cs, TreeNodeCollection.cs, TreeView.cs,
+ TreeViewAction.cs, TreeViewEventArgs.cs
+
+ * System.Windows.Forms_test.dll.sources: Added
+ TreeNodeTest.cs
+
+2004-11-24 Ravindra <rkumar@novell.com>
+
+ * SWF.csproj: Updated project.
+
+2004-11-23 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * System.Windows.Forms.dll.sources: added MonthCalendar files
+
+2004-11-21 Ravindra <rkumar@novell.com>
+
+ * SWF.csproj: Updated project.
+
+2004-11-11 Jackson Harper <jackson@ximian.com>
+
+ * System.Windows.Forms.dll.sources: Add
+ TreeViewImageIndexConverter.cs and OwnerDrawPropertyBag.cs to build
+
+2004-11-01 23:19 ravindra
+
+ * SWF.csproj: Updated project.
+
+2004-10-26 03:38 ravindra
+
+ * SWF.csproj: Updated project.
+
+2004-10-20 04:16 jordi
+
+ * System.Windows.Forms.dll.sources: enum need it by SystemInfo
+
+2004-10-19 16:50 jackson
+
+ * System.Windows.Forms.dll.sources: New optimized event queue
+
+2004-10-18 00:31 ravindra
+
+ * SWF.csproj, System.Windows.Forms.dll.sources: Updated sources
+ list and project to fix the build.
+
+2004-10-15 09:14 ravindra
+
+ * SWF.csproj, System.Windows.Forms.dll.sources: Updates sources
+ list and project.
+
+2004-10-15 06:43 jordi
+
+ * System.Windows.Forms.dll.sources: menu work, mainmenu, subitems,
+ etc
+
+2004-10-13 21:21 ravindra
+
+ * SWF.csproj: Updated project.
+
+2004-10-04 04:58 ravindra
+
+ * SWF.csproj: Updated project.
+
+2004-10-02 12:55 pbartok
+
+ * System.Windows.Forms.dll.sources:
+ - Added LeftRightAlignment source reference
+
+2004-09-30 07:32 ravindra
+
+ * SWF.csproj, System.Windows.Forms.dll.sources: Updated project and
+ sources list.
+
+2004-09-29 23:02 jambunathan
+
+ * SWF.csproj: Updated csproj to include Appearance.cs, CheckBox.cs,
+ CheckState.cs
+
+2004-09-28 14:11 jackson
+
+ * System.Windows.Forms.dll.sources: Give the build some love
+
+2004-09-28 04:31 ravindra
+
+ * Notes: Added a minor note.
+
+2004-09-28 00:18 pbartok
+
+ * Notes:
+ - Initial check in. A place to log info about MWF that doesn't fit
+ anywhere else
+
+2004-09-24 12:02 jackson
+
+ * System.Windows.Forms.dll.sources: Add tab classes to the build
+
+2004-09-23 01:44 ravindra
+
+ * SWF.csproj, System.Windows.Forms.dll.sources: Updated sources
+ list and project file.
+
+2004-09-20 18:54 jackson
+
+ * Makefile: New message loop that uses poll so we don't get a busy
+ loop
+
+2004-09-19 23:41 ravindra
+
+ * Guidelines: Added a note to Guidelines.
+
+2004-09-17 06:19 jordi
+
+ * System.Windows.Forms.dll.sources: Very early menu support
+
+2004-09-16 01:19 ravindra
+
+ * SWF.csproj, System.Windows.Forms.dll.sources: Updated project and
+ sources list.
+
+2004-09-13 22:09 ravindra
+
+ * SWF.csproj: Updated project.
+
+2004-09-13 09:24 jordi
+
+ * System.Windows.Forms.dll.sources: Add to the build Process
+
+2004-09-09 01:15 jordi
+
+ * System.Windows.Forms.dll.sources: measureitem args and handler
+
+2004-09-09 00:03 ravindra
+
+ * SWF.csproj: Updated project.
+
+2004-09-08 23:57 ravindra
+
+ * System.Windows.Forms.dll.sources: Added some new enums to the
+ list.
+
+2004-09-08 06:45 jordi
+
+ * System.Windows.Forms.dll.sources: enumerations need it by menus
+
+2004-09-07 11:12 jordi
+
+ * System.Windows.Forms.dll.sources: GroupBox control
+
+2004-09-02 14:28 pbartok
+
+ * System.Windows.Forms.dll.sources:
+ - Added AccessibleNavigation and AccessibleSelection source files
+
+2004-08-31 20:52 ravindra
+
+ * Design, Guidelines: Minor formatting changes and added location
+ for the coding style guideline for Mono.
+
+2004-08-31 19:37 pbartok
+
+ * Guidelines:
+ - Removed wrong stuff
+
+2004-08-31 16:10 pbartok
+
+ * README:
+ - Updated
+
+2004-08-31 03:13 ravindra
+
+ * System.Windows.Forms_test.dll.sources: Added sources list for
+ test dll.
+
+2004-08-30 10:48 pbartok
+
+ * Design, Guidelines:
+ - Initial check-in
+
+2004-08-29 22:35 pbartok
+
+ * System.Windows.Forms.dll.sources:
+ - Added System.Resources source files
+
+2004-08-27 16:18 ravindra
+
+ * Makefile: Lets do some tests too.
+
+2004-08-27 16:14 ravindra
+
+ * System.Windows.Forms.dll.sources: Added ImageIndexConverter to
+ sources.
+
+2004-08-23 13:14 pbartok
+
+ * SWF.csproj, SWF.sln:
+ - Created properly pathed VS.Net project and solution
+
+2004-08-23 10:46 jackson
+
+ * System.Windows.Forms.dll.sources: oops. remove unused file
+
+2004-08-22 17:47 jackson
+
+ * System.Windows.Forms.dll.sources: Add PictureBox to the build
+
+2004-08-22 12:04 pbartok
+
+ * System.Windows.Forms.dll.sources:
+ - Added Cursor.cs source
+
+2004-08-22 11:59 pbartok
+
+ * System.Windows.Forms.dll.sources:
+ - Restored sort order for file
+ - Added UserControl source file
+
+2004-08-20 13:10 jackson
+
+ * System.Windows.Forms.dll.sources: Classes for sending Async
+ messages through X/Win32
+
+2004-08-19 16:25 jordi
+
+ * System.Windows.Forms.dll.sources: theme enhancaments
+
+2004-08-17 15:09 jackson
+
+ * System.Windows.Forms.dll.sources: Add Panel to the build
+
+2004-08-16 15:24 jackson
+
+ * System.Windows.Forms.dll.sources: HandleData is used for storing
+ message information for window handles
+
+2004-08-16 08:59 pbartok
+
+ * System.Windows.Forms.dll.sources:
+ - Added ButtonBase.cs
+
+2004-08-15 17:22 ravindra
+
+ * System.Windows.Forms.dll.sources: Updated sources list for
+ ToolBar Control.
+
+2004-08-13 10:25 jackson
+
+ * System.Windows.Forms.dll.sources: SWF Timer
+
+2004-08-12 10:19 jackson
+
+ * System.Windows.Forms.dll.sources: Classes for handling status bar
+ panel click events
+
+2004-08-11 15:24 pbartok
+
+ * System.Windows.Forms.dll.sources:
+ - Fixed filename for BindingManagerBase.cs
+ - Alphabetized files
+
+2004-08-10 19:11 jackson
+
+ * System.Windows.Forms.dll.sources: Add StatusBarDrawItem stuff to
+ build
+
+2004-08-10 12:59 jackson
+
+ * System.Windows.Forms.dll.sources: Add Draw Item
+
+2004-08-09 15:40 jackson
+
+ * System.Windows.Forms.dll.sources: Add status bar panel files to
+ the build
+
+2004-08-07 17:01 jackson
+
+ * System.Windows.Forms.dll.sources: Add HorizontalAlignment enum to
+ build
+
+2004-07-26 11:42 jordi
+
+ * System.Windows.Forms.dll.sources: Theme support
+
+2004-07-26 05:41 jordi
+
+ * System.Windows.Forms.dll.sources: initial messagebox
+ implementation
+
+2004-07-21 10:19 jordi
+
+ * System.Windows.Forms.dll.sources: LinkLabel control
+ implementation
+
+2004-07-16 05:18 jordi
+
+ * System.Windows.Forms.dll.sources: add ImageList,
+ ImageListStreamer, and ColorDepth to the build process
+
+2004-07-15 03:38 jordi
+
+ * System.Windows.Forms.dll.sources: Horizontal and Vertical
+ TrackBar control implementation
+
+2004-07-13 09:33 jordi
+
+ * System.Windows.Forms.dll.sources: vertical and hort. classes
+ commit
+
+2004-07-08 23:21 pbartok
+
+ * Makefile, README, System.Windows.Forms.dll.sources:
+ - Initial check-in
+
diff --git a/mcs/class/Managed.Windows.Forms/Design b/mcs/class/Managed.Windows.Forms/Design
new file mode 100644
index 00000000000..c9fa450d553
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Design
@@ -0,0 +1,84 @@
+ Design of new implementation of SWF
+ ===================================
+
+0. About SWF:
+=============
+
+SWF stands for System.Windows.Forms. This is a class library that
+provides a set of controls for designing application UI.
+
+
+1. Architecture:
+================
+
+The new implementation of SWF is based on drivers providing access to
+the native windowing system of the host OS. The old implementation was
+based on Wine library. The motivation for new implementation comes from
+the problems faced with the Wine approach:
+- Wine was missing features that .NET provided over Win32; to add those
+ features we would have had to write the controls managed anyway
+- Installation became much more difficult due to the Wine dependencies
+ and the relatively akward way we had to initialize Wine.
+
+The new implementation takes advantage of Win32 APIs on Windows and
+emulates the same on Linux using X11 for window management and events.
+Following gives a high level idea of the new implementation of SWF.
+
+ -------------------------------------
+ | Managed SWF |
+ -------------------------------------
+ | XplatUI Driver Interface |
+ -------------------------------------
+ | X11 Driver|Win32 Driver|OSX Driver|
+ | | | |
+ | Mono on | Mono on | Mono on |
+ | Linux/Mac | Windows | Mac OS/X |
+ -------------------------------------
+
+The above picture explains how the window management is done in the new
+implementation. For drawing the controls System.Drawing library is used.
+To handle some special needs for different platforms, there are a few
+limited patches to System.Drawing to deal with calls from System.Windows.Forms
+
+
+2. Design:
+==========
+
+The new design of SWF makes porting of the library to Linux/Windows/Mac
+very easy.
+All the controls in SWF inherit from Control class and most of the painting
+operations are done using ControlPaint class. At the low level, XplatUI class
+provides the abstraction over the underlying window management system. It
+contains a XplatUIDriver for providing the window management. XplatUIDriver
+is an abstract class which is implemented by XplatX11 and XplatWin32 classes
+respectively for Linux/Mac and Windows platforms. Support for any new platform
+can be added simply by implementing XplatUIDriver for the new platform.
+
+
+2b. Themes:
+===========
+
+The look of any control is supposed to be controlled by the chosen theme.
+All control drawing needs to be done by the currently selected theme class.
+The ThemeEngine class manages the themes. All the themes implement
+Theme abstract class. The Theme class provides the drawing primitives for
+all controls. The current implementation supports the Windows Classic theme
+through the ThemeWin32Classic class and the Gnome theme through the ThemeGtk
+class. Gnome support is still very incomplete (even more incomplete than SWF
+itself)
+
+
+2c. Multi-threading:
+====================
+
+ As of this writing, multi-threading was fully supported, provided the
+ standard Microsoft implementation guidelines involving Invoke() are
+ followed.
+
+
+
+2d. Issues:
+===========
+
+ - To be added when MWF reaches completion
+
diff --git a/mcs/class/Managed.Windows.Forms/Guidelines b/mcs/class/Managed.Windows.Forms/Guidelines
new file mode 100644
index 00000000000..967ef6c7f6d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Guidelines
@@ -0,0 +1,58 @@
+ Guidelines for hacking SWF
+ ==========================
+
+This document describes some of the minimal coding guidelines
+to be followed while hacking the new SWF implementation. These
+guidelines are for the sake of consistency.
+
+1. Please refer to the design document of SWF to understand the
+ implementation.
+
+2. Please follow the general coding style described for the Mono
+ project (/cvs/mcs/class/README).
+
+3. Method stubbing is highly discouraged. It's recommended to submit
+ an implemented method instead of just the signature. If you have
+ to stub a property or method, please use the [MonoTODO ("what")]
+ attribute to document what still needs to be done.
+
+4. When you implement the drawing method for a control in a theme, it
+ should make call to ControlPaint class methods and System.Drawing
+ classes. If it is not possible to implement a control's draw method
+ under these restrictions and you need some functionality from
+ XplatUIDriver, please let us know. We will try to enhance the
+ driver, if *really* required.
+
+5. Minimize redraws as much as possible by utilizing the clipRectangle
+ when possible.
+
+6. Setting the size of a control raises a resize event even if the
+ control size is same. Be careful is setting the size and it's better
+ to avoid changing the control size as much as possible. Wherever
+ possible try scaling the control bitmap as per the size needs.
+
+7. Make sure to call the base class event methods when overriding them.
+
+8. Define regions in your code, as it makes it easy to browse the code
+ in the editors which can collapse/expand regions. Also, keep the
+ methods and properties sorted alphabetically.
+
+9. Last but not the least, please let others on the mono-winforms-list
+ know about your work, so that duplication can be avoided.
+
+10. Theme.cs provides Pen and Brush caching. This allows to share
+ the same brushes and pens between different controls and also to avoid
+ to create and destroy them in every draw operation. You should not create
+ Brushes or Pens directly, you should ask the Resource Pool for them. For
+ example, instead of:
+
+ new SolidBrush(button.BackColor);
+
+ you should use:
+
+ ResPool.GetSolidBrush (button.BackColor);
+
+ Look at SystemResPool class for more details.
+
+Happy hacking!
+
diff --git a/mcs/class/Managed.Windows.Forms/M.gif b/mcs/class/Managed.Windows.Forms/M.gif
new file mode 100644
index 00000000000..0199c2b8489
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/M.gif
Binary files differ
diff --git a/mcs/class/Managed.Windows.Forms/Makefile b/mcs/class/Managed.Windows.Forms/Makefile
new file mode 100644
index 00000000000..b4d88f5b59f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Makefile
@@ -0,0 +1,56 @@
+thisdir = class/Managed.Windows.Forms
+include ../../build/rules.make
+
+LIBRARY = System.Windows.Forms.dll
+
+# UTF-8
+CODEPAGE = 65001
+
+LIB_MCS_FLAGS = /unsafe \
+ /r:$(corlib) /r:System.dll /r:System.Xml.dll \
+ /r:System.Drawing.dll /r:Accessibility.dll \
+ /r:System.Data.dll /r:Mono.Posix.dll \
+ @System.Windows.Forms.dll.resources \
+ /nowarn:649 /nowarn:169 /nowarn:67 /nowarn:108 /nowarn:114 -debug
+
+RESX_RESOURCES = \
+ resources/System.Windows.Forms.resources \
+ resources/System.Windows.Forms.en.resources \
+ resources/System.Windows.Forms.de.resources \
+ resources/keyboards.resources
+
+CUR_RESOURCES = \
+ resources/SplitterNS.cur \
+ resources/SplitterWE.cur \
+ resources/DnDNo.cur \
+ resources/DnDCopy.cur \
+ resources/DnDLink.cur \
+ resources/DnDMove.cur
+
+RESOURCES = $(RESX_RESOURCES) $(CUR_RESOURCES)
+
+PREBUILT = $(RESX_RESOURCES:=.prebuilt)
+
+EXTRA_DISTFILES = \
+ README System.Windows.Forms.dll.resources \
+ $(RESX_RESOURCES:.resources=.resx) $(CUR_RESOURCES) $(PREBUILT) build-csproj \
+ Test/resources/a.cur
+
+TEST_MCS_FLAGS = /r:System.Drawing.dll -resource:Test/resources/a.cur,a.cur
+
+SWF.csproj: System.Windows.Forms.dll.sources
+ ./build-csproj
+
+include ../../build/library.make
+
+$(the_lib): $(RESOURCES) SWF.csproj
+
+$(RESX_RESOURCES): %.resources: %.resx
+ $(RESGEN) $< || cp $@.prebuilt $@
+
+$(LIBRARY): $(CUR_RESOURCES)
+
+$(PREBUILT): %.prebuilt: %
+ cp $* $@
+
+dist-default: $(PREBUILT)
diff --git a/mcs/class/Managed.Windows.Forms/Notes b/mcs/class/Managed.Windows.Forms/Notes
new file mode 100644
index 00000000000..35e60254400
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Notes
@@ -0,0 +1,17 @@
+ Random things to look out for when writing or using
+ code in Managed.Windows.Forms
+===========================================================================
+
+* Don't do anything that causes the <control>.DeviceContext to be recreated
+ when inside the drawing routine. Chances are the drawing routine was
+ passed <control>.DeviceContext. If an event, for example a resize, that
+ causes <control>.DeviceContext to be recreated, is initiated by the
+ drawing function, the Graphics object passed to it will no longer be valid.
+ Remember that resizing a control results in recreating <control>.DeviceContext
+ and this in turn results in destroying the old <control>.DeviceContext.
+
+* If you're implementing a theme and you need to know about certain states
+ of the control, you have to access the internal variables of the control
+ to get those states. We should probably expose those vars that are used
+ by themes as properties. We'll watch which are needed and 'propertyize'
+ them.
diff --git a/mcs/class/Managed.Windows.Forms/README b/mcs/class/Managed.Windows.Forms/README
new file mode 100644
index 00000000000..d47315aeab8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/README
@@ -0,0 +1,48 @@
+Managed.Windows.Forms README
+$Revision: 1.2 $
+
+* Introduction
+
+Managed.Windows.Forms is a managed implementation of System.Windows.Forms.
+It implements a driver interface to allow running on multiple windowing systems,
+for example X11 or Windows. All controls are implemented in managed code,
+using System.Drawing to draw them.
+
+
+* Status
+
+This library is in pre-alpha state. Development is still in the very early
+stages. Bug reports are welcome, provided they don't just point out missing
+classes. Please use http://bugzilla.ximian.com/
+
+
+* Contributions
+
+No contributions providing only stubs will be accepted at this time. We ask
+that you submit contributions for review before committing them, our goal is
+to have a consistent and complete implementation, ideally having most or all
+methods and properties of a class written by the same author. This will ensure
+a certain degree of consistency in the code. Please also check the
+'Guidelines' file.
+
+
+The core team for Managed.Windows.Forms currently are:
+ Jordi Mas i Hernandez (jordi@ximian.com)
+ Jackson Harper (jackson@ximian.com)
+ Peter Bartok (pbartok@novell.com)
+
+The Mac OS/X driver implementation is currently being done by:
+ Geoff Norton (gnorton@customerdna.com)
+
+
+* Mailing List
+
+There is a mailing list dedicated to Mono's System.Windows.Forms
+implementation, mono-winforms-list, see
+http://lists.ximian.com/mailman/listinfo/mono-winforms-list
+
+
+* To run System.Windows.Forms Applications
+
+You should use the old Wine-based implementation until this library is
+more functional and reaches beta-stage.
diff --git a/mcs/class/Managed.Windows.Forms/SWF.csproj b/mcs/class/Managed.Windows.Forms/SWF.csproj
new file mode 100644
index 00000000000..a57b8fa0d60
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/SWF.csproj
@@ -0,0 +1,2081 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{5E6430B2-6B9F-4E76-802E-20207EF80391}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "System.Windows.Forms"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Library"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = ""
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = ""
+ 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 = "false"
+ OutputPath = "bin\Release\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "1"
+ />
+ </Settings>
+ <References>
+ <Reference
+ Name = "Accessibility"
+ AssemblyName = "Accessibility"
+ HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Accessibility.dll"
+ />
+ <Reference
+ Name = "System"
+ AssemblyName = "System"
+ HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
+ />
+ <Reference
+ Name = "System.Drawing"
+ AssemblyName = "System.Drawing"
+ HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Drawing.dll"
+ />
+ <Reference
+ Name = "System.XML"
+ AssemblyName = "System.XML"
+ HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "..\..\build\common\Consts.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Assembly\Locale.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Resources\ResXNullRef.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Resources\ResXFileRef.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Resources\ResXResourceReader.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Resources\ResXResourceSet.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Resources\ResXResourceWriter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.Design\ComponentEditorForm.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.Design\ComponentEditorPage.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.Design\EventsTab.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.Design\IUIService.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.Design\IWindowsFormsEditorService.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.Design\PropertyTab.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.Design\WindowsFormsComponentEditor.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\AccessibleEvents.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\AccessibleNavigation.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\AccessibleObject.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\AccessibleRole.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\AccessibleSelection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\AccessibleStates.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\AmbientProperties.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\AnchorStyles.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Appearance.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Application.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ApplicationContext.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ArrangeDirection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ArrangeStartingPosition.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\AsyncMethodData.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\AsyncMethodResult.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\AxHost.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\BaseCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\BindingContext.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Binding.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\BindingManagerBase.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\BindingMemberInfo.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\BindingsCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\BootMode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Border3DSide.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Border3DStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\BorderStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\BoundsSpecified.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Button.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ButtonBase.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ButtonBorderStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ButtonState.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\CaptionButton.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\CategoryGridEntry.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\CharacterCasing.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\CheckBox.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\CheckedListBox.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\CheckState.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ColorDepth.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Clipboard.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ColorDialog.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ColumnClickEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ColumnClickEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ColumnHeader.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ColumnHeaderStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ComboBox.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ComboBoxStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\CommonDialog.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ComponentModel.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ContainerControl.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ContentsResizedEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ContentsResizedEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ContextMenu.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Control.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ControlBindingsCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ControlEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ControlEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ControlPaint.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ControlStyles.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ConvertEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ConvertEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\CreateParams.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\CurrencyManager.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Cursor.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\CursorConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Cursors.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DataFormats.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DataGrid.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DataGridDrawingLogic.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DataGridBoolColumn.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DataGridCell.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DataGridColumnStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DataGridLineStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DataGridParentRowsLabelStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DataGridPreferredColumnWidthTypeConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DataGridTableStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DataGridTextBox.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DataGridTextBoxColumn.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DataObject.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DateBoldEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DateBoldEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DateRangeEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DateRangeEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DateTimePicker.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DateTimePickerFormat.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Day.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DialogResult.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DockStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DomainUpDown.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DragAction.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DragDropEffects.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DragEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DragEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DrawItemEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DrawItemEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DrawItemState.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\DrawMode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ErrorBlinkStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ErrorIconAlignment.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ErrorProvider.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\FeatureSupport.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\FlatStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\FontDialog.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\FileDialog.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\FolderBrowserDialog.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Form.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\FormBorderStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\FormStartPosition.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\FormWindowState.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\FrameStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\GiveFeedbackEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\GiveFeedbackEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\GridColumnStylesCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\GridTablesFactory.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\GridTableStylesCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\GridEntry.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\GridItem.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\GridItemCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\GridItemType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\GroupBox.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Help.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\HelpEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\HelpEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\HelpNavigator.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\HelpProvider.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\HorizontalAlignment.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\HScrollBar.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Hwnd.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\IButtonControl.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ICommandExecutor.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\IComponentEditorPageSite.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\IContainerControl.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\IDataGridColumnStyleEditingNotificationService.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\IDataGridEditingService.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\IDataObject.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\IFeatureSupport.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\IFileReaderService.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ImageIndexConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ImageList.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ImageListConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ImageListStreamer.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ImeMode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\IMessageFilter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\InputLanguageChangedEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\InputLanguageChangedEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\InputLanguageChangingEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\InputLanguageChangingEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\InputLanguageCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\InputLanguage.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\InvalidateEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\InvalidateEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\IRootGridEntry.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ItemActivation.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ItemBoundsPortion.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ItemChangedEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ItemChangedEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ItemCheckEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ItemCheckEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ItemDragEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ItemDragEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\IWin32Window.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\IWindowTarget.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\KeyboardLayouts.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\KeyEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\KeyEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\KeyPressEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\KeyPressEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Keys.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\KeysConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Label.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\LabelEditEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\LabelEditEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\LayoutEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\LayoutEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\LeftRightAlignment.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\LinkArea.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\LinkBehavior.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\LinkClickedEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\LinkClickedEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\LinkLabel.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\LinkLabelLinkClickedEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\LinkLabelLinkClickedEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\LinkState.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ListBindingConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ListBox.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ListControl.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ListView.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ListViewAlignment.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ListViewItem.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ListViewItemConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MainMenu.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MdiChildContext.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MdiClient.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MdiLayout.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MeasureItemEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MeasureItemEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MenuGlyph.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Menu.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MenuAPI.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MenuItem.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MenuMerge.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MessageBoxButtons.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MessageBox.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MessageBoxDefaultButton.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MessageBoxIcon.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MessageBoxOptions.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Message.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MethodInvoker.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Mime.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MimeGenerated.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MimeIcon.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MonthCalendar.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MouseButtons.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MouseEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MouseEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MWFCategoryAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\MWFDescriptionAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\NativeWindow.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\NavigateEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\NavigateEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\NumericUpDown.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\NodeLabelEditEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\NodeLabelEditEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\NotifyIcon.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\OpacityConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\OpenFileDialog.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\OpenTreeNodeEnumerator.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Orientation.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\OSFeature.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\OSXStructs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\OwnerDrawPropertyBag.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\PaintEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\PaintEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Panel.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\PictureBox.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\PictureBoxSizeMode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ProgressBar.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\PropertiesTab.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\PropertyGrid.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\PropertyGridCommands.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\PropertyGridEntry.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\PropertyGridTextBox.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\PropertyGridView.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\PropertyManager.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\PropertySort.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\PropertyTabChangedEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\PropertyTabChangedEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\PropertyValueChangedEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\PropertyValueChangedEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\QueryAccessibilityHelpEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\QueryAccessibilityHelpEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\QueryContinueDragEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\QueryContinueDragEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\RadioButton.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\RichTextBox.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\RichTextBoxFinds.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\RichTextBoxScrollBars.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\RichTextBoxSelectionAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\RichTextBoxSelectionTypes.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\RichTextBoxStreamType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\RichTextBoxWordPunctuations.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\RightToLeft.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\SaveFileDialog.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Screen.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ScrollableControl.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ScrollBar.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ScrollBars.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ScrollButton.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ScrollEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ScrollEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ScrollEventType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\SecurityIDType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\SelectedGridItemChangedEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\SelectedGridItemChangedEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\SelectionRange.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\SelectionRangeConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\SelectionMode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\SendKeys.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Shortcut.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\SizeGrip.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\SizeGripStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\SortOrder.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Splitter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\SplitterEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\SplitterEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\StatusBar.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\StatusBarDrawItemEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\StatusBarDrawItemEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\StatusBarPanelAutoSize.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\StatusBarPanelBorderStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\StatusBarPanelClickEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\StatusBarPanelClickEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\StatusBarPanel.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\StatusBarPanelStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\StructFormat.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\SystemInformation.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TabAlignment.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TabAppearance.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TabControl.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TabDrawMode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TabPage.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TabSizeMode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TextBox.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TextBoxBase.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TextControl.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Theme.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ThemeEngine.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ThemeGtk.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ThemeNice.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ThemeWin32Classic.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ThreadExceptionDialog.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TickStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Timer.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "..\..\build\common\MonoTODOAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ToolBarAppearance.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ToolBarButtonClickEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ToolBarButtonClickEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ToolBarButton.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ToolBarButtonStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ToolBar.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ToolBarTextAlign.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\ToolTip.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TrackBar.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TreeNode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TreeNodeCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TreeNodeConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TreeView.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TreeViewAction.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TreeViewCancelEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TreeViewCancelEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TreeViewEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TreeViewEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\TreeViewImageIndexConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\UICues.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\UICuesEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\UICuesEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\UpDownBase.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\UpDownEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\UpDownEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\UserControl.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\View.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\VScrollBar.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\Win32DnD.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\X11DesktopColors.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\X11Dnd.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\X11Structs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\X11Keyboard.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\XEventQueue.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\XplatUI.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\XplatUIDriver.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\XplatUIOSX.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\XplatUIStructs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\XplatUIWin32.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms\XplatUIX11.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\Charcode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\Charset.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\CharsetFlags.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\CharsetType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\ClassDelegate.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\Color.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\DestinationDelegate.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\Font.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\KeysInit.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\KeyStruct.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\Major.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\Minor.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\RTF.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\RTFException.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\StandardCharCode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\StandardCharName.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\Style.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\StyleElement.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\StyleType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\TextMap.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Windows.Forms.RTF\TokenClass.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = ""
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "resources\System.Windows.Forms.resources"
+ BuildAction = "EmbeddedResource"
+ />
+ <File
+ RelPath = "resources\System.Windows.Forms.en.resources"
+ BuildAction = "EmbeddedResource"
+ />
+ <File
+ RelPath = "resources\System.Windows.Forms.de.resources"
+ BuildAction = "EmbeddedResource"
+ />
+ <File
+ RelPath = "resources\SplitterNS.cur"
+ CustomToolNameSpace = "System.Windows.Forms.SplitterNS.cur"
+ BuildAction = "EmbeddedResource"
+ />
+ <File
+ RelPath = "resources\SplitterWE.cur"
+ CustomToolNameSpace = "System.Windows.Forms.SplitterWE.cur"
+ BuildAction = "EmbeddedResource"
+ />
+ <File
+ RelPath = "resources\DnDNo.cur"
+ CustomToolNameSpace = "System.Windows.Forms.DnDNo.cur"
+ BuildAction = "EmbeddedResource"
+ />
+ <File
+ RelPath = "resources\DnDCopy.cur"
+ CustomToolNameSpace = "System.Windows.Forms.DnDCopy.cur"
+ BuildAction = "EmbeddedResource"
+ />
+ <File
+ RelPath = "resources\DnDLink.cur"
+ CustomToolNameSpace = "System.Windows.Forms.DnDLink.cur"
+ BuildAction = "EmbeddedResource"
+ />
+ <File
+ RelPath = "resources\DnDMove.cur"
+ CustomToolNameSpace = "System.Windows.Forms.DnDMove.cur"
+ BuildAction = "EmbeddedResource"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
diff --git a/mcs/class/Managed.Windows.Forms/SWF.sln b/mcs/class/Managed.Windows.Forms/SWF.sln
new file mode 100644
index 00000000000..f8a03830319
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/SWF.sln
@@ -0,0 +1,21 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SWF", "SWF.csproj", "{5E6430B2-6B9F-4E76-802E-20207EF80391}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {5E6430B2-6B9F-4E76-802E-20207EF80391}.Debug.ActiveCfg = Debug|.NET
+ {5E6430B2-6B9F-4E76-802E-20207EF80391}.Debug.Build.0 = Debug|.NET
+ {5E6430B2-6B9F-4E76-802E-20207EF80391}.Release.ActiveCfg = Release|.NET
+ {5E6430B2-6B9F-4E76-802E-20207EF80391}.Release.Build.0 = Release|.NET
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/mcs/class/Managed.Windows.Forms/System.Resources/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Resources/ChangeLog
new file mode 100644
index 00000000000..85dabec3c7a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Resources/ChangeLog
@@ -0,0 +1,106 @@
+2006-01-14 Robert Jordan <robertj@gmx.net>
+
+ * ResXResourceReader.cs: Fix for bug #77253. Thanks to Marek Habersack
+ (grendello@gmail.com).
+
+2005-12-05 Peter Bartok <pbartok@novell.com>
+
+ * ResXResourceReader.cs: Removed previous patch. More than just Byte[]
+ has that mime type and the patch was causing things to fail.
+ Since our writer no longer emits the mimetype this should be fine.
+
+2005-12-01 Robert Jordan <robertj@gmx.net>
+
+ * ResXResourceReader.cs: Handle mimetype="application/x-microsoft.net.object.bytearray.base64" correctly. Fixes the decoding of System.Byte[].
+ * ResXResourceWriter.cs: Fixed AddResource (string, object) to pass
+ control to AddResource (string, byte[]) if the value parameter is
+ a byte[]. Removed the emitting of the mimetype attribute for
+ System.Byte[].
+
+2005-11-30 Peter Bartok <pbartok@novell.com>
+
+ * ResXResourceReader.cs: Handle System.Byte[] encodings without
+ needing a typeconverter (This fixes bug #76414)
+
+2005-11-30 Robert Jordan <robertj@gmx.net>
+
+ * ResXResourceReader.cs, ResXResourceWriter.cs: Made string conversions
+ culture-invariant.
+ * ResXResourceWriter.cs: Fixed AddResource (string, object) to emit
+ the type attribute when the object has a type converter.
+
+2005-10-04 Peter Bartok <pbartok@novell.com>
+
+ * ResXResourceReader.cs, ResXResourceWriter.cs: Added call
+ to GC.SuppressFinalize() in dispose method. Fixes #76330
+
+2005-05-13 Peter Bartok <pbartok@novell.com>
+
+ * ResXResourceWriter.cs:
+ - Fixed/Improved AddResource(), now only uses string converter if
+ the converter supports both directions
+ - Added ability for AddResource(string, object) to detect if
+ a byte[] converter is supported for the object, if so it now calls
+ AddResource(string, byte[]) for those
+ - WriteBytes: Changed to write it's base64 output as pretty
+ as Microsoft's, inserting newlines every 80 chars
+ - WriteBytes: Added output of mimetype even if type is specified
+
+2005-05-11 Peter Bartok <pbartok@novell.com>
+
+ * ResXResourceSet.cs: Implemented
+ * ResXFileRef.cs: Implemented
+ * ResXNullRef.cs: Added missing attribute
+ * ResXResourceReader.cs: Implemented missing .ctor()s and other
+ assorted fun stuff, should now be complete
+ * ResResourceWriter.cs: Implemented missing methods and added
+ missing static fields
+
+2005-04-14 Jackson Harper <jackson@ximian.com>
+
+ * ResXResourceReader.cs: Use serialization on values that have a
+ mime type set but no type.
+
+2005-02-16 Peter Bartok <pbartok@novell.com>
+
+ * ResXResourceReader.cs, ResXResourceWriter.cs: Removed sealed
+ attribute from classes
+
+2005-02-12 Geoff Norton (gnorton@customerdna.com)
+
+ * ResXResourceReader.cs (load_data): Undo previous change as
+ ResXNullRef is now properly handled.
+ * ResXNullRef.cs: Added
+
+2005-02-11 Geoff Norton (gnorton@customerdna.com)
+
+ * ResXResourceReader.cs (load_data): Temporarily re-introduce the
+ old failure for types that we cannot yet handle to allow Npgsql to
+ build.
+
+2005-02-11 Raja R Harinath <rharinath@novell.com>
+
+ * ResXResourceReader.cs (load_data): Make exception more informative.
+
+2005-02-10 Geoff Norton <gnorton@customerdna.com>
+
+ * ResXResourceReader.cs: Implement the ability to convert the
+ MS Base64 encoded objects. Implement the ability to convert objects
+ to their type rather than just to string.
+
+2004-11-08 14:28 pbartok
+
+ * ResXResourceReader.cs:
+ - BenM's Fix for bug 68260
+
+2004-10-13 08:14 pbartok
+
+ * ResXResourceReader.cs:
+ - Patch by joel.reed@ddiworld.com (joel) to handle CDATA sections.
+
+2004-08-29 22:36 pbartok
+
+ * ResXResourceReader.cs, ResXResourceWriter.cs:
+ - Transfered files from previous version of System.Windows.Forms
+ - Added full copyright header
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Resources/ResXFileRef.cs b/mcs/class/Managed.Windows.Forms/System.Resources/ResXFileRef.cs
new file mode 100644
index 00000000000..52081d265da
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Resources/ResXFileRef.cs
@@ -0,0 +1,105 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+using System;
+using System.ComponentModel;
+using System.IO;
+using System.Reflection;
+
+namespace System.Resources {
+ [Serializable]
+ [TypeConverter(typeof(ResXFileRef.Converter))]
+ public class ResXFileRef {
+ #region Converter Class
+ public class Converter : TypeConverter {
+ #region Constructors
+ public Converter() {
+ }
+ #endregion // Constructors
+
+ #region Methods
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
+ return sourceType == typeof(string);
+ }
+
+ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) {
+ return destinationType == typeof(string);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+ string[] parts;
+ byte[] buffer;
+
+ if ( !(value is String)) {
+ return base.ConvertFrom(context, culture, value);
+ }
+
+ parts = ((string)value).Split(';');
+
+ using (FileStream file = new FileStream(parts[0], FileMode.Open, FileAccess.Read, FileShare.Read)) {
+ buffer = new byte[file.Length];
+
+ file.Read(buffer, 0, (int)file.Length);
+ }
+
+ return Activator.CreateInstance(Type.GetType(parts[1]), BindingFlags.CreateInstance | BindingFlags.Public | BindingFlags.Instance, null, new object[] { new MemoryStream(buffer) }, culture);
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) {
+ if (destinationType != typeof(String)) {
+ return base.ConvertTo (context, culture, value, destinationType);
+ }
+
+ return ((ResXFileRef)value).ToString();
+ }
+ #endregion // Methods
+ }
+ #endregion // Converter Class
+
+ #region Local Variables
+ private string filename;
+ private string typename;
+ #endregion // Local Variables
+
+ #region Public Constructors
+ public ResXFileRef(string fileName, string typeName) {
+ this.filename = fileName;
+ this.typename = typeName;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public override string ToString() {
+ return filename + ";" + typename;
+ }
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Resources/ResXNullRef.cs b/mcs/class/Managed.Windows.Forms/System.Resources/ResXNullRef.cs
new file mode 100644
index 00000000000..d172feccea9
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Resources/ResXNullRef.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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.
+//
+// Authors:
+// Geoff Norton gnorton@customerdna.com
+//
+
+using System;
+
+namespace System.Resources
+{
+ [Serializable]
+ internal class ResXNullRef
+ {
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceReader.cs b/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceReader.cs
new file mode 100644
index 00000000000..592f6ee5ffc
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceReader.cs
@@ -0,0 +1,300 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Duncan Mak duncan@ximian.com
+// Nick Drochak ndrochak@gol.com
+// Paolo Molaro lupus@ximian.com
+// Peter Bartok pbartok@novell.com
+//
+
+// COMPLETE
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Globalization;
+using System.IO;
+using System.Resources;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Xml;
+
+namespace System.Resources
+{
+ public class ResXResourceReader : IResourceReader, IDisposable
+ {
+ #region Local Variables
+ private Stream stream;
+ private XmlTextReader reader;
+ private Hashtable hasht;
+ private ITypeResolutionService typeresolver;
+ #endregion // Local Variables
+
+ #region Constructors & Destructor
+ public ResXResourceReader (Stream stream)
+ {
+ if (stream == null)
+ throw new ArgumentNullException ("Value cannot be null.");
+
+ if (!stream.CanRead)
+ throw new ArgumentException ("Stream was not readable.");
+
+ this.stream = stream;
+ basic_setup ();
+ }
+
+ public ResXResourceReader (Stream stream, ITypeResolutionService typeresolver) : this(stream) {
+ this.typeresolver = typeresolver;
+ }
+
+ public ResXResourceReader (string fileName)
+ {
+ stream = File.OpenRead (fileName);
+ basic_setup ();
+ }
+
+ public ResXResourceReader (string fileName, ITypeResolutionService typeresolver) : this(fileName) {
+ this.typeresolver = typeresolver;
+ }
+
+ public ResXResourceReader(TextReader reader) {
+ this.reader = new XmlTextReader(reader);
+ this.hasht = new Hashtable();
+
+ load_data();
+ }
+
+ public ResXResourceReader (TextReader reader, ITypeResolutionService typeresolver) : this(reader) {
+ this.typeresolver = typeresolver;
+ }
+
+ ~ResXResourceReader() {
+ Dispose(false);
+ }
+ #endregion // Constructors & Destructor
+
+
+ #region Private Methods
+ void basic_setup () {
+ reader = new XmlTextReader (stream);
+ hasht = new Hashtable ();
+
+ if (!IsStreamValid()){
+ throw new ArgumentException("Stream is not a valid .resx file! It was possibly truncated.");
+ }
+ load_data ();
+ }
+
+ static string get_attr (XmlTextReader reader, string name) {
+ if (!reader.HasAttributes)
+ return null;
+ for (int i = 0; i < reader.AttributeCount; i++) {
+ reader.MoveToAttribute (i);
+ if (String.Compare (reader.Name, name, true) == 0) {
+ string v = reader.Value;
+ reader.MoveToElement ();
+ return v;
+ }
+ }
+ reader.MoveToElement ();
+ return null;
+ }
+
+
+ static string get_value (XmlTextReader reader, string name)
+ {
+ return get_value (reader, name, true);
+ }
+
+ // Returns the value of the next XML element with the specified
+ // name from the reader. canBeCdata == true specifies that
+ // the element may be a CDATA node as well.
+ static string get_value (XmlTextReader reader, string name, bool canBeCdata) {
+ bool gotelement = false;
+ while (reader.Read ()) {
+ if (reader.NodeType == XmlNodeType.Element && String.Compare (reader.Name, name, true) == 0) {
+ gotelement = true;
+ break;
+ }
+ if (canBeCdata && reader.NodeType == XmlNodeType.CDATA)
+ return reader.Value;
+ }
+ if (!gotelement)
+ return null;
+ while (reader.Read ()) {
+ if (reader.NodeType == XmlNodeType.Text || reader.NodeType == XmlNodeType.CDATA) {
+ string v = reader.Value;
+ return v;
+ }
+ else if (reader.NodeType == XmlNodeType.EndElement && reader.Value == string.Empty)
+ {
+ string v = reader.Value;
+ return v;
+ }
+ }
+ return null;
+ }
+
+ private bool IsStreamValid() {
+ bool gotroot = false;
+ bool gotmime = false;
+
+ while (reader.Read ()) {
+ if (reader.NodeType == XmlNodeType.Element && String.Compare (reader.Name, "root", true) == 0) {
+ gotroot = true;
+ break;
+ }
+ }
+ if (!gotroot)
+ return false;
+ while (reader.Read ()) {
+ if (reader.NodeType == XmlNodeType.Element && String.Compare (reader.Name, "resheader", true) == 0) {
+ string v = get_attr (reader, "name");
+ if (v != null && String.Compare (v, "resmimetype", true) == 0) {
+ v = get_value (reader, "value");
+ if (String.Compare (v, "text/microsoft-resx", true) == 0) {
+ gotmime = true;
+ break;
+ }
+ }
+ } else if (reader.NodeType == XmlNodeType.Element && String.Compare (reader.Name, "data", true) == 0) {
+ /* resheader apparently can appear anywhere, so we collect
+ * the data even if we haven't validated yet.
+ */
+ string n = get_attr (reader, "name");
+ if (n != null) {
+ string v = get_value (reader, "value");
+ hasht [n] = v;
+ }
+ }
+ }
+ return gotmime;
+ }
+
+ private void load_data ()
+ {
+ while (reader.Read ()) {
+ if (reader.NodeType == XmlNodeType.Element && String.Compare (reader.Name, "data", true) == 0) {
+ string n = get_attr (reader, "name");
+ string t = get_attr (reader, "type");
+ string mt = get_attr (reader, "mimetype");
+
+ Type tt = t == null ? null : Type.GetType (t);
+
+ if (t != null && tt == null) {
+ throw new SystemException ("The type `" + t +"' could not be resolved");
+ }
+ if (tt == typeof (ResXNullRef)) {
+ hasht [n] = null;
+ continue;
+ }
+ if (n != null) {
+ object v = null;
+ string val = get_value (reader, "value");
+
+ if (mt != null && tt != null) {
+ TypeConverter c = TypeDescriptor.GetConverter (tt);
+ v = c.ConvertFrom (Convert.FromBase64String (val));
+ } else if (tt != null) {
+ // MS seems to handle Byte[] without any mimetype :-(
+ if (t.StartsWith("System.Byte[], mscorlib")) {
+ v = Convert.FromBase64String(val);
+ } else {
+ TypeConverter c = TypeDescriptor.GetConverter (tt);
+ v = c.ConvertFromInvariantString (val);
+ }
+ } else if (mt != null) {
+ byte [] data = Convert.FromBase64String (val);
+ BinaryFormatter f = new BinaryFormatter ();
+ using (MemoryStream s = new MemoryStream (data)) {
+ v = f.Deserialize (s);
+ }
+ } else {
+ v = val;
+ }
+ hasht [n] = v;
+ }
+ }
+ }
+ }
+
+ private Type GetType(string type) {
+ if (typeresolver == null) {
+ return Type.GetType(type);
+ } else {
+ return typeresolver.GetType(type);
+ }
+ }
+ #endregion // Private Methods
+
+ #region Public Methods
+ public void Close ()
+ {
+ if (stream != null) {
+ stream.Close ();
+ stream = null;
+ }
+
+ if (reader != null) {
+ reader.Close();
+ reader = null;
+ }
+ }
+
+ public IDictionaryEnumerator GetEnumerator () {
+ if (null == stream){
+ throw new InvalidOperationException("ResourceReader is closed.");
+ }
+ else {
+ return hasht.GetEnumerator ();
+ }
+ }
+
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return ((IResourceReader) this).GetEnumerator();
+ }
+
+ void IDisposable.Dispose ()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing) {
+ if (disposing) {
+ Close();
+ }
+ }
+
+ public static ResXResourceReader FromFileContents(string fileContents) {
+ return new ResXResourceReader(new StringReader(fileContents));
+ }
+
+ public static ResXResourceReader FromFileContents(string fileContents, ITypeResolutionService typeResolver) {
+ return new ResXResourceReader(new StringReader(fileContents), typeResolver);
+ }
+
+ #endregion // Public Methods
+
+ } // public sealed class ResXResourceReader
+} // namespace System.Resources
diff --git a/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceSet.cs b/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceSet.cs
new file mode 100644
index 00000000000..5fc589a41d6
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceSet.cs
@@ -0,0 +1,63 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+using System;
+using System.IO;
+using System.Collections;
+
+namespace System.Resources {
+ public class ResXResourceSet : ResourceSet {
+ #region Local Variables
+
+ #endregion // Local Variables
+
+ #region Public Constructors
+ public ResXResourceSet(Stream stream) {
+ this.Reader = new ResXResourceReader(stream);
+ this.Table = new Hashtable();
+ this.ReadResources();
+ }
+
+ public ResXResourceSet(string fileName) {
+ this.Reader = new ResXResourceReader(fileName);
+ this.Table = new Hashtable();
+ this.ReadResources();
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Methods
+ public override Type GetDefaultReader() {
+ return typeof(ResXResourceReader);
+ }
+
+ public override Type GetDefaultWriter() {
+ return typeof(ResXResourceWriter);
+ }
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceWriter.cs b/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceWriter.cs
new file mode 100644
index 00000000000..76da29c1cef
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Resources/ResXResourceWriter.cs
@@ -0,0 +1,336 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Duncan Mak duncan@ximian.com
+// Gonzalo Paniagua Javier gonzalo@ximian.com
+// Peter Bartok pbartok@novell.com
+//
+
+// COMPLETE
+
+using System.ComponentModel;
+using System.IO;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Text;
+using System.Xml;
+
+namespace System.Resources
+{
+ public class ResXResourceWriter : IResourceWriter, IDisposable
+ {
+ #region Local Variables
+ private string filename;
+ private Stream stream;
+ private TextWriter textwriter;
+ private XmlTextWriter writer;
+ private bool written;
+ #endregion // Local Variables
+
+ #region Static Fields
+ public static readonly string BinSerializedObjectMimeType = "application/x-microsoft.net.object.binary.base64";
+ public static readonly string ByteArraySerializedObjectMimeType = "application/x-microsoft.net.object.bytearray.base64";
+ public static readonly string DefaultSerializedObjectMimeType = BinSerializedObjectMimeType;
+ public static readonly string ResMimeType = "text/microsoft-resx";
+ public static readonly string ResourceSchema = schema;
+ public static readonly string SoapSerializedObjectMimeType = "application/x-microsoft.net.object.soap.base64";
+ public static readonly string Version = "1.3";
+ #endregion // Static Fields
+
+ #region Constructors & Destructor
+ public ResXResourceWriter (Stream stream)
+ {
+ if (stream == null)
+ throw new ArgumentNullException ("stream");
+
+ if (stream.CanWrite == false)
+ throw new ArgumentException ("stream is not writable.", "stream");
+
+ this.stream = stream;
+ }
+
+ public ResXResourceWriter (TextWriter textwriter)
+ {
+ if (textwriter == null)
+ throw new ArgumentNullException ("textwriter");
+
+ this.textwriter = textwriter;
+ }
+
+ public ResXResourceWriter (string fileName)
+ {
+ if (fileName == null)
+ throw new ArgumentNullException ("fileName");
+
+ this.filename = fileName;
+ }
+
+ ~ResXResourceWriter() {
+ Dispose(false);
+ }
+ #endregion // Constructors & Destructor
+
+ void InitWriter ()
+ {
+ if (filename != null) {
+ stream = File.OpenWrite (filename);
+ textwriter = new StreamWriter (stream, Encoding.UTF8);
+ }
+
+ writer = new XmlTextWriter (textwriter);
+ writer.Formatting = Formatting.Indented;
+ writer.WriteStartDocument ();
+ writer.WriteStartElement ("root");
+ writer.WriteRaw (schema);
+ WriteHeader ("resmimetype", "text/microsoft-resx");
+ WriteHeader ("version", "1.3");
+ WriteHeader ("reader", typeof (ResXResourceReader).AssemblyQualifiedName);
+ WriteHeader ("writer", typeof (ResXResourceWriter).AssemblyQualifiedName);
+ }
+
+ void WriteHeader (string name, string value)
+ {
+ writer.WriteStartElement ("resheader");
+ writer.WriteAttributeString ("name", name);
+ writer.WriteStartElement ("value");
+ writer.WriteString (value);
+ writer.WriteEndElement ();
+ writer.WriteEndElement ();
+ }
+
+ void WriteNiceBase64(byte[] value, int offset, int length) {
+ string b64;
+ StringBuilder sb;
+ int pos;
+ int inc;
+ string ins;
+
+ b64 = Convert.ToBase64String(value, offset, length);
+
+ // Wild guess; two extra newlines, and one newline/tab pair for every 80 chars
+ sb = new StringBuilder(b64, b64.Length + ((b64.Length + 160) / 80) * 3);
+ pos = 0;
+ inc = 80 + Environment.NewLine.Length + 1;
+ ins = Environment.NewLine + "\t";
+ while (pos < sb.Length) {
+ sb.Insert(pos, ins);
+ pos += inc;
+ }
+ sb.Insert(sb.Length, Environment.NewLine);
+ writer.WriteString(sb.ToString());
+ }
+
+ void WriteBytes (string name, string typename, byte [] value, int offset, int length)
+ {
+ writer.WriteStartElement ("data");
+ writer.WriteAttributeString ("name", name);
+
+ if (typename != null) {
+ writer.WriteAttributeString ("type", typename);
+ writer.WriteStartElement ("value");
+ WriteNiceBase64(value, offset, length);
+ } else {
+ writer.WriteAttributeString ("mimetype",
+ "application/x-microsoft.net.object.binary.base64");
+ writer.WriteStartElement ("value");
+ writer.WriteBase64 (value, offset, length);
+ }
+
+ writer.WriteEndElement ();
+ writer.WriteEndElement ();
+ }
+
+ void WriteBytes (string name, string typename, byte [] value)
+ {
+ WriteBytes (name, typename, value, 0, value.Length);
+ }
+
+ void WriteString (string name, string value)
+ {
+ WriteString (name, value, null);
+ }
+
+ void WriteString (string name, string value, string typename)
+ {
+ writer.WriteStartElement ("data");
+ writer.WriteAttributeString ("name", name);
+ if (typename != null)
+ writer.WriteAttributeString ("type", typename);
+ writer.WriteStartElement ("value");
+ writer.WriteString (value);
+ writer.WriteEndElement ();
+ writer.WriteEndElement ();
+ writer.WriteWhitespace ("\n ");
+ }
+
+ public void AddResource (string name, byte [] value)
+ {
+ if (name == null)
+ throw new ArgumentNullException ("name");
+
+ if (value == null)
+ throw new ArgumentNullException ("value");
+
+ if (written)
+ throw new InvalidOperationException ("The resource is already generated.");
+
+ if (writer == null)
+ InitWriter ();
+
+ WriteBytes (name, value.GetType ().AssemblyQualifiedName, value);
+ }
+
+ public void AddResource (string name, object value)
+ {
+ if (value is string) {
+ AddResource (name, (string) value);
+ return;
+ }
+
+ if (value is byte[]) {
+ AddResource (name, (byte[]) value);
+ return;
+ }
+
+ if (name == null)
+ throw new ArgumentNullException ("name");
+
+ if (value == null)
+ throw new ArgumentNullException ("value");
+
+ if (written)
+ throw new InvalidOperationException ("The resource is already generated.");
+
+ if (writer == null)
+ InitWriter ();
+
+ TypeConverter converter = TypeDescriptor.GetConverter (value);
+ if (converter != null && converter.CanConvertTo (typeof (string)) && converter.CanConvertFrom (typeof (string))) {
+ string str = (string) converter.ConvertToInvariantString (value);
+ WriteString (name, str, value.GetType ().AssemblyQualifiedName);
+ return;
+ }
+
+ if (converter != null && converter.CanConvertTo (typeof (byte[])) && converter.CanConvertFrom (typeof (byte[]))) {
+ byte[] b = (byte[]) converter.ConvertTo (value, typeof (byte[]));
+ WriteBytes (name, value.GetType().AssemblyQualifiedName, b);
+ return;
+ }
+
+ MemoryStream ms = new MemoryStream ();
+ BinaryFormatter fmt = new BinaryFormatter ();
+ try {
+ fmt.Serialize (ms, value);
+ } catch (Exception e) {
+ throw new InvalidOperationException ("Cannot add a " + value.GetType () +
+ "because it cannot be serialized: " +
+ e.Message);
+ }
+
+ WriteBytes (name, null, ms.GetBuffer (), 0, (int) ms.Length);
+ ms.Close ();
+ }
+
+ public void AddResource (string name, string value)
+ {
+ if (name == null)
+ throw new ArgumentNullException ("name");
+
+ if (value == null)
+ throw new ArgumentNullException ("value");
+
+ if (written)
+ throw new InvalidOperationException ("The resource is already generated.");
+
+ if (writer == null)
+ InitWriter ();
+
+ WriteString (name, value);
+ }
+
+ public void Close ()
+ {
+ if (!written) {
+ Generate ();
+ }
+
+ if (writer != null) {
+ writer.Close ();
+ stream = null;
+ filename = null;
+ textwriter = null;
+ }
+ }
+
+ public void Dispose ()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ public void Generate ()
+ {
+ if (written)
+ throw new InvalidOperationException ("The resource is already generated.");
+
+ written = true;
+ writer.WriteEndElement ();
+ writer.Flush ();
+ }
+
+ protected virtual void Dispose(bool disposing) {
+ if (disposing) {
+ Close();
+ }
+ }
+
+ static string schema = @"
+ <xsd:schema id='root' xmlns='' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'>
+ <xsd:element name='root' msdata:IsDataSet='true'>
+ <xsd:complexType>
+ <xsd:choice maxOccurs='unbounded'>
+ <xsd:element name='data'>
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name='value' type='xsd:string' minOccurs='0' msdata:Ordinal='1' />
+ <xsd:element name='comment' type='xsd:string' minOccurs='0' msdata:Ordinal='2' />
+ </xsd:sequence>
+ <xsd:attribute name='name' type='xsd:string' msdata:Ordinal='1' />
+ <xsd:attribute name='type' type='xsd:string' msdata:Ordinal='3' />
+ <xsd:attribute name='mimetype' type='xsd:string' msdata:Ordinal='4' />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name='resheader'>
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name='value' type='xsd:string' minOccurs='0' msdata:Ordinal='1' />
+ </xsd:sequence>
+ <xsd:attribute name='name' type='xsd:string' use='required' />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+".Replace ("'", "\"");
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/ChangeLog
new file mode 100644
index 00000000000..d836057885a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/ChangeLog
@@ -0,0 +1,81 @@
+2005-12-01 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ComponentEditorForm.cs: Added missing attribute
+
+2005-10-13 Peter Dennis Bartok <pbartok@novell.com>
+
+ * EventsTab.cs: Made .ctor() private to fix signature
+
+2005-05-14 Rafael Teixeira <rafaelteixeirabr@hotmail.com>
+ * EventsTab.cs: Implementation start with many gaping holes
+
+2005-05-09 Marek Safar <marek.safar@seznam.cz>
+
+ * PropertyTab.cs: Implemented.
+
+2005-02-14 Peter Bartok <pbartok@novell.com>
+
+ * PropertyTab.cs: Made class abstract
+
+2004-04-14 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * AssemblyInfo.cs: Removed
+ * TODOAttribute.cs: Removed (duplicate)
+
+ * System.Windows.Forms.Design.csproj.user
+ * System.Windows.Forms.Design.csproj: Removed (outdated)
+
+ * WindowsFormsComponentEditor.cs
+ * ComponentEditorPage.cs: Added, mostly implemented
+
+ * ComponentEditor.cs: Removed (does not belong here)
+
+2004-02-24 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * IWindowsFormsEditorService.cs: Corrected casing,
+ it is not yet corrected in the filename, implemented
+
+2003-08-30 Alexandre Pigolkine <pigolkine@gmx.de>
+
+ * ComponentEditor.cs
+ * IUIService.cs: stubs added
+
+2003-03-31 Alan Tam <Tam@SiuLung.com>
+
+ * UITypeEditor.cs: Removed because it shan't be here
+
+2002-08-04 DennisHayes <dennish@raytek.com>
+
+ * Started cheanglog
+
+2002-08-04 DennisHayes <dennish@raytek.com>
+
+ * AnchorEditor.cs
+ * AxImporter.cs
+ * ComponentDocumentDesigner.cs
+ * ComponentEditorForm.cs: Stubbed out
+
+ * ComponentTray.cs
+ * ControlDesigner.cs
+ * ComponentEditor.cs
+ * DocumentDesigner.cs
+ * EventsTab.cs
+ * FileNameEditor.cs
+ * IMenuEditorService.cs
+ * IUIService.cs
+ * IWindowsformsEditorService.cs
+ * MenusCommands.cs
+ * ParentControlDesigner.cs
+ * PropertyTab.cs
+ * ScrollableControlDesigner.cs
+ * SelectionRules.cs
+ * UITypeEditor.cs: Class body defined only. No stubbs done.
+
+ * TODOAttribute.cs:
+ Used to mark unimplemented functions.
+
+ * System.Windows.Forms.Design.csproj
+ * System.Windows.Forms.Design.csproj.user
+ * AssemblyInfo.cs:
+ Needed for Visual Studio compile.
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/ComponentEditorForm.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/ComponentEditorForm.cs
new file mode 100644
index 00000000000..5221c0a96b4
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/ComponentEditorForm.cs
@@ -0,0 +1,76 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Dennis Hayes (dennish@raytek.com)
+
+// NOT COMPLETE
+
+using System;
+using System.ComponentModel;
+using System.Windows.Forms;
+
+namespace System.Windows.Forms.Design {
+ [ToolboxItem(false)]
+ public class ComponentEditorForm : Form {
+
+ [MonoTODO]
+ public ComponentEditorForm(object component, Type[] pageTypes){
+ }
+
+ [MonoTODO]
+ protected override void OnActivated(EventArgs e){
+ }
+
+ [MonoTODO]
+ protected virtual void OnSelChangeSelector(object source, TreeViewEventArgs e){
+ }
+
+ [MonoTODO]
+ public override bool PreProcessMessage(ref Message msg){
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual DialogResult ShowForm(){
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual DialogResult ShowForm(int page){
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual DialogResult ShowForm(IWin32Window owner){
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual DialogResult ShowForm(IWin32Window owner, int page){
+ throw new NotImplementedException ();
+ }
+ [MonoTODO]
+ // can't override the function in control. bug in compiler. Fixed?
+ protected override void OnHelpRequested(HelpEventArgs e){
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/ComponentEditorPage.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/ComponentEditorPage.cs
new file mode 100644
index 00000000000..e21f225f8eb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/ComponentEditorPage.cs
@@ -0,0 +1,188 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+
+using System.ComponentModel;
+using System.Drawing;
+
+namespace System.Windows.Forms.Design
+{
+ public abstract class ComponentEditorPage : Panel
+ {
+ private bool commitOnDeactivate = false;
+ private IComponent component;
+ private bool firstActivate = true;
+ private Icon icon;
+ private int loading = 0;
+ private bool loadRequired = false;
+ private IComponentEditorPageSite pageSite;
+
+ public ComponentEditorPage ()
+ {
+ }
+
+ public bool CommitOnDeactivate {
+ get { return commitOnDeactivate; }
+ set { commitOnDeactivate = value; }
+ }
+
+ protected IComponent Component {
+ get { return component; }
+ set { component = value; }
+ }
+
+ [MonoTODO ("Find out what this does.")]
+ protected override CreateParams CreateParams {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ protected bool FirstActivate {
+ get { return firstActivate; }
+ set { firstActivate = value; }
+ }
+
+ public Icon Icon {
+ get { return icon; }
+ set { icon = value; }
+ }
+
+ protected int Loading {
+ get { return loading; }
+ set { loading = value; }
+ }
+
+ protected bool LoadRequired {
+ get { return loadRequired; }
+ set { loadRequired = value; }
+ }
+
+ protected IComponentEditorPageSite PageSite {
+ get { return pageSite; }
+ set { pageSite = value; }
+ }
+
+ public virtual string Title {
+ get { return base.Text; }
+ }
+
+ public virtual void Activate ()
+ {
+ Visible = true;
+ firstActivate = false;
+ if (loadRequired) {
+ EnterLoadingMode ();
+ LoadComponent ();
+ ExitLoadingMode ();
+ }
+ }
+
+ public virtual void ApplyChanges ()
+ {
+ SaveComponent ();
+ }
+
+ public virtual void Deactivate ()
+ {
+ Visible = false;
+ }
+
+ protected void EnterLoadingMode ()
+ {
+ loading++;
+ }
+
+ protected void ExitLoadingMode ()
+ {
+ loading--;
+ }
+
+ public virtual Control GetControl ()
+ {
+ return this;
+ }
+
+ protected IComponent GetSelectedComponent ()
+ {
+ return component;
+ }
+
+ protected bool IsFirstActivate ()
+ {
+ return firstActivate;
+ }
+
+ protected bool IsLoading ()
+ {
+ return (loading != 0);
+ }
+
+ public virtual bool IsPageMessage (ref Message msg)
+ {
+ return PreProcessMessage (ref msg);
+ }
+
+ protected abstract void LoadComponent ();
+
+ [MonoTODO ("Find out what this does.")]
+ public virtual void OnApplyComplete ()
+ {
+ }
+
+ protected virtual void ReloadComponent ()
+ {
+ loadRequired = true;
+ }
+
+ protected abstract void SaveComponent ();
+
+ public virtual void SetComponent (IComponent component)
+ {
+ this.component = component;
+ ReloadComponent ();
+ }
+
+ [MonoTODO ("Find out what this does.")]
+ protected virtual void SetDirty ()
+ {
+ }
+
+ public virtual void SetSite (IComponentEditorPageSite site)
+ {
+ pageSite = site;
+ pageSite.GetControl ().Controls.Add (this);
+
+ }
+
+ public virtual void ShowHelp ()
+ {
+ }
+
+ public virtual bool SupportsHelp ()
+ {
+ return false;
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/EventsTab.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/EventsTab.cs
new file mode 100644
index 00000000000..f5f5e03a5fb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/EventsTab.cs
@@ -0,0 +1,122 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Dennis Hayes (dennish@raytek.com)
+// Rafael Teixeira (rafaelteixeirabr@hotmail.com)
+//
+
+// NOT COMPLETE
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+
+namespace System.Windows.Forms.Design
+{
+ public class EventsTab : PropertyTab
+ {
+ [MonoTODO]
+ private EventsTab()
+ {
+ }
+
+ private IServiceProvider serviceProvider;
+
+ [MonoTODO]
+ public EventsTab(IServiceProvider serviceProvider)
+ {
+ this.serviceProvider = serviceProvider;
+ }
+
+ [MonoTODO("What value should we return?")]
+ public override string HelpKeyword
+ {
+ get {
+ return TabName;
+ }
+ }
+
+ [MonoTODO("Localization")]
+ public override string TabName
+ {
+ get {
+ return "Events";
+ }
+ }
+
+ [MonoTODO("Test")]
+ public override PropertyDescriptorCollection GetProperties(
+ ITypeDescriptorContext context,
+ object component,
+ Attribute[] attributes)
+ {
+ IEventBindingService eventPropertySvc = null;
+ EventDescriptorCollection events;
+
+ if (serviceProvider != null)
+ eventPropertySvc = (IEventBindingService)
+ serviceProvider.GetService(typeof(IEventBindingService));
+
+ if (eventPropertySvc == null)
+ return new PropertyDescriptorCollection(null);
+
+ if (attributes != null)
+ events = TypeDescriptor.GetEvents(component, attributes);
+ else
+ events = TypeDescriptor.GetEvents(component);
+
+ // Return event properties for the event descriptors.
+ return eventPropertySvc.GetEventProperties(events);
+ }
+
+ public override PropertyDescriptorCollection GetProperties(object component, Attribute[] attributes)
+ {
+ return this.GetProperties(null, component, attributes);
+ }
+
+ [MonoTODO]
+ public override bool CanExtend(object component)
+ {
+ return false;
+ }
+
+ [MonoTODO("Test")]
+ public override PropertyDescriptor GetDefaultProperty(object component)
+ {
+ object[] attributes = component.GetType().GetCustomAttributes(typeof(DefaultEventAttribute), true);
+ if (attributes.Length > 0) {
+ DefaultEventAttribute defaultEvent = attributes[0] as DefaultEventAttribute;
+ if (defaultEvent != null && serviceProvider != null) {
+ IEventBindingService eventPropertySvc = (IEventBindingService)
+ serviceProvider.GetService(typeof(IEventBindingService));
+
+ if (eventPropertySvc == null)
+ foreach (EventDescriptor ed in TypeDescriptor.GetEvents(component))
+ if (ed.Name == defaultEvent.Name)
+ return eventPropertySvc.GetEventProperty(ed);
+ }
+ }
+ return null;
+ }
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/IUIService.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/IUIService.cs
new file mode 100644
index 00000000000..e7bc6da80ec
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/IUIService.cs
@@ -0,0 +1,51 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+
+// NOT COMPLETE
+
+using System.Runtime.InteropServices;
+using System.Collections;
+
+namespace System.Windows.Forms.Design
+{
+ [Guid ("06a9c74b-5e32-4561-be73-381b37869f4f")]
+ public interface IUIService
+ {
+ IDictionary Styles {get;}
+
+ bool CanShowComponentEditor (object component);
+ IWin32Window GetDialogOwnerWindow ();
+ void SetUIDirty ();
+ bool ShowComponentEditor (object component, IWin32Window parent);
+ void ShowError (Exception ex);
+ void ShowError (string message);
+ void ShowError (Exception ex, string message);
+ DialogResult ShowDialog (Form form);
+ void ShowMessage (string message);
+ void ShowMessage (string message, string caption);
+ DialogResult ShowMessage (string message, string caption, MessageBoxButtons buttons);
+ bool ShowToolWindow (Guid toolWindow);
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/IWindowsFormsEditorService.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/IWindowsFormsEditorService.cs
new file mode 100644
index 00000000000..c68144917d8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/IWindowsFormsEditorService.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+
+// NOT COMPLETE
+
+namespace System.Windows.Forms.Design
+{
+ public interface IWindowsFormsEditorService {
+ void CloseDropDown ();
+ void DropDownControl (Control control);
+ DialogResult ShowDialog (Form dialog);
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/PropertyTab.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/PropertyTab.cs
new file mode 100644
index 00000000000..08a1b6b3448
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/PropertyTab.cs
@@ -0,0 +1,101 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors: Marek Safar (marek.safar@seznam.cz)
+//
+
+// COMPLETE
+
+using System.Drawing;
+using System.ComponentModel;
+
+namespace System.Windows.Forms.Design
+{
+ public abstract class PropertyTab: IExtenderProvider
+ {
+ Bitmap bitmap;
+ object[] components;
+
+ protected PropertyTab () {}
+
+ ~PropertyTab ()
+ {
+ Dispose (false);
+ }
+
+ public virtual Bitmap Bitmap {
+ get {
+ if (bitmap == null) {
+ Type t = base.GetType();
+ bitmap = new Bitmap (t, t.Name + ".bmp");
+ }
+ return bitmap;
+ }
+ }
+
+ public virtual object[] Components {
+ get { return components; }
+ set { components = value; }
+ }
+
+ public virtual string HelpKeyword {
+ get { return TabName; }
+ }
+
+ public abstract string TabName { get; }
+
+ public virtual bool CanExtend (object extendee)
+ {
+ return true;
+ }
+
+ public virtual void Dispose()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposing && bitmap != null) {
+ bitmap.Dispose ();
+ bitmap = null;
+ }
+ }
+
+ public virtual PropertyDescriptor GetDefaultProperty (object component)
+ {
+ return TypeDescriptor.GetDefaultProperty(component);
+ }
+
+ public virtual PropertyDescriptorCollection GetProperties (object component)
+ {
+ return GetProperties (component, null);
+ }
+
+ public abstract PropertyDescriptorCollection GetProperties (object component, Attribute[] attributes);
+
+ public virtual PropertyDescriptorCollection GetProperties (ITypeDescriptorContext context, object component, Attribute[] attributes)
+ {
+ return GetProperties (component, attributes);
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/WindowsFormsComponentEditor.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/WindowsFormsComponentEditor.cs
new file mode 100644
index 00000000000..1de8cecdaae
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Design/WindowsFormsComponentEditor.cs
@@ -0,0 +1,64 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+
+using System.ComponentModel;
+
+namespace System.Windows.Forms.Design
+{
+ public abstract class WindowsFormsComponentEditor : ComponentEditor
+ {
+ protected WindowsFormsComponentEditor ()
+ {
+ }
+
+ public override bool EditComponent (ITypeDescriptorContext context, object component)
+ {
+ return EditComponent (context, component, null);
+ }
+
+ public virtual bool EditComponent (ITypeDescriptorContext context, object component, IWin32Window owner)
+ {
+ ComponentEditorForm f = new ComponentEditorForm (component, GetComponentEditorPages ());
+ if (f.ShowForm (owner, GetInitialComponentEditorPageIndex ()) == DialogResult.OK)
+ return true;
+ return false;
+ }
+
+ public bool EditComponent (object component, IWin32Window owner)
+ {
+ return EditComponent (null, component, owner);
+ }
+
+ protected virtual Type[] GetComponentEditorPages ()
+ {
+ return null;
+ }
+
+ protected virtual int GetInitialComponentEditorPageIndex ()
+ {
+ return 0;
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/ChangeLog
new file mode 100644
index 00000000000..8ded44833a4
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/ChangeLog
@@ -0,0 +1,45 @@
+2005-12-22 Peter Dennis Bartok <pbartok@novell.com>
+
+ * RTF.cs: Added method to allow setting the default font for the RTF
+ document. This font will be used if the document does not contain
+ a font table.
+ * Font.cs: Added method to delete font with a given number;
+ changed set_Num to call this method (to allow replacing fonts
+ with the same number, particulary the default font)
+
+2005-09-04 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Charcode.cs: Created; provides StandardCharCode <-> character
+ translation
+ * Charset.cs: Created; provides two standard charsets, AnsiGeneral
+ and AnsiSymbol
+ * CharsetFlags.cs: Created
+ * CharsetType.cs: Created
+ * ClassDelegate.cs: Created; allows consumer to register a callback
+ for RTF command classes
+ * Color.cs: Created; provides access to RTF-defined RGB color sets
+ * DestinationDelegate.cs: Created; allows consumer to register a
+ callback for Destination class types
+ * Font.cs: Created; provides access to RTF-defined font descriptions
+ * KeysInit.cs: Created; provides translation table from RTF keyword
+ to Major/Minor classes
+ * KeyStruct.cs: Created
+ * Major.cs: Created; describes available RTF command groups
+ * Minor.cs: Created; describes available 'arguments' for command groups
+ * README: Created
+ * RTF.cs: Created; contains main RTF parser code
+ * rtf.csproj: Created; provides Visual Studio project that allows to
+ use test this assembly via the included test.cs
+ to provide
+ * RTFException.cs: Created; provides custom RTF exception class
+ * StandardCharCode.cs: Created
+ * StandardCharName.cs: Created
+ * Style.cs: Created; provides access to RTF-define styles
+ * StyleElement.cs: Created; provides support class to allow parsing
+ recursive styles
+ * StyleType.cs: Created
+ * test.cs: Test code showing use of RTF class (also acts as Main for
+ the included Visual Studio project)
+ * TextMap.cs: Created; allows to create simple translation table for
+ converting parsed RTF document to text; table-based
+ * TokenClass.cs: Created; describes all available RTF command classes
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Charcode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Charcode.cs
new file mode 100644
index 00000000000..600c74450ba
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Charcode.cs
@@ -0,0 +1,405 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+using System.Collections;
+
+namespace System.Windows.Forms.RTF {
+ internal class Charcode {
+ #region Local Variables
+ private StandardCharCode[] codes;
+ private Hashtable reverse;
+ private int size;
+ #endregion // Local Variables
+
+ #region Public Constructors
+ public Charcode() : this(256) {
+ }
+
+ private Charcode(int size) {
+ this.size = size;
+ this.codes = new StandardCharCode[size];
+ this.reverse = new Hashtable(size);
+
+ for (int i = 0; i < size; i++) {
+ codes[i] = StandardCharCode.nothing;
+ }
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public int this[StandardCharCode c] {
+ get {
+ object obj;
+
+ obj = reverse[c];
+ if (obj != null) {
+ return (int)obj;
+ }
+ for (int i = 0; i < size; i++) {
+ if (codes[i] == c) {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+ }
+
+ public StandardCharCode this[int c] {
+ get {
+ if (c < 0 || c >= size) {
+ return StandardCharCode.nothing;
+ }
+
+ return codes[c];
+ }
+
+ set {
+ if (c < 0 || c >= size) {
+ return;
+ }
+
+ codes[c] = value;
+ reverse[value] = c;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ #endregion // Public Instance Methods
+
+ #region Public Static Methods
+ public static Charcode AnsiGeneric {
+ get {
+ Charcode code = new Charcode(256);
+
+ code[0x06] = StandardCharCode.formula;
+ code[0x1e] = StandardCharCode.nobrkhyphen;
+ code[0x1f] = StandardCharCode.opthyphen;
+ code[' '] = StandardCharCode.space;
+ code['!'] = StandardCharCode.exclam;
+ code['"'] = StandardCharCode.quotedbl;
+ code['#'] = StandardCharCode.numbersign;
+ code['$'] = StandardCharCode.dollar;
+ code['%'] = StandardCharCode.percent;
+ code['&'] = StandardCharCode.ampersand;
+ code['\\'] = StandardCharCode.quoteright;
+ code['('] = StandardCharCode.parenleft;
+ code[')'] = StandardCharCode.parenright;
+ code['*'] = StandardCharCode.asterisk;
+ code['+'] = StandardCharCode.plus;
+ code[','] = StandardCharCode.comma;
+ code['-'] = StandardCharCode.hyphen;
+ code['.'] = StandardCharCode.period;
+ code['/'] = StandardCharCode.slash;
+ code['0'] = StandardCharCode.zero;
+ code['1'] = StandardCharCode.one;
+ code['2'] = StandardCharCode.two;
+ code['3'] = StandardCharCode.three;
+ code['4'] = StandardCharCode.four;
+ code['5'] = StandardCharCode.five;
+ code['6'] = StandardCharCode.six;
+ code['7'] = StandardCharCode.seven;
+ code['8'] = StandardCharCode.eight;
+ code['9'] = StandardCharCode.nine;
+ code[':'] = StandardCharCode.colon;
+ code[';'] = StandardCharCode.semicolon;
+ code['<'] = StandardCharCode.less;
+ code['='] = StandardCharCode.equal;
+ code['>'] = StandardCharCode.greater;
+ code['?'] = StandardCharCode.question;
+ code['@'] = StandardCharCode.at;
+ code['A'] = StandardCharCode.A;
+ code['B'] = StandardCharCode.B;
+ code['C'] = StandardCharCode.C;
+ code['D'] = StandardCharCode.D;
+ code['E'] = StandardCharCode.E;
+ code['F'] = StandardCharCode.F;
+ code['G'] = StandardCharCode.G;
+ code['H'] = StandardCharCode.H;
+ code['I'] = StandardCharCode.I;
+ code['J'] = StandardCharCode.J;
+ code['K'] = StandardCharCode.K;
+ code['L'] = StandardCharCode.L;
+ code['M'] = StandardCharCode.M;
+ code['N'] = StandardCharCode.N;
+ code['O'] = StandardCharCode.O;
+ code['P'] = StandardCharCode.P;
+ code['Q'] = StandardCharCode.Q;
+ code['R'] = StandardCharCode.R;
+ code['S'] = StandardCharCode.S;
+ code['T'] = StandardCharCode.T;
+ code['U'] = StandardCharCode.U;
+ code['V'] = StandardCharCode.V;
+ code['W'] = StandardCharCode.W;
+ code['X'] = StandardCharCode.X;
+ code['Y'] = StandardCharCode.Y;
+ code['Z'] = StandardCharCode.Z;
+ code['['] = StandardCharCode.bracketleft;
+ code['\\'] = StandardCharCode.backslash;
+ code[']'] = StandardCharCode.bracketright;
+ code['^'] = StandardCharCode.asciicircum;
+ code['_'] = StandardCharCode.underscore;
+ code['`'] = StandardCharCode.quoteleft;
+ code['a'] = StandardCharCode.a;
+ code['b'] = StandardCharCode.b;
+ code['c'] = StandardCharCode.c;
+ code['d'] = StandardCharCode.d;
+ code['e'] = StandardCharCode.e;
+ code['f'] = StandardCharCode.f;
+ code['g'] = StandardCharCode.g;
+ code['h'] = StandardCharCode.h;
+ code['i'] = StandardCharCode.i;
+ code['j'] = StandardCharCode.j;
+ code['k'] = StandardCharCode.k;
+ code['l'] = StandardCharCode.l;
+ code['m'] = StandardCharCode.m;
+ code['n'] = StandardCharCode.n;
+ code['o'] = StandardCharCode.o;
+ code['p'] = StandardCharCode.p;
+ code['q'] = StandardCharCode.q;
+ code['r'] = StandardCharCode.r;
+ code['s'] = StandardCharCode.s;
+ code['t'] = StandardCharCode.t;
+ code['u'] = StandardCharCode.u;
+ code['v'] = StandardCharCode.v;
+ code['w'] = StandardCharCode.w;
+ code['x'] = StandardCharCode.x;
+ code['y'] = StandardCharCode.y;
+ code['z'] = StandardCharCode.z;
+ code['{'] = StandardCharCode.braceleft;
+ code['|'] = StandardCharCode.bar;
+ code['}'] = StandardCharCode.braceright;
+ code['~'] = StandardCharCode.asciitilde;
+ code[0xa0] = StandardCharCode.nobrkspace;
+ code[0xa1] = StandardCharCode.exclamdown;
+ code[0xa2] = StandardCharCode.cent;
+ code[0xa3] = StandardCharCode.sterling;
+ code[0xa4] = StandardCharCode.currency;
+ code[0xa5] = StandardCharCode.yen;
+ code[0xa6] = StandardCharCode.brokenbar;
+ code[0xa7] = StandardCharCode.section;
+ code[0xa8] = StandardCharCode.dieresis;
+ code[0xa9] = StandardCharCode.copyright;
+ code[0xaa] = StandardCharCode.ordfeminine;
+ code[0xab] = StandardCharCode.guillemotleft;
+ code[0xac] = StandardCharCode.logicalnot;
+ code[0xad] = StandardCharCode.opthyphen;
+ code[0xae] = StandardCharCode.registered;
+ code[0xaf] = StandardCharCode.macron;
+ code[0xb0] = StandardCharCode.degree;
+ code[0xb1] = StandardCharCode.plusminus;
+ code[0xb2] = StandardCharCode.twosuperior;
+ code[0xb3] = StandardCharCode.threesuperior;
+ code[0xb4] = StandardCharCode.acute;
+ code[0xb5] = StandardCharCode.mu;
+ code[0xb6] = StandardCharCode.paragraph;
+ code[0xb7] = StandardCharCode.periodcentered;
+ code[0xb8] = StandardCharCode.cedilla;
+ code[0xb9] = StandardCharCode.onesuperior;
+ code[0xba] = StandardCharCode.ordmasculine;
+ code[0xbb] = StandardCharCode.guillemotright;
+ code[0xbc] = StandardCharCode.onequarter;
+ code[0xbd] = StandardCharCode.onehalf;
+ code[0xbe] = StandardCharCode.threequarters;
+ code[0xbf] = StandardCharCode.questiondown;
+ code[0xc0] = StandardCharCode.Agrave;
+ code[0xc1] = StandardCharCode.Aacute;
+ code[0xc2] = StandardCharCode.Acircumflex;
+ code[0xc3] = StandardCharCode.Atilde;
+ code[0xc4] = StandardCharCode.Adieresis;
+ code[0xc5] = StandardCharCode.Aring;
+ code[0xc6] = StandardCharCode.AE;
+ code[0xc7] = StandardCharCode.Ccedilla;
+ code[0xc8] = StandardCharCode.Egrave;
+ code[0xc9] = StandardCharCode.Eacute;
+ code[0xca] = StandardCharCode.Ecircumflex;
+ code[0xcb] = StandardCharCode.Edieresis;
+ code[0xcc] = StandardCharCode.Igrave;
+ code[0xcd] = StandardCharCode.Iacute;
+ code[0xce] = StandardCharCode.Icircumflex;
+ code[0xcf] = StandardCharCode.Idieresis;
+ code[0xd0] = StandardCharCode.Eth;
+ code[0xd1] = StandardCharCode.Ntilde;
+ code[0xd2] = StandardCharCode.Ograve;
+ code[0xd3] = StandardCharCode.Oacute;
+ code[0xd4] = StandardCharCode.Ocircumflex;
+ code[0xd5] = StandardCharCode.Otilde;
+ code[0xd6] = StandardCharCode.Odieresis;
+ code[0xd7] = StandardCharCode.multiply;
+ code[0xd8] = StandardCharCode.Oslash;
+ code[0xd9] = StandardCharCode.Ugrave;
+ code[0xda] = StandardCharCode.Uacute;
+ code[0xdb] = StandardCharCode.Ucircumflex;
+ code[0xdc] = StandardCharCode.Udieresis;
+ code[0xdd] = StandardCharCode.Yacute;
+ code[0xde] = StandardCharCode.Thorn;
+ code[0xdf] = StandardCharCode.germandbls;
+ code[0xe0] = StandardCharCode.agrave;
+ code[0xe1] = StandardCharCode.aacute;
+ code[0xe2] = StandardCharCode.acircumflex;
+ code[0xe3] = StandardCharCode.atilde;
+ code[0xe4] = StandardCharCode.adieresis;
+ code[0xe5] = StandardCharCode.aring;
+ code[0xe6] = StandardCharCode.ae;
+ code[0xe7] = StandardCharCode.ccedilla;
+ code[0xe8] = StandardCharCode.egrave;
+ code[0xe9] = StandardCharCode.eacute;
+ code[0xea] = StandardCharCode.ecircumflex;
+ code[0xeb] = StandardCharCode.edieresis;
+ code[0xec] = StandardCharCode.igrave;
+ code[0xed] = StandardCharCode.iacute;
+ code[0xee] = StandardCharCode.icircumflex;
+ code[0xef] = StandardCharCode.idieresis;
+ code[0xf0] = StandardCharCode.eth;
+ code[0xf1] = StandardCharCode.ntilde;
+ code[0xf2] = StandardCharCode.ograve;
+ code[0xf3] = StandardCharCode.oacute;
+ code[0xf4] = StandardCharCode.ocircumflex;
+ code[0xf5] = StandardCharCode.otilde;
+ code[0xf6] = StandardCharCode.odieresis;
+ code[0xf7] = StandardCharCode.divide;
+ code[0xf8] = StandardCharCode.oslash;
+ code[0xf9] = StandardCharCode.ugrave;
+ code[0xfa] = StandardCharCode.uacute;
+ code[0xfb] = StandardCharCode.ucircumflex;
+ code[0xfc] = StandardCharCode.udieresis;
+ code[0xfd] = StandardCharCode.yacute;
+ code[0xfe] = StandardCharCode.thorn;
+ code[0xff] = StandardCharCode.ydieresis;
+
+ return code;
+ }
+ }
+
+ public static Charcode AnsiSymbol {
+ get {
+ Charcode code = new Charcode(256);
+
+ code[0x06] = StandardCharCode.formula;
+ code[0x1e] = StandardCharCode.nobrkhyphen;
+ code[0x1f] = StandardCharCode.opthyphen;
+ code[' '] = StandardCharCode.space;
+ code['!'] = StandardCharCode.exclam;
+ code['"'] = StandardCharCode.universal;
+ code['#'] = StandardCharCode.mathnumbersign;
+ code['$'] = StandardCharCode.existential;
+ code['%'] = StandardCharCode.percent;
+ code['&'] = StandardCharCode.ampersand;
+ code['\\'] = StandardCharCode.suchthat;
+ code['('] = StandardCharCode.parenleft;
+ code[')'] = StandardCharCode.parenright;
+ code['*'] = StandardCharCode.mathasterisk;
+ code['+'] = StandardCharCode.mathplus;
+ code[','] = StandardCharCode.comma;
+ code['-'] = StandardCharCode.mathminus;
+ code['.'] = StandardCharCode.period;
+ code['/'] = StandardCharCode.slash;
+ code['0'] = StandardCharCode.zero;
+ code['1'] = StandardCharCode.one;
+ code['2'] = StandardCharCode.two;
+ code['3'] = StandardCharCode.three;
+ code['4'] = StandardCharCode.four;
+ code['5'] = StandardCharCode.five;
+ code['6'] = StandardCharCode.six;
+ code['7'] = StandardCharCode.seven;
+ code['8'] = StandardCharCode.eight;
+ code['9'] = StandardCharCode.nine;
+ code[':'] = StandardCharCode.colon;
+ code[';'] = StandardCharCode.semicolon;
+ code['<'] = StandardCharCode.less;
+ code['='] = StandardCharCode.mathequal;
+ code['>'] = StandardCharCode.greater;
+ code['?'] = StandardCharCode.question;
+ code['@'] = StandardCharCode.congruent;
+ code['A'] = StandardCharCode.Alpha;
+ code['B'] = StandardCharCode.Beta;
+ code['C'] = StandardCharCode.Chi;
+ code['D'] = StandardCharCode.Delta;
+ code['E'] = StandardCharCode.Epsilon;
+ code['F'] = StandardCharCode.Phi;
+ code['G'] = StandardCharCode.Gamma;
+ code['H'] = StandardCharCode.Eta;
+ code['I'] = StandardCharCode.Iota;
+ code['K'] = StandardCharCode.Kappa;
+ code['L'] = StandardCharCode.Lambda;
+ code['M'] = StandardCharCode.Mu;
+ code['N'] = StandardCharCode.Nu;
+ code['O'] = StandardCharCode.Omicron;
+ code['P'] = StandardCharCode.Pi;
+ code['Q'] = StandardCharCode.Theta;
+ code['R'] = StandardCharCode.Rho;
+ code['S'] = StandardCharCode.Sigma;
+ code['T'] = StandardCharCode.Tau;
+ code['U'] = StandardCharCode.Upsilon;
+ code['V'] = StandardCharCode.varsigma;
+ code['W'] = StandardCharCode.Omega;
+ code['X'] = StandardCharCode.Xi;
+ code['Y'] = StandardCharCode.Psi;
+ code['Z'] = StandardCharCode.Zeta;
+ code['['] = StandardCharCode.bracketleft;
+ code['\\'] = StandardCharCode.backslash;
+ code[']'] = StandardCharCode.bracketright;
+ code['^'] = StandardCharCode.asciicircum;
+ code['_'] = StandardCharCode.underscore;
+ code['`'] = StandardCharCode.quoteleft;
+ code['a'] = StandardCharCode.alpha;
+ code['b'] = StandardCharCode.beta;
+ code['c'] = StandardCharCode.chi;
+ code['d'] = StandardCharCode.delta;
+ code['e'] = StandardCharCode.epsilon;
+ code['f'] = StandardCharCode.phi;
+ code['g'] = StandardCharCode.gamma;
+ code['h'] = StandardCharCode.eta;
+ code['i'] = StandardCharCode.iota;
+ code['k'] = StandardCharCode.kappa;
+ code['l'] = StandardCharCode.lambda;
+ code['m'] = StandardCharCode.mu;
+ code['n'] = StandardCharCode.nu;
+ code['o'] = StandardCharCode.omicron;
+ code['p'] = StandardCharCode.pi;
+ code['q'] = StandardCharCode.theta;
+ code['r'] = StandardCharCode.rho;
+ code['s'] = StandardCharCode.sigma;
+ code['t'] = StandardCharCode.tau;
+ code['u'] = StandardCharCode.upsilon;
+ code['w'] = StandardCharCode.omega;
+ code['x'] = StandardCharCode.xi;
+ code['y'] = StandardCharCode.psi;
+ code['z'] = StandardCharCode.zeta;
+ code['{'] = StandardCharCode.braceleft;
+ code['|'] = StandardCharCode.bar;
+ code['}'] = StandardCharCode.braceright;
+ code['~'] = StandardCharCode.mathtilde;
+
+ return code;
+ }
+ }
+ #endregion // Public Static Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Charset.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Charset.cs
new file mode 100644
index 00000000000..5e093b4254c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Charset.cs
@@ -0,0 +1,159 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+using System;
+
+// COMPLETE
+
+namespace System.Windows.Forms.RTF {
+ internal class Charset {
+ #region Local Variables
+ private CharsetType id;
+ private CharsetFlags flags;
+ private Charcode code;
+ private string file;
+ private bool loaded;
+ #endregion // Local Variables
+
+ #region Public Constructors
+ public Charset() {
+ flags = CharsetFlags.Read | CharsetFlags.Switch;
+ id = CharsetType.General;
+ file = string.Empty;
+ loaded = false;
+ this.ReadMap();
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public Charcode Code {
+ get {
+ return code;
+ }
+
+ set {
+ code = value;
+ }
+ }
+
+ public CharsetFlags Flags {
+ get {
+ return flags;
+ }
+
+ set {
+ flags = value;
+ }
+ }
+
+ public CharsetType ID {
+ get {
+ return id;
+ }
+
+ set {
+ switch(value) {
+ case CharsetType.Symbol: {
+ id = CharsetType.Symbol;
+ return;
+ }
+
+ default:
+ case CharsetType.General: {
+ id = CharsetType.General;
+ return;
+ }
+ }
+ }
+ }
+
+ public string File {
+ get {
+ return file;
+ }
+
+ set {
+ if (file != value) {
+ file = value;
+ loaded = false;
+ }
+ }
+ }
+
+ public StandardCharCode this[int c] {
+ get {
+ return code[c];
+ }
+ }
+
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public bool ReadMap() {
+ switch (id) {
+ case CharsetType.General: {
+ if (file == string.Empty) {
+ code = Charcode.AnsiGeneric;
+ return true;
+ }
+ // FIXME - implement reading charmap from file...
+ return true;
+ }
+
+ case CharsetType.Symbol: {
+ if (file == string.Empty) {
+ code = Charcode.AnsiSymbol;
+ return true;
+ }
+
+ // FIXME - implement reading charmap from file...
+ return true;
+ }
+
+ default: {
+ return false;
+ }
+ }
+ }
+
+ public char StdCharCode(string name) {
+ // FIXME - finish this
+ return ' ';
+
+ }
+
+ public string StdCharName(char code) {
+ // FIXME - finish this
+ return String.Empty;
+ }
+
+ public StandardCharCode MapChar(char c) {
+ return code[c];
+
+ }
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/CharsetFlags.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/CharsetFlags.cs
new file mode 100644
index 00000000000..4a9ab4d06d7
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/CharsetFlags.cs
@@ -0,0 +1,36 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms.RTF {
+ [Flags]
+ internal enum CharsetFlags {
+ None = 0x00,
+ Read = 0x01,
+ Switch = 0x02
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/CharsetType.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/CharsetType.cs
new file mode 100644
index 00000000000..66de5c2cc3e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/CharsetType.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms.RTF {
+ internal enum CharsetType {
+ General = 0,
+ Symbol = 1,
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/ClassDelegate.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/ClassDelegate.cs
new file mode 100644
index 00000000000..1c252ef0825
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/ClassDelegate.cs
@@ -0,0 +1,49 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms.RTF {
+ internal delegate void ClassDelegate(RTF sender);
+
+ internal class ClassCallback {
+ ClassDelegate[] callbacks;
+
+ public ClassCallback() {
+ callbacks = new ClassDelegate[Enum.GetValues(typeof(Major)).Length];
+ }
+
+ public ClassDelegate this[TokenClass c] {
+ get {
+ return callbacks[(int)c];
+ }
+
+ set {
+ callbacks[(int)c] = value;
+ }
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Color.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Color.cs
new file mode 100644
index 00000000000..253fe3a987f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Color.cs
@@ -0,0 +1,127 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms.RTF {
+ internal class Color {
+ #region Local Variables
+ private int red;
+ private int green;
+ private int blue;
+ private int num;
+ private Color next;
+ #endregion // Local Variables
+
+ #region Constructors
+ public Color(RTF rtf) {
+ red = -1;
+ green = -1;
+ blue = -1;
+ num = -1;
+
+ lock (rtf) {
+ if (rtf.Colors == null) {
+ rtf.Colors = this;
+ } else {
+ Color c = rtf.Colors;
+ while (c.next != null)
+ c = c.next;
+ c.next = this;
+ }
+ }
+ }
+ #endregion // Constructors
+
+ #region Properties
+ public int Red {
+ get {
+ return red;
+ }
+
+ set {
+ red = value;
+ }
+ }
+
+ public int Green {
+ get {
+ return green;
+ }
+
+ set {
+ green = value;
+ }
+ }
+
+ public int Blue {
+ get {
+ return blue;
+ }
+
+ set {
+ blue = value;
+ }
+ }
+
+ public int Num {
+ get {
+ return num;
+ }
+
+ set {
+ num = value;
+ }
+ }
+ #endregion // Properties
+
+ #region Methods
+ static public Color GetColor(RTF rtf, int color_number) {
+ Color c;
+
+ lock (rtf) {
+ c = GetColor(rtf.Colors, color_number);
+ }
+ return c;
+ }
+
+ static private Color GetColor(Color start, int color_number) {
+ Color c;
+
+ if (color_number == -1) {
+ return start;
+ }
+
+ c = start;
+
+ while ((c != null) && (c.num != color_number)) {
+ c = c.next;
+ }
+ return c;
+ }
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/DestinationDelegate.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/DestinationDelegate.cs
new file mode 100644
index 00000000000..4c85bdb7607
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/DestinationDelegate.cs
@@ -0,0 +1,49 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms.RTF {
+ internal delegate void DestinationDelegate(RTF Sender);
+
+ internal class DestinationCallback {
+ DestinationDelegate[] callbacks;
+
+ public DestinationCallback() {
+ callbacks = new DestinationDelegate[Enum.GetValues(typeof(Minor)).Length];
+ }
+
+ public DestinationDelegate this[Minor c] {
+ get {
+ return callbacks[(int)c];
+ }
+
+ set {
+ callbacks[(int)c] = value;
+ }
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Font.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Font.cs
new file mode 100644
index 00000000000..b0af7c7e534
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Font.cs
@@ -0,0 +1,201 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms.RTF {
+ internal class Font {
+ #region Local Variables
+ private string name;
+ private string alt_name;
+ private int num;
+ private int family;
+ private CharsetType charset;
+ private int pitch;
+ private int type;
+ private int codepage;
+ private Font next;
+ private RTF rtf;
+ #endregion // Local Variables
+
+ #region Constructors
+ public Font(RTF rtf) {
+ this.rtf = rtf;
+ num = -1;
+
+ lock (rtf) {
+ if (rtf.Fonts == null)
+ rtf.Fonts = this;
+ else {
+ Font f = rtf.Fonts;
+ while (f.next != null)
+ f = f.next;
+ f.next = this;
+ }
+ }
+ }
+ #endregion // Constructors
+
+ #region Properties
+ public string Name {
+ get {
+ return name;
+ }
+
+ set {
+ name = value;
+ }
+ }
+
+ public string AltName {
+ get {
+ return alt_name;
+ }
+
+ set {
+ alt_name = value;
+ }
+ }
+
+ public int Num {
+ get {
+ return num;
+ }
+
+ set {
+ // Whack any previous font with the same number
+ DeleteFont(rtf, value);
+ num = value;
+ }
+ }
+
+ public int Family {
+ get {
+ return family;
+ }
+
+ set {
+ family = value;
+ }
+ }
+
+ public CharsetType Charset {
+ get {
+ return charset;
+ }
+
+ set {
+ charset = value;
+ }
+ }
+
+
+ public int Pitch {
+ get {
+ return pitch;
+ }
+
+ set {
+ pitch = value;
+ }
+ }
+
+ public int Type {
+ get {
+ return type;
+ }
+
+ set {
+ type = value;
+ }
+ }
+
+ public int Codepage {
+ get {
+ return codepage;
+ }
+
+ set {
+ codepage = value;
+ }
+ }
+ #endregion // Properties
+
+ #region Methods
+ static public bool DeleteFont(RTF rtf, int font_number) {
+ Font f;
+ Font prev;
+
+ lock (rtf) {
+ f = rtf.Fonts;
+ prev = null;
+ while ((f != null) && (f.num != font_number)) {
+ prev = f;
+ f = f.next;
+ }
+
+ if (f != null) {
+ if (f == rtf.Fonts) {
+ rtf.Fonts = f.next;
+ } else {
+ if (prev != null) {
+ prev.next = f.next;
+ } else {
+ rtf.Fonts = f.next;
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ static public Font GetFont(RTF rtf, int font_number) {
+ Font f;
+
+ lock (rtf) {
+ f = GetFont(rtf.Fonts, font_number);
+ }
+ return f;
+ }
+
+ static public Font GetFont(Font start, int font_number) {
+ Font f;
+
+ if (font_number == -1) {
+ return start;
+ }
+
+ f = start;
+
+ while ((f != null) && (f.num != font_number)) {
+ f = f.next;
+ }
+ return f;
+ }
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/KeyStruct.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/KeyStruct.cs
new file mode 100644
index 00000000000..3e2280a6d8d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/KeyStruct.cs
@@ -0,0 +1,40 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms.RTF {
+ internal struct KeyStruct {
+ public KeyStruct(Major major, Minor minor, string symbol) {
+ Major = major;
+ Minor = minor;
+ Symbol = symbol;
+ }
+ public Major Major;
+ public Minor Minor;
+ public string Symbol;
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/KeysInit.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/KeysInit.cs
new file mode 100644
index 00000000000..9a1cce188fb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/KeysInit.cs
@@ -0,0 +1,719 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms.RTF {
+ internal class KeysInit {
+ public static KeyStruct[] Init() {
+ return new KeyStruct[] {
+ new KeyStruct(Major.SpecialChar, Minor.IIntVersion, "vern"),
+ new KeyStruct(Major.SpecialChar, Minor.ICreateTime, "creatim"),
+ new KeyStruct(Major.SpecialChar, Minor.IRevisionTime, "revtim"),
+ new KeyStruct(Major.SpecialChar, Minor.IPrintTime, "printim"),
+ new KeyStruct(Major.SpecialChar, Minor.IBackupTime, "buptim"),
+ new KeyStruct(Major.SpecialChar, Minor.IEditTime, "edmins"),
+ new KeyStruct(Major.SpecialChar, Minor.IYear, "yr"),
+ new KeyStruct(Major.SpecialChar, Minor.IMonth, "mo"),
+ new KeyStruct(Major.SpecialChar, Minor.IDay, "dy"),
+ new KeyStruct(Major.SpecialChar, Minor.IHour, "hr"),
+ new KeyStruct(Major.SpecialChar, Minor.IMinute, "min"),
+ new KeyStruct(Major.SpecialChar, Minor.ISecond, "sec"),
+ new KeyStruct(Major.SpecialChar, Minor.INPages, "nofpages"),
+ new KeyStruct(Major.SpecialChar, Minor.INWords, "nofwords"),
+ new KeyStruct(Major.SpecialChar, Minor.INChars, "nofchars"),
+ new KeyStruct(Major.SpecialChar, Minor.IIntID, "id"),
+ new KeyStruct(Major.SpecialChar, Minor.CurHeadDate, "chdate"),
+ new KeyStruct(Major.SpecialChar, Minor.CurHeadDateLong, "chdpl"),
+ new KeyStruct(Major.SpecialChar, Minor.CurHeadDateAbbrev, "chdpa"),
+ new KeyStruct(Major.SpecialChar, Minor.CurHeadTime, "chtime"),
+ new KeyStruct(Major.SpecialChar, Minor.CurHeadPage, "chpgn"),
+ new KeyStruct(Major.SpecialChar, Minor.SectNum, "sectnum"),
+ new KeyStruct(Major.SpecialChar, Minor.CurFNote, "chftn"),
+ new KeyStruct(Major.SpecialChar, Minor.CurAnnotRef, "chatn"),
+ new KeyStruct(Major.SpecialChar, Minor.FNoteSep, "chftnsep"),
+ new KeyStruct(Major.SpecialChar, Minor.FNoteCont, "chftnsepc"),
+ new KeyStruct(Major.SpecialChar, Minor.Cell, "cell"),
+ new KeyStruct(Major.SpecialChar, Minor.Row, "row"),
+ new KeyStruct(Major.SpecialChar, Minor.Par, "par"),
+ new KeyStruct(Major.SpecialChar, Minor.Par, "\n"),
+ new KeyStruct(Major.SpecialChar, Minor.Par, "\r"),
+ new KeyStruct(Major.SpecialChar, Minor.Sect, "sect"),
+ new KeyStruct(Major.SpecialChar, Minor.Page, "page"),
+ new KeyStruct(Major.SpecialChar, Minor.Column, "column"),
+ new KeyStruct(Major.SpecialChar, Minor.Line, "line"),
+ new KeyStruct(Major.SpecialChar, Minor.SoftPage, "softpage"),
+ new KeyStruct(Major.SpecialChar, Minor.SoftColumn, "softcol"),
+ new KeyStruct(Major.SpecialChar, Minor.SoftLine, "softline"),
+ new KeyStruct(Major.SpecialChar, Minor.SoftLineHt, "softlheight"),
+ new KeyStruct(Major.SpecialChar, Minor.Tab, "tab"),
+ new KeyStruct(Major.SpecialChar, Minor.EmDash, "emdash"),
+ new KeyStruct(Major.SpecialChar, Minor.EnDash, "endash"),
+ new KeyStruct(Major.SpecialChar, Minor.EmSpace, "emspace"),
+ new KeyStruct(Major.SpecialChar, Minor.EnSpace, "enspace"),
+ new KeyStruct(Major.SpecialChar, Minor.Bullet, "bullet"),
+ new KeyStruct(Major.SpecialChar, Minor.LQuote, "lquote"),
+ new KeyStruct(Major.SpecialChar, Minor.RQuote, "rquote"),
+ new KeyStruct(Major.SpecialChar, Minor.LDblQuote, "ldblquote"),
+ new KeyStruct(Major.SpecialChar, Minor.RDblQuote, "rdblquote"),
+ new KeyStruct(Major.SpecialChar, Minor.Formula, "|"),
+ new KeyStruct(Major.SpecialChar, Minor.NoBrkSpace, "~"),
+ new KeyStruct(Major.SpecialChar, Minor.NoReqHyphen, "-"),
+ new KeyStruct(Major.SpecialChar, Minor.NoBrkHyphen, "_"),
+ new KeyStruct(Major.SpecialChar, Minor.OptDest, "*"),
+ new KeyStruct(Major.SpecialChar, Minor.LTRMark, "ltrmark"),
+ new KeyStruct(Major.SpecialChar, Minor.RTLMark, "rtlmark"),
+ new KeyStruct(Major.SpecialChar, Minor.NoWidthJoiner, "zwj"),
+ new KeyStruct(Major.SpecialChar, Minor.NoWidthNonJoiner, "zwnj"),
+ new KeyStruct(Major.SpecialChar, Minor.CurHeadPict, "chpict"),
+ new KeyStruct(Major.CharAttr, Minor.Plain, "plain"),
+ new KeyStruct(Major.CharAttr, Minor.Bold, "b"),
+ new KeyStruct(Major.CharAttr, Minor.AllCaps, "caps"),
+ new KeyStruct(Major.CharAttr, Minor.Deleted, "deleted"),
+ new KeyStruct(Major.CharAttr, Minor.SubScript, "dn"),
+ new KeyStruct(Major.CharAttr, Minor.SubScrShrink, "sub"),
+ new KeyStruct(Major.CharAttr, Minor.NoSuperSub, "nosupersub"),
+ new KeyStruct(Major.CharAttr, Minor.Expand, "expnd"),
+ new KeyStruct(Major.CharAttr, Minor.ExpandTwips, "expndtw"),
+ new KeyStruct(Major.CharAttr, Minor.Kerning, "kerning"),
+ new KeyStruct(Major.CharAttr, Minor.FontNum, "f"),
+ new KeyStruct(Major.CharAttr, Minor.FontSize, "fs"),
+ new KeyStruct(Major.CharAttr, Minor.Italic, "i"),
+ new KeyStruct(Major.CharAttr, Minor.Outline, "outl"),
+ new KeyStruct(Major.CharAttr, Minor.Revised, "revised"),
+ new KeyStruct(Major.CharAttr, Minor.RevAuthor, "revauth"),
+ new KeyStruct(Major.CharAttr, Minor.RevDTTM, "revdttm"),
+ new KeyStruct(Major.CharAttr, Minor.SmallCaps, "scaps"),
+ new KeyStruct(Major.CharAttr, Minor.Shadow, "shad"),
+ new KeyStruct(Major.CharAttr, Minor.StrikeThru, "strike"),
+ new KeyStruct(Major.CharAttr, Minor.Underline, "ul"),
+ new KeyStruct(Major.CharAttr, Minor.DotUnderline, "uld"),
+ new KeyStruct(Major.CharAttr, Minor.DbUnderline, "uldb"),
+ new KeyStruct(Major.CharAttr, Minor.NoUnderline, "ulnone"),
+ new KeyStruct(Major.CharAttr, Minor.WordUnderline, "ulw"),
+ new KeyStruct(Major.CharAttr, Minor.SuperScript, "up"),
+ new KeyStruct(Major.CharAttr, Minor.SuperScrShrink, "super"),
+ new KeyStruct(Major.CharAttr, Minor.Invisible, "v"),
+ new KeyStruct(Major.CharAttr, Minor.ForeColor, "cf"),
+ new KeyStruct(Major.CharAttr, Minor.BackColor, "cb"),
+ new KeyStruct(Major.CharAttr, Minor.RTLChar, "rtlch"),
+ new KeyStruct(Major.CharAttr, Minor.LTRChar, "ltrch"),
+ new KeyStruct(Major.CharAttr, Minor.CharStyleNum, "cs"),
+ new KeyStruct(Major.CharAttr, Minor.CharCharSet, "cchs"),
+ new KeyStruct(Major.CharAttr, Minor.Language, "lang"),
+ new KeyStruct(Major.CharAttr, Minor.Gray, "gray"),
+ new KeyStruct(Major.ParAttr, Minor.ParDef, "pard"),
+ new KeyStruct(Major.ParAttr, Minor.StyleNum, "s"),
+ new KeyStruct(Major.ParAttr, Minor.Hyphenate, "hyphpar"),
+ new KeyStruct(Major.ParAttr, Minor.InTable, "intbl"),
+ new KeyStruct(Major.ParAttr, Minor.Keep, "keep"),
+ new KeyStruct(Major.ParAttr, Minor.NoWidowControl, "nowidctlpar"),
+ new KeyStruct(Major.ParAttr, Minor.KeepNext, "keepn"),
+ new KeyStruct(Major.ParAttr, Minor.OutlineLevel, "level"),
+ new KeyStruct(Major.ParAttr, Minor.NoLineNum, "noline"),
+ new KeyStruct(Major.ParAttr, Minor.PBBefore, "pagebb"),
+ new KeyStruct(Major.ParAttr, Minor.SideBySide, "sbys"),
+ new KeyStruct(Major.ParAttr, Minor.QuadLeft, "ql"),
+ new KeyStruct(Major.ParAttr, Minor.QuadRight, "qr"),
+ new KeyStruct(Major.ParAttr, Minor.QuadJust, "qj"),
+ new KeyStruct(Major.ParAttr, Minor.QuadCenter, "qc"),
+ new KeyStruct(Major.ParAttr, Minor.FirstIndent, "fi"),
+ new KeyStruct(Major.ParAttr, Minor.LeftIndent, "li"),
+ new KeyStruct(Major.ParAttr, Minor.RightIndent, "ri"),
+ new KeyStruct(Major.ParAttr, Minor.SpaceBefore, "sb"),
+ new KeyStruct(Major.ParAttr, Minor.SpaceAfter, "sa"),
+ new KeyStruct(Major.ParAttr, Minor.SpaceBetween, "sl"),
+ new KeyStruct(Major.ParAttr, Minor.SpaceMultiply, "slmult"),
+ new KeyStruct(Major.ParAttr, Minor.SubDocument, "subdocument"),
+ new KeyStruct(Major.ParAttr, Minor.RTLPar, "rtlpar"),
+ new KeyStruct(Major.ParAttr, Minor.LTRPar, "ltrpar"),
+ new KeyStruct(Major.ParAttr, Minor.TabPos, "tx"),
+ new KeyStruct(Major.ParAttr, Minor.TabLeft, "tql"),
+ new KeyStruct(Major.ParAttr, Minor.TabRight, "tqr"),
+ new KeyStruct(Major.ParAttr, Minor.TabCenter, "tqc"),
+ new KeyStruct(Major.ParAttr, Minor.TabDecimal, "tqdec"),
+ new KeyStruct(Major.ParAttr, Minor.TabBar, "tb"),
+ new KeyStruct(Major.ParAttr, Minor.LeaderDot, "tldot"),
+ new KeyStruct(Major.ParAttr, Minor.LeaderHyphen, "tlhyph"),
+ new KeyStruct(Major.ParAttr, Minor.LeaderUnder, "tlul"),
+ new KeyStruct(Major.ParAttr, Minor.LeaderThick, "tlth"),
+ new KeyStruct(Major.ParAttr, Minor.LeaderEqual, "tleq"),
+ new KeyStruct(Major.ParAttr, Minor.ParLevel, "pnlvl"),
+ new KeyStruct(Major.ParAttr, Minor.ParBullet, "pnlvlblt"),
+ new KeyStruct(Major.ParAttr, Minor.ParSimple, "pnlvlbody"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumCont, "pnlvlcont"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumOnce, "pnnumonce"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumAcross, "pnacross"),
+ new KeyStruct(Major.ParAttr, Minor.ParHangIndent, "pnhang"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumRestart, "pnrestart"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumCardinal, "pncard"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumDecimal, "pndec"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumULetter, "pnucltr"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumURoman, "pnucrm"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumLLetter, "pnlcltr"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumLRoman, "pnlcrm"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumOrdinal, "pnord"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumOrdinalText, "pnordt"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumBold, "pnb"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumItalic, "pni"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumAllCaps, "pncaps"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumSmallCaps, "pnscaps"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumUnder, "pnul"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumDotUnder, "pnuld"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumDbUnder, "pnuldb"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumNoUnder, "pnulnone"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumWordUnder, "pnulw"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumStrikethru, "pnstrike"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumForeColor, "pncf"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumFont, "pnf"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumFontSize, "pnfs"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumIndent, "pnindent"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumSpacing, "pnsp"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumInclPrev, "pnprev"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumCenter, "pnqc"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumLeft, "pnql"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumRight, "pnqr"),
+ new KeyStruct(Major.ParAttr, Minor.ParNumStartAt, "pnstart"),
+ new KeyStruct(Major.ParAttr, Minor.BorderTop, "brdrt"),
+ new KeyStruct(Major.ParAttr, Minor.BorderBottom, "brdrb"),
+ new KeyStruct(Major.ParAttr, Minor.BorderLeft, "brdrl"),
+ new KeyStruct(Major.ParAttr, Minor.BorderRight, "brdrr"),
+ new KeyStruct(Major.ParAttr, Minor.BorderBetween, "brdrbtw"),
+ new KeyStruct(Major.ParAttr, Minor.BorderBar, "brdrbar"),
+ new KeyStruct(Major.ParAttr, Minor.BorderBox, "box"),
+ new KeyStruct(Major.ParAttr, Minor.BorderSingle, "brdrs"),
+ new KeyStruct(Major.ParAttr, Minor.BorderThick, "brdrth"),
+ new KeyStruct(Major.ParAttr, Minor.BorderShadow, "brdrsh"),
+ new KeyStruct(Major.ParAttr, Minor.BorderDouble, "brdrdb"),
+ new KeyStruct(Major.ParAttr, Minor.BorderDot, "brdrdot"),
+ new KeyStruct(Major.ParAttr, Minor.BorderDot, "brdrdash"),
+ new KeyStruct(Major.ParAttr, Minor.BorderHair, "brdrhair"),
+ new KeyStruct(Major.ParAttr, Minor.BorderWidth, "brdrw"),
+ new KeyStruct(Major.ParAttr, Minor.BorderColor, "brdrcf"),
+ new KeyStruct(Major.ParAttr, Minor.BorderSpace, "brsp"),
+ new KeyStruct(Major.ParAttr, Minor.Shading, "shading"),
+ new KeyStruct(Major.ParAttr, Minor.BgPatH, "bghoriz"),
+ new KeyStruct(Major.ParAttr, Minor.BgPatV, "bgvert"),
+ new KeyStruct(Major.ParAttr, Minor.FwdDiagBgPat, "bgfdiag"),
+ new KeyStruct(Major.ParAttr, Minor.BwdDiagBgPat, "bgbdiag"),
+ new KeyStruct(Major.ParAttr, Minor.HatchBgPat, "bgcross"),
+ new KeyStruct(Major.ParAttr, Minor.DiagHatchBgPat, "bgdcross"),
+ new KeyStruct(Major.ParAttr, Minor.DarkBgPatH, "bgdkhoriz"),
+ new KeyStruct(Major.ParAttr, Minor.DarkBgPatV, "bgdkvert"),
+ new KeyStruct(Major.ParAttr, Minor.FwdDarkBgPat, "bgdkfdiag"),
+ new KeyStruct(Major.ParAttr, Minor.BwdDarkBgPat, "bgdkbdiag"),
+ new KeyStruct(Major.ParAttr, Minor.DarkHatchBgPat, "bgdkcross"),
+ new KeyStruct(Major.ParAttr, Minor.DarkDiagHatchBgPat, "bgdkdcross"),
+ new KeyStruct(Major.ParAttr, Minor.BgPatLineColor, "cfpat"),
+ new KeyStruct(Major.ParAttr, Minor.BgPatColor, "cbpat"),
+ new KeyStruct(Major.SectAttr, Minor.SectDef, "sectd"),
+ new KeyStruct(Major.SectAttr, Minor.ENoteHere, "endnhere"),
+ new KeyStruct(Major.SectAttr, Minor.PrtBinFirst, "binfsxn"),
+ new KeyStruct(Major.SectAttr, Minor.PrtBin, "binsxn"),
+ new KeyStruct(Major.SectAttr, Minor.SectStyleNum, "ds"),
+ new KeyStruct(Major.SectAttr, Minor.NoBreak, "sbknone"),
+ new KeyStruct(Major.SectAttr, Minor.ColBreak, "sbkcol"),
+ new KeyStruct(Major.SectAttr, Minor.PageBreak, "sbkpage"),
+ new KeyStruct(Major.SectAttr, Minor.EvenBreak, "sbkeven"),
+ new KeyStruct(Major.SectAttr, Minor.OddBreak, "sbkodd"),
+ new KeyStruct(Major.SectAttr, Minor.Columns, "cols"),
+ new KeyStruct(Major.SectAttr, Minor.ColumnSpace, "colsx"),
+ new KeyStruct(Major.SectAttr, Minor.ColumnNumber, "colno"),
+ new KeyStruct(Major.SectAttr, Minor.ColumnSpRight, "colsr"),
+ new KeyStruct(Major.SectAttr, Minor.ColumnWidth, "colw"),
+ new KeyStruct(Major.SectAttr, Minor.ColumnLine, "linebetcol"),
+ new KeyStruct(Major.SectAttr, Minor.LineModulus, "linemod"),
+ new KeyStruct(Major.SectAttr, Minor.LineDist, "linex"),
+ new KeyStruct(Major.SectAttr, Minor.LineStarts, "linestarts"),
+ new KeyStruct(Major.SectAttr, Minor.LineRestart, "linerestart"),
+ new KeyStruct(Major.SectAttr, Minor.LineRestartPg, "lineppage"),
+ new KeyStruct(Major.SectAttr, Minor.LineCont, "linecont"),
+ new KeyStruct(Major.SectAttr, Minor.SectPageWid, "pgwsxn"),
+ new KeyStruct(Major.SectAttr, Minor.SectPageHt, "pghsxn"),
+ new KeyStruct(Major.SectAttr, Minor.SectMarginLeft, "marglsxn"),
+ new KeyStruct(Major.SectAttr, Minor.SectMarginRight, "margrsxn"),
+ new KeyStruct(Major.SectAttr, Minor.SectMarginTop, "margtsxn"),
+ new KeyStruct(Major.SectAttr, Minor.SectMarginBottom, "margbsxn"),
+ new KeyStruct(Major.SectAttr, Minor.SectMarginGutter, "guttersxn"),
+ new KeyStruct(Major.SectAttr, Minor.SectLandscape, "lndscpsxn"),
+ new KeyStruct(Major.SectAttr, Minor.TitleSpecial, "titlepg"),
+ new KeyStruct(Major.SectAttr, Minor.HeaderY, "headery"),
+ new KeyStruct(Major.SectAttr, Minor.FooterY, "footery"),
+ new KeyStruct(Major.SectAttr, Minor.PageStarts, "pgnstarts"),
+ new KeyStruct(Major.SectAttr, Minor.PageCont, "pgncont"),
+ new KeyStruct(Major.SectAttr, Minor.PageRestart, "pgnrestart"),
+ new KeyStruct(Major.SectAttr, Minor.PageNumRight, "pgnx"),
+ new KeyStruct(Major.SectAttr, Minor.PageNumTop, "pgny"),
+ new KeyStruct(Major.SectAttr, Minor.PageDecimal, "pgndec"),
+ new KeyStruct(Major.SectAttr, Minor.PageURoman, "pgnucrm"),
+ new KeyStruct(Major.SectAttr, Minor.PageLRoman, "pgnlcrm"),
+ new KeyStruct(Major.SectAttr, Minor.PageULetter, "pgnucltr"),
+ new KeyStruct(Major.SectAttr, Minor.PageLLetter, "pgnlcltr"),
+ new KeyStruct(Major.SectAttr, Minor.PageNumHyphSep, "pgnhnsh"),
+ new KeyStruct(Major.SectAttr, Minor.PageNumSpaceSep, "pgnhnsp"),
+ new KeyStruct(Major.SectAttr, Minor.PageNumColonSep, "pgnhnsc"),
+ new KeyStruct(Major.SectAttr, Minor.PageNumEmdashSep, "pgnhnsm"),
+ new KeyStruct(Major.SectAttr, Minor.PageNumEndashSep, "pgnhnsn"),
+ new KeyStruct(Major.SectAttr, Minor.TopVAlign, "vertalt"),
+ new KeyStruct(Major.SectAttr, Minor.BottomVAlign, "vertalb"),
+ new KeyStruct(Major.SectAttr, Minor.CenterVAlign, "vertalc"),
+ new KeyStruct(Major.SectAttr, Minor.JustVAlign, "vertalj"),
+ new KeyStruct(Major.SectAttr, Minor.RTLSect, "rtlsect"),
+ new KeyStruct(Major.SectAttr, Minor.LTRSect, "ltrsect"),
+ new KeyStruct(Major.DocAttr, Minor.DefTab, "deftab"),
+ new KeyStruct(Major.DocAttr, Minor.HyphHotZone, "hyphhotz"),
+ new KeyStruct(Major.DocAttr, Minor.HyphConsecLines, "hyphconsec"),
+ new KeyStruct(Major.DocAttr, Minor.HyphCaps, "hyphcaps"),
+ new KeyStruct(Major.DocAttr, Minor.HyphAuto, "hyphauto"),
+ new KeyStruct(Major.DocAttr, Minor.LineStart, "linestart"),
+ new KeyStruct(Major.DocAttr, Minor.FracWidth, "fracwidth"),
+ new KeyStruct(Major.DocAttr, Minor.MakeBackup, "makeback"),
+ new KeyStruct(Major.DocAttr, Minor.MakeBackup, "makebackup"),
+ new KeyStruct(Major.DocAttr, Minor.RTFDefault, "defformat"),
+ new KeyStruct(Major.DocAttr, Minor.PSOverlay, "psover"),
+ new KeyStruct(Major.DocAttr, Minor.DocTemplate, "doctemp"),
+ new KeyStruct(Major.DocAttr, Minor.DefLanguage, "deflang"),
+ new KeyStruct(Major.DocAttr, Minor.FENoteType, "fet"),
+ new KeyStruct(Major.DocAttr, Minor.FNoteEndSect, "endnotes"),
+ new KeyStruct(Major.DocAttr, Minor.FNoteEndDoc, "enddoc"),
+ new KeyStruct(Major.DocAttr, Minor.FNoteText, "ftntj"),
+ new KeyStruct(Major.DocAttr, Minor.FNoteBottom, "ftnbj"),
+ new KeyStruct(Major.DocAttr, Minor.ENoteEndSect, "aendnotes"),
+ new KeyStruct(Major.DocAttr, Minor.ENoteEndDoc, "aenddoc"),
+ new KeyStruct(Major.DocAttr, Minor.ENoteText, "aftntj"),
+ new KeyStruct(Major.DocAttr, Minor.ENoteBottom, "aftnbj"),
+ new KeyStruct(Major.DocAttr, Minor.FNoteStart, "ftnstart"),
+ new KeyStruct(Major.DocAttr, Minor.ENoteStart, "aftnstart"),
+ new KeyStruct(Major.DocAttr, Minor.FNoteRestartPage, "ftnrstpg"),
+ new KeyStruct(Major.DocAttr, Minor.FNoteRestart, "ftnrestart"),
+ new KeyStruct(Major.DocAttr, Minor.FNoteRestartCont, "ftnrstcont"),
+ new KeyStruct(Major.DocAttr, Minor.ENoteRestart, "aftnrestart"),
+ new KeyStruct(Major.DocAttr, Minor.ENoteRestartCont, "aftnrstcont"),
+ new KeyStruct(Major.DocAttr, Minor.FNoteNumArabic, "ftnnar"),
+ new KeyStruct(Major.DocAttr, Minor.FNoteNumLLetter, "ftnnalc"),
+ new KeyStruct(Major.DocAttr, Minor.FNoteNumULetter, "ftnnauc"),
+ new KeyStruct(Major.DocAttr, Minor.FNoteNumLRoman, "ftnnrlc"),
+ new KeyStruct(Major.DocAttr, Minor.FNoteNumURoman, "ftnnruc"),
+ new KeyStruct(Major.DocAttr, Minor.FNoteNumChicago, "ftnnchi"),
+ new KeyStruct(Major.DocAttr, Minor.ENoteNumArabic, "aftnnar"),
+ new KeyStruct(Major.DocAttr, Minor.ENoteNumLLetter, "aftnnalc"),
+ new KeyStruct(Major.DocAttr, Minor.ENoteNumULetter, "aftnnauc"),
+ new KeyStruct(Major.DocAttr, Minor.ENoteNumLRoman, "aftnnrlc"),
+ new KeyStruct(Major.DocAttr, Minor.ENoteNumURoman, "aftnnruc"),
+ new KeyStruct(Major.DocAttr, Minor.ENoteNumChicago, "aftnnchi"),
+ new KeyStruct(Major.DocAttr, Minor.PaperWidth, "paperw"),
+ new KeyStruct(Major.DocAttr, Minor.PaperHeight, "paperh"),
+ new KeyStruct(Major.DocAttr, Minor.PaperSize, "psz"),
+ new KeyStruct(Major.DocAttr, Minor.LeftMargin, "margl"),
+ new KeyStruct(Major.DocAttr, Minor.RightMargin, "margr"),
+ new KeyStruct(Major.DocAttr, Minor.TopMargin, "margt"),
+ new KeyStruct(Major.DocAttr, Minor.BottomMargin, "margb"),
+ new KeyStruct(Major.DocAttr, Minor.FacingPage, "facingp"),
+ new KeyStruct(Major.DocAttr, Minor.GutterWid, "gutter"),
+ new KeyStruct(Major.DocAttr, Minor.MirrorMargin, "margmirror"),
+ new KeyStruct(Major.DocAttr, Minor.Landscape, "landscape"),
+ new KeyStruct(Major.DocAttr, Minor.PageStart, "pgnstart"),
+ new KeyStruct(Major.DocAttr, Minor.WidowCtrl, "widowctrl"),
+ new KeyStruct(Major.DocAttr, Minor.LinkStyles, "linkstyles"),
+ new KeyStruct(Major.DocAttr, Minor.NoAutoTabIndent, "notabind"),
+ new KeyStruct(Major.DocAttr, Minor.WrapSpaces, "wraptrsp"),
+ new KeyStruct(Major.DocAttr, Minor.PrintColorsBlack, "prcolbl"),
+ new KeyStruct(Major.DocAttr, Minor.NoExtraSpaceRL, "noextrasprl"),
+ new KeyStruct(Major.DocAttr, Minor.NoColumnBalance, "nocolbal"),
+ new KeyStruct(Major.DocAttr, Minor.CvtMailMergeQuote, "cvmme"),
+ new KeyStruct(Major.DocAttr, Minor.SuppressTopSpace, "sprstsp"),
+ new KeyStruct(Major.DocAttr, Minor.SuppressPreParSpace, "sprsspbf"),
+ new KeyStruct(Major.DocAttr, Minor.CombineTblBorders, "otblrul"),
+ new KeyStruct(Major.DocAttr, Minor.TranspMetafiles, "transmf"),
+ new KeyStruct(Major.DocAttr, Minor.SwapBorders, "swpbdr"),
+ new KeyStruct(Major.DocAttr, Minor.ShowHardBreaks, "brkfrm"),
+ new KeyStruct(Major.DocAttr, Minor.FormProtected, "formprot"),
+ new KeyStruct(Major.DocAttr, Minor.AllProtected, "allprot"),
+ new KeyStruct(Major.DocAttr, Minor.FormShading, "formshade"),
+ new KeyStruct(Major.DocAttr, Minor.FormDisplay, "formdisp"),
+ new KeyStruct(Major.DocAttr, Minor.PrintData, "printdata"),
+ new KeyStruct(Major.DocAttr, Minor.RevProtected, "revprot"),
+ new KeyStruct(Major.DocAttr, Minor.Revisions, "revisions"),
+ new KeyStruct(Major.DocAttr, Minor.RevDisplay, "revprop"),
+ new KeyStruct(Major.DocAttr, Minor.RevBar, "revbar"),
+ new KeyStruct(Major.DocAttr, Minor.AnnotProtected, "annotprot"),
+ new KeyStruct(Major.DocAttr, Minor.RTLDoc, "rtldoc"),
+ new KeyStruct(Major.DocAttr, Minor.LTRDoc, "ltrdoc"),
+ new KeyStruct(Major.StyleAttr, Minor.Additive, "additive"),
+ new KeyStruct(Major.StyleAttr, Minor.BasedOn, "sbasedon"),
+ new KeyStruct(Major.StyleAttr, Minor.Next, "snext"),
+ new KeyStruct(Major.PictAttr, Minor.MacQD, "macpict"),
+ new KeyStruct(Major.PictAttr, Minor.PMMetafile, "pmmetafile"),
+ new KeyStruct(Major.PictAttr, Minor.WinMetafile, "wmetafile"),
+ new KeyStruct(Major.PictAttr, Minor.DevIndBitmap, "dibitmap"),
+ new KeyStruct(Major.PictAttr, Minor.WinBitmap, "wbitmap"),
+ new KeyStruct(Major.PictAttr, Minor.PixelBits, "wbmbitspixel"),
+ new KeyStruct(Major.PictAttr, Minor.BitmapPlanes, "wbmplanes"),
+ new KeyStruct(Major.PictAttr, Minor.BitmapWid, "wbmwidthbytes"),
+ new KeyStruct(Major.PictAttr, Minor.PicWid, "picw"),
+ new KeyStruct(Major.PictAttr, Minor.PicHt, "pich"),
+ new KeyStruct(Major.PictAttr, Minor.PicGoalWid, "picwgoal"),
+ new KeyStruct(Major.PictAttr, Minor.PicGoalHt, "pichgoal"),
+ new KeyStruct(Major.PictAttr, Minor.PicGoalWid, "picwGoal"),
+ new KeyStruct(Major.PictAttr, Minor.PicGoalHt, "pichGoal"),
+ new KeyStruct(Major.PictAttr, Minor.PicScaleX, "picscalex"),
+ new KeyStruct(Major.PictAttr, Minor.PicScaleY, "picscaley"),
+ new KeyStruct(Major.PictAttr, Minor.PicScaled, "picscaled"),
+ new KeyStruct(Major.PictAttr, Minor.PicCropTop, "piccropt"),
+ new KeyStruct(Major.PictAttr, Minor.PicCropBottom, "piccropb"),
+ new KeyStruct(Major.PictAttr, Minor.PicCropLeft, "piccropl"),
+ new KeyStruct(Major.PictAttr, Minor.PicCropRight, "piccropr"),
+ new KeyStruct(Major.PictAttr, Minor.PicMFHasBitmap, "picbmp"),
+ new KeyStruct(Major.PictAttr, Minor.PicMFBitsPerPixel, "picbpp"),
+ new KeyStruct(Major.PictAttr, Minor.PicBinary, "bin"),
+ new KeyStruct(Major.NeXTGrAttr, Minor.NeXTGWidth, "width"),
+ new KeyStruct(Major.NeXTGrAttr, Minor.NeXTGHeight, "height"),
+ new KeyStruct(Major.Destination, Minor.FontTbl, "fonttbl"),
+ new KeyStruct(Major.Destination, Minor.FontAltName, "falt"),
+ new KeyStruct(Major.Destination, Minor.EmbeddedFont, "fonteb"),
+ new KeyStruct(Major.Destination, Minor.FontFile, "fontfile"),
+ new KeyStruct(Major.Destination, Minor.FileTbl, "filetbl"),
+ new KeyStruct(Major.Destination, Minor.FileInfo, "file"),
+ new KeyStruct(Major.Destination, Minor.ColorTbl, "colortbl"),
+ new KeyStruct(Major.Destination, Minor.StyleSheet, "stylesheet"),
+ new KeyStruct(Major.Destination, Minor.KeyCode, "keycode"),
+ new KeyStruct(Major.Destination, Minor.RevisionTbl, "revtbl"),
+ new KeyStruct(Major.Destination, Minor.Info, "info"),
+ new KeyStruct(Major.Destination, Minor.ITitle, "title"),
+ new KeyStruct(Major.Destination, Minor.ISubject, "subject"),
+ new KeyStruct(Major.Destination, Minor.IAuthor, "author"),
+ new KeyStruct(Major.Destination, Minor.IOperator, "operator"),
+ new KeyStruct(Major.Destination, Minor.IKeywords, "keywords"),
+ new KeyStruct(Major.Destination, Minor.IComment, "comment"),
+ new KeyStruct(Major.Destination, Minor.IVersion, "version"),
+ new KeyStruct(Major.Destination, Minor.IDoccomm, "doccomm"),
+ new KeyStruct(Major.Destination, Minor.IVerscomm, "verscomm"),
+ new KeyStruct(Major.Destination, Minor.NextFile, "nextfile"),
+ new KeyStruct(Major.Destination, Minor.Template, "template"),
+ new KeyStruct(Major.Destination, Minor.FNSep, "ftnsep"),
+ new KeyStruct(Major.Destination, Minor.FNContSep, "ftnsepc"),
+ new KeyStruct(Major.Destination, Minor.FNContNotice, "ftncn"),
+ new KeyStruct(Major.Destination, Minor.ENSep, "aftnsep"),
+ new KeyStruct(Major.Destination, Minor.ENContSep, "aftnsepc"),
+ new KeyStruct(Major.Destination, Minor.ENContNotice, "aftncn"),
+ new KeyStruct(Major.Destination, Minor.PageNumLevel, "pgnhn"),
+ new KeyStruct(Major.Destination, Minor.ParNumLevelStyle, "pnseclvl"),
+ new KeyStruct(Major.Destination, Minor.Header, "header"),
+ new KeyStruct(Major.Destination, Minor.Footer, "footer"),
+ new KeyStruct(Major.Destination, Minor.HeaderLeft, "headerl"),
+ new KeyStruct(Major.Destination, Minor.HeaderRight, "headerr"),
+ new KeyStruct(Major.Destination, Minor.HeaderFirst, "headerf"),
+ new KeyStruct(Major.Destination, Minor.FooterLeft, "footerl"),
+ new KeyStruct(Major.Destination, Minor.FooterRight, "footerr"),
+ new KeyStruct(Major.Destination, Minor.FooterFirst, "footerf"),
+ new KeyStruct(Major.Destination, Minor.ParNumText, "pntext"),
+ new KeyStruct(Major.Destination, Minor.ParNumbering, "pn"),
+ new KeyStruct(Major.Destination, Minor.ParNumTextAfter, "pntexta"),
+ new KeyStruct(Major.Destination, Minor.ParNumTextBefore, "pntextb"),
+ new KeyStruct(Major.Destination, Minor.BookmarkStart, "bkmkstart"),
+ new KeyStruct(Major.Destination, Minor.BookmarkEnd, "bkmkend"),
+ new KeyStruct(Major.Destination, Minor.Pict, "pict"),
+ new KeyStruct(Major.Destination, Minor.Object, "object"),
+ new KeyStruct(Major.Destination, Minor.ObjClass, "objclass"),
+ new KeyStruct(Major.Destination, Minor.ObjName, "objname"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjTime, "objtime"),
+ new KeyStruct(Major.Destination, Minor.ObjData, "objdata"),
+ new KeyStruct(Major.Destination, Minor.ObjAlias, "objalias"),
+ new KeyStruct(Major.Destination, Minor.ObjSection, "objsect"),
+ new KeyStruct(Major.Destination, Minor.ObjItem, "objitem"),
+ new KeyStruct(Major.Destination, Minor.ObjTopic, "objtopic"),
+ new KeyStruct(Major.Destination, Minor.ObjResult, "result"),
+ new KeyStruct(Major.Destination, Minor.DrawObject, "do"),
+ new KeyStruct(Major.Destination, Minor.Footnote, "footnote"),
+ new KeyStruct(Major.Destination, Minor.AnnotRefStart, "atrfstart"),
+ new KeyStruct(Major.Destination, Minor.AnnotRefEnd, "atrfend"),
+ new KeyStruct(Major.Destination, Minor.AnnotID, "atnid"),
+ new KeyStruct(Major.Destination, Minor.AnnotAuthor, "atnauthor"),
+ new KeyStruct(Major.Destination, Minor.Annotation, "annotation"),
+ new KeyStruct(Major.Destination, Minor.AnnotRef, "atnref"),
+ new KeyStruct(Major.Destination, Minor.AnnotTime, "atntime"),
+ new KeyStruct(Major.Destination, Minor.AnnotIcon, "atnicn"),
+ new KeyStruct(Major.Destination, Minor.Field, "field"),
+ new KeyStruct(Major.Destination, Minor.FieldInst, "fldinst"),
+ new KeyStruct(Major.Destination, Minor.FieldResult, "fldrslt"),
+ new KeyStruct(Major.Destination, Minor.DataField, "datafield"),
+ new KeyStruct(Major.Destination, Minor.Index, "xe"),
+ new KeyStruct(Major.Destination, Minor.IndexText, "txe"),
+ new KeyStruct(Major.Destination, Minor.IndexRange, "rxe"),
+ new KeyStruct(Major.Destination, Minor.TOC, "tc"),
+ new KeyStruct(Major.Destination, Minor.NeXTGraphic, "NeXTGraphic"),
+ new KeyStruct(Major.FontFamily, Minor.FFNil, "fnil"),
+ new KeyStruct(Major.FontFamily, Minor.FFRoman, "froman"),
+ new KeyStruct(Major.FontFamily, Minor.FFSwiss, "fswiss"),
+ new KeyStruct(Major.FontFamily, Minor.FFModern, "fmodern"),
+ new KeyStruct(Major.FontFamily, Minor.FFScript, "fscript"),
+ new KeyStruct(Major.FontFamily, Minor.FFDecor, "fdecor"),
+ new KeyStruct(Major.FontFamily, Minor.FFTech, "ftech"),
+ new KeyStruct(Major.FontFamily, Minor.FFBidirectional, "fbidi"),
+ new KeyStruct(Major.FontAttr, Minor.FontCharSet, "fcharset"),
+ new KeyStruct(Major.FontAttr, Minor.FontPitch, "fprq"),
+ new KeyStruct(Major.FontAttr, Minor.FontCodePage, "cpg"),
+ new KeyStruct(Major.FontAttr, Minor.FTypeNil, "ftnil"),
+ new KeyStruct(Major.FontAttr, Minor.FTypeTrueType, "fttruetype"),
+ new KeyStruct(Major.FileAttr, Minor.FileNum, "fid"),
+ new KeyStruct(Major.FileAttr, Minor.FileRelPath, "frelative"),
+ new KeyStruct(Major.FileAttr, Minor.FileOSNum, "fosnum"),
+ new KeyStruct(Major.FileSource, Minor.SrcMacintosh, "fvalidmac"),
+ new KeyStruct(Major.FileSource, Minor.SrcDOS, "fvaliddos"),
+ new KeyStruct(Major.FileSource, Minor.SrcNTFS, "fvalidntfs"),
+ new KeyStruct(Major.FileSource, Minor.SrcHPFS, "fvalidhpfs"),
+ new KeyStruct(Major.FileSource, Minor.SrcNetwork, "fnetwork"),
+ new KeyStruct(Major.ColorName, Minor.Red, "red"),
+ new KeyStruct(Major.ColorName, Minor.Green, "green"),
+ new KeyStruct(Major.ColorName, Minor.Blue, "blue"),
+ new KeyStruct(Major.CharSet, Minor.MacCharSet, "mac"),
+ new KeyStruct(Major.CharSet, Minor.AnsiCharSet, "ansi"),
+ new KeyStruct(Major.CharSet, Minor.PcCharSet, "pc"),
+ new KeyStruct(Major.CharSet, Minor.PcaCharSet, "pca"),
+ new KeyStruct(Major.TblAttr, Minor.RowDef, "trowd"),
+ new KeyStruct(Major.TblAttr, Minor.RowGapH, "trgaph"),
+ new KeyStruct(Major.TblAttr, Minor.CellPos, "cellx"),
+ new KeyStruct(Major.TblAttr, Minor.MergeRngFirst, "clmgf"),
+ new KeyStruct(Major.TblAttr, Minor.MergePrevious, "clmrg"),
+ new KeyStruct(Major.TblAttr, Minor.RowLeft, "trql"),
+ new KeyStruct(Major.TblAttr, Minor.RowRight, "trqr"),
+ new KeyStruct(Major.TblAttr, Minor.RowCenter, "trqc"),
+ new KeyStruct(Major.TblAttr, Minor.RowLeftEdge, "trleft"),
+ new KeyStruct(Major.TblAttr, Minor.RowHt, "trrh"),
+ new KeyStruct(Major.TblAttr, Minor.RowHeader, "trhdr"),
+ new KeyStruct(Major.TblAttr, Minor.RowKeep, "trkeep"),
+ new KeyStruct(Major.TblAttr, Minor.RTLRow, "rtlrow"),
+ new KeyStruct(Major.TblAttr, Minor.LTRRow, "ltrrow"),
+ new KeyStruct(Major.TblAttr, Minor.RowBordTop, "trbrdrt"),
+ new KeyStruct(Major.TblAttr, Minor.RowBordLeft, "trbrdrl"),
+ new KeyStruct(Major.TblAttr, Minor.RowBordBottom, "trbrdrb"),
+ new KeyStruct(Major.TblAttr, Minor.RowBordRight, "trbrdrr"),
+ new KeyStruct(Major.TblAttr, Minor.RowBordHoriz, "trbrdrh"),
+ new KeyStruct(Major.TblAttr, Minor.RowBordVert, "trbrdrv"),
+ new KeyStruct(Major.TblAttr, Minor.CellBordBottom, "clbrdrb"),
+ new KeyStruct(Major.TblAttr, Minor.CellBordTop, "clbrdrt"),
+ new KeyStruct(Major.TblAttr, Minor.CellBordLeft, "clbrdrl"),
+ new KeyStruct(Major.TblAttr, Minor.CellBordRight, "clbrdrr"),
+ new KeyStruct(Major.TblAttr, Minor.CellShading, "clshdng"),
+ new KeyStruct(Major.TblAttr, Minor.CellBgPatH, "clbghoriz"),
+ new KeyStruct(Major.TblAttr, Minor.CellBgPatV, "clbgvert"),
+ new KeyStruct(Major.TblAttr, Minor.CellFwdDiagBgPat, "clbgfdiag"),
+ new KeyStruct(Major.TblAttr, Minor.CellBwdDiagBgPat, "clbgbdiag"),
+ new KeyStruct(Major.TblAttr, Minor.CellHatchBgPat, "clbgcross"),
+ new KeyStruct(Major.TblAttr, Minor.CellDiagHatchBgPat, "clbgdcross"),
+ new KeyStruct(Major.TblAttr, Minor.CellDarkBgPatH, "clbgdkhoriz"),
+ new KeyStruct(Major.TblAttr, Minor.CellDarkBgPatH, "clbgdkhor"),
+ new KeyStruct(Major.TblAttr, Minor.CellDarkBgPatV, "clbgdkvert"),
+ new KeyStruct(Major.TblAttr, Minor.CellFwdDarkBgPat, "clbgdkfdiag"),
+ new KeyStruct(Major.TblAttr, Minor.CellBwdDarkBgPat, "clbgdkbdiag"),
+ new KeyStruct(Major.TblAttr, Minor.CellDarkHatchBgPat, "clbgdkcross"),
+ new KeyStruct(Major.TblAttr, Minor.CellDarkDiagHatchBgPat, "clbgdkdcross"),
+ new KeyStruct(Major.TblAttr, Minor.CellBgPatLineColor, "clcfpat"),
+ new KeyStruct(Major.TblAttr, Minor.CellBgPatColor, "clcbpat"),
+ new KeyStruct(Major.FieldAttr, Minor.FieldDirty, "flddirty"),
+ new KeyStruct(Major.FieldAttr, Minor.FieldEdited, "fldedit"),
+ new KeyStruct(Major.FieldAttr, Minor.FieldLocked, "fldlock"),
+ new KeyStruct(Major.FieldAttr, Minor.FieldPrivate, "fldpriv"),
+ new KeyStruct(Major.FieldAttr, Minor.FieldAlt, "fldalt"),
+ new KeyStruct(Major.PosAttr, Minor.AbsWid, "absw"),
+ new KeyStruct(Major.PosAttr, Minor.AbsHt, "absh"),
+ new KeyStruct(Major.PosAttr, Minor.RPosMargH, "phmrg"),
+ new KeyStruct(Major.PosAttr, Minor.RPosPageH, "phpg"),
+ new KeyStruct(Major.PosAttr, Minor.RPosColH, "phcol"),
+ new KeyStruct(Major.PosAttr, Minor.PosX, "posx"),
+ new KeyStruct(Major.PosAttr, Minor.PosNegX, "posnegx"),
+ new KeyStruct(Major.PosAttr, Minor.PosXCenter, "posxc"),
+ new KeyStruct(Major.PosAttr, Minor.PosXInside, "posxi"),
+ new KeyStruct(Major.PosAttr, Minor.PosXOutSide, "posxo"),
+ new KeyStruct(Major.PosAttr, Minor.PosXRight, "posxr"),
+ new KeyStruct(Major.PosAttr, Minor.PosXLeft, "posxl"),
+ new KeyStruct(Major.PosAttr, Minor.RPosMargV, "pvmrg"),
+ new KeyStruct(Major.PosAttr, Minor.RPosPageV, "pvpg"),
+ new KeyStruct(Major.PosAttr, Minor.RPosParaV, "pvpara"),
+ new KeyStruct(Major.PosAttr, Minor.PosY, "posy"),
+ new KeyStruct(Major.PosAttr, Minor.PosNegY, "posnegy"),
+ new KeyStruct(Major.PosAttr, Minor.PosYInline, "posyil"),
+ new KeyStruct(Major.PosAttr, Minor.PosYTop, "posyt"),
+ new KeyStruct(Major.PosAttr, Minor.PosYCenter, "posyc"),
+ new KeyStruct(Major.PosAttr, Minor.PosYBottom, "posyb"),
+ new KeyStruct(Major.PosAttr, Minor.NoWrap, "nowrap"),
+ new KeyStruct(Major.PosAttr, Minor.DistFromTextAll, "dxfrtext"),
+ new KeyStruct(Major.PosAttr, Minor.DistFromTextX, "dfrmtxtx"),
+ new KeyStruct(Major.PosAttr, Minor.DistFromTextY, "dfrmtxty"),
+ new KeyStruct(Major.PosAttr, Minor.TextDistY, "dyfrtext"),
+ new KeyStruct(Major.PosAttr, Minor.DropCapLines, "dropcapli"),
+ new KeyStruct(Major.PosAttr, Minor.DropCapType, "dropcapt"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjEmb, "objemb"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjLink, "objlink"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjAutoLink, "objautlink"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjSubscriber, "objsub"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjPublisher, "objpub"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjICEmb, "objicemb"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjLinkSelf, "linkself"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjLock, "objupdate"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjUpdate, "objlock"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjHt, "objh"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjWid, "objw"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjSetSize, "objsetsize"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjAlign, "objalign"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjTransposeY, "objtransy"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjCropTop, "objcropt"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjCropBottom, "objcropb"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjCropLeft, "objcropl"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjCropRight, "objcropr"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjScaleX, "objscalex"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjScaleY, "objscaley"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjResRTF, "rsltrtf"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjResPict, "rsltpict"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjResBitmap, "rsltbmp"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjResText, "rslttxt"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjResMerge, "rsltmerge"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjBookmarkPubObj, "bkmkpub"),
+ new KeyStruct(Major.ObjAttr, Minor.ObjPubAutoUpdate, "pubauto"),
+ new KeyStruct(Major.ACharAttr, Minor.ACBold, "ab"),
+ new KeyStruct(Major.ACharAttr, Minor.ACAllCaps, "caps"),
+ new KeyStruct(Major.ACharAttr, Minor.ACForeColor, "acf"),
+ new KeyStruct(Major.ACharAttr, Minor.ACSubScript, "adn"),
+ new KeyStruct(Major.ACharAttr, Minor.ACExpand, "aexpnd"),
+ new KeyStruct(Major.ACharAttr, Minor.ACFontNum, "af"),
+ new KeyStruct(Major.ACharAttr, Minor.ACFontSize, "afs"),
+ new KeyStruct(Major.ACharAttr, Minor.ACItalic, "ai"),
+ new KeyStruct(Major.ACharAttr, Minor.ACLanguage, "alang"),
+ new KeyStruct(Major.ACharAttr, Minor.ACOutline, "aoutl"),
+ new KeyStruct(Major.ACharAttr, Minor.ACSmallCaps, "ascaps"),
+ new KeyStruct(Major.ACharAttr, Minor.ACShadow, "ashad"),
+ new KeyStruct(Major.ACharAttr, Minor.ACStrikeThru, "astrike"),
+ new KeyStruct(Major.ACharAttr, Minor.ACUnderline, "aul"),
+ new KeyStruct(Major.ACharAttr, Minor.ACDotUnderline, "auld"),
+ new KeyStruct(Major.ACharAttr, Minor.ACDbUnderline, "auldb"),
+ new KeyStruct(Major.ACharAttr, Minor.ACNoUnderline, "aulnone"),
+ new KeyStruct(Major.ACharAttr, Minor.ACWordUnderline, "aulw"),
+ new KeyStruct(Major.ACharAttr, Minor.ACSuperScript, "aup"),
+ new KeyStruct(Major.FNoteAttr, Minor.FNAlt, "ftnalt"),
+ new KeyStruct(Major.KeyCodeAttr, Minor.AltKey, "alt"),
+ new KeyStruct(Major.KeyCodeAttr, Minor.ShiftKey, "shift"),
+ new KeyStruct(Major.KeyCodeAttr, Minor.ControlKey, "ctrl"),
+ new KeyStruct(Major.KeyCodeAttr, Minor.FunctionKey, "fn"),
+ new KeyStruct(Major.BookmarkAttr, Minor.BookmarkFirstCol, "bkmkcolf"),
+ new KeyStruct(Major.BookmarkAttr, Minor.BookmarkLastCol, "bkmkcoll"),
+ new KeyStruct(Major.IndexAttr, Minor.IndexNumber, "xef"),
+ new KeyStruct(Major.IndexAttr, Minor.IndexBold, "bxe"),
+ new KeyStruct(Major.IndexAttr, Minor.IndexItalic, "ixe"),
+ new KeyStruct(Major.TOCAttr, Minor.TOCType, "tcf"),
+ new KeyStruct(Major.TOCAttr, Minor.TOCLevel, "tcl"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawLock, "dolock"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawPageRelX, "doxpage"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawColumnRelX, "dobxcolumn"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawMarginRelX, "dobxmargin"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawPageRelY, "dobypage"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawColumnRelY, "dobycolumn"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawMarginRelY, "dobymargin"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawHeight, "dobhgt"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawBeginGroup, "dpgroup"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawGroupCount, "dpcount"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawEndGroup, "dpendgroup"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawArc, "dparc"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawCallout, "dpcallout"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawEllipse, "dpellipse"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawLine, "dpline"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawPolygon, "dppolygon"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawPolyLine, "dppolyline"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawRect, "dprect"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawTextBox, "dptxbx"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawOffsetX, "dpx"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawSizeX, "dpxsize"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawOffsetY, "dpy"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawSizeY, "dpysize"),
+ new KeyStruct(Major.DrawAttr, Minor.COAngle, "dpcoa"),
+ new KeyStruct(Major.DrawAttr, Minor.COAccentBar, "dpcoaccent"),
+ new KeyStruct(Major.DrawAttr, Minor.COBestFit, "dpcobestfit"),
+ new KeyStruct(Major.DrawAttr, Minor.COBorder, "dpcoborder"),
+ new KeyStruct(Major.DrawAttr, Minor.COAttachAbsDist, "dpcodabs"),
+ new KeyStruct(Major.DrawAttr, Minor.COAttachBottom, "dpcodbottom"),
+ new KeyStruct(Major.DrawAttr, Minor.COAttachCenter, "dpcodcenter"),
+ new KeyStruct(Major.DrawAttr, Minor.COAttachTop, "dpcodtop"),
+ new KeyStruct(Major.DrawAttr, Minor.COLength, "dpcolength"),
+ new KeyStruct(Major.DrawAttr, Minor.CONegXQuadrant, "dpcominusx"),
+ new KeyStruct(Major.DrawAttr, Minor.CONegYQuadrant, "dpcominusy"),
+ new KeyStruct(Major.DrawAttr, Minor.COOffset, "dpcooffset"),
+ new KeyStruct(Major.DrawAttr, Minor.COAttachSmart, "dpcosmarta"),
+ new KeyStruct(Major.DrawAttr, Minor.CODoubleLine, "dpcotdouble"),
+ new KeyStruct(Major.DrawAttr, Minor.CORightAngle, "dpcotright"),
+ new KeyStruct(Major.DrawAttr, Minor.COSingleLine, "dpcotsingle"),
+ new KeyStruct(Major.DrawAttr, Minor.COTripleLine, "dpcottriple"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawTextBoxMargin, "dptxbxmar"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawTextBoxText, "dptxbxtext"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawRoundRect, "dproundr"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawPointX, "dpptx"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawPointY, "dppty"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawPolyCount, "dppolycount"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawArcFlipX, "dparcflipx"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawArcFlipY, "dparcflipy"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawLineBlue, "dplinecob"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawLineGreen, "dplinecog"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawLineRed, "dplinecor"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawLinePalette, "dplinepal"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawLineDashDot, "dplinedado"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawLineDashDotDot, "dplinedadodo"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawLineDash, "dplinedash"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawLineDot, "dplinedot"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawLineGray, "dplinegray"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawLineHollow, "dplinehollow"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawLineSolid, "dplinesolid"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawLineWidth, "dplinew"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawHollowEndArrow, "dpaendhol"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawEndArrowLength, "dpaendl"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawSolidEndArrow, "dpaendsol"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawEndArrowWidth, "dpaendw"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawHollowStartArrow,"dpastarthol"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawStartArrowLength,"dpastartl"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawSolidStartArrow, "dpastartsol"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawStartArrowWidth, "dpastartw"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawBgFillBlue, "dpfillbgcb"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawBgFillGreen, "dpfillbgcg"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawBgFillRed, "dpfillbgcr"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawBgFillPalette, "dpfillbgpal"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawBgFillGray, "dpfillbggray"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawFgFillBlue, "dpfillfgcb"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawFgFillGreen, "dpfillfgcg"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawFgFillRed, "dpfillfgcr"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawFgFillPalette, "dpfillfgpal"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawFgFillGray, "dpfillfggray"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawFillPatIndex, "dpfillpat"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawShadow, "dpshadow"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawShadowXOffset, "dpshadx"),
+ new KeyStruct(Major.DrawAttr, Minor.DrawShadowYOffset, "dpshady"),
+ new KeyStruct(Major.Version, Minor.Undefined, "rtf"),
+ new KeyStruct(Major.DefFont, Minor.Undefined, "deff"),
+ new KeyStruct(Major.Unicode, Minor.UnicodeCharBytes, "uc"),
+ new KeyStruct(Major.Unicode, Minor.UnicodeChar, "u"),
+ new KeyStruct(Major.Unicode, Minor.UnicodeDestination, "ud"),
+ new KeyStruct(Major.Unicode, Minor.UnicodeDualDestination, "upr"),
+ new KeyStruct(Major.Unicode, Minor.UnicodeAnsiCodepage, "ansicpg"),
+ };
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Major.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Major.cs
new file mode 100644
index 00000000000..023a012e370
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Major.cs
@@ -0,0 +1,67 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms.RTF {
+ internal enum Major {
+ // Group class
+ BeginGroup = 0,
+ EndGroup = 1,
+
+ // Control
+ Version = 0,
+ DefFont = 1,
+ CharSet = 2,
+
+ Destination = 3,
+ FontFamily = 4,
+ ColorName = 5,
+ SpecialChar = 6,
+ StyleAttr = 7,
+ DocAttr = 8,
+ SectAttr = 9,
+ TblAttr = 10,
+ ParAttr = 11,
+ CharAttr = 12,
+ PictAttr = 13,
+ BookmarkAttr = 14,
+ NeXTGrAttr = 15,
+ FieldAttr = 16,
+ TOCAttr = 17,
+ PosAttr = 18,
+ ObjAttr = 19,
+ FNoteAttr = 20,
+ KeyCodeAttr = 21,
+ ACharAttr = 22,
+ FontAttr = 23,
+ FileAttr = 24,
+ FileSource = 25,
+ DrawAttr = 26,
+ IndexAttr = 27,
+ Unicode = 28
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Minor.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Minor.cs
new file mode 100644
index 00000000000..92afb4a42f6
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Minor.cs
@@ -0,0 +1,765 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ internal enum Minor {
+ Undefined = -1,
+
+ // Major.CharSet
+ AnsiCharSet = 0,
+ MacCharSet = 1,
+ PcCharSet = 2,
+ PcaCharSet = 3,
+
+ // Major.Destination
+ FontTbl = 0,
+ FontAltName = 1,
+ EmbeddedFont = 2,
+ FontFile = 3,
+ FileTbl = 4,
+ FileInfo = 5,
+ ColorTbl = 6,
+ StyleSheet = 7,
+ KeyCode = 8,
+ RevisionTbl = 9,
+ Info = 10,
+ ITitle = 11,
+ ISubject = 12,
+ IAuthor = 13,
+ IOperator = 14,
+ IKeywords = 15,
+ IComment = 16,
+ IVersion = 17,
+ IDoccomm = 18,
+ IVerscomm = 19,
+ NextFile = 20,
+ Template = 21,
+ FNSep = 22,
+ FNContSep = 23,
+ FNContNotice = 24,
+ ENSep = 25,
+ ENContSep = 26,
+ ENContNotice = 27,
+ PageNumLevel = 28,
+ ParNumLevelStyle= 29,
+ Header = 30,
+ Footer = 31,
+ HeaderLeft = 32,
+ HeaderRight = 33,
+ HeaderFirst = 34,
+ FooterLeft = 35,
+ FooterRight = 36,
+ FooterFirst = 37,
+ ParNumText = 38,
+ ParNumbering = 39,
+ ParNumTextAfter = 40,
+ ParNumTextBefore= 41,
+ BookmarkStart = 42,
+ BookmarkEnd = 43,
+ Pict = 44,
+ Object = 45,
+ ObjClass = 46,
+ ObjName = 47,
+ ObjTime = 48,
+ ObjData = 49,
+ ObjAlias = 50,
+ ObjSection = 51,
+ ObjResult = 52,
+ ObjItem = 53,
+ ObjTopic = 54,
+ DrawObject = 55,
+ Footnote = 56,
+ AnnotRefStart = 57,
+ AnnotRefEnd = 58,
+ AnnotID = 59,
+ AnnotAuthor = 60,
+ Annotation = 61,
+ AnnotRef = 62,
+ AnnotTime = 63,
+ AnnotIcon = 64,
+ Field = 65,
+ FieldInst = 66,
+ FieldResult = 67,
+ DataField = 68,
+ Index = 69,
+ IndexText = 70,
+ IndexRange = 71,
+ TOC = 72,
+ NeXTGraphic = 73,
+ MaxDestination = 74,
+
+ // Major.FontFamily
+ FFNil = 0,
+ FFRoman = 1,
+ FFSwiss = 2,
+ FFModern = 3,
+ FFScript = 4,
+ FFDecor = 5,
+ FFTech = 6,
+ FFBidirectional = 7,
+
+ // Major.ColorName
+ Red = 0,
+ Green = 1,
+ Blue = 2,
+
+ // Major.SpecialChar
+ IIntVersion = 0,
+ ICreateTime = 1,
+ IRevisionTime = 2,
+ IPrintTime = 3,
+ IBackupTime = 4,
+ IEditTime = 5,
+ IYear = 6,
+ IMonth = 7,
+ IDay = 8,
+ IHour = 9,
+ IMinute = 10,
+ ISecond = 11,
+ INPages = 12,
+ INWords = 13,
+ INChars = 14,
+ IIntID = 15,
+ CurHeadDate = 16,
+ CurHeadDateLong = 17,
+ CurHeadDateAbbrev= 18,
+ CurHeadTime = 19,
+ CurHeadPage = 20,
+ SectNum = 21,
+ CurFNote = 22,
+ CurAnnotRef = 23,
+ FNoteSep = 24,
+ FNoteCont = 25,
+ Cell = 26,
+ Row = 27,
+ Par = 28,
+ Sect = 29,
+ Page = 30,
+ Column = 31,
+ Line = 32,
+ SoftPage = 33,
+ SoftColumn = 34,
+ SoftLine = 35,
+ SoftLineHt = 36,
+ Tab = 37,
+ EmDash = 38,
+ EnDash = 39,
+ EmSpace = 40,
+ EnSpace = 41,
+ Bullet = 42,
+ LQuote = 43,
+ RQuote = 44,
+ LDblQuote = 45,
+ RDblQuote = 46,
+ Formula = 47,
+ NoBrkSpace = 49,
+ NoReqHyphen = 50,
+ NoBrkHyphen = 51,
+ OptDest = 52,
+ LTRMark = 53,
+ RTLMark = 54,
+ NoWidthJoiner = 55,
+ NoWidthNonJoiner= 56,
+ CurHeadPict = 57,
+
+ // Major.StyleAttr
+ Additive = 0,
+ BasedOn = 1,
+ Next = 2,
+
+ // Major.DocAttr
+ DefTab = 0,
+ HyphHotZone = 1,
+ HyphConsecLines = 2,
+ HyphCaps = 3,
+ HyphAuto = 4,
+ LineStart = 5,
+ FracWidth = 6,
+ MakeBackup = 7,
+ RTFDefault = 8,
+ PSOverlay = 9,
+ DocTemplate = 10,
+ DefLanguage = 11,
+ FENoteType = 12,
+ FNoteEndSect = 13,
+ FNoteEndDoc = 14,
+ FNoteText = 15,
+ FNoteBottom = 16,
+ ENoteEndSect = 17,
+ ENoteEndDoc = 18,
+ ENoteText = 19,
+ ENoteBottom = 20,
+ FNoteStart = 21,
+ ENoteStart = 22,
+ FNoteRestartPage= 23,
+ FNoteRestart = 24,
+ FNoteRestartCont= 25,
+ ENoteRestart = 26,
+ ENoteRestartCont= 27,
+ FNoteNumArabic = 28,
+ FNoteNumLLetter = 29,
+ FNoteNumULetter = 30,
+ FNoteNumLRoman = 31,
+ FNoteNumURoman = 32,
+ FNoteNumChicago = 33,
+ ENoteNumArabic = 34,
+ ENoteNumLLetter = 35,
+ ENoteNumULetter = 36,
+ ENoteNumLRoman = 37,
+ ENoteNumURoman = 38,
+ ENoteNumChicago = 39,
+ PaperWidth = 40,
+ PaperHeight = 41,
+ PaperSize = 42,
+ LeftMargin = 43,
+ RightMargin = 44,
+ TopMargin = 45,
+ BottomMargin = 46,
+ FacingPage = 47,
+ GutterWid = 48,
+ MirrorMargin = 49,
+ Landscape = 50,
+ PageStart = 51,
+ WidowCtrl = 52,
+ LinkStyles = 53,
+ NoAutoTabIndent = 54,
+ WrapSpaces = 55,
+ PrintColorsBlack= 56,
+ NoExtraSpaceRL = 57,
+ NoColumnBalance = 58,
+ CvtMailMergeQuote= 59,
+ SuppressTopSpace= 60,
+ SuppressPreParSpace= 61,
+ CombineTblBorders= 62,
+ TranspMetafiles = 63,
+ SwapBorders = 64,
+ ShowHardBreaks = 65,
+ FormProtected = 66,
+ AllProtected = 67,
+ FormShading = 68,
+ FormDisplay = 69,
+ PrintData = 70,
+ RevProtected = 71,
+ Revisions = 72,
+ RevDisplay = 73,
+ RevBar = 74,
+ AnnotProtected = 75,
+ RTLDoc = 76,
+ LTRDoc = 77,
+
+ // Major.SectAttr
+
+ SectDef = 0,
+ ENoteHere = 1,
+ PrtBinFirst = 2,
+ PrtBin = 3,
+ SectStyleNum = 4,
+ NoBreak = 5,
+ ColBreak = 6,
+ PageBreak = 7,
+ EvenBreak = 8,
+ OddBreak = 9,
+ Columns = 10,
+ ColumnSpace = 11,
+ ColumnNumber = 12,
+ ColumnSpRight = 13,
+ ColumnWidth = 14,
+ ColumnLine = 15,
+ LineModulus = 16,
+ LineDist = 17,
+ LineStarts = 18,
+ LineRestart = 19,
+ LineRestartPg = 20,
+ LineCont = 21,
+ SectPageWid = 22,
+ SectPageHt = 23,
+ SectMarginLeft = 24,
+ SectMarginRight = 25,
+ SectMarginTop = 26,
+ SectMarginBottom= 27,
+ SectMarginGutter= 28,
+ SectLandscape = 29,
+ TitleSpecial = 30,
+ HeaderY = 31,
+ FooterY = 32,
+ PageStarts = 33,
+ PageCont = 34,
+ PageRestart = 35,
+ PageNumRight = 36,
+ PageNumTop = 37,
+ PageDecimal = 38,
+ PageURoman = 39,
+ PageLRoman = 40,
+ PageULetter = 41,
+ PageLLetter = 42,
+ PageNumHyphSep = 43,
+ PageNumSpaceSep = 44,
+ PageNumColonSep = 45,
+ PageNumEmdashSep= 46,
+ PageNumEndashSep= 47,
+ TopVAlign = 48,
+ BottomVAlign = 49,
+ CenterVAlign = 50,
+ JustVAlign = 51,
+ RTLSect = 52,
+ LTRSect = 53,
+
+ // Major.TblAttr
+ RowDef = 0,
+ RowGapH = 1,
+ CellPos = 2,
+ MergeRngFirst = 3,
+ MergePrevious = 4,
+ RowLeft = 5,
+ RowRight = 6,
+ RowCenter = 7,
+ RowLeftEdge = 8,
+ RowHt = 9,
+ RowHeader = 10,
+ RowKeep = 11,
+ RTLRow = 12,
+ LTRRow = 13,
+ RowBordTop = 14,
+ RowBordLeft = 15,
+ RowBordBottom = 16,
+ RowBordRight = 17,
+ RowBordHoriz = 18,
+ RowBordVert = 19,
+ CellBordBottom = 20,
+ CellBordTop = 21,
+ CellBordLeft = 22,
+ CellBordRight = 23,
+ CellShading = 24,
+ CellBgPatH = 25,
+ CellBgPatV = 26,
+ CellFwdDiagBgPat= 27,
+ CellBwdDiagBgPat= 28,
+ CellHatchBgPat = 29,
+ CellDiagHatchBgPat = 30,
+ CellDarkBgPatH = 31,
+ CellDarkBgPatV = 32,
+ CellFwdDarkBgPat= 33,
+ CellBwdDarkBgPat= 34,
+ CellDarkHatchBgPat = 35,
+ CellDarkDiagHatchBgPat = 36,
+ CellBgPatLineColor = 37,
+ CellBgPatColor = 38,
+
+ // Major.ParAttr
+ ParDef = 0,
+ StyleNum = 1,
+ Hyphenate = 2,
+ InTable = 3,
+ Keep = 4,
+ NoWidowControl = 5,
+ KeepNext = 6,
+ OutlineLevel = 7,
+ NoLineNum = 8,
+ PBBefore = 9,
+ SideBySide = 10,
+ QuadLeft = 11,
+ QuadRight = 12,
+ QuadJust = 13,
+ QuadCenter = 14,
+ FirstIndent = 15,
+ LeftIndent = 16,
+ RightIndent = 17,
+ SpaceBefore = 18,
+ SpaceAfter = 19,
+ SpaceBetween = 20,
+ SpaceMultiply = 21,
+ SubDocument = 22,
+ RTLPar = 23,
+ LTRPar = 24,
+ TabPos = 25,
+ TabLeft = 26,
+ TabRight = 27,
+ TabCenter = 28,
+ TabDecimal = 29,
+ TabBar = 30,
+ LeaderDot = 31,
+ LeaderHyphen = 32,
+ LeaderUnder = 33,
+ LeaderThick = 34,
+ LeaderEqual = 35,
+ ParLevel = 36,
+ ParBullet = 37,
+ ParSimple = 38,
+ ParNumCont = 39,
+ ParNumOnce = 40,
+ ParNumAcross = 41,
+ ParHangIndent = 42,
+ ParNumRestart = 43,
+ ParNumCardinal = 44,
+ ParNumDecimal = 45,
+ ParNumULetter = 46,
+ ParNumURoman = 47,
+ ParNumLLetter = 48,
+ ParNumLRoman = 49,
+ ParNumOrdinal = 50,
+ ParNumOrdinalText= 51,
+ ParNumBold = 52,
+ ParNumItalic = 53,
+ ParNumAllCaps = 54,
+ ParNumSmallCaps = 55,
+ ParNumUnder = 56,
+ ParNumDotUnder = 57,
+ ParNumDbUnder = 58,
+ ParNumNoUnder = 59,
+ ParNumWordUnder = 60,
+ ParNumStrikethru= 61,
+ ParNumForeColor = 62,
+ ParNumFont = 63,
+ ParNumFontSize = 64,
+ ParNumIndent = 65,
+ ParNumSpacing = 66,
+ ParNumInclPrev = 67,
+ ParNumCenter = 68,
+ ParNumLeft = 69,
+ ParNumRight = 70,
+ ParNumStartAt = 71,
+ BorderTop = 72,
+ BorderBottom = 73,
+ BorderLeft = 74,
+ BorderRight = 75,
+ BorderBetween = 76,
+ BorderBar = 77,
+ BorderBox = 78,
+ BorderSingle = 79,
+ BorderThick = 80,
+ BorderShadow = 81,
+ BorderDouble = 82,
+ BorderDot = 83,
+ BorderDash = 84,
+ BorderHair = 85,
+ BorderWidth = 86,
+ BorderColor = 87,
+ BorderSpace = 88,
+ Shading = 89,
+ BgPatH = 90,
+ BgPatV = 91,
+ FwdDiagBgPat = 92,
+ BwdDiagBgPat = 93,
+ HatchBgPat = 94,
+ DiagHatchBgPat = 95,
+ DarkBgPatH = 96,
+ DarkBgPatV = 97,
+ FwdDarkBgPat = 98,
+ BwdDarkBgPat = 99,
+ DarkHatchBgPat = 100,
+ DarkDiagHatchBgPat= 101,
+ BgPatLineColor = 102,
+ BgPatColor = 103,
+
+ // Major.CharAttr
+ Plain = 0,
+ Bold = 1,
+ AllCaps = 2,
+ Deleted = 3,
+ SubScript = 4,
+ SubScrShrink = 5,
+ NoSuperSub = 6,
+ Expand = 7,
+ ExpandTwips = 8,
+ Kerning = 9,
+ FontNum = 10,
+ FontSize = 11,
+ Italic = 12,
+ Outline = 13,
+ Revised = 14,
+ RevAuthor = 15,
+ RevDTTM = 16,
+ SmallCaps = 17,
+ Shadow = 18,
+ StrikeThru = 19,
+ Underline = 20,
+ DotUnderline = 21,
+ DbUnderline = 22,
+ NoUnderline = 23,
+ WordUnderline = 24,
+ SuperScript = 25,
+ SuperScrShrink = 26,
+ Invisible = 27,
+ ForeColor = 28,
+ BackColor = 29,
+ RTLChar = 30,
+ LTRChar = 31,
+ CharStyleNum = 32,
+ CharCharSet = 33,
+ Language = 34,
+ Gray = 35,
+
+ // Major.PictAttr
+ MacQD = 0,
+ PMMetafile = 1,
+ WinMetafile = 2,
+ DevIndBitmap = 3,
+ WinBitmap = 4,
+ PixelBits = 5,
+ BitmapPlanes = 6,
+ BitmapWid = 7,
+ PicWid = 8,
+ PicHt = 9,
+ PicGoalWid = 10,
+ PicGoalHt = 11,
+ PicScaleX = 12,
+ PicScaleY = 13,
+ PicScaled = 14,
+ PicCropTop = 15,
+ PicCropBottom = 16,
+ PicCropLeft = 17,
+ PicCropRight = 18,
+ PicMFHasBitmap = 19,
+ PicMFBitsPerPixel= 20,
+ PicBinary = 21,
+
+ // Major.BookmarkAttr
+ BookmarkFirstCol= 0,
+ BookmarkLastCol = 1,
+
+ // Major.NeXTGrAttr
+ NeXTGWidth = 0,
+ NeXTGHeight = 1,
+
+ // Major.FieldAttr
+ FieldDirty = 0,
+ FieldEdited = 1,
+ FieldLocked = 2,
+ FieldPrivate = 3,
+ FieldAlt = 4,
+
+ // Major.TOCAttr
+ TOCType = 0,
+ TOCLevel = 1,
+
+ // Major.PosAttr
+ AbsWid = 0,
+ AbsHt = 1,
+ RPosMargH = 2,
+ RPosPageH = 3,
+ RPosColH = 4,
+ PosX = 5,
+ PosNegX = 6,
+ PosXCenter = 7,
+ PosXInside = 8,
+ PosXOutSide = 9,
+ PosXRight = 10,
+ PosXLeft = 11,
+ RPosMargV = 12,
+ RPosPageV = 13,
+ RPosParaV = 14,
+ PosY = 15,
+ PosNegY = 16,
+ PosYInline = 17,
+ PosYTop = 18,
+ PosYCenter = 19,
+ PosYBottom = 20,
+ NoWrap = 21,
+ DistFromTextAll = 22,
+ DistFromTextX = 23,
+ DistFromTextY = 24,
+ TextDistY = 25,
+ DropCapLines = 26,
+ DropCapType = 27,
+
+ // Major.ObjAttr
+ ObjEmb = 0,
+ ObjLink = 1,
+ ObjAutoLink = 2,
+ ObjSubscriber = 3,
+ ObjPublisher = 4,
+ ObjICEmb = 5,
+ ObjLinkSelf = 6,
+ ObjLock = 7,
+ ObjUpdate = 8,
+ ObjHt = 9,
+ ObjWid = 10,
+ ObjSetSize = 11,
+ ObjAlign = 12,
+ ObjTransposeY = 13,
+ ObjCropTop = 14,
+ ObjCropBottom = 15,
+ ObjCropLeft = 16,
+ ObjCropRight = 17,
+ ObjScaleX = 18,
+ ObjScaleY = 19,
+ ObjResRTF = 20,
+ ObjResPict = 21,
+ ObjResBitmap = 22,
+ ObjResText = 23,
+ ObjResMerge = 24,
+ ObjBookmarkPubObj= 25,
+ ObjPubAutoUpdate= 26,
+
+ // Major.FNoteAttr
+ FNAlt = 0,
+
+ // Major.KeyCodeAttr
+ AltKey = 0,
+ ShiftKey = 1,
+ ControlKey = 2,
+ FunctionKey = 3,
+
+ // Major.ACharAttr
+ ACBold = 0,
+ ACAllCaps = 1,
+ ACForeColor = 2,
+ ACSubScript = 3,
+ ACExpand = 4,
+ ACFontNum = 5,
+ ACFontSize = 6,
+ ACItalic = 7,
+ ACLanguage = 8,
+ ACOutline = 9,
+ ACSmallCaps = 10,
+ ACShadow = 11,
+ ACStrikeThru = 12,
+ ACUnderline = 13,
+ ACDotUnderline = 14,
+ ACDbUnderline = 15,
+ ACNoUnderline = 16,
+ ACWordUnderline = 17,
+ ACSuperScript = 18,
+
+ // Major.FontAttr
+ FontCharSet = 0,
+ FontPitch = 1,
+ FontCodePage = 2,
+ FTypeNil = 3,
+ FTypeTrueType = 4,
+
+ // Major.FileAttr
+ FileNum = 0,
+ FileRelPath = 1,
+ FileOSNum = 2,
+
+ // Major.FileSource
+ SrcMacintosh = 0,
+ SrcDOS = 1,
+ SrcNTFS = 2,
+ SrcHPFS = 3,
+ SrcNetwork = 4,
+
+ // Major.DrawAttr
+ DrawLock = 0,
+ DrawPageRelX = 1,
+ DrawColumnRelX = 2,
+ DrawMarginRelX = 3,
+ DrawPageRelY = 4,
+ DrawColumnRelY = 5,
+ DrawMarginRelY = 6,
+ DrawHeight = 7,
+ DrawBeginGroup = 8,
+ DrawGroupCount = 9,
+ DrawEndGroup = 10,
+ DrawArc = 11,
+ DrawCallout = 12,
+ DrawEllipse = 13,
+ DrawLine = 14,
+ DrawPolygon = 15,
+ DrawPolyLine = 16,
+ DrawRect = 17,
+ DrawTextBox = 18,
+ DrawOffsetX = 19,
+ DrawSizeX = 20,
+ DrawOffsetY = 21,
+ DrawSizeY = 22,
+ COAngle = 23,
+ COAccentBar = 24,
+ COBestFit = 25,
+ COBorder = 26,
+ COAttachAbsDist = 27,
+ COAttachBottom = 28,
+ COAttachCenter = 29,
+ COAttachTop = 30,
+ COLength = 31,
+ CONegXQuadrant = 32,
+ CONegYQuadrant = 33,
+ COOffset = 34,
+ COAttachSmart = 35,
+ CODoubleLine = 36,
+ CORightAngle = 37,
+ COSingleLine = 38,
+ COTripleLine = 39,
+ DrawTextBoxMargin= 40,
+ DrawTextBoxText = 41,
+ DrawRoundRect = 42,
+ DrawPointX = 43,
+ DrawPointY = 44,
+ DrawPolyCount = 45,
+ DrawArcFlipX = 46,
+ DrawArcFlipY = 47,
+ DrawLineBlue = 48,
+ DrawLineGreen = 49,
+ DrawLineRed = 50,
+ DrawLinePalette = 51,
+ DrawLineDashDot = 52,
+ DrawLineDashDotDot= 53,
+ DrawLineDash = 54,
+ DrawLineDot = 55,
+ DrawLineGray = 56,
+ DrawLineHollow = 57,
+ DrawLineSolid = 58,
+ DrawLineWidth = 59,
+ DrawHollowEndArrow = 60,
+ DrawEndArrowLength = 61,
+ DrawSolidEndArrow = 62,
+ DrawEndArrowWidth = 63,
+ DrawHollowStartArrow = 64,
+ DrawStartArrowLength = 65,
+ DrawSolidStartArrow = 66,
+ DrawStartArrowWidth = 67,
+ DrawBgFillBlue = 68,
+ DrawBgFillGreen = 69,
+ DrawBgFillRed = 70,
+ DrawBgFillPalette = 71,
+ DrawBgFillGray = 72,
+ DrawFgFillBlue = 73,
+ DrawFgFillGreen = 74,
+ DrawFgFillRed = 75,
+ DrawFgFillPalette = 76,
+ DrawFgFillGray = 77,
+ DrawFillPatIndex = 78,
+ DrawShadow = 79,
+ DrawShadowXOffset = 80,
+ DrawShadowYOffset = 81,
+
+ // Major.IndexAttr
+ IndexNumber = 0,
+ IndexBold = 1,
+ IndexItalic = 2,
+
+ // Major.Unicode
+ UnicodeCharBytes = 0,
+ UnicodeChar = 1,
+ UnicodeDestination = 2,
+ UnicodeDualDestination = 3,
+ UnicodeAnsiCodepage = 4
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/README b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/README
new file mode 100644
index 00000000000..ccfb3fab6a2
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/README
@@ -0,0 +1,7 @@
+This RTF parser was originally based on a C-based RTF parser written
+by Paul DuBois (dubois@primate.wisc.edu). It came with the following license:
+
+ * This software may be redistributed without restriction and used for
+ * any purpose whatsoever.
+
+and was part of the code found in the 'rewind' project.
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/RTF.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/RTF.cs
new file mode 100644
index 00000000000..689deafa8a4
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/RTF.cs
@@ -0,0 +1,883 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+
+// COMPLETE
+
+#undef RTF_DEBUG
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Text;
+
+namespace System.Windows.Forms.RTF {
+ internal class RTF {
+ #region Local Variables
+ internal const char EOF = unchecked((char)-1);
+ internal const int NoParam = -1000000;
+
+ private TokenClass rtf_class;
+ private Major major;
+ private Minor minor;
+ private int param;
+ private int format;
+ private StringBuilder text_buffer;
+ private int line_num;
+ private int line_pos;
+
+ private char pushed_char;
+ private StringBuilder pushed_text_buffer;
+ private TokenClass pushed_class;
+ private Major pushed_major;
+ private Minor pushed_minor;
+ private int pushed_param;
+
+ private char prev_char;
+ private bool bump_line;
+
+ private Font font_list;
+ private Color color_list;
+ private Style style_list;
+
+ private Charset cur_charset;
+ private Stack charset_stack;
+
+ private Style styles;
+ private Color colors;
+ private Font fonts;
+
+ private StreamReader source;
+
+ private static Hashtable key_table;
+ private static KeyStruct[] Keys = KeysInit.Init();
+
+ private DestinationCallback destination_callbacks;
+ private ClassCallback class_callbacks;
+ #endregion // Local Variables
+
+ #region Constructors
+ static RTF() {
+ key_table = new Hashtable(Keys.Length);
+ for (int i = 0; i < Keys.Length; i++) {
+ key_table[Keys[i].Symbol] = Keys[i];
+ }
+ }
+
+ public RTF(Stream stream) {
+ source = new StreamReader(stream);
+
+ text_buffer = new StringBuilder(1024);
+ pushed_text_buffer = new StringBuilder(1024);
+
+ rtf_class = TokenClass.None;
+ pushed_class = TokenClass.None;
+ pushed_char = unchecked((char)-1);
+
+ line_num = 0;
+ line_pos = 0;
+ prev_char = unchecked((char)-1);
+ bump_line = false;
+
+ cur_charset = new Charset();
+
+ destination_callbacks = new DestinationCallback();
+ class_callbacks = new ClassCallback();
+
+ destination_callbacks[Minor.FontTbl] = new DestinationDelegate(ReadFontTbl);
+ destination_callbacks[Minor.ColorTbl] = new DestinationDelegate(ReadColorTbl);
+ destination_callbacks[Minor.StyleSheet] = new DestinationDelegate(ReadStyleSheet);
+ destination_callbacks[Minor.Info] = new DestinationDelegate(ReadInfoGroup);
+ destination_callbacks[Minor.Pict] = new DestinationDelegate(ReadPictGroup);
+ destination_callbacks[Minor.Object] = new DestinationDelegate(ReadObjGroup);
+ }
+ #endregion // Constructors
+
+ #region Properties
+ public TokenClass TokenClass {
+ get {
+ return this.rtf_class;
+ }
+
+ set {
+ this.rtf_class = value;
+ }
+ }
+
+ public Major Major {
+ get {
+ return this.major;
+ }
+
+ set {
+ this.major = value;
+ }
+ }
+
+ public Minor Minor {
+ get {
+ return this.minor;
+ }
+
+ set {
+ this.minor = value;
+ }
+ }
+
+ public int Param {
+ get {
+ return this.param;
+ }
+
+ set {
+ this.param = value;
+ }
+ }
+
+ public string Text {
+ get {
+ return this.text_buffer.ToString();
+ }
+
+ set {
+ if (value == null) {
+ this.text_buffer.Length = 0;
+ } else {
+ this.text_buffer = new StringBuilder(value);
+ }
+ }
+ }
+
+ public Color Colors {
+ get {
+ return colors;
+ }
+
+ set {
+ colors = value;
+ }
+ }
+
+ public Style Styles {
+ get {
+ return styles;
+ }
+
+ set {
+ styles = value;
+ }
+ }
+
+ public Font Fonts {
+ get {
+ return fonts;
+ }
+
+ set {
+ fonts = value;
+ }
+ }
+
+ public ClassCallback ClassCallback {
+ get {
+ return class_callbacks;
+ }
+
+ set {
+ class_callbacks = value;
+ }
+ }
+
+ public DestinationCallback DestinationCallback {
+ get {
+ return destination_callbacks;
+ }
+
+ set {
+ destination_callbacks = value;
+ }
+ }
+
+ public int LineNumber {
+ get {
+ return line_num;
+ }
+ }
+
+ public int LinePos {
+ get {
+ return line_pos;
+ }
+ }
+ #endregion // Properties
+
+ #region Methods
+ /// <summary>Set the default font for documents without font table</summary>
+ public void DefaultFont(string name) {
+ Font font;
+
+ font = new Font(this);
+ font.Num = 0;
+ font.Name = name;
+ }
+
+ /// <summary>Read the next character from the input</summary>
+ private char GetChar() {
+ char c;
+ bool old_bump_line;
+
+ if ((c = (char)source.Read()) != EOF) {
+ this.text_buffer.Append(c);
+ }
+
+ if (this.prev_char == EOF) {
+ this.bump_line = true;
+ }
+
+ old_bump_line = bump_line;
+ bump_line = false;
+
+ if (c == '\r') {
+ bump_line = true;
+ } else if (c == '\n') {
+ bump_line = true;
+ if (this.prev_char == '\r') {
+ old_bump_line = false;
+ }
+ }
+
+ this.line_pos ++;
+ if (old_bump_line) {
+ this.line_num++;
+ this.line_pos = 1;
+ }
+
+ this.prev_char = c;
+ return c;
+ }
+
+ /// <summary>Parse the RTF stream</summary>
+ public void Read() {
+ while (GetToken() != TokenClass.EOF) {
+ RouteToken();
+ }
+ }
+
+ /// <summary>Route a token</summary>
+ public void RouteToken() {
+ if (CheckCM(TokenClass.Control, Major.Destination)) {
+ DestinationDelegate d;
+
+ d = destination_callbacks[minor];
+ if (d != null) {
+ d(this);
+ }
+ }
+
+ // Invoke class callback if there is one
+ ClassDelegate c;
+
+ c = class_callbacks[rtf_class];
+ if (c != null) {
+ c(this);
+ }
+
+ }
+
+ /// <summary>Skip to the end of the current group</summary>
+ public void SkipGroup() {
+ int level;
+
+ level = 1;
+
+ while (GetToken() != TokenClass.EOF) {
+ if (rtf_class == TokenClass.Group) {
+ if (this.major == Major.BeginGroup) {
+ level++;
+ } else if (this.major == Major.EndGroup) {
+ level--;
+ if (level < 1) {
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ /// <summary>Return the next token in the stream</summary>
+ public TokenClass GetToken() {
+ if (pushed_class != TokenClass.None) {
+ this.rtf_class = this.pushed_class;
+ this.major = this.pushed_major;
+ this.minor = this.pushed_minor;
+ this.param = this.pushed_param;
+ this.pushed_class = TokenClass.None;
+ return this.rtf_class;
+ }
+
+ GetToken2();
+
+ if (this.rtf_class == TokenClass.Text) {
+ this.minor = (Minor)this.cur_charset[(int)this.major];
+ }
+
+ if (this.cur_charset.Flags == CharsetFlags.None) {
+ return this.rtf_class;
+ }
+
+ if (((this.cur_charset.Flags & CharsetFlags.Read) != 0) && CheckCM(TokenClass.Control, Major.CharSet)) {
+ this.cur_charset.ReadMap();
+ } else if (((this.cur_charset.Flags & CharsetFlags.Switch) != 0) && CheckCMM(TokenClass.Control, Major.CharAttr, Minor.FontNum)) {
+ Font fp;
+
+ fp = Font.GetFont(this.font_list, this.param);
+
+ if (fp != null) {
+ if (fp.Name.StartsWith("Symbol")) {
+ this.cur_charset.ID = CharsetType.Symbol;
+ } else {
+ this.cur_charset.ID = CharsetType.General;
+ }
+ } else if (((this.cur_charset.Flags & CharsetFlags.Switch) != 0) && (this.rtf_class == TokenClass.Group)) {
+ switch(this.major) {
+ case Major.BeginGroup: {
+ this.charset_stack.Push(this.cur_charset);
+ break;
+ }
+
+ case Major.EndGroup: {
+ this.cur_charset = (Charset)this.charset_stack.Pop();
+ break;
+ }
+ }
+ }
+ }
+
+ return this.rtf_class;
+ }
+
+ private void GetToken2() {
+ char c;
+ int sign;
+
+ this.rtf_class = TokenClass.Unknown;
+ this.param = NoParam;
+
+ this.text_buffer.Length = 0;
+
+ if (this.pushed_char != EOF) {
+ c = this.pushed_char;
+ this.text_buffer.Append(c);
+ this.pushed_char = EOF;
+ } else if ((c = GetChar()) == EOF) {
+ this.rtf_class = TokenClass.EOF;
+ return;
+ }
+
+ if (c == '{') {
+ this.rtf_class = TokenClass.Group;
+ this.major = Major.BeginGroup;
+ return;
+ }
+
+ if (c == '}') {
+ this.rtf_class = TokenClass.Group;
+ this.major = Major.EndGroup;
+ return;
+ }
+
+ if (c != '\\') {
+ if (c != '\t') {
+ this.rtf_class = TokenClass.Text;
+ this.major = (Major)c; // FIXME - typing?
+ return;
+ } else {
+ this.rtf_class = TokenClass.Control;
+ this.major = Major.SpecialChar;
+ this.minor = Minor.Tab;
+ return;
+ }
+ }
+
+ if ((c = GetChar()) == EOF) {
+ // Not so good
+ return;
+ }
+
+ if (!Char.IsLetter(c)) {
+ if (c == '\'') {
+ char c2;
+
+ if ((c = GetChar()) == EOF) {
+ return;
+ }
+
+ if ((c2 = GetChar()) == EOF) {
+ return;
+ }
+
+ this.rtf_class = TokenClass.Text;
+ this.major = (Major)((Char)((Convert.ToByte(c.ToString(), 16) * 16 + Convert.ToByte(c2.ToString(), 16))));
+ return;
+ }
+
+ // Escaped char
+ if (c == ':' || c == '{' || c == '}' || c == '\\') {
+ this.rtf_class = TokenClass.Text;
+ this.major = (Major)c;
+ return;
+ }
+
+ Lookup(this.text_buffer.ToString());
+ return;
+ }
+
+ while (Char.IsLetter(c)) {
+ if ((c = GetChar()) == EOF) {
+ break;
+ }
+ }
+
+ if (c != EOF) {
+ this.text_buffer.Length--;
+ }
+
+ Lookup(this.text_buffer.ToString());
+
+ if (c != EOF) {
+ this.text_buffer.Append(c);
+ }
+
+ sign = 1;
+ if (c == '-') {
+ sign = -1;
+ c = GetChar();
+ }
+
+ if (c != EOF && Char.IsDigit(c)) {
+ this.param = 0;
+ while (Char.IsDigit(c)) {
+ this.param = this.param * 10 + Convert.ToByte(c) - 48;
+ if ((c = GetChar()) == EOF) {
+ break;
+ }
+ }
+ this.param *= sign;
+ }
+
+ if (c != EOF) {
+ if (c != ' ') {
+ this.pushed_char = c;
+ }
+ this.text_buffer.Length--;
+ }
+ }
+
+ public void SetToken(TokenClass cl, Major maj, Minor min, int par, string text) {
+ this.rtf_class = cl;
+ this.major = maj;
+ this.minor = min;
+ this.param = par;
+ if (par == NoParam) {
+ this.text_buffer = new StringBuilder(text);
+ } else {
+ this.text_buffer = new StringBuilder(text + par.ToString());
+ }
+ }
+
+ public void UngetToken() {
+ if (this.pushed_class != TokenClass.None) {
+ throw new RTFException(this, "Cannot unget more than one token");
+ }
+
+ if (this.rtf_class == TokenClass.None) {
+ throw new RTFException(this, "No token to unget");
+ }
+
+ this.pushed_class = this.rtf_class;
+ this.pushed_major = this.major;
+ this.pushed_minor = this.minor;
+ this.pushed_param = this.param;
+ this.pushed_text_buffer = new StringBuilder(this.text_buffer.ToString());
+ }
+
+ public TokenClass PeekToken() {
+ GetToken();
+ UngetToken();
+ return rtf_class;
+ }
+
+ public void Lookup(string token) {
+ Object obj;
+ KeyStruct key;
+
+ obj = key_table[token.Substring(1)];
+ if (obj == null) {
+ rtf_class = TokenClass.Unknown;
+ return;
+ }
+
+ key = (KeyStruct)obj;
+ this.rtf_class = TokenClass.Control;
+ this.major = key.Major;
+ this.minor = key.Minor;
+ }
+
+ public bool CheckCM(TokenClass rtf_class, Major major) {
+ if ((this.rtf_class == rtf_class) && (this.major == major)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public bool CheckCMM(TokenClass rtf_class, Major major, Minor minor) {
+ if ((this.rtf_class == rtf_class) && (this.major == major) && (this.minor == minor)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public bool CheckMM(Major major, Minor minor) {
+ if ((this.major == major) && (this.minor == minor)) {
+ return true;
+ }
+
+ return false;
+ }
+ #endregion // Methods
+
+ #region Default Delegates
+ private void ReadFontTbl(RTF rtf) {
+ int old;
+ Font font;
+
+ old = -1;
+ font = null;
+
+ while (true) {
+ rtf.GetToken();
+
+ if (rtf.CheckCM(TokenClass.Group, Major.EndGroup)) {
+ break;
+ }
+
+ if (old < 0) {
+ if (rtf.CheckCMM(TokenClass.Control, Major.CharAttr, Minor.FontNum)) {
+ old = 1;
+ } else if (rtf.CheckCM(TokenClass.Group, Major.BeginGroup)) {
+ old = 0;
+ } else {
+ throw new RTFException(rtf, "Cannot determine format");
+ }
+ }
+
+ if (old == 0) {
+ if (!rtf.CheckCM(TokenClass.Group, Major.BeginGroup)) {
+ throw new RTFException(rtf, "missing \"{\"");
+ }
+ rtf.GetToken();
+ }
+
+ font = new Font(rtf);
+
+ while ((rtf.rtf_class != TokenClass.EOF) && (!rtf.CheckCM(TokenClass.Text, (Major)';')) && (!rtf.CheckCM(TokenClass.Group, Major.EndGroup))) {
+ if (rtf.rtf_class == TokenClass.Control) {
+ switch(rtf.major) {
+ case Major.FontFamily: {
+ font.Family = (int)rtf.minor;
+ break;
+ }
+
+ case Major.CharAttr: {
+ switch(rtf.minor) {
+ case Minor.FontNum: {
+ font.Num = rtf.param;
+ break;
+ }
+
+ default: {
+ #if RTF_DEBUG
+ Console.WriteLine("Got unhandled Control.CharAttr.Minor: " + rtf.minor);
+ #endif
+ break;
+ }
+ }
+ break;
+ }
+
+ case Major.FontAttr: {
+ switch (rtf.minor) {
+ case Minor.FontCharSet: {
+ font.Charset = (CharsetType)rtf.param;
+ break;
+ }
+
+ case Minor.FontPitch: {
+ font.Pitch = rtf.param;
+ break;
+ }
+
+ case Minor.FontCodePage: {
+ font.Codepage = rtf.param;
+ break;
+ }
+
+ case Minor.FTypeNil:
+ case Minor.FTypeTrueType: {
+ font.Type = rtf.param;
+ break;
+ }
+ default: {
+ #if RTF_DEBUG
+ Console.WriteLine("Got unhandled Control.FontAttr.Minor: " + rtf.minor);
+ #endif
+ break;
+ }
+ }
+ break;
+ }
+
+ default: {
+ #if RTF_DEBUG
+ Console.WriteLine("ReadFontTbl: Unknown Control token " + rtf.major);
+ #endif
+ break;
+ }
+ }
+ } else if (rtf.CheckCM(TokenClass.Group, Major.BeginGroup)) {
+ rtf.SkipGroup();
+ } else if (rtf.rtf_class == TokenClass.Text) {
+ StringBuilder sb;
+
+ sb = new StringBuilder();
+
+ while ((rtf.rtf_class != TokenClass.EOF) && (!rtf.CheckCM(TokenClass.Text, (Major)';')) && (!rtf.CheckCM(TokenClass.Group, Major.EndGroup))) {
+ sb.Append((char)rtf.major);
+ rtf.GetToken();
+ }
+
+ if (rtf.CheckCM(TokenClass.Group, Major.EndGroup)) {
+ rtf.UngetToken();
+ }
+
+ font.Name = sb.ToString();
+ continue;
+#if RTF_DEBUG
+ } else {
+ Console.WriteLine("ReadFontTbl: Unknown token " + rtf.text_buffer);
+#endif
+ }
+
+ rtf.GetToken();
+ }
+
+ if (old == 0) {
+ rtf.GetToken();
+
+ if (!rtf.CheckCM(TokenClass.Group, Major.EndGroup)) {
+ throw new RTFException(rtf, "Missing \"}\"");
+ }
+ }
+ }
+
+ if (font == null) {
+ throw new RTFException(rtf, "No font created");
+ }
+
+ if (font.Num == -1) {
+ throw new RTFException(rtf, "Missing font number");
+ }
+
+ rtf.RouteToken();
+ }
+
+ private void ReadColorTbl(RTF rtf) {
+ Color color;
+ int num;
+
+ num = 0;
+
+ while (true) {
+ rtf.GetToken();
+
+ if (rtf.CheckCM(TokenClass.Group, Major.EndGroup)) {
+ break;
+ }
+
+ color = new Color(rtf);
+ color.Num = num++;
+
+ while (rtf.CheckCM(TokenClass.Control, Major.ColorName)) {
+ switch (rtf.minor) {
+ case Minor.Red: {
+ color.Red = rtf.param;
+ break;
+ }
+
+ case Minor.Green: {
+ color.Green = rtf.param;
+ break;
+ }
+
+ case Minor.Blue: {
+ color.Blue = rtf.param;
+ break;
+ }
+ }
+
+ rtf.GetToken();
+ }
+ if (!rtf.CheckCM(TokenClass.Text, (Major)';')) {
+ throw new RTFException(rtf, "Malformed color entry");
+ }
+ }
+ rtf.RouteToken();
+ }
+
+ private void ReadStyleSheet(RTF rtf) {
+ Style style;
+ StringBuilder sb;
+
+ sb = new StringBuilder();
+
+ while (true) {
+ rtf.GetToken();
+
+ if (rtf.CheckCM(TokenClass.Group, Major.EndGroup)) {
+ break;
+ }
+
+ style = new Style(rtf);
+
+ if (!rtf.CheckCM(TokenClass.Group, Major.BeginGroup)) {
+ throw new RTFException(rtf, "Missing \"{\"");
+ }
+
+ while (true) {
+ rtf.GetToken();
+
+ if ((rtf.rtf_class == TokenClass.EOF) || rtf.CheckCM(TokenClass.Text, (Major)';')) {
+ break;
+ }
+
+ if (rtf.rtf_class == TokenClass.Control) {
+ if (rtf.CheckMM(Major.SpecialChar, Minor.OptDest)) {
+ continue;
+ }
+ if (rtf.CheckMM(Major.ParAttr, Minor.StyleNum)) {
+ style.Num = rtf.param;
+ style.Type = StyleType.Paragraph;
+ continue;
+ }
+ if (rtf.CheckMM(Major.CharAttr, Minor.CharStyleNum)) {
+ style.Num = rtf.param;
+ style.Type = StyleType.Character;
+ continue;
+ }
+ if (rtf.CheckMM(Major.StyleAttr, Minor.SectStyleNum)) {
+ style.Num = rtf.param;
+ style.Type = StyleType.Section;
+ continue;
+ }
+ if (rtf.CheckMM(Major.StyleAttr, Minor.BasedOn)) {
+ style.BasedOn = rtf.param;
+ continue;
+ }
+ if (rtf.CheckMM(Major.StyleAttr, Minor.Additive)) {
+ style.Additive = true;
+ continue;
+ }
+ if (rtf.CheckMM(Major.StyleAttr, Minor.Next)) {
+ style.NextPar = rtf.param;
+ continue;
+ }
+
+ new StyleElement(style, rtf.rtf_class, rtf.major, rtf.minor, rtf.param, rtf.text_buffer.ToString());
+ } else if (rtf.CheckCM(TokenClass.Group, Major.BeginGroup)) {
+ // This passes over "{\*\keycode ... }, among other things
+ rtf.SkipGroup();
+ } else if (rtf.rtf_class == TokenClass.Text) {
+ while (rtf.rtf_class == TokenClass.Text) {
+ if (rtf.major == (Major)';') {
+ rtf.UngetToken();
+ break;
+ }
+
+ sb.Append((char)rtf.major);
+ rtf.GetToken();
+ }
+
+ style.Name = sb.ToString();
+#if RTF_DEBUG
+ } else {
+ Console.WriteLine("ReadStyleSheet: Ignored token " + rtf.text_buffer);
+#endif
+ }
+ }
+ rtf.GetToken();
+
+ if (!rtf.CheckCM(TokenClass.Group, Major.EndGroup)) {
+ throw new RTFException(rtf, "Missing EndGroup (\"}\"");
+ }
+
+ // Sanity checks
+ if (style.Name == null) {
+ throw new RTFException(rtf, "Style must have name");
+ }
+
+ if (style.Num < 0) {
+ if (!sb.ToString().StartsWith("Normal") && !sb.ToString().StartsWith("Standard")) {
+ throw new RTFException(rtf, "Missing style number");
+ }
+
+ style.Num = Style.NormalStyleNum;
+ }
+
+ if (style.NextPar == -1) {
+ style.NextPar = style.Num;
+ }
+ }
+
+ rtf.RouteToken();
+ }
+
+ private void ReadInfoGroup(RTF rtf) {
+ rtf.SkipGroup();
+ rtf.RouteToken();
+ }
+
+ private void ReadPictGroup(RTF rtf) {
+ rtf.SkipGroup();
+ rtf.RouteToken();
+ }
+
+ private void ReadObjGroup(RTF rtf) {
+ rtf.SkipGroup();
+ rtf.RouteToken();
+ }
+ #endregion // Default Delegates
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/RTFException.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/RTFException.cs
new file mode 100644
index 00000000000..07d35f2dd4f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/RTFException.cs
@@ -0,0 +1,81 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+using System;
+using System.Text;
+
+namespace System.Windows.Forms.RTF {
+ internal class RTFException : ApplicationException {
+ #region Local Variables
+ private int pos;
+ private int line;
+ private TokenClass token_class;
+ private Major major;
+ private Minor minor;
+ private int param;
+ private string text;
+ private string error_message;
+ #endregion // Local Variables
+
+ #region Constructors
+ public RTFException(RTF rtf, string error_message) {
+ this.pos = rtf.LinePos;
+ this.line = rtf.LineNumber;
+ this.token_class = rtf.TokenClass;
+ this.major = rtf.Major;
+ this.minor = rtf.Minor;
+ this.param = rtf.Param;
+ this.text = rtf.Text;
+ this.error_message = error_message;
+ }
+ #endregion // Constructors
+
+ #region Properties
+ public override string Message {
+ get {
+ StringBuilder sb;
+
+ sb = new StringBuilder();
+ sb.Append(error_message);
+ sb.Append("\n");
+
+ sb.Append("RTF Stream Info: Pos:" + pos + " Line:" + line);
+ sb.Append("\n");
+
+ sb.Append("TokenClass:" + token_class + ", ");
+ sb.Append("Major:" + String.Format("{0}", (int)major) + ", ");
+ sb.Append("Minor:" + String.Format("{0}", (int)minor) + ", ");
+ sb.Append("Param:" + String.Format("{0}", param) + ", ");
+ sb.Append("Text:" + text);
+
+ return sb.ToString();
+ }
+ }
+ #endregion // Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/StandardCharCode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/StandardCharCode.cs
new file mode 100644
index 00000000000..02eacf82f90
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/StandardCharCode.cs
@@ -0,0 +1,386 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms.RTF {
+ internal enum StandardCharCode {
+ nothing = 0,
+ space = 1,
+ exclam = 2,
+ quotedbl = 3,
+ numbersign = 4,
+ dollar = 5,
+ percent = 6,
+ ampersand = 7,
+ quoteright = 8,
+ parenleft = 9,
+ parenright = 10,
+ asterisk = 11,
+ plus = 12,
+ comma = 13,
+ hyphen = 14,
+ period = 15,
+ slash = 16,
+ zero = 17,
+ one = 18,
+ two = 19,
+ three = 20,
+ four = 21,
+ five = 22,
+ six = 23,
+ seven = 24,
+ eight = 25,
+ nine = 26,
+ colon = 27,
+ semicolon = 28,
+ less = 29,
+ equal = 30,
+ greater = 31,
+ question = 32,
+ at = 33,
+ A = 34,
+ B = 35,
+ C = 36,
+ D = 37,
+ E = 38,
+ F = 39,
+ G = 40,
+ H = 41,
+ I = 42,
+ J = 43,
+ K = 44,
+ L = 45,
+ M = 46,
+ N = 47,
+ O = 48,
+ P = 49,
+ Q = 50,
+ R = 51,
+ S = 52,
+ T = 53,
+ U = 54,
+ V = 55,
+ W = 56,
+ X = 57,
+ Y = 58,
+ Z = 59,
+ bracketleft = 60,
+ backslash = 61,
+ bracketright = 62,
+ asciicircum = 63,
+ underscore = 64,
+ quoteleft = 65,
+ a = 66,
+ b = 67,
+ c = 68,
+ d = 69,
+ e = 70,
+ f = 71,
+ g = 72,
+ h = 73,
+ i = 74,
+ j = 75,
+ k = 76,
+ l = 77,
+ m = 78,
+ n = 79,
+ o = 80,
+ p = 81,
+ q = 82,
+ r = 83,
+ s = 84,
+ t = 85,
+ u = 86,
+ v = 87,
+ w = 88,
+ x = 89,
+ y = 90,
+ z = 91,
+ braceleft = 92,
+ bar = 93,
+ braceright = 94,
+ asciitilde = 95,
+ exclamdown = 96,
+ cent = 97,
+ sterling = 98,
+ fraction = 99,
+ yen = 100,
+ florin = 101,
+ section = 102,
+ currency = 103,
+ quotedblleft = 104,
+ guillemotleft = 105,
+ guilsinglleft = 106,
+ guilsinglright = 107,
+ fi = 108,
+ fl = 109,
+ endash = 110,
+ dagger = 111,
+ daggerdbl = 112,
+ periodcentered = 113,
+ paragraph = 114,
+ bullet = 115,
+ quotesinglbase = 116,
+ quotedblbase = 117,
+ quotedblright = 118,
+ guillemotright = 119,
+ ellipsis = 120,
+ perthousand = 121,
+ questiondown = 122,
+ grave = 123,
+ acute = 124,
+ circumflex = 125,
+ tilde = 126,
+ macron = 127,
+ breve = 128,
+ dotaccent = 129,
+ dieresis = 130,
+ ring = 131,
+ cedilla = 132,
+ hungarumlaut = 133,
+ ogonek = 134,
+ caron = 135,
+ emdash = 136,
+ AE = 137,
+ ordfeminine = 138,
+ Lslash = 139,
+ Oslash = 140,
+ OE = 141,
+ ordmasculine = 142,
+ ae = 143,
+ dotlessi = 144,
+ lslash = 145,
+ oslash = 146,
+ oe = 147,
+ germandbls = 148,
+ Aacute = 149,
+ Acircumflex = 150,
+ Adieresis = 151,
+ Agrave = 152,
+ Aring = 153,
+ Atilde = 154,
+ Ccedilla = 155,
+ Eacute = 156,
+ Ecircumflex = 157,
+ Edieresis = 158,
+ Egrave = 159,
+ Eth = 160,
+ Iacute = 161,
+ Icircumflex = 162,
+ Idieresis = 163,
+ Igrave = 164,
+ Ntilde = 165,
+ Oacute = 166,
+ Ocircumflex = 167,
+ Odieresis = 168,
+ Ograve = 169,
+ Otilde = 170,
+ Scaron = 171,
+ Thorn = 172,
+ Uacute = 173,
+ Ucircumflex = 174,
+ Udieresis = 175,
+ Ugrave = 176,
+ Yacute = 177,
+ Ydieresis = 178,
+ aacute = 179,
+ acircumflex = 180,
+ adieresis = 181,
+ agrave = 182,
+ aring = 183,
+ atilde = 184,
+ brokenbar = 185,
+ ccedilla = 186,
+ copyright = 187,
+ degree = 188,
+ divide = 189,
+ eacute = 190,
+ ecircumflex = 191,
+ edieresis = 192,
+ egrave = 193,
+ eth = 194,
+ iacute = 195,
+ icircumflex = 196,
+ idieresis = 197,
+ igrave = 198,
+ logicalnot = 199,
+ minus = 200,
+ multiply = 201,
+ ntilde = 202,
+ oacute = 203,
+ ocircumflex = 204,
+ odieresis = 205,
+ ograve = 206,
+ onehalf = 207,
+ onequarter = 208,
+ onesuperior = 209,
+ otilde = 210,
+ plusminus = 211,
+ registered = 212,
+ thorn = 213,
+ threequarters = 214,
+ threesuperior = 215,
+ trademark = 216,
+ twosuperior = 217,
+ uacute = 218,
+ ucircumflex = 219,
+ udieresis = 220,
+ ugrave = 221,
+ yacute = 222,
+ ydieresis = 223,
+ Alpha = 224,
+ Beta = 225,
+ Chi = 226,
+ Delta = 227,
+ Epsilon = 228,
+ Phi = 229,
+ Gamma = 230,
+ Eta = 231,
+ Iota = 232,
+ Kappa = 233,
+ Lambda = 234,
+ Mu = 235,
+ Nu = 236,
+ Omicron = 237,
+ Pi = 238,
+ Theta = 239,
+ Rho = 240,
+ Sigma = 241,
+ Tau = 242,
+ Upsilon = 243,
+ varUpsilon = 244,
+ Omega = 245,
+ Xi = 246,
+ Psi = 247,
+ Zeta = 248,
+ alpha = 249,
+ beta = 250,
+ chi = 251,
+ delta = 252,
+ epsilon = 253,
+ phi = 254,
+ varphi = 255,
+ gamma = 256,
+ eta = 257,
+ iota = 258,
+ kappa = 259,
+ lambda = 260,
+ mu = 261,
+ nu = 262,
+ omicron = 263,
+ pi = 264,
+ varpi = 265,
+ theta = 266,
+ vartheta = 267,
+ rho = 268,
+ sigma = 269,
+ varsigma = 270,
+ tau = 271,
+ upsilon = 272,
+ omega = 273,
+ xi = 274,
+ psi = 275,
+ zeta = 276,
+ nobrkspace = 277,
+ nobrkhyphen = 278,
+ lessequal = 279,
+ greaterequal = 280,
+ infinity = 281,
+ integral = 282,
+ notequal = 283,
+ radical = 284,
+ radicalex = 285,
+ approxequal = 286,
+ apple = 287,
+ partialdiff = 288,
+ opthyphen = 289,
+ formula = 290,
+ lozenge = 291,
+ universal = 292,
+ existential = 293,
+ suchthat = 294,
+ congruent = 295,
+ therefore = 296,
+ perpendicular = 297,
+ minute = 298,
+ club = 299,
+ diamond = 300,
+ heart = 301,
+ spade = 302,
+ arrowboth = 303,
+ arrowleft = 304,
+ arrowup = 305,
+ arrowright = 306,
+ arrowdown = 307,
+ second = 308,
+ proportional = 309,
+ equivalence = 310,
+ arrowvertex = 311,
+ arrowhorizex = 312,
+ carriagereturn = 313,
+ aleph = 314,
+ Ifraktur = 315,
+ Rfraktur = 316,
+ weierstrass = 317,
+ circlemultiply = 318,
+ circleplus = 319,
+ emptyset = 320,
+ intersection = 321,
+ union = 322,
+ propersuperset = 323,
+ reflexsuperset = 324,
+ notsubset = 325,
+ propersubset = 326,
+ reflexsubset = 327,
+ element = 328,
+ notelement = 329,
+ angle = 330,
+ gradient = 331,
+ product = 332,
+ logicaland = 333,
+ logicalor = 334,
+ arrowdblboth = 335,
+ arrowdblleft = 336,
+ arrowdblup = 337,
+ arrowdblright = 338,
+ arrowdbldown = 339,
+ angleleft = 340,
+ registersans = 341,
+ copyrightsans = 342,
+ trademarksans = 343,
+ angleright = 344,
+ mathplus = 345,
+ mathminus = 346,
+ mathasterisk = 347,
+ mathnumbersign = 348,
+ dotmath = 349,
+ mathequal = 350,
+ mathtilde = 351,
+
+ MaxChar = 352
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/StandardCharName.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/StandardCharName.cs
new file mode 100644
index 00000000000..3c75464d104
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/StandardCharName.cs
@@ -0,0 +1,405 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms.RTF {
+ internal class StandardCharName {
+ public static string[] Names = {
+ "nothing",
+ "space",
+ "exclam",
+ "quotedbl",
+ "numbersign",
+ "dollar",
+ "percent",
+ "ampersand",
+ "quoteright",
+ "parenleft",
+ "parenright",
+ "asterisk",
+ "plus",
+ "comma",
+ "hyphen",
+ "period",
+ "slash",
+ "zero",
+ "one",
+ "two",
+ "three",
+ "four",
+ "five",
+ "six",
+ "seven",
+ "eight",
+ "nine",
+ "colon",
+ "semicolon",
+ "less",
+ "equal",
+ "greater",
+ "question",
+ "at",
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G",
+ "H",
+ "I",
+ "J",
+ "K",
+ "L",
+ "M",
+ "N",
+ "O",
+ "P",
+ "Q",
+ "R",
+ "S",
+ "T",
+ "U",
+ "V",
+ "W",
+ "X",
+ "Y",
+ "Z",
+ "bracketleft",
+ "backslash",
+ "bracketright",
+ "asciicircum",
+ "underscore",
+ "quoteleft",
+ "a",
+ "b",
+ "c",
+ "d",
+ "e",
+ "f",
+ "g",
+ "h",
+ "i",
+ "j",
+ "k",
+ "l",
+ "m",
+ "n",
+ "o",
+ "p",
+ "q",
+ "r",
+ "s",
+ "t",
+ "u",
+ "v",
+ "w",
+ "x",
+ "y",
+ "z",
+ "braceleft",
+ "bar",
+ "braceright",
+ "asciitilde",
+ "exclamdown",
+ "cent",
+ "sterling",
+ "fraction",
+ "yen",
+ "florin",
+ "section",
+ "currency",
+ "quotedblleft",
+ "guillemotleft",
+ "guilsinglleft",
+ "guilsinglright",
+ "fi",
+ "fl",
+ "endash",
+ "dagger",
+ "daggerdbl",
+ "periodcentered",
+ "paragraph",
+ "bullet",
+ "quotesinglbase",
+ "quotedblbase",
+ "quotedblright",
+ "guillemotright",
+ "ellipsis",
+ "perthousand",
+ "questiondown",
+ "grave",
+ "acute",
+ "circumflex",
+ "tilde",
+ "macron",
+ "breve",
+ "dotaccent",
+ "dieresis",
+ "ring",
+ "cedilla",
+ "hungarumlaut",
+ "ogonek",
+ "caron",
+ "emdash",
+ "AE",
+ "ordfeminine",
+ "Lslash",
+ "Oslash",
+ "OE",
+ "ordmasculine",
+ "ae",
+ "dotlessi",
+ "lslash",
+ "oslash",
+ "oe",
+ "germandbls",
+ "Aacute",
+ "Acircumflex",
+ "Adieresis",
+ "Agrave",
+ "Aring",
+ "Atilde",
+ "Ccedilla",
+ "Eacute",
+ "Ecircumflex",
+ "Edieresis",
+ "Egrave",
+ "Eth",
+ "Iacute",
+ "Icircumflex",
+ "Idieresis",
+ "Igrave",
+ "Ntilde",
+ "Oacute",
+ "Ocircumflex",
+ "Odieresis",
+ "Ograve",
+ "Otilde",
+ "Scaron",
+ "Thorn",
+ "Uacute",
+ "Ucircumflex",
+ "Udieresis",
+ "Ugrave",
+ "Yacute",
+ "Ydieresis",
+ "aacute",
+ "acircumflex",
+ "adieresis",
+ "agrave",
+ "aring",
+ "atilde",
+ "brokenbar",
+ "ccedilla",
+ "copyright",
+ "degree",
+ "divide",
+ "eacute",
+ "ecircumflex",
+ "edieresis",
+ "egrave",
+ "eth",
+ "iacute",
+ "icircumflex",
+ "idieresis",
+ "igrave",
+ "logicalnot",
+ "minus",
+ "multiply",
+ "ntilde",
+ "oacute",
+ "ocircumflex",
+ "odieresis",
+ "ograve",
+ "onehalf",
+ "onequarter",
+ "onesuperior",
+ "otilde",
+ "plusminus",
+ "registered",
+ "thorn",
+ "threequarters",
+ "threesuperior",
+ "trademark",
+ "twosuperior",
+ "uacute",
+ "ucircumflex",
+ "udieresis",
+ "ugrave",
+ "yacute",
+ "ydieresis",
+ "Alpha",
+ "Beta",
+ "Chi",
+ "Delta",
+ "Epsilon",
+ "Phi",
+ "Gamma",
+ "Eta",
+ "Iota",
+ "Kappa",
+ "Lambda",
+ "Mu",
+ "Nu",
+ "Omicron",
+ "Pi",
+ "Theta",
+ "Rho",
+ "Sigma",
+ "Tau",
+ "Upsilon",
+ "varUpsilon",
+ "Omega",
+ "Xi",
+ "Psi",
+ "Zeta",
+ "alpha",
+ "beta",
+ "chi",
+ "delta",
+ "epsilon",
+ "phi",
+ "varphi",
+ "gamma",
+ "eta",
+ "iota",
+ "kappa",
+ "lambda",
+ "mu",
+ "nu",
+ "omicron",
+ "pi",
+ "varpi",
+ "theta",
+ "vartheta",
+ "rho",
+ "sigma",
+ "varsigma",
+ "tau",
+ "upsilon",
+ "omega",
+ "xi",
+ "psi",
+ "zeta",
+ "nobrkspace",
+ "nobrkhyphen",
+ "lessequal",
+ "greaterequal",
+ "infinity",
+ "integral",
+ "notequal",
+ "radical",
+ "radicalex",
+ "approxequal",
+ "apple",
+ "partialdiff",
+ "opthyphen",
+ "formula",
+ "lozenge",
+ "universal",
+ "existential",
+ "suchthat",
+ "congruent",
+ "therefore",
+ "perpendicular",
+ "minute",
+ "club",
+ "diamond",
+ "heart",
+ "spade",
+ "arrowboth",
+ "arrowleft",
+ "arrowup",
+ "arrowright",
+ "arrowdown",
+ "second",
+ "proportional",
+ "equivalence",
+ "arrowvertex",
+ "arrowhorizex",
+ "carriagereturn",
+ "aleph",
+ "Ifraktur",
+ "Rfraktur",
+ "weierstrass",
+ "circlemultiply",
+ "circleplus",
+ "emptyset",
+ "intersection",
+ "union",
+ "propersuperset",
+ "reflexsuperset",
+ "notsubset",
+ "propersubset",
+ "reflexsubset",
+ "element",
+ "notelement",
+ "angle",
+ "gradient",
+ "product",
+ "logicaland",
+ "logicalor",
+ "arrowdblboth",
+ "arrowdblleft",
+ "arrowdblup",
+ "arrowdblright",
+ "arrowdbldown",
+ "angleleft",
+ "registersans",
+ "copyrightsans",
+ "trademarksans",
+ "angleright",
+ "mathplus",
+ "mathminus",
+ "mathasterisk",
+ "mathnumbersign",
+ "dotmath",
+ "mathequal",
+ "mathtilde"
+ };
+
+ /// <summary>Lookup name by ID</summary>
+ public static string Name(int index) {
+ if ((index < 0) || (index >= Names.Length)) {
+ return string.Empty;
+ }
+
+ return Names[index];
+ }
+
+ /// <summary>Lookup ID by name (e.g. mathtilde)</summary>
+ public static int ID(string name) {
+ for (int i=0; i < Names.Length; i++) {
+ if (name.Equals(Names[i])) {
+ return i;
+ }
+ }
+ return 0;
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Style.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Style.cs
new file mode 100644
index 00000000000..9e8ed79efc2
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Style.cs
@@ -0,0 +1,205 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms.RTF {
+ internal class Style {
+ #region Local Variables
+ public const int NoStyleNum = 222;
+ public const int NormalStyleNum = 0;
+
+ private string name;
+ private StyleType type;
+ private bool additive;
+ private int num;
+ private int based_on;
+ private int next_par;
+ private int se_list;
+ private bool expanding;
+ private StyleElement elements;
+ private Style next;
+ #endregion Local Variables
+
+ #region Constructors
+ public Style(RTF rtf) {
+ num = -1;
+ type = StyleType.Paragraph;
+ based_on = NoStyleNum;
+ next_par = -1;
+
+ lock (rtf) {
+ if (rtf.Styles == null) {
+ rtf.Styles = this;
+ } else {
+ Style s = rtf.Styles;
+ while (s.next != null)
+ s = s.next;
+ s.next = this;
+ }
+ }
+ }
+ #endregion // Constructors
+
+ #region Properties
+ public string Name {
+ get {
+ return name;
+ }
+
+ set {
+ name = value;
+ }
+ }
+
+ public StyleType Type {
+ get {
+ return type;
+ }
+
+ set {
+ type = value;
+ }
+ }
+
+ public bool Additive {
+ get {
+ return additive;
+ }
+
+ set {
+ additive = value;
+ }
+ }
+
+ public int BasedOn {
+ get {
+ return based_on;
+ }
+
+ set {
+ based_on = value;
+ }
+ }
+
+ public StyleElement Elements {
+ get {
+ return elements;
+ }
+
+ set {
+ elements = value;
+ }
+ }
+
+ public bool Expanding {
+ get {
+ return expanding;
+ }
+
+ set {
+ expanding = value;
+ }
+ }
+
+ public int NextPar {
+ get {
+ return next_par;
+ }
+
+ set {
+ next_par = value;
+ }
+ }
+
+ public int Num {
+ get {
+ return num;
+ }
+
+ set {
+ num = value;
+ }
+ }
+ #endregion // Properties
+
+ #region Methods
+ public void Expand(RTF rtf) {
+ StyleElement se;
+
+ if (num == -1) {
+ return;
+ }
+
+ if (expanding) {
+ throw new Exception("Recursive style expansion");
+ }
+ expanding = true;
+
+ if (num != based_on) {
+ rtf.SetToken(TokenClass.Control, Major.ParAttr, Minor.StyleNum, based_on, "\\s");
+ rtf.RouteToken();
+ }
+
+ se = elements;
+ while (se != null) {
+ rtf.TokenClass = se.TokenClass;
+ rtf.Major = se.Major;
+ rtf.Minor = se.Minor;
+ rtf.Param = se.Param;
+ rtf.Text = se.Text;
+ rtf.RouteToken();
+ }
+
+ expanding = false;
+ }
+
+ static public Style GetStyle(RTF rtf, int style_number) {
+ Style s;
+
+ lock (rtf) {
+ s = GetStyle(rtf.Styles, style_number);
+ }
+ return s;
+ }
+
+ static public Style GetStyle(Style start, int style_number) {
+ Style s;
+
+ if (style_number == -1) {
+ return start;
+ }
+
+ s = start;
+
+ while ((s != null) && (s.num != style_number)) {
+ s = s.next;
+ }
+ return s;
+ }
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/StyleElement.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/StyleElement.cs
new file mode 100644
index 00000000000..505758de792
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/StyleElement.cs
@@ -0,0 +1,116 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms.RTF {
+ internal class StyleElement {
+ #region Local Variables
+ private TokenClass token_class;
+ private Major major;
+ private Minor minor;
+ private int param;
+ private string text;
+ private StyleElement next;
+ #endregion Local Variables
+
+ #region Constructors
+ public StyleElement(Style s, TokenClass token_class, Major major, Minor minor, int param, string text) {
+ this.token_class = token_class;
+ this.major = major;
+ this.minor = minor;
+ this.param = param;
+ this.text = text;
+
+ lock (s) {
+ if (s.Elements == null) {
+ s.Elements = this;
+ } else {
+ StyleElement se = s.Elements;
+ while (se.next != null)
+ se = se.next;
+ se.next = this;
+ }
+ }
+ }
+ #endregion // Constructors
+
+ #region Properties
+ public TokenClass TokenClass {
+ get {
+ return token_class;
+ }
+
+ set {
+ token_class = value;
+ }
+ }
+
+ public Major Major {
+ get {
+ return major;
+ }
+
+ set {
+ major = value;
+ }
+ }
+
+ public Minor Minor {
+ get {
+ return minor;
+ }
+
+ set {
+ minor = value;
+ }
+ }
+
+ public int Param {
+ get {
+ return param;
+ }
+
+ set {
+ param = value;
+ }
+ }
+
+ public string Text {
+ get {
+ return text;
+ }
+
+ set {
+ text = value;
+ }
+ }
+ #endregion // Properties
+
+ #region Methods
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/StyleType.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/StyleType.cs
new file mode 100644
index 00000000000..f34a667e8fc
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/StyleType.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms.RTF {
+ internal enum StyleType {
+ Paragraph = 0,
+ Character = 1,
+ Section = 2
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/TextMap.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/TextMap.cs
new file mode 100644
index 00000000000..b77497a20e8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/TextMap.cs
@@ -0,0 +1,228 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// This map is for convencience only, any app can create/use it's own
+// StdCharCode -> <text> table
+
+using System.Collections;
+
+namespace System.Windows.Forms.RTF {
+ internal class TextMap {
+ #region Local Variables
+ private string[] table;
+ #endregion // Local Variables
+
+ #region Public Constructors
+ public TextMap() {
+ table = new string[(int)StandardCharCode.MaxChar];
+
+ for (int i = 0; i < (int)StandardCharCode.MaxChar; i++) {
+ table[i] = string.Empty;
+ }
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ internal string this[StandardCharCode c] { // FIXME - this should be public, if the whole namespace was public (ie standalone RTF parser)
+ get {
+ return table[(int)c];
+ }
+
+ set {
+ table[(int)c] = value;
+ }
+ }
+
+ public string[] Table {
+ get {
+ return table;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Static Methods
+ public static void SetupStandardTable(string[] table) {
+ table[(int)StandardCharCode.space] = " ";
+ table[(int)StandardCharCode.exclam] = "!";
+ table[(int)StandardCharCode.quotedbl] = "\"";
+ table[(int)StandardCharCode.numbersign] = "#";
+ table[(int)StandardCharCode.dollar] = "$";
+ table[(int)StandardCharCode.percent] = "%";
+ table[(int)StandardCharCode.ampersand] = "&";
+ table[(int)StandardCharCode.quoteright] = "'";
+ table[(int)StandardCharCode.parenleft] = "(";
+ table[(int)StandardCharCode.parenright] = ")";
+ table[(int)StandardCharCode.asterisk] = "*";
+ table[(int)StandardCharCode.plus] = "+";
+ table[(int)StandardCharCode.comma] = ",";
+ table[(int)StandardCharCode.hyphen] = "-";
+ table[(int)StandardCharCode.period] = ".";
+ table[(int)StandardCharCode.slash] = "/";
+ table[(int)StandardCharCode.zero] = "0";
+ table[(int)StandardCharCode.one] = "1";
+ table[(int)StandardCharCode.two] = "2";
+ table[(int)StandardCharCode.three] = "3";
+ table[(int)StandardCharCode.four] = "4";
+ table[(int)StandardCharCode.five] = "5";
+ table[(int)StandardCharCode.six] = "6";
+ table[(int)StandardCharCode.seven] = "7";
+ table[(int)StandardCharCode.eight] = "8";
+ table[(int)StandardCharCode.nine] = "9";
+ table[(int)StandardCharCode.colon] = ":";
+ table[(int)StandardCharCode.semicolon] = ";";
+ table[(int)StandardCharCode.less] = "<";
+ table[(int)StandardCharCode.equal] = "=";
+ table[(int)StandardCharCode.greater] = ">";
+ table[(int)StandardCharCode.question] = "?";
+ table[(int)StandardCharCode.at] = "@";
+ table[(int)StandardCharCode.A] = "A";
+ table[(int)StandardCharCode.B] = "B";
+ table[(int)StandardCharCode.C] = "C";
+ table[(int)StandardCharCode.D] = "D";
+ table[(int)StandardCharCode.E] = "E";
+ table[(int)StandardCharCode.F] = "F";
+ table[(int)StandardCharCode.G] = "G";
+ table[(int)StandardCharCode.H] = "H";
+ table[(int)StandardCharCode.I] = "I";
+ table[(int)StandardCharCode.J] = "J";
+ table[(int)StandardCharCode.K] = "K";
+ table[(int)StandardCharCode.L] = "L";
+ table[(int)StandardCharCode.M] = "M";
+ table[(int)StandardCharCode.N] = "N";
+ table[(int)StandardCharCode.O] = "O";
+ table[(int)StandardCharCode.P] = "P";
+ table[(int)StandardCharCode.Q] = "Q";
+ table[(int)StandardCharCode.R] = "R";
+ table[(int)StandardCharCode.S] = "S";
+ table[(int)StandardCharCode.T] = "T";
+ table[(int)StandardCharCode.U] = "U";
+ table[(int)StandardCharCode.V] = "V";
+ table[(int)StandardCharCode.W] = "W";
+ table[(int)StandardCharCode.X] = "X";
+ table[(int)StandardCharCode.Y] = "Y";
+ table[(int)StandardCharCode.Z] = "Z";
+ table[(int)StandardCharCode.bracketleft] = "[";
+ table[(int)StandardCharCode.backslash] = "\\";
+ table[(int)StandardCharCode.bracketright] = "]";
+ table[(int)StandardCharCode.asciicircum] = "^";
+ table[(int)StandardCharCode.underscore] = "_";
+ table[(int)StandardCharCode.quoteleft] = "`";
+ table[(int)StandardCharCode.a] = "a";
+ table[(int)StandardCharCode.b] = "b";
+ table[(int)StandardCharCode.c] = "c";
+ table[(int)StandardCharCode.d] = "d";
+ table[(int)StandardCharCode.e] = "e";
+ table[(int)StandardCharCode.f] = "f";
+ table[(int)StandardCharCode.g] = "g";
+ table[(int)StandardCharCode.h] = "h";
+ table[(int)StandardCharCode.i] = "i";
+ table[(int)StandardCharCode.j] = "j";
+ table[(int)StandardCharCode.k] = "k";
+ table[(int)StandardCharCode.l] = "l";
+ table[(int)StandardCharCode.m] = "m";
+ table[(int)StandardCharCode.n] = "n";
+ table[(int)StandardCharCode.o] = "o";
+ table[(int)StandardCharCode.p] = "p";
+ table[(int)StandardCharCode.q] = "q";
+ table[(int)StandardCharCode.r] = "r";
+ table[(int)StandardCharCode.s] = "s";
+ table[(int)StandardCharCode.t] = "t";
+ table[(int)StandardCharCode.u] = "u";
+ table[(int)StandardCharCode.v] = "v";
+ table[(int)StandardCharCode.w] = "w";
+ table[(int)StandardCharCode.x] = "x";
+ table[(int)StandardCharCode.y] = "y";
+ table[(int)StandardCharCode.z] = "z";
+ table[(int)StandardCharCode.braceleft] = "{";
+ table[(int)StandardCharCode.bar] = "|";
+ table[(int)StandardCharCode.braceright] = "}";
+ table[(int)StandardCharCode.asciitilde] = "~";
+ table[(int)StandardCharCode.AE] = "AE";
+ table[(int)StandardCharCode.OE] = "OE";
+ table[(int)StandardCharCode.acute] = "'";
+ table[(int)StandardCharCode.ae] = "ae";
+ table[(int)StandardCharCode.angleleft] = "<";
+ table[(int)StandardCharCode.angleright] = ">";
+ table[(int)StandardCharCode.arrowboth] = "<->";
+ table[(int)StandardCharCode.arrowdblboth] = "<=>";
+ table[(int)StandardCharCode.arrowdblleft] = "<=";
+ table[(int)StandardCharCode.arrowdblright] = "=>";
+ table[(int)StandardCharCode.arrowleft] = "<-";
+ table[(int)StandardCharCode.arrowright] = "->";
+ table[(int)StandardCharCode.bullet] = "o";
+ table[(int)StandardCharCode.cent] = "cent";
+ table[(int)StandardCharCode.circumflex] = "^";
+ table[(int)StandardCharCode.copyright] = "(c)";
+ table[(int)StandardCharCode.copyrightsans] = "(c)";
+ table[(int)StandardCharCode.degree] = "deg.";
+ table[(int)StandardCharCode.divide] = "/";
+ table[(int)StandardCharCode.dotlessi] = "i";
+ table[(int)StandardCharCode.ellipsis] = "...";
+ table[(int)StandardCharCode.emdash] = "--";
+ table[(int)StandardCharCode.endash] = "-";
+ table[(int)StandardCharCode.fi] = "fi";
+ table[(int)StandardCharCode.fl] = "fl";
+ table[(int)StandardCharCode.fraction] = "/";
+ table[(int)StandardCharCode.germandbls] = "ss";
+ table[(int)StandardCharCode.grave] = "`";
+ table[(int)StandardCharCode.greaterequal] = ">=";
+ table[(int)StandardCharCode.guillemotleft] = "<<";
+ table[(int)StandardCharCode.guillemotright] = ">>";
+ table[(int)StandardCharCode.guilsinglleft] = "<";
+ table[(int)StandardCharCode.guilsinglright] = ">";
+ table[(int)StandardCharCode.lessequal] = "<=";
+ table[(int)StandardCharCode.logicalnot] = "~";
+ table[(int)StandardCharCode.mathasterisk] = "*";
+ table[(int)StandardCharCode.mathequal] = "=";
+ table[(int)StandardCharCode.mathminus] = "-";
+ table[(int)StandardCharCode.mathnumbersign] = "#";
+ table[(int)StandardCharCode.mathplus] = "+";
+ table[(int)StandardCharCode.mathtilde] = "~";
+ table[(int)StandardCharCode.minus] = "-";
+ table[(int)StandardCharCode.mu] = "u";
+ table[(int)StandardCharCode.multiply] = "x";
+ table[(int)StandardCharCode.nobrkhyphen] = "-";
+ table[(int)StandardCharCode.nobrkspace] = "";
+ table[(int)StandardCharCode.notequal] = "!=";
+ table[(int)StandardCharCode.oe] = "oe";
+ table[(int)StandardCharCode.onehalf] = "1/2";
+ table[(int)StandardCharCode.onequarter] = "1/4";
+ table[(int)StandardCharCode.periodcentered] = ".";
+ table[(int)StandardCharCode.plusminus] = "+/-";
+ table[(int)StandardCharCode.quotedblbase] = ",,";
+ table[(int)StandardCharCode.quotedblleft] = "\"";
+ table[(int)StandardCharCode.quotedblright] = "\"";
+ table[(int)StandardCharCode.quotesinglbase] = ",";
+ table[(int)StandardCharCode.registered] = "reg.";
+ table[(int)StandardCharCode.registersans] = "reg.";
+ table[(int)StandardCharCode.threequarters] = "3/4";
+ table[(int)StandardCharCode.tilde] = "~";
+ table[(int)StandardCharCode.trademark] = "(TM)";
+ table[(int)StandardCharCode.trademarksans] = "(TM)";
+ }
+ #endregion // Public Static Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/TokenClass.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/TokenClass.cs
new file mode 100644
index 00000000000..bd86509b101
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/TokenClass.cs
@@ -0,0 +1,39 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms.RTF {
+ internal enum TokenClass {
+ None = -1,
+ Unknown = 0,
+ Group = 1,
+ Text = 2,
+ Control = 3,
+ EOF = 4,
+ MaxClass = 5
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/rtf.csproj b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/rtf.csproj
new file mode 100644
index 00000000000..f8763b1b5c7
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/rtf.csproj
@@ -0,0 +1,200 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{12D60959-776E-41E9-82BE-AA5DF4BB7CAE}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "rtf"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Exe"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "rtf"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = ""
+ 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 = "false"
+ OutputPath = "bin\Release\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "1"
+ />
+ </Settings>
+ <References>
+ <Reference
+ Name = "System.Drawing"
+ AssemblyName = "System.Drawing"
+ HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Drawing.dll"
+ />
+ <Reference
+ Name = "System"
+ AssemblyName = "System"
+ HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
+ />
+ <Reference
+ Name = "System.Windows.Forms"
+ AssemblyName = "System.Windows.Forms"
+ HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Windows.Forms.dll"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "Charcode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Charset.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "CharsetFlags.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "CharsetType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ClassDelegate.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Color.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "DestinationDelegate.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Font.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "KeysInit.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "KeyStruct.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Major.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Minor.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "RTF.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "RTFException.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "StandardCharCode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "StandardCharName.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Style.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "StyleElement.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "StyleType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "test.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "TextMap.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "TokenClass.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/rtf.csproj.user b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/rtf.csproj.user
new file mode 100644
index 00000000000..0e89b7e9542
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/rtf.csproj.user
@@ -0,0 +1,48 @@
+<VisualStudioProject>
+ <CSHARP LastOpenVersion = "7.10.3077" >
+ <Build>
+ <Settings ReferencePath = "" >
+ <Config
+ Name = "Debug"
+ EnableASPDebugging = "false"
+ EnableASPXDebugging = "false"
+ EnableUnmanagedDebugging = "false"
+ EnableSQLServerDebugging = "false"
+ RemoteDebugEnabled = "false"
+ RemoteDebugMachine = ""
+ StartAction = "Project"
+ StartArguments = ""
+ StartPage = ""
+ StartProgram = ""
+ StartURL = ""
+ StartWorkingDirectory = ""
+ StartWithIE = "false"
+ />
+ <Config
+ Name = "Release"
+ EnableASPDebugging = "false"
+ EnableASPXDebugging = "false"
+ EnableUnmanagedDebugging = "false"
+ EnableSQLServerDebugging = "false"
+ RemoteDebugEnabled = "false"
+ RemoteDebugMachine = ""
+ StartAction = "Project"
+ StartArguments = ""
+ StartPage = ""
+ StartProgram = ""
+ StartURL = ""
+ StartWorkingDirectory = ""
+ StartWithIE = "false"
+ />
+ </Settings>
+ </Build>
+ <OtherProjectSettings
+ CopyProjectDestinationFolder = ""
+ CopyProjectUncPath = ""
+ CopyProjectOption = "0"
+ ProjectView = "ProjectFiles"
+ ProjectTrust = "0"
+ />
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/test.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/test.cs
new file mode 100644
index 00000000000..c62cdb90c49
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/test.cs
@@ -0,0 +1,286 @@
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Drawing.Text;
+using System.Windows.Forms;
+using System.Text;
+using System.Threading;
+using System.Windows.Forms.RTF;
+using System.IO;
+
+namespace TextTestClass {
+ public class Test {
+ static Test test;
+ int skip_width;
+ int skip_count;
+ private string rtf_string = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Microsoft Sans Serif;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs17 testing 123testiong\\par\r\n}";
+ private string rtf_string2 = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fswiss\\fcharset0 Arial;}{\\f1\\fmodern\\fprq1\\fcharset0 Courier;}{\\f2\\fswiss\\fprq2\\fcharset0 Arial;}}\r\n" +
+ "{\\colortbl ;\\red255\\green0\\blue0;\\red0\\green0\\blue0;}\r\n" +
+ "{\\*\\generator Msftedit 5.41.15.1507;}\\viewkind4\\uc1\\pard\\f0\\fs20 I am in Arial 10pt\\par\r\n" +
+ "\\fs24 I am in Arial 12pt\\par\r\n" +
+ "\\f1 I am in Courier 12pt\\par\r\n" +
+ "\\cf1 I am in Courier 12pt Red\\par\r\n" +
+ "\\cf2\\f2\\fs20 I am in Arial 10pt\\par\r\n" +
+ "\\b I am in Arial 10pt Italic\\cf0\\b0\\f0\\par\r\n" +
+ "}";
+ private string rtf_string3 = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fswiss\\fcharset0 Arial;}{" +
+ "\\f1\\fmodern\\fprq1\\fcharset0 Courier;}{\\f2\\fswiss\\fprq2\\fcharset0 Arial;}{\\f3\\fni" +
+ "l\\fcharset0 Impact;}{\\f4\\fnil\\fcharset0 Arial Unicode MS;}{\\f5\\fnil\\fcharset136 Arial Unicode MS;}{\\f6\\fnil\\fcharset0 MS" +
+ " Shell Dlg;}}" +
+ "{\\colortbl ;\\red255\\green0\\blue0;\\red0\\green0\\blue0;}" +
+ "{\\*\\generator Msftedit 5.41.15.1507;}\\viewkind4\\uc1\\pard\\f0\\fs20 I am in Arial 1" +
+ "0pt\\par" +
+ "\\fs24 I am in Arial 12pt\\par" +
+ "\\f1 I am in Courier 12pt\\par" +
+ "\\cf1 I am in Courier 12pt Red\\par" +
+ "\\cf2\\f2\\fs20 I am in Arial 10pt\\par" +
+ "\\b I am in Arial 10pt Bold\\par" +
+ "\\i I am in Arial 10pt Bold Italic\\par" +
+ "\\ul I am in Arial 10pt Bold Italic Underline\\par" +
+ "\\ulnone\\b0\\i0\\strike I am in Arial 10pt Strikethrough\\par" +
+ "\\cf0\\strike0\\f3\\fs23 Some cyrilic character: \\u1034?\\par" +
+ "And 5 CJK characters: \\f4\\fs21\\u23854?\\u23854?\\u23854?\\u23854?\\u23854?\\f5\\fs17\\par" +
+ "Some special chars:\\par" +
+ "\\tab Tilde: ~\\par" +
+ "\\tab Questionmark:?\\par" +
+ "\\tab Yen: \\f5\\u165?\\f6\\fs17\\par" +
+ "\\tab Umlaut: \\'e4\\par" +
+ "\\f0\\fs20\\par" +
+ "}";
+
+ TextMap text;
+
+ public Test() {
+ MemoryStream stream;
+ RTF rtf;
+ byte[] buffer;
+
+ text = new TextMap();
+ TextMap.SetupStandardTable(text.Table);
+
+ buffer = new byte[rtf_string.Length];
+ for (int i = 0; i < buffer.Length; i++) {
+ buffer[i] = (byte)rtf_string[i];
+ }
+ stream = new MemoryStream(buffer);
+ rtf = new RTF(stream);
+
+ skip_width = 0;
+ skip_count = 0;
+
+ rtf.ClassCallback[TokenClass.Text] = new ClassDelegate(HandleText);
+ rtf.ClassCallback[TokenClass.Control] = new ClassDelegate(HandleControl);
+
+ rtf.Read();
+
+ stream.Close();
+ }
+
+ void HandleControl(RTF rtf) {
+ switch(rtf.Major) {
+ case Major.Unicode: {
+ switch(rtf.Minor) {
+ case Minor.UnicodeCharBytes: {
+ skip_width = rtf.Param;
+ break;
+ }
+
+ case Minor.UnicodeChar: {
+ Console.Write("[Unicode {0:X4}]", rtf.Param);
+ skip_count += skip_width;
+ break;
+ }
+ }
+ break;
+ }
+
+ case Major.Destination: {
+ Console.Write("[Got Destination control {0}]", rtf.Minor);
+ rtf.SkipGroup();
+ break;
+ }
+
+ case Major.CharAttr: {
+ switch(rtf.Minor) {
+ case Minor.ForeColor: {
+ System.Windows.Forms.RTF.Color color;
+ int num;
+
+ color = System.Windows.Forms.RTF.Color.GetColor(rtf, rtf.Param);
+ if (color != null) {
+ if (color.Red == -1 && color.Green == -1 && color.Blue == -1) {
+ Console.Write("[Default Color]");
+ } else {
+ Console.Write("[Color {0} [{1:X2}{2:X2}{3:X}]]", rtf.Param, color.Red, color.Green, color.Blue);
+ }
+ }
+ break;
+ }
+
+ case Minor.FontSize: {
+ Console.Write("[Fontsize {0}]", rtf.Param);
+ break;
+ }
+
+ case Minor.FontNum: {
+ System.Windows.Forms.RTF.Font font;
+
+ font = System.Windows.Forms.RTF.Font.GetFont(rtf, rtf.Param);
+ if (font != null) {
+ Console.Write("[Font {0} [{1}]]", rtf.Param, font.Name);
+ }
+ break;
+ }
+
+ case Minor.Plain: {
+ Console.Write("[Normal]");
+ break;
+ }
+
+ case Minor.Bold: {
+ if (rtf.Param == RTF.NoParam) {
+ Console.Write("[Bold]");
+ } else {
+ Console.Write("[NoBold]");
+ }
+ break;
+ }
+
+ case Minor.Italic: {
+ if (rtf.Param == RTF.NoParam) {
+ Console.Write("[Italic]");
+ } else {
+ Console.Write("[NoItalic]");
+ }
+ break;
+ }
+
+ case Minor.StrikeThru: {
+ if (rtf.Param == RTF.NoParam) {
+ Console.Write("[StrikeThru]");
+ } else {
+ Console.Write("[NoStrikeThru]");
+ }
+ break;
+ }
+
+ case Minor.Underline: {
+ if (rtf.Param == RTF.NoParam) {
+ Console.Write("[Underline]");
+ } else {
+ Console.Write("[NoUnderline]");
+ }
+ break;
+ }
+
+ case Minor.NoUnderline: {
+ Console.Write("[NoUnderline]");
+ break;
+ }
+ }
+ break;
+ }
+
+ case Major.SpecialChar: {
+ Console.Write("[Got SpecialChar control {0}]", rtf.Minor);
+ SpecialChar(rtf);
+ break;
+ }
+ }
+ }
+
+ void SpecialChar(RTF rtf) {
+ switch(rtf.Minor) {
+ case Minor.Page:
+ case Minor.Sect:
+ case Minor.Row:
+ case Minor.Line:
+ case Minor.Par: {
+ Console.Write("\n");
+ break;
+ }
+
+ case Minor.Cell: {
+ Console.Write(" ");
+ break;
+ }
+
+ case Minor.NoBrkSpace: {
+ Console.Write(" ");
+ break;
+ }
+
+ case Minor.Tab: {
+ Console.Write("\t");
+ break;
+ }
+
+ case Minor.NoBrkHyphen: {
+ Console.Write("-");
+ break;
+ }
+
+ case Minor.Bullet: {
+ Console.Write("*");
+ break;
+ }
+
+ case Minor.EmDash: {
+ Console.Write("—");
+ break;
+ }
+
+ case Minor.EnDash: {
+ Console.Write("–");
+ break;
+ }
+
+ case Minor.LQuote: {
+ Console.Write("‘");
+ break;
+ }
+
+ case Minor.RQuote: {
+ Console.Write("’");
+ break;
+ }
+
+ case Minor.LDblQuote: {
+ Console.Write("“");
+ break;
+ }
+
+ case Minor.RDblQuote: {
+ Console.Write("”");
+ break;
+ }
+
+ default: {
+ rtf.SkipGroup();
+ break;
+ }
+ }
+ }
+
+
+ void HandleText(RTF rtf) {
+ if (skip_count > 0) {
+ skip_count--;
+ return;
+ }
+ if ((StandardCharCode)rtf.Minor != StandardCharCode.nothing) {
+ Console.Write("{0}", text[(StandardCharCode)rtf.Minor]);
+ } else {
+ if ((int)rtf.Major > 31 && (int)rtf.Major < 128) {
+ Console.Write("{0}", (char)rtf.Major);
+ } else {
+ Console.Write("[Literal:0x{0:X2}]", (int)rtf.Major);
+ }
+ }
+ }
+
+ public static void Main() {
+ test = new Test();
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.resources b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.resources
new file mode 100644
index 00000000000..c819860e364
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.resources
@@ -0,0 +1,10 @@
+-resource:resources/System.Windows.Forms.resources
+-resource:resources/System.Windows.Forms.en.resources
+-resource:resources/System.Windows.Forms.de.resources
+-resource:resources/SplitterNS.cur,System.Windows.Forms.SplitterNS.cur
+-resource:resources/SplitterWE.cur,System.Windows.Forms.SplitterWE.cur
+-resource:resources/DnDNo.cur,System.Windows.Forms.DnDNo.cur
+-resource:resources/DnDCopy.cur,System.Windows.Forms.DnDCopy.cur
+-resource:resources/DnDLink.cur,System.Windows.Forms.DnDLink.cur
+-resource:resources/DnDMove.cur,System.Windows.Forms.DnDMove.cur
+-resource:resources/keyboards.resources \ No newline at end of file
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources
new file mode 100644
index 00000000000..b2c42c632d1
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources
@@ -0,0 +1,533 @@
+Assembly/AssemblyInfo.cs
+../../build/common/Consts.cs
+Assembly/Locale.cs
+System.Resources/ResXNullRef.cs
+System.Resources/ResXFileRef.cs
+System.Resources/ResXResourceReader.cs
+System.Resources/ResXResourceSet.cs
+System.Resources/ResXResourceWriter.cs
+System.Windows.Forms.Design/ComponentEditorForm.cs
+System.Windows.Forms.Design/ComponentEditorPage.cs
+System.Windows.Forms.Design/EventsTab.cs
+System.Windows.Forms.Design/IUIService.cs
+System.Windows.Forms.Design/IWindowsFormsEditorService.cs
+System.Windows.Forms.Design/PropertyTab.cs
+System.Windows.Forms.Design/WindowsFormsComponentEditor.cs
+System.Windows.Forms/AccessibleEvents.cs
+System.Windows.Forms/AccessibleNavigation.cs
+System.Windows.Forms/AccessibleObject.cs
+System.Windows.Forms/AccessibleRole.cs
+System.Windows.Forms/AccessibleSelection.cs
+System.Windows.Forms/AccessibleStates.cs
+System.Windows.Forms/AmbientProperties.cs
+System.Windows.Forms/AnchorStyles.cs
+System.Windows.Forms/Appearance.cs
+System.Windows.Forms/Application.cs
+System.Windows.Forms/ApplicationContext.cs
+System.Windows.Forms/ArrangeDirection.cs
+System.Windows.Forms/ArrangeStartingPosition.cs
+System.Windows.Forms/AsyncMethodData.cs
+System.Windows.Forms/AsyncMethodResult.cs
+System.Windows.Forms/AutoScaleMode.cs
+System.Windows.Forms/AxHost.cs
+System.Windows.Forms/BaseCollection.cs
+System.Windows.Forms/BindingContext.cs
+System.Windows.Forms/Binding.cs
+System.Windows.Forms/BindingManagerBase.cs
+System.Windows.Forms/BindingMemberInfo.cs
+System.Windows.Forms/BindingsCollection.cs
+System.Windows.Forms/BootMode.cs
+System.Windows.Forms/Border3DSide.cs
+System.Windows.Forms/Border3DStyle.cs
+System.Windows.Forms/BorderStyle.cs
+System.Windows.Forms/BoundsSpecified.cs
+System.Windows.Forms/Button.cs
+System.Windows.Forms/ButtonBase.cs
+System.Windows.Forms/ButtonBorderStyle.cs
+System.Windows.Forms/ButtonState.cs
+System.Windows.Forms/CaptionButton.cs
+System.Windows.Forms/CategoryGridEntry.cs
+System.Windows.Forms/CharacterCasing.cs
+System.Windows.Forms/CheckBox.cs
+System.Windows.Forms/CheckedListBox.cs
+System.Windows.Forms/CheckState.cs
+System.Windows.Forms/ColorDepth.cs
+System.Windows.Forms/Clipboard.cs
+System.Windows.Forms/ColorDialog.cs
+System.Windows.Forms/ColumnClickEventArgs.cs
+System.Windows.Forms/ColumnClickEventHandler.cs
+System.Windows.Forms/ColumnHeader.cs
+System.Windows.Forms/ColumnHeaderStyle.cs
+System.Windows.Forms/ComboBox.cs
+System.Windows.Forms/ComboBoxStyle.cs
+System.Windows.Forms/CommonDialog.cs
+System.Windows.Forms/ComponentModel.cs
+System.Windows.Forms/ContainerControl.cs
+System.Windows.Forms/ContentsResizedEventArgs.cs
+System.Windows.Forms/ContentsResizedEventHandler.cs
+System.Windows.Forms/ContextMenu.cs
+System.Windows.Forms/Control.cs
+System.Windows.Forms/ControlBindingsCollection.cs
+System.Windows.Forms/ControlEventArgs.cs
+System.Windows.Forms/ControlEventHandler.cs
+System.Windows.Forms/ControlPaint.cs
+System.Windows.Forms/ControlStyles.cs
+System.Windows.Forms/ConvertEventArgs.cs
+System.Windows.Forms/ConvertEventHandler.cs
+System.Windows.Forms/CreateParams.cs
+System.Windows.Forms/CurrencyManager.cs
+System.Windows.Forms/Cursor.cs
+System.Windows.Forms/CursorConverter.cs
+System.Windows.Forms/Cursors.cs
+System.Windows.Forms/DataFormats.cs
+System.Windows.Forms/DataGrid.cs
+System.Windows.Forms/DataGridDrawingLogic.cs
+System.Windows.Forms/DataGridBoolColumn.cs
+System.Windows.Forms/DataGridCell.cs
+System.Windows.Forms/DataGridColumnStyle.cs
+System.Windows.Forms/DataGridLineStyle.cs
+System.Windows.Forms/DataGridParentRowsLabelStyle.cs
+System.Windows.Forms/DataGridPreferredColumnWidthTypeConverter.cs
+System.Windows.Forms/DataGridTableStyle.cs
+System.Windows.Forms/DataGridTextBox.cs
+System.Windows.Forms/DataGridTextBoxColumn.cs
+System.Windows.Forms/DataGridViewAdvancedBorderStyle.cs
+System.Windows.Forms/DataGridViewAdvancedCellBorderStyle.cs
+System.Windows.Forms/DataGridViewAutoSizeColumnMode.cs
+System.Windows.Forms/DataGridViewAutoSizeColumnModeEventArgs.cs
+System.Windows.Forms/DataGridViewAutoSizeColumnModeEventHandler.cs
+System.Windows.Forms/DataGridViewAutoSizeColumnsMode.cs
+System.Windows.Forms/DataGridViewAutoSizeColumnsModeEventArgs.cs
+System.Windows.Forms/DataGridViewAutoSizeColumnsModeEventHandler.cs
+System.Windows.Forms/DataGridViewAutoSizeModeEventArgs.cs
+System.Windows.Forms/DataGridViewAutoSizeModeEventHandler.cs
+System.Windows.Forms/DataGridViewAutoSizeRowMode.cs
+System.Windows.Forms/DataGridViewAutoSizeRowsMode.cs
+System.Windows.Forms/DataGridViewBand.cs
+System.Windows.Forms/DataGridViewBindingCompleteEventArgs.cs
+System.Windows.Forms/DataGridViewBindingCompleteEventHandler.cs
+System.Windows.Forms/DataGridViewButtonCell.cs
+System.Windows.Forms/DataGridViewButtonColumn.cs
+System.Windows.Forms/DataGridViewCellBorderStyle.cs
+System.Windows.Forms/DataGridViewCellCancelEventArgs.cs
+System.Windows.Forms/DataGridViewCellCancelEventHandler.cs
+System.Windows.Forms/DataGridViewCellCollection.cs
+System.Windows.Forms/DataGridViewCellContextMenuStripNeededEventArgs.cs
+System.Windows.Forms/DataGridViewCellContextMenuStripNeededEventHandler.cs
+System.Windows.Forms/DataGridViewCell.cs
+System.Windows.Forms/DataGridViewCellErrorTextNeededEventArgs.cs
+System.Windows.Forms/DataGridViewCellErrorTextNeededEventHandler.cs
+System.Windows.Forms/DataGridViewCellEventArgs.cs
+System.Windows.Forms/DataGridViewCellEventHandler.cs
+System.Windows.Forms/DataGridViewCellFormattingEventArgs.cs
+System.Windows.Forms/DataGridViewCellFormattingEventHandler.cs
+System.Windows.Forms/DataGridViewCellMouseEventArgs.cs
+System.Windows.Forms/DataGridViewCellMouseEventHandler.cs
+System.Windows.Forms/DataGridViewCellPaintingEventArgs.cs
+System.Windows.Forms/DataGridViewCellPaintingEventHandler.cs
+System.Windows.Forms/DataGridViewCellParsingEventArgs.cs
+System.Windows.Forms/DataGridViewCellParsingEventHandler.cs
+System.Windows.Forms/DataGridViewCellStateChangedEventArgs.cs
+System.Windows.Forms/DataGridViewCellStateChangedEventHandler.cs
+System.Windows.Forms/DataGridViewCellStyleContentChangedEventArgs.cs
+System.Windows.Forms/DataGridViewCellStyleContentChangedEventHandler.cs
+System.Windows.Forms/DataGridViewCellStyleConverter.cs
+System.Windows.Forms/DataGridViewCellStyle.cs
+System.Windows.Forms/DataGridViewCellStyleScopes.cs
+System.Windows.Forms/DataGridViewCellToolTipTextNeededEventArgs.cs
+System.Windows.Forms/DataGridViewCellToolTipTextNeededEventHandler.cs
+System.Windows.Forms/DataGridViewCellValidatingEventArgs.cs
+System.Windows.Forms/DataGridViewCellValidatingEventHandler.cs
+System.Windows.Forms/DataGridViewCellValueEventArgs.cs
+System.Windows.Forms/DataGridViewCellValueEventHandler.cs
+System.Windows.Forms/DataGridViewCheckBoxCell.cs
+System.Windows.Forms/DataGridViewCheckBoxColumn.cs
+System.Windows.Forms/DataGridViewClipboardCopyMode.cs
+System.Windows.Forms/DataGridViewColumnCollection.cs
+System.Windows.Forms/DataGridViewColumn.cs
+System.Windows.Forms/DataGridViewColumnDesignTimeVisibleAttribute.cs
+System.Windows.Forms/DataGridViewColumnDividerDoubleClickEventArgs.cs
+System.Windows.Forms/DataGridViewColumnDividerDoubleClickEventHandler.cs
+System.Windows.Forms/DataGridViewColumnEventArgs.cs
+System.Windows.Forms/DataGridViewColumnEventHandler.cs
+System.Windows.Forms/DataGridViewColumnHeaderCell.cs
+System.Windows.Forms/DataGridViewColumnHeadersHeightSizeMode.cs
+System.Windows.Forms/DataGridViewColumnSortMode.cs
+System.Windows.Forms/DataGridViewColumnStateChangedEventArgs.cs
+System.Windows.Forms/DataGridViewColumnStateChangedEventHandler.cs
+System.Windows.Forms/DataGridViewComboBoxCell.cs
+System.Windows.Forms/DataGridViewComboBoxColumn.cs
+System.Windows.Forms/DataGridViewComboBoxDisplayStyle.cs
+System.Windows.Forms/DataGridViewComboBoxEditingControl.cs
+System.Windows.Forms/DataGridViewContentAlignment.cs
+System.Windows.Forms/DataGridView.cs
+System.Windows.Forms/DataGridViewDataErrorContexts.cs
+System.Windows.Forms/DataGridViewDataErrorEventArgs.cs
+System.Windows.Forms/DataGridViewDataErrorEventHandler.cs
+System.Windows.Forms/DataGridViewEditingControlShowingEventArgs.cs
+System.Windows.Forms/DataGridViewEditingControlShowingEventHandler.cs
+System.Windows.Forms/DataGridViewEditMode.cs
+System.Windows.Forms/DataGridViewElement.cs
+System.Windows.Forms/DataGridViewElementStates.cs
+System.Windows.Forms/DataGridViewHeaderBorderStyle.cs
+System.Windows.Forms/DataGridViewHeaderCell.cs
+System.Windows.Forms/DataGridViewHitTestType.cs
+System.Windows.Forms/DataGridViewImageCell.cs
+System.Windows.Forms/DataGridViewImageCellLayout.cs
+System.Windows.Forms/DataGridViewImageColumn.cs
+System.Windows.Forms/DataGridViewPaintParts.cs
+System.Windows.Forms/DataGridViewRowCancelEventArgs.cs
+System.Windows.Forms/DataGridViewRowCancelEventHandler.cs
+System.Windows.Forms/DataGridViewRowCollection.cs
+System.Windows.Forms/DataGridViewRowContextMenuStripNeededEventArgs.cs
+System.Windows.Forms/DataGridViewRowContextMenuStripNeededEventHandler.cs
+System.Windows.Forms/DataGridViewRow.cs
+System.Windows.Forms/DataGridViewRowDividerDoubleClickEventArgs.cs
+System.Windows.Forms/DataGridViewRowDividerDoubleClickEventHandler.cs
+System.Windows.Forms/DataGridViewRowErrorTextNeededEventArgs.cs
+System.Windows.Forms/DataGridViewRowErrorTextNeededEventHandler.cs
+System.Windows.Forms/DataGridViewRowEventArgs.cs
+System.Windows.Forms/DataGridViewRowEventHandler.cs
+System.Windows.Forms/DataGridViewRowHeaderCell.cs
+System.Windows.Forms/DataGridViewRowHeadersWidthSizeMode.cs
+System.Windows.Forms/DataGridViewRowHeightInfoNeededEventArgs.cs
+System.Windows.Forms/DataGridViewRowHeightInfoNeededEventHandler.cs
+System.Windows.Forms/DataGridViewRowHeightInfoPushedEventArgs.cs
+System.Windows.Forms/DataGridViewRowHeightInfoPushedEventHandler.cs
+System.Windows.Forms/DataGridViewRowPostPaintEventArgs.cs
+System.Windows.Forms/DataGridViewRowPostPaintEventHandler.cs
+System.Windows.Forms/DataGridViewRowPrePaintEventArgs.cs
+System.Windows.Forms/DataGridViewRowPrePaintEventHandler.cs
+System.Windows.Forms/DataGridViewRowsAddedEventArgs.cs
+System.Windows.Forms/DataGridViewRowsAddedEventHandler.cs
+System.Windows.Forms/DataGridViewRowsDeletedEventArgs.cs
+System.Windows.Forms/DataGridViewRowsRemovedEventArgs.cs
+System.Windows.Forms/DataGridViewRowsRemovedEventHandler.cs
+System.Windows.Forms/DataGridViewRowStateChangedEventArgs.cs
+System.Windows.Forms/DataGridViewRowStateChangedEventHandler.cs
+System.Windows.Forms/DataGridViewSelectedCellCollection.cs
+System.Windows.Forms/DataGridViewSelectedColumnCollection.cs
+System.Windows.Forms/DataGridViewSelectedRowCollection.cs
+System.Windows.Forms/DataGridViewSelectionMode.cs
+System.Windows.Forms/DataGridViewSortCompareEventArgs.cs
+System.Windows.Forms/DataGridViewSortCompareEventHandler.cs
+System.Windows.Forms/DataGridViewTextBoxCell.cs
+System.Windows.Forms/DataGridViewTextBoxColumn.cs
+System.Windows.Forms/DataGridViewTextBoxEditingControl.cs
+System.Windows.Forms/DataGridViewTopLeftHeaderCell.cs
+System.Windows.Forms/DataGridViewTriState.cs
+System.Windows.Forms/DataObject.cs
+System.Windows.Forms/DateBoldEventArgs.cs
+System.Windows.Forms/DateBoldEventHandler.cs
+System.Windows.Forms/DateRangeEventArgs.cs
+System.Windows.Forms/DateRangeEventHandler.cs
+System.Windows.Forms/DateTimePicker.cs
+System.Windows.Forms/DateTimePickerFormat.cs
+System.Windows.Forms/Day.cs
+System.Windows.Forms/DialogResult.cs
+System.Windows.Forms/DockStyle.cs
+System.Windows.Forms/DomainUpDown.cs
+System.Windows.Forms/DragAction.cs
+System.Windows.Forms/DragDropEffects.cs
+System.Windows.Forms/DragEventArgs.cs
+System.Windows.Forms/DragEventHandler.cs
+System.Windows.Forms/DrawItemEventArgs.cs
+System.Windows.Forms/DrawItemEventHandler.cs
+System.Windows.Forms/DrawItemState.cs
+System.Windows.Forms/DrawMode.cs
+System.Windows.Forms/ErrorBlinkStyle.cs
+System.Windows.Forms/ErrorIconAlignment.cs
+System.Windows.Forms/ErrorProvider.cs
+System.Windows.Forms/FeatureSupport.cs
+System.Windows.Forms/FlatStyle.cs
+System.Windows.Forms/FontDialog.cs
+System.Windows.Forms/FileDialog.cs
+System.Windows.Forms/FixedSizeTextBox.cs
+System.Windows.Forms/FolderBrowserDialog.cs
+System.Windows.Forms/Form.cs
+System.Windows.Forms/FormBorderStyle.cs
+System.Windows.Forms/FormStartPosition.cs
+System.Windows.Forms/FormWindowState.cs
+System.Windows.Forms/FrameStyle.cs
+System.Windows.Forms/GiveFeedbackEventArgs.cs
+System.Windows.Forms/GiveFeedbackEventHandler.cs
+System.Windows.Forms/GridColumnStylesCollection.cs
+System.Windows.Forms/GridTablesFactory.cs
+System.Windows.Forms/GridTableStylesCollection.cs
+System.Windows.Forms/GridEntry.cs
+System.Windows.Forms/GridItem.cs
+System.Windows.Forms/GridItemCollection.cs
+System.Windows.Forms/GridItemType.cs
+System.Windows.Forms/GroupBox.cs
+System.Windows.Forms/HandledMouseEventArgs.cs
+System.Windows.Forms/Help.cs
+System.Windows.Forms/HelpEventArgs.cs
+System.Windows.Forms/HelpEventHandler.cs
+System.Windows.Forms/HelpNavigator.cs
+System.Windows.Forms/HelpProvider.cs
+System.Windows.Forms/HorizontalAlignment.cs
+System.Windows.Forms/HScrollBar.cs
+System.Windows.Forms/Hwnd.cs
+System.Windows.Forms/IButtonControl.cs
+System.Windows.Forms/ICommandExecutor.cs
+System.Windows.Forms/IComponentEditorPageSite.cs
+System.Windows.Forms/IContainerControl.cs
+System.Windows.Forms/IDataGridColumnStyleEditingNotificationService.cs
+System.Windows.Forms/IDataGridEditingService.cs
+System.Windows.Forms/IDataGridViewEditingCell.cs
+System.Windows.Forms/IDataGridViewEditingControl.cs
+System.Windows.Forms/IDataObject.cs
+System.Windows.Forms/IFeatureSupport.cs
+System.Windows.Forms/IFileReaderService.cs
+System.Windows.Forms/ImageIndexConverter.cs
+System.Windows.Forms/ImageLayout.cs
+System.Windows.Forms/ImageList.cs
+System.Windows.Forms/ImageListConverter.cs
+System.Windows.Forms/ImageListStreamer.cs
+System.Windows.Forms/ImeMode.cs
+System.Windows.Forms/IMessageFilter.cs
+System.Windows.Forms/ImplicitHScrollBar.cs
+System.Windows.Forms/ImplicitVScrollBar.cs
+System.Windows.Forms/InputLanguageChangedEventArgs.cs
+System.Windows.Forms/InputLanguageChangedEventHandler.cs
+System.Windows.Forms/InputLanguageChangingEventArgs.cs
+System.Windows.Forms/InputLanguageChangingEventHandler.cs
+System.Windows.Forms/InputLanguageCollection.cs
+System.Windows.Forms/InputLanguage.cs
+System.Windows.Forms/InternalWindowManager.cs
+System.Windows.Forms/InvalidateEventArgs.cs
+System.Windows.Forms/InvalidateEventHandler.cs
+System.Windows.Forms/IRootGridEntry.cs
+System.Windows.Forms/ItemActivation.cs
+System.Windows.Forms/ItemBoundsPortion.cs
+System.Windows.Forms/ItemChangedEventArgs.cs
+System.Windows.Forms/ItemChangedEventHandler.cs
+System.Windows.Forms/ItemCheckEventArgs.cs
+System.Windows.Forms/ItemCheckEventHandler.cs
+System.Windows.Forms/ItemDragEventArgs.cs
+System.Windows.Forms/ItemDragEventHandler.cs
+System.Windows.Forms/IWin32Window.cs
+System.Windows.Forms/IWindowTarget.cs
+System.Windows.Forms/KeyboardLayouts.cs
+System.Windows.Forms/KeyEventArgs.cs
+System.Windows.Forms/KeyEventHandler.cs
+System.Windows.Forms/KeyPressEventArgs.cs
+System.Windows.Forms/KeyPressEventHandler.cs
+System.Windows.Forms/Keys.cs
+System.Windows.Forms/KeysConverter.cs
+System.Windows.Forms/Label.cs
+System.Windows.Forms/LabelEditEventArgs.cs
+System.Windows.Forms/LabelEditEventHandler.cs
+System.Windows.Forms/LayoutEventArgs.cs
+System.Windows.Forms/LayoutEventHandler.cs
+System.Windows.Forms/LeftRightAlignment.cs
+System.Windows.Forms/LinkArea.cs
+System.Windows.Forms/LinkBehavior.cs
+System.Windows.Forms/LinkClickedEventArgs.cs
+System.Windows.Forms/LinkClickedEventHandler.cs
+System.Windows.Forms/LinkLabel.cs
+System.Windows.Forms/LinkLabelLinkClickedEventArgs.cs
+System.Windows.Forms/LinkLabelLinkClickedEventHandler.cs
+System.Windows.Forms/LinkState.cs
+System.Windows.Forms/ListBindingConverter.cs
+System.Windows.Forms/ListBox.cs
+System.Windows.Forms/ListControl.cs
+System.Windows.Forms/ListView.cs
+System.Windows.Forms/ListViewAlignment.cs
+System.Windows.Forms/ListViewItem.cs
+System.Windows.Forms/ListViewItemConverter.cs
+System.Windows.Forms/MainMenu.cs
+System.Windows.Forms/MdiWindowManager.cs
+System.Windows.Forms/MdiClient.cs
+System.Windows.Forms/MdiLayout.cs
+System.Windows.Forms/MeasureItemEventHandler.cs
+System.Windows.Forms/MeasureItemEventArgs.cs
+System.Windows.Forms/MenuGlyph.cs
+System.Windows.Forms/Menu.cs
+System.Windows.Forms/MenuAPI.cs
+System.Windows.Forms/MenuItem.cs
+System.Windows.Forms/MenuMerge.cs
+System.Windows.Forms/MessageBoxButtons.cs
+System.Windows.Forms/MessageBox.cs
+System.Windows.Forms/MessageBoxDefaultButton.cs
+System.Windows.Forms/MessageBoxIcon.cs
+System.Windows.Forms/MessageBoxOptions.cs
+System.Windows.Forms/Message.cs
+System.Windows.Forms/MethodInvoker.cs
+System.Windows.Forms/Mime.cs
+System.Windows.Forms/MimeIcon.cs
+System.Windows.Forms/MonthCalendar.cs
+System.Windows.Forms/MouseButtons.cs
+System.Windows.Forms/MouseEventArgs.cs
+System.Windows.Forms/MouseEventHandler.cs
+System.Windows.Forms/MWFCategoryAttribute.cs
+System.Windows.Forms/MWFDescriptionAttribute.cs
+System.Windows.Forms/NativeWindow.cs
+System.Windows.Forms/NavigateEventArgs.cs
+System.Windows.Forms/NavigateEventHandler.cs
+System.Windows.Forms/NumericUpDown.cs
+System.Windows.Forms/NodeLabelEditEventArgs.cs
+System.Windows.Forms/NodeLabelEditEventHandler.cs
+System.Windows.Forms/NotifyIcon.cs
+System.Windows.Forms/OpacityConverter.cs
+System.Windows.Forms/OpenFileDialog.cs
+System.Windows.Forms/OpenTreeNodeEnumerator.cs
+System.Windows.Forms/Orientation.cs
+System.Windows.Forms/OSFeature.cs
+System.Windows.Forms/OSXStructs.cs
+System.Windows.Forms/OwnerDrawPropertyBag.cs
+System.Windows.Forms/Padding.cs
+System.Windows.Forms/PageSetupDialog.cs
+System.Windows.Forms/PaintEventArgs.cs
+System.Windows.Forms/PaintEventHandler.cs
+System.Windows.Forms/Panel.cs
+System.Windows.Forms/PictureBox.cs
+System.Windows.Forms/PictureBoxSizeMode.cs
+System.Windows.Forms/PrintControllerWithStatusDialog.cs
+System.Windows.Forms/PrintDialog.cs
+System.Windows.Forms/PrintPreviewControl.cs
+System.Windows.Forms/PrintPreviewDialog.cs
+System.Windows.Forms/ProgressBar.cs
+System.Windows.Forms/ProgressBarStyle.cs
+System.Windows.Forms/PropertiesTab.cs
+System.Windows.Forms/PropertyGrid.cs
+System.Windows.Forms/PropertyGridCommands.cs
+System.Windows.Forms/PropertyGridEntry.cs
+System.Windows.Forms/PropertyGridTextBox.cs
+System.Windows.Forms/PropertyGridView.cs
+System.Windows.Forms/PropertyManager.cs
+System.Windows.Forms/PropertySort.cs
+System.Windows.Forms/PropertyTabChangedEventArgs.cs
+System.Windows.Forms/PropertyTabChangedEventHandler.cs
+System.Windows.Forms/PropertyValueChangedEventArgs.cs
+System.Windows.Forms/PropertyValueChangedEventHandler.cs
+System.Windows.Forms/QueryAccessibilityHelpEventArgs.cs
+System.Windows.Forms/QueryAccessibilityHelpEventHandler.cs
+System.Windows.Forms/QueryContinueDragEventArgs.cs
+System.Windows.Forms/QueryContinueDragEventHandler.cs
+System.Windows.Forms/QuestionEventArgs.cs
+System.Windows.Forms/QuestionEventHandler.cs
+System.Windows.Forms/RadioButton.cs
+System.Windows.Forms/RichTextBox.cs
+System.Windows.Forms/RichTextBoxFinds.cs
+System.Windows.Forms/RichTextBoxScrollBars.cs
+System.Windows.Forms/RichTextBoxSelectionAttribute.cs
+System.Windows.Forms/RichTextBoxSelectionTypes.cs
+System.Windows.Forms/RichTextBoxStreamType.cs
+System.Windows.Forms/RichTextBoxWordPunctuations.cs
+System.Windows.Forms/RightToLeft.cs
+System.Windows.Forms/SaveFileDialog.cs
+System.Windows.Forms/Screen.cs
+System.Windows.Forms/ScrollableControl.cs
+System.Windows.Forms/ScrollBar.cs
+System.Windows.Forms/ScrollBars.cs
+System.Windows.Forms/ScrollButton.cs
+System.Windows.Forms/ScrollEventArgs.cs
+System.Windows.Forms/ScrollEventHandler.cs
+System.Windows.Forms/ScrollEventType.cs
+System.Windows.Forms/SecurityIDType.cs
+System.Windows.Forms/SelectedGridItemChangedEventArgs.cs
+System.Windows.Forms/SelectedGridItemChangedEventHandler.cs
+System.Windows.Forms/SelectionRange.cs
+System.Windows.Forms/SelectionRangeConverter.cs
+System.Windows.Forms/SelectionMode.cs
+System.Windows.Forms/SendKeys.cs
+System.Windows.Forms/Shortcut.cs
+System.Windows.Forms/SizeGrip.cs
+System.Windows.Forms/SizeGripStyle.cs
+System.Windows.Forms/SortOrder.cs
+System.Windows.Forms/Splitter.cs
+System.Windows.Forms/SplitterEventArgs.cs
+System.Windows.Forms/SplitterEventHandler.cs
+System.Windows.Forms/StatusBar.cs
+System.Windows.Forms/StatusBarDrawItemEventArgs.cs
+System.Windows.Forms/StatusBarDrawItemEventHandler.cs
+System.Windows.Forms/StatusBarPanelAutoSize.cs
+System.Windows.Forms/StatusBarPanelBorderStyle.cs
+System.Windows.Forms/StatusBarPanelClickEventArgs.cs
+System.Windows.Forms/StatusBarPanelClickEventHandler.cs
+System.Windows.Forms/StatusBarPanel.cs
+System.Windows.Forms/StatusBarPanelStyle.cs
+System.Windows.Forms/StructFormat.cs
+System.Windows.Forms/SystemInformation.cs
+System.Windows.Forms/TabAlignment.cs
+System.Windows.Forms/TabAppearance.cs
+System.Windows.Forms/TabControl.cs
+System.Windows.Forms/TabDrawMode.cs
+System.Windows.Forms/TabPage.cs
+System.Windows.Forms/TabSizeMode.cs
+System.Windows.Forms/TextBox.cs
+System.Windows.Forms/TextBoxBase.cs
+System.Windows.Forms/TextControl.cs
+System.Windows.Forms/TextFormatFlags.cs
+System.Windows.Forms/Theme.cs
+System.Windows.Forms/ThemeClearlooks.cs
+System.Windows.Forms/ThemeEngine.cs
+System.Windows.Forms/ThemeGtk.cs
+System.Windows.Forms/ThemeNice.cs
+System.Windows.Forms/ThemeWin32Classic.cs
+System.Windows.Forms/ThreadExceptionDialog.cs
+System.Windows.Forms/TickStyle.cs
+System.Windows.Forms/Timer.cs
+../../build/common/MonoTODOAttribute.cs
+System.Windows.Forms/ToolBarAppearance.cs
+System.Windows.Forms/ToolBarButtonClickEventArgs.cs
+System.Windows.Forms/ToolBarButtonClickEventHandler.cs
+System.Windows.Forms/ToolBarButton.cs
+System.Windows.Forms/ToolBarButtonStyle.cs
+System.Windows.Forms/ToolBar.cs
+System.Windows.Forms/ToolBarTextAlign.cs
+System.Windows.Forms/ToolTip.cs
+System.Windows.Forms/TrackBar.cs
+System.Windows.Forms/TreeNode.cs
+System.Windows.Forms/TreeNodeCollection.cs
+System.Windows.Forms/TreeNodeConverter.cs
+System.Windows.Forms/TreeView.cs
+System.Windows.Forms/TreeViewAction.cs
+System.Windows.Forms/TreeViewCancelEventArgs.cs
+System.Windows.Forms/TreeViewCancelEventHandler.cs
+System.Windows.Forms/TreeViewEventArgs.cs
+System.Windows.Forms/TreeViewEventHandler.cs
+System.Windows.Forms/TreeViewImageIndexConverter.cs
+System.Windows.Forms/UICues.cs
+System.Windows.Forms/UICuesEventArgs.cs
+System.Windows.Forms/UICuesEventHandler.cs
+System.Windows.Forms/UpDownBase.cs
+System.Windows.Forms/UpDownEventArgs.cs
+System.Windows.Forms/UpDownEventHandler.cs
+System.Windows.Forms/UserControl.cs
+System.Windows.Forms/View.cs
+System.Windows.Forms/VScrollBar.cs
+System.Windows.Forms/Win32DnD.cs
+System.Windows.Forms/X11DesktopColors.cs
+System.Windows.Forms/X11Dnd.cs
+System.Windows.Forms/X11Structs.cs
+System.Windows.Forms/X11Keyboard.cs
+System.Windows.Forms/XEventQueue.cs
+System.Windows.Forms/XplatUI.cs
+System.Windows.Forms/XplatUIDriver.cs
+System.Windows.Forms/XplatUIOSX.cs
+System.Windows.Forms/XplatUIStructs.cs
+System.Windows.Forms/XplatUIWin32.cs
+System.Windows.Forms/XplatUIX11.cs
+System.Windows.Forms.RTF/Charcode.cs
+System.Windows.Forms.RTF/Charset.cs
+System.Windows.Forms.RTF/CharsetFlags.cs
+System.Windows.Forms.RTF/CharsetType.cs
+System.Windows.Forms.RTF/ClassDelegate.cs
+System.Windows.Forms.RTF/Color.cs
+System.Windows.Forms.RTF/DestinationDelegate.cs
+System.Windows.Forms.RTF/Font.cs
+System.Windows.Forms.RTF/KeysInit.cs
+System.Windows.Forms.RTF/KeyStruct.cs
+System.Windows.Forms.RTF/Major.cs
+System.Windows.Forms.RTF/Minor.cs
+System.Windows.Forms.RTF/RTF.cs
+System.Windows.Forms.RTF/RTFException.cs
+System.Windows.Forms.RTF/StandardCharCode.cs
+System.Windows.Forms.RTF/StandardCharName.cs
+System.Windows.Forms.RTF/Style.cs
+System.Windows.Forms.RTF/StyleElement.cs
+System.Windows.Forms.RTF/StyleType.cs
+System.Windows.Forms.RTF/TextMap.cs
+System.Windows.Forms.RTF/TokenClass.cs
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleEvents.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleEvents.cs
new file mode 100644
index 00000000000..0252cf27473
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleEvents.cs
@@ -0,0 +1,74 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum AccessibleEvents {
+ SystemSound = 1,
+ SystemAlert = 2,
+ SystemForeground = 3,
+ SystemMenuStart = 4,
+ SystemMenuEnd = 5,
+ SystemMenuPopupStart = 6,
+ SystemMenuPopupEnd = 7,
+ SystemCaptureStart = 8,
+ SystemCaptureEnd = 9,
+ SystemMoveSizeStart = 10,
+ SystemMoveSizeEnd = 11,
+ SystemContextHelpStart = 12,
+ SystemContextHelpEnd = 13,
+ SystemDragDropStart = 14,
+ SystemDragDropEnd = 15,
+ SystemDialogStart = 16,
+ SystemDialogEnd = 17,
+ SystemScrollingStart = 18,
+ SystemScrollingEnd = 19,
+ SystemSwitchStart = 20,
+ SystemSwitchEnd = 21,
+ SystemMinimizeStart = 22,
+ SystemMinimizeEnd = 23,
+ Create = 32768,
+ Destroy = 32769,
+ Show = 32770,
+ Hide = 32771,
+ Reorder = 32772,
+ Focus = 32773,
+ Selection = 32774,
+ SelectionAdd = 32775,
+ SelectionRemove = 32776,
+ SelectionWithin = 32777,
+ StateChange = 32778,
+ LocationChange = 32779,
+ NameChange = 32780,
+ DescriptionChange = 32781,
+ ValueChange = 32782,
+ ParentChange = 32783,
+ HelpChange = 32784,
+ DefaultActionChange = 32785,
+ AcceleratorChange = 32786
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleNavigation.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleNavigation.cs
new file mode 100644
index 00000000000..f91faadb3a0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleNavigation.cs
@@ -0,0 +1,39 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum AccessibleNavigation {
+ Up = 1,
+ Down = 2,
+ Left = 3,
+ Right = 4,
+ Next = 5,
+ Previous = 6,
+ FirstChild = 7,
+ LastChild = 8
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleObject.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleObject.cs
new file mode 100644
index 00000000000..043e23c5078
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleObject.cs
@@ -0,0 +1,570 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// NOT COMPLETE
+
+using Accessibility;
+using System.Drawing;
+using System.Globalization;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public class AccessibleObject : MarshalByRefObject, IReflect, IAccessible {
+ #region Private Variables
+ internal string name;
+ internal string value;
+ internal Control owner;
+ internal AccessibleRole role;
+ internal string default_action;
+ internal string description;
+ internal string help;
+ internal string keyboard_shortcut;
+ #endregion // Private Variables
+
+ #region Public Constructors
+ public AccessibleObject() {
+ this.owner=null;
+ this.value=null;
+ this.name=null;
+ this.role=AccessibleRole.Default;
+ this.default_action=null;
+ this.description=null;
+ this.help=null;
+ this.keyboard_shortcut=null;
+ }
+ #endregion // Public Constructors
+
+ #region Private Constructors
+ internal AccessibleObject(Control owner) : this () {
+ this.owner=owner;
+ }
+ #endregion // Private Constructors
+
+ #region Public Instance Properties
+ public virtual Rectangle Bounds {
+ get {
+ return owner.Bounds;
+ }
+ }
+
+ public virtual string DefaultAction {
+ get {
+ return default_action;
+ }
+ }
+
+ public virtual string Description {
+ get {
+ return description;
+ }
+ }
+
+ public virtual string Help {
+ get {
+ return help;
+ }
+ }
+
+ public virtual string KeyboardShortcut {
+ get {
+ return keyboard_shortcut;
+ }
+ }
+
+ public virtual string Name {
+ get {
+ return name;
+ }
+
+ set {
+ name=value;
+ }
+ }
+
+ public virtual AccessibleObject Parent {
+ get {
+ if ((owner!=null) && (owner.Parent!=null)) {
+ return owner.Parent.AccessibilityObject;
+ }
+ return null;
+ }
+ }
+
+ public virtual AccessibleRole Role {
+ get {
+ return role;
+ }
+ }
+
+ public virtual AccessibleStates State {
+ get {
+ AccessibleStates state=AccessibleStates.None;
+
+ if (owner!=null) {
+ if (owner.Focused) {
+ state |= AccessibleStates.Focused;
+ }
+
+ if (!owner.Visible) {
+ state |= AccessibleStates.Invisible;
+ }
+ }
+ return state;
+ }
+ }
+
+ public virtual string Value {
+ get {
+ return this.value;
+ }
+
+ set {
+ this.value=value;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public virtual void DoDefaultAction() {
+ if (owner!=null) {
+ owner.DoDefaultAction();
+ }
+ }
+
+ public virtual AccessibleObject GetChild(int index) {
+ if (owner!=null) {
+ if (index<owner.child_controls.Count) {
+ return owner.child_controls[index].AccessibilityObject;
+ }
+ }
+ return null;
+ }
+
+ public virtual int GetChildCount() {
+ if (owner!=null) {
+ return owner.child_controls.Count;
+ }
+ return -1;
+ }
+
+ public virtual AccessibleObject GetFocused() {
+ Control result;
+
+ if (owner.has_focus) {
+ return owner.AccessibilityObject;
+ }
+
+ result = FindFocusControl(owner);
+
+ if (result != null) {
+ return result.AccessibilityObject;
+ }
+
+ return null;
+ }
+
+ public virtual int GetHelpTopic(out string FileName) {
+
+ FileName = null;
+
+ return -1;
+ }
+
+ public virtual AccessibleObject GetSelected() {
+ Control result;
+
+ if (owner.is_selected) {
+ return owner.AccessibilityObject;
+ }
+
+ result = FindSelectedControl(owner);
+
+ if (result != null) {
+ return result.AccessibilityObject;
+ }
+
+ return null;
+ }
+
+ public virtual AccessibleObject HitTest(int x, int y) {
+ Control result;
+
+ result = FindHittestControl(owner, x, y);
+
+ if (result != null) {
+ return result.AccessibilityObject;
+ }
+
+ return null;
+ }
+
+ public virtual AccessibleObject Navigate(AccessibleNavigation navdir) {
+ int index;
+
+ // I'm not throwing exceptions if an object doesn't exist in the specified direction
+ // Might not be too helpful to a blind dude trying to navigate. Instead we return
+ // our own object
+
+ if (owner.parent != null) {
+ index = owner.parent.child_controls.IndexOf(owner);
+ } else {
+ index = -1;
+ }
+
+ switch (navdir) {
+ // Spatial navigation; limited to siblings
+ case AccessibleNavigation.Up: {
+ if (owner.parent != null) {
+ for (int i=0; i<owner.parent.child_controls.Count; i++) {
+ if ((owner != owner.parent.child_controls[i]) && (owner.parent.child_controls[i].Top<owner.Top)) {
+ return owner.parent.child_controls[i].AccessibilityObject;
+ }
+ }
+
+ }
+ return owner.AccessibilityObject;
+ }
+
+ case AccessibleNavigation.Down: {
+ if (owner.parent != null) {
+ for (int i=0; i<owner.parent.child_controls.Count; i++) {
+ if ((owner != owner.parent.child_controls[i]) && (owner.parent.child_controls[i].Top>owner.Bottom)) {
+ return owner.parent.child_controls[i].AccessibilityObject;
+ }
+ }
+
+ }
+ return owner.AccessibilityObject;
+ }
+
+ case AccessibleNavigation.Left: {
+ if (owner.parent != null) {
+ for (int i=0; i<owner.parent.child_controls.Count; i++) {
+ if ((owner != owner.parent.child_controls[i]) && (owner.parent.child_controls[i].Left<owner.Left)) {
+ return owner.parent.child_controls[i].AccessibilityObject;
+ }
+ }
+
+ }
+ return owner.AccessibilityObject;
+ }
+
+ case AccessibleNavigation.Right: {
+ if (owner.parent != null) {
+ for (int i=0; i<owner.parent.child_controls.Count; i++) {
+ if ((owner != owner.parent.child_controls[i]) && (owner.parent.child_controls[i].Left>owner.Right)) {
+ return owner.parent.child_controls[i].AccessibilityObject;
+ }
+ }
+
+ }
+ return owner.AccessibilityObject;
+ }
+
+ // Logical navigation
+ case AccessibleNavigation.Next: {
+ if (owner.parent != null) {
+ if ((index+1)<owner.parent.child_controls.Count) {
+ return owner.parent.child_controls[index+1].AccessibilityObject;
+ } else {
+ return owner.parent.child_controls[0].AccessibilityObject;
+ }
+ } else {
+ return owner.AccessibilityObject;
+ }
+ }
+
+ case AccessibleNavigation.Previous: {
+ if (owner.parent != null) {
+ if (index>0) {
+ return owner.parent.child_controls[index-1].AccessibilityObject;
+ } else {
+ return owner.parent.child_controls[owner.parent.child_controls.Count-1].AccessibilityObject;
+ }
+ } else {
+ return owner.AccessibilityObject;
+ }
+ }
+
+ case AccessibleNavigation.FirstChild: {
+ if (owner.child_controls.Count>0) {
+ return owner.child_controls[0].AccessibilityObject;
+ } else {
+ return owner.AccessibilityObject;
+ }
+ }
+
+ case AccessibleNavigation.LastChild: {
+ if (owner.child_controls.Count>0) {
+ return owner.child_controls[owner.child_controls.Count-1].AccessibilityObject;
+ } else {
+ return owner.AccessibilityObject;
+ }
+ }
+ }
+
+ return owner.AccessibilityObject;
+ }
+
+ public virtual void Select(AccessibleSelection flags) {
+ if ((flags & AccessibleSelection.TakeFocus) != 0){
+ owner.Select(owner);
+ }
+ return;
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected void UseStdAccessibleObjects(IntPtr handle) {
+ }
+
+ protected void UseStdAccessibleObjects(IntPtr handle, int objid) {
+ UseStdAccessibleObjects(handle, 0);
+ }
+ #endregion // Protected Instance Methods
+
+
+ #region Internal Methods
+ internal static Control FindFocusControl(Control parent) {
+ Control child;
+
+ for (int i=0; i < parent.child_controls.Count; i++) {
+ child=parent.child_controls[i];
+ if (child.has_focus) {
+ return child;
+ }
+ if (child.child_controls.Count>0) {
+ Control result;
+
+ result = FindFocusControl(child);
+ if (result != null) {
+ return result;
+ }
+ }
+ }
+ return null;
+ }
+
+ internal static Control FindSelectedControl(Control parent) {
+ Control child;
+
+ for (int i=0; i < parent.child_controls.Count; i++) {
+ child=parent.child_controls[i];
+ if (child.has_focus) {
+ return child;
+ }
+ if (child.child_controls.Count>0) {
+ Control result;
+
+ result = FindSelectedControl(child);
+ if (result != null) {
+ return result;
+ }
+ }
+ }
+ return null;
+ }
+
+ internal static Control FindHittestControl(Control parent, int x, int y) {
+ Control child;
+ Point child_point;
+ Point hittest_point;
+
+ hittest_point = new Point(x, y);
+
+ child_point = parent.PointToClient(hittest_point);
+ if (parent.ClientRectangle.Contains(child_point)) {
+ return parent;
+ }
+
+ for (int i=0; i < parent.child_controls.Count; i++) {
+ child=parent.child_controls[i];
+ child_point = child.PointToClient(hittest_point);
+ if (child.ClientRectangle.Contains(child_point)) {
+ return child;
+ }
+ if (child.child_controls.Count>0) {
+ Control result;
+
+ result = FindHittestControl(child, x, y);
+ if (result != null) {
+ return result;
+ }
+ }
+ }
+ return null;
+ }
+ #endregion // Internal Methods
+
+ #region IReflection Methods and Properties
+ FieldInfo IReflect.GetField(String name, BindingFlags bindingAttr) {
+ throw new NotImplementedException();
+ }
+
+ FieldInfo[] IReflect.GetFields(BindingFlags bindingAttr) {
+ throw new NotImplementedException();
+ }
+
+ MemberInfo[] IReflect.GetMember(String name, BindingFlags bindingAttr) {
+ throw new NotImplementedException();
+ }
+
+ MemberInfo[] IReflect.GetMembers(BindingFlags bindingAttr) {
+ throw new NotImplementedException();
+ }
+
+ MethodInfo IReflect.GetMethod(String name, BindingFlags bindingAttr) {
+ throw new NotImplementedException();
+ }
+
+ MethodInfo IReflect.GetMethod(String name, BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers) {
+ throw new NotImplementedException();
+ }
+
+ MethodInfo[] IReflect.GetMethods(BindingFlags bindingAttr) {
+ throw new NotImplementedException();
+ }
+
+ PropertyInfo IReflect.GetProperty(String name, BindingFlags bindingAttr) {
+ throw new NotImplementedException();
+ }
+
+ PropertyInfo IReflect.GetProperty(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) {
+ throw new NotImplementedException();
+ }
+
+ PropertyInfo[] IReflect.GetProperties(BindingFlags bindingAttr) {
+ throw new NotImplementedException();
+ }
+
+ Object IReflect.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) {
+ throw new NotImplementedException();
+ }
+
+ Type IReflect.UnderlyingSystemType {
+ get {
+ throw new NotImplementedException();
+ }
+ }
+ #endregion // IReflection Methods and Properties
+
+ #region IAccessible Methods and Properties
+ void IAccessible.accDoDefaultAction(object childID) {
+ throw new NotImplementedException();
+ }
+
+ int IAccessible.accChildCount {
+ get {
+ throw new NotImplementedException();
+ }
+ }
+
+ object IAccessible.accFocus {
+ get {
+ throw new NotImplementedException();
+ }
+ }
+
+ object IAccessible.accHitTest(int xLeft, int yTop) {
+ throw new NotImplementedException();
+ }
+
+ void IAccessible.accLocation(out int pxLeft, out int pyTop, out int pcxWidth, out int pcyHeight, object childID) {
+ throw new NotImplementedException();
+ }
+
+ object IAccessible.accNavigate(int navDir, object childID) {
+ throw new NotImplementedException();
+ }
+
+ object IAccessible.accParent {
+ get {
+ throw new NotImplementedException();
+ }
+ }
+
+ void IAccessible.accSelect(int flagsSelect, object childID) {
+ throw new NotImplementedException();
+ }
+
+ object IAccessible.accSelection {
+ get {
+ throw new NotImplementedException();
+ }
+ }
+
+ object IAccessible.get_accChild(object childID) {
+ throw new NotImplementedException();
+ }
+
+ string IAccessible.get_accDefaultAction(object childID) {
+ throw new NotImplementedException();
+ }
+
+ string IAccessible.get_accDescription(object childID) {
+ throw new NotImplementedException();
+ }
+
+ string IAccessible.get_accHelp(object childID) {
+ throw new NotImplementedException();
+ }
+
+ int IAccessible.get_accHelpTopic(out string pszHelpFile,object childID) {
+ throw new NotImplementedException();
+ }
+
+ string IAccessible.get_accKeyboardShortcut(object childID) {
+ throw new NotImplementedException();
+ }
+
+ string IAccessible.get_accName(object childID) {
+ throw new NotImplementedException();
+ }
+
+ object IAccessible.get_accRole(object childID) {
+ throw new NotImplementedException();
+ }
+
+ object IAccessible.get_accState(object childID) {
+ throw new NotImplementedException();
+ }
+
+ string IAccessible.get_accValue(object childID) {
+ throw new NotImplementedException();
+ }
+
+ void IAccessible.set_accName(object childID, string newName) {
+ throw new NotImplementedException();
+ }
+
+ void IAccessible.set_accValue(object childID, string newValue) {
+ throw new NotImplementedException();
+ }
+ #endregion // IAccessible Methods and Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleRole.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleRole.cs
new file mode 100644
index 00000000000..1e512e29f7e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleRole.cs
@@ -0,0 +1,95 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum AccessibleRole {
+ None = 0,
+ TitleBar = 1,
+ MenuBar = 2,
+ ScrollBar = 3,
+ Grip = 4,
+ Sound = 5,
+ Cursor = 6,
+ Caret = 7,
+ Alert = 8,
+ Window = 9,
+ Client = 10,
+ MenuPopup = 11,
+ MenuItem = 12,
+ ToolTip = 13,
+ Application = 14,
+ Document = 15,
+ Pane = 16,
+ Chart = 17,
+ Dialog = 18,
+ Border = 19,
+ Grouping = 20,
+ Separator = 21,
+ ToolBar = 22,
+ StatusBar = 23,
+ Table = 24,
+ ColumnHeader = 25,
+ RowHeader = 26,
+ Column = 27,
+ Row = 28,
+ Cell = 29,
+ Link = 30,
+ HelpBalloon = 31,
+ Character = 32,
+ List = 33,
+ ListItem = 34,
+ Outline = 35,
+ OutlineItem = 36,
+ PageTab = 37,
+ PropertyPage = 38,
+ Indicator = 39,
+ Graphic = 40,
+ StaticText = 41,
+ Text = 42,
+ PushButton = 43,
+ CheckButton = 44,
+ RadioButton = 45,
+ ComboBox = 46,
+ DropList = 47,
+ ProgressBar = 48,
+ Dial = 49,
+ HotkeyField = 50,
+ Slider = 51,
+ SpinButton = 52,
+ Diagram = 53,
+ Animation = 54,
+ Equation = 55,
+ ButtonDropDown = 56,
+ ButtonMenu = 57,
+ ButtonDropDownGrid= 58,
+ WhiteSpace = 59,
+ PageTabList = 60,
+ Clock = 61,
+ Default = -1
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleSelection.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleSelection.cs
new file mode 100644
index 00000000000..fd7ea3be8e2
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleSelection.cs
@@ -0,0 +1,39 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ [Flags]
+ public enum AccessibleSelection {
+ None = 0x00000000,
+ TakeFocus = 0x00000001,
+ TakeSelection = 0x00000002,
+ ExtendSelection = 0x00000004,
+ AddSelection = 0x00000008,
+ RemoveSelection = 0x00000010
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleStates.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleStates.cs
new file mode 100644
index 00000000000..3daaa48333c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AccessibleStates.cs
@@ -0,0 +1,67 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+
+ [Flags]
+ public enum AccessibleStates {
+ None = 0x00000000,
+ Unavailable = 0x00000001,
+ Selected = 0x00000002,
+ Focused = 0x00000004,
+ Pressed = 0x00000008,
+ Checked = 0x00000010,
+ Mixed = 0x00000020,
+ Indeterminate = 0x00000020,
+ ReadOnly = 0x00000040,
+ HotTracked = 0x00000080,
+ Default = 0x00000100,
+ Expanded = 0x00000200,
+ Collapsed = 0x00000400,
+ Busy = 0x00000800,
+ Floating = 0x00001000,
+ Marqueed = 0x00002000,
+ Animated = 0x00004000,
+ Invisible = 0x00008000,
+ Offscreen = 0x00010000,
+ Sizeable = 0x00020000,
+ Moveable = 0x00040000,
+ SelfVoicing = 0x00080000,
+ Focusable = 0x00100000,
+ Selectable = 0x00200000,
+ Linked = 0x00400000,
+ Traversed = 0x00800000,
+ MultiSelectable = 0x01000000,
+ ExtSelectable = 0x02000000,
+ AlertLow = 0x04000000,
+ AlertMedium = 0x08000000,
+ AlertHigh = 0x10000000,
+ Protected = 0x20000000,
+ Valid = 0x3FFFFFFF
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AmbientProperties.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AmbientProperties.cs
new file mode 100644
index 00000000000..e9004f19627
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AmbientProperties.cs
@@ -0,0 +1,87 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+using System.Drawing;
+
+namespace System.Windows.Forms {
+ public sealed class AmbientProperties {
+ #region Local Variables
+ private Color fore_color;
+ private Color back_color;
+ private Font font;
+ private Cursor cursor;
+ #endregion // Local Variables
+
+ #region Public Constructors
+ public AmbientProperties() {
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public Color BackColor {
+ get {
+ return back_color;
+ }
+
+ set {
+ back_color = value;
+ }
+ }
+
+ public Cursor Cursor {
+ get {
+ return cursor;
+ }
+
+ set {
+ cursor = value;
+ }
+ }
+
+ public Font Font {
+ get {
+ return font;
+ }
+
+ set {
+ font = value;
+ }
+ }
+
+ public Color ForeColor {
+ get {
+ return fore_color;
+ }
+
+ set {
+ fore_color = value;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AnchorStyles.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AnchorStyles.cs
new file mode 100644
index 00000000000..23355ab3786
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AnchorStyles.cs
@@ -0,0 +1,42 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+ [Flags]
+ [Serializable]
+ [Editor("System.Windows.Forms.Design.AnchorEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
+ public enum AnchorStyles {
+ None = 0x00000000,
+ Top = 0x00000001,
+ Bottom = 0x00000002,
+ Left = 0x00000004,
+ Right = 0x00000008
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Appearance.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Appearance.cs
new file mode 100644
index 00000000000..02becb9b297
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Appearance.cs
@@ -0,0 +1,37 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public enum Appearance {
+ Normal = 0,
+ Button = 1
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs
new file mode 100644
index 00000000000..e8e65f01649
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs
@@ -0,0 +1,475 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 - 2006 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+// COMPLETE
+
+#undef DebugRunLoop
+
+using Microsoft.Win32;
+using System;
+using System.Drawing;
+using System.ComponentModel;
+using System.Collections;
+using System.Diagnostics;
+using System.Globalization;
+using System.IO;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Threading;
+
+namespace System.Windows.Forms {
+ public sealed class Application {
+ private static bool browser_embedded = false;
+ private static InputLanguage input_language = InputLanguage.CurrentInputLanguage;
+ private static bool messageloop_started = false;
+ private static string safe_caption_format = "{1} - {0} - {2}";
+ private static ArrayList message_filters = new ArrayList();
+
+ private Application () {
+ }
+
+ #region Private Methods
+ private static void CloseForms(Thread thread) {
+ Control c;
+ IEnumerator control;
+ bool all;
+
+ #if DebugRunLoop
+ Console.WriteLine(" CloseForms({0}) called", thread);
+ #endif
+ if (thread == null) {
+ all = true;
+ } else {
+ all = false;
+ }
+
+ control = Control.controls.GetEnumerator();
+
+ while (control.MoveNext()) {
+ c = (Control)control.Current;
+ if (c is Form) {
+ if (all || (thread == c.creator_thread)) {
+ if (c.IsHandleCreated) {
+ XplatUI.PostMessage(c.Handle, Msg.WM_CLOSE_INTERNAL, IntPtr.Zero, IntPtr.Zero);
+ }
+ #if DebugRunLoop
+ Console.WriteLine(" Closing form {0}", c);
+ #endif
+ }
+ }
+ }
+
+ }
+ #endregion // Private methods
+
+ #region Public Static Properties
+ public static bool AllowQuit {
+ get {
+ return browser_embedded;
+ }
+ }
+
+ public static string CommonAppDataPath {
+ get {
+ return Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
+ }
+ }
+
+ public static RegistryKey CommonAppDataRegistry {
+ get {
+ RegistryKey key;
+
+ key = Registry.LocalMachine.OpenSubKey("Software\\" + Application.CompanyName + "\\" + Application.ProductName + "\\" + Application.ProductVersion, true);
+
+ return key;
+ }
+ }
+
+ public static string CompanyName {
+ get {
+ AssemblyCompanyAttribute[] attrs = (AssemblyCompanyAttribute[]) Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), true);
+
+ if ((attrs != null) && attrs.Length>0) {
+ return attrs[0].Company;
+ }
+
+ return Assembly.GetEntryAssembly().GetName().Name;
+ }
+ }
+
+ public static CultureInfo CurrentCulture {
+ get {
+ return Thread.CurrentThread.CurrentUICulture;
+ }
+
+ set {
+
+ Thread.CurrentThread.CurrentUICulture=value;
+ }
+ }
+
+ public static InputLanguage CurrentInputLanguage {
+ get {
+ return input_language;
+ }
+
+ set {
+ input_language=value;
+ }
+ }
+
+ public static string ExecutablePath {
+ get {
+ return Assembly.GetEntryAssembly().Location;
+ }
+ }
+
+ public static string LocalUserAppDataPath {
+ get {
+ return Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), CompanyName), ProductName), ProductVersion);
+ }
+ }
+
+ public static bool MessageLoop {
+ get {
+ return messageloop_started;
+ }
+ }
+
+ public static string ProductName {
+ get {
+ AssemblyProductAttribute[] attrs = (AssemblyProductAttribute[]) Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), true);
+
+ if ((attrs != null) && attrs.Length>0) {
+ return attrs[0].Product;
+ }
+
+ return Assembly.GetEntryAssembly().GetName().Name;
+ }
+ }
+
+ public static string ProductVersion {
+ get {
+ String version;
+
+ version = Assembly.GetEntryAssembly().GetName().Version.ToString();
+
+ if (version.StartsWith("0.")) {
+ version="1." + version.Substring(2);
+ }
+ return version;
+ }
+ }
+
+ public static string SafeTopLevelCaptionFormat {
+ get {
+ return safe_caption_format;
+ }
+
+ set {
+ safe_caption_format=value;
+ }
+ }
+
+ public static string StartupPath {
+ get {
+ return Path.GetDirectoryName(Application.ExecutablePath);
+ }
+ }
+
+ public static string UserAppDataPath {
+ get {
+ return Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), CompanyName), ProductName), ProductVersion);
+ }
+ }
+
+ public static RegistryKey UserAppDataRegistry {
+ get {
+ RegistryKey key;
+
+ key = Registry.CurrentUser.OpenSubKey("Software\\" + Application.CompanyName + "\\" + Application.ProductName + "\\" + Application.ProductVersion, true);
+
+ return key;
+ }
+ }
+ #endregion
+
+ #region Public Static Methods
+ public static void AddMessageFilter(IMessageFilter value) {
+ message_filters.Add(value);
+ }
+
+ public static void DoEvents() {
+ XplatUI.DoEvents();
+ }
+
+ public static void EnableVisualStyles() {
+ XplatUI.EnableThemes();
+ }
+
+#if NET_2_0
+ public static void EnableRTLMirroring ()
+ {
+ }
+
+ //
+ // If true, it uses GDI+, performance reasons were quoted
+ //
+ static internal bool use_compatible_text_rendering = true;
+
+ public static void SetCompatibleTextRenderingDefault (bool defaultValue)
+ {
+ use_compatible_text_rendering = defaultValue;
+ }
+#endif
+
+ public static void Exit() {
+ CloseForms(null);
+
+ // FIXME - this needs to be fired when they're all closed
+ // But CloseForms uses PostMessage, so it gets fired before
+ // We need to wait on something...
+ if (ApplicationExit != null) {
+ ApplicationExit(null, EventArgs.Empty);
+ }
+ }
+
+ public static void ExitThread() {
+ CloseForms(Thread.CurrentThread);
+ }
+
+ public static ApartmentState OleRequired() {
+ //throw new NotImplementedException("OLE Not supported by this System.Windows.Forms implementation");
+ return ApartmentState.Unknown;
+ }
+
+ public static void OnThreadException(Exception t) {
+ if (Application.ThreadException != null) {
+ Application.ThreadException(null, new ThreadExceptionEventArgs(t));
+ return;
+ }
+
+ if (SystemInformation.UserInteractive) {
+ Form form = new ThreadExceptionDialog (t);
+ form.ShowDialog ();
+ } else {
+ Console.WriteLine (t.ToString ());
+ }
+ }
+
+ public static void RemoveMessageFilter(IMessageFilter filter) {
+ message_filters.Remove(filter);
+ }
+
+ public static void Run() {
+ RunLoop(false, new ApplicationContext());
+ }
+
+ public static void Run(Form mainForm) {
+ RunLoop(false, new ApplicationContext(mainForm));
+ }
+
+ public static void Run(ApplicationContext context) {
+ RunLoop(false, context);
+ }
+
+ internal static void RunLoop(bool Modal, ApplicationContext context) {
+ Queue toplevels;
+ IEnumerator control;
+ MSG msg;
+
+ msg = new MSG();
+
+ if (context == null) {
+ context = new ApplicationContext();
+ }
+
+ if (context.MainForm != null) {
+ context.MainForm.Show();
+ // FIXME - do we need this?
+ //context.MainForm.PerformLayout();
+ context.MainForm.context = context;
+ context.MainForm.Activate();
+ context.MainForm.closing = false;
+ }
+
+ #if DebugRunLoop
+ Console.WriteLine("Entering RunLoop(Modal={0}, Form={1})", Modal, context.MainForm != null ? context.MainForm.ToString() : "NULL");
+ #endif
+
+ if (Modal) {
+ Control c;
+
+ if (context.MainForm.Modal) {
+ throw new Exception("fixme");
+ }
+ context.MainForm.is_modal = true;
+
+ toplevels = new Queue();
+ control = Control.controls.GetEnumerator();
+
+ while (control.MoveNext()) {
+
+ c = (Control)control.Current;
+ if (c is Form && (c != context.MainForm)) {
+ if (c.IsHandleCreated && XplatUI.IsEnabled(c.Handle)) {
+ #if DebugRunLoop
+ Console.WriteLine(" Disabling form {0}", c);
+ #endif
+ XplatUI.EnableWindow(c.Handle, false);
+ toplevels.Enqueue(c);
+ }
+ }
+ }
+ // FIXME - need activate?
+
+ XplatUI.SetModal(context.MainForm.Handle, true);
+ } else {
+ toplevels = null;
+ }
+
+ XplatUI.StartLoop(Thread.CurrentThread);
+ messageloop_started = true;
+
+ while (XplatUI.GetMessage(ref msg, IntPtr.Zero, 0, 0)) {
+ if ((message_filters != null) && (message_filters.Count > 0)) {
+ Message m;
+ bool drop;
+
+ drop = false;
+ m = Message.Create(msg.hwnd, (int)msg.message, msg.wParam, msg.lParam);
+ for (int i = 0; i < message_filters.Count; i++) {
+ if (((IMessageFilter)message_filters[i]).PreFilterMessage(ref m)) {
+ // we're dropping the message
+ drop = true;
+ break;
+ }
+ }
+ if (drop) {
+ continue;
+ }
+ }
+
+ switch((Msg)msg.message) {
+ case Msg.WM_KEYDOWN:
+ case Msg.WM_SYSKEYDOWN:
+ case Msg.WM_CHAR:
+ case Msg.WM_SYSCHAR:
+ case Msg.WM_KEYUP:
+ case Msg.WM_SYSKEYUP: {
+ Message m;
+ Control c;
+
+ m = Message.Create(msg.hwnd, (int)msg.message, msg.wParam, msg.lParam);
+ c = Control.FromHandle(msg.hwnd);
+ if ((c != null) && !c.PreProcessMessage(ref m)) {
+ goto default;
+ }
+ break;
+ }
+ default: {
+ XplatUI.TranslateMessage(ref msg);
+ XplatUI.DispatchMessage(ref msg);
+ break;
+ }
+ }
+
+ // Handle exit, Form might have received WM_CLOSE and set 'closing' in response
+ if ((context.MainForm != null) && context.MainForm.closing) {
+ if (!Modal) {
+ XplatUI.PostQuitMessage(0);
+ } else {
+ break;
+ }
+ }
+ }
+ #if DebugRunLoop
+ Console.WriteLine(" RunLoop loop left");
+ #endif
+
+ messageloop_started = false;
+ XplatUI.EndLoop(Thread.CurrentThread);
+
+ if (Modal) {
+ Control c;
+
+ context.MainForm.Hide();
+ context.MainForm.is_modal = false;
+
+ while (toplevels.Count>0) {
+ #if DebugRunLoop
+ Console.WriteLine(" Re-Enabling form form {0}", toplevels.Peek());
+ #endif
+ c = (Control)toplevels.Dequeue();
+ if (c.IsHandleCreated) {
+ XplatUI.EnableWindow(c.window.Handle, true);
+ }
+ }
+ #if DebugRunLoop
+ Console.WriteLine(" Done with the re-enable");
+ #endif
+ if (context.MainForm.IsHandleCreated) {
+ XplatUI.SetModal(context.MainForm.Handle, false);
+ }
+ #if DebugRunLoop
+ Console.WriteLine(" Done with the SetModal");
+ #endif
+ }
+
+ #if DebugRunLoop
+ Console.WriteLine("Leaving RunLoop(Modal={0}, Form={1})", Modal, context.MainForm != null ? context.MainForm.ToString() : "NULL");
+ #endif
+ if (context.MainForm != null) {
+ context.MainForm.context = null;
+ }
+
+ if (!Modal) {
+ if (ThreadExit != null) {
+ ThreadExit(null, EventArgs.Empty);
+ }
+
+ context.ExitThread();
+ }
+ }
+
+ #endregion // Public Static Methods
+
+ #region Events
+ public static event EventHandler ApplicationExit;
+
+ public static event EventHandler Idle {
+ add {
+ XplatUI.Idle += value;
+ }
+ remove {
+ XplatUI.Idle -= value;
+ }
+ }
+
+ public static event EventHandler ThreadExit;
+ public static event ThreadExceptionEventHandler ThreadException;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ApplicationContext.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ApplicationContext.cs
new file mode 100644
index 00000000000..8e14ce3d0f0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ApplicationContext.cs
@@ -0,0 +1,92 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public class ApplicationContext {
+ #region Local Variables
+ Form main_form;
+ #endregion // Local Variables
+
+ #region Public Constructors & Destructors
+ public ApplicationContext() : this(null) {
+ }
+
+ public ApplicationContext(Form mainForm) {
+ main_form=mainForm;
+ }
+
+ ~ApplicationContext() {
+ this.Dispose(false);
+ }
+ #endregion // Public Constructors & Destructors
+
+ #region Public Instance Properties
+ public Form MainForm {
+ get {
+ return main_form;
+ }
+
+ set {
+ if (main_form!=value) {
+ main_form=value;
+ }
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public void Dispose() {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ public void ExitThread() {
+ ExitThreadCore();
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected virtual void Dispose(bool disposing) {
+ main_form=null;
+ }
+
+ protected virtual void ExitThreadCore() {
+ if (ThreadExit!=null) {
+ ThreadExit(this, EventArgs.Empty);
+ }
+ }
+
+ protected virtual void OnMainFormClosed(object sender, EventArgs e) {
+ ExitThreadCore();
+ }
+ #endregion // Public Instance Methods
+
+ #region Events
+ public event EventHandler ThreadExit;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ArrangeDirection.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ArrangeDirection.cs
new file mode 100644
index 00000000000..bc6e8190e02
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ArrangeDirection.cs
@@ -0,0 +1,39 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public enum ArrangeDirection {
+ Left = 0,
+ Right = 0,
+ Down = 4,
+ Up = 4
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ArrangeStartingPosition.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ArrangeStartingPosition.cs
new file mode 100644
index 00000000000..59584b8f016
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ArrangeStartingPosition.cs
@@ -0,0 +1,37 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum ArrangeStartingPosition {
+ BottomLeft = 0,
+ BottomRight = 1,
+ TopLeft = 2,
+ TopRight = 3,
+ Hide = 8
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AsyncMethodData.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AsyncMethodData.cs
new file mode 100644
index 00000000000..7a001cbc731
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AsyncMethodData.cs
@@ -0,0 +1,43 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+using System;
+using System.Threading;
+
+
+namespace System.Windows.Forms {
+
+ internal class AsyncMethodData {
+ public Delegate Method;
+ public object [] Args;
+ public AsyncMethodResult Result;
+#if NET_2_0
+ public ExecutionContext Context;
+#else
+ public CompressedStack Stack;
+#endif
+ }
+
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AsyncMethodResult.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AsyncMethodResult.cs
new file mode 100644
index 00000000000..8c52ca71dcc
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AsyncMethodResult.cs
@@ -0,0 +1,90 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+using System;
+using System.Threading;
+
+namespace System.Windows.Forms {
+
+ internal class AsyncMethodResult : IAsyncResult {
+
+ private ManualResetEvent handle;
+ private object state;
+ private bool completed;
+ private object return_value;
+
+ public AsyncMethodResult ()
+ {
+ handle = new ManualResetEvent (false);
+ }
+
+ public virtual WaitHandle AsyncWaitHandle {
+ get {
+ lock (this) {
+ return handle;
+ }
+ }
+ }
+
+ public object AsyncState {
+ get { return state; }
+ set { state = value; }
+ }
+
+ public bool CompletedSynchronously {
+ get { return false; }
+ }
+
+ public bool IsCompleted {
+ get {
+ lock (this) {
+ return completed;
+ }
+ }
+ }
+
+ public object EndInvoke ()
+ {
+ lock (this) {
+ if (completed)
+ return return_value;
+ }
+ handle.WaitOne ();
+ return return_value;
+ }
+
+ public void Complete (object result)
+ {
+ lock (this) {
+ completed = true;
+ return_value = result;
+ handle.Set ();
+ }
+ }
+ }
+
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AutoScaleMode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AutoScaleMode.cs
new file mode 100644
index 00000000000..0ceefc13273
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AutoScaleMode.cs
@@ -0,0 +1,38 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2006 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Peter Dennis Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+#if NET_2_0
+namespace System.Windows.Forms {
+ public enum AutoScaleMode {
+ None = 0,
+ Font = 1,
+ Dpi = 2,
+ Inherit = 3
+ }
+}
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AxHost.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AxHost.cs
new file mode 100644
index 00000000000..49d45437fed
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/AxHost.cs
@@ -0,0 +1,830 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok <pbartok@novell.com>
+//
+//
+
+// NOT COMPLETE
+
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.IO;
+using System.Runtime.InteropServices;
+using System.Runtime.Serialization;
+
+namespace System.Windows.Forms {
+ [MonoTODO("Possibly implement this for Win32; find a way for Linux and Mac")]
+ [DefaultEvent("Enter")]
+ [Designer("System.Windows.Forms.Design.AxHostDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ [DesignTimeVisible(false)]
+ [ToolboxItem(false)]
+ public abstract class AxHost : Control, ISupportInitialize, ICustomTypeDescriptor {
+ #region AxHost Subclasses
+ #region AxHost.ActiveXInvokeKind Enum
+ public enum ActiveXInvokeKind {
+ MethodInvoke = 0,
+ PropertyGet = 1,
+ PropertySet = 2
+ }
+ #endregion // AxHost.ActiveXInvokeKind Enum
+
+ #region AxHost.AxComponentEditor Class
+ public class AxComponentEditor : System.Windows.Forms.Design.WindowsFormsComponentEditor {
+ public AxComponentEditor() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ public override bool EditComponent(ITypeDescriptorContext context, object obj, IWin32Window parent) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+ #endregion // AxHost.AxComponentEditor Class
+
+ #region AxHost.ClsidAttribute
+ [AttributeUsage(AttributeTargets.Class,Inherited=false)]
+ public sealed class ClsidAttribute : Attribute {
+ string clsid;
+
+ public ClsidAttribute (string clsid) {
+ this.clsid = clsid;
+ }
+
+ public string Value {
+ get {
+ return clsid;
+ }
+ }
+ }
+ #endregion AxHost.ClsidAttribute
+
+ #region AxHost.ConnectionPointCookie
+ [ComVisible(false)]
+ public class ConnectionPointCookie {
+ public ConnectionPointCookie(object source, object sink, Type eventInterface) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ public void Disconnect() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ ~ConnectionPointCookie() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+ #endregion // AxHost.ConnectionPointCookie
+
+ #region AxHost.InvalidActiveXStateException Class
+ public class InvalidActiveXStateException : Exception {
+ public InvalidActiveXStateException(string name, ActiveXInvokeKind kind) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ public override string ToString() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+ #endregion // AxHost.InvalidActiveXStateException Class
+
+ #region AxHost.State Class
+ [Serializable]
+ [TypeConverter("System.ComponentModel.TypeConverter, " + Consts.AssemblySystem)]
+ public class State : ISerializable {
+ public State(Stream ms, int storageType, bool manualUpdate, string licKey) {
+ //throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ private State(SerializationInfo info, StreamingContext context) {
+ }
+
+ void ISerializable.GetObjectData(SerializationInfo si,StreamingContext context) {
+ //throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+ #endregion // AxHost.State Class
+
+ #region AxHost.TypeLibraryTimeStampAttribute Class
+ [AttributeUsage(AttributeTargets.Assembly, Inherited=false)]
+ public sealed class TypeLibraryTimeStampAttribute : Attribute {
+ public TypeLibraryTimeStampAttribute(string timestamp) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ public DateTime Value {
+ get {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+ }
+ #endregion // AxHost.TypeLibraryTimeStampAttribute Class
+
+ #region AxHost.StateConverter Class
+ public class StateConverter : System.ComponentModel.TypeConverter {
+ public StateConverter() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+ #endregion // AxHost.StateConverter Class
+ #endregion // AxHost Subclasses
+
+ string text;
+
+ #region Protected Constructors
+ protected AxHost(string clsid) {
+ text = "";
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ protected AxHost(string clsid, int flags) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Properties
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Color BackColor {
+ get {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ set {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Image BackgroundImage {
+ get {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ set {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public ContainerControl ContainingControl {
+ get {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ set {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override ContextMenu ContextMenu {
+ get {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ set {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Cursor Cursor {
+ get {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ set {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public bool EditMode {
+ get {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new virtual bool Enabled {
+ get {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ set {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Font Font {
+ get {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ set {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Color ForeColor {
+ get {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ set {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public bool HasAboutBox {
+ get {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+
+ [Browsable(false)]
+ [DefaultValue(null)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [RefreshProperties(RefreshProperties.All)]
+ public AxHost.State OcxState {
+ get {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ set {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [Localizable(true)]
+ public new virtual bool RightToLeft {
+ get {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ set {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+
+ public override ISite Site {
+ set {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override string Text {
+ get {
+ return text;
+ }
+
+ set {
+ text = value;
+ }
+ }
+ #endregion // Protected Constructors
+
+ #region Protected Instance Properties
+ protected override CreateParams CreateParams {
+ get {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ }
+
+ protected override Size DefaultSize {
+ get {
+ return new Size (75, 23);
+ }
+ }
+ #endregion // Protected Instance Properties
+
+ #region Protected Static Methods
+ [CLSCompliant(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected static Color GetColorFromOleColor(uint color){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected static Font GetFontFromIFont(object font){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected static Font GetFontFromIFontDisp(object font){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected static object GetIFontDispFromFont(Font font){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected static object GetIFontFromFont(Font font){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected static object GetIPictureDispFromPicture(Image image){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected static object GetIPictureFromCursor(Cursor cursor){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected static object GetIPictureFromPicture(Image image){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected static double GetOADateFromTime(DateTime time){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [CLSCompliant(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected static uint GetOleColorFromColor(Color color){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected static Image GetPictureFromIPicture(object picture){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected static Image GetPictureFromIPictureDisp(object picture){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected static DateTime GetTimeFromOADate(double date){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ #endregion // Protected Static Methods
+
+ #region Public Instance Methods
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public void BeginInit() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ public void DoVerb(int verb){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public virtual void EndInit() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public object GetOcx() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ public bool HasPropertyPages() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public void InvokeEditMode(){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public void MakeDirty(){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ public override bool PreProcessMessage(ref Message msg) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ public void ShowAboutBox() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ public void ShowPropertyPages() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ public void ShowPropertyPages(Control control) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected virtual void AttachInterfaces() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ protected override void CreateHandle() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void CreateSink(){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ protected override void DestroyHandle() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void DetachSink(){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ protected override void Dispose(bool disposing) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ protected override bool IsInputChar(char charCode) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ protected override void OnBackColorChanged(EventArgs e) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ protected override void OnFontChanged(EventArgs e) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ protected override void OnForeColorChanged(EventArgs e) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ protected override void OnHandleCreated(EventArgs e) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ protected virtual void OnInPlaceActive() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void OnLostFocus(EventArgs e) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ protected override bool ProcessDialogKey(Keys keyData) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ protected override bool ProcessMnemonic(char charCode) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected bool PropsValid(){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void RaiseOnMouseDown(short button, short shift, int x, int y){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void RaiseOnMouseDown(short button, short shift, float x, float y){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void RaiseOnMouseDown(object o1, object o2, object o3, object o4){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void RaiseOnMouseMove(short button, short shift, int x, int y){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void RaiseOnMouseMove(short button, short shift, float x, float y){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void RaiseOnMouseMove(object o1, object o2, object o3, object o4){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void RaiseOnMouseUp(short button, short shift, int x, int y){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void RaiseOnMouseUp(short button, short shift, float x, float y){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void RaiseOnMouseUp(object o1, object o2, object o3, object o4){
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ protected void SetAboutBoxDelegate(AxHost.AboutBoxDelegate d) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ protected override void SetVisibleCore(bool value) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ protected override void WndProc(ref Message m) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ #endregion // Protected Instance Methods
+
+ #region Private Instance Methods
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ private bool ShouldSerializeContainingControl() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ #endregion // Protected Instance Methods
+
+ #region Events
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler BackColorChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler BackgroundImageChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler BindingContextChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event UICuesEventHandler ChangeUICues;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler Click;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler ContextMenuChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler CursorChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler DoubleClick;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event DragEventHandler DragDrop;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event DragEventHandler DragEnter;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler DragLeave;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event DragEventHandler DragOver;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler EnabledChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler FontChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler ForeColorChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event GiveFeedbackEventHandler GiveFeedback;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event HelpEventHandler HelpRequested;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler ImeModeChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event KeyEventHandler KeyDown;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event KeyPressEventHandler KeyPress;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event KeyEventHandler KeyUp;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event LayoutEventHandler Layout;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event MouseEventHandler MouseDown;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler MouseEnter;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler MouseHover;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler MouseLeave;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event MouseEventHandler MouseMove;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event MouseEventHandler MouseUp;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event MouseEventHandler MouseWheel;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event PaintEventHandler Paint;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event QueryContinueDragEventHandler QueryContinueDrag;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler RightToLeftChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler StyleChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler TabIndexChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler TabStopChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler TextChanged;
+ #endregion // Events
+
+ #region Delegates
+ [Serializable]
+ protected delegate void AboutBoxDelegate();
+ #endregion // Delegates
+
+ #region Interfaces
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ AttributeCollection ICustomTypeDescriptor.GetAttributes() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ string ICustomTypeDescriptor.GetClassName() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ string ICustomTypeDescriptor.GetComponentName() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ TypeConverter ICustomTypeDescriptor.GetConverter() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ EventDescriptor ICustomTypeDescriptor.GetDefaultEvent() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ object ICustomTypeDescriptor.GetEditor(Type editorBaseType) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ EventDescriptorCollection ICustomTypeDescriptor.GetEvents() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties() {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd) {
+ throw new NotImplementedException("COM/ActiveX support is not implemented");
+ }
+ #endregion // Interfaces
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BaseCollection.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BaseCollection.cs
new file mode 100644
index 00000000000..028f33f0185
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BaseCollection.cs
@@ -0,0 +1,99 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+ public class BaseCollection : MarshalByRefObject, ICollection, IEnumerable {
+ internal ArrayList list;
+
+ #region Public Constructors
+ public BaseCollection ()
+ {
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public virtual int Count {
+ get {
+ return List.Count;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public bool IsReadOnly {
+ get {
+ return false;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public bool IsSynchronized {
+ get {
+ return false;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public object SyncRoot {
+ get {
+ return this;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Properties
+ protected virtual ArrayList List {
+ get {
+ if (list == null)
+ list = new ArrayList ();
+ return list;
+ }
+ }
+ #endregion // Protected Instance Properties
+
+ #region Public Instance Methods
+ public void CopyTo (Array ar, int index)
+ {
+ List.CopyTo (ar, index);
+ }
+
+ public IEnumerator GetEnumerator ()
+ {
+ return List.GetEnumerator ();
+ }
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Binding.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Binding.cs
new file mode 100644
index 00000000000..36b5510e4ab
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Binding.cs
@@ -0,0 +1,311 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+// Jackson Harper jackson@ximian.com
+//
+
+
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+
+ [TypeConverter (typeof (ListBindingConverter))]
+ public class Binding {
+
+ private string property_name;
+ private object data_source;
+ private string data_member;
+
+ private string row_name;
+ private string col_name;
+
+ private BindingMemberInfo binding_member_info;
+ private Control control;
+
+ private BindingManagerBase manager;
+ private PropertyDescriptor prop_desc;
+ private PropertyDescriptor is_null_desc;
+
+ private EventDescriptor changed_event;
+ private EventHandler property_value_changed_handler;
+ private object event_current; // The manager.Current as far as the changed_event knows
+
+ private object data;
+ private Type data_type;
+
+ #region Public Constructors
+ public Binding (string propertyName, object dataSource, string dataMember)
+ {
+ property_name = propertyName;
+ data_source = dataSource;
+ data_member = dataMember;
+ binding_member_info = new BindingMemberInfo (dataMember);
+
+ int sp = data_member.IndexOf ('.');
+ if (sp != -1) {
+ row_name = data_member.Substring (0, sp);
+ col_name = data_member.Substring (sp + 1, data_member.Length - sp - 1);
+ }
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public BindingManagerBase BindingManagerBase {
+ get {
+ return manager;
+ }
+ }
+
+ public BindingMemberInfo BindingMemberInfo {
+ get {
+ return binding_member_info;
+ }
+ }
+
+ [DefaultValue (null)]
+ public Control Control {
+ get {
+ return control;
+ }
+ }
+
+ public object DataSource {
+ get {
+ return data_source;
+ }
+ }
+
+ public bool IsBinding {
+ get {
+ if (control == null || !control.Created)
+ return false;
+ if (manager == null || manager.IsSuspended)
+ return false;
+ return true;
+ }
+ }
+
+ [DefaultValue ("")]
+ public string PropertyName {
+ get {
+ return property_name;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Methods
+ protected virtual void OnFormat (ConvertEventArgs cevent)
+ {
+ if (Format!=null)
+ Format (this, cevent);
+ }
+
+ protected virtual void OnParse (ConvertEventArgs cevent)
+ {
+ if (Parse!=null)
+ Parse (this, cevent);
+ }
+ #endregion // Protected Instance Methods
+
+
+ internal void SetControl (Control control)
+ {
+ if (control == this.control)
+ return;
+
+ prop_desc = TypeDescriptor.GetProperties (control).Find (property_name, true);
+
+ if (prop_desc == null)
+ throw new ArgumentException (String.Concat ("Cannot bind to property '", property_name, "' on target control."));
+ if (prop_desc.IsReadOnly)
+ throw new ArgumentException (String.Concat ("Cannot bind to property '", property_name, "' because it is read only."));
+
+ data_type = prop_desc.PropertyType; // Getting the PropertyType is kinda slow and it should never change, so it is cached
+ control.Validating += new CancelEventHandler (ControlValidatingHandler);
+
+ this.control = control;
+ control.DataBindings.Add (this);
+ }
+
+ internal void Check (BindingContext binding_context)
+ {
+ if (control == null)
+ return;
+
+ string member_name = data_member;
+ if (row_name != null)
+ member_name = row_name;
+ manager = control.BindingContext [data_source, member_name];
+ manager.AddBinding (this);
+ manager.PositionChanged += new EventHandler (PositionChangedHandler);
+
+ WirePropertyValueChangedEvent ();
+
+ is_null_desc = TypeDescriptor.GetProperties (manager.Current).Find (property_name + "IsNull", false);
+
+ PullData ();
+ }
+
+ internal void PushData ()
+ {
+ if (IsBinding == false)
+ return;
+
+ data = prop_desc.GetValue (control);
+ data = FormatData (data);
+ SetPropertyValue (data);
+ }
+
+ internal void PullData ()
+ {
+ if (IsBinding == false)
+ return;
+
+ if (is_null_desc != null) {
+ bool is_null = (bool) is_null_desc.GetValue (manager.Current);
+ if (is_null) {
+ data = Convert.DBNull;
+ return;
+ }
+ }
+
+ if (row_name != null && col_name != null) {
+ PropertyDescriptor pd = TypeDescriptor.GetProperties (manager.Current).Find (col_name, true);
+ object pulled = pd.GetValue (manager.Current);
+ data = ParseData (pulled, pd.PropertyType);
+ } else if (data_member != null) {
+ PropertyDescriptor pd = TypeDescriptor.GetProperties (manager.Current).Find (data_member, true);
+ object pulled = pd.GetValue (manager.Current);
+ data = ParseData (pulled, pd.PropertyType);
+ } else {
+ object pulled = manager.Current;
+ data = ParseData (pulled, pulled.GetType ());
+ }
+
+ data = FormatData (data);
+ SetControlValue (data);
+ }
+
+ internal void UpdateIsBinding ()
+ {
+ PullData ();
+ }
+
+ private void SetControlValue (object data)
+ {
+ prop_desc.SetValue (control, data);
+ }
+
+ private void SetPropertyValue (object data)
+ {
+ string member_name = data_member;
+ if (col_name != null)
+ member_name = col_name;
+ PropertyDescriptor pd = TypeDescriptor.GetProperties (manager.Current).Find (member_name, true);
+ if (pd.IsReadOnly)
+ return;
+ pd.SetValue (manager.Current, data);
+ }
+
+ private void CurrentChangedHandler ()
+ {
+ if (changed_event != null) {
+ changed_event.RemoveEventHandler (event_current, property_value_changed_handler);
+ WirePropertyValueChangedEvent ();
+ }
+ }
+
+ private void WirePropertyValueChangedEvent ()
+ {
+ EventDescriptor changed_event = TypeDescriptor.GetEvents (manager.Current).Find (property_name + "Changed", false);
+ if (changed_event == null)
+ return;
+ property_value_changed_handler = new EventHandler (PropertyValueChanged);
+ changed_event.AddEventHandler (manager.Current, property_value_changed_handler);
+
+ event_current = manager.Current;
+ }
+
+ private void PropertyValueChanged (object sender, EventArgs e)
+ {
+ PullData ();
+ }
+
+ private void ControlValidatingHandler (object sender, CancelEventArgs e)
+ {
+ PullData ();
+ }
+
+ private void PositionChangedHandler (object sender, EventArgs e)
+ {
+ PullData ();
+ }
+
+ private object ParseData (object data, Type data_type)
+ {
+ ConvertEventArgs e = new ConvertEventArgs (data, data_type);
+
+ OnParse (e);
+ if (data_type.IsInstanceOfType (e.Value))
+ return e.Value;
+ if (e.Value == Convert.DBNull)
+ return e.Value;
+
+ return ConvertData (e.Value, data_type);
+ }
+
+ private object FormatData (object data)
+ {
+ if (data_type == typeof (object))
+ return data;
+
+ ConvertEventArgs e = new ConvertEventArgs (data, data_type);
+
+ OnFormat (e);
+ if (data_type.IsInstanceOfType (e.Value))
+ return e.Value;
+
+ return ConvertData (data, data_type);
+ }
+
+ private object ConvertData (object data, Type data_type)
+ {
+ TypeConverter converter = TypeDescriptor.GetConverter (data.GetType ());
+ if (converter != null && converter.CanConvertTo (data_type))
+ return converter.ConvertTo (data, data_type);
+
+ if (data is IConvertible) {
+ object res = Convert.ChangeType (data, data_type);
+ if (data_type.IsInstanceOfType (res))
+ return res;
+ }
+
+ return null;
+ }
+
+ #region Events
+ public event ConvertEventHandler Format;
+ public event ConvertEventHandler Parse;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingContext.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingContext.cs
new file mode 100644
index 00000000000..234de4104ce
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingContext.cs
@@ -0,0 +1,227 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+// Jackson Harper jackson@ximian.com
+
+
+using System.Collections;
+using System.Globalization;
+using System.ComponentModel;
+
+
+namespace System.Windows.Forms {
+
+ [DefaultEvent("CollectionChanged")]
+ public class BindingContext : ICollection, IEnumerable {
+
+ private Hashtable managers;
+ private object null_data_source = new object ();
+
+ private class DataSourceEntry {
+
+ private object source;
+ private Hashtable members;
+ // private BindingManagerBase default_manager;
+
+ public DataSourceEntry (object source)
+ {
+ this.source = source;
+ members = new Hashtable ();
+ }
+
+ public BindingManagerBase AddMember (string member)
+ {
+ if (member == null)
+ member = String.Empty;
+ BindingManagerBase res = members [member] as BindingManagerBase;
+ if (res != null)
+ return res;
+ res = CreateBindingManager (source, member);
+ members [member] = res;
+ return res;
+ }
+
+ public void AddMember (string member, BindingManagerBase manager)
+ {
+ members [member] = manager;
+ }
+
+ public bool Contains (string member)
+ {
+ return members.Contains (member);
+ }
+ }
+
+ public BindingContext ()
+ {
+ managers = new Hashtable ();
+ }
+
+ public bool IsReadOnly {
+ get {
+ return false;
+ }
+ }
+
+ public BindingManagerBase this [object dataSource] {
+ get {
+ return this [dataSource, String.Empty];
+ }
+ }
+
+ public BindingManagerBase this [object data_source, string data_member] {
+ get {
+ DataSourceEntry ds = GetEntry (data_source, data_member, true);
+ return ds.AddMember (data_member);
+ }
+ }
+
+ private DataSourceEntry GetEntry (object data_source, string data_member, bool create)
+ {
+ if (data_source == null)
+ data_source = null_data_source;
+
+ DataSourceEntry ds = managers [data_source] as DataSourceEntry;
+ if (ds == null && create) {
+ ds = new DataSourceEntry (data_source);
+ managers [data_source] = ds;
+ }
+
+ return ds;
+ }
+
+ private static BindingManagerBase CreateBindingManager (object data_source,
+ string data_member)
+ {
+ if (data_source is IList ||
+ data_source is IListSource ||
+ data_source is IBindingList) {
+ CurrencyManager res = new CurrencyManager (data_source, data_member);
+ return res;
+ }
+
+ return new PropertyManager (data_source, data_member);
+ }
+
+ #region Public Instance Methods
+ public bool Contains(object dataSource)
+ {
+ return Contains (dataSource, String.Empty);
+ }
+
+ public bool Contains (object dataSource, string dataMember)
+ {
+ DataSourceEntry ds = GetEntry (dataSource, dataMember, false);
+ if (ds == null)
+ return false;
+ return ds.Contains (dataMember);
+
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+
+ protected internal void Add (object dataSource, BindingManagerBase listManager)
+ {
+ AddCore (dataSource, listManager);
+ OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Add, dataSource));
+ }
+
+ protected virtual void AddCore (object dataSource, BindingManagerBase listManager)
+ {
+ if (dataSource == null)
+ throw new ArgumentNullException ("dataSource");
+ if (listManager == null)
+ throw new ArgumentNullException ("listManager");
+ DataSourceEntry ds = GetEntry (dataSource, String.Empty, true);
+ ds.AddMember (String.Empty, listManager);
+ }
+
+ protected internal void Clear ()
+ {
+ ClearCore();
+ OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Refresh, null));
+ }
+
+ protected virtual void ClearCore ()
+ {
+ managers.Clear ();
+ }
+
+ protected virtual void OnCollectionChanged(System.ComponentModel.CollectionChangeEventArgs ccevent)
+ {
+ if (CollectionChanged != null) {
+ CollectionChanged (this, ccevent);
+ }
+ }
+
+ protected internal void Remove (object dataSource)
+ {
+ RemoveCore (dataSource);
+ OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Remove, dataSource));
+ }
+
+ protected virtual void RemoveCore (object dataSource)
+ {
+ managers.Remove (dataSource);
+ }
+ #endregion // Protected Instance Methods
+
+ #region Events
+ public event CollectionChangeEventHandler CollectionChanged;
+ #endregion // Events
+
+ #region ICollection Interfaces
+ void ICollection.CopyTo (Array array, int index)
+ {
+ managers.CopyTo (array, index);
+ }
+
+ int ICollection.Count {
+ get {
+ return managers.Count;
+ }
+ }
+
+ bool ICollection.IsSynchronized {
+ get {
+ return false;
+ }
+ }
+
+ object ICollection.SyncRoot {
+ get {
+ return null;
+ }
+ }
+
+ #endregion // ICollection Interfaces
+
+ #region IEnumerable Interfaces
+ [MonoTODO]
+ IEnumerator IEnumerable.GetEnumerator() {
+ throw new NotImplementedException();
+ }
+ #endregion // IEnumerable Interfaces
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingManagerBase.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingManagerBase.cs
new file mode 100644
index 00000000000..e3ab60b7170
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingManagerBase.cs
@@ -0,0 +1,153 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+// Jackson Harper jackson@ximian.com
+//
+
+
+// NOT COMPLETE
+
+using System.ComponentModel;
+using System.Collections;
+
+namespace System.Windows.Forms {
+ public abstract class BindingManagerBase {
+ private BindingsCollection bindings;
+ private bool pulling_data;
+
+ private static int count = 0;
+ private int id = count++;
+
+#region Public Constructors
+ public BindingManagerBase() {
+ }
+ #endregion // Public Constructors
+
+ #region Protected Instance Fields
+ protected EventHandler onCurrentChangedHandler;
+ protected EventHandler onPositionChangedHandler;
+ #endregion // Protected Instance Fields
+
+ #region Public Instance Properties
+ public BindingsCollection Bindings {
+ get {
+ if (bindings == null) {
+ bindings = new BindingsCollection ();
+ }
+ return bindings;
+ }
+ }
+
+ public abstract int Count {
+ get;
+ }
+
+ public abstract object Current {
+ get;
+ }
+
+ public abstract int Position {
+ get; set;
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public abstract void AddNew();
+
+ public abstract void CancelCurrentEdit();
+
+ public abstract void EndCurrentEdit();
+
+ public abstract PropertyDescriptorCollection GetItemProperties();
+
+ public abstract void RemoveAt(int index);
+
+ public abstract void ResumeBinding();
+
+ public abstract void SuspendBinding();
+ #endregion // Public Instance Methods
+
+ internal abstract bool IsSuspended {
+ get;
+ }
+
+ #region Protected Instance Methods
+ [MonoTODO]
+ protected internal virtual PropertyDescriptorCollection GetItemProperties(System.Collections.ArrayList dataSources, System.Collections.ArrayList listAccessors) {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ protected virtual PropertyDescriptorCollection GetItemProperties(Type lisType, int offset, System.Collections.ArrayList dataSources, System.Collections.ArrayList listAccessors) {
+ throw new NotImplementedException();
+ }
+
+ protected internal abstract string GetListName (System.Collections.ArrayList listAccessors);
+
+ protected internal abstract void OnCurrentChanged (EventArgs e);
+
+ protected void PullData()
+ {
+ pulling_data = true;
+ try {
+ UpdateIsBinding ();
+ foreach (Binding binding in Bindings)
+ binding.PullData ();
+ } finally {
+ pulling_data = false;
+ }
+ }
+
+ protected void PushData()
+ {
+ if (pulling_data)
+ return;
+
+ UpdateIsBinding ();
+ foreach (Binding binding in Bindings)
+ binding.PushData ();
+ }
+
+ protected abstract void UpdateIsBinding();
+ #endregion // Protected Instance Methods
+
+ internal void AddBinding (Binding binding)
+ {
+ if (Bindings.Contains (binding))
+ return;
+ Bindings.Add (binding);
+ }
+
+ #region Events
+ public event EventHandler CurrentChanged {
+ add { onCurrentChangedHandler += value; }
+ remove { onCurrentChangedHandler -= value; }
+ }
+
+ public event EventHandler PositionChanged {
+ add { onPositionChangedHandler += value; }
+ remove { onPositionChangedHandler -= value; }
+ }
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingMemberInfo.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingMemberInfo.cs
new file mode 100644
index 00000000000..7bf925a6ef5
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingMemberInfo.cs
@@ -0,0 +1,93 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public struct BindingMemberInfo {
+ private string data_member;
+ private string data_field;
+ private string data_path;
+
+ #region Public Constructors
+ public BindingMemberInfo(string dataMember) {
+ int i;
+
+ if (dataMember!=null) {
+ this.data_member=dataMember;
+ } else {
+ this.data_member=String.Empty;
+ }
+
+ // Break out our components
+ i=data_member.LastIndexOf('.');
+ if (i!=-1) {
+ data_field=data_member.Substring(i+1);
+ data_path=data_member.Substring(0, i);
+ } else {
+ data_field=data_member;
+ data_path=String.Empty;
+ }
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public string BindingField {
+ get {
+ return this.data_field;
+ }
+ }
+
+ public string BindingMember {
+ get {
+ return this.data_member;
+ }
+ }
+
+ public string BindingPath {
+ get {
+ return this.data_path;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public override bool Equals(object otherObject) {
+ if (otherObject is BindingMemberInfo) {
+ return ((this.data_field == ((BindingMemberInfo)otherObject).data_field) &&
+ (this.data_path == ((BindingMemberInfo)otherObject).data_path) &&
+ (this.data_member == ((BindingMemberInfo)otherObject).data_member));
+ } else {
+ return false;
+ }
+ }
+
+ public override int GetHashCode() {
+ return this.data_member.GetHashCode();
+ }
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingsCollection.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingsCollection.cs
new file mode 100644
index 00000000000..b8572eb7c14
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingsCollection.cs
@@ -0,0 +1,120 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+// Jackson Harper jackson@ximian.com
+//
+
+
+// COMPLETE
+
+using System.Collections;
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+ [DefaultEvent("CollectionChanged")]
+ public class BindingsCollection : BaseCollection {
+
+#region Public Constructors
+ internal BindingsCollection ()
+ {
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public override int Count {
+ get {
+ return base.Count;
+ }
+ }
+
+ public Binding this[int index] {
+ get {
+ return (Binding)(base.List[index]);
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Properties
+ protected override ArrayList List {
+ get {
+ return base.List;
+ }
+ }
+ #endregion // Protected Instance Properties
+
+ #region Protected Instance Methods
+ protected internal void Add(Binding binding) {
+ AddCore(binding);
+ }
+
+ protected virtual void AddCore(Binding dataBinding) {
+ base.List.Add(dataBinding);
+ OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, base.List));
+ }
+
+ protected internal void Clear() {
+ ClearCore();
+ }
+
+ protected virtual void ClearCore() {
+ base.List.Clear();
+ OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Refresh, base.List));
+ }
+
+ protected virtual void OnCollectionChanged(System.ComponentModel.CollectionChangeEventArgs ccevent) {
+ if (CollectionChanged!=null) CollectionChanged(this, ccevent);
+ }
+
+ protected internal void Remove(Binding binding) {
+ RemoveCore(binding);
+ }
+
+ protected internal void RemoveAt(int index) {
+ base.List.RemoveAt(index);
+ OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Remove, base.List));
+ }
+
+ protected virtual void RemoveCore(Binding dataBinding) {
+ base.List.Remove(dataBinding);
+ OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Remove, base.List));
+ }
+
+ protected internal bool ShouldSerializeMyAll() {
+ if (this.Count>0) {
+ return(true);
+ } else {
+ return(false);
+ }
+ }
+ #endregion // Public Instance Methods
+
+ internal bool Contains (Binding binding)
+ {
+ return List.Contains (binding);
+ }
+
+ #region Events
+ public event CollectionChangeEventHandler CollectionChanged;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BootMode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BootMode.cs
new file mode 100644
index 00000000000..943779459b4
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BootMode.cs
@@ -0,0 +1,39 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+
+//COMPLETE
+
+
+namespace System.Windows.Forms
+{
+
+ public enum BootMode
+ {
+ Normal = 0,
+ FailSafe = 1,
+ FailSafeWithNetwork = 2
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Border3DSide.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Border3DSide.cs
new file mode 100644
index 00000000000..ae739e9e40c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Border3DSide.cs
@@ -0,0 +1,42 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ [Flags]
+ public enum Border3DSide {
+ Left = 0x00000001,
+ Top = 0x00000002,
+ Right = 0x00000004,
+ Bottom = 0x00000008,
+ Middle = 0x00000800,
+ All = 0x0000080F
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Border3DStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Border3DStyle.cs
new file mode 100644
index 00000000000..ecf9b828bdf
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Border3DStyle.cs
@@ -0,0 +1,45 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public enum Border3DStyle {
+ RaisedOuter = 1,
+ SunkenOuter = 2,
+ RaisedInner = 4,
+ Raised = 5,
+ Etched = 6,
+ SunkenInner = 8,
+ Bump = 9,
+ Sunken = 10,
+ Adjust = 8192,
+ Flat = 16394
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BorderStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BorderStyle.cs
new file mode 100644
index 00000000000..b4bb1eecb45
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BorderStyle.cs
@@ -0,0 +1,37 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public enum BorderStyle {
+ None = 0,
+ FixedSingle = 1,
+ Fixed3D = 2
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BoundsSpecified.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BoundsSpecified.cs
new file mode 100644
index 00000000000..0b64c75381b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BoundsSpecified.cs
@@ -0,0 +1,42 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+ [Flags]
+ public enum BoundsSpecified
+ {
+ None = 0x00000000,
+ X = 0x00000001,
+ Y = 0x00000002,
+ Location = 0x00000003,
+ Width = 0x00000004,
+ Height = 0x00000008,
+ Size = 0x0000000c,
+ All = 0x0000000f
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs
new file mode 100644
index 00000000000..fee2af3d6fe
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs
@@ -0,0 +1,122 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+// COMPLETE
+
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Text;
+
+namespace System.Windows.Forms {
+ public class Button : ButtonBase, IButtonControl {
+ #region Local variables
+ DialogResult dialog_result;
+ #endregion // Local variables
+
+ #region Public Constructors
+ public Button() {
+ dialog_result = DialogResult.None;
+ SetStyle(ControlStyles.StandardDoubleClick, false);
+ }
+ #endregion // Public Constructors
+
+ #region Internal methods
+ internal override void HaveDoubleClick() {
+ if (DoubleClick != null) DoubleClick(this, EventArgs.Empty);
+ }
+ #endregion // Internal methods
+
+ #region Public Instance Properties
+ [DefaultValue(DialogResult.None)]
+ public DialogResult DialogResult { // IButtonControl
+ get {
+ return dialog_result;
+ }
+ set {
+ dialog_result = value;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Properties
+ protected override CreateParams CreateParams {
+ get {
+ return base.CreateParams;
+ }
+ }
+ #endregion // Protected Instance Properties
+
+ #region Public Instance Methods
+ public virtual void NotifyDefault(bool value) { // IButtonControl
+ this.IsDefault = value;
+ }
+
+ public void PerformClick() { // IButtonControl
+ OnClick(EventArgs.Empty);
+ }
+
+ public override string ToString() {
+ return base.ToString() + ", Text: " + this.text;
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected override void OnClick(EventArgs e) {
+ if (dialog_result != DialogResult.None) {
+ Form p = Parent as Form;
+
+ if (p != null) {
+ p.DialogResult = dialog_result;
+ }
+ }
+ base.OnClick(e);
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e) {
+ base.OnMouseUp (e);
+ }
+
+ protected override bool ProcessMnemonic(char charCode) {
+ if (IsMnemonic(charCode, Text) == true) {
+ PerformClick();
+ return true;
+ }
+
+ return base.ProcessMnemonic(charCode);
+ }
+
+ protected override void WndProc(ref Message m) {
+ base.WndProc (ref m);
+ }
+ #endregion // Protected Instance Methods
+
+ #region Events
+ [Browsable(false)]
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ public event EventHandler DoubleClick;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonBase.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonBase.cs
new file mode 100644
index 00000000000..ffe88e749c7
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonBase.cs
@@ -0,0 +1,563 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+// COMPLETE
+
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.Drawing.Text;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ public abstract class ButtonBase : Control {
+ #region Local Variables
+ internal FlatStyle flat_style;
+ internal int image_index;
+ internal Image image;
+ internal ImageList image_list;
+ internal ContentAlignment image_alignment;
+ internal ContentAlignment text_alignment;
+ private bool is_default;
+ internal bool is_pressed;
+ internal bool enter_state;
+ internal StringFormat text_format;
+ internal bool paint_as_acceptbutton;
+ private bool use_compatible_text_rendering;
+ private bool use_visual_style_back_color;
+ #endregion // Local Variables
+
+ #region ButtonBaseAccessibleObject sub-class
+ [ComVisible(true)]
+ public class ButtonBaseAccessibleObject : ControlAccessibleObject {
+ #region ButtonBaseAccessibleObject Local Variables
+ private Control owner;
+ #endregion // ButtonBaseAccessibleObject Local Variables
+
+ #region ButtonBaseAccessibleObject Constructors
+ public ButtonBaseAccessibleObject(Control owner) : base(owner) {
+ this.owner = owner;
+ }
+ #endregion // ButtonBaseAccessibleObject Constructors
+
+ #region ButtonBaseAccessibleObject Methods
+ public override void DoDefaultAction() {
+ ((ButtonBase)owner).PerformClick();
+ }
+ #endregion // ButtonBaseAccessibleObject Methods
+ }
+ #endregion // ButtonBaseAccessibleObject sub-class
+
+ #region Private Properties and Methods
+ internal ButtonState ButtonState {
+ get {
+ ButtonState ret = ButtonState.Normal;
+
+ if (Enabled) {
+ // Popup style is only followed as long as the mouse isn't "in" the control
+ if (is_entered) {
+ if (flat_style == FlatStyle.Flat) {
+ ret |= ButtonState.Flat;
+ }
+ } else {
+ if (flat_style == FlatStyle.Flat || flat_style == FlatStyle.Popup) {
+ ret |= ButtonState.Flat;
+ }
+ }
+
+ if (is_entered && is_pressed) {
+ ret |= ButtonState.Pushed;
+ }
+ } else {
+ ret |= ButtonState.Inactive;
+ if ((flat_style == FlatStyle.Flat) || (flat_style == FlatStyle.Popup)) {
+ ret |= ButtonState.Flat;
+ }
+ }
+ return ret;
+ }
+ }
+
+ [MonoTODO("Make the FillRectangle use a global brush instead of creating one every time")]
+ internal void Redraw() {
+ Refresh ();
+ }
+
+ // Derived classes should override Draw method and we dont want
+ // to break the control signature, hence this approach.
+ internal virtual void Draw (PaintEventArgs pevent) {
+ ThemeEngine.Current.DrawButtonBase (pevent.Graphics, pevent.ClipRectangle, this);
+ }
+
+ internal virtual void HaveDoubleClick() {
+ // override me
+ }
+
+ private void RedrawEvent(object sender, System.EventArgs e) {
+ Redraw();
+ }
+
+ #endregion // Private Properties and Methods
+
+ #region Public Constructors
+ protected ButtonBase() : base() {
+ flat_style = FlatStyle.Standard;
+ image_index = -1;
+ image = null;
+ image_list = null;
+ image_alignment = ContentAlignment.MiddleCenter;
+ text_alignment = ContentAlignment.MiddleCenter;
+ ime_mode = ImeMode.Inherit;
+ is_default = false;
+ is_entered = false;
+ is_pressed = false;
+ has_focus = false;
+ text_format = new StringFormat();
+ text_format.Alignment = StringAlignment.Center;
+ text_format.LineAlignment = StringAlignment.Center;
+ text_format.HotkeyPrefix = HotkeyPrefix.Show;
+
+ TextChanged+=new System.EventHandler(RedrawEvent);
+ ForeColorChanged+=new EventHandler(RedrawEvent);
+ BackColorChanged+=new System.EventHandler(RedrawEvent);
+ FontChanged+=new EventHandler(RedrawEvent);
+ SizeChanged+=new EventHandler(RedrawEvent);
+
+ SetStyle(ControlStyles.ResizeRedraw |
+ ControlStyles.Opaque |
+ ControlStyles.UserMouse |
+ ControlStyles.SupportsTransparentBackColor |
+ ControlStyles.CacheText |
+ ControlStyles.DoubleBuffer, true);
+ SetStyle(ControlStyles.StandardClick, false);
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ [Localizable(true)]
+ [DefaultValue(FlatStyle.Standard)]
+ [MWFDescription("Determines look of button"), MWFCategory("Appearance")]
+ public FlatStyle FlatStyle {
+ get {
+ return flat_style;
+ }
+
+ set {
+ flat_style = value;
+ Redraw();
+ }
+ }
+
+ [Localizable(true)]
+ [MWFDescription("Sets image to be displayed on button face"), MWFCategory("Appearance")]
+ public Image Image {
+ get {
+ return image;
+ }
+
+ set {
+ image = value;
+ Redraw();
+ }
+ }
+
+ [Localizable(true)]
+ [DefaultValue(ContentAlignment.MiddleCenter)]
+ [MWFDescription("Sets the alignment of the image to be displayed on button face"), MWFCategory("Appearance")]
+ public ContentAlignment ImageAlign {
+ get {
+ return image_alignment;
+ }
+
+ set {
+ image_alignment=value;
+ Redraw();
+ }
+ }
+
+ [Localizable(true)]
+ [DefaultValue(-1)]
+ [Editor("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
+ [TypeConverter(typeof(ImageIndexConverter))]
+ [MWFDescription("Index of image to display, if ImageList is used for button face images"), MWFCategory("Appearance")]
+ public int ImageIndex {
+ get {
+ if (image_list==null) {
+ return -1;
+ }
+ return image_index;
+ }
+
+ set {
+ image_index=value;
+ Redraw();
+ }
+ }
+
+ [DefaultValue(null)]
+ [MWFDescription("ImageList used for ImageIndex"), MWFCategory("Appearance")]
+ public ImageList ImageList {
+ get {
+ return image_list;
+ }
+
+ set {
+ image_list = value;
+ if (value != null) {
+ if (image != null) {
+ image=null;
+ }
+ if (image_list.Images.Count >= image_index) {
+ image_index=image_list.Images.Count-1;
+ }
+ }
+ Redraw();
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new ImeMode ImeMode {
+ get {
+ return ime_mode;
+ }
+
+ set {
+ if (ime_mode != value) {
+ ime_mode = value;
+
+ if (ImeModeChanged != null) {
+ ImeModeChanged(this, EventArgs.Empty);
+ }
+ }
+ }
+ }
+
+ [Localizable(true)]
+ [DefaultValue(ContentAlignment.MiddleCenter)]
+ [MWFDescription("Alignment for button text"), MWFCategory("Appearance")]
+ public virtual ContentAlignment TextAlign {
+ get {
+ return text_alignment;
+ }
+
+ set {
+ if (text_alignment != value) {
+ text_alignment = value;
+ switch(text_alignment) {
+ case ContentAlignment.TopLeft: {
+ text_format.Alignment=StringAlignment.Near;
+ text_format.LineAlignment=StringAlignment.Near;
+ break;
+ }
+
+ case ContentAlignment.TopCenter: {
+ text_format.Alignment=StringAlignment.Center;
+ text_format.LineAlignment=StringAlignment.Near;
+ break;
+ }
+
+ case ContentAlignment.TopRight: {
+ text_format.Alignment=StringAlignment.Far;
+ text_format.LineAlignment=StringAlignment.Near;
+ break;
+ }
+
+ case ContentAlignment.MiddleLeft: {
+ text_format.Alignment=StringAlignment.Near;
+ text_format.LineAlignment=StringAlignment.Center;
+ break;
+ }
+
+ case ContentAlignment.MiddleCenter: {
+ text_format.Alignment=StringAlignment.Center;
+ text_format.LineAlignment=StringAlignment.Center;
+ break;
+ }
+
+ case ContentAlignment.MiddleRight: {
+ text_format.Alignment=StringAlignment.Far;
+ text_format.LineAlignment=StringAlignment.Center;
+ break;
+ }
+
+ case ContentAlignment.BottomLeft: {
+ text_format.Alignment=StringAlignment.Near;
+ text_format.LineAlignment=StringAlignment.Far;
+ break;
+ }
+
+ case ContentAlignment.BottomCenter: {
+ text_format.Alignment=StringAlignment.Center;
+ text_format.LineAlignment=StringAlignment.Far;
+ break;
+ }
+
+ case ContentAlignment.BottomRight: {
+ text_format.Alignment=StringAlignment.Far;
+ text_format.LineAlignment=StringAlignment.Far;
+ break;
+ }
+ }
+ Redraw();
+ }
+ }
+ }
+
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Properties
+ protected override CreateParams CreateParams {
+ get {
+ return base.CreateParams;
+ }
+ }
+
+ protected override ImeMode DefaultImeMode {
+ get {
+ return ImeMode.Inherit;
+ }
+ }
+
+ protected override Size DefaultSize {
+ get {
+ return ThemeEngine.Current.ButtonBaseDefaultSize;
+ }
+ }
+
+ protected bool IsDefault {
+ get {
+ return is_default;
+ }
+
+ set {
+ if (is_default != value) {
+ is_default = true;
+ Redraw();
+ }
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Methods
+ protected override AccessibleObject CreateAccessibilityInstance() {
+ AccessibleObject ao;
+ ao = base.CreateAccessibilityInstance();
+ ao.description = "Button";
+ ao.role = AccessibleRole.PushButton;
+
+ return ao;
+ }
+
+ protected override void Dispose(bool Disposing) {
+ base.Dispose(Disposing);
+ }
+
+ protected override void OnEnabledChanged(EventArgs e) {
+ Redraw();
+ base.OnEnabledChanged(e);
+ }
+
+ protected override void OnGotFocus(EventArgs e) {
+ has_focus=true;
+ Redraw();
+ base.OnGotFocus(e);
+ }
+
+ protected override void OnKeyDown(KeyEventArgs kevent) {
+ if (is_enabled && (kevent.KeyData == Keys.Space)) {
+ enter_state = is_entered;
+ is_entered = true;
+ OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 2, 2, 0));
+ kevent.Handled=true;
+ }
+ base.OnKeyDown(kevent);
+ }
+
+ protected override void OnKeyUp(KeyEventArgs kevent) {
+ if (is_enabled && (kevent.KeyData == Keys.Space)) {
+ OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 2, 2, 0));
+ is_entered = enter_state;
+ kevent.Handled=true;
+ }
+ base.OnKeyUp(kevent);
+ }
+
+ protected override void OnLostFocus(EventArgs e) {
+ has_focus=false;
+ Redraw();
+ base.OnLostFocus(e);
+ }
+
+ protected override void OnMouseDown(MouseEventArgs mevent) {
+ if (is_enabled && (mevent.Button == MouseButtons.Left)) {
+ is_pressed = true;
+ this.Capture = true;
+ Redraw();
+ }
+
+ base.OnMouseDown(mevent);
+ }
+
+ protected override void OnMouseEnter(EventArgs e) {
+ is_entered=true;
+ if ( is_enabled )
+ Redraw();
+ base.OnMouseEnter(e);
+ }
+
+ protected override void OnMouseLeave(EventArgs e) {
+ is_entered=false;
+ if ( is_enabled )
+ Redraw();
+ base.OnMouseLeave(e);
+ }
+
+ protected override void OnMouseMove(MouseEventArgs mevent) {
+ bool inside = false;
+ bool redraw = false;
+
+ if (mevent.X>=0 && mevent.Y>=0 && mevent.X<this.client_size.Width && mevent.Y<=this.client_size.Height) {
+ inside = true;
+ }
+
+ // If the button was pressed and we leave, release the button press and vice versa
+ if (this.Capture && (inside != is_pressed)) {
+ is_pressed = inside;
+ redraw = true;
+ }
+
+ if (is_entered != inside) {
+ is_entered = inside;
+ redraw = true;
+ }
+
+ if (redraw) {
+ Redraw();
+ }
+
+ base.OnMouseMove(mevent);
+ }
+
+ protected override void OnMouseUp(MouseEventArgs mevent) {
+ if (this.Capture && mevent.Button == MouseButtons.Left) {
+ this.Capture = false;
+ if (is_pressed) {
+ is_pressed = false;
+ Redraw();
+ } else if ((this.flat_style == FlatStyle.Flat) || (this.flat_style == FlatStyle.Popup)) {
+ Redraw();
+ }
+
+ if (mevent.X>=0 && mevent.Y>=0 && mevent.X<this.client_size.Width && mevent.Y<=this.client_size.Height) {
+ OnClick(EventArgs.Empty);
+ }
+ }
+ base.OnMouseUp(mevent);
+ }
+
+ protected override void OnPaint(PaintEventArgs pevent) {
+ Draw (pevent);
+ base.OnPaint (pevent);
+ }
+
+ protected override void OnParentChanged(EventArgs e) {
+ base.OnParentChanged(e);
+ }
+
+ protected override void OnTextChanged(EventArgs e) {
+ Redraw();
+ base.OnTextChanged(e);
+ }
+
+ protected override void OnVisibleChanged(EventArgs e) {
+ if (!Visible) {
+ is_pressed = false;
+ has_focus = false;
+ is_entered = false;
+ }
+ base.OnVisibleChanged(e);
+ }
+
+ protected void ResetFlagsandPaint() {
+ // Nothing to do; MS internal
+ // Should we do Redraw (); ?
+ }
+
+ protected override void WndProc(ref Message m) {
+ switch((Msg)m.Msg) {
+ case Msg.WM_LBUTTONDBLCLK: {
+ HaveDoubleClick();
+ break;
+ }
+
+ case Msg.WM_MBUTTONDBLCLK: {
+ HaveDoubleClick();
+ break;
+ }
+
+ case Msg.WM_RBUTTONDBLCLK: {
+ HaveDoubleClick();
+ break;
+ }
+ }
+ base.WndProc (ref m);
+ }
+ #endregion // Public Instance Properties
+
+
+ #region Internal Methods
+ private void PerformClick() {
+ OnClick(EventArgs.Empty);
+ }
+ #endregion // Internal Methods
+
+ #region Events
+ [Browsable(false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler ImeModeChanged;
+ #endregion // Events
+
+
+ #region .NET 2.0 Public Instance Properties
+#if NET_2_0
+ public bool UseVisualStyleBackColor {
+ get { return use_visual_style_back_color; }
+ set { use_visual_style_back_color = value; }
+ }
+
+ public bool UseCompatibleTextRendering {
+ get {
+ return use_compatible_text_rendering;
+ }
+
+ set {
+ use_compatible_text_rendering = value;
+ }
+ }
+#endif
+ #endregion
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonBorderStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonBorderStyle.cs
new file mode 100644
index 00000000000..b4dfb70aa16
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonBorderStyle.cs
@@ -0,0 +1,38 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum ButtonBorderStyle {
+ None = 0,
+ Dotted = 1,
+ Dashed = 2,
+ Solid = 3,
+ Inset = 4,
+ Outset = 5
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonState.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonState.cs
new file mode 100644
index 00000000000..52c9887a72a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonState.cs
@@ -0,0 +1,40 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+
+ [Flags]
+ public enum ButtonState {
+ Normal = 0x00000000,
+ Inactive = 0x00000100,
+ Pushed = 0x00000200,
+ Checked = 0x00000400,
+ Flat = 0x00004000,
+ All = 0x00004700
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CaptionButton.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CaptionButton.cs
new file mode 100644
index 00000000000..8b6c23e69a9
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CaptionButton.cs
@@ -0,0 +1,37 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum CaptionButton {
+ Close = 0,
+ Minimize = 1,
+ Maximize = 2,
+ Restore = 3,
+ Help = 4
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CategoryGridEntry.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CategoryGridEntry.cs
new file mode 100644
index 00000000000..5f02ff70ef3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CategoryGridEntry.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Drawing;
+
+namespace System.Windows.Forms.PropertyGridInternal
+{
+ /// <summary>
+ /// Summary description for CategoryGridEntry.
+ /// </summary>
+ internal class CategoryGridEntry : GridEntry
+ {
+ private string label;
+ public CategoryGridEntry(string category)
+ {
+ label = category;
+ }
+
+ public override GridItemType GridItemType {
+ get {
+ return GridItemType.Category;
+ }
+ }
+
+
+ public override string Label {
+ get {
+ return label;
+ }
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
new file mode 100644
index 00000000000..d1ef9d397cf
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
@@ -0,0 +1,12067 @@
+2006-03-25 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeWin32Classic.cs:
+ - GroupBox: Inserted a little gap between the text and the lines
+ on the right side
+ - Made the code in CPDrawBorder3D more readable
+ - Corrected the drawing location of the up and down arrows in
+ CPDrawScrollButton
+
+2006-03-25 Alexander Olk <alex.olk@googlemail.com>
+
+ * ControlPaint.cs: Corrected line widths in DrawBorder for
+ ButtonBorderStyle Inset and Outset
+
+2006-03-25 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeWin32Classic.cs:
+ - Rewrote the totally broken CPDrawBorder3D method. That was
+ one of the main problems for the terrific ThemeWin32Classic
+ look
+ - Updated and corrected Button drawing
+ - Correct the dimensions of the SizeGrip to match ms ones
+ - Removed a small drawing glitch in DrawComboBoxEditDecorations
+ * XplatUIX11.cs: Draw borders with BorderStyle = Fixed3D with
+ Border3DStyle.Sunken to match ms.
+
+2006-03-25 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeWin32Classic.cs: First small part of the "de-uglify
+ ThemeWin32Classic" effort, SizeGrip
+
+2006-03-24 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: Give a max idle time of one second, this matches
+ MS and forces an Idle event every second when there are no other
+ events in the queue.
+
+2006-03-24 Mike Kestner <mkestner@novell.com>
+
+ * ListView.cs: Handle (Large|Small)ImageList == null more robustly.
+ * ListView.Item.cs: fix layout issues with null image lists and images
+ smaller than checkbox size.
+ * ThemeWin32Classic.cs: Draw a 12 pixel line in ListView LargeIcon
+ mode like MS does. It's weird, but consistent. ;-)
+ Fixes #77890.
+
+2006-03-24 Mike Kestner <mkestner@novell.com>
+
+ * ListView.cs: Scroll wheel support for the item control. Fixes
+ #77839.
+
+2006-03-23 Jackson Harper <jackson@ximian.com>
+
+ * ScrollableControl.cs: Special case negative sized areas, not
+ zero.
+ * MonthCalendar.cs: Save the rect of the clicked date so we can
+ use it for invalidation.
+ - Try to cut down on the number of invalidates
+ - Invalidate the rect the mouse is over and was over when moving
+ the mouse, so we get the focus box following the cursor.
+
+2006-03-23 Mike Kestner <mkestner@novell.com>
+
+ * ThemeWin32Classic.cs: fix FullRowSelect selection background and
+ focus rectangle drawing. Fixes #77835.
+
+2006-03-23 Mike Kestner <mkestner@novell.com>
+
+ * XplatUIX11.cs: rework the fix for #77828 by changing the order of
+ the if and else if and reverting back to the original == check on the
+ None conditional.
+
+2006-03-23 Alexander Olk <alex.olk@googlemail.com>
+
+ * FontDialog.cs: Update the example panel if the selected index of
+ the fontListBox changes.
+
+2006-03-23 Alexander Olk <alex.olk@googlemail.com>
+
+ * FileDialog.cs: Make FileDialog remember which directory it was in
+ last in the same execution.
+
+2006-03-22 Mike Kestner <mkestner@novell.com>
+
+ * FileDialog.cs: make the DropDownMenu on the toolbar display
+ RadioChecks since they are mutually exclusive and that's what MS does.
+
+2006-03-22 Mike Kestner <mkestner@novell.com>
+
+ * Theme.cs: add Color param to CPDrawMenuGlyph.
+ * ThemeWin32Classic.cs: do color specific menu glyph rendering so that
+ checks and radio marks and arrows are visible on highlighted items.
+ * ControlPaint.cs: update to use new Theme signature.
+
+2006-03-22 Mike Kestner <mkestner@novell.com>
+
+ * MenuAPI.cs: only process Enter and arrow keypresses if the tracker
+ is active. Fixes #77870.
+
+2006-03-22 Alexander Olk <alex.olk@googlemail.com>
+
+ * FileDialog.cs: Corrected TabIndex order and set fileNameComboBox
+ to be focused/selected after startup
+
+2006-03-22 Alexander Olk <alex.olk@googlemail.com>
+
+ * ColorDialog.cs:
+ - Corrected behaviour of Color, AllowFullOpen, FullOpen,
+ CustomColors and ShowHelp properties
+ - Some internal rewrites to get better results when using the
+ ColorMatrix
+
+2006-03-22 Mike Kestner <mkestner@novell.com>
+
+ * ListView.cs: hook into Peter's new ResetMouseHover capability to fix
+ HoverSelection. Fixes #77836.
+
+2006-03-22 Mike Kestner <mkestner@novell.com>
+
+ * FileDialog.cs: bugfixes for the toolbar. Use PushButtons instead of
+ ToggleButtons. (De)Sensitize the Back button around a stack count of
+ 1, not 0. Update ButtonSize based on a pixel count of the win32
+ control. Adjust the toolbar size/location for new button size.
+
+2006-03-22 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: Don't handle configurenotifys if PostQuitState is
+ true.
+ * ScrollBar.cs: When doing increments and decrements we need to
+ set the Value property so that ValueChanged gets raised. A
+ possible optimization here would be to make an internal SetValue
+ that doesn't invalidate immediately.
+ * ToolTip.cs: Tooltips get added to their container (when
+ supplied) so they get disposed when the container is disposed.
+ - Don't create tooltips for String.Empty. This prevents all these
+ little 2-3 pixel windows from showing up when running nunit-gui
+ and driving me mad.
+ * Form.cs: Don't set topmost when setting the owner if the handles
+ haven't been created yet. The topmost set will happen when the
+ handles are created.
+
+2006-03-22 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs:
+ - DeriveWindowStyles: Fixed typo in borderstyle generation (#77828)
+ - SetVisible: Sending WINDOWPOSCHANGED for all controls when made
+ visible (to allow them to recalculate their sizes)
+
+2006-03-21 Mike Kestner <mkestner@novell.com>
+
+ * ThemeWin32Classic.cs: major refactoring of the ToolBar rendering
+ methods. Removed a ton of redundant code. Still not really happy with
+ the border rendering, but I think that's mainly because of the
+ ControlDarkDark being black instead of a dark grey. Depending on how
+ close we want to be, we might want to revisit those color choices.
+ Among the new features added during the refactor were DropDownArrow
+ pressed rendering, Disabled image rendering. Proper flat appearance
+ boundary rendering. Removed the Divider and Wrapping dividers since I
+ can't figure out any combination of themes and conditions to make the
+ MS control draw a horizontal line on a toolbar despite what the
+ Divider property docs indicate.
+ * ToolBar.cs: rewrite the layout engine. Fixes numerous flicker
+ conditions and incorrect layout. Updated to coding standard.
+ * ToolBarButton.cs: refactored layout and positioning code from
+ ToolBar to here. Invalidate wherever possible instead of forcing
+ redraws of the whole toolbar.
+ (Known remaining issues: explicit ButtonSize smaller than provided
+ images.)
+
+2006-03-21 Mike Kestner <mkestner@novell.com>
+
+ * ContextMenu.cs (Show): use the position parameter instead of just
+ showing at the MousePosition.
+
+>>>>>>> .r58288
+2006-03-21 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Remove the call to ProcessKeyEventArgs and let
+ control handle this.
+ * TreeNodeCollection.cs: If we are clearing the root node we need
+ to reset top_node so calcs can still happen.
+ * ThemeWin32Classic.cs: This is a Flags so we need to check
+ properly.
+
+2006-03-21 Jackson Harper <jackson@ximian.com>
+
+ * DataGrid.cs: Create columns when the binding context has been
+ changed.
+ * X11Structs.cs: Keysyms are uints.
+ - Add size to fix build.
+
+2006-03-21 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIX11.cs, XplatUIWin32.cs,
+ XplatUIOSX.cs:
+ - Added ResetMouseHover method to allow controls to retrigger
+ hovering if they need it more than once
+ - Implemented MouseHoverTime and MouseHoverSize properties
+ * Timer.cs: Start() must reset the interval
+ * SystemInformation.cs: Added 2.0 MouseHoverTime and MouseHoverSize
+ properties
+
+2006-03-21 Jackson Harper <jackson@ximian.com>
+
+ * X11Keyboard.cs: improved layout detection. Move the nonchar
+ tables into this file.
+ * KeyboardLayouts.cs: Move the tables into resource files.
+
+2006-03-21 Mike Kestner <mkestner@novell.com>
+
+ * ListView.cs: use OnItemActivated to raise events. Fixes #77834.
+
+2006-03-21 Alexander Olk <alex.olk@googlemail.com>
+
+ * Mime.cs: Various speed optimizations. Looking up mime types
+ is now 2 times faster than before
+
+2006-03-17 Peter Dennis Bartok <pbartok@novell.com>
+
+ * CreateParams.cs: Added internal menu field
+ * Control.cs:
+ - Switched call order for UpdateBounds; now we always call
+ the one that also takes ClientSize, and we're calculating the
+ client size via driver method in the others. The previous
+ method of tracking client size by difference wasn't working
+ for forms where even the starting client size wouldn't match
+ the overall form size (due to borders) (Part of fix for #77729)
+ - CreateParams(): Do not use parent.Handle unless the handle is
+ already created. Causes havoc with Nexxia and throws off our
+ creation of controls
+ * XplatUIX11.cs:
+ - Created new PerformNCCalc method to trigger WM_NCCALCSIZE message
+ - Switched handling of ConfigureNotify over to new PerformNCCalc
+ method (consolidates code)
+ - Changed RequestNCRecalc to use new PerformNCCalc method
+ - Added calls to RequestNCRecalc when menus and borders are changed
+ to allow app to set NC size. (Part of fix for #77729) This matches
+ when MS send a WM_NCRECALC on Win32 windows.
+ - Now sending WM_WINDOWPOSCHANGED when toplevel for is made visible
+ (Part of fix for #77729). This matches what MS does, they also
+ send that message when the form is made visible.
+ - XException.GetMessage: Improved usability of X errors by including
+ a translation of the window into Hwnd and Control class
+ - Improved debug info for window creation, reparenting and destruction
+ - Created helper method WindowIsMapped() [Currently not used]
+ * XplatUIWin32.cs: Added ToString() debug helper to RECT structure
+ * Form.cs:
+ - CreateParams: Now setting our menu on the new internal menu field
+ - SetClientSizeCore: Now passing cp.menu instead of ActiveMenu to
+ avoid calculating the same property twice
+ * Hwnd.cs:
+ - Improved usability of ToString() for debugging purposes
+ - GetWindowRectangle(): Now uses proper CalcMenuBarSize method to
+ determine the height of the menu, instead of just the font. This
+ required to also create a graphics context and to keep a bmp
+ around (for performance reasons)
+
+2006-03-17 Peter Dennis Bartok <pbartok@novell.com>
+
+ * MenuAPI.cs: Added OnMouseUp method
+ * Form.cs:
+ - Now remembering the requested client size, avoids size errors
+ - WndProc: Now handling WM_xBUTTONUP and passing it to MenuTracker
+ instead of base if the menu is active. This is required due to
+ control now capturing and releasing on down/up and it would
+ prematurely release our menu capture
+
+2006-03-17 Jackson Harper <jackson@ximian.com>
+
+ * KeyboardLayouts.cs: Add the czech layouts.
+
+2006-03-16 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Use the viewport space when sizing not the controls
+ client size, so things like ScrollableControl that effect the
+ viewport size (when scrollbars are added) are computed correctly.
+ * BindingContext.cs: Cleanup to use the DataSourceEntrys instead
+ of ManagerEntrys.
+ - Handle creating BindingManagers for null data sources.
+ * DataGrid.cs: Bind the cached_currencymgr_events to the real data
+ source, otherwise when rows are added they are added to the 'fake'
+ datasource and we will crash when trying to set the position in
+ those rows.
+ - Use Implicit scrollbars on the datagrid so they arent
+ selectable.
+
+2006-03-16 Jackson Harper <jackson@ximian.com>
+
+ * Binding.cs:
+ * InternalWindowManager.cs:
+ * MdiWindowManager.cs:
+ * X11Keyboard.cs: I really want Mike to love me again (fix
+ compiler warnings).
+
+2006-03-16 Peter Dennis Bartok <pbartok@novell.com>
+
+ * DataGrid.cs:
+ - OnMouseDown: Switch to editing mode when clicking on the cell
+ even if we're clicking on the cell that's currently
+ selected
+ - ProcessGridKey: Left/Right now wrap like MS.Net does
+ - ProcessGridKey: Tab now knows to add a new row when tab is
+ pressed in the cell of the last column of the
+ last row
+ - ProcessGridKey: Enter now adds another row if pressed in the last
+ row and selectes the new row, same column cell
+ - ProcessGridKey: Home/End navigate columns, not rows, like
+ originally implemented
+ - Broke ProcessKeyPreview code out into an extra Internal method
+ so it can be called from the edit code
+ * DataGridTextBox.cs (ProcessKeyMessage):
+ - Switched to accept Tab keypresses
+ - Added F2 handling to allow jumping to the end of the edited cell
+ - Added logic to allow moving caret left/right inside edited cell
+ and making the edited cell jump when the caret hits cell borders
+ - Tab and Enter are now passed to the datagrid after being handled
+ * TextBoxBase.cs:
+ - Removed capture code now that Control handles it
+ - set_SelectionStart now ensures caret is visible
+
+2006-03-16 Jackson Harper <jackson@ximian.com>
+
+ * TrackBar.cs: Debackwards the increment/decrement for handling
+ mouse clicks on the bar with vertical trackbars.
+ * ThemeWin32Classic.cs: Draw vertical trackbars with 0 at the
+ bottom to match MS.
+
+2006-03-16 Mike Kestner <mkestner@novell.com>
+
+ * ListView.cs: make shift/ctrl keyboard and mouse selection
+ consistent with the MS control. Fix a bug in
+ SelectedListViewItemCollection.Clear that was pissing me off for the
+ better part of a day because the collection was being altered
+ underneath us as we walked the list.
+
+2006-03-16 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs: Not sure how we could miss this so long, but it seems
+ that MS.Net has Capture set all the way from before calling
+ OnMouseDown through sending the mouse events until after
+ OnMouseUp. This will fix DataGrid's selection being set to end
+ at the location of the MouseUp.
+
+2006-03-15 Jackson Harper <jackson@ximian.com>
+
+ * BindingContext.cs: Check the binding after its added so that it
+ can initialize the binding managers and hookup to events.
+ * Binding.cs: Data members seem to sometimes include rows/cols in
+ the format Row.Column we now take this into account.
+ - Hookup to the position changed event so we can update the
+ control when the position has changed in the data set.
+ * CurrencyManager.cs: Take into account the row/col naming
+ convention when creating dataset tables.
+ * BindingContext.cs: Using a newer better way of storing
+ datasource/datamember pairs. Hopefully this better matches MS for
+ looking up binding managers.
+
+
+2006-03-15 Jackson Harper <jackson@ximian.com>
+
+ * BindingContext.cs: The currency manager needs the data member
+ name, if the member is a data set we use the name to find the
+ correct table.
+ * CurrencyManager.cs: When creating the list prefer an IList over
+ an IListSource.
+ - Attempt to create a DataTable from a DataSet (TODO: might need
+ some better error checking here, although MS doesn't seem to have much)
+ - If we have a DataTable create a view and use it as our list.
+
+2006-03-15 Mike Kestner <mkestner@novell.com>
+
+ * ListView.cs: keep a matrix of the icon mode layout to facilitate
+ keyboard navigation. Support Up/Down/Left/Right selection correctly
+ for all 4 View modes.
+ * ListViewItem.cs: add internal row/col fields for icon layouts.
+
+2006-03-15 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Redraw the tabs when we resize so their newly
+ calculated sizes are drawn on screen.
+ * X11Keyboard.cs: Begginnings of XIM support. We also now support
+ composite characters.
+ * XplatUIX11.cs: Keyboard driver needs to know about focus changes
+ - filter events so that composite characters can be created
+ patches by peter
+ * X11Structs.cs: Add XIMProperties enum.
+
+2006-03-14 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs (BringToFront, SendToBack): Don't use window or handle
+ unless it's created
+
+2006-03-14 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs (PerformLayout): We don't need to consider visiblity
+ for anchoring, only for docking. This fixes 'whacky' alignment
+ in listbox and other controls that use implicit scrollbars after
+ the previous PerformLayout patch
+ * ListBox.cs: Switched to use implicit scrollbars
+
+2006-03-14 Mike Kestner <mkestner@novell.com>
+
+ * ToolBar.cs:
+ * VScrollBar.cs:
+ - chain up the "new event" overrides to base and use
+ OnEvent to raise them. Part of fix for bug #76509.
+
+2006-03-14 Alexander Olk <alex.olk@googlemail.com>
+
+ * FileDialog.cs: Do not select an item in the parent directory
+ on backspace
+
+2006-03-14 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs (PerformLayout): It would seem that we considered
+ invisible windows for our layout. Not quite the right thing
+ to do. Now we don't any longer, thereby fixing bug #76889.
+
+2006-03-14 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs (CanFocus): I goofed. A control can have focus
+ even though it's not selectable. Made it match MS docs.
+
+2006-03-13 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ControlPaint.cs (DrawBorder3D): DrawBorder3D does not fill the
+ center by default (fixes #76895)
+ * ThemeWin32Classic.cs, ThemeNice.cs, ThemeClearlooks.cs: Replaced
+ all uses of Border3DSides.All with the explicit ORd together
+ Left|Right|Top|Bottom because I assume that nobody was aware
+ that All also implies a center fill. Most places I checked had
+ a fill right above.
+ * ProgressBarStyle.cs: Added
+
+2006-03-13 Mike Kestner <mkestner@novell.com>
+
+ * ListView.cs: fix breakage in drag shadow header positioning
+ from Peter's csc compilation fix.
+
+2006-03-13 Mike Kestner <mkestner@novell.com>
+
+ * ListView.cs: fix NRE produced by backspacing twice in a focused
+ FileDialog.
+
+2006-03-13 Mike Kestner <mkestner@novell.com>
+
+ * ListView.cs: proxy Key(Down|Up) from ItemControl to ListView.
+
+2006-03-13 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Hwnd.cs: Added fixed_size field to track windows whose size cannot
+ be changed
+ * XplatUIX11.cs: Now setting fixed_size on hwnd and if set, re-setting
+ the allowed size before making programmatic size changes
+
+2006-03-13 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs: Don't call XSetWMNormalHints if no flags are
+ set, metacity is broken and will still use the emty sizes in
+ the struct. (Fix for #77089)
+
+2006-03-13 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIStructs.cs: Split WindowStyles into WindowStyles and
+ WindowExStyles and marked both enums as Flags
+ * Form.cs, ComboBox.cs, ToolTip.cs, Control.cs, PropertyGridView.cs,
+ NotifyIcon.cs, MenuAPI.cs, XplatUIOSX.cs, MonthCalendar.cs: Updated
+ to match WindowStyles split
+ * XplatUIX11.cs:
+ - SetWMStyles: Added cehck to not apply WM attributes to Child windows
+ - Updated to match WindowStyles split
+ * XplatUIWin32.cs:
+ - Fixed FosterParent creation, was using ExStyle on the Style field
+ (This should help with Popup focus issues)
+ - Updated to match WindowStyles split
+
+2006-03-13 Jackson Harper <jackson@ximian.com>
+
+ * MdiWindowManager.cs: Use the system menu height. Fixes some
+ strange sizing issues.
+
+2006-03-12 Peter Dennis Bartok <pbartok@novell.com>
+
+ * RichTextBox.cs: Need to scroll to caret after text is inserted (#77672)
+ * TextBoxBase.cs:
+ - Scroll to caret after inserting text (#77672)
+ - Make scroll range one pixel higher, fixes off-by-one error (and
+ makes underlines visible on the last line)
+
+2006-03-12 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs: Added call to new Keyboard.ResetKeyState to prevent
+ the keyboard state from being stuck with keys in 'pressed' state when
+ focus is switched away via keyboard
+ * X11Keyboard.cs: Added new ResetKeyState method to allow drivers to
+ reset the keyboard if no X11 KeyUp events are expected to come
+ * X11Structs.cs: Switched type of Visible to bool to match driver
+
+2006-03-12 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextControl.cs:
+ - Switched caret to be just 1 pixel wide, matches MS and looks less
+ clunky
+ - Moved caret display 1 pixel down from the top of the control
+ to improve view
+ - InsertCharAtCharet: Update the selection start if moving the caret
+ (fixes bug #77696; based on patch suggested by kazuki@panicode.com)
+ - No longer always creating the caret when the caret methods are
+ called. Only the actual ShowCaret/HideCaret will do that now
+ - Only setting caret visible if the owner control has focus
+ - UpdateView: Added invalidation-shortcut logic for center and right
+ aligned text. Previously we'd update all according to the left
+ logic which caused drawing errors. Also fixed height of invalidated
+ areas, now properly invalidating the whole area (was off-by-one)
+ - owner_HandleCreated: Always generate the document when the
+ handle is created; this ensures that
+ * TextBoxBase.cs:
+ - Fixed situation where caret would disappear under the right
+ window border, also improved scrolling behaviour on left-
+ aligned textboxes
+ - Fixed right-aligned textboxes to have a border to the
+ right instead of the caret being under the right border
+ * XplatUIX11.cs:
+ - Switched from 'nested' to simple visible/not visible tracking
+ for caret (part of fix for #77671)
+ - No longer passing through translated FocusIn/FocusOut messages
+ since we were notifying too often and the wrong windows. Instead
+ we just notify our focussed window of receiving or loosing focus
+ * XplatUIWin32.cs: Switched from 'nested' show/hide
+ counting for caret to simple visible yes/no behaviour (part of
+ fix for #77671)
+
+2006-03-11 Alexander Olk <alex.olk@googlemail.com>
+
+ * Mime.cs: Remove debug code...
+
+2006-03-11 Alexander Olk <alex.olk@googlemail.com>
+
+ * MimeGenerated.cs: Removed
+ * Mime.cs: Mime now reads the mime data (magic, globs, aliases
+ and subclasses) from /usr/(local/)share/mime and
+ $HOME/.local/share/mime.
+
+2006-03-10 Jackson Harper <jackson@ximian.com>
+
+ * MdiWindowManager.cs: Recalc the NC area when a window is
+ maximized/restored so that the menu area is drawn on forms that
+ don't have a menu.
+
+2006-03-10 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIOSX.cs, XplatUIWin32.cs,
+ XplatUIX11.cs: Added RequestNCRecalc method to driver to allow
+ us to force a WM_NCCALCRESIZE message being sent. This is needed
+ for MDI maximizing.
+
+2006-03-10 Jackson Harper <jackson@ximian.com>
+
+ * Form.cs: We need to use the ActiveMenu when calculating menu
+ height.
+ - Fix nullref when the window manager hasn't been created yet.
+ * Control.cs: Fix nullref when we try to bring a control to the
+ front that has no parent.
+ * MdiWindowManager.cs: Use the MaximizedMenu for calculating
+ height.
+ - Add a dummy item to the maximized menu so it always has the
+ correct height. Otherwise when there are no menus we don't get our
+ icon and buttons.
+
+
+2006-03-10 Jackson Harper <jackson@ximian.com>
+
+ * MenuAPI.cs: Make this available elsewhere. I need it in some MDI
+ stuff.
+ * Form.cs: Make the window_state internal so the window managers
+ can track it.
+ - When an MDI child is maximized let its window manager create the
+ main menu (so it can add its icon).
+ - Notify the window managers of state changes
+ - Let the window manager paint its buttons and handle button
+ clicks on the menu when it is maximized.
+ * InternalWindowManager.cs: Move the prev_bounds into the mdi
+ window manager, since tool windows don't use it, only mdi windows.
+ - Tell the main form that we don't want it to handle NCPAINT
+ itself to avoid extra painting.
+ - Handle clicks on a maximized windows menu.
+ - Handle window state changes
+ - Handle minimize/maximize clicks correctly by setting the window state.
+ * MdiWindowManager.cs: Add an icon menu that (the menu you get
+ when clicking on the forms icon).
+ - New method to create a forms maximized menu. This is its normal
+ menu + an icon.
+ - Handle window state changes.
+ - Handle sizing of maximized windows. Maximized windows are just
+ drawn bigger then the parent visible area. All controls are still
+ there, they are just outside the visible area (this matches windows).
+ * MdiClient.cs: No scrollbars when a child window is maximized.
+ - Let the children windows figure out how big they should be when
+ sizing maximized windows.
+ - Implement a version of ArrangeIconicWindows somewhat similar to
+ Windows version. There are some little differences, but I don't
+ think any app will rely on the layout of minimized mdi windows.
+
+2006-03-10 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Padding.cs: Several fixes to allow compiling with csc 2.0
+
+2006-03-09 Jackson Harper <jackson@ximian.com>
+
+ * Menu.cs:
+ * MenuItem.cs: Cheap hack so we can add items to the list without
+ the events being raised. This allows adding mdi items during
+ drawing. TODO: Should probably find a better time to add the items.
+
+2006-03-10 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ThemeWin32Classic.cs:
+ - CheckBox_DrawText: Added logic to not wrap if not enough space
+ is available (Fix for bug #77727)
+ - RadioButton_DrawText: Added logic not to wrap if not enough
+ space is available (Fix for bug #77727). Also removed some
+ duplicate code, DrawString always drawing the regular text
+ before hitting the if statement.
+
+2006-03-10 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs: Handle an unmapped window state in SetWindowState
+
+2006-03-10 Peter Dennis Bartok <pbartok@novell.com>
+
+ * PictureBox.cs: Implemented ISupportInitialize interface (fixes #77726)
+ * ContainerControl.cs: Partial implementation of some 2.0 scaling
+ methods. Moved the new 2.0 properties into alphabetical order with
+ other properties and added MonoTODO tags
+
+2006-03-09 Peter Dennis Bartok <pbartok@novell.com>
+
+ * AutoScaleMode.cs: Added. Fix build.
+
+2006-03-09 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIX11.cs, XplatUIWin32.cs,
+ XplatUIOSX.cs: Removed HWnd argument from CalcuateClientRect, not used
+ and was requiring premature handle creation for calls from above
+ * Form.cs, Control.cs: Removed handle arguments from calls to
+ CalculateClientRect()
+
+2006-03-09 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ListView.cs (HeaderMouseMove): Fix csc compilation.
+ drag_column.column_rect is MarshalByRef and can't be used that way
+
+2006-03-09 Peter Dennis Bartok <pbartok@novell.com>
+
+ * AxHost.cs: Added deserialization constructor for
+ AxHost+State (fixes 77743)
+
+2006-03-09 Mike Kestner <mkestner@novell.com>
+
+ * ListView.cs:
+ - Added column drag reordering for details view.
+ - fixed behavior when mouse is dragged off column and
+ AllowColumnReorder is false.
+ * ColumnHeader.cs: clone the format too in Clone.
+ * Theme.cs: add DrawListViewHeaderDragDetails method.
+ * ThemeWin32Classic.cs:
+ - impl new method for drawing drag column shadows and targets.
+ - support column offset for details mode in DrawListViewItem.
+
+2006-03-09 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextControl.cs: Reset the char_count when the document is cleared
+ (Fixes bug reported on mono-winforms mailing list)
+
+2006-03-09 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextBoxBase.cs: Honor the Handled state of KeyPress events. Instead
+ of calling base we simply process the key ourselves, since both
+ DefWindowProc and the handled method would set m.Result.
+ (Fixes #77732)
+
+2006-03-09 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Form.cs(ScaleCore): No longer calling base.ScaleCore since that
+ method also moves the window; instead implemented a copy of
+ Control.ScaleCore (Part of fix for #77456)
+ * TextBoxBase.cs:
+ - Created new CreateGraphicsInternal method to allow providing
+ a graphics context when no handle is created without triggering
+ handle creation. (Part of fix for #77456)
+ - Replaced use of Control.CreateGraphics with CreateGraphicsInternal
+ * TextControl.cs:
+ - Switched Constructor to require TextBoxBase instead of Control (to
+ allow uncast access to CreateGraphicsInternal)
+ - Safeguarded use of owner.Handle property. No longer accessing it
+ unless the handle is already created.
+ - Replaced use of Control.CreateGraphics with CreateGraphicsInternal
+ - Now triggering a recalc when owning control becomes visible
+ * TextBox.cs, RichTextBox.cs: Switched to use new internal
+ TextBoxBase.CreateGraphicsInternal() method to avoid triggering
+ premature handle creation (Part of fix for #77456)
+ * Control.cs:
+ - We now only destroy our double-buffering buffers when the
+ control is resized or disposed, but not when visibility
+ changes. (The code even re-created them twice every time)
+ - Now requiring a redraw of the buffer on visibility changes
+ (fixes bug 77654 part 2)
+ - Not passing OnParentVisibleChanged up unless the control
+ is visible
+ - CanFocus: Fixed to match MS documentation
+ - Focus: Fixed to return actual focus state and to check if
+ setting focus is legal before setting it
+
+2006-03-08 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ThemeWin32Classic.cs: TabPages cannot have focus. Determine
+ when to draw focus rectangle by looking at parent focus and
+ selected state instead. This fixes TabPages on Linux sometimes
+ having none or multiple focus rectangles.
+ * XplatUIX11.cs (SetFocus):
+ - Don't set the focus if the same window already has focus
+ - Use SendMessage instead of PostMessage (like it's Win32
+ equivalent) and send the WM_SETFOCUS before the WM_KILLFOCUS
+ to match MS behaviour
+ * TabControl.cs(SelectedIndex): Don't set Focus on TabPage, TabPages
+ are not selectable.
+
+2006-03-07 Jackson Harper <jackson@ximian.com>
+
+ * PictureBox.cs: Revert line I accidently committed last week.
+
+2006-03-07 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - Added new IsRecreating and ParentIsRecreating properties to
+ allow testing if RecreateHandle has been called on ourselves
+ or one of our parents
+ - WndProc(WM_DESTROY): If our control handle is being recreated
+ we immediately need to create the handle when receiving the
+ destroy, that way our child windows find a valid parent handle
+ when they themselves are being recreated upon WM_DESTROY receipt
+ (fix for bug #77654 part 1)
+ * XplatUIX11.cs:
+ - DestroyWindow: WM_DESTROY must be sent to our own window before
+ notifying any child windows. MS documents that child windows
+ are still valid when WM_DESTROY is received. (Control now relies on
+ this behaviour)
+ - Added some fine-grain debug options
+
+2006-03-06 Jackson Harper <jackson@ximian.com>
+
+ * MdiClient.cs: Redid scrolling logic a bit to create a virtual
+ box and base calculations off this.
+ * MdiChildContext.cs:
+ * MdiWindowManager.cs: Don't need to ensure scrollbars here
+ anymore.
+
+2006-03-06 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Splitter.cs: In situations where the affected control is added
+ to the parent's control list after the splitter, we would not
+ populate affected. Now we try populating it on mousedown, if
+ it's not already set, and force it to be re-set whenever our
+ parent changes.
+
+2006-03-03 Matt Hargett <matt@use.net>
+
+ * Control.cs: implement Control.Padding
+ * Padding.cs: -Padding.All returns -1 when constructing with the
+ implicit default ctor
+ -Padding.ToString() matches MS.NET
+ * ContainerControl.cs: implement
+ ContainerControl.AutoScaleDimensions
+ * ListControl.cs: implement ListControl.FormattingEnabled
+ * TextBox.cs: Implemented TextBox.UseSystemPasswordChar.
+ * ButtonBase.cs:
+ * TabPage.cs: Implement UseVisualStyleBackColor.
+ * PictureBox.cs: Implement PictureBox.InitialImage.
+
+2006-03-03 Mike Kestner <mkestner@novell.com>
+
+ * ListView.cs: Refactor into HeaderControl and ItemControl. Fix new
+ event declarations to proxy to base event.
+ * ListViewItem.cs: update to use ItemControl.
+ * Theme.cs: make DrawListViewHeader. s/DrawListView/DrawListViewItems.
+ * ThemeWin32Classic.cs: update to new ListView theme API and fix
+ column header label rendering for 0 width columns.
+
+2006-03-03 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs (ControlCollection.SetChildIndex): Avoid using a call
+ that causes the control to be created. Fixes #77476.
+
+2006-03-02 Jackson Harper <jackson@ximian.com>
+
+ * Hwnd.cs: Clear the nc pending when clearing the NC area, not the
+ expose_pending.
+
+2006-03-02 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs: Implemented 2.0 feature where OnClick has MouseEventArgs
+ passed in for the EventArgs (fixes #77690)
+
+2006-03-01 Jackson Harper <jackson@ximian.com>
+
+ * ScrollBar.cs: Refresh afterbeing resized.
+
+2006-02-28 Mike Kestner <mkestner@novell.com>
+
+ * MenuAPI.cs: Call PerformPopup internal method to emit Popup.
+ Clean up a tracker compile warning.
+ * MenuItem.cs: add internal PerformPopup method.
+ [Fixes #77457]
+
+2006-02-28 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextBoxBase.cs (set_Text): Recalculate the document (causing an
+ implicit expose) when the text is set to null
+
+2006-02-28 Peter Dennis Bartok <pbartok@novell.com>
+
+ * RichTextBox.cs (FlushText): When newline is true, we always
+ need to split the line, even if no text is on it and we may
+ never eat newlines. (Fixes #77669)
+
+2006-02-28 Mike Kestner <mkestner@novell.com>
+
+ * ListView.cs: Add UpdateSelection internal method. Remove SelectItem
+ and set Selected instead.
+ * ListViewItem.cs: Call owner.UpdateSelection to manipulate the
+ collections.
+
+2006-02-28 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ComboBox.cs: Allow setting SelectedIndex to -1. Fixes #77665
+
+2006-02-28 Alexander Olk <alex.olk@googlemail.com>
+
+ * FontDialog.cs:
+ - Got rid of the panel. All controls are now directly added to
+ the dialog form
+ - It is now possible to set a font with the Font property
+ - MinSize and MaxSize property do now what they should
+ - ShowApply, ShowHelp, ShowColor, ShowEffects likewise
+ - Searching and selecting a font with the font textbox works now,
+ the same applies to the style and size textbox
+ - Draw the correct 3D border in the example panel
+ - Fixed a little mem leak (unused fonts didn't get disposed)
+ - Many other internal updates/rewrites...
+ - Fix typo
+
+2006-02-27 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextControl.cs:
+ - InsertRTFFromStream: Added 'number of characters inserted' argument
+ - set_SelectedRTF: Now using the number of characters to calculate
+ the new location for the selection and cursor (x/y cannot be used
+ due to potentially already wrapped text)
+
+2006-02-27 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextControl.cs: Added property and implemented means to allow
+ disabling recalculation of a document (can be used to speed up
+ multiple inserts and is needed to make RTF inserts predictable, see
+ bug #77659)
+ * RichTextBox.cs: Using the new NoRecalc property of Document to
+ keep x/y insert locations predictable. Also makes it faster inserting
+ large chunks of RTF
+
+2006-02-27 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs: Separated special WM_SYSKEYUP keyboard handling. That way
+ it's easier for a child control to handle the other messages without
+ having to duplicate the special functionality
+ * TextBoxBase.cs
+ - WndProc: Removed calling base handler for WM_KEYDOWN and added
+ code to handle processing the key ourselves, in order to get
+ access to the result of KeyEventArgs.Handled. We now only call
+ ProcessKey if they key hasn't been handled already. Fixes #77526.
+ - set_Text: If null or empty string is given, just clear the
+ document. Fixes part of #77526
+
+2006-02-27 Jackson Harper <jackson@ximian.com>
+
+ * SizeGrip.cs: Paint the background color before painting the grip
+ so things look right.
+ * MdiClient.cs: Add the sizegrip when both scrollbars are used.
+
+2006-02-27 Mike Kestner <mkestner@novell.com>
+
+ * ListView.cs:
+ - Restructure layout and invalidation model to remove a ton of
+ flicker from the control and speed up performance in general.
+ - Add manual column resize, flickers like crazy, but I already have
+ some ideas on how I'll fix that. (#76822)
+ - Merge the three Icon-based views into a single layout method.
+ - Move item selection interaction logic from the item since
+ interaction with the collections is more appropriate to the view.
+ - Deselection on non-item clicks.
+ * ListViewItem.cs:
+ - Encapsulate most of the layout. Add some internal props to trigger
+ layout. Move to a model where Items invalidate themselves instead
+ of just invalidating the whole control every time something changes.
+ - Invalidate on Text/Caption changes.
+ - switch to an offset based layout model to avoid having to absolute
+ position every element on item moves.
+ - correct checkbox layout to conform to MS layout.
+ * ThemeWin32Classic.cs:
+ - refactor some column header drawing code.
+ - fix string justification for column headers (#76821)
+ - make SmallIcon labels top justified for compat with MS impl.
+ * ThemeClearlooks.cs:
+ - adjust to new ListViewItem internal checkbox bounds api.
+
+2006-02-27 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Change where implicit controls fall in the zorder.
+ They are now on top of all children.
+ - Synced AddImplicit code with Add
+ - Removed unused enumerator.
+ * SizeGrip.cs: Remove the TODO as its been TODONE.
+
+2006-02-26 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextControl.cs(Insert): Combine the last lines unless the insertion
+ string ends with \n\n, otherwise we leave one line too many (Fixes
+ something I noticed with the testapp for #77526; the bug itself was
+ already fixed in the previous checkin)
+
+2006-02-26 Peter Dennis Bartok <pbartok@novell.com>
+
+ * RichTextBox.cs:
+ - SelectionColor and SelectionFont methods no longer set absolute
+ styles. Instead, the keep font or color respectively (This
+ resolves a long-standing FIXME in the code)
+ - When flushing RTF text, the insert code now considers text trailing
+ behind the insertion point (Fixes the bug where when replacing
+ the selected text via SelectedRTF the remainder of the line behind
+ the selection would stay on the first insertion line)
+ * TextBoxBase.cs:
+ - AppendText now updates the selection points after inserting text
+ - AppendText now ensures that the last tag (sometimes 0-length) of
+ the document is used for the style information (Fixes part of
+ bug #77220)
+ * TextControl.cs:
+ - Created new FontDefiniton class to allow describing partial style
+ changes
+ - StreamLine() now takes a lines argument, to allow it to decide
+ whether an encountered zero-length tag is the last in the document
+ (which must be kept to not loose the font/color contained in it,
+ for later appends)
+ - Created Combine() and Split() methods for Marker structs, to
+ support marker updates due to reformatted documents (soft line
+ wraps)
+ - Implemented Document.CaretTag setter
+ - Fixed MoveCaret(CtrlEnd) handling, now moves to the last character
+ of the last line (Not the cause, but also exposed by bug #77220)
+ - Added LineTag argument to InsertString method, to allow callers
+ to force a certain tag to be used (required to force use of the
+ trailing zero-length tag of a document)
+ - Now updating markers in Combine(), to avoid stale tag markers
+ - Added some method descriptions to aid maintenance
+ - Implemented new FormatText concept, allowing additive/subtractive
+ formatting by only specifying the components that are to be
+ changed. This was needed for resolving the RTB.SelectedColor/
+ RTB.SelectedFont fixmes
+ - Added Break() support method to allow breaking up linetags (used
+ for partial formatting)
+ - Added GenerateTextFormat() method. It is used for partial
+ formatting and allows to generate a full font/color from given
+ attributes and an existing tag.
+
+2006-02-26 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: Use the correct caption height.
+ - Translate hittest coordinates to screen coords to match MS.
+ * XplatUIWin32.cs: When we create MDI windows we need to reset
+ some of the style flags, so we get a nice blank window, and can
+ draw all the decorations ourselves.
+ - Set a clipping rectangle on the non client paint event, the
+ window manager drawing code needs one.
+ * Form.cs: The window manager needs to know when the window state
+ has been updated.
+ * Hwnd.cs: The window manager stuff now does a proper NCCALC so we
+ don't need to factor in border and title sizes in these
+ methods. TODO: Remove the args and fix the call points.
+ * InternalWindowManager.cs: Handle NCHITTEST and NCCALCAREA
+ properly.
+ - Let the driver set the cursors.
+ - Improve active window handling
+ - Correct sizes for title bars and buttons.
+ - Match MS drawing better
+ * MdiWindowManager.cs: We don't need to handle border style
+ updates specially anymore.
+ - Check for scrollbars when windows are done moving
+ - Handle Active properly.
+ * MimeIcon.cs: Don't crash when we can't load the GNOME stuff
+ correctly. I am spewing the exception though, so we don't hide the
+ bugs.
+
+2006-02-26 Pedro Martinez Julia <pedromj@gmail.com>
+
+ * DataGridViewRowPostPaintEventArgs.cs,
+ DataGridViewCellPaintingEventArgs.cs,
+ DataGridViewRowCollection.cs,
+ DataGridViewRowPrePaintEventArgs.cs,
+ DataGridViewCell.cs: Clear a few warnings and implement a few
+ exceptions that should be thrown.
+
+2006-02-22 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ScrollBar.cs (ctor): Explicitly set a cursor to avoid
+ 'inheriting' our parent's (non-default) cursor. (Part of
+ the fix for #77479)
+
+2006-02-22 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs: Fixed cast to make csc happy
+
+2006-02-22 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs (WndProc): Only handle WM_SETCURSOR messages if
+ it's for the client area (part of fix for #77479 and needed
+ for MDI window cursor handling)
+ * XplatUIX11.cs
+ - DefWindowProc: Now handles the WM_SETCURSOR messages, setting
+ the appropriate default cursors and also passing the message
+ up the parent chain
+ - GetMessage: Now generating WM_NCHITTEST and WM_SETCURSOR even
+ for non-client areas
+
+2006-02-15 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIWin32.cs: Since we fake MDI dont tell Windows that this
+ is a real MDI window
+
+2006-02-14 Alexander Olk <alex.olk@googlemail.com>
+
+ * X11DesktopColors.cs: Instead of checking the desktop session
+ string for "KDE" check if it starts with "KDE"
+
+2006-02-10 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: These should be unsigned (fixes crash on 32 bit
+ systems).
+
+2006-02-10 Alexander Olk <alex.olk@googlemail.com>
+
+ * FileDialog.cs: Added Refresh to RunDialog to fix some drawing
+ errors
+ * ColorDialog.cs:
+ - Got rid of the panel. All controls are now directly added to
+ the dialog form
+ - Changed to mono coding style
+
+2006-02-10 Jackson Harper <jackson@ximian.com>
+
+ * InternalWindowManager.cs: We don't need the set visibility to
+ false hack anymore now that peter has written beautiful shutdown
+ code.
+
+2006-02-10 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs: Ignore DestroyNotify messages for windows that
+ where already explicitly destroyed
+
+2006-02-10 Jackson Harper <jackson@ximian.com>
+
+ * MdiClient.cs: Handle the case where windows are too high or to
+ the left and we need scrollbars.
+
+2006-02-10 Alexander Olk <alex.olk@googlemail.com>
+
+ * MimeIcon.cs: Added some icons
+ * FileDialog.cs:
+ - Fixed bug #77477
+ - Got rid of the panel. All controls are now directly added to
+ the dialog form
+ - Changed to mono coding style
+ - On Linux "My Computer" and "My Network" will now show some
+ more usefull information. A new class, MasterMount, gathers
+ this information from /proc/mount. Updated MWFFileView to make
+ use of this information
+ - Fixed a bug that caused FileDialog to crash when
+ ".recently_used" file had a zero size
+ - FilterIndex does now what it should
+ - Some Refactoring
+ * OpenFileDialog.cs, SaveFileDialog.cs: Updated to reflect latest
+ FileDialog changes
+
+2006-02-09 Jackson Harper <jackson@ximian.com>
+
+ * ComboBox.cs: Don't touch if null.
+
+2006-02-09 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Cursor.cs: 64bit safeness fix
+ * XplatUIX11.cs: Removed several unneeded and one moronic cast.
+
+2006-02-09 Jackson Harper <jackson@ximian.com>
+
+ * Form.cs: If a form is made into an MDI form update the styles so
+ all the props can get set correctly.
+ - Kill the mdi_container when we dont need it anymore.
+ * InternalWindowManager.cs: Add missing NOT
+
+2006-02-08 Jackson Harper <jackson@ximian.com>
+
+ * InternalWindowManager.cs: Respek clipping when drawing MDi
+ decorations.
+
+2006-02-08 Jackson Harper <jackson@ximian.com>
+
+ * Hwnd.cs: Add bits to track non client expose events.
+ * XplatUIX11.cs: Track non client expose events on the hwnd. This
+ gives us a proper invalid rect and will allow for some nice
+ optimizations with NC client drawing
+ - MDI windows are children windows, so move their style handling
+ into the child window block.
+ * InternalWindowManager.cs: Remove a state reset that was
+ getting invoked at the wrong time. Fixes managed windows getting
+ into a 'stuck' captured state.
+
+2006-02-07 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextControl.cs (Document.ctor): Now initializing
+ selection_anchor. Fixes #77493
+
+2006-02-07 Jackson Harper <jackson@ximian.com>
+
+ * TrackBar.cs: The increment/decrements were backwards.
+
+2006-02-07 Mike Kestner <mkestner@novell.com>
+
+ * Theme*.cs : remove ThemeEngine.Current usage as it just points back
+ to the instance itself.
+
+2006-02-07 Peter Dennis Bartok <pbartok@novell.com>
+
+ * X11DesktopColors.cs, ThemeGtk.cs: The GObject structure is based
+ on ulongs and pointers, the size differs between 32bit and 64bit
+ systems.
+
+2006-02-07 Mike Kestner <mkestner@novell.com>
+
+ * XplatUIX11.cs : force the WorkingArea away from XGetWindowProperty
+ for 64 bit platforms to work around a metacity bug.
+
+2006-02-07 Jackson Harper <jackson@ximian.com>
+
+ * TrackBar.cs: Process the input keys we need, and hookup to
+ KeyDown instead of using WndProc, so we get key messages.
+
+2006-02-06 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs: Atoms are only 32bit on the wire, no matter what
+ machine we're on.
+ * X11Dnd.cs(SetAllowDrop): Since atoms are always 32bit on the wire
+ we need to translate the XdndVersion atoms array before sending it
+
+2006-02-06 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs:
+ - The preceeding 64bit fixes had a bug: ChangeProperty expects the
+ number of bits for the property, not the number of bytes. The
+ change to provide IntPtr.Size broke 32bit. (64bit was also wrong
+ but would not crash since it specified 8 bits instead of 4 bits)
+ - More 64bit fixes: Switched all atoms from int to IntPtr (they are
+ defined as XID -> long in the C headers)
+ - Removed 'new IntPtr((int))' and '(IntPtr)' casts from all NetAtoms
+ references since those are now IntPtr to begin with
+ - Switched all Atom.XXX 'int' casts to IntPtr casts
+ - Fixed XGrabPointer DllImport signature to work for 64bit (cursor arg)
+ - Fixed XInternAtom signature for 64bit, now returns an IntPtr
+ - Added XChangeActivePointerGrab DllImport (for X11DnD)
+ * X11Structs.cs:
+ - Changed 'int' type for Atoms in XEvent structures to IntPtr
+ - Changed atom in HoverStruct to be IntPtr
+ * X11DnD.cs:
+ - Removed local DllImports, switched code to use those from XplatUIX11
+ - Removed/fixed casts related to the switch of Atom to be a IntPtr
+
+2006-02-06 Mike Kestner <mkestner@novell.com>
+
+ * XplatUIX11.cs : many more 64 bit pinvoke changes. I've audited all the
+ method signatures in the import region. There may still be some
+ lingering struct marshaling issues, as I didn't drill down into those.
+ Yet.
+
+2006-02-06 Jackson Harper <jackson@ximian.com>
+
+ * ComboBox.cs: Dont manually set the top_item, this is computed
+ when the scrollbar position is set.
+
+2006-02-06 Mike Kestner <mkestner@novell.com>
+
+ * XplatUIX11.cs : 64 bit changes to XGetWindowProperty usage. Fixes
+ startup crashes on amd64. There's other fixes needed. All pinvoke
+ usage of Atom needs to be mapped to IntPtr for example. And there are
+ likely other int/long issues to be addressed.
+
+2006-02-04 Alexander Olk <alex.olk@googlemail.com>
+
+ * FileDialog.cs: One more...
+
+2006-02-03 Alexander Olk <alex.olk@googlemail.com>
+
+ * FileDialog.cs: Next try
+
+2006-02-03 Alexander Olk <alex.olk@googlemail.com>
+
+ * FileDialog.cs: First part of fix for #77464
+
+2006-02-03 Alexander Olk <alex.olk@googlemail.com>
+
+ * ButtonBase.cs, ContainerControl.cs, Forms.cs,
+ ThemeWin32Classic.cs: Fix for #77458. Correct handling of
+ AcceptButton border drawing.
+
+2006-02-03 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Form.cs: Moved positioning of form after auto scaling is applied,
+ otherwise it would possibly use wrong form size.
+
+2006-02-03 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs (RecreateHandle): No need to re-create any child
+ controls, the child windows will get destroyed automatically by
+ the windowing system or driver, and re-created when the handle
+ is being accessed the first time. Fixes #77456
+ * Form.cs: No longer setting the form to closing if the handle is
+ being recreated. This seems like the right thing to do, don't
+ have a bug or testcase for this, though.
+
+2006-02-02 Peter Dennis Bartok <pbartok@novell.com>
+
+ * FileDialog.cs: Suspend/Resume layouting when changing sizes of
+ controls to avoid unwanted side effects
+
+2006-02-02 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - ScaleCore needs to scale the bounds, not the ClientSize of the
+ control. Fixes #77416.
+ - DefaultSize is 0,0 for control
+ * TextBoxBase.cs:
+ - DefaultSize is 100, 20
+ - SetBoundsCore: Now enforcing the height, no matter if the provided
+ height is more or less than the preferred one, as long as AutoSize
+ is on
+ * Form.cs: Apply documented fudge factor. Part of item 3 fix for #77416
+
+2006-02-02 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - ResumeLayout: Fixed logic when to call PerformLayout, we may not
+ call unless both performLayout is true *and* we have a pending
+ layout change
+ - ResumeLayout: MS does not completely nest Suspend and Resume,
+ they bottom out at 0, fixed our code to match that.
+ - UpdateBounds/SetBoundsCore: Moved calling of UpdateDistances() to
+ SetBoundsCore, we were updating even when we shouldn't. This fixes
+ swf-anchors mis-anchoring when resizing the app fast and lots.
+ - UpdateDistances: Now only setting the left and top distance if
+ we have a parent and are not suspended, this is based on
+ a suggestion by Don Edvaldson in bug #77355.
+ - OnVisibleChanged: Fixed logic when to create the control. We may
+ not create the control if we have no parent or if it's not visible;
+ switched to using Visible property instead of is_visible field
+ since the property also considers parent states. This fixes a bug
+ when starting Paint.Net
+
+2006-02-02 Jackson Harper <jackson@ximian.com>
+
+ * Form.cs: If the forms handle hasn't been created yet don't call
+ into xplatui to make it top most, just set the topmost flag on the
+ form in CreateParams
+ * XplatUIX11.cs: Handle WS_EX_TOPMOST.
+
+2006-02-01 Jackson Harper <jackson@ximian.com>
+
+ * ScrollableControl.cs: Refactored the Recalculate method a
+ little, this wasn't handling all the variants of bottom and right
+ bars needed to be added and added/removed based on their
+ counterparts being added/removed (which changes the drawable
+ size). Also we special case client widths and heights of 0 and
+ don't add the scrollbar for those.
+
+2006-02-01 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs:
+ - Added method to get AbsoluteGeometry(); currently unused, but might
+ be used in the future, if we try again to figure out toplevel
+ coordinates with some more crappy window managers
+ - Added FrameExtents() method to retrieve the WM set decoration size
+ - Tried to fix up AddConfigureNotify and handling of ReparentNotify
+ to deal with at least KDE, FVWM and metacity (Fixes #77092)
+ * Hwnd.cs:
+ - Added whacky_wm tracking var for metacity
+ - Added logic to have default menu height if the actual menu height
+ has not yet been calculated (part of fix for #77426)
+ * Form.cs: Keep track whether client size has been set and re-set
+ it if a menu is added/removed afterwards (Fixes #77426)
+
+2006-01-31 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: When a new Site is set on the component attempt to
+ pull the AmbientProperties from it.
+
+2006-01-31 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ThemeWin32Classic.cs: Menu background is drawn in ColorMenu, not
+ in the background of the owning form. Fixes #77332
+
+2006-01-31 Alexander Olk <alex.olk@googlemail.com>
+
+ * MimeIcon.cs: Fix for #77409
+
+2006-01-31 Alexander Olk <alex.olk@googlemail.com>
+
+ * XplatUIX11GTK.cs: Initial import
+
+2006-01-31 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * FixedSizeTextBox: fixes class signature
+
+2006-01-30 Jackson Harper <jackson@ximian.com>
+
+ * FixedSizeTextBox.cs: New internal class that represents a
+ textBox that will not be scaled.
+ * TreeView.cs:
+ * ComboBox.cs:
+ * UpDownBase.cs: Use the new FixedSizeTextBox instead of a
+ standard TextBox.
+
+2006-01-30 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs: Retrieve default screen number instead of
+ assuming 0. Attempted fix for #77318
+
+2006-01-30 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIWin32.cs:
+ - GetWindowPos: When a window is parented by FosterParent, use
+ the desktop instead of FosterParent as the base to get coordinates
+ - CreateWindow: Don't make FosterParent the parent window for Popups
+ if we don't want a taskbar entry, Popups automatically don't get one
+ * Hwnd.cs: Need to call remove to actually remove the key from the
+ hash table
+
+2006-01-30 Mike Kestner <mkestner@novell.com>
+
+ * MenuAPI.cs: adjust MainMenu item popup location to y=0.
+
+2006-01-30 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs:
+ * TreeNode.cs: Raise events no matter how the treenode is
+ checked. Patch by Don Edvalson.
+
+2006-01-30 Jackson Harper <jackson@ximian.com>
+
+ * TreeNode.cs: Signature fix.
+
+2006-01-29 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeClearlooks.cs: Fixed a crash in ProgressBar drawing.
+
+2006-01-20 Mike Kestner <mkestner@novell.com>
+
+ * Form.cs: Add ActiveTracker property to do Captures and perform mouse
+ event forwarding when menus are active.
+ * MenuAPI.cs: kill the GrabControl hack. Use Form.ActiveTracker.
+ Most of the patch is pdb's with a little rework.
+
+2006-01-26 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIX11.cs, XplatUIOSX.cs:
+ Removed GetMenuDC and ReleaseMenuDC methods; replaced
+ by PaintEventStart(handle, false) and PaintEventEnd(handle, false)
+ * Form.cs: Changed WM_NCPAINT handler to use PaintEventStart and End
+ * InternalWindowManager.cs: Added use of PaintEventStart/End to
+ handling of WM_NCPAINT message, now passing the PaintEventArgs to
+ the PaintWindowDecorations method
+ * MainMenu.cs: Switched logic from GetMenuDC to PaintEventStart
+ * MdiChildContext.cs: Switched logic from GetMenuDC to PaintEventStart
+ * MenuAPI.cs: Made tracker window invisible
+ * XplatUIWin32.cs:
+ - Removed GetMenuDC and ReleaseMenuDC methods
+ - Implemented the client=false path for PaintEventStart and
+ PaintEventEnd
+
+2006-01-26 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIWin32.cs(SetBorderStyle): Fixed3D needs a border
+ * XplatUIX11.cs(DeriveWindowStyles): Updated to match fixed Form
+ styles
+ * Form.cs:
+ - MaximizeBox, MinimizeBox: Recreate the handle when setting
+ the style
+ - CreateParams: Reworked the styles to match MS look'n'feel,
+ removed automatic setting of MinimizeBox, MaximizeBox, etc. via
+ the WS_OVERLAPPEDWINDOW style. This fixes #76823.
+
+2006-01-26 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs(GetWindowState): Now throwing an exception when the
+ window is not mapped, since otherwise every form that's being
+ created is considered minimized, which is wrong.
+ * Form.cs: Catching the exception and returning our internal value
+ instead
+
+2006-01-26 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIOSX.cs: Added new driver method
+ SetWindowMinMax() to have means to tell the driver about the minimum,
+ maximum and maximized state window sizes. (Part of the fix for #76485)
+ * Form.cs:
+ - Implemented tracking of minimum and maximum window size, now calling
+ new SetWindowMinMax() driver method to tell the driver (Part of the
+ fix for #76485)
+ - Finished handling of WM_GETMINMAXINFO method, now setting all values
+ (Completes fix for #76485)
+ - Calling new SetWindowMinMax driver method when the handle for a
+ form is created, to make sure the driver knows about it even if
+ the values have been set before the window was created
+ - Now eating the WM_WINDOWPOSCHANGED message if the form is minimized
+ to avoid messing up our anchoring calculations (partial fix
+ for #77355)
+ * XplatUIStructs.cs: Added MINMAXINFO struct (moved from Win32 driver)
+ * XplatUIX11.cs:
+ - Added _NET_WM_STATE_HIDDEN property for detecting minimized state
+ - Improved GetWindowState() to detect 'Minimized' state on Metacity
+ (and presumably other freedesktop.org compliant WMs). Left the
+ assumption unmapped=minimized, needed for SetVisible to work.
+ - Now setting the window state when creating windows
+ - Fixed SetVisible to consider/set the window state when mapping
+ a Form. We cannot set the state before it's mapped, and we cannot
+ use Form.WindowState once it's mapped (since it would ask the
+ driver and get 'normal'. Therefore, we grab the state before
+ mapping, map, and then set state.
+ - Implmemented SetWindowMinMax method; Metacity does not seem to
+ honor the ZoomHints, though.
+ * XplatUIWin32.cs:
+ - Removed MINMAXINFO (moved to XplatUIStructs)
+ - Added SetWindowMinMax stub (on Win32 the only way to set that
+ information is in response to the WM_GETMINMAXINFO message, which
+ is handled in Form.cs)
+ - Added logic to SetVisible to set the proper window state when a
+ form is made visible (fixes #75720)
+
+2006-01-26 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs (BeginInvoke): Automagically handle EventHandlers the
+ same way we handle them with Invoke.
+
+2006-01-25 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Form.cs:
+ - Added tracking of window state so CreateParams can return
+ the appropriate style
+ - Moved setting of WS_CAPTION style in CreateParams to allow
+ styles without caption
+ * DataGridTextBoxColumn.cs: We are now also creating the TextBox
+ control if the TextBox property is accessed. Fixes #77345
+ * Control.cs:
+ - get_Created: now uses is_disposed and is_created to determine
+ return value (suggested by Jackson)
+ - CreateHandle: No longer exits if the handle is being recreated
+ - RecreateHandle: If the handle is not yet created call the
+ appropriate method to create either control or handle. If the
+ control is already created CreateHandle will simply exit instead
+ of just creating the handle
+ * Hwnd.cs: Removed expose_pending tracking, no longer needed since we
+ now SendMessage WM_DESTROY directly to the control when DestroyWindow
+ is called.
+ * XplatUIX11.cs:
+ - When DestroyWindow is called, instead of waiting for the
+ DestroyNotification from X11, we directly post it to the WndProc
+ and immediately dispose the hwnd object.
+ Same applies to DestroyChildWindows, and this obsoletes the
+ expose_pending tracking. Contrary to Win32 behaviour we destroy our
+ child windows before our own, to avoid X11 errors.
+ - Removed the direct sending of WM_PAINT on UpdateWindow
+ * XplatUIWin32.cs:
+ - Reworked DoEvents and GetMessage to allow access to internal queue
+ even when trying non-blocking access to the queue. Fixes #77335.
+ Based on a patch suggestion by Don Edvalson. The new private
+ GetMessage can now also be used as a backend for a PeekMessage
+ frontend version.
+ * XplatUI.cs: Improved debug output for CreateWindow
+
+2006-01-25 Jackson Harper <jackson@ximian.com>
+
+ * Help.cs: Allow param to be null. Patch by Don Edvalson.
+
+2006-01-24 Jackson Harper <jackson@ximian.com>
+
+ * ComboBox.cs: Clamp the max value set for the vertical scrollbar
+ when we have a MaxDropItems lower then the selected index.
+
+2006-01-24 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Don't allow selection of non visible controls, allow
+ selection of controls without parents.
+
+2006-01-24 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * ThemeWin32Classic.cs: Fixes Datagrid drawing issues
+ * DataGridDrawingLogic.cs: Add editing row only when is necessary
+
+2006-01-23 Jackson Harper <jackson@ximian.com>
+
+ * UpDownBase.cs: Make the textbox handle all the selection and
+ tabbing. This fixes tabing to updown controls.
+
+2006-01-24 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * TextBoxBase.cs: fixes exception thown the object was null
+
+2006-01-23 Jackson Harper <jackson@ximian.com>
+
+ * ButtonBase.cs: Just use the base CreateParams. They set
+ visibility and enabled correctly.
+ * ComboBox.cs:
+ * TrackBar.cs:
+ * MonthCalendar.cs: Lets let the base set as much of the
+ createparams as possible so we don't have duplicate code all over
+ the place.
+
+2006-01-22 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeGtk.cs: Added TrackBar and some experimental code to
+ get double buffering back
+
+2006-01-21 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * DataGrid.cs: Allows row number set internally higher than the last
+ when creating a new row. Restores the editing functionality.
+
+2006-01-20 Mike Kestner <mkestner@novell.com>
+
+ * MimeIcon.cs: delay Image creation until the icons are accessed
+ instead of creating 190 scaled images on GnomeHandler startup.
+
+2006-01-19 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextBoxBase.cs (WndProc): When handling WM_KEYDOWN we need to
+ first call base before processing the event. Fixes #77279
+
+2006-01-19 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIWin32.cs, Cursor.cs: Fixed code that wrongly assumed
+ that the stride for the GDI bitmap would match the stride of
+ a DIB or a Cursor.
+
+2006-01-19 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeGtk.cs: Added ProgressBar, RadioButton, CheckBox
+
+2006-01-19 Jackson Harper <jackson@ximian.com>
+
+ * ComboBox.cs: Hookup the text controls keydown event so we get
+ those when the text control has the focus.
+
+2006-01-18 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Label.cs: Now using the base events instead of defining new ones;
+ this allows us to just call the base properties without having to
+ duplicate all base property logic
+
+2006-01-18 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Label.cs: A label by default is not a tabstop (Fixes one of our
+ failing nunit tests)
+
+2006-01-18 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIWin32.cs: Fixed wrong DoEvents logic. Fixes #77282
+ * XplatUIX11.cs: Removed WM_PAINT check from DoEvents. Fixes #77282
+
+2006-01-18 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Cursor.cs: Reimplemented creating cursor bitmaps without using
+ the Bitmap(Stream) constructor which is semi-broken on MS GDI+.
+ This fixes #77218
+ * XplatUIWin32.cs:
+ - Reimplemented creating Bitmaps from DIBs since the Bitmap(Stream)
+ constructor creates images that can't be saved. Part of the fix
+ for #76103
+ - Added handling of CF_BITMAP as CF_DIB to clipboard code (Fixes #76103)
+ - SetWindowState: Switched ShowWindow flags (part of an upcoming
+ bug fix for handling window state in forms properly)
+
+2006-01-18 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeGtk.cs: Simplify ScrollBar drawing
+
+2006-01-18 Jackson Harper <jackson@ximian.com>
+
+ * Splitter.cs: Set the default dock style for the splitter control
+ in the constructor.
+
+2006-01-18 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeGtk.cs: Corrected StateType and ShadowType for
+ gtk_paint_box
+
+2006-01-18 Alexander Olk <alex.olk@googlemail.com>
+
+ * Control.cs: Make use of Theme.DoubleBufferingSupported
+ * ThemeGtk.cs:
+ - Added drawing for flat style buttons
+ - Added ScrollBar drawing
+
+2006-01-18 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeClearlooks.cs: Removed some unneeded code.
+ * ThemeGtk.cs: First part of ThemeGtk enhancements.
+
+2006-01-17 Peter Dennis Bartok <pbartok@novell.com>
+
+ * LinkLabel.cs: We need to update the hover drawing when
+ leaving the control as well.
+
+2006-01-18 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * DataGrid.cs: Clicking on non empty areas in the columns
+ area was giving an exception
+
+2006-01-17 Jackson Harper <jackson@ximian.com>
+
+ * ThemeWin32Classic.cs:
+ * ListView.cs: Do not draw/clip the headers when the header style
+ is None.
+
+2006-01-17 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * DataGrid.cs: Fixes 77260
+
+2006-01-17 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * DataGrid.cs: Clicking on a column on a empty grid was giving
+ an exception
+
+2006-01-17 Peter Dennis Bartok <pbartok@novell.com>
+
+ * DataGrid.cs (OnKeyDown): Don't use the array if it's empty
+ or any keypress will crash the grid.
+
+2006-01-17 Mike Kestner <mkestner@novell.com>
+
+ * MainMenu.cs (OnMenuChanged): set Height=0 to cause relayout.
+ * ThemeWin32Classic.cs (CalcItemSize): clear Height/Width for
+ invisible/previously-visible items.
+ [Fixes #76909]
+
+2006-01-17 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeClearlooks.cs:
+ - Added CL_Draw_Button method; now other theme controls that are
+ not derived from button or do not have a button can draw buttons
+ too
+ - Updated ComboBox drawing
+ - Beautified RadioButton drawing
+ - Corrected drawing of bottom and left tabs
+ - Beautified DateTimePicker and MonthCalendar
+ - Added CPDrawButton and CPDrawRadioButton
+
+2006-01-16 Jackson Harper <jackson@ximian.com>
+
+ * ComboBox.cs: Set the initial value of the scrollbar to the
+ current index. Reduce the numbers of refreshs and IndexOfs called.
+
+2006-01-14 Alexander Olk <alex.olk@googlemail.com>
+
+ * FileDialog.cs: When the file listview is focused hitting the
+ backspace key moves the fileview to the parent directory
+
+2006-01-13 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Form.cs:
+ - Added RecreateHandle call when changing taskbar visibility to
+ trigger reparenting in Win32 driver (Fixes #75719)
+ - If a window has minimize or maximize buttons, it cannot have
+ a help button
+ * XplatUIWin32.cs:
+ - CreateWindow: When no WS_EX_APPWINDOW style is found we parent
+ the toplevel form with FosterParent (A toolwindow not on the
+ taskbar) (Fixes #75719)
+ - Made FosterParent a toolwindow
+
+2006-01-13 Alexander Olk <alex.olk@googlemail.com>
+
+ * FileDialog.cs: Don't crash if InitialDirectory doesn't exist
+
+2006-01-13 Alexander Olk <alex.olk@googlemail.com>
+
+ * ToolTip.cs: If SetToolTip is called from a control and the mouse
+ is currently over that control, make sure that tooltip_window.Text
+ gets updated
+
+2006-01-13 Mike Kestner <mkestner@novell.com>
+
+ * MimeIcon.cs: size_t on lp64 fix for gdk_pixbuf_save_to_file extern.
+
+2006-01-13 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: On MS GetNodeAt never actually factors in the X
+ value passed. Also redraw the selected node when we recieve
+ focus, so tabbing between trees works correctly.
+
+2006-01-13 Alexander Olk <alex.olk@googlemail.com>
+
+ * MimeIcon.cs: GnomeHandler: older gnome versions don't have
+ ~/.gconf/%gconf-tree.xml, so use
+ .gconf/desktop/gnome/interface/%gconf.xml
+
+2006-01-13 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextControl.cs: Draw text in gray if control is disabled
+
+2006-01-13 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TreeView.cs: Draw the focus rectangle outside the highlight, to
+ make sure it's always visible. Fixes #76680.
+
+2006-01-13 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TreeView.cs: Implemented Wheel scrolling. Fixes #76531
+
+2006-01-13 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * PageSetupDialog.cs: Added.
+ * PrintDialog.cs: Attributes.
+ * PrintPreviewControl.cs: Updates.
+ * PrintPreviewDialog.cs: Updates.
+
+2006-01-12 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs: Undid my selection check fix, since it's not needed
+ * TextBoxBase.cs:
+ - Now considering the presence of hscroll/vscroll when sizing
+ vscroll/hscroll respectively. Fixed bug #77077
+ - Added Left/Up/Down/Right to IsInputKey list to prevent
+ ContainerControl from stealing them. This fixes what I broke
+ with my last checkin.
+
+2006-01-12 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ScrollableControl.cs: Implemented dockpadding. Fixes #77166. And
+ I finally understand how the property can be set without a setter :-)
+
+2006-01-12 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Application.cs:
+ - Switched RunLoop to use static Message.Create to create a
+ Message object
+ - Added PreProcessMessage call in runloop for keyboard events; this
+ is part of the fix for #77219, I overlooked this originally in the
+ MSDN doc for PreProcessMessage
+ * Control.cs:
+ - Removed call to PreProcessMessage from handling of keyboard
+ messages; it's supposed to be done in the message pump
+ - Moved call to ProcessKeyEventArgs inside ProcessKeyMessage as
+ per MSDN documentation.
+ - IsInputChar: All chars are input chars by default; removed the
+ parent calling chain, MS does not document that
+ - PreProcessMessage: If IsInputChar is true, we want to return false
+ to allow dispatching of the message
+ - When selecting the next control, now also check that we're not
+ selecting ourselves again and therefore return a false positive.
+ * TextBoxBase.cs:
+ - Tried to match return values for IsInputKey and ProcessDialogKey
+ to what MS returns; moved processing of our special keys outside
+ ProcessDialogKey since MS does not seem to return true on those.
+ - Moved code that previously was in ProcessDialogKey into new private
+ ProcessKey method, which gets called upon receipt of WM_KEYDOWN
+ - Reworked handling of WM_CHAR to not have to duplicate code from
+ Control.cs anymore, instead we simply call down to base.
+
+2006-01-12 Jackson Harper <jackson@ximian.com>
+
+ * ComboBox.cs: We always need to refresh the text area when
+ EndUpdate is called. Fixes the combobox in the file dialog.
+ * Control.cs: Don't create the creator_thread until the controls
+ handle is created. Also in InvokeRequired we check if the
+ creator_thread is null. This gives the effect of InvokeRequired
+ returning true if the controls handle is not created yet, and
+ matches MS.
+
+2006-01-12 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUI.cs:
+ - Added StartLoop() driver method. This is used to allow drivers to
+ prepare for an upcoming GetMessage/TranslateMessage/DispatchMessage
+ loop for a particular thread
+ - Added EndLoop() driver method. This is called once the message
+ pump for the thread is shut down
+ - Added SupportsTransparency method to allow the driver to indicate
+ opacity support for windows
+ * Form.cs:
+ - Removed TODO attribute, completed AllowTransparency property
+ - Added documented logic to Opacity
+ * GroupBox.cs, Label.cs, LinkLabel.cs, PropertyGrid.cs, Control.cs,
+ ButtonBase.cs, CheckedListBox.cs: Combined Jackson's and Miguel's
+ versions of CompatibleTextRendering
+ * X11Structs.cs: Added opacity atom to our atom enumeration
+ * Hwnd.cs: Added opacity tracking (we need to track since the opacity
+ of a form might be set before it's reparented by the WM, and we need
+ the opacity value without calling up to Form)
+ * XplatUIDriver.cs: Added StartLoop(), EndLoop() and
+ SupportsTransparency() driver methods
+ * Application.cs: Now calling StartLoop and EndLoop driver methods
+ * XplatUIX11.cs:
+ - Added opacity atom registration
+ - Added StartLoop()/EndLoop() methods. They're empty right now but
+ will need to get implemented when we switch to a per-thread queue
+ - Implemented SupportsTransparency() method
+ - Implemented SetWindowTransparency() method
+ - Added support for setting the opacity value when a window is
+ reparented (since the opacity needs to be set on the WM frame)
+ * XplatUIOSX.cs, XplatUIWin32.cs:
+ - Added SupportsTransparency(), StartLoop() and EndLoop() methods
+
+2006-01-12 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeClearlooks.cs: Don't crash if TabControl.Parent is null.
+
+2006-01-12 Alexander Olk <alex.olk@googlemail.com>
+
+ * FileDialog.cs: Added ToolTip for MWFFileView
+ * MimeIcon.cs: Rewrote GnomeHandler.
+ - Get currently used gnome icon theme from
+ ($HOME)/.gconf/%gconf-tree.xml
+ - Make use of inherited icon themes
+ - Support SVG icon themes like Tango via librsvg
+
+2006-01-12 Miguel de Icaza <miguel@novell.com>
+
+ Revert's Jackson's revert which broke 2.0 builds. Fix both
+ builds.
+
+ * Application.cs: Move the use_compatible_text_rendering outside
+ the NET_2_0 define. If we ever need to use the
+ use_compatible_text_rendering on the individual controls they will
+ access the variable from the common shared code paths.
+
+2006-01-12 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUI.cs:
+ - Added more granular debug options
+ - Added method to print both window text and id
+ - Switched debug output to use new Window() debug method
+ - Added IsEnabled() driver method
+ - Added EnableWindow() driver method
+ * Form.cs:
+ - Removed end_modal; no longer needed, new loop handles termination
+ via 'closing' variable
+ - If form is modal, setting DialogResult will now initiate loop
+ termination via 'closing' variable
+ - Added support for is_enabled/WS_DISABLED to CreateParams
+ - Close() now just send the WM_CLOSE message; the WM_CLOSE handler
+ does all the work
+ - Removed code that's now in RunLoop from ShowDialog()
+ - Added various documented sanity checks to ShowDialog()
+ - Added handling of WM_DESTROY message; we set 'closing' on getting
+ the message to indicate the message pump to terminate
+ - Added handling of new internal WM_CLOSE_INTERNAL message - it's
+ send by the Application.ExitThread method. (We send the message
+ to destroy the window after all other events have been
+ processed through the queue, instead of destroying the handle
+ directly)
+ - Moved code from Close() method to WM_CLOSE handler; added logic
+ to only send close-related events if the form is not displayed
+ modal
+ * Splitter.cs (..ctor): Fixed typo in resource name
+ * Control.cs:
+ - DrawBackgroundImage: Explicitly selecting the wrap mode for the
+ brush now
+ - set_Cursor: Now only setting calling into XplatUI if the handle for
+ the control is already created; this avoids implict handle creation
+ or crashes if it's not created
+ - set_Enabled: Now setting the enabled state via the new driver method
+ instead of just tracking it
+ - CreateParams: Added logic to set WS_DISABLED based on enabled state
+ - CreateControl: Reordered event firing and method calls to more
+ closely fire events in the order MS does. Now setting the
+ enabled state in the driver when creating the control.
+ - SetVisibleCore: Moved when the OnVisibleChanged event is fired to
+ match MS order
+ * FolderBrowserDialog.cs, MessageBox.cs, ButtonBase.cs, TrackBar.cs,
+ MonthCalendar.cs: get_CreateParams: Added setting of WS_DISABLED
+ * XplatUIStructs.cs: Added internal WM_CLOSE_INTERNAL mesage id
+ * Hwnd.cs:
+ - Added tracking of window enabled state (get_Enabled/set_Enabled)
+ - Added EnabledHwnd property to easily allow a driver to find the
+ handle of the first enabled window in the parent chain (this is
+ used by drivers to pass up input events of disabled windows)
+ * XplatUIDriver.cs: Added IsEnabled() method
+ * Application.cs:
+ - Removed crude and obsolete exiting tracking variable
+ - Removed internal ModalRun(); replaced by RunLoop()
+ - Implemented private CloseForms() method to allow closing all
+ windows owned by a particular (or all) threads
+ - Exit() now properly closes all windows without forcing the message
+ pump to quit
+ - Removed obsolete InternalExit() method
+ - Changed Run() methods to use new RunLoop() message pump
+ - Implemented new RunLoop() method for both modal and non-modal forms
+ * CommonDialog.cs:
+ - get_CreateParams: Added setting of WS_DISABLED
+ - Simplified ShowDialog(); now all the work is done in RunLoop(),
+ invoked via Form.ShowDialog()
+ * NativeWindow.cs: We don't remove the window from the collection when
+ the handle is destroyed; there might still be messages for it in the
+ queue (mainly the resulting WM_DESTROY); instead it will be removed
+ when Control calls InvalidateHandle in the WM_DESTROY handler
+ * XplatUIX11.cs:
+ - CreateWindow: Added logic to handle the WS_DISABLED window style
+ - EnableWindow: Implemented based on Hwnd.Enabled
+ - GetMessage: Reset PostQuitState so the method can be called again
+ - Implemented support for disabled windows (passing messages to the
+ first enabled parent) in handling all input messages
+ - Added optimizations for handling Expose events
+ - Implemeted new driver method IsEnabled()
+ - Now always resetting paint pending tracking vars when we start paint
+ - Re-implemented UpdateWindow via just sending a WM_PAINT message
+ * XplatUIOSX.cs: Added IsEnabled method stub
+ * XplatUIWin32.cs: Implemented new IsEnabled() method
+
+2006-01-11 Jackson Harper <jackson@ximian.com>
+
+ * ButtonBase.cs, CheckedListBox.cs, GroupBox.cs, Label.cs,
+ LinkLabel.cs, PropertyGrid.cs: Unbreak 1.1 build. Consolidate the
+ variables a little.
+ * ColorDialog.cs: Clear out the old form before adding the new
+ panel.
+
+2006-01-11 Jackson Harper <jackson@ximian.com>
+
+ * X11Dnd.cs: Make sure to add all the text formats when adding
+ strings to the data object.
+ * TreeNodeCollection.cs: When adding to a sorted tree we need to
+ do some redrawing too. Also change the UpdateNode to an
+ UpdateBelow so the newly added node gets painted.
+
+2006-01-11 Miguel de Icaza <miguel@novell.com>
+
+ * ButtonBase.cs, CheckedListBox.cs, GroupBox.cs, Label.cs,
+ LinkLabel.cs, PropertyGrid.cs: Implement the
+ UseCompatibleTextRendering property for 2.x
+
+ * Application.cs (SetCompatibleTextRenderingDefault): Add.
+
+2006-01-11 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Use the property for setting the selected node so
+ the correct events get raised.
+ * TreeNode.cs: Update the tree when the fore/back colours of a
+ node are set.
+
+2006-01-10 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Allow setting SelectedNode to null.
+
+2006-01-9 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * Form.cs: Fix support for Form TransparencyKey and Opacity on Windows.
+
+2006-01-9 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * PrintControllerWithStatusDialog.cs: Update page number in dialog.
+
+2006-01-9 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * PrintDialog.cs: Added attributes and set default property values.
+
+2006-01-9 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * PrintControllerWithStatusDialog.cs:
+ Added PrintControllerWithStatusDialog.
+
+2006-01-9 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * XplatUI.cs, Form.cs, XplatUIDriver.cs, XplatUIX11.cs, XplatUIOSX.cs,
+ XplatUIWin32.cs: Added support for Form TransparencyKey and Opacity on Windows.
+
+2006-01-9 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * ComboBox.cs: Fix crash when there is no selected item (due to last commit)
+
+2006-01-09 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * ComboBox.cs: Added KeyDown event handler for processing arrow keys
+ and PgUp/PgDown. Also, scroll to selected item upon dropdown. Bugs 76857 and 76788.
+
+2006-01-08 Alexander Olk <alex.olk@googlemail.com>
+
+ * MimeIcon.cs: Added internal class SVGUtil.
+
+2006-01-08 Alexander Olk <alex.olk@googlemail.com>
+
+ * FileDialog.cs: Don't crash if there are two files with the
+ same name but different locations.
+
+2006-01-08 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * MonthCalendar.cs: Fixed annoying rendering bug when selecting
+ dates across multiple month grids. Used to not highlight entire
+ month, but does now.
+
+2006-01-06 Jackson Harper <jackson@ximian.com>
+
+ * MonthCalendar.cs: Removed DoEvents call to prevent a running
+ message loop. Change timer intervals to numbers that seem more
+ natural.
+
+2006-01-06 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * DateTimePicker.cs: Modified CalculateDropDownLocation to use the screen
+ object for location info since screen object is now implemented.
+
+2006-01-05 Jackson Harper <jackson@ximian.com>
+
+ * AsyncMethodData.cs: Check if the call is complete before doing a WaitOne
+ * AsyncMethodResult.cs: We no longer use a WeakReference for the
+ AsyncMethodResult, this is because we ALWAYS want the
+ ManualResetEvent to get set.
+ * Control.cs: When disposing use an async invoke to call shutdown
+ code, so that thigns don't block on the finalizer thread. Also
+ check if we even have a message loop before trying to send
+ messages, if we don't then don't bother sending messages.
+ - No more weak references for async methods
+ * XplatUIDriver.cs: No more weak references for async methods.
+
+2006-01-04 Alexander Olk <alex.olk@googlemail.com>
+
+ * FontDialog.cs: Fix, don't throw an exception if FontFamily.Families
+ returns two FontFamily with the same name
+
+2006-01-04 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ThemeWin32Classic.cs, ThemeClearlooks.cs: Dropped stupid scheme of
+ drawing disabled text. Instead using the ColorGrayText color
+
+2006-01-04 Jackson Harper <jackson@ximian.com>
+
+ * TreeNode.cs: redraw the node when its image index is changed.
+
+2006-01-04 Peter Dennis Bartok <pbartok@novell.com>
+
+ * RichTextBox.cs: Same fix as last, just for SelectionColor. This
+ time I checked there are no others like it.
+
+2006-01-04 Jackson Harper <jackson@ximian.com>
+
+ * AsyncMethodResult.cs: Use a ManualResetEvent instead of a mutex,
+ this gives the behavoir I was looking for.
+ * Control.cs: Special case Invoking EventHandlers, this matches MS
+ and fixes part of bug #76326.
+
+2006-01-04 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeClearlooks.cs, FileDialog.cs:
+ - Reflect the latest Theme class changes
+ - Remove Mono.Unix.Syscall.time in FileDialg and replace it
+ with DateTime
+
+2006-01-04 Alexander Olk <alex.olk@googlemail.com>
+
+ * Theme.cs: Cache UI resource images and resize them if needed
+
+2006-01-03 Peter Dennis Bartok <pbartok@novell.com>
+
+ * RichTextBox.cs: FormatText is 1-based, make it so when SelectionFont
+ is called. This fixes the crash in Nexxia when setting the font
+ attributes in the chat. [However, RTF needs a look-over to make sure
+ that all SelectionXXX methods handle the special case that selection
+ is empty and therefore the change must be applied to all text starting
+ at the cursor/selection start]
+
+2006-01-03 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIX11.cs, XplatUIWin32.cs,
+ XplatUIOSX.cs: Added SendMessage and PostMessage methods
+ * X11Keyboard.cs: Switched to new way of calling PostMessage
+
+2006-01-03 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Theme.cs: Added theme interface for images to allow the theme to
+ control what images are used for things like FileDialog, MessageBox
+ icons, etc.
+ * MessageBox.cs: Now uses the new Theme icon/image interfaces
+
+2006-01-03 Alexander Olk <alex.olk@googlemail.com>
+
+ * FileDialog.cs:
+ - Removed some dead code
+ - Opening a recently used file does work now
+ - Small UI enhancements
+ - Refactoring
+
+2006-01-02 Alexander Olk <alex.olk@googlemail.com>
+
+ * FileDialog.cs: Forgot too add __MonoCS__
+
+2006-01-02 Alexander Olk <alex.olk@googlemail.com>
+
+ * FileDialog.cs: We are able to read recently used files now let's
+ go on and write them.
+
+2006-01-01 Alexander Olk <alex.olk@googlemail.com>
+
+ * FileDialog.cs: Breathe some life into "last open"/"recently used"
+ button
+ * MimeIcon.cs: Do a check for the top level media type also
+
+2005-12-31 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeClearlooks.cs:
+ - Added CPDrawStringDisabled
+ - ButtonBase_DrawText: Workaround for a DrawString bug; cut off
+ some chars if the text doesn't fit into text_rect
+ - DrawListViewItem: If View = View.LargeIcon center the image;
+ rewrote the drawing of ListViewItem.Text if View =
+ View.LargeIcon
+
+2005-12-31 Alexander Olk <alex.olk@googlemail.com>
+
+ * MimeIcon.cs: Use default KDE icon theme if there is no
+ "48x48" directory for the current icon theme, fixes #77114
+ * Mime.cs: Disable not working and actually not used code.
+ * ThemeWin32Classic.cs:
+ - Replace "new SolidBrush" in GetControlBackBrush and
+ GetControlForeBrush with ResPool.GetSolidBrush
+ - Changed DrawListViewItem from private to protected virtual
+ * FileDialog.cs:
+ - Added form.MaximizeBox = true
+ - Don't throw an exception if there is a broken symbolic link
+
+2005-12-23 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Give the panels focus, keyboard navigation is
+ fixed so this works correctly now.
+ - We need these key events also.
+ * ToolBar.cs: Remove some of the poor mans double buffering.
+
+2005-12-24 Alexander Olk <alex.olk@googlemail.com>
+
+ * ComboBox.cs: The internal TextBox now returns the focus.
+
+2005-12-23 Jackson Harper <jackson@ximian.com>
+
+ * ThemeWin32Classic.cs: Draw the text for all tab appearances.
+
+2005-12-23 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs: Removed debug code
+ * XplatUIX11.cs: Changed DestroyChildWindows to also consider
+ implicit children
+
+2005-12-23 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs: When creating the control, update the Z-order after
+ all it's children are created, too. (Fixes nexxia not showing
+ picturebox bug)
+
+2005-12-23 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs: Do not update the anchoring distances if layout is
+ suspended, instead do it once layout is resumed
+
+2005-12-22 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - After many hours of debugging, for both Jackson and
+ myself, it turns out that it helps to set the parent of a control
+ if you want to actually see it onscreen. In the spirit of that
+ discovery, we're now setting the parent of the control and
+ it's children when the control's handle is created. This fix
+ will make Lutz Roeder's Reflector run happily.
+ - now just creating the handle instead of the whole control when
+ getting a graphics context for the control.
+
+2005-12-22 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ScrollableControl.cs: When calculating the canvas, don't consider
+ the scrollbar widths. Instead, predict if horizontal scrollbar
+ will affect canvas when deciding on vertical display and vice versa.
+
+2005-12-22 Peter Dennis Bartok <pbartok@novell.com>
+
+ * RichTextBox.cs: Set default RTF font for documents that don't
+ have a font table (Fixes #77076)
+
+2005-12-22 Jackson Harper <jackson@ximian.com>
+
+ * TextBoxBase.cs: It's difficult to do, but you can have an empty
+ clipboard. This prevents a NullRef in that case.
+ * XplatUIX11.cs: Use CLIPBOARD not PRIMARY for our
+ clipboard. PRIMARY is for the currently selected text only. (We
+ should implement PRIMARY at some point.
+
+2005-12-21 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIWin32.cs: Fixed the TEXTMETRIC structure, we were calling
+ a Unicode function with a structure that was defined in Ansi way.
+ This fixes #76942.
+
+2005-12-21 Jackson Harper <jackson@ximian.com>
+
+ * StatusBar.cs: Statusbar handles its fore/back colours on it's
+ on. Because thats how it rolls. (and this avoids it using ambient
+ colours).
+ * ThemeWin32Classic.cs: Use the proper back color for filling.
+ * Menu.cs: Use the system menu bar color for drawing menu
+ bars. Using the window back color will bring ambient colours into
+ the picture.
+
+2005-12-21 Alexander Olk <alex.olk@googlemail.com>
+
+ * ColorDialog.cs: Fixed a memory leak that caused a SIGSEV. A lot of
+ Bitmaps were created and not disposed.
+
+2005-12-21 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs (CreateControl): Don't do anything if the control is
+ already created, otherwise we'd fire the OnCreated event more than
+ once
+
+2005-12-21 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ComboBox.cs (FindStringCaseInsensitive): Don't search for emtpy strings,
+ will always match. Instead return -1. Fixes #76464.
+
+2005-12-21 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextControl.cs (RecalculateLine): Only wrap if the wrap point is
+ neither the beginning nor the end of the line (Fixes bug #76479)
+
+2005-12-21 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - ControlNativeWindow.ControlFromHandle(): Now handling situation
+ where handle is invalid
+ - FromHandle(): Now using hashtable-based ControlFromHandle() lookup
+ instead of slower linear search
+ * NativeWindow.cs: Don't remove the window from the hashtable until
+ after the driver has destroyed it (since the driver might use
+ Control.FromHandle to lookup the control object
+ * Hwnd.cs: Added DestroyPending property to track if a window is
+ already destroyed as far as the driver is concerned and only hasn't
+ yet notified the control
+ * XplatUIX11.cs:
+ - Activate(): Check if the window is still valid before using the
+ handle
+ - Implemented DestroyChildWindow() method to mark child windows as
+ destroyed when a window is destroyed. This prevents situations
+ where we might call an X method based on queued events for a
+ window that already has been destroyed but we haven't yet pulled
+ the destroy method from the queue.
+ - Added a call to the new DestroyChildWindow() method to the drivers
+ DestroyWindow code. Also now marking the destroyed window itself
+ as pending
+
+2005-12-20 Jackson Harper <jackson@ximian.com>
+
+ * StatusBar.cs:
+ * StatusBarPanel.cs: Don't calculate panel sizes on draw
+ anymore. Just do them when needed, also track the rects of panels
+ so that we can optimize refreshing more in the future.
+
+2005-12-20 Alexander Olk <alex.olk@googlemail.com>
+
+ * ColorDialog.cs: Fixed focus drawing in small color controls
+
+2005-12-19 Jackson Harper <jackson@ximian.com>
+
+ * InternalWindowManager.cs:
+ * MdiWindowManager.cs: Cleanup some coordinate system changes so
+ moving windows works properly.
+
+2005-12-19 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - Removed call to InitLayout() from SetBoundsCore(); doc says
+ it's only called when a control is added to a container
+ - Split InitLayout logic, moved to separate UpdateDistances() method
+ since we need to perform those calculations more often than just
+ when adding the control to a container. (Needed to fix #77022)
+ - Now calling UpdateDistances() from UpdateBounds() (fixes #77022)
+ - Reduced the OnBindingContextChanged events count, don't send them
+ unless the control is created, we still aren't totally matching
+ MS, but I can't quite figure out some of their rules
+
+2005-12-18 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeClearlooks.cs: Corrected distance between ProgressBar
+ stripes
+
+2005-12-18 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeClearlooks.cs:
+ - Updated ProgressBar drawing
+ - Corrected drawing of ScrollBars and scroll buttons
+ - Some temporary fixes for minor pixel artefacts
+
+2005-12-18 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - Reworked Controls.Add(), Controls.Remove() and set_Parent() to
+ cause events to be sent in the same order as MS does.
+ - Added ChangeParent() method to trigger various OnXXXChanged events
+ that need to be fired when a parent changes (This is a reworking
+ of the patch from r54254, with the X11 errors fixed)
+ - Removed SuspendLayout()/ResumeLayout() calls from Controls.Clear()
+ since on MS we get OnLayoutChanged events when calling Clear()
+ - Changed Enabled property to consider parent state as well, if a
+ parent is not enabled, the control will not be either
+ - Changed Parent property to simply call Controls.Add() since that
+ now does all the work required, this way we avoid code duplication
+ - Threw in a few OnBindingsContextChanged calls to try and match
+ when MS sends them. We seem to send a few too many, though.
+ - Added call to CreateControl when adding the control to a parent.
+ We were never calling CreateControl. Still needs some work, in
+ some places we treat HandleCreated and ControlCreated as equal,
+ which is wrong
+ - Removed obsolete commented out code from UpdateZOrder()
+
+2005-12-18 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeClearlooks.cs: Updated TrackBar drawing.
+
+2005-12-17 Alexander Olk <alex.olk@googlemail.com>
+
+ * FileDialog.cs: Patch for #76901 by Atsushi Enomoto
+
+2005-12-17 Alexander Olk <alex.olk@googlemail.com>
+
+ * FileDialog.cs: Add the Help button and the open readonly
+ checkbox only if needed
+
+2005-12-16 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Make sure we have an active menu before trying to
+ process commands on it. Prevents menu-less forms from crashing
+ when Alt is pressed.
+ * TreeNodeCollection.cs: Some fixes to prevent null refs. Patch by
+ Dieter Bremes.
+ * RichTextBox.cs: Expand statement to help out gmcs and fix the
+ 2.0 build.
+
+2005-12-16 Jackson Harper <jackson@ximian.com>
+
+ * InternalWindowManager.cs: Don't translate tool windows screen
+ coordinates. This fixes windows 'bouncing' around when being moved.
+
+2005-12-15 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextBoxBase.cs:
+ - MaxLength now treats 2^31-1 equal to unlimited length (this is
+ not quite MS compatible, MS uses that number only for single line
+ and 2^32-1 for multi-line, but I figure it won't hurt keeping
+ the limit at 2GB)
+ - Now enforcing the MaxLength limit when entering characters
+ - Added argument to internal Paste() method to track if it's called
+ from programatically or via keyboard, since keyboard driven pastes
+ need to enforce max-length
+ - Added logic to Paste to only paste as many chars as MaxLength
+ allows
+ * RichTextBox.cs: Updated to use new obey argument for internal Paste()
+ * TextControl.cs:
+ - Added Length property to return number of characters in document
+ - Added private CharCount property which only tracks actual chars
+ in the document (no linefeeds) and fires event when CharCount
+ changes
+ - Added tracking of character count to all methods that alter it
+ - Added LengthChanged event to allow applications to subscribe
+ to any changes to the document
+
+2005-12-15 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextBox.cs:
+ - Removed local password_char field (moved to TextBoxBase)
+ - Now setting the document's password var when password is
+ set
+ * TextBoxBase.cs:
+ - Added password_char field (needed here so MultiLine can
+ access it)
+ - Added logic to MultiLine property setter to set the document's
+ variable when password display is allowed
+ - Removed debug code and made some debug code conditional
+ * TextControl.cs:
+ - Added RecalculatePasswordLine() method to handle special password
+ char only lines
+ - Added PasswordChar property, also added related tracking vars
+ - Draw() method now uses local text var for grabbing text to draw,
+ this var is set to line.text unless we're doing password display,
+ then it is set to the pre-generated all-password-chars line
+ - Added calling RecalculatePasswordLine() method for password lines
+
+2005-12-14 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Hwnd.cs:
+ - Added Reparented property to allow tracking of Window Manager
+ reparenting actions (which affect X/Y calculations of toplevel
+ windows)
+ - Made ToString() print window handles in hex
+ * XplatUIX11.cs:
+ - AddConfigureNotify(): Now uses reparented state off Hwnd to
+ determine if X/Y needs offsetting
+ - AddConfigureNotify(): Fixed offset calculations
+ - Now adds ReparentNotify messages into the queue
+ - Now processes ReparentNotify messages and causes a
+ WM_WINDOWPOSCHANGED message to be sent upstream if a window
+ is reparented (as most likely it's X/Y coordinates are changed
+ due to that)
+
+2005-12-14 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: Tool windows still need to respek focus.
+
+2005-12-14 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs: Undid 54254 (causing XConfigure errors) so we can
+ have a working release
+
+2005-12-13 Jackson Harper <jackson@ximian.com>
+
+ * Form.cs: Update styles after setting the border style regardless
+ of whether or not the window is using a window manager.
+
+2005-12-13 Jackson Harper <jackson@ximian.com>
+
+ * Form.cs: We now hook into an internal window manager instead of just an
+ MDI subsystem, this is so we can have properly behaving tool windows.
+ * MdiClient.cs: Naming change, MdiChildContext is now WindowManager
+ * InternalWindowManager.cs: New internal class that acts as a
+ window manager for tool windows and as a base for mdi windows.
+ * MdiWindowManager.cs: New class that acts as a window manager for
+ mdi windows.
+
+2005-12-12 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Updates so we match behavoir for for implicit
+ controls. Fixes explosions in MDI.
+
+2005-12-12 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Implement Invalidate (Region).
+
+2005-12-12 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - Changed handling of Controls.Add/Controls.Remove to fire (almost)
+ the same events as MS does. MS fires events for each property
+ except, for unknown reasons, Cursor, when the control is reparented.
+ I can't seem to totally match add/remove since MS also fires some
+ VisibleChanged events, which makes no sense. Consolidated the
+ parenting code into a separate method so it can be called from
+ both Add and Remove. set_Parent no longer needs any special logic
+ as it calls the parent's add method which implicitly fires
+ all events
+ - Removed some obsolete code and debug output
+ - Enabled state is inherited from parents, if this is enabled
+
+2005-12-08 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Form.cs: Removed commented out code
+
+2005-12-08 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - Added internal version of Invoke, with additional argument
+ indicating if we're calling it from a Dispose() handler. That
+ way we can avoid BeginInvoke throwing an exception if we're
+ calling for an already destroyed window.
+ - Added a dispose argument to BeginInvokeInternal, and made the
+ check if a valid window handle chain exists conditional on
+ it not being a dispose call
+ - Removed code in DestroyHandle to destroy our children. Since we
+ now handle the WM_DESTROY message we will catch all our children
+ being destroyed.
+ - Now calling OnHandleDestroyed from our new WM_DESTROY handler
+ * Form.cs:
+ - Added a field to track the application context of the form.
+ - No need to set closing variable as response to WM_CLOSE, instead
+ we destroy the window. We also call PostQuitMessage if the form
+ has an application context (which makes it the main app form,
+ which, when closed terminates the app)
+ * XplatUI.cs:
+ - Dropped Exit() method, it's naming was confusing
+ - Added PostQuitMessage() which causes GetMessage to return false
+ once the message queue is empty
+ * XplatUIDriver.cs, XplatUIWin32.cs: Dropped Exit(), added
+ PostQuitMessage()
+ * XplatUIOSX.cs: Switched signature for Exit method since Exit() is
+ no longer a valid XplatUI method, but left it in since it's used
+ internally. Added empty PostQuitMessage() method.
+ * MenuAPI.cs: Replaced call to Exit() with call to
+ PostQuitMessage, even though this is probably no longer needed.
+ * Hwnd.cs: Added 'pretty' ToString() to support debugging.
+ * X11Structs.cs: Added pretty XEvent.ToString() to support debugging.
+ * Application.cs:
+ - Replaced call to XplatUI.Exit() with PostQuitMessage()
+ - Removed old debug code that would call XplatUI for exception
+ display, enabled standard exception handling (Still not enabled
+ though, until NativeWindow's ExternalExceptionHandler define
+ is removed
+ * NativeWindow.cs:
+ - Added internal method to allow control to update NativeWindow
+ after a window has been destroyed
+ - Added handling of already destroyed windows when calling i
+ DestroyWindow
+ - Added removal of handle from list on ReleaseHandle
+ * XplatUIX11.cs:
+ - Dropped GetMessageResult var and related code
+ - Added PostQuitState to field to track if PostQuitMessage has been
+ called
+ - Dropped Exit() method
+ - Added PostQuitMessage() method
+ - GetMessage now will return false if PostQuitState is set and no
+ more messages are in the queue.
+ - Expose handler will no longer generate WM_PAINT messages if we are
+ in PostQuitState since it's very likely any windows have already
+ been destroyed, and since Hwnd won't get updated until we have
+ processed the DestroyNotify we'd be causing X errors.
+
+2005-12-07 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs(WndProc): Apparently I'm suffering from brain cloud.
+ Thanks to Mike for pointing out the err of my ways.
+
+2005-12-07 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs(PreProcessMessage): Moved menu handling back, but
+ after all other key handling, to match MS (who handles Menu in
+ DefWndProc)
+ * Menu.cs (WndProc): Removed my brainfart
+
+2005-12-07 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs(PreProcessMessage): Removed special menu handling
+ * Menu.cs (WndProc): Added handling of WM_SYSKEYUP for menu purposes.
+
+2005-12-07 Mike Kestner <mkestner@novell.com>
+
+ * Control.cs : special case SYSKEYUP so that we can adjust keynav
+ state according in tracker.
+ * Menu.cs : promote tracker field to base class and provide a tracker
+ lookup capability. Add/Remove shortcuts dynamically if the top menu
+ has a tracker. Unparent items that are removed from the collection.
+ * MenuAPI.cs : implement mnemonic, shortcut, and arrow-based keynav.
+ * Theme*.cs: add always_show_hotkeys field to support configurability
+ of mnemonic display. win32 doesn't show mnemonics until Alt is
+ pressed.
+
+2005-12-07 Jackson Harper <jackson@ximian.com>
+
+ * MdiChildContext.cs: Use Control.ResetCursor.
+ * Control.cs: ResetCursor needs to set the property so that the
+ correct XplatUI call gets made.
+
+2005-12-07 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs: More fixes to make our key events match MS. We
+ were not setting the modifier state on KeyData, and we were
+ not generating any events when Alt was pressed with a key
+ since handling of WM_SYSxxx was missing for the OnKey methods.
+
+2005-12-07 Jackson Harper <jackson@ximian.com>
+
+ * MdiChildContext.cs: reenable the sizing code.
+ - When the mouse leaves a window reset its cursor.
+
+2005-12-07 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeClearlooks.cs: Reflect latest Hwnd changes
+
+2005-12-07 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Hwnd.cs: Now using the theme 3d bordersize to calculate
+ widths of Fixed3D borders
+
+2005-12-07 Jackson Harper <jackson@ximian.com>
+
+ * MdiClient.cs: Fix warnings. Earn Mike's love.
+
+2005-12-07 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeClearlooks.cs:
+ - Adjusted mouse over button color
+ - Added first parts of CheckBox drawing
+ - Added correct color for selected text background
+ - Fixed ComboBox drawing
+ - Added CPDrawBorder3D and CPDrawBorder
+
+2005-12-06 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs: Added call to XBell for AudibleAlert
+
+2005-12-06 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIX11.cs, XplatUIWin32.cs,
+ XplatUIOSX.cs: Added AudibleAlert() method to have a means to
+ alert users via sound. We could add an enum arg with different
+ types of alerts in the future
+
+2005-12-06 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs: Fix behaviour problems pointed out by Mike
+
+2005-12-05 Mike Kestner <mkestner@novell.com>
+
+ * StatusBarPanel.cs: add Invalidate method and hook it into all the
+ prop setters. Calls parent.Refresh for now, but could be maybe be
+ optimized with an internal method on StatusBar at some point.
+ [Fixes #76513]
+
+2005-12-05 Peter Dennis Bartok <pbartok@novell.com>
+
+ * RichTextBox.cs: Implemented get_SelectionColor
+
+2005-12-05 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeClearlooks.cs:
+ - Removed dead code
+ - Draw black button border only if button is Form.AcceptButton
+ - Draw correct button color for pressed RadioButton if the mouse
+ has entered the button
+ - Updated ProgressBar drawing!
+ - Updated CPDrawSizeGrip drawing
+ - Updated StatusBarPanel drawing
+
+2005-12-05 Mike Kestner <mkestner@novell.com>
+
+ * Control.cs (PreProcessMessage): add Keys.Alt based on LParam value.
+ * X11Keyboard.cs (SendKeyboardInput): formal lParam for alt mod.
+
+2005-12-04 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeClearlooks.cs: Initial check-in, activate with
+ export MONO_THEME=clearlooks
+ * ThemeEngine.cs: Added ThemeClearlooks
+
+2005-12-03 Mike Kestner <mkestner@novell.com>
+
+ * MenuAPI.cs: deactivate menus prior to calling item.PerformClick.
+ [Fixes #76897]
+
+2005-12-02 Jackson Harper <jackson@ximian.com>
+
+ * Form.cs: If the child form has no menu the default main menu is
+ used as the active menu.
+
+2005-12-02 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ListBox.cs: Check if any items exist before trying to resolve
+ coordinates into items
+
+2005-12-02 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ThemeWin32Classic.cs: Hatchbrush on Win32 seems to always use white
+ as the second color for the background hatch
+
+2005-12-02 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextBoxBase.cs: Now uses Jackson's new and improved ImplicitScrollbar
+ * RichTextBox.cs: FormatText position arguments are 1-based, now making
+ sure that what we pass to FormatText is always 1-based. Fixes #76885
+
+2005-11-29 Miguel de Icaza <miguel@novell.com>
+
+ * NumericUpDown.cs (EndInit): When we are done initializing,
+ reflect any updates on the UI.
+
+2005-12-02 Jackson Harper <jackson@ximian.com>
+
+ * ImplicitHScrollBar.cs:
+ * ImplicitVScrollBar.cs: New scrollbars that don't take focus from
+ their container controls.
+ * TreeView.cs: Use the new implicit scrollbars.
+
+2005-12-02 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Make top_node internal so the TreeNodeCollections
+ can play with it.
+ * TreeNodeCollection.cs: If we remove the topnode we need to
+ update topnode to the next node in line.
+ - When clearing nodes go through the same process as removing
+ them, so they get depareneted and checked if they are top node.
+
+2005-12-01 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: When imagelists are used the image area is
+ selectable as well as the text.
+ - If there are no selected nodes select the first one.
+ * TreeNodeCollection.cs: Getting the TreeView is mildly expensive,
+ so don't do it more then we need to.
+
+2005-12-01 Jackson Harper <jackson@ximian.com>
+
+ * ThemeWin32Classic.cs: Reimplement the scroll arrow drawing so
+ that arrows can be scaled.
+
+2005-12-01 Jackson Harper <jackson@ximian.com>
+
+ * TreeNode.cs : Fixed bugs that caused FullPathTest + Traverse to
+ fail. Patch by Dieter Bremes
+
+2005-11-30 Jackson Harper <jackson@ximian.com>
+
+ * Form.cs: Property is 2.0 only
+ * PrintDialog.cs: Signature fix.
+
+2005-11-30 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextControl.cs:
+ - No longer artificially moves text 2 pixels down (now that we have
+ borders this is no longer needed)
+ - Added calcs for left, hanging and right indent
+
+2005-11-23 Mike Kestner <mkestner@novell.com>
+
+ * Menu.cs: mark MenuChanged internal, since it's not exposed by MS.
+
+2005-11-30 Jackson Harper <jackson@ximian.com>
+
+ * MdiChildContext.cs: Set the cloned menus forms, as these don't
+ get cloned as part of CloneMenu ().
+ * Menu.cs: Make sure the parent of the items get set correctly
+ when they are added. And the owners are notified of the changes.
+ * Form.cs: Create an ActiveMenu property, so that when MDI is used
+ we can change the menu being displayed/handled by the form without
+ changing the menu assosciated with the form.
+ - Don't let Mdi children draw/handle menus.
+
+2005-11-30 Jackson Harper <jackson@ximian.com>
+
+ * Menu.cs: Switch the MenuChanged method to OnMenuChanged and add
+ a MenuChanged event. Just to make the API a little more
+ consistent.
+ * MainMenu.cs:
+ * MenuItem.cs: Use the new OnMenuChanged
+ * MdiChildContext.cs: Handle menu merging.
+ * Form.cs: Implement MergedMenu.
+
+2005-11-30 Jackson Harper <jackson@ximian.com>
+
+ * Menu.cs: We were misusing Add. Add goes behind the specified
+ index according to the docs, and does not replace the specified
+ index. So I added an Insert method.
+
+2005-11-30 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextBoxBase.cs: Implemented Ctrl-Ins (Copy), Shift-Ins (Paste) and
+ Shift-Del (Cut), apparently Emacs uses these old Win 2.x keys. This
+ is for Jackson
+ * RichTextBox.cs: Added calls to base for DnD events
+
+2005-11-28 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextControl.cs:
+ - Fixed drag-selection related crash; style fixes
+ - Implemented undo class
+ o Implemented method to capture document state for specified
+ range in document tree
+ o Implemented method to restore captured document state
+ o Implemented cursor tracking
+ o Implemented basic undo stack
+ - Added undo cursor tracking to methods altering cursor location
+ - Added undo tracking to selection deletion (still missing
+ other text-altering hookups)
+ * RichTextBox.cs:
+ - Added SelectionLength property
+ - Implemented CanPaste()
+ - Implemented Paste()
+ - Added missing protected methods
+ - Fixed RTF->Document conversion; now uses font index 0 and color
+ index 0 as the default font for the parsed text
+ - Fixed RTF<->Document font size translation
+ - Fixed RTF generation, now properly handles cross-tag boundaries
+ for single line selection
+ - No longer always appends blank line to generated RTF
+ - Removed TODOs
+ - Added missing attributes
+ - Hooked up undo-related methods
+ * TextBoxBase.cs:
+ - Implemented Copy()
+ - Implemented Paste()
+ - Implemented Cut()
+ - Fixed caret mis-behaviour on backspace across line-boundaries
+
+2005-11-29 Jackson Harper <jackson@ximian.com>
+
+ * MdiClient.cs: Add a method for activating mdi children. Very
+ basic right now. I imagine someday it might need more girth.
+ * MenuItem.cs: Implement MDI lists. When mdilist is true the mdi
+ children windows names are added to the menu item.
+ * ThemeWin32Classic.cs: Draw the arrow if the item is an
+ mdilist. This happens regardless of whether or not there are any
+ mdi windows to see in the list, and according to my tests happens
+ before the items are even added. Also happens if there isn't even
+ an mdi client to get windows from.
+
+2005-11-29 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeWin32Classic.cs: Make DrawFlatStyleRadioButton protected
+ * ThemeNice.cs: Fix drawing of flatstyle radiobuttons
+
+2005-11-29 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * DataGridTableStyle.cs:
+ - Create always the styles for the missing columns even if they are
+ provided by the user (not default table style)
+ * DataGrid.cs:
+ - Fixes bug 76770
+ - Fixes SetDataBinding (always re-attach source)
+ - Fixes SetNewDataSource (only clear styles if they are not for
+ this source)
+ - Expands OnTableStylesCollectionChanged to handle style refresh
+ and remove properly
+
+2005-11-29 Jackson Harper <jackson@ximian.com>
+
+ * FileDialog.cs: Implement missing bits, remove some dead
+ code.
+ * FontDialog.cs: Implement missing Apply stuff, and ToString. Move
+ creation of the panel so that the options set on the dialog are
+ seen when the panel is created.
+ * TreeView.cs: raise a click when items are clicked.
+
+2005-11-29 Jackson Harper <jackson@ximian.com>
+
+ * MdiClient.cs: Pass some signature methods through to base.
+
+2005-11-28 Jackson Harper <jackson@ximian.com>
+
+ * ListView.cs: Raise the click event when items are clicked.
+
+2005-11-28 Jackson Harper <jackson@ximian.com>
+
+ * MdiClient.cs: Make this algorithm even more beautiful. And fix
+ a nullref.
+
+2005-11-27 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeNice.cs: - Removed 1 pixel bitmaps
+ - Use SmoothingMode.AntiAlias where it makes sense
+ (ScrollButton arrow for example)
+ - Enhanced Button focus drawing
+ - Fixed ComboBox drawing (no artefacts anymore, focus
+ rectangle is back again, reduced size of ComboButton, etc.)
+ - Fixed RadioButton focus drawing for Appearence.Button
+ - Slight ScrollButton redesign
+ - Some LinearGradientBrush size fixes
+ - GroupBoxes have now rounded edges
+ - Fixed StatusBar drawing
+
+2005-11-25 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeNice.cs: - Remove dead code
+ - use correct background colors for menus, etc.
+ - Fake pixel drawing with 1 pixel bitmaps
+
+2005-11-24 Jackson Harper <jackson@ximian.com>
+
+ * MdiClient.cs: Size the scrollbars when resizing the window.
+ - Resize the maximized windows when the client is resized
+ * Form.cs: Make the child context available
+
+2005-11-23 Jackson Harper <jackson@ximian.com>
+
+ * MdiChildContext.cs: Don't size windows if they are maximized.
+
+2005-11-23 Mike Kestner <mkestner@novell.com>
+
+ * ContextMenu.cs: use MenuTracker.
+ * Control.cs: remove menu handle usage.
+ * Form.cs: remove menu handle usage.
+ * Hwnd.cs: remove menu handle usage.
+ * MainMenu.cs: Draw method moved here from MenuAPI.DrawMenuBar. Proxy
+ motion and clicks to the new Tracker handlers.
+ * Menu.cs: add sizing accessors, SelectedItem prop, kill CreateItems
+ and handle usage.
+ * MenuAPI.cs: refactored to combine popup and menubar event handling.
+ Killed the MENU and MENUITEM data types and associated collections
+ since we now keep the info on Menu and MenuItem. Expanded TRACKER into
+ MenuTracker class that exposes the leftovers from the old MenuAPI
+ static methods. Restructured Capture handling so that only one grab is
+ done for the entire menu hierarchy instead of handing off grabs to
+ submenus. Tracker now has an invisible control to Capture when active.
+ * MenuItem.cs: add sizing accessors, kill Create
+ and handle usage.
+ * Theme.cs: remove menu handle and MENU(ITEM) usage.
+ * ThemeWin32Classic.cs: use Menu/MenuItem sizing props instead of
+ MENU(ITEM). remove menu handle usage, use Menu directly.
+ * XplatUIDriver.cs: remove menu handle usage.
+ * XplatUIOSX.cs: remove menu handle usage.
+ * XplatUIWin32.cs: remove menu handle usage.
+ * XplatUIX11.cs: remove menu handle usage.
+
+2005-11-22 Jackson Harper <jackson@ximian.com>
+
+ * Hwnd.cs: Don't compute the menu size for
+ DefaultClientRectangle.
+ - Reenable menu sizes being computed for GetClienRectangle.
+ * Form.cs: Remove comment of trechery
+
+2005-11-22 Jackson Harper <jackson@ximian.com>
+
+ * Hwnd.cs: The adjustments for the menu bar are made when it is
+ attached to the form.
+
+2005-11-19 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: Create an HGRN of the invalid area for WM_NCPAINT
+ (just like on windows).
+
+2005-11-19 Jackson Harper <jackson@ximian.com>
+
+ * MdiChildContext.cs: Handle all the buttons ourselves. We can't
+ use real buttons anymore because they are in non client area. The
+ one TODO here is that I need to somehow invalidate a section of
+ the non client area.
+
+2005-11-18 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Put the enum check back in now that MDI doesnt have
+ to use this to set border styles.
+ * Form.cs: Only set mdi child windows borders if the handle has
+ been created.
+ * MdiChildContext.cs: Don't set the InternalBorderStyle, just pass
+ this directly on to the driver.
+ - Get the move start position before adjusting for the titlebar
+ height, this fixes the windows "skipping" when they are first
+ moved.
+
+2005-11-18 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: Just compute the mdi borders separately as they
+ don't totally match up with normal form borders.
+
+2005-11-18 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Set WS_ styles for borders, so that the driver does
+ not have to retrieve the control instance to figure out what kind
+ of borders it should have.
+ * Form.cs: Set the WS_EX_MDICHILD flag on mdi children, so the
+ driver can know its an mdi child easily.
+ * XplatUIX11.cs: Get the border styles and whether the window is
+ MDI from the Styles and ExStyles params instead of having to get a
+ control. This prevents a chicken and egg problem.
+
+2005-11-18 Jackson Harper <jackson@ximian.com>
+
+ * MdiClient.cs: Fix typo so scrollbars show up correctly.
+
+2005-11-18 Jackson Harper <jackson@ximian.com>
+
+ * MdiClient.cs: Calculate when to add and remove scrollbars
+ correctly.
+ * MdiChildContext.cs: Adjust the y position to take the titlebar
+ into account.
+ - No height for FormBorderStyle.None
+
+2005-11-18 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Allow non enum values to be used for
+ InternalBorderStyle. MDI does this to set a special border style.
+ - New utility methods for converting points to/from client coords
+ - Add the newly created control to the Controls collection before
+ updating its style. This way UpdateStyle can walk the control
+ heirarchy to find the control if needed.
+ so I don't need to create a new Point object all the time.
+ * Form.cs: Let MDI windows handle their border styles.
+ - Set styles on MDI windows so the correct title style is derived.
+ * MdiChildContext.cs: Move all the painting and window handling
+ into the non client area.
+ - Use correct sizing and put correct buttons on frames based on
+ the FormBorderStyle.
+ - Notify the mdi client about scrolling
+ - Need to handle the buttons ourselves now, because they are all
+ in non client areas and we can't add controls there.
+ * MdiClient.cs: Halfway to scrolling, this implementation is
+ somewhat broken though, we need to check to make sure other
+ windows aren't causing scrolling before removing the bars. Also
+ the bars need to be drawn on top, maybe I can switch implicit
+ controls to be on top.
+ * Hwnd.cs: caption_height and tool_caption_height are now
+ properties of an hwnd, this way they can be set by the driver
+ based on the type of window they are. In X11 the window manager
+ handles the decorations so caption_height is zero unless its an
+ MDI window.
+ - Add 3 pixel borders for MDI windows (0xFFFF).
+ - Get rid of some code duplication, have DefaultClientRectanle
+ just call GetClientRectangle.
+ * XplatUIX11.cs: Pass caption_height and tool_caption_height to
+ Hwnd now.
+ - Set border styles differently for mdi windows.
+ * XplatUIOSX.cs: Pass caption_height and tool_caption_height to
+ Hwnd now.
+
+2005-11-15 Mike Kestner <mkestner@novell.com>
+
+ * Menu.cs: when adding an item to the collection, if item is already
+ parented, remove it from the parent.
+
+2005-11-13 Alexander Olk <alex.olk@googlemail.com>
+
+ * X11DesktopColors.cs: Added KDE support
+
+2005-11-11 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIWin32.cs:
+ - Clipboard methods now can translate Rtf format
+ - No longer removes clipboard contents whenever a new format is added
+ to allow placing multiple formats on the clipboard
+ * Clipboard.cs: Clipboard now supports getting a IDataObject and
+ will place all formats contained in it onto the clipboard. Also
+ now cleans the clipboard before placing a new object onto it
+ * RichTextBox.cs:
+ - Implemented set_Rtf
+ - Implemented set_SelectedRtf
+ - Created InsertRTFFromStream() method to allow single code base
+ for all properties and methods that insert RTF into document
+ - Removed debug output
+ * TextControl.cs:
+ - Fixed Delete(int) to fix up line numbers
+ - Fixed ReplaceSelection to combine start and end line
+ - Fixed serious DeleteChars bug that would leave the document tree
+ broken
+ - Improved DumpTree with several logic checks to detect broken
+ document trees
+ - Removed debug lines
+ - Fixed Caret.WordForward/WordBack moving code, now always also
+ updates caret.tag (fixes crash when word-selecting across tag
+ boundaries via keyboard)
+ - Added Insert() method for inserting multiline text into documents
+ - Fixed DeleteChars() calculation errors that would cause a broken
+ tag chain with multiple tag lines
+ - DeleteChars() no longer crashes on multi-tag lines if not all tags
+ - Split() no longer moves caret if split is at caret location
+ - ReplaceSelection() now updates the cursor and re-displays it
+ - ReplaceSelection() now uses new Insert() method to avoid code
+ duplication
+ - FormatText() can now handle formatting partial lines
+ * TextBoxBase.cs:
+ - Append now uses new TextControl.Insert() method (this avoids
+ duplicate code)
+ - Implemented Ctrl-X (Cut) (
+ - Implemented Ctrl-C (Copy)
+ - Implemented Ctrl-V (Paste) (Still some bugs related to screen
+ regeneration when pasting text; roundtripping Copy&Paste within
+ edit control still fails due to some calculation bugs in GenerateRTF)
+ - The Delete key will now remove the current selection if it is visible
+ * TextBox.cs: Removed debug lines
+ * XplatUI.cs: Trigger initialization of DataFormats (which requires the
+ driver to be initialized and can't therefore be done via a static ctor)
+
+2005-11-10 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextControl.cs: Added backend code for finding char arrays and strings
+ * TextBoxBase.cs:
+ - Added mouse wheel scroll support
+ - Added support for VScroll and HScroll events
+ * RichTextBox.cs:
+ - Implemented all seven Find() variants
+ - Implemented GetCharFromPosition()
+ - Implemented GetCharIndexFromPosition()
+ - Implemented GetLineFromIndex()
+ - Implemented GetPositionFromCharIndex();
+ - Implemented SaveFile for PlainText and UnicodeText
+ - Fixed set_Font, now setting a new font applies that font to
+ the whole document
+ - Implemented generic Document to RTF converter
+ - Implemented SaveFile for RichText format (still missing unicode
+ conversion for non-ansi chars)
+ - Implemented get_Rtf
+ - Implemented get_SelectedRtf
+
+2005-11-09 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs (WndProc): Call HandleClick after having sent OnMouseUp
+ to allow any captures to be released before triggering OnClick. This
+ way a click handler may capture the mouse without interference.
+ * XplatUIX11.cs: Always send mouse messages to grab window if one exists.
+ This way we send them even though X may not allow a grab (if the window
+ isn't visible, for example)
+
+2005-11-08 Pedro Martinez Julia <pedromj@gmail.com>
+
+ * DataGridViewRowEventArgs.cs: DataGridView implementation
+ * DataGridViewElement.cs: DataGridView implementation
+ * DataGridViewComboBoxCell.cs: DataGridView implementation
+ * DataGridViewDataErrorContexts.cs: DataGridView implementation
+ * DataGridViewCellErrorTextNeededEventArgs.cs: DataGridView implementation
+ * DataGridViewColumnHeadersHeightSizeMode.cs: DataGridView implementation
+ * ImageLayout.cs: DataGridView implementation
+ * DataGridViewComboBoxColumn.cs: DataGridView implementation
+ * DataGridViewCellMouseEventHandler.cs: DataGridView implementation
+ * DataGridViewSelectionMode.cs: DataGridView implementation
+ * IDataGridViewEditingControl.cs: DataGridView implementation
+ * DataGridViewSortCompareEventHandler.cs: DataGridView implementation
+ * DataGridViewCellStyleContentChangedEventHandler.cs: DataGridView implementation
+ * DataGridViewAutoSizeModeEventHandler.cs: DataGridView implementation
+ * DataGridViewColumnStateChangedEventHandler.cs: DataGridView implementation
+ * DataGridViewColumnSortMode.cs: DataGridView implementation
+ * DataGridView.cs: DataGridView implementation
+ * DataGridViewRowStateChangedEventHandler.cs: DataGridView implementation
+ * DataGridViewRowPostPaintEventArgs.cs: DataGridView implementation
+ * DataGridViewDataErrorEventArgs.cs: DataGridView implementation
+ * Padding.cs: DataGridView implementation
+ * DataGridViewCellParsingEventArgs.cs: DataGridView implementation
+ * DataGridViewCellStateChangedEventHandler.cs: DataGridView implementation
+ * DataGridViewRowEventHandler.cs: DataGridView implementation
+ * DataGridViewCellPaintingEventHandler.cs: DataGridView implementation
+ * DataGridViewCellFormattingEventHandler.cs: DataGridView implementation
+ * DataGridViewButtonCell.cs: DataGridView implementation
+ * DataGridViewCellStyleContentChangedEventArgs.cs: DataGridView implementation
+ * DataGridViewEditMode.cs: DataGridView implementation
+ * DataGridViewCellValueEventArgs.cs: DataGridView implementation
+ * DataGridViewRowCancelEventArgs.cs: DataGridView implementation
+ * DataGridViewRowHeadersWidthSizeMode.cs: DataGridView implementation
+ * DataGridViewCheckBoxColumn.cs: DataGridView implementation
+ * DataGridViewCellToolTipTextNeededEventHandler.cs: DataGridView implementation
+ * DataGridViewAutoSizeColumnsMode.cs: DataGridView implementation
+ * DataGridViewCellEventHandler.cs: DataGridView implementation
+ * DataGridViewEditingControlShowingEventHandler.cs: DataGridView implementation
+ * DataGridViewCellStyleConverter.cs: DataGridView implementation
+ * DataGridViewSelectedRowCollection.cs: DataGridView implementation
+ * DataGridViewBindingCompleteEventHandler.cs: DataGridView implementation
+ * DataGridViewColumnEventArgs.cs: DataGridView implementation
+ * DataGridViewRowHeightInfoPushedEventHandler.cs: DataGridView implementation
+ * DataGridViewRowContextMenuStripNeededEventHandler.cs: DataGridView implementation
+ * QuestionEventArgs.cs: DataGridView implementation
+ * IDataGridViewEditingCell.cs: DataGridView implementation
+ * DataGridViewTriState.cs: DataGridView implementation
+ * DataGridViewColumnDesignTimeVisibleAttribute.cs: DataGridView implementation
+ * DataGridViewCellStateChangedEventArgs.cs: DataGridView implementation
+ * DataGridViewColumnCollection.cs: DataGridView implementation
+ * DataGridViewCellValueEventHandler.cs: DataGridView implementation
+ * DataGridViewRowDividerDoubleClickEventHandler.cs: DataGridView implementation
+ * DataGridViewCellFormattingEventArgs.cs: DataGridView implementation
+ * DataGridViewColumn.cs: DataGridView implementation
+ * DataGridViewCellBorderStyle.cs: DataGridView implementation
+ * DataGridViewCellContextMenuStripNeededEventHandler.cs: DataGridView implementation
+ * DataGridViewCellValidatingEventArgs.cs: DataGridView implementation
+ * DataGridViewRow.cs: DataGridView implementation
+ * DataGridViewImageCellLayout.cs: DataGridView implementation
+ * DataGridViewImageCell.cs: DataGridView implementation
+ * DataGridViewTopLeftHeaderCell.cs: DataGridView implementation
+ * DataGridViewCheckBoxCell.cs: DataGridView implementation
+ * DataGridViewHeaderCell.cs: DataGridView implementation
+ * DataGridViewCellErrorTextNeededEventHandler.cs: DataGridView implementation
+ * DataGridViewRowHeightInfoPushedEventArgs.cs: DataGridView implementation
+ * DataGridViewAutoSizeColumnsModeEventHandler.cs: DataGridView implementation
+ * DataGridViewTextBoxColumn.cs: DataGridView implementation
+ * QuestionEventHandler.cs: DataGridView implementation
+ * DataGridViewCellStyleScopes.cs: DataGridView implementation
+ * DataGridViewSortCompareEventArgs.cs: DataGridView implementation
+ * DataGridViewCellContextMenuStripNeededEventArgs.cs: DataGridView implementation
+ * DataGridViewCell.cs: DataGridView implementation
+ * DataGridViewCellEventArgs.cs: DataGridView implementation
+ * DataGridViewClipboardCopyMode.cs: DataGridView implementation
+ * DataGridViewCellStyle.cs: DataGridView implementation
+ * DataGridViewColumnHeaderCell.cs: DataGridView implementation
+ * DataGridViewRowPrePaintEventHandler.cs: DataGridView implementation
+ * DataGridViewRowCancelEventHandler.cs: DataGridView implementation
+ * TextFormatFlags.cs: DataGridView implementation
+ * DataGridViewCellToolTipTextNeededEventArgs.cs: DataGridView implementation
+ * DataGridViewDataErrorEventHandler.cs: DataGridView implementation
+ * DataGridViewAdvancedCellBorderStyle.cs: DataGridView implementation
+ * DataGridViewCellPaintingEventArgs.cs: DataGridView implementation
+ * DataGridViewButtonColumn.cs: DataGridView implementation
+ * DataGridViewRowsRemovedEventArgs.cs: DataGridView implementation
+ * HandledMouseEventArgs.cs: DataGridView implementation
+ * DataGridViewCellParsingEventHandler.cs: DataGridView implementation
+ * DataGridViewColumnDividerDoubleClickEventHandler.cs: DataGridView implementation
+ * DataGridViewCellMouseEventArgs.cs: DataGridView implementation
+ * DataGridViewAutoSizeRowsMode.cs: DataGridView implementation
+ * DataGridViewRowCollection.cs: DataGridView implementation
+ * DataGridViewAdvancedBorderStyle.cs: DataGridView implementation
+ * DataGridViewCellCancelEventHandler.cs: DataGridView implementation
+ * DataGridViewHitTestType.cs: DataGridView implementation
+ * DataGridViewAutoSizeModeEventArgs.cs: DataGridView implementation
+ * DataGridViewColumnStateChangedEventArgs.cs: DataGridView implementation
+ * DataGridViewColumnEventHandler.cs: DataGridView implementation
+ * DataGridViewRowDividerDoubleClickEventArgs.cs: DataGridView implementation
+ * DataGridViewAutoSizeRowMode.cs: DataGridView implementation
+ * DataGridViewRowHeightInfoNeededEventArgs.cs: DataGridView implementation
+ * DataGridViewRowsDeletedEventArgs.cs: DataGridView implementation
+ * DataGridViewTextBoxEditingControl.cs: DataGridView implementation
+ * DataGridViewContentAlignment.cs: DataGridView implementation
+ * DataGridViewRowPostPaintEventHandler.cs: DataGridView implementation
+ * DataGridViewComboBoxEditingControl.cs: DataGridView implementation
+ * DataGridViewCellValidatingEventHandler.cs: DataGridView implementation
+ * DataGridViewSelectedColumnCollection.cs: DataGridView implementation
+ * DataGridViewPaintParts.cs: DataGridView implementation
+ * DataGridViewCellCollection.cs: DataGridView implementation
+ * DataGridViewRowsAddedEventArgs.cs: DataGridView implementation
+ * DataGridViewImageColumn.cs: DataGridView implementation
+ * DataGridViewRowsRemovedEventHandler.cs: DataGridView implementation
+ * DataGridViewElementStates.cs: DataGridView implementation
+ * DataGridViewRowHeightInfoNeededEventHandler.cs: DataGridView implementation
+ * DataGridViewColumnDividerDoubleClickEventArgs.cs: DataGridView implementation
+ * DataGridViewRowPrePaintEventArgs.cs: DataGridView implementation
+ * DataGridViewRowStateChangedEventArgs.cs: DataGridView implementation
+ * DataGridViewEditingControlShowingEventArgs.cs: DataGridView implementation
+ * DataGridViewCellCancelEventArgs.cs: DataGridView implementation
+ * DataGridViewRowHeaderCell.cs: DataGridView implementation
+ * DataGridViewBindingCompleteEventArgs.cs: DataGridView implementation
+ * DataGridViewTextBoxCell.cs: DataGridView implementation
+ * DataGridViewBand.cs: DataGridView implementation
+ * DataGridViewAutoSizeColumnModeEventArgs.cs: DataGridView implementation
+ * DataGridViewHeaderBorderStyle.cs: DataGridView implementation
+ * DataGridViewRowsAddedEventHandler.cs: DataGridView implementation
+ * DataGridViewAutoSizeColumnMode.cs: DataGridView implementation
+ * DataGridViewAutoSizeColumnModeEventHandler.cs: DataGridView implementation
+ * DataGridViewAutoSizeColumnsModeEventArgs.cs: DataGridView implementation
+ * DataGridViewRowErrorTextNeededEventHandler.cs: DataGridView implementation
+ * DataGridViewSelectedCellCollection.cs: DataGridView implementation
+ * DataGridViewRowContextMenuStripNeededEventArgs.cs: DataGridView implementation
+ * DataGridViewRowErrorTextNeededEventArgs.cs: DataGridView implementation
+ * DataGridViewComboBoxDisplayStyle.cs: DataGridView implementation
+
+2005-11-08 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ThemeWin32Classic.cs:
+ - Draw the outside focus rectangle around buttons
+ - Use CPDrawFocusRectangle to draw focus rectangles until Cairo
+ doesn't use end caps for every dash of a line anymore. This
+ workaround ignores the forecolor.
+
+2005-11-08 Kornél Pál <kornelpal@hotmail.com>
+
+ * ImageList.cs: Don't use ArgbColor with LayoutKind.Explicit as it isn't
+ endian safe.
+
+2005-11-07 Jackson Harper <jackson@ximian.com>
+
+ * X11Dnd.cs: Set the X/Y positions on the DragEventArgs correctly.
+
+2005-11-07 Jackson Harper <jackson@ximian.com>
+
+ * ScrollableControl.cs: Calculate the maximum and change vars
+ (more) correctly so that scrollbars appear as a sensible size.
+
+2005-11-04 Jackson Harper <jackson@ximian.com>
+
+ * TreeNodeCollection.cs: Refresh when nodes are cleared from the
+ collection.
+ * TreeView.cs: When the tree is sorted null out the top_node so
+ that it is recalculated.
+ - Use dotted lines instead of dashed lines to match MS better.
+
+2005-11-04 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * ListView.cs:
+ - Implements key search for items. Useful when browsing files with FileDialog
+ - When changing view mode or when clear the items reset scrollbar positions
+
+2005-11-04 Jackson Harper <jackson@ximian.com>
+
+ * CurrencyManager.cs: Implement the MetaDataChanged event, the
+ Reset method, and the CheckEmpty. CheckEmpty is just a total guess
+ as to what the method may do as there is no real way of creating a
+ derived CurrencyManager and calling the method.
+
+2005-11-03 Jackson Harper <jackson@ximian.com>
+
+ * ThemeWin32Classic.cs: Implement ownerdrawing in the tab control
+ * TabControl.cs: Add Ownerdrawing bits, add the UpdateTabSelection
+ method which seems to just be used internally to refresh the tabs.
+
+2005-11-03 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Implement the remove method. Fix some broken
+ comments.
+
+2005-11-03 Peter Dennis Bartok <pbartok@novell.com>
+
+ * DateTimePicker.cs:
+ - Added missing DateTimePickerAccessibleObject class
+ - Added missing events
+ - Added OnFontChanged method
+ * Form.cs: Added missing attributes
+ * TreeView.cs: Added missing attributes
+
+2005-11-03 Peter Dennis Bartok <pbartok@novell.com>
+
+ * GridItemCollection.cs: Fix signatures
+
+2005-11-03 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUI.cs: Updated build rev/date
+ * ComboBox.cs, DataGridTextBoxColumn.cs Control.cs,
+ DataGridTableStyle.cs, DataGrid.cs, DateTimePicker.cs: Signature fixes
+ * Application.cs: Trigger context-specific ExitThread events
+
+2005-11-03 Jackson Harper <jackson@ximian.com>
+
+ * Menu.cs:
+ * MainMenu.cs:
+ * GridTableStylesCollection.cs:
+ * Timer.cs:
+ * TabPage.cs:
+ * HelpProvider.cs:
+ * StatusBar.cs:
+ * MonthCalendar.cs: Signature fixes
+
+2005-11-03 Jackson Harper <jackson@ximian.com>
+
+ * TreeNodeCollection.cs: Remove should not be virtual.
+ * TreeView.cs: Implement the last of the missing methods.
+
+2005-11-03 Jackson Harper <jackson@ximian.com>
+
+ * TreeNodeConverter.cs: Implement to get off my class-status back.
+
+2005-11-03 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Hookup the bits for drag and drop.
+ * TreeNode.cs: Don't cache the tree_view or index anymore, now
+ that nodes can be moved from tree to tree easily this just causes
+ all sorts of problems.
+ * TreeNodeCollection: Don't need to give treenodes an index and
+ treeview anymore when they are added, these are computed on the
+ fly. Also make sure to remove a node before its added.
+
+2005-11-03 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextControl.cs:
+ - Added CaretSelection enum
+ - Added comparison methods to Marker struct, makes selection code
+ more readable
+ - Added SelectionStart and SelectionEnd as 'moveable' location for
+ the CaretDirection enum and handler
+ - Added selection_prev variable to track optimized invalidation for
+ word and line selection
+ - Added SelectionVisible property (returns true if there is a valid
+ selection)
+ - Switched CaretHasFocus to only display the caret if there is no
+ visible selection
+ - Avoiding StringBuilder.ToString to retrieve a single char, instead
+ using the direct character index; should be much faster
+ - Added various conditional debug statements
+ - Fixed invalidation calculation for selection ranges
+ - Added ExpandSelection() method to support word and line selection
+ - Switched SetSelectionToCaret to use new Marker compare overloads
+ - Added central IsWordSeparator() method to determine word
+ separators/whitespace and FindWordSeparator() to streamline common
+ usage of IsWordSeparator()
+ * TextBoxBase.cs:
+ - Removed unneeded grabbed variable, it was just mirroring
+ Control.Capture
+ - No longer firing OnTextChanged event when Text setter is called,
+ since the base will fire the event for us
+ - Added handling of Ctrl-Up/Down selection
+ - Added handling of Shift-Cursorkey selection
+ - Added handling for Ctrl-Delete and Ctrl-Backspace to remove
+ words
+ - Added handling of Shift and Ctrl-Shift-Home/End selection
+ - Removed some debug output
+ - Added handling for single/double/tripple-click to place caret/
+ select word/select line respectively (Fixes bug #76031)
+ - Added support for drag expansion of word/line selection
+ * RichTextBox.cs: Handle GotFocus event to trigger redrawing of
+ current selection
+
+2005-11-02 Jackson Harper <jackson@ximian.com>
+
+ * X11Dnd.cs: If the drag is going to and from a MWF window just
+ copy the data instead of sending it out through the X Selection
+ mechanism.
+
+2005-11-02 Jackson Harper <jackson@ximian.com>
+
+ * X11Dnd.cs:
+ * XplatUIX11.cs: When in a drag we don't want motion notify
+ messages to get passed on to the other controls. This prevents
+ mouse move messages from showing up in the drag source.
+
+2005-11-02 Jackson Harper <jackson@ximian.com>
+
+ * X11Dnd.cs: Remove unneeded call to XAllowEvents. Make sure that
+ the correct button is release to end a drag.
+ * XplatUIX11.cs: Make the button state internal so the drag system
+ can access it. Dragging needs to know about all button releases,
+ not just left button.
+
+2005-11-02 Miguel de Icaza <miguel@novell.com>
+
+ * Form.cs (Icon): If the icon is null, reset the icon to the
+ default value.
+
+ * Cursor.cs: When writing the AND-mask bitmap do not include the
+ number of colors, but hardcode those to two (black and white),
+ fixes the loading of color cursors (Paint Dot Net).
+
+ * Form.cs: To debug, allow MONO_MWF_SCALING=disable variable to
+ turn off autoscaling.
+
+ * Cursor.cs: Allow resource type to be 1 or 2 (from ImageMagic).
+
+2005-11-02 Jackson Harper <jackson@ximian.com>
+
+ * X11Dnd.cs: Make sure to send a status message if the pointer
+ enters a control that can not accept a drop, otherwise the cursor
+ isn't updated correctly. Also tried to compress the lines of code
+ a bit.
+
+2005-11-02 Jackson Harper <jackson@ximian.com>
+
+ * X11Dnd.cs: Change cursors based on drag action. Also attempt to
+ set actions correctly. This isn't perfect as XDND and win32 have
+ some differences on how you allow actions. I'll clear this up by
+ adding a path for drag from MWF to MWF windows.
+ * XplatUIX11.cs: Hook into the dnd system.
+
+2005-11-02 Jordi Mas i Hernandez <jmas@softcatala.org>
+
+ * ListView.cs: Fixes scroll bar visibility. Hide them if they were
+ previously shown but they are no longer need it. Very obvious when
+ browsing files with FileDialog.
+
+2005-11-01 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs: We always need to call OnPaintBackground. We pretty much
+ ignore AllPaintingInWmPaint and always do the painting there, whether
+ it's set or not, since we always ignore the WM_ERASEBKGND message
+ (which we don't generate on X11). This fixes #76616.
+ * Panel.cs: Removed unneeded background painting. This happens properly
+ in Control.cs already
+
+2005-10-31 Mike Kestner <mkestner@novell.com>
+
+ * Menu.cs: Add items to collection before setting their index.
+ * MenuItem.cs : add range checking with ArgumentException like MS.
+ [Fixes #76510]
+
+2005-10-31 Jackson Harper <jackson@ximian.com>
+
+ * ListBox.cs: Invalidate if the area is visible at all not just
+ contained in the visible rect. Fixes unselection of semi visible
+ items.
+
+2005-10-31 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Consistently name the dnd methods. Make them
+ internal so we can override them to match some MS behavoir
+ internally.
+ * Win32DnD.cs: Use the new consistent names.
+
+2005-10-31 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Don't draw the selected node when we lose focus.
+
+2005-10-31 Jackson Harper <jackson@ximian.com>
+
+ * X11Dnd.cs: We still need to reset the state even though a full
+ reset isn't being done, otherwise status's still get sent all over
+ the place.
+
+2005-10-31 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Make the dnd_aware flag internal so the dnd
+ subsystem can check it. Catch exceptions thrown in dnd handlers to
+ match MS behavoir.
+ * Hwnd.cs: Add a flag for whether or not a window is dnd aware.
+ * X11Dnd.cs: Handle null data in the converters. Set the XDND
+ version when sending a XdndEnter. Use the control/hwnd dnd_aware
+ flags to reduce the number of dnd enters/status's sent.
+
+2005-10-31 Jackson Harper <jackson@ximian.com>
+
+ * X11Dnd.cs: Don't need the sizeof here. Patch by Jordi Mas.
+
+2005-10-31 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * PictureBox.cs: Fixes 76512
+
+2005-10-28 Jackson Harper <jackson@ximian.com>
+
+ * X11Dnd.cs: Early implementation to support winforms being a drag
+ source for data on X11. Also restructured the converters so they
+ can go both ways now.
+ * XplatUIX11.cs: Tie ins to the the Dnd stuff.
+
+2005-10-27 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs: Fixed FIXME - implemented ASCII encoding for XA_STRING
+ clipboard requests
+
+2005-10-27 Jackson Harper <jackson@ximian.com>
+
+ * TreeNode.cs: Implement serialization so my DnD examples will work.
+
+2005-10-24 Kornél Pál <kornelpal@hotmail.com>
+
+ * ButtonBase.cs, ListView.cs, NotifyIcon.cs, PictureBox.cs, ToolBar.cs,
+ TreeView.cs: Don't dispose objects that are not owned.
+
+2005-10-24 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Cursor.cs: Defaulting the Current cursor to Cursors.Default. We
+ should retrieve the current cursor and report that, but XplatUI
+ doesn't (yet) have an interface for that (and I'm not sure I even
+ can, on X11)
+ * XplatUIWin32.cs: Fixed override behaviour. The override is temporary,
+ until any message loop processing is done (and the WM_SETCURSOR
+ replaces the cursor to the proper one)
+ * XplatUIX11.cs:
+ - Fixed override behaviour, we can't set the cursor globally on X11,
+ just for our windows.
+ - Invalidating the System.Drawing X11 display handle when we are
+ shutting down
+ * Control.cs: Fix to make csc happy
+
+2005-10-23 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextBoxBase.cs:
+ - get_Text: Add last line (without trailing newline) to returned
+ value (Fixes 76212)
+ - get_TextLength: Count last line in returned length
+ - ToString: Call Text property instead of duplicating code
+
+2005-10-23 Kornél Pál <kornelpal@hotmail.com>
+
+ * ImageList.cs: Dispose ImageAttributes objects.
+
+2005-10-22 Kornél Pál <kornelpal@hotmail.com>
+
+ * ImageList.cs: Use attribute constructors with less arguments where
+ possible.
+
+2005-10-22 Kornél Pál <kornelpal@hotmail.com>
+
+ * ImageList.cs: Added lastKeyIndex field and use in IndexOfKey.
+ Use typeof instead of strings when assembly is referenced. Added
+ some more comments.
+
+2005-10-21 Jackson Harper <jackson@ximian.com>
+
+ * ListView.cs: Raise a double click event. Also tried to somewhat
+ fix when the selectedindexchanged event is raised. Its still
+ broken though.
+
+2005-10-21 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: New method to invalidate the plus minus area of a
+ node without invalidating the whole node (maybe this can be used
+ in some more places).
+ * TreeNodeCollection.cs: When adding to an empty node we need to
+ invalidate its plus minus area so the little block shows up.
+
+2005-10-21 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Make sure that when we invalidate a node the bounds
+ are big enough to cover the selected box and the focus
+ rectangle. Use a different colour for the lines connecting nodes
+ so they show up with all themes.
+
+2005-10-21 Peter Dennis Bartok <pbartok@novell.com>
+
+ * NativeWindow.cs: Don't call anything that could call into the driver,
+ we might be on a different thread.
+
+2005-10-21 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs(Dispose): Since Dispose might run on a different thread,
+ make sure that we call methods that could call into the driver via
+ invoke, to avoid thread issues
+
+2005-10-21 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUI.cs: Removed finalizer
+ * XplatUIX11.cs: Removed Destructor, was causing crashes due to X11
+ not allowing to be called on the finalizer thread.
+
+2005-10-21 Kornél Pál <kornelpal@hotmail.com>
+
+ * ImageList.cs:
+ - Reverted r51889 and r51891.
+ - Added ImageListItem class that stores unmodified image items and image
+ properties required to create list images until handle is created.
+ - Added AddItem and moved image creation logic to AddItemInternal.
+ - Added CreateHandle method that creates images based on unmodified items.
+ - Added DestroyHandle that changes state to store unmodified items.
+ - Add and AddStrip methods no more create handle.
+ - ReduceColorDepth has no return value.
+ - Dispose destroys handle.
+ - Modified other methods to reflect the above changes.
+ - Implemented key support.
+ - Added profile 2.0 members and attributes.
+ - Added private Reset and ShouldSerialize methods that provide the same
+ behavior as MS.NET but the Visual Studio .NET designer seems to ignore
+ them as they are private.
+ - Added some more comments about implementation details.
+
+2005-10-21 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGrid.cs: Adds support for vertical scrolling using the mousewheel
+
+2005-10-21 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Binding.cs: No PushData/PullData if there is no binding (fixes crash)
+
+2005-10-21 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridDrawingLogic.cs: Fixes column hit calcultation
+ * DataGridColumnStyle.cs: Remove debug message
+
+2005-10-20 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: We can always get input keys regardless of whether
+ or not editing is enabled. They are used for navigation.
+
+2005-10-20 Jackson Harper <jackson@ximian.com>
+
+ * TreeNode.cs: Use the viewport rect for determining if a node
+ needs to be moved for visibility. Don't use Begin/End edit. This
+ calls a full refresh when its done.
+ * TreeView.cs: New SetBottom works correctly. Make the viewport
+ rect property internal so the treenodes can see it. When clicking
+ on a node we need to ensure that its visible because it might just
+ be partly visible when clicked.
+
+2005-10-20 Jackson Harper <jackson@ximian.com>
+
+ * TreeNodeCollection.cs: Remove debug code.
+
+2005-10-20 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Datagrid.cs: Implements column sorting in Datagrid
+ * DataGridColumnStyle.cs: Implements column sorting in Datagrid
+
+2005-10-20 Jackson Harper <jackson@ximian.com>
+
+ * TreeNodeCollection.cs: Remove items properly. Update the correct
+ area after removing them.
+
+2005-10-20 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Datagrid.cs: Should not call base.OnPaintBackground
+
+2005-10-20 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs (GetMessage):
+ - Now properly calculates NC_xBUTTONDOWN coordinates off the whole
+ window instead of client window
+ - Now properly calculates NC_xBUTTONUP message coordinates
+ - ScreenToMenu now properly calculates it's coordinates of whole
+ window, since menus are in the whole window, not in the client
+ window
+ - Added WholeToScreen coordinate translation method
+
+2005-10-20 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs (GetMessage): Don't return in situations where we don't
+ want to return a message, loop back to the beginning of the function
+ and grab the next real message to process instead.
+
+2005-10-20 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Splitter.cs: Properly set limits if no filler control is used
+
+2005-10-19 Jackson Harper <jackson@ximian.com>
+
+ * ColorDialog.cs: Don't show the help button if it is not enabled
+ instead of disabling it (this is what MS does). Don't create the
+ panel until the dialog is run, otherwise the vars (such as
+ ShowHelp) are not set yet.
+
+2005-10-19 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Implement Begin/EndEdit more correctly so refreshes
+ are reduced when adding nodes.
+ * TreeNode.cs:
+ * TreeNodeCollection.cs: Use UpdateNode instead of refreshing the
+ tree.
+
+2005-10-19 Jackson Harper <jackson@ximian.com>
+
+ * FolderBrowserDialog.cs: End editing our treeview so the window
+ actually gets refreshed.
+
+2005-10-18 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs: Fixed logic flip on when to call OnPaintBackground.
+ Obsoleted handling of WM_ERASEBKGND, now always draws our background
+ inside of WM_PAINT
+
+2005-10-18 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * MenuAPI.cs: Returns after Hidding window
+ * XplatUIX11.cs: Added TODO found while debugging menu issues
+
+2005-10-18 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs: Do not re-map the whole window when it's size
+ becomes non-zero unless it's supposed to be actually visible
+
+2005-10-18 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: We don't need to keep a count anymore.
+ * TreeNodeCollection.cs: Fix off by one in RemoveAt, Insert can
+ use the Grow method.
+
+2005-10-18 Jackson Harper <jackson@ximian.com>
+
+ * TreeNodeCollection.cs: Insert is not supported on arrays, so
+ implement it manually here.
+
+2005-10-18 Jackson Harper <jackson@ximian.com>
+
+ * ImageList.cs: Dont kill the list when the colour depth is
+ changed, just change the colour depth of all the images.
+ - Same goes for setting the image size. Just resize them all
+ instead of killing the list softly.
+
+2005-10-18 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Don't invalidate empty rectangles.
+
+2005-10-18 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListViewItem.cs:
+ - Adds checked item to the Checked/Item lists (where empty before)
+ - Do not add items to the Selected lists if they are already present
+ * ListView.cs:
+ - Fixes IsFixedSize, SyncRoot, IsReadOnly in many collections
+ - When deleting items make sure that we delete them for the Selected
+ and Checked list also.
+
+2005-10-18 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Label.cs: Dispose objects no longer used
+ * ThemeWin32Classic.cs: Dispose objects no longer used
+
+2005-10-18 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Don't refresh the whole control when the tabs are
+ scrolled, we just need to refresh the tab area.
+
+2005-10-17 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: Compress code a little bit. Only calculate the
+ after handle when we need it.
+
+2005-10-17 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs: When the parent size changes, recalculate anchor
+ positions. Partial fix for #76462
+
+2005-10-17 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ThemeWin32Classic.cs: Make sure the picturebox has it's background
+ drawn. Fixes #76462
+
+2005-10-17 Jackson Harper <jackson@ximian.com>
+
+ * MonthCalendar.cs: Don't create the numeric up down until our
+ handle is created. Otherwise our handle is created in the
+ constructor and we don't know if we are a WS_CHILD or WS_POPUP
+ yet.
+
+2005-10-17 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Merge in patch by Rafael Teixeira to align strings
+ correctly.
+
+2005-10-17 Rafael Teixeira <rafaelteixeirabr@hotmail.com>
+ * TreeNode.cs : small logical fix (was using local var instead of field)
+
+2005-10-17 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ThemeWin32Classic.cs: Fixes vert/horz scrollbar colours
+
+2005-10-17 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ThemeWin32Classic.cs: Fixes focus drawing in for non-flat/popup buttons
+
+2005-10-16 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - Re-implemented anchoring code. My first version was really broken.
+ This fixes bug #76033. Unlike the previous implementation we will
+ no longer have round errors since all numbers are calculated from
+ scratch every time. Removed various anchor-related obsolete vars.
+ - InitLayout no longer causes layout event firing and layout to be
+ performed
+
+2005-10-16 Jackson Harper <jackson@ximian.com>
+
+ * Hwnd.cs: Compute invalid area correctly (fixes my last commit
+ which was broken).
+
+2005-10-16 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Remove debug code.
+
+2005-10-16 Jackson Harper <jackson@ximian.com>
+
+ * XEventQueue.cs: Increase the default queue size (very simple
+ apps needed to grow the queue).
+ * Hwnd.cs: No finalizer so we don't need to suppress
+ finalization. Compute the invalid area manually so a new rectangle
+ does not newto be created.
+ * ScrollableControl.cs: Don't set any params (otherwise visibility
+ isn't set correctly).
+ * MdiChildContext.cs: New constructor takes the mdi parent so it
+ doesn't have to be computed and avoids a crash on windows. Draw
+ the window icon properly, and allow the text to be seen.
+ * Form.cs: Use new MdiChildContext constructor. Make sure the
+ child context isn't null in wndproc.
+ * TabControl.cs: Don't set focus, this is muddling keyboard
+ behavoir. Expand the tab rows when a window size increase will
+ allow extra tabs to be seen. Don't allow tabs smaller than the
+ width of a window to be scrolled out of view.
+ * TreeNode.cs:
+ * TreeView.cs: Use measure string to calculate a nodes width, the
+ width is cached and only updated when the text or the font is
+ changed. Don't check for expand/collapse clicks on the first level
+ nodes if root lines are disabled.
+
+2005-10-16 Ritvik Mayank <mritvik@novell.com>
+
+ * TextBoxBase.cs: Fixes #76352 (passing tab key in a multiline textbox)
+
+2005-10-16 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridBoolColumn.cs: fixes warning
+
+2005-10-16 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ControlPaint.cs: Fixes methods Dark, DarkDark, Light, LightLight
+ to match more to match more precisely the MS Net behavior
+
+2005-10-13 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Hwnd.cs: Added field to track if window is mapped
+ * XplatUIX11.cs:
+ - Unmap windows if they become 0-size, re-map when
+ they are >0 again; fixes #76035
+ - Re-set our error handler after initializing X11Desktop
+ to override any error handlers Gtk or whatever was called
+ may have set.
+
+2005-10-13 Peter Dennis Bartok <pbartok@novell.com>
+
+ * CheckedListBox.cs: Removed unused vars
+ * ListView.cs: Fixed signatures
+ * RichTextBox.cs: Removed unused vars
+ * TextBoxBase.cs: Removed unused vars
+ * XplatUIWin32.cs: Removed unused vars
+ * XplatUIX11.cs: Removed unused vars
+ * XplatUI.cs: Updated version and date to latest published
+
+2005-10-13 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Cursor.cs: Added private .ctor to work around a bug in
+ resourceset (Thanks to Geoff Norton for the help on this)
+ * SplitterEventArgs.cs: Made fields accessible so we don't
+ waste boatloads of objects and can reuse the same one
+ in Splitter
+ * XplatUIWin32.cs(DrawReversibleLine): Now also considers
+ any captions and borders when generating screen coordinates
+ * Splitter.cs: Reimplemented control, now fully complete, uses
+ rubberband drawing, supports and obeys all properties, has
+ proper cursors
+
+2005-10-13 Miguel de Icaza <miguel@novell.com>
+
+ * Form.cs (Form): Setup default values for autoscale and
+ autoscale_base_size; Make these instance variables, not static
+ variables.
+
+ (OnLoad): on the first load, adjust the size of the form.
+
+2005-10-13 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIOSX.cs: Added
+ width argument to DrawReversibleRectangle()
+ * XplatUIWin32.cs, XplatUIX11.cs:
+ - Implemented width for DrawReversibleRectangle()
+ - Added logic to DrawReversibleRectangle that recognizes a zero
+ width or height and only draws a line in that situation
+
+2005-10-12 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUI.cs, XplatUIDriver.cs: Added GetAutoScaleSize()
+ * XplatUIOSX.cs: Stubbed GetAutoScaleSize() method
+ * XplatUIWin32.cs, XplatUIX11.cs: Implemented GetAutoScaleSize()
+ method (it uses our FosterParent window to get a graphics context)
+
+2005-10-12 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUI.cs, XplatUIDriver.cs: Removed EraseWindowBackground
+ and SetWindowBackground methods
+ * Control.cs:
+ - Setting proper ControlStyles
+ - We no longer call XplatUI.SetWindowBackground and XplatUI.
+ EraseWindowBackground, instead we draw the window background
+ ourselves in PaintControlBackground. This behaviour is
+ required to match MS, where, when OnPaintBackground is not
+ called, the background is not drawn.
+ - Removed unneeded Refresh() in set_Text
+ * Hwnd.cs: Dropped the ErasePending support. No longer needed
+ * XplatUIX11.cs:
+ - Created DeriveStyles method to translate from CreateParams to
+ FormBorderStyle and TitleStyle, also handles BorderStyle (which
+ matches FormBorderStyle enum values)
+ - Consolidated SetHwndStyles and CalculateWindowRect border/title
+ style calculations into single DeriveStyles method
+ - Fixed CreateWindow to (finally) use Gravity. This prevents X11
+ from redrawing the whole window on any resize or expose.
+ - Fixed CreateWindow usage of SetWindowValuemask. Before not
+ all styles were applied to our whole/client window appropriately
+ - Removed EraseWindowBackground() and SetWindowBackground() methods
+ - Removed handling of WM_ERASEBKGND message from DefWndProc, we
+ no longer clear/redraw the background through X
+ - Removed handling of erase_pending bit, we have no use for it (or
+ so it seems)
+ * XplatUIOSX.cs:
+ - Removed generation and handling of WM_ERASEBKGND message
+ - Removed EraseWindowBackground() and SetWindowBackground() methods
+ - Removed handling of hwnd.ErasePending flag
+ * XplatUIWin32.cs:
+ - Removed EraseWindowBackground() and SetWindowBackground() methods
+ - We no longer call EraseWindowBackground on PaintEventStart, we
+ ignore the fErase flag, erasing is handled in Control in the
+ background handler
+ * Button.cs, GroupBox.cs, Label.cs, CheckBox.cs, ProgressBar.cs,
+ LinkLabel.cs, ListControl.cs, TabPage.cs, UpDownBase.cs,
+ TextBoxBase.cs, TextBox.cs, ListView.cs, ButtonBase.cs,
+ CheckedListBox.cs, MdiClient.cs, Panel.cs, DataGrid.cs,
+ DataGridTextBox.cs, ScrollBar.cs, ListBox.cs, TrackBar.cs,
+ TabControl.cs, ScrollableControl.cs, ToolBar.cs, PictureBox.cs,
+ DateTimePicker.cs, StatusBar.cs, MonthCalendar.cs: Setting proper ControlStyles
+
+2005-10-12 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * PropertyGrids.cs: Get sub properties
+ * PropertyGridView.cs: Fix drawing code
+
+2005-10-11 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListBox.cs: Fixes 76383
+
+2005-10-11 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumn.cs: Sets location and size before attachment
+ * ThemeWin32Classic.cs: Fixes border drawing and calculations
+ * DataGridDrawingLogic.cs: Fixes border drawing and calculations
+
+
+2005-10-11 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs: Fixes border drawing
+
+2005-10-10 Miguel de Icaza <miguel@novell.com>
+
+ * MimeIcon.cs: Ignore errors if the file can not be read.
+
+2005-10-11 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Theme.cs, ThemeWin32Classic.cs, ListBox.cs:
+ - Fixed border calculations
+ - Fixed horizontal scrolling in single column listboxes
+ - Fixed drawing issues
+
+2005-10-10 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUI.cs, XplatUIOSX.cs, XplatUIWin32.cs: Switched from BorderStyle to
+ FormBorderStyle enum
+ * XplatUIX11.cs: Switched BorderStyle to FormBorderStyle, added
+ code to determine FormBorderStyles from CreateParams
+ * Form.cs:
+ - Fixed bug where we'd set the wrong window styles if we were
+ not creating an MDI window
+ - Added call to XplatUI.SetBorderStyle when form borders are set
+ * Control.cs: Casting BorderStyles to accommodate changed XplatUI APIs
+ * Hwnd.cs:
+ - Removed obsolete edge style
+ - Switched from BorderStyle to FormBorderStyle
+
+2005-10-10 Jackson Harper <jackson@ximian.com>
+
+ * Form.cs: Use the property to get the window handle instead of
+ accessing it directly. Prevents a null reference exception.
+
+2005-10-10 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Don't adjust the rect given to DrawString now that
+ our libgdiplus draws correctly.
+
+2005-10-08 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Don't try to find the clicked on node if there are
+ no nodes in the tree.
+
+2005-10-08 Alexander Olk <alex.olk@googlemail.com>
+
+ * RichTextBox.cs:
+
+ restore
+
+2005-10-08 Alexander Olk <alex.olk@googlemail.com>
+
+ * ImageListStreamer.cs, TreeView.cs, UpDownBase.cs, RichTextBox.cs,
+ ColorDialog.cs, TextControl.cs, Panel.cs, MdiChildContext.cs,
+ ErrorProvider.cs:
+ Use ResPool for brushes and dispose System.Drawing objects that
+ are not used anymore.
+
+2005-10-07 Jackson Harper <jackson@ximian.com>
+
+ * MdiChildContext.cs: Use the new borders instead of drawing them
+ ourselves.
+
+2005-10-06 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Calling UpdateBounds after changing the window's BorderStyle
+ since the style can change the ClientSize
+
+2005-10-06 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs: Made PaintControlBackground virtual
+ * Panel.cs: Overriding PaintControlBackground instead of using paint
+ event; paint event method was interfering with 'real' users of the
+ event.
+
+2005-10-06 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ThemeWin32Classic.cs: remove border drawing since it is handled
+ by the base control class now and was causing double border drawing.
+
+2005-10-06 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Panel.cs: Redraw our background on paint. Not a pretty solution,
+ but it does seem to match MS behaviour. This fixes bug #75324
+
+2005-10-06 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs: A better DrawReversibleRectangle version, however
+ somewhat hackish looking
+
+2005-10-06 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextBoxBase.cs:
+ - We now accept Enter even if AcceptEnter is false, if the containing
+ form does not have an AcceptButton configured (fixes bug #76355)
+ - Calculations are now fixed to no longer use Width/Height, but
+ ClientSize.Width/Height, since we now support borders (this was
+ a result of fixing borders and therefore bug #76166)
+ - We no longer show the horizontal scrollbar if TextBox.WordWrap is
+ true (fixes bug #76354)
+
+2005-10-06 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - Defaulting BorderStyle and setting it in XplatUI when our window
+ is created
+ - Added enum check to InternalBorderStyle setter
+ * XplatUIX11.cs:
+ - Added drawing of window borders
+ - Now properly calculates WM decorations offset for toplevel
+ windows (fixes bug #74763)
+ * XplatUIWin32.cs:
+ - Implemented BorderStyles for windows (we're letting win32 draw
+ the border for us)
+ - Fixed the signature for SetWindowLong
+ * PictureBox.cs, DataGrid.cs, TextBoxBase.cs, ToolBar.cs, Panel.cs,
+ ListBox.cs, Label.cs: Now uses Control.InternalBorderStyle for
+ setting borders
+ * UpDownBase.cs: Remove drawing of borders, this is handled by
+ the driver, outside the client area
+ * ListView.cs: Removed bogus border calculations. The control should
+ be oblivious to borders, since those are not part of the client
+ area.
+ * X11DesktopColors.cs: Commented out (currently) unneeded variables
+ * ThemeWin32Classic.cs: Removed border calculations from ListView
+ drawing code
+
+2005-10-06 Jackson Harper <jackson@ximian.com>
+
+ * MdiChildContext.cs: Clear out the old virtual position remove
+ all the unneeded calls to CreateGraphics.
+
+2005-10-06 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextControl.cs: Use proper color for highlighted text; fixes #76350
+
+2005-10-06 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Form.cs:
+ - Added loading and setting of our new default icon
+ - Only set icon if window is already created
+
+2005-10-06 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Label.cs:
+ - Do not explicitly set the foreground and background colors, to
+ allow inheriting from parents (fixes #76302)
+ - Use Control's InternalBorderStyle property to deal with borders
+
+2005-10-06 Jackson Harper <jackson@ximian.com>
+
+ * MdiChildContext.cs: Use the new xplatui function to draw a
+ reversible rect.
+
+2005-10-06 Jackson Harper <jackson@ximian.com>
+
+ * Form.cs: Add the parent before creating the child context cause
+ we need the parent when setting up the child.
+
+2005-10-06 Jackson Harper <jackson@ximian.com>
+
+ * FolderBrowserDialog.cs: redo the tree population code so a
+ second thread isn't used. Should be a lot faster and more stable
+ now.
+
+2005-10-05 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: There are no expand/collapse boxes if the node has
+ no children.
+
+2005-10-05 Jackson Harper <jackson@ximian.com>
+
+ * X11DesktopColors.cs: Get menu colours for the gtk theme.
+
+2005-10-05 Alexander Olk <alex.olk@googlemail.com>
+
+ * FileDialog.cs: Fix InitialDirectory
+
+2005-10-05 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs:
+ - Fixes changing between styles
+ - Fixes simple mode
+ - Fixes last item crashing when navigating with keyboard
+
+2005-10-05 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * LinkLabel.cs: Related to 76045. Stops the LinkLabel been drawn as a Label
+
+2005-10-05 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: If updating the root node do a full refresh.
+ * TreeNode.cs: The root node should be expanded by default. Also
+ added a utility prop to tell if we are the root node.
+ * TreeNodeCollection.cs: Only refresh if the node we are being
+ added to is expanded. Also added a comment on a potential
+ optimization.
+
+2005-10-04 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Cursor.cs, Hwnd.cs: Added call to GC.SuppressFinalize()
+ in dispose method. Fixes #76330
+
+2005-10-04 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListView.cs, ThemeWin32Classic.cs, ListViewItem.cs:
+
+ - Implements vertical and horizontal scrolling using XplatUI
+ - Fixes keyboard navagation
+ - Fixes EnsureVisible
+ - Drawing fixes
+ - Handles and draws focus properly
+
+
+2005-10-04 Kornél Pál <kornelpal@hotmail.com>
+
+ * ImageList.cs: Use upper case initials for internal fields. ImageStream:
+ Create handle. NET_2_0: Destroy handle when value is null.
+
+2005-10-03 Jackson Harper <jackson@ximian.com>
+
+ * ScrollBar.cs: My last scrollbar patch was broken. This is a
+ revert and a new patch to prevent the thumb from refreshing so
+ much.
+
+2005-10-02 Jackson Harper <jackson@ximian.com>
+
+ * ScrollBar.cs: Don't update position if it hasn't actually
+ changed. This occurs when you hold down the increment/decrement
+ buttons and the thumb gets to the max/min.
+
+2005-10-01 Jackson Harper <jackson@ximian.com>
+
+ * Form.cs:
+ * MdiChildContext.cs:
+ * MdiClient.cs: Implement ActiveMdiChild in Form.
+
+2005-10-01 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs: Include ComboBoxEdit flag for the edit item
+
+2005-10-01 Peter Dennis Bartok <pbartok@novell.com>
+
+ * X11DesktopColors.cs: Bow out gracefully if the Gtk libs cannot
+ be found
+
+2005-09-30 Jackson Harper <jackson@ximian.com>
+
+ * ListBox.cs: Don't do a full refresh unless some data has
+ actually changed.
+
+2005-09-30 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Make sure that the checkboxes size is factored in
+ even when not visible.
+
+2005-09-30 Peter Dennis Bartok <pbartok@novell.com>
+
+ * FileDialog.cs: Fix Jordi's build break
+
+2005-09-30 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * FileDialog.cs:
+ - Use standard the Windows colours for the combobox as espected
+ - Dispose objects that use resouces when no longer need them
+
+2005-09-30 Peter Dennis Bartok <pbartok@novell.com>
+
+ * X11DesktopColors.cs: Initial incomplete implementation
+ * XplatUIX11.cs: Added call to initialize X11DesktopColors
+
+2005-09-30 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Theme.cs:
+ - Switched Theme color names to match the names defined in
+ System.Drawing.KnownColors. Life's hard enough, no need to make
+ it harder.
+ - Added setters to all theme color properties so themes can set
+ their color schemes. The setters also propagate the color changes
+ to System.Drawing.KnownColors via reflection
+ * ControlPaint.cs, Label.cs, TextControl.cs, ToolTip.cs, ThemeNice.cs,
+ ComboBox.cs, MdiChildContext.cs, TextBoxBase.cs, DateTimePicker.cs
+ DataGridColumnStyle.cs, MonthCalendar.cs, TreeView.cs: Updated to
+ use the new, more logical theme color names
+ * XplatUIWin32.cs: Updated the GetSysColorIndex enum to include new
+ post-NT colors
+ * ThemeWin32Classic.cs:
+ - Removed code to set the old classic Windows colors. Instead it
+ now relies on the colors returned by System.Drawing.KnownColors
+ which will be either modern static colors (Unix) or colors
+ read from the user's configuration (Win32)
+ - Updated to use the new, more logical theme color names
+ - Switched DataGrid drawing code to use only Theme colors instead of
+ a mix of System.Drawing.KnownColors and Theme colors
+ - DrawFrameControl(): Removed code that fills the button area, the
+ fill would overwrite any previous fill done by a control. This
+ fixes bug #75338
+ - Added DrawReversibleRectangle() stub
+ * ScrollableControl.cs: Set visible state to false when scrollbars
+ are removed (pdn fix)
+ * XplatUI.cs, XplatUIOSX.cs, XplatUIDriver.cs: Added
+ DrawReversibleRectangle() method to allow drawing primitive
+ 'rubber bands'
+ * XplatUIX11.cs: Implemented DrawReversibleRectangle()
+
+2005-09-30 Kornél Pál <kornelpal@hotmail.com>
+
+ * ImageList.cs: Add(Icon): Create handle.
+
+2005-09-30 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListView.cs:
+ * ThemeWin32Classic.cs:
+ - Fixes detail mode
+ - Sets clippings
+ - Issues with drawing
+
+2005-09-30 Kornél Pál <kornelpal@hotmail.com>
+
+ * ImageList.cs: Moved RecreateHandle back to ImageList as event
+ source has to be the ImageList.
+
+2005-09-30 Kornél Pál <kornelpal@hotmail.com>
+
+ * ImageList.cs: Add(Icon): Use Graphics.DrawIcon instead of Icon.ToBitmap.
+
+2005-09-30 Kornél Pál <kornelpal@hotmail.com>
+
+ * ImageList.cs: ReduceColorDepth: Clean up pointer operations.
+
+2005-09-30 Kornél Pál <kornelpal@hotmail.com>
+
+ * ImageList.cs: ImageCollection: Removed owner field as it is no more used.
+
+2005-09-29 Jonathan Chambers <jonathan.chambers@ansys.com>
+ * GridItem.cs: Fixed TODOs
+ * GridItemCollection.cs: Added ICollection interface
+
+2005-09-30 Kornél Pál <kornelpal@hotmail.com>
+
+ * ImageList.cs: Resize icons when needed.
+
+2005-09-29 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListViewItem.cs
+ - Fixes GetBounds and returns on screen rects
+ * ListView.cs:
+ - Fixes vertical and horzintal scrolling of items
+ * ThemeWin32Classic.cs:
+ - Fixes drawing
+
+2005-09-29 Raja R Harinath <harinath@gmail.com>
+
+ * ImageList.cs (ImageStream) [NET_2_0]: Reflect re-factoring.
+
+2005-09-29 Kornél Pál <kornelpal@hotmail.com>
+
+ * ImageList.cs: Added comments about handle creation. Moved Handle,
+ HandleCreated and OnRecreateHandle implementations to ImageCollection.
+ Handle is created in Add methods.
+
+2005-09-28 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridDrawingLogic.cs:
+ - Takes rows into account on Colum calculations
+ - Returns the column when clickig
+ * DataGrid.cs:
+ - Fixes default HitTestInfo values
+ - Fixes HitTestInfo.ToString
+ - Fixes ResetBackColor
+
+2005-09-28 Jackson Harper <jackson@ximian.com>
+
+ * MdiChildContext.cs: Obey rules for fixed sized windows (no
+ sizing or cursor changes). Also added some temp code to draw the
+ titlebars text (Makes dev a little easier).
+
+2005-09-28 Kornél Pál <kornelpal@hotmail.com>
+
+ * ImageList.cs: AddStrip: Throw ArgumentException when Image is not a Bitmap.
+
+2005-09-28 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListBox.cs: Fixes bug 76253
+
+2005-09-28 Kornél Pál <kornelpal@hotmail.com>
+
+ * ImageList.cs: Added comments about the current implementation. Added
+ ReduceColorDepth, IndexedColorDepths and GetNearestColor to can use
+ Format32bppArgb to preserve transparency and can use Graphics.FromImage
+ while using the specified ColorDepth. ReduceColorDepth uses unsafe code
+ with Bitmap.LockBits for better performance. Revised the whole file to
+ match MS.NET behaviour and provide better performance. Non-public
+ interface members are calling public members even when they throw
+ NotSupportedException for better maintainability. Moved ColorDepth,
+ ImageSize, ImageStream and TransparentColor implementations to
+ ImageCollection for better performance as these properties are not used
+ by ImageList.
+ * ImageListStreamer.cs: Added a new internal constructor that takes an
+ ImageList.ImageCollection and serializes Images based on
+ ImageCollection.ToArray(). Renamed ImageColorDepth to ColorDepth to
+ match ImageList property name.
+
+2005-09-28 Kazuki Oikawa <kazuki@panicode.com>
+
+ * ListBox.cs: Fixes IndexFromPoint for last item
+
+2005-09-27 Jackson Harper <jackson@ximian.com>
+
+ * Form.cs: Set the position of new mdi children correctly.
+
+2005-09-27 Jackson Harper <jackson@ximian.com>
+
+ * MdiClient.cs: New mdi children need to be added to the back of
+ the controls collection so the zorder is set correctly. Also add a
+ count of all the child windows that have been created.
+
+2005-09-27 Jackson Harper <jackson@ximian.com>
+
+ * Form.cs (CreateParams): Setup MDI forms correctly.
+
+2005-09-27 Jackson Harper <jackson@ximian.com>
+
+ * MdiChildContext.cs:
+ * MonthCalendar.cs:
+ * UpDownBase.cs:
+ * ListBox.cs:
+ * ListView.cs:
+ * TextBoxBase.cs:
+ * TreeView.cs:
+ * ScrollableControl.cs:
+ * ComboBox.cs: Add implicit controls using the new implict control
+ functionality in ControlCollection. Also try to block multiple
+ control add in a suspend/resume layout to save some cycles.
+
+2005-09-27 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Add functionality to the controls collection to add
+ 'implicit controls' these are controls that are created by the
+ containing control but should not be exposed to the user. Such as
+ scrollbars in the treeview.
+ * Form.cs: The list var of the ControlsCollection is no longer
+ available because of the potential of implicit controls getting
+ ignored by someone accessing the list directly.
+
+2005-09-26 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs: Fixed SetChildIndex; it no longer causes a child to
+ loose it's parent. (Fixed bug introduced in r49103 when we added
+ setting the child parent to null on Remove)
+
+2005-09-26 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * DataGridBoolColumn.cs: Marked CheckState private to fix public API.
+ * Splitter.cs: Added missing attributes for BorderStyle property.
+ * TextBoxBase.cs: Marked Calculate* methods internal.
+ * TextBox.cs: Fixed DefaultValue for PasswordChar property to match
+ MS.NET.
+
+2005-09-26 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListBox.cs: Fixes navigation to the last item in multicolumn lists
+
+2005-09-25 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Update the node bounds correctly regardless of
+ whether the node is visible.
+
+2005-09-25 Jackson Harper <jackson@ximian.com>
+
+ * ImageList.cs: Don't dispose the image after it is added to the
+ image list. Only reformat images that need to be resized.
+
+2005-09-25 Jackson Harper <jackson@ximian.com>
+
+ * ImageList.cs: Don't set the format when changing the image.
+
+2005-09-25 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: We can't just assume the node has a font. Use the
+ treeviews font if no node font is available.
+
+2005-09-25 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Allow the scrollbars to be reset with negative
+ values.
+ - Don't add scrollbars to negative sized windows.
+
+2005-09-23 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: Update to use Mono.Posix.Native instead of plain
+ old Mono.Posix. Also remove some stray code that shouldn't have
+ been committed.
+
+2005-09-23 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Attempt at proper sizing of the horizontal
+ scrollbar. Also don't resize the scrollbars unless they are
+ visible.
+
+2005-09-23 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: We don't need to expand the invalid area when the
+ selection changes, as this is all drawn in the node's bounding
+ box. The area needs to be expanded (previous typo was contracting
+ it) when the focus rect moves.
+
+2005-09-23 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Display the selection box under the correct
+ circumstances. We were rendering white text with no selection box
+ before.
+
+2005-09-23 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TextControl.cs(Split): Now updates selection start/end if it points
+ into a line that's being split. Fixes a FIXME and bug #75258
+
+2005-09-23 Jackson Harper <jackson@ximian.com>
+
+ * Binding.cs:
+ * ListControl.cs: Don't use the path when retrieving binding
+ managers from the binding context. My bat sense tells me that the
+ path is only used on insertion.
+
+2005-09-22 Jackson Harper <jackson@ximian.com>
+
+ * Splitter.cs: Set the cursor an easier way. (Thanks peter).
+
+2005-09-22 Jackson Harper <jackson@ximian.com>
+
+ * Splitter.cs: There are special cursors used for splitting.
+ * XplatUIX11.cs: The VSplit and HSplit cursors were backwards.
+
+2005-09-22 Jackson Harper <jackson@ximian.com>
+
+ * Splitter.cs: Change the cursor appropriately when the splitter
+ is moused over, so the user actually knows there is a splitter
+ there.
+
+2005-09-22 Hisham Mardam Bey <hisham.mardambey@gmail.com>
+
+ * Label.cs : Fix ToString method to give same output as MS.NET
+
+2005-09-22 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Create the scrollbars when the handle is created
+ and add them right away, just make them invisble. Also account for
+ the window being shrunk vertically to the point that the vert
+ scrollbar needs to be added.
+ - Remove some 0.5 adjustments to get around anti aliasing issues.
+
+2005-09-22 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * MainMenu.cs: Fixes default value
+ * MenuItem.cs: Fixes default value
+
+2005-09-22 Kazuki Oikawa <kazuki@panicode.com>
+
+ * AsyncMethodResult.cs: Fixes Control.Invoke is blocked infinitely.
+
+2005-09-21 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Don't try to set the border style on the window if
+ it hasn't been created. When the window is created the border
+ style will be used.
+
+2005-09-21 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs (Update): Don't call XplatUI if we don't have a
+ window handle yet
+
+2005-09-21 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ContainerControl.cs: Instead of throwing an exception, print
+ a one-time warning about Validate not being implemented
+ * XplatUIWin32.cs: Removed debug output
+
+2005-09-21 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs: Only set XplatUI background if we expect the windowing
+ system to handle the background. This stops controls that draw their
+ own background from flickering
+
+ * XplatUIX11.cs: Support custom visuals and colormaps for window
+ creation. This allows, amongst other things, using MWF X11 windows
+ with OpenGL.
+
+2005-09-21 Peter Dennis Bartok <pbartok@novell.com>
+
+ * OpenFileDialog.cs, ContentsResizedEventArgs.cs, LibSupport.cs, GridItem.cs,
+ CursorConverter.cs, SplitterEventHandler.cs, PropertyGridTextBox.cs,
+ GridTablesFactory.cs, MethodInvoker.cs, AccessibleEvents.cs,
+ SplitterEventArgs.cs, XplatUI.cs, Mime.cs, PropertySort.cs,
+ TreeViewCancelEventHandler.cs, Form.cs, PropertyGridCommands.cs,
+ IDataGridEditingService.cs, DateBoldEventHandler.cs, Label.cs,
+ KeyboardLayouts.cs, TextControl.cs, ProgressBar.cs, ToolTip.cs,
+ RadioButton.cs, OSFeature.cs, LinkLabel.cs, ColorDialog.cs,
+ ThemeNice.cs, ErrorIconAlignment.cs, TreeNode.cs, MimeGenerated.cs,
+ ComboBox.cs, DataGridTextBoxColumn.cs, ArrangeStartingPosition.cs,
+ GridColumnStylesCollection.cs,
+ IDataGridColumnStyleEditingNotificationService.cs,
+ PropertyGrid.cs, IFeatureSupport.cs, ICommandExecutor.cs,
+ MdiLayout.cs, GridEntry.cs, ControlBindingsCollection.cs,
+ GridTableStylesCollection.cs, TreeViewCancelEventArgs.cs,
+ TreeNodeCollection.cs, AmbientProperties.cs,
+ RichTextBoxSelectionAttribute.cs, RichTextBoxSelectionTypes.cs,
+ DataObject.cs, ErrorProvider.cs, Splitter.cs,
+ DataGridLineStyle.cs, Shortcut.cs, Control.cs,
+ FontDialog.cs, SecurityIDType.cs, GridItemType.cs,
+ BindingMemberInfo.cs, DataGridCell.cs, MdiChildContext.cs,
+ IRootGridEntry.cs, PropertyGridView.cs, DataGridParentRowsLabelStyle.cs,
+ FolderBrowserDialog.cs, OpacityConverter.cs, HelpProvider.cs,
+ IComponentEditorPageSite.cs, DataGridTableStyle.cs, NavigateEventArgs.cs,
+ NotifyIcon.cs, ContentsResizedEventHandler.cs, MenuItem.cs,
+ PropertyTabChangedEventHandler.cs, TextBoxBase.cs, OpenTreeNodeEnumerator.cs,
+ SelectionMode.cs, TextBox.cs, ListBindingConverter.cs,
+ FileDialog.cs, KeysConverter.cs, DomainUpDown.cs,
+ DataFormats.cs, SaveFileDialog.cs, GridItemCollection.cs,
+ ArrangeDirection.cs, FeatureSupport.cs, SelectionRangeConverter.cs,
+ RichTextBoxScrollBars.cs, NodeLabelEditEventHandler.cs, TreeNodeConverter.cs,
+ MimeIcon.cs, X11Structs.cs, PropertyGridEntry.cs,
+ ImageList.cs, ThemeWin32Classic.cs, X11Keyboard.cs,
+ CheckedListBox.cs, HelpNavigator.cs, DateTimePickerFormat.cs,
+ MdiClient.cs, DataGridDrawingLogic.cs, DataGridBoolColumn.cs,
+ NodeLabelEditEventArgs.cs, Screen.cs, PropertyManager.cs,
+ ComponentModel.cs, PropertiesTab.cs, CurrencyManager.cs,
+ SizeGrip.cs, DateBoldEventArgs.cs, X11Dnd.cs, Panel.cs,
+ Hwnd.cs, OSXStructs.cs, DrawMode.cs, XplatUIDriver.cs,
+ RichTextBox.cs, PropertyTabChangedEventArgs.cs, CommonDialog.cs,
+ DataGrid.cs, XplatUIX11.cs, RichTextBoxStreamType.cs, Win32DnD.cs,
+ ErrorBlinkStyle.cs, TreeViewEventHandler.cs,
+ PropertyValueChangedEventHandler.cs, IFileReaderService.cs,
+ DataGridTextBox.cs, SelectedGridItemChangedEventArgs.cs, ScrollBar.cs,
+ ListBox.cs, TreeViewAction.cs, Help.cs, TrackBar.cs,
+ AxHost.cs, PropertyValueChangedEventArgs.cs, XplatUIOSX.cs,
+ RichTextBoxFinds.cs, UpDownEventArgs.cs, Cursors.cs,
+ CategoryGridEntry.cs, RichTextBoxWordPunctuations.cs, DataGridColumnStyle.cs,
+ SelectedGridItemChangedEventHandler.cs, DateTimePicker.cs, NavigateEventHandler.cs,
+ Clipboard.cs, UpDownEventHandler.cs, MonthCalendar.cs,
+ SendKeys.cs, DataGridPreferredColumnWidthTypeConverter.cs, TreeView.cs,
+ ThreadExceptionDialog.cs, ImageListConverter.cs, XplatUIWin32.cs,
+ TreeViewEventArgs.cs: Fixed whitespace and set eol-style:native attribute
+
+2005-09-21 Jackson Harper <jackson@ximian.com>
+
+ * TreeNode.cs: Call Before/After Expand not Collapse when
+ expanding.
+
+2005-09-20 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: Use the more hand looking hand (in most themes).
+
+2005-09-16 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListViewItem.cs:
+ - Fixes bug 76120
+ - Fixes proper storing of subitems
+ - Fixes not updated items
+
+2005-09-20 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Control.cs, TextBoxBase.cs, TextControl.cs: Don't do certain
+ things if our window handle isn't created yet. Also disabled
+ debug for TextBoxBase
+
+2005-09-20 Peter Dennis Bartok <pbartok@novell.com>
+
+ * MenuAPI.cs: Remove filtering of events to allow menu usage
+
+2005-09-20 Miguel de Icaza <miguel@novell.com>
+
+ * Cursor.cs: Allow null to be passed to Cursor.Current.
+
+2005-09-20 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeWin32Classic.cs:
+ - Change some private methods/fields to protected virtual so that
+ they can be accessed and overriden in derived classes
+ - First refactoring of some methods. Derived themes now don't
+ need to duplicate the complete code from ThemeWin32Classic
+ * ThemeNice.cs:
+ - Added nice StatusBar
+ - Derive from ThemeWin32Classic and not Theme
+ - Removed duplicate ThemeWin32Classic code
+
+2005-09-20 Miguel de Icaza <miguel@novell.com>
+
+ * Control.cs (ControlCollection.Add): If the value null is passed
+ the control is ignored.
+
+ Optimize this loop.
+
+2005-09-19 Peter Dennis Bartok <pbartok@novell.com>
+
+ * MenuAPI.cs: Replaced Application.Run() with a loop that tracks
+ PostQuitMessage state.
+ * XplatUIWin32.cs: Removed bogus PostQuitMessage P/Invoke with HWND arg
+
+2005-09-19 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Application.cs: Our constructor will never get called, move
+ initialization to fields; fixes bug #75933
+
+2005-09-19 Hisham Mardam Bey <hisham.mardambey@gmail.com>
+
+ * FileDialog.cs :
+ - Allow files to be selected properly using file name
+ combo box.
+ - Add ability to change diretory (absolute / relative)
+ using file name combo box.
+
+2005-09-16 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListBox.cs:
+ - Fixes Multicolumn listboxes item wrong calculations
+ - Allows to click when only one item is in the listbox
+ - Fixes crash when no items using keyboard navigation
+
+2005-09-16 Alexander Olk <alex.olk@googlemail.com>
+
+ * ComboBox.cs: Reverted almost everything from the latest patch which
+ broke ComboBox
+
+2005-09-16 Kazuki Oikawa <kazuki@panicode.com>
+
+ * ToolTip.cs:
+ - Fixed #Mtd2 of ToolTipTest.RemoveToolTipTest.
+ * ComboBox.cs:
+ - When DropDownStyle is Simple, it does not show scrollbar
+ to the last item of the list.
+ - When DropDownStyle is Simple, it crashed when the list was
+ scrolled down with the down cursor key.
+ - Fixed a bug that when DropDownStyle is DropDownList, the
+ selected item was not shown.
+ - The position of the selected item was not preserved when
+ the next dropdown happened.
+ * ThemeWin32Classic.cs:
+ - Items were wrapped at the right end.
+ * CheckedListBox.cs:
+ - Fixed Add method
+ * ListBox.cs:
+ - Items should be fully shown.
+ - When resizing and vertical scrollbar disappeared, the item
+ of index 0 should be on the top of the list.
+ - GetItemRectangle should consider the size of ver. scrollbar
+ * StatusBar.cs:
+ - SizingGrip area should not be allocated when it is not
+ displayed.
+ - Now it reflects MinWidth of the containing panel and
+ fixed a crash that happens when its width becomes so small.
+
+2005-09-13 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * CheckedListBox.cs: Fixes bug 76028
+ * ListBox.cs: Fixes bug 76028
+
+2005-09-13 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ThemeWin32Classic.cs: Sets clipping on DataGridPaintRowsHeaders
+ * DataGridDrawingLogic.cs: fixes issues with Datagrid drawing
+
+2005-09-12 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * XplatUIX11.cs: fixes System.NullReferenceException in some situations
+
+2005-09-09 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * IRootGridEntry.cs: Changed namespace to PropertyGridInternal
+
+2005-09-09 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * IRootGridEntry.cs: Added
+ * PropertyGridCommands.cs: Added
+ * PropertiesTab.cs: Added missing methods and property
+ * PropertyGridView.cs: Made class internal
+ * PropertyGridTextBox.cs: Made class internal
+
+2005-09-09 Alexander Olk <alex.olk@googlemail.com>
+
+ * MimeIcon.cs: Try to check some other environment variables
+ if "DESKTOP_SESSION" returns "default"
+
+2005-09-09 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeNice.cs: Corrected background colors (e.g. menus)
+ * ColorDialog.cs: Use correct background colors for controls
+
+2005-09-09 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeNice.cs: Merged r49535 from ThemeWin32Classic
+
+2005-09-08 Peter Dennis Bartok <pbartok@novell.com>
+
+ * RichTextBox.cs: Added initial implementation
+ * lang.cs: Removed. Was accidentally checked in long time ago
+ * TODO: Removed. Contents were obsolete
+
+2005-09-06 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * PropertiesTab.cs : Added
+
+2005-09-06 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * PropertyGrid.cs : Update
+ * PropertyGridView.cs : Update
+ * System.Windows.Forms.resx : Added images and strings
+
+2005-09-06 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ThemeNice.cs: Do not dispose Pens retrieved from ResPool
+
+2005-09-06 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs: Force a flush after Ungrab; if case the app enters
+ a busy loop right after the Ungrab the X11 display is otherwise
+ blocked
+
+2005-09-06 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ThemeWin32Classic.cs: Optimise the use of clipping
+
+2005-09-05 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGrid.cs: fixes recursion bug
+
+2005-09-03 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeNice.cs:
+ - Draw RadioButton and CheckBox Buttons with DrawButtonBase
+ - Cleanup
+
+2005-09-02 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeNice.cs: Draw nice ProgressBars
+
+2005-09-01 Miguel de Icaza <miguel@novell.com>
+
+ * VScrollBar.cs: Another buglet found by Aaron's tool.
+
+ * ProgressBar.cs: Fix three recursive bugs found by Aaron Tomb's
+ bug finder.
+
+2005-08-30 Alexander Olk <alex.olk@googlemail.com>
+
+ * ThemeNice.cs:
+ - Added nicer menu drawing
+ - Updated DrawTab
+ - some refactoring
+
+2005-08-30 Peter Dennis Bartok <pbartok@novell.com>
+
+ * CreateParams.cs (ToString): Made output match MS
+ * Control.cs (Text): Don't set Text or Focus via XplatUI unless
+ handle is already created (to avoid forcing window creation)
+ * XplatUIX11.cs: Set window text to caption after creating window,
+ in case Text was set before window was created
+ * Form.cs: Use this.Text instead of a static string as caption
+
+2005-08-30 Peter Dennis Bartok <pbartok@novell.com>
+
+ * NotifyIcon.cs: Don't set the window to visible; this screws
+ up Win32 (causes WM_NCPAINT to be sent on Win32, which calls
+ OnPaint without a bitmap)
+ * XplatUIX11.cs: Removed Visible optimization in AddExpose; doesn't
+ happen very often anyway; we could add the check to the WM_PAINT
+ event generation code
+
+2005-08-30 Peter Dennis Bartok <pbartok@novell.com>
+
+ * NotifyIcon.cs: Fill the icon area with a background color, to
+ avoid 'residue' when transparent icons are drawn
+ * XplatUIX11.cs:
+ - Handle whole_window == client_window when destroying windows
+ - SystrayAdd(): Set client_window to whole_window value to
+ get mouse and other events passed to NotifyIcon
+
+2005-08-30 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Form.cs: Set proper default for Opacity property
+ * NotifyIcon.cs:
+ - ShowSystray(): Don't bother creating telling the OS
+ about the systray item if no icon is provided
+ - Now handles WM_NCPAINT message to deal with whole/client window
+ split
+ - Create window as visible to not get caught by Expose optimization
+ * Hwnd.cs: Removed debug message
+ * ComboBox.cs, ScrollBar.cs, ListBox.cs, TrackBar.cs, TabControl.cs,
+ StatusBar.cs, TreeView.cs, XplatUIOSX.cs, XplatUIWin32.cs: Switched
+ PaintEventStart/End to use new client argument
+ * TextBoxBase.cs:
+ - Commented out debug messages
+ - Switched PaintEventStart/End to use new client argument
+ * XplatUI.cs: Added client window bool to PaintEventStart()/
+ PaintEventEnd() calls, to support drawing in non-client areas
+ * XplatUIDriver.cs:
+ - Added client window bool to PaintEventStart()/PaintEventEnd()
+ calls, to support drawing in non-client areas
+ - Added conditional compile to allow using MWF BeginInvoke
+ on MS runtime
+ * XplatUIX11.cs:
+ - Added some conditional debug output
+ - Fixed SystrayAdd() method to support new (for SystrayAdd, anyway)
+ whole/client window split
+ - Implemented handling of client argument to PaintEventStart()/End()
+ * Control.cs:
+ - Throw exception if BeginInvoke() is called and the window handle
+ or one of the window's parent handles is not created
+ - Added conditional compile to allow using MWF BeginInvoke on
+ MS runtime
+ - get_Parent(): Only sets parent if handle is created. This avoids
+ forcing window handle creation when parent is set.
+ - Now fires Layout and Parent changed events in proper order
+ - Switched to use Handle instead of window.Handle for Z-Order setting,
+ the get_Parent() patch above causes us to possibly get null for 'window'
+ - Implemented handling of client argument to PaintEventStart()/End()
+ - Now reports back to windows that WM_SETCURSOR was handled (to avoid
+ default handling)
+ - Now sends a Refresh() to all child windows when Refresh() is called
+
+2005-08-29 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Form.cs: Added (non-functional) Opacity property
+ * XplatUIWin32.cs (SystrayAdd): Removed bogus line of code
+
+2005-08-29 Alexander Olk <xenomorph2@onlinehome.de>
+ * ThemeNice.cs: New theme for MWF, based on ThemWin32Classic
+ use export MONO_THEME=nice to activate it.
+ Currently supported controls:
+ - Button
+ - ComboBox
+ - ScrollBar
+ - TabControl (TabAlignment.Top only, other will follow)
+ * ThemeEngine.cs: Add theme nice
+ * ButtonBase.cs: Redraw button on MouseEnter and MouseLeave everytime,
+ if enabled
+
+2005-08-25 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * Splitter.cs: Resize docked control and its neighbor.
+
+2005-08-24 Rafael Teixeira <rafaelteixeirabr@hotmail.com>
+ -- Making Windows with Menus layout correctly --
+ * Form.cs : The first leg of the fix
+ Menu setter - adjust Client Size as needed to make space for the menu
+ SetClientSizeCore - doesn't call base version to be able to pass the
+ menu handle to XplatUI.CalculateWindowRect
+ * Hwnd.cs: Fix for menu_height, now gets from MenuAPI.MENU
+ * XplatUIX11.cs: The critical second leg of the fix
+ GetWindowPos needs to use a recalculated client_rect
+ so that resizing the window doesn't break layout of child controls.
+ Also a more complete rule to avoid X Server roundtrips in SetWindowPos
+ Lots of \t\n killed
+
+2005-08-23 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Label.cs: Now properly recalculates width and height on Font and Text
+ changes if AutoSize is set
+
+2005-08-19 Rafael Teixeira <rafaelteixeirabr@hotmail.com>
+ * TreeView.cs : Revamped drawing logic, and support for FullRowSelect
+
+2005-08-19 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ImageList.cs: Makes ToString method compatible with MS
+
+2005-08-18 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * MenuAPI.cs: fixes bug 75716
+
+2005-08-11 Umadevi S <sumadevi@novell.com>
+ * Control.cs: Fixed Remove & RemoveAt to make the parent of the control null.
+
+2005-08-11 Umadevi S <sumadevi@novell.com>
+ * Contorl.cs: Fixed ResetRightToLeft and ResetImeMode to work correctly
+
+2005-08-10 Umadevi S <sumadevi@novell.com>
+ * CheckedListBox.cs: Fixed event firing on Adding to the CheckedListBox
+
+2005-08-07 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Menu.cs: fixes bug 75700
+ * MenuAPI.cs: fixes navigation issues
+
+2005-08-09 Umadevi S <sumadevi@novell.com>
+ * CheckedListBox.cs - simple fix for GetItemChecked.
+
+2005-08-08 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs: Serveral fixes
+ * ListBox.cs: Serveral fixes
+
+2005-08-05 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs: Fixes FindString methods and GetItemHeight
+ * ListBox.cs: Fixes FindString methods
+
+2005-08-05 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGrid.cs: fixes bugs exposed by new tests
+
+2005-08-04 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Mime.cs: Compile Mono assembly references only if compiling
+ with Mono (Allows to build with VS.Net again)
+
+2005-07-28 Marek Safar <marek.safar@seznam.cz>
+
+ * Control.cs (PaintControlBackground): Draw background image
+ corrrectly.
+ (CheckForIllegalCrossThreadCalls): Stubbed.
+
+ * Form.cs (OnCreateControl): Center when should be centered.
+
+ * ThemeWin32Classic.cs (DrawPictureBox): Pass size.
+
+2005-07-19 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Binding.cs: Binding to properties should be case unsensitive
+
+2005-07-18 vlindos@nucleusys.com
+
+ * DataGrid.cs: fixes setmember order
+
+2005-07-07 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * MimeIcon.cs: added MimeIcon stuff (MimeIconEngine)
+ * FileDialog.cs: FileDialog is now resizable and uses the new
+ MimeIconEngine
+
+2005-07-06 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumn.cs: default value
+ * GridColumnStylesCollection.cs: fixes event firing, checking MappingName
+ * GridTableStylesCollection.cs: fixes checking MappingName
+ * DataGridDrawingLogic.cs: fixes drawing logic issues
+ * DataSourceHelper.cs: rewritten to make compatible with more data sources
+ * DataGrid.cs: fixes
+
+2005-07-06 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * MimeGenerated.cs: Use case sensitive comparer for
+ NameValueCollections
+
+2005-07-01 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumn.cs: bug fixes, code refactoring
+ * ThemeWin32Classic.cs: bug fixes, code refactoring
+ * DataGridDrawingLogic.cs: bug fixes, code refactoring
+ * DataGrid.cs: bug fixes, code refactoring
+ * DataGridTextBox.cs: bug fixes, code refactoring
+ * DataGridColumnStyle.cs: bug fixes, code refactoring
+ * Theme.cs: bug fixes, code refactoring
+
+2005-07-01 Peter Bartok <pbartok@novell.com>
+
+ * TextControl.cs: Quick fix for the reported crash on ColorDialog
+ and other text box usage
+
+2005-07-01 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Make sure the bottom of the tab covers the pages
+ border.
+
+2005-06-30 Peter Bartok <pbartok@novell.com>
+
+ * Form.cs (ShowDialog): Assign owner of the dialog
+ * TextBoxBase.cs: Always refresh caret size when deleting, caret
+ might have been moved to a tag with different height
+
+2005-06-30 Jackson Harper <jackson@ximian.com>
+
+ * Form.cs: Don't create an infinite loop when setting focus
+ * MenuItem.cs: Don't dirty the parents if we don't have any
+
+2005-06-29 Ben Maurer <bmaurer@ximian.com>
+
+ * LibSupport.cs: Rename
+
+2005-06-29 Peter Bartok <pbartok@novell.com>
+
+ * TextBoxBase.cs: Re-align caret after deleting a character
+ * TextControl.cs:
+ - DeleteChars(): Ensure that tag covers the provided position
+ - StreamLine(): Drop reference for dropped tag
+
+2005-06-29 Peter Bartok <pbartok@novell.com>
+
+ * TextControl.cs:
+ - Selections now work properly, anchoring at the initial location
+ and properly extending in either direction (SetSelectionToCaret(),
+ SetSelectionStart() and SetSelectionEnd())
+ - No longer redraws the whole control on selection change, now
+ calculates delta between previous and new selection and only
+ invalidates/redraws that area
+ - Fixed FindPos() math off-by-one errors
+ - Changed DeleteChars() to verify the provided tag covers the
+ provided position, selections may have a tag that doesn't cover
+ the position if the selection is at a tag border
+ - Fixed off-by-one errors in DeleteChars()
+ - Added missing streamlining check in DeleteChars() to remove
+ zero-length tags
+ - Implemented Invalidate() method, now properly calculates exposures
+ between two given lines/positions
+ - Implemented SetSelection()
+ - Obsoleted and removed FixupSelection()
+ - Improved RecalculateDocument() logic, removing code duplication
+
+2005-06-29 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * LibSupport.cs: changes to match different input/output arguments.
+
+2005-06-29 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * LibSupport.cs: added libsupport.so init routine.
+
+2005-06-29 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ControlBindingsCollection.cs
+ - Throws an exception on null datasource when adding
+ - Checks for duplicated bindings when adding
+
+2005-06-28 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs (OnKeyDown): Support left and right properly
+ (navigates as well as expanding and collapsing.
+ - Add support for Multiply, this expands all the selected nodes
+ children.
+ - Fix some tabbing.
+
+2005-06-28 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Implement keyboard navigation, currently supports,
+ LEFT, RIGHT, UP, DOWN, PGUP, PGDOWN, HOME, END, ADD, SUBTRACT. Add
+ support for toggling checkboxes with the space bar.
+
+2005-06-28 Jackson Harper <jackson@ximian.com>
+
+ * OpenTreeNodeEnumerator.cs: Don't move past the begining of the
+ tree.
+
+2005-06-28 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Add missing event.
+
+2005-06-27 Peter Bartok <pbartok@novell.com>
+
+ * TextControl.cs:
+ - Made line ending size configurable (now allows for counting
+ lineendings as \n or \r\n)
+ - Added margin to viewport to keep caret visible on right side
+ - Fixed translation routines for line/pos to documentpos to consider
+ cr/lf when counting (Fixes RichTextBox.SelectionFont issues)
+ - Fixed some line-endings to be unix style
+ - Fixed Document.FormatText to perform it's calculations 1-based
+ - Added descriptions for a few methods that might otherwise get
+ used wrong
+ - Added NOTE section with some basic conventions to remember at
+ the top of the file
+ - Major fixup for RichTextBox selection drawing:
+ * Fixed crashes when multiple tags on a single line were selected
+ * fixed selection box drawing not overlaying text
+ * fixed bogus offset calculation for tags not starting at index 1
+ * Switched behaviour from using multiple Substrings of a
+ StringBuilder.ToString() to using multiple
+ StringBuilder.ToString(start, length) statements, hoping this is
+ faster (kept original version commented out in the code, in case
+ original version was faster)
+ * TextBox.cs (set_TextAlignment): TextBox always needs to wrap if
+ alignment != Left
+ * TextBoxBase.cs (CalculateDocument): Made protected so RichTextBox can
+ call it as well
+
+2005-06-27 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Move to the left and right with the arrow
+ keys. These keys don't cycle beyond first and last like
+ tab. Refresh all the tabs when scrolling them to the left or
+ right.
+
+2005-06-27 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs:
+ - ToString: Added method
+ - CreateParams: Remove TODO and comment
+ - OnKeyDown: Cycle through bounds properly.
+ - SelectedIndex: Scroll to the right or left if we need to
+ display the newly selected tab.
+
+2005-06-23 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Stay in bounds when cycling. Make sure Handled is
+ set.
+
+2005-06-23 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Keyboard handling. We now support CTRL-TAB,
+ CTRL-SHIFT-TAB, and HOME, END are there any others?
+
+2005-06-23 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: Get the modifier keys from the keyboard driver.
+
+2005-06-22 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumn.cs: fixes and enhancements
+ * ThemeWin32Classic.cs: fixes and enhancements
+ * DataGridBoolColumn.cs: fixes and enhancements
+ * DataGridDrawingLogic.cs: fixes and enhancements
+ * CurrencyManager.cs: fixes and enhancements
+ * DataGrid.cs: fixes and enhancements
+ * DataGridColumnStyle.cs: fixes and enhancements
+
+2005-06-22 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Add some missing methods that just call into the
+ base. Make the TabPageCollection's IList interface behave in the
+ same manner as the MS implementation.
+
+2005-06-22 Peter Bartok <pbartok@novell.com>
+
+ * TextControl.cs: Added sanity check
+ * TextBoxBase.cs:
+ - Fixed wrapping behaviour, don't set wrap on single line controls
+ (this fixes the breakage of colordialog introduced in an earlier
+ checkin)
+ - Added rudimentary support for autoscrolling right-aligned controls
+ (still needs fixing, also, center alignment scroll is missing)
+
+2005-06-22 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ScrollBar.cs: Fixes thumbpos on Maximum values
+
+2005-06-21 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * PropertyGridView.cs: Pass context information to UITypeEditors
+
+2005-06-21 Peter Bartok <pbartok@novell.com>
+
+ * TextBoxBase.cs:
+ - Now calling PositionCaret with absolute space coordinates
+ - Enabled vertical scrolling
+ - Better tracking of scrollbar changes, tied into WidthChange
+ event
+ - Improved cursor tracking
+ - Removed debug output
+ * TextControl.cs:
+ - PositionCaret coordinates are now works in absolute space, not
+ the canvas
+ - Improved tracking of document size
+ - Added events for width and height changes
+
+2005-06-21 Peter Bartok <pbartok@novell.com>
+
+ * Form.cs: Set focus to active control when form is activated
+ * TextControl.cs:
+ - Added word-wrap functionality to RecalculateLine()
+ - Added some short function descriptions for VS.Net to aid in
+ writing dependent controls
+ - Added Caret property, returning the current coords of the caret
+ - Added ViewPortWidth and ViewPortHeight properties
+ - Added Wrap property
+ - Added CaretMoved event
+ - Removed some old debug code
+ - Split() can now create soft splits
+ - Added PreviousTag()/NextTag() to allow walking "tag-lists"
+ - Added method to format existing text
+ - Fixed size/alignment calculations to use viewport
+ - RecalculateDocument now can handle changing line-numbers while
+ calculating lines
+
+ * TextBox.cs:
+ - Added some wrap logic, we don't wrap if alignment is not left
+ - Added casts for scrollbar var, base class switched types to
+ also support RichTextBoxA
+ - Implemented handling of scrollbar visibility flags
+
+ * TextBoxBase.cs:
+ - Switched scrollbars type to RichTextBoxScrollBars to support
+ RichTextBox
+ - Added tracking of canvas width/height
+ - Switched scrollbars to be not selectable (to keep focus on text)
+ - Added central CalculateDocument() method to handle all redraw
+ requirements
+ - Added ReadOnly support
+ - Added WordWrap support
+ - Fixed handling of Enter key (we now treat it as a DialogKey)
+ - Fixed caret positioning when h or v scroll is not zero
+ - Fixed placing/generation of vertical scrollbar
+ - Added CalculateScrollBars() method to allow updating scrollbar
+ limits and visibility
+ - Fixed handling of horizontal scroll
+ - Added handling of vertical scroll
+ - Implemented auto-'jump' when caret moves to close to a left or
+ right border and there is text to be scrolled into view (currently
+ there's the potential for a stack overflow, until a bug in
+ scrollbar is fixed)
+
+2005-06-21 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Initial implementation of WM_ERASEBKGND
+
+2005-06-19 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * Mime.cs:
+ - added inodes.
+ - return application/x-zerosize for files with size zero
+ (if no extension pattern matches).
+ - check matches collection for strings too.
+ - return only the first mime type if the name value
+ collection has more than one mime type.
+
+2005-06-18 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * PropertyGrid.cs: Cleaned up some TODOs
+ * PropertyGridView.cs: Added support for UITypeEditors
+
+2005-06-17 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGrid.cs: clears cached value
+
+2005-06-17 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumn.cs: new rows, speed improvements, fixes, readonly prop.
+ * DataGridDrawingLogic.cs: new rows, speed improvements, fixes, readonly prop.
+ * DataGrid.cs: new rows, speed improvements, fixes, readonly prop.
+ * DataGridColumnStyle.cs: new rows, speed improvements, fixes, readonly prop.
+
+2005-06-16 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ThemeWin32Classic.cs: fixes colour
+
+2005-06-15 Peter Bartok <pbartok@novell.com>
+
+ * MWFCategoryAttribute.cs: Added (Needed for PropertyGrid designer support)
+ * MWFDescriptionAttribute.cs: Added (Needed for PropertyGrid designer support)
+ * ButtonBase.cs: Added MWFCategory and MWFDescription attributes
+ * Control.cs: Added some MWFCategory and MWFDescription attributes
+ * ScrollBar.cs: Added some MWFCategory and MWFDescription attributes
+
+2005-06-15 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * Mime.cs, MimeGenerated.cs: First draft of MWF mime stuff, see Mime.cs for
+ usage
+
+2005-06-14 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumn.cs: default datagrid settings for Default Styles, fixes
+ * DataGridTableStyle.cs: default datagrid settings for Default Styles, fixes
+ * DataGridDrawingLogic.cs: default datagrid settings for Default Styles, fixes
+ * DataGridBoolColumn.cs: default datagrid settings for Default Styles, fixes
+ * DataGrid.cs: default datagrid settings for Default Styles, fixes
+ * DataGridColumnStyle.cs: default datagrid settings for Default Styles, fixes
+
+2005-06-13 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: Override SetAllowDrop on X11 so an error message
+ isn't printed when the user enables dropping. (X11 does accept
+ drops).
+
+2005-06-13 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Remove some TODOS.
+
+2005-06-13 Jackson Harper <jackson@ximian.com>
+
+ * Form.cs: Hook into the mdi framework.
+ * MdiClient.cs: Use the base control collections add method so
+ parents get setup correctly. Set the default back colour and dock
+ style.
+ * MdiChildContext.cs: New class, this bad actor handles an
+ instance of an MDI window. Right now there is only basic
+ support. You can drag, close, and resize windows. Minimize and
+ Maximize are partially implemented.
+
+2005-06-13 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: Mash numbers together properly, otherwise we get
+ freaky when both vals are negative. NOTE: There are probably other
+ places in XplatUIX11 that this needs to be done.
+
+2005-06-13 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGrid.cs: implement missing methods, move KeyboardNavigation
+ * DataGridColumnStyle.cs: fixes signature
+
+2005-06-12 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: Use sizing cursors similar to the ones on
+ windows.
+
+2005-06-11 Jackson Harper <jackson@ximian.com>
+
+ * StatusBarPanel.cs: Signature cleanups. Implement
+ BeginInit/EndInit.
+
+2005-06-10 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumn.cs: Honors aligment
+ * GridColumnStylesCollection.cs: Contains is case unsensitive
+ * GridTableStylesCollection.cs: several fixes
+ * DataGridTableStyle.cs: default column creation
+ * DataGridDrawingLogic.cs: fixes
+ * CurrencyManager.cs: ListName property
+ * DataGrid.cs: multiple styles support
+ * DataGridColumnStyle.cs: fixes
+
+
+2005-06-10 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs(Select): Moved SetFocus call to avoid potential
+ loops if controls change the active control when getting focus
+ * UpDownBase.cs: Fixes to allow proper keyboard focus after clicking
+ the up/down buttons
+
+2005-06-10 Matthias Felgner <matthiasf@voelcker.ocm>
+
+ * ImageListConverter.cs: Implemented
+
+2005-06-10 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * MonthCalendar.cs: Wired in NumericUpDown control for year
+
+2005-06-10 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * MonthCalendar.cs: Removed MonoTodo attributes on Click and
+ DoubleClick events, since they are not meant to be fired.
+
+2005-06-09 Peter Bartok <pbartok@novell.com>
+
+ * UpDownBase.cs, NumericUpDown.cs, DomainUpDown.cs: Integrated
+ Jonathan's standalone controls into MWF, implemented missing
+ events, attributes and methods; added xxxAccessible classes
+ * AccessibleObject.cs: Made fields internal so other classes
+ can change them if needed
+
+2005-06-09 Jonathan Gilbert <2a5gjx302@sneakemail.com>
+
+ * UpDownBase.cs: Complete implementation
+ * NumericUpDown.cs: Complete implementation
+ * DomainUpDown.cs: Complete implementation
+
+2005-06-09 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumn.cs: drawing fixes
+ * DataGridCell.cs: fixes ToString method to match MSNet
+ * DataGridTableStyle.cs: fixes
+ * DataGridBoolColumn.cs: fixes, drawing
+ * DataGridDrawingLogic.cs: fixes, new methods
+ * DataGridTextBox.cs: Keyboard and fixes
+ * DataGrid.cs:
+ - Keyboard navigation
+ - Scrolling fixes
+ - Row selection (single, multiple, deletion, etc)
+ - Lots of fixes
+
+2005-06-07 Jackson Harper <jackson@ximian.com>
+
+ * ThemeWin32Classic.cs: Clear the background area when drawing
+ buttons.
+
+2005-06-06 Peter Bartok <pbartok@novell.com>
+
+ * ImageListStreamer.cs: Fixed signature for GetData
+ * CheckBox.cs: Fixed base class for CheckBoxAccessibleObject
+ * ComboBox.cs:
+ - Added missing ChildAccessibleObject class
+ - Added missing OnXXXFocus overrides, switched to using those
+ instead of the event handler
+ * Control.cs:
+ - Added Parent property for ControlAccessibleObject
+ - Fixed signatures
+ - Fixed attributes
+ - Added ResetBindings()
+ * ListBindingConverter.cs: Implemented some methods
+ * ButtonBase.cs: Added missing ButtonBaseAccessibleObject class
+ * ImageList.cs: Implemented basic handle scheme, removed TODOs
+ * ContainerControl.cs: Fixed signature, now subscribing to the
+ ControlRemoved event instead of overriding the handler, LAMESPEC
+ * CurrencyManager.cs: Added missing attribute
+ * MonthCalendar.cs: Added missing properties
+
+2005-06-06 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridColumnStyle.cs: fixes for DataGridColumnStyle
+
+2005-06-06 Gaurav Vaish and Ankit Jain
+
+ * DataSourceHelper.cs: Gaurav Vaish and Ankit Jain patch for databinding
+ * DataGrid.cs: Gaurav Vaish and Ankit Jain patch for databinding
+
+2005-06-06 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Control.cs: fixes CreateParams Width / Height.
+
+2005-06-05 Peter Bartok <pbartok@novell.com>
+
+ * Win32DnD.cs: Removed compilation warnings
+
+2005-06-05 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs (CreateParams): Since we don't know if one of the
+ properties we use is overridden, lets make sure if we fail accessing
+ we continue with a backup plan
+
+2005-06-05 Peter Bartok <pbartok@novell.com>
+
+ * Win32DnD.cs:
+ - Removed debug output
+ - Added MarshalAs attribute to ensure proper marshalling of FORMATETC
+ struct
+ - Plugged resource leak
+ * XplatUIStructs.cs: Changed ClipboardFormats size to ushort, to match
+ MS size
+
+2005-06-05 Peter Bartok <pbartok@novell.com>
+
+ * XplatUIWin32.cs: Removed DnD code
+ * Win32DnD.cs: Implemented drop source and drop target functionality
+
+2005-06-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * UpDownBase.cs: remove duplicate addition of event, enable some code
+ that was commented out.
+ * NumericUpDown.cs: added missing attributes and Hexadecimal property.
+ Validate input when a key is pressed. It works fine now for every
+ combination of Hexadecimal. Only missing some drawing love when sharing
+ space with other controls.
+
+2005-06-04 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - We need to pass a window for DragDrop, so enable callback events
+ - Added DnD callback events when being a DragSource
+ * XplatUI.cs (StartDrag): Added window handle argument
+ * XplatUIDriver.cs (StartDrag): Added window handle argument
+ * QueryContinueDragEventArgs: Made fields internally accessible so
+ drivers can set them
+ * GiveFeedbackEventArgs: Made fields internally accessible so drivers
+ can set them
+
+2005-06-03 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumn.cs: column text editing
+ * DataGridTableStyle.cs: Respect columns styles created by the user
+ * DataGridDrawingLogic.cs: lots of drawing fixes and enhanments
+ * DataGridBoolColumn.cs: bool column editing
+ * DataGrid.cs: fixes to scrolling, properties, etc
+ * DataGridTextBox.cs: handle keyboard
+ * DataGridColumnStyle.cs: fixes
+
+2005-06-02 Jackson Harper <jackson@ximian.com>
+
+ * ImageListStreamer.cs: Somewhat broken implementation of
+ GetObjectData. The RLE needs some work to match MS properly.
+
+2005-06-02 Jackson Harper <jackson@ximian.com>
+
+ * X11Dnd.cs: Attempting to keep at least one file in MWF
+ monostyled.
+
+2005-06-02 Peter Bartok <pbartok@novell.com>
+
+ * X11DnD.cs: Use Marshal.SizeOf instead of sizeof, no /unsafe required
+ that way
+
+2005-06-02 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs: Removed MonoTODO from DoDragDrop and added call to Xplat
+ * XplatUI.cs: Added DoDragDrop() method
+ * XplatUIDriver.cs: Added DoDragDrop() method
+
+2005-06-02 Jackson Harper <jackson@ximian.com>
+
+ * Splitter.cs: Implement BorderStyle.
+
+2005-06-02 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: Tie into the X11Dnd subsystem.
+ * X11Dnd.cs: New file. A subsystem that handles drag and drop on
+ X11 using XDND.
+
+2005-06-02 Peter Bartok <pbartok@novell.com>
+
+ * DataObject.cs:
+ - Added Data setter
+ - Fixed broken insertion code for SetData, now also
+ overwrites any existing entry of the same format name
+ * Hwnd.cs: Added list of pointers that automatically gets
+ freed when the window is disposed
+ * XplatUI.cs: Call driver initialization method when loading
+ a driver
+ * Control.cs:
+ - OnDragLeave takes EventArgs, not DragEventArgs
+ - Added setting of WS_EX_ACCEPTFILES style when dropping is
+ supported
+ - Forces style update when drop state changes
+ * XplatUIWin32.cs: Implemented Drag'n'Drop (as good as possible,
+ not perfect since we cannot (yet) call the IDataObject.GetData()
+ method, we keep getting 0x80004005 error, dunno why)
+
+2005-06-02 Peter Bartok <pbartok@novell.com>
+
+ * DragEventArgs.cs: Make fields internal so we can cache the
+ object and re-set the fields from XplatUI
+
+2005-06-02 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Add some internal methods so the DnD subsystem can
+ raise DnD events. Also call into the driver when AllowDrop is set.
+ * XplatUI.cs:
+ * XplatUIDriver.cs: New method for setting whether or not a window
+ is allowed to accept drag and drop messages.
+
+2005-06-01 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ScrollBar.cs: Make sure that values sent in Scroll events
+ are always between Maximum and Minimum.
+
+2005-06-01 Marek Safar <marek.safar@seznam.cz>
+
+ * Menu.cs: Call MenuChanged when menuitem visibility has been
+ changed.
+ * MenuItem.cs: Rebuild menu when item is (not) visible.
+ * MainMenu.cs: MainMenu has special MenuChanged.
+ * Theme.cs: Caption and FrameBorderSize are not fixed.
+ * XplatUI.cs: Added CaptionHeight,FrameBorderSize.
+ * XplatUIDriver.cs: Introduced Caption and FrameBorderSize.
+ * XplatUIX11.cs,
+ * XplatUIOSX: Caption and FrameBorderSize not implemented yet.
+ * XplatUIWin32.cs: Get Caption and FrameBorderSize from system.
+
+2005-05-30 Jackson Harper <jackson@ximian.com>
+
+ * DataFormat.cs: We can't statically initialize this stuff because
+ it calls into the xplatui and could create a loop. So we lazy init
+ it.
+
+2005-05-28 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Proper implementation of Product(Name/Version).
+
+2005-05-27 Jackson Harper <jackson@ximian.com>
+
+ * DataObject.cs: Dont crash if no data is found.
+
+2005-05-26 Rafael Teixeira <rafaelteixeirabr@hotmail.com>
+ * MdiClient.cs: Add missing Localizable attribute to BackgroundImage property
+ as per status page, guessing it should be set to true
+
+2005-05-26 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumn.cs: Draws text and basic text formatting
+ * DataGridTableStyle.cs: set proper formatting text, def header text
+ * ThemeWin32Classic.cs: new themable paramaters
+ * DataGridBoolColumn.cs: paint check box, get data, fixes
+ * DataGridDrawingLogic.cs: huge improvements in painting, fixes, new methods
+ * DataGrid.cs: fixes properties, implements vertical and horizontal scrolling
+ * DataGridColumnStyle.cs: fixes
+ * Theme.cs: new themable paramaters
+
+2005-05-26 Peter Bartok <pbartok@novell.com>
+
+ * ContainerControl.cs: Pass AdjustFormScrollbars() call on to base
+
+2005-05-24 Jonathan S. Chambers <jonathan.chambers@ansys.com>
+ * Control.cs: Fixed LowOrder and HighOrder to preserve sign.
+
+2005-05-24 Peter Bartok <pbartok@novell.com>
+
+ * OpenFileDialog.cs, Form.cs, Menu.cs, GroupBox.cs, UserControl.cs,
+ Label.cs, DataGridTextBoxColumn.cs, PropertyGrid.cs, ErrorProvider.cs
+ Splitter.cs, Control.cs, FontDialog.cs, TabPage.cs,
+ FolderBrowserDialog.cs, HelpProvider.cs, DataGridTableStyle.cs,
+ NotifyIcon.cs, FileDialog.cs, ListView.cs, SaveFileDialog.cs,
+ ToolBarButton.cs, ImageList.cs, DataGridBoolColumn.cs, Panel.cs,
+ DataGrid.cs, DataGridTextBox.cs, ListBox.cs, TrackBar.cs,
+ AxHost.cs, TabControl.cs, ScrollableControl.cs, ToolBar.cs,
+ DataGridColumnStyle.cs, PictureBox.cs, DateTimePicker.cs,
+ StatusBar.cs, MonthCalendar.cs, TreeView.cs: Added
+ missing attributes, etc
+ * DataGridPreferredColumnWidthTypeConverter.cs: Added
+
+2005-05-24 Peter Bartok <pbartok@novell.com>
+
+ * Help.cs: Added, implemented trivial functions, throws up MessageBox
+ when user tries to get help
+ * DataObject.cs, DataFormats.cs, LinkArea.cs,
+ SelectionRangeConverter.cs, Clipboard.cs : Removed unused variables
+ to suppress warnings
+ * XplatUIWin32.cs, XplatUIOSX.cs, XplatUIX11.cs: Removed unused code to
+ avoid unreachable code warning
+
+2005-05-20 Peter Bartok <pbartok@novell.com>
+
+ * CursorConverter.cs (ConvertTo): Switched to use Cursor.GetObjectData
+
+2005-05-20 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumn.cs: Basic painting methods
+ * DataGridTableStyle.cs: Set table style in the column
+ * ThemeWin32Classic.cs: Use Theme for colors
+ * DataGridDrawingLogic.cs: Implement more drawing
+ * DataGrid.cs: drawing, theming, enhacements, fixes
+ * DataGridColumnStyle.cs: fixes, drawing
+ * Theme.cs: theming for Datagrid
+
+2005-05-20 Peter Bartok <pbartok@novell.com>
+
+ * Cursor.cs: Implemented GetObjectData() method
+
+2005-05-20 Peter Bartok <pbartok@novell.com>
+
+ * Cursors.cs: Added setting of cursor name
+ * Cursor.cs:
+ - Implemented constructors
+ - Implemented Draw and DrawStretched
+ - Implemented Current property
+ - Implemented == and != operators
+ - Implemented Dispose()
+ - Implemented ToString
+ - Added missing attributes
+ * XplatUIX11.cs:
+ - Added missing reset for OverrideCursor when DoEvents is called
+ - Fixed creation of cursor, logic was wrong
+ * XplatUIWin32.cs:
+ - Added missing reset for OverrideCursor when DoEvents is called
+ - Fixed creation of cursor, bit arrays were swapped
+ * Clipboard.cs: Removed obsolete MonoTODO attribute
+
+2005-05-20 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs: fixes OnSelectedItemChanged
+ * ControlBindingsCollection.cs: fixes item range check
+
+2005-05-20 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * UpDownBase.cs:
+ - Calc preferred height properly
+ - Implement missing properties
+
+ * NumericUpDown.cs: Implement missing events
+
+2005-05-19 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: New method that resizes the tab pages before
+ redrawing them. This as needed as the control is double buffered
+ and sizing will not be recalculated unless ResizeTabPages is
+ called.
+ * TabPage.cs: Set base.Text instead of Text in the constructor so
+ that UpdateOwner does not get called. Use the new Redraw method of
+ TabControl instead of Refresh so the sizing is recalculated.
+ * ThemeWin32Classic.cs: Draw the text for button tabs.
+
+2005-05-19 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Paint control background images. Fix typo where
+ PaintControlBackground was not getting called correctly.
+
+2005-05-19 Peter Bartok <pbartok@novell.com>
+
+ * ScrollableControl.cs (DisplayRectangle): Undid my last change until
+ I can investigate, apparently I broke FileDialog
+
+2005-05-19 Marek Safar <marek.safar@seznam.cz>
+
+ * AxHost.cs: Some simple properties.
+ * Control.cs: window must be accessible after ctor.
+ * Form.cs: Added TransparencyKey property.
+ * TextBoxBase.cs: Implemented Clear. Text property can be null.
+ * XplatUIWin32.cs: SetBorderStyle implemented.
+
+2005-05-18 Peter Bartok <pbartok@novell.com>
+
+ * DataObject.cs: Entries are not global but particular to the
+ DataObject, now it behaves that way
+ * XplatUIWin32.cs: Implemented Clipboard methods
+ * Clipboard.cs: Implemented
+ * ScrollableControl.cs (DisplayRectangle): Fixed calculation
+ * XplatUIOSX.cs: Updated to final clipboard prototypes
+ * XplatUIX11.cs: Implemented Clipboard methods
+ * XplatUIDriver.cs: Updated to final clipboard prototypes
+ * XplatUIStructs.cs:
+ - Added BITMAPINFOHEADER struct
+ - Added ClipboardFormats enum
+ * X11Structs.cs:
+ - Added ClipboardStruct
+ - Added Atom enum items for clipboard types
+ - Fixed atom types for Selection event structures
+ * DataFormats.cs:
+ - Added internal properties and methods for drivers to enumerate
+ all known formats
+ - Switched initialization method to allow drivers to assign their
+ own IDs even for the MS predefined clipboard IDs
+ * XplatUI.cs: Updated to final clipboard interface
+
+2005-05-18 Jonathan S. Chambers <jonathan.chambers@ansys.com>
+ * PropertyGridView.cs: Fixed compiler warnings.
+
+2005-05-18 Jonathan S. Chambers <jonathan.chambers@ansys.com>
+ * PropertyGrid.cs: Added some event calls
+ * PropertyGridView.cs: Change drawing code to use double buffering
+ * PropertyGridTextBox.cs: Changed Text property name
+ * GridItem.cs: Added Bounds property.
+ * GridEntry.cs: Added Bounds property.
+
+2005-05-17 Lluis Sanchez Gual <lluis@novell.com>
+
+ * Binding.cs: Use IsInstanceOfType instead of IsAssignableFrom
+ since GetType() may not return the correct type if the object is
+ a remoting proxy.
+
+2005-05-17 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * TreeNodeCollection.cs: fixes get/set item ranges
+
+2005-05-15 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListBox.cs: Kazuki Oikawa's PreferredHeight and ItemHeight fixes
+
+2005-05-15 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs: Fix item range comparation
+ * ListView.cs: Fix item range comparation
+
+2005-05-03 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * FontDialog.cs:
+ - Clear example panel when OnPaint is called
+ - Better solution for displaying the example panel text
+ - Select default indexes in the ListBoxes
+
+2005-05-11 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Avoid painting into invisible views. Fixes #74926
+
+2005-05-11 Peter Bartok <pbartok@novell.com>
+
+ * LinkArea.cs: Added and implemented LinkAreaTypeConverter class
+ * SelectionRangeConverter.cs: Implemented
+ * PropertyGrid.cs: Fixed attribute value
+ * Control.cs:
+ - Invoke(): Don't call Begin/EndInvoke if it is not neccessary
+ - Added Sebastien Pouliot's CAS Stack Propagation fixes
+ * XplatUIDriver.cs: Added new XplatUIDriverSupport class, for code
+ that's common to all drivers. First methods to go there are
+ Sebastien Pouliot's CAS Stack Propagation helper methods
+ * XplatUIWin32.cs, XplatUIX11.cs, AsyncMethodData.cs: Fixes by
+ Sebastien Pouliot for CAS Stack Propagation
+
+2005-05-11 Geoff Norton <gnorton@customerdna.com>
+
+ * OSXStructs.cs:
+ XplatUIOSX.cs: More cosmetic cleanup courtesy of Artyom Tyazhelov (Artyom.Tyazhelov@helmes.ee)
+
+2005-05-12 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumn.cs: fixed some members
+ * GridColumnStylesCollection.cs: indexed column is case insensitive
+ * DataGridTableStyle.cs: fixes
+ * ThemeWin32Classic.cs: add new theme parameter
+ * Theme.cs: add new theme parameter
+ * DataGridDrawingLogic.cs: Datagrid's drawing logic
+ * DataGrid.cs: fixes, new internal properties, etc.
+ * DataGridColumnStyle.cs: allows to set grid value
+ *
+
+2005-05-10 Peter Bartok <pbartok@novell.com>
+
+ * AccessibleObject.cs:
+ - Removed MonoTODO attribute on help, method is correct
+ - Fixed Bounds property
+ * AxHost.cs: Moved MonoTODO
+ * ButtonBase.cs: Now setting AccessibleObject properties
+ * RadioButton.cs: Setting proper AccessibleObject role
+ * CheckBox.cs: Setting proper AccessibleObject role
+ * ControlBindingsCollection.cs: Added properties, methods and attributes
+ * DataFormats.cs: Fixed awkward internal API, and changed to enable
+ userdefined DataFormats.Format items as well
+ * ListControl.cs: Removed data_member from the public eye
+ * OpenFileDialog.cs:
+ - Made class sealed
+ - Added missing attributes
+ * SaveFileDialog.cs: Added missing attributes
+ * ImageListStreamer.cs: Fixed code that caused warnings
+ * LinkLabel.cs: Removed unreachable code
+ * TreeView.cs: Fixed code that caused warnings
+ * PropertyGridView.cs: Fixed code that caused warnings
+ * GridColumnStylesCollection.cs: Added missing attributes
+ * GridTableStylesCollection: Added missing attribute
+ * PropertyManager: Added .ctor
+ * SecurityIDType: Added
+ * DataObject.cs: Implemented class
+ * LinkArea.cs: Added missing attribute
+
+2005-05-11 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * RadioButton.cs: call base method to allow to fire OnClick event
+ * UpDownBase.cs: OnMouseUp call base method
+ * CheckedListBox.cs: call base method before returning
+ * TrackBar.cs: call base method before returning
+
+
+2005-05-10 Peter Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs: Fix for #74902, check pending timers when peeking
+ for messages
+
+2005-05-10 Peter Bartok <pbartok@novell.com>
+
+ * DataFormats.cs: Implemented
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIOSX.cs,
+ XplatUIX11.cs: Added Clipboard APIs
+ * XplatUIWin32.cs: Implemented Clipboard APIs
+ * FolderBrowserDialog.cs: Added missing event, attributes
+
+2005-05-10 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * CheckBox.cs: call base method to allow to fire OnClick event
+
+2005-05-09 Sebastien Pouliot <sebastien@ximian.com>
+
+ * XplatUI.cs: Use PlatformID.Unix under NET_2_0.
+
+2005-05-06 Peter Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs: Redid Jackson's fix, it was causing a busy loop
+ * Screen.cs: Implemented
+ * HelpNavigator.cs: Added
+ * XplatUIWin32.cs: Added SystemParametersInfo call, fixed WorkArea
+ property
+ * HelpProvider.cs: Implemented all we can do until we have a CHM
+ help library (which means that "What's This" does work now)
+
+2005-05-06 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: Fix waking up the main loop.
+
+2005-05-05 Peter Bartok <pbartok@novell.com>
+
+ * XplatUI.cs: Updated revision
+ * Form.cs: Removed enless loop
+ * GroupBox.cs (OnPaint): Added call to base.OnPaint()
+ * Label.cs (OnPaint): Added call to base.OnPaint()
+ * ToolTip.cs: Made ToolTipWindow reusable for other controls
+ * LinkLabel.cs (OnPaint): Added call to base.OnPaint()
+ * UpDownBase.cs (OnPaint): Moved base.OnPaint() call to end of method
+ * AxHost.cs: Added
+ * ButtonBase.cs: Moved base.OnPaint() call to end of method
+ * ThemeWin32Classic.cs: Replaced references to ToolTip with references
+ to ToolTip.ToolTipWindow for drawing and size methods; this allows
+ reuse of ToolTipWindow by other controls
+ * SizeGrip.cs: Moved base.OnPaint() call to end of method
+ * XplatUIX11.cs: Now clipping drawing area (experimental)
+ * PictureBox.cs: Moved base.OnPaint() call to end of method
+ * Theme.cs: Fixed ToolTip abstracts to match new format
+ * ErrorProvider.cs: Implemented
+
+2005-05-05 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Label.cs: fire events using OnAutoSizeChanged and OnTextAlignChanged
+ * LinkLabel.cs:
+ - Adds cursors
+ - Handles focus
+ - Implements LinkBehavior
+ - Fixes many issues
+
+2005-05-03 Jackson Harper <jackson@ximian.com>
+
+ * ListView.cs: Calculate the scrollbar positioning on resize and
+ paint, so they get put in the correct place.
+
+2005-05-03 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * ColorDialogs.cs: The small color panels are now handled by
+ SmallColorControl. This fixes drawing of the focus rectangle
+ and adds a 3D border.
+
+2005-05-03 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs: Modified version of Jonathan Chamber's fix for
+ double-buffering
+
+2005-05-03 Jackson Harper <jackson@ximian.com>
+
+ * ListView.cs: Remove redraw variable. Control now handles whether
+ or not a redraw needs to be done, and will only raise the paint
+ event if redrawing is needed.
+
+2005-05-03 Jackson Harper <jackson@ximian.com>
+
+ * Splitter.cs: No decorations for the splitter form. Cache the
+ hatch brush.
+
+2005-05-03 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Use dashed lines to connect nodes. Use the
+ ControlPaint method for drawing the focus rect instead of doing
+ that in treeview.
+
+2005-05-02 Peter Bartok <pbartok@novell.com>
+
+ * LinkLabel.cs: Fixed the fixes from r43566 and 43521
+
+2005-04-29 Jackson Harper <jackson@ximian.com>
+
+ * ThemeWin32Classic.cs: Don't clear the GC that will clear the
+ entire image buffer. Just clear the clipping rectangle.
+
+2005-04-29 Jackson Harper <jackson@ximian.com>
+
+ * ThemeWin32Classic.cs: Don't draw list view items that are
+ outside the clipping rectangle.
+
+2005-04-29 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListBox.cs: added horizontal item scroll
+
+2005-04-29 Jackson Harper <jackson@ximian.com>
+
+ * ThemeWin32Classic.cs: Remove some old debug code that was
+ causing flicker with the new double buffering code.
+
+2005-04-29 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * MonthCalendar.cs, DateTimePicker.cs: Made monthcalendar dropdwon
+ behave like combobox and comboboxlist (still not sure if this is
+ correct though).
+
+2005-04-28 Jackson Harper <jackson@ximian.com>
+
+ * ThemeWin32Classic.cs: Don't fill the middle of progress
+ bars. This fills areas outside of the clip bounds that don't need
+ to be filled.
+
+2005-04-28 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Don't expose functionality to touch the image buffers.
+ * ProgressBar.cs:
+ * ListView.cs: We do not need to (and no longer can) manipulate
+ the image buffers directly. All of this is handled by Control.
+
+2005-04-28 Peter Bartok <pbartok@novell.com>
+
+ * RichTextBoxSelectionAttribute.cs, RichTextBoxSelectionTypes.cs,
+ RichTextBoxScrollBars.cs, RichTextBoxStreamType.cs,
+ RichTextBoxFinds.cs, RichTextBoxWordPunctuations.cs: Added
+
+2005-04-28 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Combobox:
+ - Adjust control's height for non-simple comboboxes (bug fix)
+ - Remove dead code
+ * MenuAPI.cs: remove unused var
+ * ScrollBar.cs: remove unsed var
+
+ * ListBox.cs: unselect items when clearing
+
+2005-04-28 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListControl.cs: honors OnPositionChanged and default Selected Item
+ * ListBox.cs: unselect items when clearing
+
+2005-04-27 Jackson Harper <jackson@ximian.com>
+
+ * X11Keyboard.cs: Initialize a default keyboard and give a warning
+ if a "correct" keyboard is not found. This will make us not crash,
+ but might give some users bad keyboard layouts...seems to be the
+ same thing rewind does.
+
+2005-04-27 Jackson Harper <jackson@ximian.com>
+
+ * BindingManagerBase.cs: Attach the current/position changed
+ handlers to their respective events.
+
+2005-04-27 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Make sure that the first WM_PAINT does a full draw,
+ not just a blit.
+ * ThemeWin32Classic.cs: Don't fill the background for picture
+ boxes. This could overright user drawing.
+ * ComboBox.cs: Just fill the clipping rect not the entire client
+ rect when drawing the background. This prevents pieces of the
+ image buffer from getting overwritten and is theoretically faster.
+
+2005-04-26 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs: Databinding support fixes, fire missing events
+ * ListControl.cs: implement missing methods and properties, fixes
+ * ThemeWin32Classic.cs: Databiding support on Drawing
+ * CheckedListBox.cs: Databinding support fixes, fire missing events
+ * ListBox.cs: Databinding support fixes, fire missing events
+
+2005-04-25 Peter Bartok <pbartok@novell.com>
+
+ * LinkLabel.cs: Length of LinkArea is not allowed to be negative
+
+2005-04-25 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Use the horizontal scrollbars height not width when
+ determining how much of the client area is available.
+
+2005-04-25 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Double buffering is handled differently now. As per
+ the spec, the extra buffer is created in the WM_PAINT message and
+ passed down to the control's drawing code.
+ * GroupBox.cs:
+ * Label.cs:
+ * CheckBox.cs:
+ * ProgressBar.cs:
+ * RadioButton.cs:
+ * ColorDialog.cs:
+ * ComboBox.cs:
+ * PropertyGridView.cs:
+ * UpDownBase.cs:
+ * MessageBox.cs:
+ * MenuAPI.cs:
+ * ListView.cs:
+ * ButtonBase.cs:
+ * SizeGrip.cs:
+ * ScrollBar.cs:
+ * ListBox.cs:
+ * TrackBar.cs:
+ * ToolBar.cs:
+ * PictureBox.cs:
+ * DateTimePicker.cs:
+ * StatusBar.cs:
+ * TreeView.cs: Update to new double buffering system.
+ * MonthCalendar.cs: Uncomment block, as Capture is now
+ working. Update to new double buffering
+ * LinkLabel.cs: Lazy init the link collection. Update to new double buffering
+ * PaintEventArgs.cs: New internal method allows us to set the
+ graphics object. This is used for double buffering.
+ * ThemeWin32Classic.cs: Give the picture box drawing code a clip
+ rectangle. The internal paint_area var has been removed from
+ StatusBar. The clipping rect should be used instead.
+ * Theme.cs: Give the PictureBox drawing method a clipping rect.
+ * TabPage.cs: The RefreshTabs method was removed, so just call the
+ tab controls Refresh method now.
+ * TabControl.cs: Update to new double buffering. Make sure the
+ handle is created before sizing the tab pages, otherwise we will
+ get stuck in a loop.
+
+2005-04-24 Borja Sanchez Zamorano <borsanza@gmail.com>
+
+ * LinkLabel.cs: Fix typo, bug #74719; patch
+ from Borja Sanchez Zamorano
+
+2005-04-22 Jackson Harper <jackson@ximian.com>
+
+ * TreeNode.cs: Implement Handle stuff.
+ * TreeView.cs: Utility methods so nodes can get/lookup by handle.
+
+2005-04-22 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumn.cs: call base constructors, fixes
+ * GridColumnStylesCollection.cs: missing events, methods, and functionality
+ * GridTableStylesCollection.cs: fixes, check duplicate mapping names
+ * DataGridTableStyle.cs: implements create default column styles
+ * DataGridBoolColumn.cs: which types can handle
+ * DataGrid.cs: missing methods, fixes, new functionality
+ * DataGridColumnStyle.cs: fixes
+
+2005-04-20 Alexander Olk <xenomorph2@onlinehome.de>
+ * FolderBrowserDialog.cs:
+ - Use a thread to fill the TreeView
+ - Adjusted some sizes
+
+2005-04-19 Peter Bartok <pbartok@novell.com>
+
+ * LinkLabel.cs: (Re-)create the pieces when setting the Text
+ property. Fixes #74360.
+
+2005-04-19 Jackson Harper <jackson@ximian.com>
+
+ * XEventQueue.cs: Lock when getting the lockqueue size.
+ * PictureBox.cs: Call base OnPaint
+
+2005-04-19 Peter Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs: Fixed bug introduced with the HWND rewrite, Async
+ messages were no longer being processed (this broke BeginInvoke)
+
+
+2005-04-18 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: buglet that caused node images to get drawn
+ regardless of whether or not they were in the clipping rectangle.
+
+2005-04-18 Jackson Harper <jackson@ximian.com>
+
+ * CurrencyManager.cs: There are four rules for GetItemProperties:
+ - If the type is an array use the element type of the array
+ - If the type is a typed list, use the type
+ - If the list contains an Item property that is not an object, use
+ that property
+ - use the first element of the list if there are any elements in
+ the list.
+
+2005-04-17 Jackson Harper <jackson@ximian.oom>
+
+ * TreeView.cs: Calculate plus minus and checkbox bounds when there is a
+ click. This handles offsets for scrolling properly and reduces
+ memory. Also fixed GetNode to not offset now that TopNode works
+ properly.
+ * TreeNode.cs: No longer need to track the plus minus or checkbox bounds.
+
+2005-04-17 Jackson Harper <jackson@ximian.com>
+
+ * CursorConverter.cs: Initial implementation.
+
+2005-04-15 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListControl.cs: work towards complex data binding support on ListControl
+ * CurrencyManager.cs: work towards complex data binding support on ListControl
+ * ListBox.cs: work towards complex data binding support on ListControl
+
+
+2005-04-15 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * GridTableStylesCollection.cs: fixes name and constructor
+ * DataGridTableStyle.cs: fixes
+ * DataGridBoolColumn.cs: fixes names and constructors
+ * DataGrid.cs: define methods and properties. Some init implementations
+ * DataGridCell.cs: define methods and properties. Some init implementations
+ * GridTablesFactory.cs: Define methods and properties
+
+2005-04-15 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Handle proper mouse tracking even if the current
+ graphics port changes. We still want the coordinates in global screen
+ coordinates.
+
+2005-04-14 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Handle clicks when plus minus is disabled. Don't
+ check plus minus or checkbox clicks unless those features are enabled.
+
+2005-04-14 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Add methods for setting the top and bottom visible
+ nodes. TreeNode::EnsureVisible uses these methods.
+ * TreeNode.cs: Implement EnsureVisible
+
+2005-04-13 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Form.cs: Pospone menu assignation if the window has not been created yet
+ * XplatUIWin32.cs: Fixes Win32SetWindowPos, then does not change window
+ size and position
+
+2005-04-12 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Set the TopNode properly when scrolling
+ occurs. This has the added benifit of reducing the amount of
+ walking that needs to be done when drawing. Also removed an old
+ misleading TODO.
+ * OpenTreeNodeEnumerator.cs: Fix moving backwards.
+
+2005-04-11 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Timer.cs: fixes interval setting when the timer is already enabled
+
+2005-04-10 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * FolderBrowserDialog.cs: First approach
+
+2005-04-09 Peter Bartok <pbartok@novell.com>
+
+ * FolderBrowserDialog: Added
+
+2005-04-07 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * LinkLabel.cs: move drawing code into the theme
+ * ThemeWin32Classic.cs: drawing code and painting background bugfix
+ * Theme.cs: define DrawLinkLabel method
+
+2005-04-05 Jackson Harper <jackson@ximian.com>
+
+ * BindingContext.cs: Use weak references so these bad actors don't
+ stay alive longer then they need to.
+
+2005-04-05 Jackson Harper <jackson@ximian.com>
+
+ * ListControl.cs: Basic implementation of complex databinding.
+ * ComboBox.cs:
+ * ListBox.cs: Add calls to ListControl databinding methods.
+
+2005-04-05 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * FileDialog.cs:
+ - Don't change PopupButtonState to Normal when the
+ PopupButton gets pressed several times.
+ - Renamed ButtonPanel to PopupButtonPanel
+
+2005-04-05 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ColorDialog.cs: Use cached objects instead of creating them
+ * LinkLabel.cs: Use cached objects instead of creating them
+ * Splitter.cs: Use cached objects instead of creating them
+ * FontDialog.cs: Use cached objects instead of creating them
+ * PropertyGridView.cs: Use cached objects instead of creating them
+ * MessageBox.cs: Use cached objects instead of creating them
+ * FileDialog.cs: Use cached objects instead of creating them
+ * ThemeWin32Classic.cs: Use cached objects instead of creating them
+ * TreeView.cs: Use cached objects instead of creating them
+
+2005-04-04 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Control.cs: use Equals to compare the font since no == op
+ * ScrollBar.cs: use Equals to compare the font since no == op
+
+2005-04-04 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * SaveFileDialog.cs: Open stream in OpenFile with FileMode Create
+
+2005-04-01 Jackson Harper <jackson@ximian.com>
+
+ * Binding.cs: Implement IsBinding.
+ * BindingManagerBase.cs:
+ * PropertyManager.cs:
+ * CurrencyManager.cs: Add IsSuspended property.
+
+2005-04-01 Jackson Harper <jackson@ximian.com>
+
+ * Binding.cs: Had some IsAssignableFrom calls backwards.
+
+2005-04-01 Jackson Harper <jackson@ximian.com>
+
+ * Binding.cs: Handle null data members when pulling data.
+ * PropertyManager.cs: Handle the data member being a property that
+ does not exist.
+
+2005-04-01 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumn.cs: fixes signature
+ * DataGrid.cs: calls right constructor
+
+2005-04-01 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumn.cs: implements DataGridTextBoxColumn class
+ * GridColumnStylesCollection.cs: implements GridColumnStylesCollection
+ * GridTableStylesCollection.cs: implements GridTableStylesCollection
+ * DataGridTableStyle.cs: implements DataGridTableStyle
+ * DataGridBoolColumn.cs: implements DataGridBoolColumn
+ * DataGridTextBox.cs: implements DataGridTextBox
+ * DataGridColumnStyle.cs: implements DataGridColumnStyle
+
+2005-03-31 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * FileDialog.cs: Added simple PopupButton class for ButtonPanel
+
+2005-03-29 Peter Bartok <pbartok@novell.com>
+
+ * Application.cs:
+ - Properly implemented CompanyName property
+ - Fixed LocalUserAppDataPath and UserAppDataPath, now properly
+ returns a path that includes CompanyName, ProductName and
+ Version (fixes bug #70330)
+
+2005-03-29 Stefan Buehler <sbuehler@gmx.ch>
+
+ * TabPage.cs: Don't use Owner.DisplayRectangle unless owner is valid,
+ fixes bug #72588.
+
+2005-03-28 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * FileDialog.cs, SaveFileDialog.cs OpenFileDialog.cs:
+
+ - Added ReadOnly CheckBox
+ - Further refactoring: moved some code from Open-/SaveFileDialog
+ to FileDialog
+
+2005-03-28 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * OpenFileDialog.cs: Fixed CheckFileExists
+ * FileDialog.cs:
+ Moved FileView and DirComboBox outside FileDialog class.
+ They can now be used outside FileDialog
+
+2005-03-27 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * FileDialog.cs: Added a contextmenu to change ShowHiddenFiles
+ * SaveDialog.cs, OpenFileDialog.cs: Fixes for Reset() method
+
+2005-03-27 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * FileDialog.cs, OpenFileDialog.cs, SaveFileDialog.cs:
+ - Added missing CreatePrompt property in SaveDialog
+ - Overall SaveDialog handling should be better now
+ - Added non standard ShowHiddenFiles property
+ - Added extension, CreatePrompt and OverwritePrompt support in SaveDialog
+ - Added InitialDirectory and RestoreDirectory support
+
+2005-03-26 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * FileDialog.cs: Made dirComboBox usable
+
+2005-03-24 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * FileDialog.cs: Added Filter support (case sensitiv)
+
+2005-03-24 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Need a couple more pixels for the lines.
+
+2005-03-23 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Give the tab page focus when it is selected.
+
+2005-03-23 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Account for the drawing of tabs borders when
+ invalidating. If the slider was clicked dont do click detection on
+ the tabs.
+
+2005-03-23 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Fix typo, emilinates an unneeded expose event.
+
+2005-03-22 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * CategoryGridEntry.cs: Added
+ * GridItem.cs: Added helper properties
+ * PropertyGridTextBox.cs: Custom textbox control for PropertyGrid.
+ * GridEntry.cs: Updated code for collection
+ * PropertyGrid.cs: Cleaned up some formatting
+ * PropertyGridView.cs: Added drop down functionality for enums.
+ * GridItemCollection.cs: Added enumerator logic
+ * PropertyGridEntry.cs: Added
+
+2005-03-19 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * FileDialog.cs:
+ - Removed unnecessary commented code
+ - Fixed handling for entering the filename manually in the combobox
+
+2005-03-19 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * FileDialog.cs, OpenFileDialog.cs: OpenFileDialog Multiselect now works
+
+2005-03-18 Peter Bartok <pbartok@novell.com>
+
+ * ThemeWin32Classic.cs: Moved listview column headers a bit, to avoid
+ them being touching the border
+
+2005-03-18 Peter Bartok <pbartok@novell.com>
+
+ * TextControl.cs: Quick hack to center text better
+
+2005-03-18 Peter Bartok <pbartok@novell.com>
+
+ * ControlPaint.cs:
+ - Don't throw NotImplemented exceptions, just print a notice once
+ instead (requested by Miguel). This makes running existing SWF
+ apps a bit easier
+ * Control.cs:
+ - Commented out Drag'N'Drop XplatUI call (no driver support yet)
+ - Added context menu trigger on right click
+ * Panel.cs: Trigger invalidate on resize
+ * StatusBar.cs:
+ - Removed old double-buffer drawing
+ - Added ResizeRedraw style to force proper update of statusbar
+ * ListView.cs:
+ - Removed debug output
+ * ThemeWin32Classic.cs:
+ - Fixed drawing of status bar, now draws Text property if there
+ are no defined panels
+
+2005-03-18 Jackson Harper <jackson@ximian.com>
+
+ * ImageList.cs: When the image stream is set pull all the images
+ from it.
+ * ImageListStreamer.cs: Implement reading image list streams.
+
+2005-03-18 Peter Bartok <pbartok@novell.com>
+
+ * ThemeWin32Classic.cs (DrawPictureBox):
+ - Fixed calculations for centered drawing
+ - Fixed drawing for normal mode, not scaling the image on normal
+
+2005-03-18 Peter Bartok <pbartok@novell.com>
+
+ * ComboBox.cs: Now also firing the OnKeyPress events for the embedded
+ textbox
+ * FileDialog.cs:
+ - Made Open/Save button the accept button for FileDialog
+ - Tied the cancel button to the IButtonControl cancel button
+ - Save/Open now properly builds the pathname
+ - Now handles user-entered text
+ - Preventing crash on right-click if no item is selected
+ - Fixed Text property, now uses contents of textbox
+ - Fixed SelectedText property, now just returns the text part that
+ is selected in the text box
+
+2005-03-18 Jackson Harper <jackson@ximian.com>
+
+ * ThemeWin32Classic.cs: Use the proper func for drawing the focus
+ rect, make sure to de-adjust the interior rect after drawing the
+ tab text.
+
+2005-03-18 Peter Bartok <pbartok@novell.com>
+
+ * MenuAPI.cs: Remove menu *before* executing selected action to
+ prevent the menu from 'hanging around'
+
+2005-03-17 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Implemented WorkingArea property
+
+2005-03-17 Peter Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs: Fixed menu coord calculations
+ * MenuAPI.cs: Now using new ScreenToMenu()/MenuToScreen() methods
+ for calculating offsets
+
+2005-03-17 Peter Bartok <pbartok@novell.com>
+
+ * Hwnd.cs: Do not consider menu presence for default client
+ rectangle location/size
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIX11.cs, XplatUIOSX.cs,
+ XplatUIWin32.cs: Added MenuToScreen() and ScreenToMenu() coord
+ translation functions
+ * FileDialog.cs: Fixed (what I presume is a) typo
+
+2005-03-17 Jonathan Gilbert <logic@deltaq.org>
+
+ * XplatUIX11.cs: Added call to XInitThreads() to allow multi-threaded
+ X access (avoids X-Async errors)
+
+2005-03-16 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Raise the SelectedIndexChanged event.
+
+2005-03-16 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * FileDialog.cs, OpenFileDialog.cs, SaveFileDialog.cs:
+ - Removed vertical ToolBar and replaced it with a custom panel
+ (desktop and home button already work)
+ - Added Help button (some controls get resized or relocated then)
+ - Draw correct text depending on Open or Save.
+ - Fixed some typos...
+
+2005-03-16 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ScrollBar.cs:
+ - Only change Maximum and Minimum when need it (bug fix)
+
+2005-03-15 Peter Bartok <pbartok@novell.com>
+
+ * Form.cs: Use Handle for icon, to trigger creation if
+ the window does not yet exist
+ * Control.cs:
+ - CanSelect: Slight performance improvement
+ - Focus(): Preventing possible recursion
+ - Invalidate(): Removed ControlStyle based clear flag setting
+ - WM_PAINT: fixed logic for calling OnPaintBackground
+ - WM_ERASEBKGND: Fixed logic, added call to new driver method
+ EraseWindowBackground if the control doesn't paint background
+ * XplatUIWin32.cs:
+ - Moved EraseWindowBackground() method to internal methods
+ - Removed unused WM_ERASEBKGND handling in GetMessage; msg never comes;
+ is sent via SendMessage on BeginPaint call on Win32
+ * XplatUIX11.cs:
+ - Added EraseWindowBackground() method
+ - No longer sends WM_ERASEBKGND on .Expose, but on call to
+ PaintEventStart, which more closely matches Win32 behaviour
+ - Fixed Invalidate() call, now updates new ErasePending Hwnd property
+ - Fixed SetFocus() to properly deal with client and whole windows
+ * Hwnd.cs: Added ErasePending property
+ * XplatUIOSX.cs: Stubbed EraseWindowBackground() method
+ * XplatUI.cs, XplatUIDriver.cs: Added EraseWindowBackground() method
+
+2005-03-12 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs:
+ - Fix hard loop when timers exist.
+ - Fix bugs with middle and right click for 3 button mice.
+
+2005-03-11 Peter Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs:
+ - get_WorkingArea: Need to call X directly, GetWindowPos only
+ returns cached data now
+ - Added sanity check to GetWindowPos hwnd usage
+
+2005-03-11 Jackson Harper <jackson@ximian.com>
+
+ * BindingManagerBase.cs: This method isn't used anymore as
+ PullData now updates the data in the control.
+
+2005-03-11 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Form.cs: fixes menu drawing on X11
+ * MenuAPI.cs: fixes menu drawing on X11
+
+2005-03-11 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs: Changed OnCreateControl behaviour based on a suggestion
+ from Jonathan Gilbert; should fix bug #73606
+ * XplatUIX11.cs: Fixed NC Mouse message coordinates, they need to be
+ in Screen coordinates. Thanks, Jordi.
+ * Form.cs: Added missing attribute
+
+2005-03-11 Peter Bartok <pbartok@novell.com>
+
+ * Form.cs:
+ - Rudimentary Mdi support
+ - Removed outdated FormParent code
+ - Implemented lots of missing properties and methods, still missing
+ transparency support
+ - Added missing attributes
+ - Implemented support for MaximumBounds
+ - Added firing of various events
+ * XplatUI.cs: Added SetIcon() method
+ * XplatUIDriver.cs: Added SetIcon() abstract
+ * XplatUIOSX.cs: Stubbed out SetIcon() method
+ * XplatUIX11.cs:
+ - Implemented SetIcon() support
+ - Moved SetMenu() and SetBorderStyle() to proper alphabetical pos
+ - Switched to unix line endings
+ * XplatUIWin32.cs:
+ - Made POINT internal so for can access it as part of MINMAX
+ - Implemented SetIcon() support
+ - Implemented support for CLIENTCREATESTRUCT (but might have to drop
+ native Mdi support again, might have to go managed)
+ * Control.cs: Now fires the StyleChanged event
+ * MdiClient.cs: Added; still mostly empty
+
+2005-03-10 Peter Bartok <pbartok@novell.com>
+
+ * SaveFileDialog.cs: Added emtpy file
+
+2005-03-08 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs: Fixed bug #73190; now invokes CreateControl (which
+ in turn triggers OnCreateContro) when creating a handle for the
+ first time.
+ * TextControl.cs: Fixed endless loop in certain cases when
+ replacing the current selection
+
+2005-03-08 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ScrollBar.cs:
+ - Honors NewValue changes in Scroll events allowing apps to change it
+ - Adds First and Last Scroll events
+ - Fixes Thumb events
+
+2005-03-07 Peter Bartok <pbartok@novell.com>
+
+ * Hwnd.cs: Added DefaultClientRectangle property
+ * XplatUI.cs: Now using the X11 driver Where() method, which provides
+ more detailed debug information
+ * XplatUIX11.cs:
+ - Fixed size-change feedback loop, where we would pull an old size
+ off the queue and mistakenly change our window's size to an
+ earlier value
+ - Now compressing ConfigureNotify events, to reduce looping and
+ redraw issues
+ * TextBoxBase.cs: Preventing crash when no text is set and ToString()
+ is called
+
+2005-03-07 Jackson Harper <jackson@ximian.com>
+
+ * Binding.cs: Push data pushes from data -> property. Check if the
+ property is readonly when attempting to set it.
+
+2005-03-07 Jackson Harper <jackson@ximian.com>
+
+ * Binding.cs: Format and parse data correctly. Use ASsignableFrom
+ instead of IsSubclassOf. Pulling data now sets the value on the
+ control.
+ * PropertyManager.cs:
+ * CurrencyManager.cs: Just need to pull data when updating now,
+ because PullData will set the value on the control.
+
+2005-03-04 Jackson Harper <jackson@ximian.com>
+
+ * Binding.cs: Implement data type parsing and converting on pulled
+ data. TODO: Are there more ways the data can be converted?
+
+2005-03-04 Jackson Harper <jackson@ximian.com>
+
+ * Binding.cs: Support <Property>IsNull checks. Also bind to the
+ controls Validating method so we can repull the data when the
+ control loses focus.
+
+2005-03-03 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ColumnHeader.cs:
+ - Fixes null string format
+
+ * ListView.cs:
+ - Adds enum type checks
+ - Fixes redrawing and recalc need after changing some properties
+ - Fixes on focus_item set after the event
+ - Fixes adding columns after the control has been created
+
+ * ThemeWin32Classic.cs:
+ - Fixes CheckBox focus rectangle
+ - Fixes ColumnHeader drawing
+
+
+2005-03-03 Jackson Harper <jackson@ximian.com>
+
+ * Binding.cs: Bind to <Property>Changed events so we can detect
+ when properties are changed and update the data.
+
+2005-03-02 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ImageList.cs:
+ - Changes 32-bit pixel format to Format32bppArgb to allow transparency
+ - Fixes ImageList constructor with ImageList container
+ - Fixes image scaling (wrong parameters at DrawImage)
+
+2005-02-02 Jackson Harper <jackson@ximian.com>
+
+ * Binding.cs: Make property searches case-insensitive. Eliminate
+ some duplicated code.
+
+2005-03-01 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs:
+ - Handle focus event
+ - Fix scrollbar events
+ - Discard highlighted item if remove it
+ - Fixes SelectedItem with strings
+
+2005-03-01 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - Fixed Visible property, now follows (once again) parent chain
+ to return false if any control in the chain is visible=false
+ - Fixed OnParentVisibleChanged, now just calls OnVisibleChanged event
+ - Fixed several places where is_visible instead of Visible was used
+ - Implemented FIXME related to focus selection when setting focused
+ control to be invisible
+
+ * XplatUIWin32.cs: Now using proper method to find out if window is
+ visible. Thanks to Jordi for pointing it out
+
+2005-02-28 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs: show/hide scrollbar instead of creating it
+
+2005-02-27 Jackson Harper <jackson@ximian.com>
+
+ * CurrencyManager.cs: Add PositionChanged stuff.
+
+2005-02-27 Peter Bartok <pbartok@novell.com>
+
+ * XplatUI.cs, XplatUIDriver.cs: Added new GetMenuOrigin() method
+ * XplatUIOSX.cs: Added GetMenuOrigin() stub
+ * XplatUIWin32.cs: Implemented GetMenuOrigin()
+ * XplatUIX11.cs:
+ - Implemented GetMenuDC()
+ - Implemented GetMenuOrigin()
+ - Implemented ReleaseMenuDC()
+ - Implemented generation of WM_NCPAINT message
+ - Implemented generation and handling of WM_NCCALCSIZE message
+ * Form.cs: Added debug helper message for Jordi's menu work
+ * Hwnd.cs:
+ - Modified ClientRect property; added setter, fixed getter to handle
+ setting of ClientRect
+ - Added MenuOrigin property
+
+2005-02-26 Peter Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs:
+ - Destroys the caret if a window that's being destroyed contains it
+ - Ignores expose events coming from the X11 queue for windows that
+ already are destroyed
+ - Now uses the proper variable for handling DestroyNotify, before we
+ marked the wrong window as destroyed
+ - Improved/added some debug output
+
+2005-02-26 Peter Bartok <pbartok@novell.com>
+
+ * X11Keyboard.cs: Fixes to work on 64bit systems
+
+2005-02-26 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - Now calling OnHandleDestroyed from DestroyHandle()
+ instead of Dispose()
+ - Removed bogus call to controls.Remove() from DestroyHandle()
+
+2005-02-26 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs: Properly destroy child windows when our handle is
+ destroyed
+
+2005-02-25 Peter Bartok <pbartok@novell.com>
+
+ * XplatUI.cs:
+ - Added 'DriverDebug' define to allow tracing XplatUI API calls
+ - Alphabetized Static Methods and Subclasses
+
+ * XplatUIX11.cs:
+ - Added XException class to allow custom handling of X11 exceptions
+ - Created custom X11 error handler, tied into XException class
+ - Added support for MONO_XEXCEPTIONS env var to allow the user
+ to either throw an exception on X errors or continue running
+ after displaying the error
+ - Added handling of DestroyNotify message
+ - Added handler for CreateNotify message (still disabled)
+ - Improved (tried to at least) Where method to provide file and lineno
+ * X11Structs.cs:
+ - Added XErrorHandler delegate
+ - Added XRequest enumeration (to suppor translation of errors)
+
+2005-02-25 Jackson Harper <jackson@ximian.com>
+
+ * PropertyManager.cs: Implement editing features
+ * CurrencyManager.cs:
+ * Binding.cs: First attempt at UpdateIsBinding
+ * BindingManagerBase.cs: Call UpdateIsBinding before
+ pushing/pulling data.
+
+2005-02-25 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * MenuAPI.cs: Respect disabled items
+ * ThemeWin32Classic.cs
+ - Caches ImageAttributes creation for DrawImageDisabled
+ - Fixes vertical menu line drawing
+ - Draws disabled arrows in disable menu items
+
+2005-02-24 Peter Bartok <pbartok@novell.com>
+
+ * Hwnd.cs:
+ - Added UserData property to allow associating arbitrary objects
+ with the handle
+ - Fixed leak; now removing Hwnd references from static windows array
+ * XplatUIWin32.cs:
+ - Fixed Graphics leak in PaintEventEnd
+ - Removed usage of HandleData, switched over to Hwnd class
+ * HandleData.cs: Removed, obsoleted by Hwnd.cs
+
+2005-02-24 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ThemeWin32Classic.cs: Adds Cliping to TrackBar drawing
+ * ScrollBar.cs: Fixes bug
+ * TrackBar.cs: removes death code, clipping, mimize refreshes,
+ keyboard navigation enhancements
+
+2005-02-24 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Control.cs: Call DefWndProc at WM_PAINT only if UserPaint not defined
+ * GroupBox.cs: Add control styles
+ * Label.cs: Add control styles
+ * UpDownBase.cs: Add control styles
+ * ListBox.cs: Add control styles
+ * XplatUIWin32.cs: Fixes wrong parameter order
+
+
+2005-02-23 Chris Bacon <chris.bacon@docobo.co.uk>
+
+ * ListView.cs: Assign owner for ColumnHeader. Patch by Chris Bacon
+
+2005-02-23 Jackson Harper <jackson@ximian.com>
+
+ * PropertyManager.cs: Implement property binding. This doesn't
+ seem to work yet though as (I think) there are some bugs in
+ System.ComponentModel.PropertyDescriptor.
+ * BindingContext.cs: Use new PropertyManager constructor.
+
+2005-02-23 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ProgressBar.cs: use clip region in ProgressBar
+ * ThemeWin32Classic.cs: use clip region in ProgressBar
+
+2004-02-22 Jackson Harper <jackson@ximian.com>
+
+ * BindingsCollection.cs: Remove some debug code.
+
+2005-02-22 Jackson Harper <jackson@ximian.com>
+
+ * BindingContext.cs:
+ * ControlBindingsCollection.cs:
+ * CurrencyManager.cs:
+ * Binding.cs:
+ * BindingManagerBase.cs: Initial implementation
+ * BindingsCollection.cs: Add an internal contains method that the
+ BindingManagerBase uses to ensure bindings aren't added twice to
+ the collection.
+ * PropertyManager.cs: Stubbed out.
+ * Control.cs:
+ * ContainerControl.cs: Hook up databinding
+
+2005-02-22 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs:
+ OSXStructs.cs: Refactored to handle the new Hwnd NC logic area.
+ Fixed Invalidate/Update chain.
+ Fixed tons of other minor bugs (this is almost a complete rewrite).
+
+2005-02-22 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs: do subcontrol creation when the control is created
+
+2005-02-19 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Label.cs: fixes image drawing (image and imagelist)
+ * ThemeWin32Classic.cs: cache brushes
+
+2005-02-19 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Form.cs: Move menu drawing code to Theme class
+ * ComboBox.cs: Move ComboBox drawing code to Theme class
+ * MenuItem.cs: Move menu drawing code to Theme class
+ * MenuAPI.cs: Move menu drawing code to Theme class
+ * ThemeWin32Classic.cs: New methods
+ * CheckedListBox.cs: Move CheckedListbox drawing code to Theme class
+ * ListBox.cs: Move Listbox drawing code to Theme class
+ * Theme.cs: New methods
+
+2005-02-20 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - Fixed ProcessKeyEventArgs to also handle WM_SYSKEY messages (and
+ only process mnemonics on those)
+ - Fixed event sequence for key handling; first calling
+ ProcessKeyEventArgs now
+ * TextBoxBase.cs:
+ - Removed WM_KEYDOWN hook, instead we now use ProcessDialogKey()
+ for processing non-character keys
+ - Fixed WM_CHAR to generate proper event sequence before processing
+ * XplatUIWin32.cs: Added ALT key state to ModifierKeys property
+ generation
+
+2005-02-19 Peter Bartok <pbartok@novell.com>
+
+ * UserControl.cs: Added TextChanged event; added attributes
+ * SizeGrip.cs: Implemented resizing and optional display of grip
+ * Form.cs: Fixed attribute
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIOSX.cs, XplatUIWin32.cs:
+ Changed meaning of ScrollWindow bool argument; instead of the
+ clear attribute (which will be true usually anyway), it gives the
+ option of moving child controls as well.
+ * XplatUIX11.cs:
+ - Changed to match new ScrollWindow argument
+ - Fixed GetWindowPos/SetWindowPos behaviour for toplevel controls,
+ now handles the implicit parent window a WM puts around us
+ * ScrollableControl.cs: Implemented (not the prettiest, but it seems
+ to work)
+ * TextBoxBase.cs: Adjusted to new ScrollWindow arguments
+ * TreeView.cs: Adjusted to new ScrollWindow arguments
+
+2005-02-19 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Form.cs: Menu integration with non-client area
+ * MenuItem.cs: Menu integration with non-client area
+ * MenuAPI.cs: Menu integration with non-client area
+
+2005-02-18 Peter Bartok <pbartok@novell.com>
+
+ * MethodInvoker.cs: Added
+ * MdiLayout.cs: Added
+ * SendKeys.cs: Started implementation
+ * ErrorIconAlignment.cs: Added
+
+2005-02-18 Peter Bartok <pbartok@novell.com>
+
+ * XplatUIWin32.cs: Implemented SetMenu(); fixed GetMenuDC()
+ * Form.cs: Added handling for Menu-related Non-client messages
+
+2005-02-17 Peter Bartok <pbartok@novell.com>
+
+ * UpDownBase.cs: Fixed typo, compilation errors
+ * DomainUpDown.cs: Fixed attribute value
+
+2005-02-16 Miguel de Icaza <miguel@novell.com>
+
+ * UpDownBase.cs: Attach entry events.
+ Propagate events.
+ Add ForeColor property, Focused, InterceptArrowKeys (interception
+ does not work yet).
+
+2005-02-17 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Form.cs:
+ - Redraw non client are on Setmenu
+ - Calc proper menu starting point
+
+2005-02-17 Peter Bartok <pbartok@novell.com>
+
+ * Application.cs: Fixed message_filter check
+
+2005-02-17 Peter Bartok <pbartok@novell.com>
+
+ * Application.cs: Now calls registered message filters
+ * DockStyle.cs: Fixed attribute
+ * Form.cs: Fixed attribute
+ * Menu.cs: Fixed attribute
+ * ToolTip.cs: Fixed attribute
+ * TreeNode.cs: Added missing attributes and arranged in regions
+ * PropertyGrid.cs: Fixed signatures
+ * TreeNodeCollection.cs: Added attributes
+ * Splitter.cs: Added missing attributes; arranged into regions
+ * TabPage.cs: Added missing attributes; arranged into regions
+ * TextBoxBase.cs: Added missing attributes
+ * TextBox.cs: Added missing attributes
+ * ArrangeDirection.cs: Added missing attributes
+ * TreeNodeConverter.cs: Added stub (needed for TreeNode)
+ * ToolBarButton.cs: Fixed attributes
+ * AnchorStyles.cs: Fixed attribute
+ * TrackBar.cs: Fixed attributes
+ * TabControl.cs: Added missing attributes and arranged into regions
+ * ToolBar.cs: Fixed attribute
+ * StatusBar.cs: Fixed signature, organized into regions and added
+ attributes
+ * StatusBarPanel.cs: Fixed attributes
+ * ContentsResizedEventArgs.cs: Implemented
+ * ContentsResizedEventHandler.cs: Implemented
+ * DateBoldEventArgs.cs: Implemented
+ * DateBoldEventHandler.cs: Implemented
+ * UpDownEventArgs.cs: Implemented
+ * UpDownEventHandler.cs: Implemented
+
+2005-02-16 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Form.cs: first Menu NC refactoring
+ * MenuAPI.cs: first Menu NC refactoring
+
+2005-02-16 Peter Bartok <pbartok@novell.com>
+
+ * ImeMode.cs: Added missing attributes
+ * Menu.cs: Fixed attribute
+ * GroupBox.cs: Fixed attribute
+ * Label.cs: Fixed attribute
+ * ColorDialog.cs (RunDialog): Removed TODO attribute
+ * ComboBox.cs: Fixed attributes
+ * ListControl.cs: Added missing attributes
+ * PropertyGrid.cs: Fixed attributes
+ * Control.cs: Fixed attributes
+ * ListViewItem.cs: Added TypeConverter attribute
+ * NotifyIcon.cs: Fixed attributes
+ * ListView.cs: Fixed attributes
+ * ButtonBase.cs: Fixed attribute
+ * ImageList.cs: Added missing attributes
+ * ContainerControl.cs: Fixed signature
+ * CheckedListBox.cs: Fixed attribute; added missing attributes
+ * Panel.cs: Fixed attributes
+ * PropertyTabChangedEventArgs.cs: Added missing attribute
+ * PropertyValueChangedEventArgs.cs: Added missing attribute
+ * Binding.cs: Fixed attribute
+ * ListViewItemConverter: Implemented ListViewSubItemConverter class
+ * ListBox.cs: Fixed attribute; added missing attributes;
+ * ScrollableControl.cs: Added missing attributes
+ * PictureBox.cs: Added missing attributes; implemented missing property
+ * DateTimePicker.cs: Added missing attributes
+ * Theme.cs (ToolWindowCaptionHeight): Fixed type
+ * MonthCalendar.cs: Fixed attributes
+ * StatusBarPanel.cs: Added missing attributes
+ * SystemInformation.cs (ToolWindowCaptionHeight): Fixed type
+
+2005-02-16 Peter Bartok <pbartok@novell.com>
+
+ * TextBoxBase.cs: The previous method to enforce height yet remember
+ the requested high was less than ideal, this is an attempt to do
+ it better.
+ * Control.cs: Added comment about possible problem
+ * Copyright: Updated format
+ * GridItemType.cs: Fixed swapped values
+
+2005-02-15 Jackson Harper <jackson@ximian.com>
+
+ * BaseCollection.cs: Use property so we never access an
+ uninitialized list. Also initialize the list in the property.
+
+2005-02-15 Peter Bartok <pbartok@novell.com>
+
+ * GroupBox.cs (ProcessMnemonic): Implemented
+ * Label.cs (ProcessMnemonic): Implemented
+ * ThemeWin32Classic.cs (DrawGroupBox): Added stringformat to show
+ hotkeys
+
+2005-02-15 Peter Bartok <pbartok@novell.com>
+
+ * RadioButton.cs (ProcessMnemonic): Implemented
+ * CheckBox.cs (ProcessMnemonic): Implemented
+ * Control.cs:
+ - Added handling of WM_SYSxxx keyboard messages to support mnemonic
+ handling
+ - Added internal method to allow calling ProcessMnemonic from other
+ controls
+ * ContainerControl.cs:
+ - Started support for handling validation chain handling
+ - Implemented ProcessMnemonic support
+ - Added Select() call to Active, to make sure the active control
+ receives focus
+ * Form.cs: Setting toplevel flag for Forms (this was lost in the
+ FormParent rewrite)
+ * ThemeWin32Classic.cs:
+ - DrawCheckBox(): Fixed stringformat to show hotkeys
+ - DrawRadioButton(): Fixed stringformat to show hotkeys
+ * CommonDialog.cs: Removed WndProc override, not needed
+
+2005-02-14 Peter Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs: Fixed NotImplemented exceptions for properties,
+ missed those in the rewrite
+
+2005-02-14 Miguel de Icaza <miguel@novell.com>
+
+ * NumericUpDown.cs (Increment, ToString): Add.
+ (DecimalPlaces): implement.
+
+ Add attributes.
+
+ * UpDownBase.cs: Add the designer attributes.
+
+2005-02-13 Peter Bartok <pbartok@novell.com>
+
+ * Panel.cs: Removed border_style, now in Control
+ * XplatUIDriver.cs: Added SetBorderStyle, SetMenu, GetMenuDC and
+ ReleaseMenuDC Methods; renmaed ReleaseWindow to UngrabWindow
+
+2005-02-13 Peter Bartok <pbartok@novell.com>
+
+ * MouseButtons.cs: Added missing attributes
+ * XplatUIStructs.cs: Added enumeration for title styles
+ * LeftRightAlignment.cs: Added missing attributes
+ * Hwnd.cs: Switched to use client_window as handle (slower, but makes
+ it compatible with Graphics.FromHwnd()
+ * SelectedGridItemChangedEventArgs.cs: Fixed property type
+ * Keys.cs: Added missing attributes
+ * SelectionRange.cs: Added missing attributes
+ * SelectionRangeConverter.cs: Added
+ * XplatUI.cs:
+ - Introduced SetBorderStyle, SetMenu, GetMenuDC and
+ ReleaseMenuDC methods
+ - Renamed ReleaseWindow to UngrabWindow
+ - Added proper startup notice to allow version identification
+ * Form.cs:
+ - Added missing attributes
+ - Removed FormParent concept
+ * Label.cs: Removed border_style field, now in Control
+ * RadioButton.cs: Now properly selects RadioButton when focus is
+ received
+ * ThemeGtk.cs: Fixed SetDisplay call to match new X11 behaviour
+ * Control.cs:
+ - Added missing attributes
+ - Added borderstyle handling
+ - Removed FormParent concept support
+ - Fixed calls to XplatUI to match changed APIs
+ - Fixed bug that would case us to use disposed Graphics objects
+ - Removed unneeded internal methods
+ - PerformLayout(): Fixed to handle DockStyle.Fill properly
+ - SelectNextControl(): Fixed to properly check common parents
+ * TextBoxBase.cs: Removed border_style field (now in Control)
+ * MessageBox.cs:
+ - Patch by Robert Thompson (rmt@corporatism.org): Added icon support,
+ fixed calculations for form size
+ - Added support for localized strings and icons
+ - Improved form size calculations, added border
+ * ListView.cs: Removed border_style field (now in Control)
+ * X11Structs.cs: Moved several structs from X11 driver here
+ * X11Keyboard.cs: Changed debug message
+ * Application.cs: Removed FormParent concept support
+ * CommonDialog.cs:
+ - Resetting end_modal flag
+ - Removed FormParent concept support
+ * NativeWindow.cs: Removed FormParent concept support
+ * XplatUIX11.cs: Rewritten, now using the new Hwnd class, implementing
+ Client area and Non-Client whole window to allow support for WM_NC
+ messages
+ * XplatUIOSX.cs: Updated to match latest driver spec; added exception
+ prevent using it until it supports Hwnd as per Geoff Norton's request
+ * ToolBar.cs: Fixed drawing, was not doing proper drawing
+ * PictureBox.cs: Removed border_style field, now in Control
+ * XplatUIWin32.cs: Added new driver methods
+
+2005-02-12 Peter Bartok <pbartok@novell.com>
+
+ * OpacityConverter.cs: Implemented
+ * Hwnd.cs: Internal class to support drivers that need to emulate
+ client area/non-client area window behaviour
+
+2005-02-11 Peter Bartok <pbartok@novell.com>
+
+ * KeysConverter.cs: Implemented
+
+2005-02-11 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Menu.cs: fixes methods GetContextMenu, GetMainMenu, ToString
+ * LinkLabel: Added missing attributes
+ * MainMenu.cs: fixes ToString
+ * MenuItem.cs: fixes methods GetContextMenu, GetMainMenu
+ * ListBox.cs: fixes event position
+ * TrackBar.cs: adds missing attributes and events
+
+2005-02-10 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * MenuItem.cs: Use SystemInformation and bug fixes
+ * MenuAPI.cs: Use SystemInformation and bug fixes
+
+2005-02-09 Jackson Harper <jackson@ximian.com>
+
+ * X11Keyboard.cs: We ignore some keys, but still need to set/reset
+ their keystate otherwise things like VK_MENU get stuck "on".
+
+2005-02-09 Kazuki Oikawa <kazuki@panicode.com>
+
+ * ListBox.cs: Fixes AddRange bug
+
+2005-02-09 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ProgressBar.cs
+ - Add missing attributes
+ - Add missing method
+
+ * CheckedListBox.cs: Added missing attributes
+ - Add missing attributes
+ - Remove extra method
+
+ * ComboBox.cs: Added missing attributes
+ * VScrollBar.cs: Added missing attributes
+ * ScrollBar.cs: Added missing attributes
+ * ListBox.cs: Fixes signature, add missing consts
+ * LinkArea.cs: Added missing attributes
+
+
+2005-02-08 Peter Bartok <pbartok@novell.com>
+
+ * Menu.cs: Added missing attributes
+ * MainMenu.cs: Added missing attributes
+ * GroupBox.cs: Added missing attributes
+ * Label.cs: Added missing attributes
+ * CheckBox.cs: Implemented CheckBoxAccessibleObject class
+ * ColorDialog.cs:
+ - Added Instance and Options properties
+ - Added missing attributes
+ * Cursor.cs: Made Serializable
+ * NotifyIcon: Added missing attributes
+ * MenuItem.cs: Added missing attributes
+ * TextBoxBase.cs: Implemented AppendText() and Select() methods
+ * Panel.cs: Added Missing attributes
+ * MonthCalendar.cs: Fixed CreateParams
+
+2005-02-08 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * LinkLabel.cs:
+ - Fixes signature
+ - Fixes issues with links
+ - Adds the class attributes
+
+2005-02-08 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs:
+ - Fixes button when no items available in dropdown
+ - Fixes repainting problems
+ - Adds the class attributes
+
+2005-02-07 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Detect the menu bar and title bar height from
+ the current theme. Cache these on startup.
+
+2005-02-07 Jackson Harper <jackson@ximian.com>
+
+ * ScrollBar.cs: Give the correct clipping rect to the theme. Dirty
+ the scrollbar buttons when they are depressed.
+
+2005-02-07 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Really fix working at resolutions not 1024x768.
+ Get the display size from the main displayid. We currently dont
+ support multiple display configurations.
+
+2005-02-07 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Ensure the window doesn't get stuck behind the statusbar.
+
+2005-02-07 Miguel de Icaza <miguel@novell.com>
+
+ * UpDownBase.cs: Add ReadOnly and UpDownAlign properties.
+
+2005-02-05 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * PropertyGrid.cs: Updated. Patch by Jonathan Chambers
+
+2005-02-04 Jackson Harper <jackson@ximian.com>
+
+ * ThemeWin32Classic.cs: Respect the clipping rect when
+ drawing. Only fill the intersection of clips and rects so there
+ isn't a lot of large fills.
+ * ScrollBar.cs: Pass the correct clipping rect to the theme
+ engine. Remove some debug code.
+
+2005-02-05 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * DateTimePicker.cs:
+ - Fixed crash on DateTime.Parse, use Constructor instead
+
+2005-02-04 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * MenuItem.cs:
+ * MenuAPI.cs:
+ - Owner draw support (MeasureItem and DrawItem)
+
+2005-02-04 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Menu.cs:
+ - Implements FindMergePosition and MergeMenu functions (very poor documented)
+ - Fixes MenuItems.Add range
+ * MenuItem.cs:
+ - MergeMenu and Clone and CloneMenu functions
+
+2005-02-03 Jackson Harper <jackson@ximian.com>
+
+ * ScrollBar.cs: Make abstract
+ * ScrollableControl.cs: Create H/V scrollbars now that scrollbar
+ is abstract.
+
+2005-02-03 Jackson Harper <jackson@ximian.com>
+
+ * ScrollBar.cs: First part of my scrollbar fixups. This removes
+ all the unneeded refreshes and uses invalidates with properly
+ computed rects.
+
+2005-02-03 Peter Bartok <pbartok@novell.com>
+
+ * ComponentModel.cs: Added
+ * IDataGridEditingService.cs: Added
+ * Timer.cs: Added missing attributes
+ * ToolTip.cs: Added missing attributes
+
+2005-02-03 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * PropertyGridView.cs: Added. Patch by Jonathan Chambers
+
+2005-02-03 Peter Bartok <pbartok@novell.com>
+
+ * ListBox.cs: Added missing attributes
+
+2005-02-03 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListBox.cs:
+ - Fixes font height after font change
+ - Avoid generating unnecesary OnSelectedIndexChanged on clearing
+
+2005-02-02 Peter Bartok <pbartok@novell.com>
+
+ * HandleData.cs: Introduced static methods to allow class
+ to be more self-contained and track it's own HandleData objects
+ * XplatUIOSX.cs, XplatUIWin32.cs, XplatUIX11.cs: Fixed usage of
+ HandleData to use new static methods
+
+2005-02-02 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Combobox.cs:
+ - Fixes default size and PreferredHeight
+ - Missing events
+ - ObjectCollection.Insert implementation
+
+ * ListControl.cs
+ - Fixes signature
+ * ListBox.cs:
+ - Several fixes
+ - ObjectCollection.Insert implementation
+ - No selection after clean
+ - Small fixes
+
+2005-01-31 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * ThemeWin32Classic.cs: quick fix to comboboxbutton pushed painting
+
+2005-02-01 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Combobox.cs:
+ - Caches ItemHeight calculation for OwnerDrawVariable
+ - Handles dropdown properly
+ - Fixes several minor bugs
+
+2005-01-31 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListBox.cs:
+ - Fixes 71946 and 71950
+ - Fixes changing Multicolumn on the fly
+ - Fixes keyboard navigation on Multicolumn listboxes
+
+2005-01-31 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Call ExitToShell in our teardown to avoid a
+ crash reporter log.
+
+2005-01-31 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Allow applications to actually exit.
+
+2005-01-31 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: SetWindowStyle implemented. Reposition views in
+ their parent at creation time rather than lazily later. Fixes a major
+ regression we were experiencing.
+
+2005-01-31 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * ThemeWin32Classic.cs: more date time picker painting fixes
+ * DateTimePicker.cs: more monthcalendar drop down fixes
+ * MonthCalendar.cs: more CreateParams fixes to ensure correct drop down
+
+2005-01-31 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ScrollBar.cs:
+ - When moving the thumb going outside the control should stop the moving
+ - Adds the firing of missing events
+ - Fixes no button show if Size is not specified
+ - End / Home keys for keyboard navigation
+
+2005-01-30 Peter Bartok <pbartok@novell.com>
+
+ * NotifyIcon.cs (CalculateIconRect): Removed debug output and added
+ sanity check to prevent theoretical loop
+ * XplatUIWin32.cs (SetVisible): Removed debug output
+ * XplatUIX11.cs (SystrayChange): Added sanity check
+ * ScrollableControl.cs (OnVisibleChanged): Now calls base method
+ * Control.cs (OnVisibleChanged): Added workaround for ParentForm
+ behaviour, valid until the X11 client window rewrite is done
+ * TextBox.cs (ctor): Setting proper default foreground and background
+ colors
+
+2005-01-30 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * Theme: Added DrawDateTimePicker to interface
+ * ThemeWin32Classic.cs: Added DrawDateTimePicker (incomplete)
+ * DateTimePicker.cs: Created (still needs keys and painting code)
+ * DateTimePickerFormat.cs: added
+ * MonthCalendar.cs: fixed CreateParams for popup window mode
+
+2005-01-29 Peter Bartok <pbartok@novell.com>
+
+ * ControlPaint.cs: Fixed luminace value returned on achromatic colors,
+ this should also the calculations for ligher/darker
+ * Theme.cs: Fixed defaults for ScrollBar widths/heights
+
+2005-01-29 Peter Bartok <pbartok@novell.com>
+
+ * ArrangeDirection.cs: Added
+ * ArrangeStartingPositon.cs: Added
+ * SystemInformation.cs: Implemented
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIOSX.cs, XplatUIWin32.cs,
+ XplatUIX11.cs, Theme.cs: Added/implemented new static properties
+ used by SystemInformation class
+ * X11Strucs.cs: Added XSizeHints structure
+ * MenuAPI.cs:
+ - Fixed CreateParams to make sure the menu window is always visible
+ - TrackPopupMenu: Added check to make sure we don't draw the
+ menu offscreen
+
+2005-01-29 Peter Bartok <pbartok@novell.com>
+
+ * HandleData.cs: Added method for altering invalid area
+ * TextBoxBase.cs: Implemented TextLength
+
+2005-01-28 Peter Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs: Improvement over last patch, not sending
+ the WM_PAINT directly anymore, instead we scroll any pending
+ exposed areas and let the system pick out the WM_PAINT later
+
+2005-01-28 Peter Bartok <pbartok@novell.com>
+
+ * SWF.csproj: Deleted, no longer used. Instead,
+ Managed.Windows.Forms/SWF.csproj should be used
+ * XplatUIX11.cs: Instead of posting the WM_PAINT, we send it
+ directly, to avoid a potential race condition with the next
+ scroll
+
+2005-01-28 Peter Bartok <pbartok@novell.com>
+
+ * XplatUI.cs: Made class internal
+
+2005-01-28 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * CheckedListBox.cs:
+ - Draw focus
+ - Fixed Drawing
+ - Missing methods and events
+
+2005-01-27 Peter Bartok <pbartok@novell.com>
+
+ * Application.cs (Run): Don't use form if we don't have one
+
+2005-01-27 Peter Bartok <pbartok@novell.com>
+
+ * TextBoxBase.cs (get_Lines): Fixed index off by one error
+
+2005-01-27 Peter Bartok <pbartok@novell.com>
+
+ * GridEntry.cs: Added; Patch by Jonathan S. Chambers
+ * GridItem.cs: Added; Patch by Jonathan S. Chambers
+ * GridItemCollection.cs: Added; Patch by Jonathan S. Chambers
+ * GridItemType.cs: Added; Patch by Jonathan S. Chambers
+ * PropertyGrid.cs: Added; Patch by Jonathan S. Chambers
+ * PropertySort.cs: Added; Patch by Jonathan S. Chambers
+ * PropertyTabChangedEventArgs.cs: Added; Patch by Jonathan S. Chambers
+ * PropertyTabChangedEventHandler.cs: Added; Patch by Jonathan S. Chambers
+ * PropertyValueChangedEventArgs.cs: Added; Patch by Jonathan S. Chambers
+ * PropertyValueChangedEventArgs.cs: Added; Patch by Jonathan S. Chambers
+ * SelectedGridItemChangedEventArgs.cs: Added; Patch by Jonathan S. Chambers
+ * SelectedGridItemChangedEventHandler.cs: Added; Patch by Jonathan S. Chambers
+
+2005-01-27 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Combobox.cs:
+ - Draw focus on Simple Combobox
+ - Fixes drawing issues
+ - fixes 71834
+
+2005-01-27 Peter Bartok <pbartok@novell.com>
+
+ * Form.cs:
+ - Place window in default location, instead of hardcoded 0/0
+ - Send initial LocationChanged event
+ * Control.cs:
+ - UpdateBounds after creation to find out where the WM placed us
+ - Make sure that if the ParentForm changes location the Form
+ is notified
+ * XplatUIX11.cs: XGetGeometry will not return the coords relative
+ to the root, but to whatever the WM placed around us.
+ Translate to root coordinates before returning toplevel
+ coordinates
+ * XplatUIWin32.cs: Removed debug output
+ * XplatUIOSX.cs, XplatUI.cs, XplatUIDriver.cs: Added toplevel
+ flag to GetWindowPos, to allow translation of coordinates on X11
+
+2005-01-27 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListBox.cs: connect LostFocus Event
+
+2005-01-27 Peter Bartok <pbartok@novell.com>
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIWin32.cs, XplatUIOSX.cs,
+ XplatUIX11.cs: Extended the Systray API
+ * Form.cs: Removed debug output
+ * Application.cs: Fixed focus assignment, always need to call
+ XplatUI.Activate() since Form.Activate() has rules that may
+ prevent activation
+ * NotifyIcon.cs: Should be complete now
+ * ToolTip.cs: Worked around possible timer bug
+
+2005-01-27 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs:
+ - Only invalidate the effected tabs when the
+ selected index changes. This reduces drawing and gets rid of some
+ flicker.
+ - Only refresh if the tabs need to be shifted, otherwise only
+ invalidate the slider button.
+ - On windows the tabs are not filled to right if the slider is
+ visible.
+
+2005-01-27 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Only refresh on mouseup if we are showing the
+ slider. Also only invalidate the button whose state has changed.
+
+2005-01-26 Peter Bartok <pbartok@novell.com>
+
+ * XplatUI.cs, XplatUIDriver.cs: Added Systray methods
+ * XplatUIWin32.cs: Implemented SystrayAdd(), SystrayChange()
+ and SystrayRemove() methods
+ * XplatUIOSX.cs: Stubbed Systray methods
+ * XplatUIX11.cs:
+ - Implemented SystrayAdd(), SystrayChange() and SystrayRemove()
+ methods
+ - Fixed broken XChangeProperty calls (marshalling messed up things)
+ * X11Structs.cs: Added enums and structs required for Size hinting
+ * NotifyIcon.cs: Added & implemented
+
+2005-01-26 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Space vertically layed out tabs properly.
+
+2005-01-26 Peter Bartok <pbartok@novell.com>
+
+ * Form.cs (CreateClientParams): Always set the location to 0,0
+ since we're a child window.
+
+ * Control.cs (SetVisibleCore): Always explicitly setting the location
+ of a toplevel window, apparently X11 doesn't like to move windows
+ while they're not mapped.
+
+2005-01-26 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Implement FillToRight size mode with vertically
+ rendered tabs.
+
+2005-01-26 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ControlPaint.cs, ThemeWin32Classic.cs
+ - Fixes DrawFocusRectangle
+
+2005-01-26 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * MenuAPI.cs:
+ - MenuBar tracking only starts when item is first clicked
+ - Fixes menu hidding for multiple subitems
+ - Unselect item in MenuBar when item Executed
+ - Fixes bug 71495
+
+2005-01-25 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListControl.cs:
+ - IsInputKey for ListBox
+ * ListBox.cs:
+ - Focus item
+ - Shift and Control item selection
+ - Implement SelectionMode.MultiExtended
+ - Fixes RightToLeft
+ * ComboBox.cs:
+ - IsInputKey implemented
+ - Do not generate OnTextChangedEdit on internal txt changes
+
+2005-01-23 Peter Bartok <pbartok@novell.com>
+
+ * AccessibleObject.cs: Partially implemented Select()
+ * MonthCalendar.cs: Added missing attributes and events
+ * Form.cs: Fixed CreateParams behaviour, now controls derived from
+ form can properly override CreateParams.
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIOSX.cs, XplatUIWin32.cs,
+ XplatUIX11.cs: Dropped RefreshWindow method, not needed if
+ Control performs Invalidate & Update
+ * NativeWindow (CreateHandle): Added special handling for Form
+ and Form.FormParent classes to allow overriding of From.CreateParams
+ * Control.cs:
+ - ControlNativeWindow: Renamed 'control' variable to more intuitive
+ name 'owner'
+ - ControlNativeWindow: Added Owner property
+ - Removed usage of Refresh() on property changes, changed into
+ Invalidate(), we need to wait until the queue is processed for
+ updates, direct calls might cause problems if not all vars for
+ Paint are initialized
+ - Added call to UpdateStyles() when creating the window, to set any
+ styles that CreateWindow might have ignored.
+ - Added support for Form CreateParent overrides to UpdateStyles()
+ * MessageBox.cs: Removed no longer needed FormParent override stuff,
+ CreateParams are now properly overridable
+ * CommonDialog.cs: Removed no longer needed FormParent override stuff,
+ CreateParams are now properly overridable
+
+2005-01-23 Miguel de Icaza <miguel@ximian.com>
+
+ * UpDownBase.cs (ctor): Connect TextChanged in the entry to the
+ OnTextBoxChanged.
+
+ Capture LostFocus and OnTextBoxChanged. The later introduces a
+ recursive invocation that I have not figured out yet.
+
+ Reset the timer when not using (it was accumulating).
+
+
+ (OnTextBoxChanged): Set UserEdit to true here to track whether the
+ user has made changes that require validation.
+
+ Reset changing to avoid loops.
+
+2005-01-22 Miguel de Icaza <miguel@ximian.com>
+
+ * NumericUpDown.cs: Display value at startup.
+
+ * UpDownBase.cs (Text): Do not call UpdateEditText here, only call
+ ValidateEditText.
+
+ * NumericUpDown.cs: Minimum, Maximum, Text, Value properties
+ filled in. Added some basic parsing of text.
+
+ Still missing the OnXXX method overrides, and figuring out the
+ events that must be emitted.
+
+ * UpDownBase.cs: Handle UserEdit on the Text property.
+
+2005-01-22 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs:
+ - Fixes IntegralHeight
+ - ToString method
+
+2005-01-21 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Set the SelectedIndex property when SelectedTab
+ is set so that the page visibility is updated and the tabs are
+ sized correctly.
+
+2005-01-21 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Use cliping rectangle for blitting. Give the
+ theme the clipping rect so we can do clipping while
+ drawing. Remove some debug code.
+
+2005-01-21 Jackson Harper <jackson@ximian.com>
+
+ * TabPage.cs: Add a new method so tab pages can force the tab
+ control to recalculate the tab page sizes.
+ * TabControl.cs: UpdateOwner needs to make the tab control recalc
+ sizes.
+
+2005-01-20 Jackson Harper <jackson@ximian.com>
+
+ * ThemeWin32Classic.cs: Clip text to the staus bar panels rects.
+
+2005-01-20 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Set the bounds for nodes properly. They were
+ getting screwed up when checkboxes were not enabled, but images
+ were.
+
+2005-01-20 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListBox.cs:
+ - Owner draw support
+ - Fixes
+
+2005-01-20 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIStructs.cs: More misc keys
+ * X11Keyboard.cs: Ignore some control keys.
+
+2005-01-20 Jackson Harper <jackson@ximian.com>
+
+ * X11Structs.cs: Add the modmaps to the keymask struct and tabify.
+ * X11Keyboard.cs: Set the AltGr mask when we get a key event.
+
+2005-01-19 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs: Un-selecting the control when it is loosing focus
+
+2005-01-19 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Hook up to the text controls leave event so we can
+ end editing when the users clicks outside the text box.
+
+2005-01-19 Jackson Harper <jackson@ximian.com>
+
+ * X11Keyboard.cs: Fix typo that was causing the wrong keycodes to
+ get set in the conversion array.
+
+2005-01-19 Peter Bartok <pbartok@novell.com>
+
+ * Application.cs (ModalRun): Added a call to CreateControl to ensure
+ focus is properly set
+ * Button.cs:
+ - Added missing attributes
+ - removed styles, those are already set in the base class
+ * ButtonBase.cs:
+ - Added missing attributes
+ - Added clip window styles
+ * CheckBox.cs: Added missing attributes
+ * CommonDialog.cs:
+ - FormParentWindow.CreateParams: Added required clip styles
+ * Form.cs (ProcessDialogKey): Fixed handling of Escape key, now
+ also filters modifier keys
+ * MessageBox.cs:
+ - Added assignment of Accept and Cancel button to enable Enter
+ and Esc keys in MessageBox dialogs
+ - FormParentWindow.CreateParams: Added required clip styles
+ * RadioButton.cs: Added missing attributes
+ * TextControl.cs: No longer draws selection if control does not
+ have focus
+ * TextBoxBase.cs:
+ - Now draws simple rectangle around test area to make it obvious
+ there's a control. This is a hack until we properly support borders
+ - A few simple fixes to support selections better, now erases selected
+ text when typing, and resets selection when using movement keys
+
+2005-01-19 Miguel de Icaza <miguel@ximian.com>
+
+ * UpDownBase.cs: Added some new properties.
+
+ * DomainUpDown.cs: Implement a lot to get my test working.
+
+2005-01-19 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Fix a minor bug to bring the close box back
+
+2005-01-19 Geoff Norton <gnorton@customerdna.com>
+
+ * OSXStructs (WindowAttributes): Fixed csc complaints
+
+2005-01-19 Geoff Norton <gnorton@customerdna.com>
+
+ * XplayUIOSX.cs:
+ OSXStructs.cs: Initial refactor to move enums and consts into
+ OSXStructs and use them in the driver for greater readability.
+
+2005-01-19 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Initial support for Standard Cursors.
+ * OSXStructs.cs: Move our structs here; added ThemeCursor enum
+
+2005-01-19 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs: ability to change style when the ctrl is already
+ created, missing methods and events, bug fixes, signature fixes
+
+2005-01-19 Peter Bartok <pbartok@novell.com>
+
+ * Cursors.cs (ctor): Added ctor to fix signature
+
+2005-01-18 Peter Bartok <pbartok@novell.com>
+
+ * Button.cs: Implemented DoubleClick event
+ * ButtonBase.cs:
+ - Fixed keyboard handling to behave like MS, where the press of
+ Spacebar is equivalent to a mousedown, and the key release is
+ equivalent to mouseup. Now a spacebar push will give the same
+ visual feedback like a mouse click.
+ - Added missing attributes
+ - Added ImeModeChanged event
+ - Added support for generating DoubleClick event for derived classes
+ * CheckBox.cs:
+ - Implemented DoubleClick event
+ - Added missing attributes
+ * CommonDialog.cs: Added missing attribute
+ * ContextMenu.cs: Added missing attributes
+ * RadioButton.cs:
+ - AutoChecked buttons do not allow to be unselected when clicked
+ (otherwise we might end up with no selected buttons in a group)
+ - Added missing attributes
+ - Implemented DoubleClickEvent
+ * ThreadExceptionDialog.cs: Enabled TextBox code
+
+2005-01-18 Peter Bartok <pbartok@novell.com>
+
+ * Form.cs: Removed debug output
+ * Button.cs: Added support for DoubleClick method
+
+2005-01-18 Peter Bartok <pbartok@novell.com>
+
+ * Form.cs:
+ - Added method to parent window that allows triggering size
+ calculations when a menu is added/removed
+ - set_Menu: Cleaned up mess from early days of Form and Control,
+ now properly triggers a recalc when a menu is added/removed
+ - Added case to select form itself as focused form if no child
+ controls exist
+ - Added PerformLayout call when showing dialog, to ensure properly
+ placed controls
+ * Control.cs:
+ - Select(): Made internal so Form can access it
+ - Focus(): Only call Xplat layer if required (avoids loop), and sets
+ status
+ * Application.cs (Run): Removed hack and calls PerformLayout instead
+ to trigger calculation when Form becomes visible
+
+2005-01-18 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs: fixes for ownerdraw
+
+2005-01-18 Peter Bartok <pbartok@novell.com>
+
+ * TextControl.cs:
+ - Sentinel is no longer static, each Document gets it's own, this
+ avoids locking or alternatively overwrite problems when more
+ than one text control is used simultaneously.
+ - Switched to use Hilight and HilightText brushes for text selection
+
+ * TextBoxBase.cs (PaintControl): Disabled AntiAliasing to improve looks
+
+2005-01-18 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - Hooked up the following events:
+ o ControlAdded
+ o ControlRemoved
+ o HandleDestroyed
+ o ImeModeChanged
+ o ParentChanged
+ o TabStopChanged
+ o Invalidated
+ o SystemColorsChanged
+ o ParentFontChanged
+ o Move
+ - Removed debug output
+ - Added a call to the current theme's ResetDefaults when a color change
+ is detected
+ * Form.cs: Now setting the proper ImeMode
+ * Theme.cs: Defined a method to force recreation of cached resources
+ and rereading of system defaults (ResetDefaults())
+ * ThemeWin32Classic.cs: Added ResetDefaults() stub
+
+2005-01-17 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs: Added missing attributes
+
+2005-01-17 Jackson Harper <jackson@ximian.com>
+
+ * TreeNode.cs: Implement editing. Add missing properties selected
+ and visible.
+ * TreeView.cs: Implement node editing. Also some fixes to use
+ Invalidate (invalid area) instead of Refresh when selecting.
+
+2005-01-17 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - Implemented InvokeGotFocus() method
+ - Implemented InvokeLostFocus() method
+ - Implemented InvokePaint() method
+ - Implemented InvokePaintBackground() method
+ - Implemented InvokeClick() method
+ - Implemented FindForm() method
+ - Implemented RectangleToClient() method
+ - Implemented ClientToRectangle() method
+ - Implemented ResetBackColor() method
+ - Implemented ResetCursor() method
+ - Implemented ResetFont() method
+ - Implemented ResteForeColor() method
+ - Implemented ResetImeMode() method
+ - Implemented ResetLeftToRight() method
+ - Implemented ResetText() method
+ - Implemented Scale() methods
+ - Implemented ScaleCore() method
+ - Implemented Update() method
+ - Removed unused variables
+ - Stubbed AccessibilityNotifyClients and
+ ControlAccessibleObject.NotifyClients() methods (dunno what to do
+ with those yet)
+ - Now setting proper default for RightToLeft property
+ - Fixed bug in SetClientSizeCore that would cause windows to get
+ really big
+ - Now sending Click/DoubleClick events
+ - Now selecting controls when left mouse button is clicked on
+ selectable control
+ * AccessibleEvents.cs: Added
+ * XplatUI.cs, XplatUIDriver.cs: Added UpdateWindow() method
+ * XplatUIOSX.cs: Stubbed UpdateWindow() method
+ * XplatUIWin32.cs: Implemented UpdateWindow() method
+ * XplatUIX11.cs: Implemented UpdateWindow() method
+ * Form.cs: Removed stray semicolon causing CS0162 warning
+ * ThemeWin32Classic.cs: Fixed unused variable warnings
+ * ScrollableControl.cs: Now calls base method for ScaleCore
+ * ButtonBase.cs: Now disabling StandardClick and StandardDoubleClick
+ style to avoid interference with internal click handler (which is
+ different than standard Control click handling)
+ * RadioButton.cs:
+ - Now unchecks all sibling radio buttons when control is
+ selected (Fixes #68756)
+ - Removed internal tabstop variable, using the one inherited from
+ Control
+
+2005-01-17 Jackson Harper <jackson@ximian.com>
+
+ * NavigateEventArgs.cs: Fix base type.
+ * LinkLabel.cs: Sig fix
+
+2005-01-17 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Only invalidate the effected nodes bounds when
+ selecting nodes.
+
+2005-01-13 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * XplatUIWin32.cs: fixes Win32 marshaling
+ * XplatUIX11.cs: fixes method signature
+
+2005-01-17 Peter Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs: Clean up resources when we no longer need them
+
+2005-01-17 Peter Bartok <pbartok@novell.com>
+
+ * XplatUI.cs, XplatUIDriver.cs: Added SetCursor(), ShowCursor(),
+ OverrideCursor(), DefineCursor(), DefineStdCursor(), GetCursorInfo()
+ and DestroyCursor() methods.
+ * Cursor.cs: Partially implemented, now supports standard cursors;
+ still contains some debug code
+ * Cursors.cs: Implemented class
+ * Control.cs:
+ - WndProc(): Added handling of WM_SETCURSOR message, setting the
+ appropriate cursor
+ - Implemented Cursor property
+ - Replaced break; with return; more straightforwar and possibly
+ faster
+ - Now properly setting the result for WM_HELP
+ * X11Structs.cs: Added CursorFontShape enum
+ * XplatUIStructs.cs:
+ - Added StdCursor enum (to support DefineStdCursor() method)
+ - Added HitTest enum (to support sending WM_SETCURSOR message)
+ * XplatUIX11.cs:
+ - Now sends the WM_SETCURSOR message
+ - Implemented new cursor methods
+ * XplatUIOSX.cs: Stubbed new cursor methods
+ * XplatUIWin32.cs:
+ - Implemented new cursor methods
+ - Added GetSystemMetrics function and associated enumeration
+
+2005-01-15 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - WndProc(): Now handles EnableNotifyMessage
+ - SelectNextControl(): Fixed bug where if no child or sibling
+ controls exist we looped endlessly
+
+2005-01-14 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Recalculate the tab pages when a new one is added
+ so that the proper bounding rects are created.
+
+2005-01-14 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Draw a gray box instead of a grip in the lower
+ right hand corner when there are both horizontal and vertical
+ scroll bars.
+
+2005-01-14 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: When erasing backgrounds use FromHwnd instead of
+ FromHdc when there is a NULL wparam. This occurs on the X driver.
+ * XplatUIX11.cs: Set the wparam to NULL.
+
+2005-01-13 Jackson Harper <jackson@ximian.com>
+
+ * PictureBox.cs: Implement missing methods (except ToString, need
+ to test that on windows) and events. When visibility is changed we
+ need to redraw the image because the buffers are killed. When size
+ is changed refresh if the sizemode needs it.
+
+2005-01-13 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs (SelectNextControl): Was using wrong method to select
+ a control
+
+2005-01-13 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs: fixes dropstyle
+
+2005-01-13 Peter Bartok <pbartok@novell.com>
+
+ * Form.cs:
+ - Implemented Select() override
+ - Now handles WM_SETFOCUS/WM_KILLFOCUS messages
+ - Now sets keyboard focus on startup
+ * Control.cs (SelectNextControl): Now properly handles directed=true
+ * TextBoxBase.cs:
+ - WndProc: Now passes tab key on to base if AcceptTabChar=false
+ - Added (really bad) focus rectangle (mostly for testing)
+ * TextBox.cs: Added code to handle getting/loosing focus and invalidating
+ to enforce redraw on focus changes
+ * ContainerControl.cs:
+ - Fixed detection of Shift-Tab key presses
+ - Fixed traversal with arrow keys
+ * XplatUIX11.cs: Implemented simulated keyboard focus; not sure if we're
+ gonna keep this or if it's complete yet
+
+2005-01-13 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs: missing properties, fixes
+
+2005-01-13 Peter Bartok <pbartok@novell.com>
+
+ * Panel.cs (ctor): Setting Selectable window style to off
+ * Splitter.cs (ctor): Setting Selectable window style to off
+ * GroupBox.cs (ctor): Setting Selectable window style to off
+ * Label.cs (ctor): Setting Selectable window style to off
+
+2005-01-12 Miguel de Icaza <miguel@ximian.com>
+
+ * UpDownBase.cs (InitTimer): If the timer has been already
+ created, enable it.
+
+ Use a TextBox instead of a Label.
+
+2005-01-12 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Refresh the tree after sorting the nodes. Always
+ draw the connecting node lines (when ShowLines is true).
+ * TreeNode.cs: The nodes index can now be updated. This is used
+ when a node collection is sorted.
+ * TreeNodeCollection.cs: Implement sorting. Nodes can be sorted on
+ insert or an existing unsorted node collection can be sorted.
+
+2005-01-12 Peter Bartok <pbartok@novell.com>
+
+ * ContainerControl.cs: Implemented ProcessDialogKeys()
+
+2005-01-12 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - Implemented SelectNextControl() method
+ - Several focus related bug fixes
+ - Fixed Docking calculations to match MS documentation and
+ behaviour
+
+2005-01-12 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ContainerControl.cs, ListControl.cs, ListBox.cs: keyboard navigation and
+ bug fixes
+
+2005-01-12 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs:
+ - Fixed broken Contains() method
+ - Implemented GetNextControl() method. Finally. This is the pre-
+ requisite for focus handling.
+
+2005-01-12 Peter Bartok <pbartok@novell.com>
+
+ * OSXStrucs.cs: Added
+
+2005-01-12 Peter Bartok <pbartok@novell.com>
+
+ * XplatUIWin32.cs:
+ - Removed PeekMessageFlags
+ - Implemented SetWindowStyle() method
+ * XplatUIStructs.cs: Added PeekMessageFlags
+ * X11Structs: Added missing border_width field to XWindowChanges struct
+ * XplatUIX11.cs:
+ - PeekMessage: Now throws exception if flags which are not yet
+ supported are passed
+ - Implemented SetWindowStyle() method
+ - Fixed SetZOrder to handle AfterHwnd properly
+ * XplatUI.cs: Added SetWindowStyle() method
+ * XplatUIDriver.cs: Added SetWindowStyle() abstract
+ * Control.cs:
+ - Implemented UpdateStyles() method
+ - Implemented UpdateZOrder() method
+ * XplatUIOSX.cs: Added SetWindowStyle() stub
+
+2005-01-12 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Fix SetZOrder (this needs more testing with a 3
+ button mouse).
+
+
+2005-01-11 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Still need to draw lines to siblings even if out of
+ the current node is out of the clip.
+
+2005-01-11 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: When setting the hbar/vbar/grip position use
+ SetBounds so that perform layout is only called once. Also suspend
+ and resume layout so layout is only done once for all controls.
+ - Removed some debug fluff
+ * SizeGrip.cs: Call base implmentation in overriding methods.
+ - When visibility is changed the drawing buffers are killed so we
+ need to redraw.
+
+2005-01-11 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Calculate the open node count while drawing. This
+ saves us an entire tree traversal for every paint operation. Use
+ a member var for the open node count so less vars are passed around.
+
+2005-01-11 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * MonthCalendar.cs:
+ - fixed selection to use mousemove, not mouse polling on timer
+ * ThemeWin32Classic.cs
+ - removed redundant unused variable "no_more_content"
+
+2005-01-11 Peter Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs (DoEvents): Needs to return when no more events
+ are pending, so it now calls PeekMessage instead of GetMessage;
+ implemented a incomplete version of PeekMessage
+
+2005-01-11 Peter Bartok <pbartok@novell.com>
+
+ * XplatUIWin32.cs: Switched P/Invokes to unicode charset to avoid
+ I18n issues
+ * TextBoxBase.cs: Added sending of TextChanged event
+
+2005-01-10 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Try not to draw outside the clipping rectangle on
+ each node element.
+
+2005-01-10 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs: keyboard navigation, item navigation, bug fixes
+
+2005-01-10 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs:
+ - Implement fast scrolling. Now only the newly
+ exposed nodes are drawn and the old image is moved using the
+ XplatUI::ScrollWindow method.
+ - Factor in height of nodes when calculating whether or not the
+ node is in the clipping rect.
+
+2005-01-10 Jackson Harper <jackson@ximian.com>
+
+ * TreeNodeCollection.cs: Refresh the tree when a new node is added.
+
+2005-01-10 Peter Bartok <pbartok@novell.com>
+
+ * Application.cs: Added temporary hack to resolve all our resize
+ required issues on startup. This will get fixed properly at
+ some point in the future
+
+2005-01-10 Jackson Harper <jackson@ximian.com>
+
+ * SizeGrip.cs: New internal class that is used as a sizing
+ grip control...hence the name.
+
+2005-01-10 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs: Implemented proper TabIndex handling, now assigning
+ a tabindex when a control is added to a container
+ * GroupBox.cs (ctor): Now sets the Container style bit, required
+ for Control.GetNextControl()
+
+2005-01-09 Jackson Harper <jackson@ximian.com>
+
+ * TextBoxBase.cs: Clear window when scrolling (fixes build).
+
+2005-01-09 Peter Bartok <pbartok@novell.com>
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIWin32.cs, XplatUIOSX.cs,
+ XplatUIX11.cs: Added ability to control ScrollWindow expose and
+ an overload for ScrollWindow to allow only scrolling a rectangle
+
+2005-01-09 Peter Bartok <pbartok@novell.com>
+
+ * Form.cs:
+ - Implemented SetDesktopBounds method
+ - Implemented SetDesktopLocation method
+
+2005-01-08 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Only set the vbar's Maximum and LargeChange when
+ the node count has changed, this removes to VScroll::Refresh calls
+ when drawing.
+
+2005-01-08 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Fix GetWindowState & SetWindowState
+
+2005-01-07 Jackson Harper <jackson@ximian.com>
+
+ * TreeNode.cs: Just update the single node when it is
+ checked. Don't refresh after toggling, the Expand/Collapse already
+ handles this.
+ * TreeView.cs: Respect clipping a little more when drawing. Try
+ not to redraw things that don't need to be redrawn. Just hide the
+ scrollbars when they are no longer needed instead of removing
+ them, so they don't have to be created again and again.
+
+2005-01-07 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs (SetCaretPos): We need to translate the view
+ coordinates to window space to place the caret properly, FIXED.
+ Implement GetWindowState & SetWindowState
+
+2005-01-06 Peter Bartok <pbartok@novell.com>
+
+ * Form.cs:
+ - Implemented ClientSize property
+ - Implemented DesktopBounds property
+ - Implemented DesktopLocation property
+ - Implemented IsRestrictedWindow property
+ - Implemented Size property
+ - Implemented TopLevel property
+ - Implemented FormWindowState property
+ * Control.cs:
+ - Implemented GetTopLevel() method
+ - Implemented SetTopLevel() method
+ * X11Structs.cs (Atom):
+ - Added AnyPropertyType definition
+ - Added MapState definiton and updated XWindowAttribute struct
+ * XplatUI.cs: Added GetWindowState() and SetWindowState() methods
+ * XplatUIDriver.cs: Added GetWindowState() and SetWindowState() methods
+ * XplatUIOSX.cs: Stubbed GetWindowState() and SetWindowState() methods
+ * XplatUIWin32.cs:
+ - Implemented GetWindowState() and SetWindowState() methods
+ - Fixed Win32GetWindowLong return type
+ * XplatUIX11.cs:
+ - Introduced central function for sending NET_WM messages
+ - Implemented GetWindowState() and SetWindowState() methods
+ * TextBoxBase.cs (set_Lines):
+ - Now uses Foreground color for text added via Text property (Duh!)
+ - Added code to remember programmatically requested size (fixes
+ behaviour when Multiline is set after Size)
+ - Added AutoSize logic
+
+2005-01-06 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Draw the image after the checkbox if checkboxes are enabled.
+
+2005-01-06 Jackson Harper <jackson@ximian.com>
+
+ * ListBox.cs: Don't allow the horizontal scrollbars maximum to be
+ set to less then 0.
+
+2005-01-06 Jackson Harper <jackson@ximian.com>
+
+ * ScrollableControl.cs: Lazy init the scrollbars.
+
+2005-01-06 Jackson Harper <jackson@ximian.com>
+
+ * Theme.cs: Speed up getting pens and solid brushes, by using
+ their ARGB as a hash instead of tostring and not calling Contains.
+
+2005-01-06 Peter Bartok <pbartok@novell.com>
+
+ * Form.cs:
+ - Implemented OnActivated and OnDeactivate event trigger
+ - Implemented Activate() method
+ - Fixed ShowDialog() to activate the form that was active before
+ the dialog was shown
+ * XplatUIX11.cs:
+ - Added global active_window var that tracks the currently active
+ X11 window
+ - Now always grabs Property changes from the root window to always
+ catch changes on the active window property
+ - Added code to PropertyNotify handler to send Active/Inactive
+ messages when state changes. This puts X11 and Win32 en par on
+ WM_ACTIVATE notifications (except for double notifications when
+ the user clicks away from our modal window to another one of our
+ windows)
+
+2005-01-05 Jackson Harper <jackson@ximian.com>
+
+ * ImageList.cs: Implment ctor
+
+2005-01-05 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Implement Activate/SetTopmost
+
+2005-01-05 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Implement SetZOrder, minor cleanup
+
+2005-01-05 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Implement GetActive/SetFocus.
+
+2005-01-05 Peter Bartok <pbartok@novell.com>
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIWin32.cs, XplatUIX11.cs,
+ XplatUIOSX.cs: Added GetActive method to return the currently
+ active window for the application (or null, if none is active)
+ * Form.cs:
+ - Implemented ActiveForm
+ - Commented out owner assignment for modal dialogs (causes problems
+ on Win32, since the owner will be disabled)
+ - Reworked some Active/Focus handling (still incomplete)
+ * CommonDialog.cs: Commented out owner assignment for modal dialogs
+ (causes problems on Win32, since the owner will be disabled)
+ * IWin32Window: Added ComVisible attribute
+
+2005-01-05 Peter Bartok <pbartok@novell.com>
+
+ * ToolTip.cs (WndProc): Enable setting focus now that we have the
+ required XplatUI functions.
+
+2005-01-05 Peter Bartok <pbartok@novell.com>
+
+ * XplatUI.cs, XplatUIOSX.cs, XplatUIWin32.cs, XplatUIDriver.cs,
+ XplatUIX11.cs, X11Structs.cs, Form.cs: Framework code required
+ to implement focus and activation handling; still incomplete and
+ with debug output
+
+2005-01-04 Peter Bartok <pbartok@novell.com>
+
+ * TextBoxBase.cs: Changed access level for Document property to
+ match switch to internal for TextControl
+
+2005-01-04 Peter Bartok <pbartok@novell.com>
+
+ * AccessibleObject: Added ComVisible attribute
+
+2005-01-04 Jackson Harper <jackson@ximian.com>
+
+ * X11Keyboard.cs: Remove unneeded var.
+
+2005-01-04 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs (DoEvents): Implement, Just cast aside all events
+ but PAINT.
+ * XplatUIX11.cs (GetMessage): Call Exit when we get an unknown
+ ClientMessage. This makes apps exit cleanly (more often).
+
+2005-01-04 Jackson Harper <jackson@ximian.com>
+
+ * TreeNode.cs: Patches by Kazuki Oikawa (kazuki@panicode.com) for
+ handling focus, return correct colors and fonts,
+ * TreeView.cs: Patches by Kazuki Oikawa (kazuki@panicode.com) to
+ handle selection, horizontal scrolling, and mouse interaction.
+
+2005-01-04 Peter Bartok <pbartok@novell.com>
+
+ * ICommandExecutor.cs: Added
+ * IDataGridColumnStyleEditingNotificationService.cs: Added
+ * IFeatureSupport.cs: Added
+ * IFileReaderService.cs: Added
+ * IDataObject.cs: Added ComVisible attribute
+ * AmbientProperties.cs: Added
+ * BaseCollection.cs: Added missing attributes
+ * ListBindingConverter.cs: Added (stubbed, required for certain attributes)
+ * BaseCollection.cs: Added missing attributes
+ * Binding.cs: Added TypeConverter attribute
+ * BindingContext.cs: Added DefaultEvent attribute
+ * BindingsCollection.cs: Added DefaultEvent attribute
+ * Button.cs: Added DefaultValue attribute
+ * DragEventArgs.cs: Added ComVisible attribute
+ * GiveFeedbackEventArgs.cs: Added ComVisible attribute
+ * KeyEventArgs.cs: Added ComVisible attribute
+ * KeyPressEventArgs.cs: Added ComVisible attribute
+ * MouseEventArgs.cs: Added ComVisible attribute
+ * NavigateEventArgs.cs: Added
+ * NavigateEventHandler.cs: Added
+ * FeatureSupport.cs: Added
+ * OSFeature.cs: Added
+ * Theme.cs: Added abstract Version property to support OSFeature
+ * ThemeWin32Classic.cs: Added Version property to
+ support OSFeature.Themes
+ * ProgressBar.cs: Removed OnPaintBackground override, not required since
+ the proper styles to avoid background drawing are set, also doesn't
+ match MS signature
+ * QueryAccessibilityHelpEventArgs.cs: Added ComVisible attribute
+ * QueryContinueDragEventArgs.cs: Added ComVisible attribute
+ * ScrollEventArgs.cs: Added ComVisible attribute
+ * SplitterEventArgs.cs: Added ComVisible attribute
+ * AccessibleSelection.cs: Added Flags attribute
+ * Appearance.cs: Added ComVisible attribute
+ * Border3DSide.cs: Added ComVisible attribute
+ * Border3DStyle.cs: Added ComVisible attribute
+ * BorderStyle.cs: Added ComVisible attribute
+ * DragAction.cs: Added ComVisible attribute
+ * ErrorBlinkStyle.cs: Added
+ * ScrollEventType.cs: Added ComVisible attribute
+ * AnchorStyles.cs: Added Editor attribute
+ * DockStyle.cs: Added Editor attribute
+ * HorizontalAlignment.cs: Added ComVisible attribute
+ * HelpEventArgs.cs: Added ComVisible attribute
+ * PaintEventArgs.cs: Added IDisposable
+
+2005-01-04 Peter Bartok <pbartok@novell.com>
+
+ * TextControl.cs: Switched Line, LineTag and Document classes to
+ internal
+
+2005-01-04 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs, ThemeWin32Classic.cs, ListBox.cs, Theme.cs:
+ Simple mode, fixes, IntegralHeight, etc.
+
+2005-01-04 Peter Bartok <pbartok@novell.com>
+
+ * TextBoxBase.cs: Using proper font variable now
+
+2005-01-04 Peter Bartok <pbartok@novell.com>
+
+ * Form.cs (ShowDialog): Set parent to owner, if provided
+ * GroupBox.cs: Removed unused vars
+ * TextControl.cs:
+ - Added GetHashCode() for Document and LineTag classes
+ - Removed unused variables
+ - Added CharIndexToLineTag() and LineTagToCharIndex() methods
+ to allow translation between continuous char position and line/pos
+ * CheckBox.cs: Removed vars that are provided by base class
+ * RadioButton.cs: Removed vars that are provided by base class, added
+ new keyword where required
+ * LinkLabel.cs: Added new keyword where required
+ * Control.cs (WndProc): Removed unused variable
+ * TextBoxBase.cs:
+ - Finished SelectionLength property
+ - Implemented SelectionStart property
+ - Implemented Text property
+ - Removed unused vars
+ * MessageBox.cs: Added new keyword where required
+ * TextBox.cs: Removed Text property code (now in TextBoxBase), fixed
+ WndProc signature
+ * MenuAPI.cs: Added new keyword where required
+ * ButtonBase.cs: Removed vars that are provided by base class, added
+ new keyword where required
+ * ThemeWin32Classic.cs (DrawMonthCalendarDate): Now cast Math.Floor
+ argument to double, to allow compiling with csc 2.0 (Atsushi ran
+ into this)
+ * Application.cs (Run): Now triggers the ThreadExit event
+ * CommonDialog.cs: Added new keyword where required; now properly sets
+ parent (owner) for dialog
+ * XplatUIX11.cs: Commented out unused vars
+ * StatusBar.cs: Fixed signature for Text property
+ * TabPage.cs: Undid Jordi's removal of unused var, now using the var
+
+2005-01-04 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs, TabPage.cs, MenuAPI.cs, ThemeWin32Classic.cs,
+ TrackBar.cs, MonthCalendar.cs: remove unused vars
+
+2005-01-03 Jackson Harper <jackson@ximian.com>
+
+ * ThemeWin32Classic.cs:
+ * X11Keyboard.cs: Remove unused vars.
+
+2005-01-03 Peter Bartok <pbartok@novell.com>
+
+ * TextBox.cs:
+ - set_Text: Tied into TextControl
+ - set_TextAlignment: Tied into TextControl
+ * TextControl.cs:
+ - Added alignment properties and implemented alignment handling
+ and drawing (still has a bug, not generating proper expose events)
+ - Added new Line() constructor to allow passing the line alignment
+ - Fixed selection setting, properly handling end<start now
+ - Added aligment considerations to RecalculateDocument()
+ * TextBoxBase.cs:
+ - Now properly enforces control height for single line controls
+ - Added support for CharacterCasing
+ - Added IsInputKey override
+ - Fixed Keys.Enter logic
+ - Added SetBoundsCore override
+ - Fixed mouse selection handling
+
+2005-01-03 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs:
+ - Collapse and uncheck all nodes when CheckBoxes is disabled.
+ - Checkboxes are always aligned to the bottom of the node,
+ regardless of item height.
+ - Use the node bounds to draw the text so we can center it when
+ the item height is greater then the font height.
+ - Node::Bounds are only the text part of the node.
+ * TreeNode.cs: New method to combine collapsing and unchecking all
+ nodes recursively.
+
+2005-01-02 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Draw checkmarks, handle detecting check mark clicks
+ * TreeNode.cs: Add a bounding box for the checkbox, refresh the
+ tree when a check is changed. TODO: Only refresh the checked node.
+
+2004-12-30 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Draw checkbox boxes when checkboxes are enabled.
+ * TreeNode.cs: When collapsing make sure to never collapse the
+ root node.
+
+2004-12-29 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Align lines to the bottom of plus minus boxes properly.
+
+2004-12-28 Zoltan Varga <vargaz@freemail.hu>
+
+ * X11Structs.cs X11Keyboard.cs XplatUIX11.cs: Fix 64 bit issues.
+
+2004-12-28 Peter Bartok <pbartok@novell.com>
+
+ * MessageBox.cs (get_CreateParams): Don't use owner var if it's
+ not yet assigned
+
+2004-12-28 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs (WndProc): Added WM_HELP handler, now generates
+ HelpRequested event
+ * Form.cs: Added HelpButton property and required support code
+ * XplatUIStructs.cs: Added HELPINFO structure for WM_HELP handling
+
+2004-12-28 Peter Bartok <pbartok@novell.com>
+
+ * CommonDialog.cs:
+ - Made DialogForm.owner variable internal
+ - Added check to ensure owner form is set before setting
+ owner properties in CreateParams
+
+2004-12-28 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Implement mouse hovering. Fix QDPoint struct to avoid
+ swizzling. Implement ClientToScreen and ScreenToClient. Implement
+ GetCursorPos. Fix major visibility issues. Rework the windowing
+ system to support borderless/titleless windows (implements menus).
+ Fix GetWindowPos. Implement initial background color support for
+ views.
+
+2004-12-28 Peter Bartok <pbartok@novell.com>
+
+ * Form.cs (get_CreateParams): Make sure we have an owner before using
+ the owner variable. Implement proper default if no owner exists
+
+2004-12-28 Peter Bartok <pbartok@novell.com>
+
+ * In preparation for making Managed.Windows.Forms the default build target
+ for System.Windows.Forms, the following stubbed files were added.
+ Dialogs are currently being implemented by contributors and are only
+ short-term place holders.
+ * ColorDialog.cs: Initial check-in (minmal stub)
+ * DataGrid.cs: Initial check-in (minimal stub)
+ * DataGridLineStyle.cs: Initial check-in (minimal stub)
+ * DataGridParentRowsLabelStyle.cs: Initial check-in (minimal stub)
+ * DataGridTableStyle.cs: Initial check-in (minimal stub)
+ * FontDialog.cs: Initial check-in (minimal stub)
+ * FileDialog.cs: Initial check-in (minimal stub)
+ * GridColumnStylesCollection.cs: Initial check-in (minimal stub)
+ * GridTableStylesCollection.cs: Initial check-in (minimal stub)
+ * OpenFileDialog: Initial check-in (minimal stub)
+ * IComponentEditorPageSite.cs: Initial check-in
+ * Splitter.cs: Initial check-in (for Jackson)
+ * SplitterEventArgs.cs: Initial check-in (for Jackson)
+ * SplitterEventHandler.cs: Initial check-in (for Jackson)
+ * TextBox.cs: Initial check-in; still needs some wiring to
+ TextControl backend
+ * Form.cs: Implemented ControlBox property
+ * MessageBox.cs: Added proper coding for Minimize/Maximize/ControlBox
+ * CommonDialog.cs: Added proper coding for Minimize/Maximize/ControlBox
+ * TextControl.cs: Added selection functionality; added todo header
+ * TextBoxBase.cs:
+ - Implemented Lines property
+ - Implemented TextHeight property
+ - Implemented SelectedText property
+ - Implemented SelectionLength property
+ - Implemented SelectAll method
+ - Implemented ToString method
+ - Removed and cleaned up some debug code
+ - Implemented (still buggy) mouse text selection
+
+2004-12-27 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBox.cs: Complete DropDownList implementation, fixes.
+
+2004-12-26 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ThemeWin32Classic, Theme.cs: ComboBox drawing methods
+ * ComboBoxStyle.cs: ComboBoxStyle enum
+ * ComboBox.cs: Initial work on ComboBox control
+
+2004-12-21 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs (ctor, CreateParams): Moved setting of is_visible
+ forward so that anything that creates a window gets the default,
+ also no longer uses Visible property in CreateParams to avoid
+ walking up the parent chain and possibly get the wrong visible
+ status. Fixed IsVisible to no longer walk up to the parent.
+
+2004-12-21 Peter Bartok <pbartok@novell.com>
+
+ * Form.cs (ShowDialog): Unset modality for the proper window
+
+2004-12-20 Peter Bartok <pbartok@novell.com>
+
+ * CommonDialog.cs: Initial check-in
+
+2004-12-20 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs (Visible): Now uses the parent window instead of the
+ client area window for the property
+
+ * Form.cs
+ - ShowDialog(): Now uses the proper window for modality
+ - The default visibility state for the form parent is now false. This
+ will prevent the user from seeing all the changes to the form and
+ its controls before the application hits Application.Run()
+ - Removed some stale commented out code
+
+ * NativeWindow.cs:
+ - Added FindWindow() method to have a method to check for existence
+ of a window handle
+ - Added ability to override default exception handling (for example
+ when debugging with VS.Net; to do this the ExternalExceptionHandler
+ define must be set
+ - Removed some useless debug output
+
+ * XplatUIX11.cs:
+ - Removed r37929 (SetModal patch from Ashwin Bharambe), was
+ not working as expected
+ - Implemented modal_window stack and checking for _WM_ACTIVE_WINDOW
+ property to allow switching back to the modal window if focus is
+ given to another one of our windows (Application Modal)
+ - Now only sets override_redirect if we create a window
+ without WS_CAPTION
+ - Moved EventMask selection before mapping of newly created window
+ so we can catch the map event as well
+ - Implemented Activate() method via the _WM_ACTIVE_WINDOW property
+ - Added various Atom related DllImports
+ - Implemented Exit() method
+ - .ctor() : No longer shows window if WS_VISIBLE is not defined
+ in the CreateParams
+
+ * MessageBox.cs: Now properly deals with the FormParent window by
+ providing an override the FormParent CreateParams property to
+ set as POPUP instead of OVERLAPPED window.
+
+2004-12-19 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Implement DestroyWindow. Implement ScrollWindow
+ Minor code cleanup.
+
+2004-12-19 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs (SetModal): Implement this method on OSX.
+
+2004-12-18 Peter Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs (SetModal): Applied patch from Ashwin Bharambe,
+ implementing SetModal() method
+
+2004-12-18 Peter Bartok <pbartok@novell.com>
+
+ * X11Structs.cs (XGCValues): Fixed type of function element
+ * XplatUI.cs: Added ScrollWindow() method
+ * XplatUIDriver.cs: Added ScrollWindow() abstract
+ * XplatUIWin32.cs: Implemented ScrollWindow() method
+ * XplatUIX11.cs: Implemented ScrollWindow() method
+ * XplatUIOSX.cs: Stubbed out ScrollWindow() method
+
+2004-12-17 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Fix cursor to use an Invert instead of drawing it
+ Some more keyboard support (INCOMPLETE)
+
+2004-12-17 Peter Bartok <pbartok@novell.com>
+
+ * TextControl.cs:
+ - Added color attribute to line tags.
+ - Added color argument to all functions dealing with tags
+ - Added color argument support to various functions
+ - Fixed miss-calculation of baseline/shift in certain circumstances
+
+ * TextBoxBase.cs: Added new color option to test code
+
+2004-12-17 Jackson Harper <jackson@ximian.com>
+
+ * TreeNode.cs:
+ * MonthCalendar.cs: Signature fixes
+
+2004-12-17 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Find the missing caret; caret was dissappearing after a
+ keyboard event moved it. Create a new graphics context for each paint resolves this
+
+2004-12-17 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Fix hard cpu eat on loop with existing timers,
+ Make caret exist and go blink blink. Initial keyboard support.
+ Fix exception handler, Add Invalidate support. Change way RefreshWindow
+ works.
+
+2004-12-17 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIStructs.cs: Updated set of virtual keycodes.
+ * KeyboardLayouts.cs: SCROLL_LOCK is now SCROLL
+
+2004-12-17 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: Prune old keyboard code.
+
+2004-12-17 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: When generating mouse wparams get the modifier
+ keys from the ModifierKeys property.
+
+2004-12-17 Jackson Harper <jackson@ximian.com>
+
+ * X11Keyboard.cs: Send up/down input when generating
+ messages. Remove some unused vars.
+
+2004-12-17 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs:
+ * TreeView.cs: get rid of warnings.
+
+2004-12-17 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIStructs.cs: Fix a couple wrong virtual keycodes.
+
+2004-12-17 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListBox.cs: bug fixes, changes for CheckedListBox.cs
+ CheckedListBox.cs: Implementation
+
+2004-12-17 Peter Bartok <pbartok@novell.com>
+
+ * TextControl.cs (RecalculateLine): Fixed baseline aligning calcs
+
+2004-12-16 Peter Bartok <pbartok@novell.com>
+
+ * TextControl.cs:
+ - InsertCharAtCaret(): Fixed start pos fixup
+ - CaretLine_get: No longer derives the line from the tag, the tag
+ could be stale if lines in the document have been added or deleted
+ - RebalanceAfterDelete(): Fixed bug in balancing code
+ - RebalanceAfterAdd(): Fixed really stupid bug in balancing code
+ - Line.Streamline(): Now can also elminate leading empty tags
+ - DumpTree(): Added a few more tests and prevented exception on
+ uninitialized data
+ - Added Debug section for Combining lines
+ - Delete(): Now copies all remaining properties of a line
+
+ * TextBoxBase.cs:
+ - Left mousebutton now sets the caret (and middle button still acts
+ as formatting tester, which must go away soon)
+ - Added Debug section for Deleting/Combining lines
+ - Fixed calculations for UpdateView after Combining lines
+
+2004-12-16 Peter Bartok <pbartok@novell.com>
+
+ * TextControl.cs: Now properly aligns text on a baseline, using the
+ new XplatUI.GetFontMetrics() method. Simplified several calculations
+ * TextBoxBase.cs: Moved #endif to allow compiling if Debug is not
+ defined
+
+2004-12-16 Peter Bartok <pbartok@novell.com>
+
+ * XplatUI.cs: Added GetFontMetrics() method
+ * XplatUIDriver.cs: Added GetFontMetrics() abstract
+ * XplatUIX11.cs: Implemented GetFontMetrics() method, now calls
+ into libgdiplus, our private GetFontMetrics function
+ * XplatUIOSX.cs: Implemented GetFontMetrics() method, same as X11
+ * XplatUIWin32.cs: Implemented GetFontMetrics() method
+
+2004-12-16 Jackson Harper <jackson@ximain.com>
+
+ * XplatUIStruct.cs: Add enum for dead keys
+ * X11Keyboard.cs: Map and unmap dead keys.
+
+2004-12-16 Jackson Harper <jackson@ximian.com>
+
+ * X11Keyboard.cs: Detect and use the num lock mask.
+
+2004-12-16 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs (CreateGraphics): Added check to make sure the
+ handle of the window exists before calling Graphics.FromHwnd()
+
+2004-12-16 Peter Bartok <pbartok@novell.com>
+
+ * TextBoxBase.cs: Initial check-in. DO NOT TRY TO USE THIS YET. It
+ contains a lot of code that's not supposed to be there for the
+ real thing, but required for developing/testing the textbox
+ backend.
+
+2004-12-16 Peter Bartok <pbartok@novell.com>
+
+ * TextControl.cs:
+ - Fixed Streamline method
+ - Added FindTag method to Line
+ - Added DumpTree method for debugging
+ - Added DecrementLines() method for deleting lines
+ - Fixed UpdateView to update the cursor to end-of-line on single-line
+ updates
+ - Added PositionCaret() method
+ - Fixed MoveCaret(LineDown) to move into the last line, too
+ - Added InsertChar overload
+ - Fixed InsertChar tag offset calculations
+ - Added DeleteChar() method
+ - Added Combine() method for folding lines
+ - Fixed Delete() method, no longer allocates wasted Line object and
+ now copies all properties when swapping nodes
+ - Delete() method now updates document line counter
+
+2004-12-15 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: Get the modifier keys from the keyboard driver
+ * X11Keyboard.cs: Expose the currently selected modifier keys
+ through a property.
+
+2004-12-15 Peter Bartok <pbartok@novell.com>
+
+ * TextControl.cs: Initial check-in. Still incomplete
+
+2004-12-15 Jackson Harper <jackson@ximian.com>
+
+ * TreeNode.cs:
+ * TreeView.cs: Fix build on csc (second time today ;-))
+
+2004-12-15 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Store the treenodes plus/minus box bounds when it
+ is calculated and use this for click testing.
+ * TreeNode.cs: Add functionality to store the nodes plus minus box bounds.
+
+2004-12-15 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Pass the nodes image index to the image list when
+ drawing that image.
+
+2004-12-15 Jackson Harper <jackson@ximian.com>
+
+ * X11Keyboard.cs: Set messages hwnd.
+ * XplatUIX11.cs: Pass proper hwnd wot keyboard driver. Set hwnd on
+ post_message calls.
+
+2004-12-15 Jackson Harper <jackson@ximian.com>
+
+ * X11Keyboard.cs: Fix to compile with csc.
+
+2004-12-15 Jackson Harper <jackson@ximian.com>
+
+ * X11Structs.cs: Add key mask values
+ * XplatUIStruct.cs: Add keyboard event flags, and keyboard definitions
+ * X11Keyboard.cs: New file - Extrapolates and interpolates key
+ down/up foo into WM_CHAR foo
+ * KeyboardLayouts.cs: Common keyboard layouts
+ * XplatUIX11.cs: Add the keyboard driver. Add functionality to
+ post messages into the main queue.
+
+2004-12-13 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Button.cs: implement ProcessMnemonic
+ * ThemeWin32Classic.cs: use ResPool (caching) instead of creating
+ brushes everytime
+ * Control.cs: fixes IsMnemonic (support for &&, case insensitive, etc)
+ * ButtonBase.cs: Show HotkeyPrefix (not the &)
+
+2004-12-12 John BouAntoun <jba-mon@optusnet.com.au>
+
+ * MonthCalendar.cs: Implemented click-hold for next/previous month
+ and date selection
+
+2004-12-11 Peter Bartok <pbartok@novell.com>
+
+ * X11Structs.cs:
+ - Added XKeyboardState (moved from XplatUIX11.cs)
+ - Added XCreateGC related enums and structures
+ - Added GXFunction for XSetFunction
+
+ * XplatUIStructs.cs: Added missing WS_EX_xxx definitions
+
+ * XplatUI.cs: Added CreateCaret(), DestroyCaret(), SetCaretPos() and
+ CaretVisible() calls
+
+ * ToolTip.cs: Added code to prevent stealing focus from app windows
+
+ * XplatUIDriver.cs: Added abstracts for caret functions (CreateCaret,
+ DestroyCaret, SetCaretPos and CaretVisible)
+
+ * XplatUIX11.cs:
+ - Added implementation for caret functions
+ - Moved hover variables into a struct, to make it a bit easier
+ on the eyes and to debug
+ - Removed XKeyboardState (moved to XplatUIX11.cs)
+ - Moved Keyboard properties into the properties region
+
+ * Control.cs (get_Region): Control.CreateGraphics is the appropriate
+ call to get a graphics context for our control
+
+ * XplatUIOSX.cs: Added empty overrides for the new caret functions
+
+ * TreeView.cs: Fixed bug. No matter what color was set it would always
+ return SystemColors.Window
+
+ * XplatUIWin32.cs: Implemented caret overrides
+
+2004-12-10 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListBox.cs: fire events, implement missing methods and properties,
+ sorting.
+
+2004-12-10 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * MonthCalendar.cs: invalidation bug fixing
+ * ThemeWin32Classic.cs: paint fixing
+
+2004-12-09 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Refactor to pass the real hwnd into Graphics.FromHwnd, we
+ prepare the CGContextRef there now.
+
+2004-12-09 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * MonthCalendar.cs:
+ - optimisationL only invalidate areas that have changed
+ * ThemeWin32Classic.cs:
+ - only paint parts that intersect with clip_area
+
+2004-12-09 Peter Bartok <pbartok@novell.com>
+
+ * Application.cs: Undid changes from r37004 which cause problems
+ on X11
+
+2004-12-09 Ravindra <rkumar@novell.com>
+
+ * ToolBar.cs: Added support for displaying ContextMenu
+ attached to a button on ToolBar.
+ * ToolBarButton.cs: Uncomment/fixed the DropDownMenu
+ property.
+
+2004-12-09 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Label.cs: autosize works in text change and removes unnecessary
+ invalidate
+
+2004-12-09 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ThemeWin32Classic.cs, XplatUIOSX.cs, XplatUIWin32.cs:
+ remove warnings
+
+2004-12-08 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Added mouse move/click/grab support
+ Remove some debugging WriteLines not needed anymore.
+ Add window resizing/positioning.
+ Fix visibility on reparenting.
+
+2004-12-08 Peter Bartok <pbartok@novell.com>
+
+ * XplatUIOSX.cs: Added Idle event, now compiles on VS.Net
+
+2004-12-07 Geoff Norton <gnorton@customerdna.com>
+
+ * XplatUIOSX.cs: Initial checkin
+ * XplatUI.cs: Use the Quartz driver if the environment is set to use it
+
+2004-12-03 Ravindra <rkumar@novell.com>
+
+ * ListView.cs: Added some keybindings and fixed scrolling.
+ ScrollBars listen to ValueChanged event instead of Scroll
+ Event. This would let us take care of all changes being
+ done in the scrollbars' values programmatically or manually.
+ * ListView.cs (CanMultiselect): Added a check for shift key.
+ * ListView.cs (EnsureVisible): Fixed. Do proper scrolling.
+ * ListViewItem.cs (Clone): Fixed. We need to make a copy
+ of ListViewSubItemCollection as well.
+
+2004-12-06 Peter Bartok <pbartok@novell.com>
+
+ * Control.cs (Parent): Added check and exception to prevent
+ circular parenting
+
+2004-12-03 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListBox.cs: implemented clipping, selection single and multiple,
+ bug fixing
+
+2004-12-03 Ravindra <rkumar@novell.com>
+
+ * ListView.cs (ListView_KeyDown):
+ * ListView.cs (ListView_KeyUp): Fixed multiple selection handling
+ when CTRL key is pressed.
+ * ListViewItem.cs (Selected): Fixed setting the property.
+
+2004-12-03 Marek Safar <marek.safar@seznam.cz>
+
+ * Application.cs (OnThreadException): Use ThreadExceptionDialog.
+
+ * Form.cs: Add ActiveForm, FormBorderStyle, MaximizeBox,
+ MinimizeBox, ShowInTaskbar, TopMost properties.
+
+ * ThreadExceptionDialog.cs: Implemented (disabled TextBox until
+ will be implemented).
+
+2004-12-03 Marek Safar <marek.safar@seznam.cz>
+
+ * OwnerDrawPropertyBag.cs: New internal parameterless ctor.
+
+ * TreeNode.cs: Implemented ICloneable, Fixed to pass my simple
+ tests.
+
+ * TreeNodeCollection.cs: Add exception throwing for Add,AddRange.
+
+ * TreeView.cs: BackColor is Colors.Window.
+
+2004-12-01 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: When resizing the tree if the user is making it
+ smaller we don't get expose events, so we need to handle adding
+ the horizontal scrollbar in the size changed handler as well as
+ the expose handler.
+
+2004-12-02 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DrawItemState.cs: fixes wrong enum values
+
+2004-12-01 Jackson Harper <jackson@ximian.com>
+
+ * TreeView.cs: Resize the hbar as well as the vbar on resize.
+
+2004-12-01 Jackson Harper <jackson@ximian.com>
+
+ * NodeLabelEditEventArgs.cs:
+ * NodeLabelEditEventHandler.cs:
+ * OpenTreeNodeEnumerator.cs:
+ * TreeNode.cs:
+ * TreeNodeCollection.cs:
+ * TreeView.cs:
+ * TreeViewAction.cs:
+ * TreeViewCancelEventArgs.cs:
+ * TreeViewCancelEventHandler.cs:
+ * TreeViewEventArgs.cs:
+ * TreeViewEventHandler.cs: Initial implementation.
+
+2004-12-01 Ravindra <rkumar@novell.com>
+
+ * ListView.cs (CalculateListView): Fixed scrolling related
+ calculations. Also, removed some debug statements from other
+ places.
+ * ListViewItem.cs: Changed access to 'selected' instance variable
+ from private to internal.
+ * ThemeWin32Classic.cs (DrawListViewItem): Fixed SubItem drawing.
+
+2004-12-01 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ThemeWin32Classic.cs: remove cache of brush and pens for
+ specific controls and use the global system, fixes scrollbutton
+ bugs (for small sizes, disabled, etc)
+
+ * ScrollBar.cs: does not show the thumb for very small controls
+ (as MS) and allow smaller buttons that the regular size
+
+2004-12-01 Miguel de Icaza <miguel@ximian.com>
+
+ * UpDownBase.cs: Add abstract methods for the interface.
+ Add new virtual methods (need to be hooked up to TextEntry when it
+ exists).
+ Add override methods for most features.
+ Computes the size, forces the height of the text entry.
+
+ * NumericUpDown.cs: Put here the current testing code.
+
+ * Set eol-style property on all files that do not have mixed line
+ endings, to minimize the future problems. There are still a few
+ files with mixed endings, and someone should choose whether they
+ want to move it or not.
+
+2004-11-30 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * MonthCalendar.cs, ListView.cs: use Theme colours instead of
+ System.Colors
+
+2004-11-30 Ravindra <rkumar@novell.com>
+
+ * ThemeWin32Classic.cs (DrawListViewItem): Fixed selected item
+ drawing and replaced use of SystemColors by theme colors.
+ * ListView.cs (ListView_Paint): Fixed painting done during scrolling.
+ * ListView.cs (ListViewItemCollection.Add): Throw exception when
+ same ListViewItem is being added more than once.
+
+2004-11-30 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * MonthCalendar.cs:
+ - ControlStyles love to make the control not flicker
+
+2004-11-30 Peter Bartok <pbartok@novell.com>
+
+ * CharacterCasing.cs: Added
+
+2004-11-29 Peter Bartok <pbartok@novell.com>
+
+ * TreeNode.cs, TreeNodeCollection.cs, TreeView.cs,
+ TreeViewAction.cs, TreeViewEventArgs.cs: Removed new files.
+ I am removing these files as they conflict with already completed
+ work. While it is fantastic to get contributions to MWF, I
+ respectfully ask that everyone please coordinate their contributions
+ through mono-winforms-list or #mono-winforms at this time. We're
+ explicitly avoiding stubbing and don't want controls that don't have
+ their basic functionality implemented in svn. Please also see
+ http://www.mono-project.com/contributing/winforms.html
+
+
+2004-11-29 Marek Safar <marek.safar@seznam.cz>
+
+ * Application.cs (ModalRun): Don't hang after exit.
+
+ * Theme.cs: New TreeViewDefaultSize property.
+
+ * ThemeWin32Classic.cs: Replaced hardcoded defaultWindowBackColor
+ with less hardcoded SystemColors constant.
+ Implemented TreeViewDefaultSize.
+
+ * TreeNode.cs, TreeNodeCollection.cs, TreeView.cs,
+ TreeViewAction.cs, TreeViewEventArgs.cs: New files.
+
+
+2004-11-29 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * MonthCalendar.cs:
+ - Fix NextMonthDate and PrevMonthDate click moving calendar
+
+2004-11-26 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * MonthCalendar.cs:
+ - Fix usage of ScrollChange Property when scrolling months
+
+2004-11-26 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Menu.cs, MainMenu.cs, MenuItem.cs, MenuAPI.cs
+ - Fixes menu destroying
+ - Support adding and removing items on already created menus
+
+2004-11-26 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * MonthCalendar.cs:
+ - Re-worked all bolded dates handling to match win32
+ * ThemeWin32Classic.cs:
+ - Fixed rendering with bolded dates
+
+2004-11-25 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListBox.cs, Theme.cs, ThemeWin32Classic.cs:
+ - Horizontal scroolbar
+ - Multicolumn
+ - Fixes
+
+
+2004-11-25 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * MonthCalendar.cs:
+ - Fix Usage of MaxSelectionCount from SelectionRange
+ - Fixed Shift + Cursor Selection
+ - Fixed Shift + (Pg up/Pg dn, Home/End) selection
+ - Fixed normal cursor selection to be compat with win32
+ - Fixed Shift + Mouse Click selection
+
+2004-11-24 Peter Bartok <pbartok@novell.com>
+
+ * XplatUI.cs (DispatchMessage): Switched to return IntPtr
+ * XplatUIDriver.cs (DispatchMessage): Switched to return IntPtr
+ * XplatUIX11.cs:
+ - CreatedKeyBoardMsg now updates keystate with Alt key
+ - Added workaround for timer crash to CheckTimers, Jackson will
+ develop a proper fix and check in later
+ - Implemented DispatchMessage
+ - Removed calling the native window proc from GetMessage (call
+ now moved to DispatchMessage)
+
+ * KeyEventArgs.cs (Constructor): Now combines modifierkeys into
+ the keydata (Fixes bug #69831)
+
+ * XplatUIWin32.cs:
+ - (DispatchMessage): Switched to return IntPtr
+ - Added DllImport for SetFocus
+
+2004-11-24 Ravindra <rkumar@novell.com>
+
+ * ThemeWin32Classic.cs: Fixed ListView border and checkbox
+ background drawing.
+ * ListViewItem.cs: Fixed various properties, calculations
+ and Clone() method. Fixed ListViewSubItemCollection.Clear() method.
+ * ListView.cs: Fixed calculations, BackColor, ForeColor properties
+ and some internal properties. Fixed MouseDown handler and Paint
+ method.
+
+2004-11-24 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * MonthCalendar.cs: Add TitleMonth ContextMenu handling
+
+2004-11-24 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * ContainerControl.cs: correct accidental check in of local changes
+
+2004-11-24 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * ThemeWin32Classic.cs:
+ - Fixed Drawing Last month in grid (sometimes not showing)
+ * MonthCalendar.cs:
+ - Fixed title width calculation bug (makeing title small)
+
+2004-11-23 Peter Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs:
+ - Added generation of WM_MOUSEHOVER event
+ - Added missing assignment of async_method atom
+ - Fixed WM_ERASEBKGND; now only redraws the exposed area
+
+2004-11-23 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * ThemeWin32Classic.cs:
+ - Fixed Drawing of today circle when showtodaycircle not set
+ - fixed drawing of first and last month in the grid (gay dates)
+ * MonthCalendar.cs:
+ - Fixed Drawing of today circle
+ - Fixed drawing of grady dates
+ - Fixed HitTest for today link when ShowToday set to false
+ - Fixed DefaultSize to obey ShowToday
+
+2004-11-23 John BouAntoun <jba-mono@optusnet.com.au>
+
+ * ThemeWin32Classic.cs: Fixed DrawMonthCalendar and private support methods
+ * System.Windows.Forms/Theme.cs
+ * MonthCalendar.cs: added for MonthCalendar
+ * SelectionRange.cs: added for MonthCalendar
+ * Day.cs: added for MonthCalendar: added for MonthCalendar
+ * DateRangeEventArgs.cs: added for MonthCalendar
+ * DateRangeEventHandler.cs: added for MonthCalendar
+
+2004-11-22 Ravindra <rkumar@novell.com>
+
+ * ThemeWin32Classic.cs: Fixed ListViewDrawing with 'UseItemStyleForSubItems'
+ property.
+
+2004-11-22 Miguel de Icaza <miguel@ximian.com>
+
+ * UpDownBase.cs (InitTimer): Use prehistoric C# 1.0 notation for
+ event handler.
+
+ * NumericUpDown.cs: Added new implementation.
+ * UpDownBase.cs: Added new implementation.
+
+ * XplatUIWin32.cs (KeyboardSpeed, KeyboardDelay): added default
+ implementations.
+
+ * XplatUIX11.cs (KeyboardSpeed, KeyboardDelay): added default
+ implementations.
+
+ * XplatUIDriver.cs ((KeyboardSpeed, KeyboardDelay): added new
+ methods.
+
+2004-11-21 Miguel de Icaza <miguel@ximian.com>
+
+ * Timer.cs (Dispose): Should call the base dispose when
+ overriding.
+
+2004-11-19 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ScrollBar.cs: updates thumb position when max, min or increment
+ is changed
+
+2004-11-21 Ravindra <rkumar@novell.com>
+
+ * ListView.cs: Implemented item selection, activation and
+ column header style. Fixed properties to do a redraw, if
+ required. Added support for MouseHover, DoubleClick, KeyDown
+ and KeyUp event handling and some minor fixes.
+ * ListViewItem.cs: Fixed constructor.
+ * ThemeWin32Classic.cs: Improved drawing for ListView.
+
+2004-11-19 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ThemeWin32Classic.cs: initial listbox drawing code
+ * DrawMode.cs: new enumerator
+ * ListControl.cs: stubbed class
+ * ListBox.cs: initial implementation
+ * Theme.cs: new methods definitions
+ * SelectionMode.cs: new enumerator
+
+2004-11-17 Peter Bartok <pbartok@novell.com>
+
+ * XplatUIWin32.cs: Added double-click events to the class style
+ * Control.cs (WndProc):
+ - Added handling of click-count to MouseDown/ MouseUp events.
+ - Added handling of middle and right mouse buttons
+ - Removed old debug code
+
+2004-11-17 Jackson Harper <jackson@ximian.com>
+
+ * XplatUIX11.cs: Use the new Mono.Unix namespace.
+
+2004-11-17 Ravindra <rkumar@novell.com>
+
+ * ListView.cs: Added event handling for MouseMove/Up/Down.
+ * ColumnHeader.cs: Added a read-only internal property 'Pressed'.
+ * ThemeWin32Classic.cs: We need to clear the graphics context and
+ draw column header in a proper state.
+
+
+2004-11-17 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Menu.cs: fixes signature
+
+2004-11-16 Peter Bartok <pbartok@novell.com>
+
+ * XplatUIX11.cs (GetMessage): Implemented generation of
+ double click mouse messages
+
+2004-11-12 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Form.cs, MainMenu.cs, MenuAPI.cs: tracker should be for tracking session
+ not by menu
+
+2004-11-11 Peter Bartok <pbartok@novell.com>
+
+ * HandleData.cs: Added Visible property
+ * XplatUIX11.cs (IsVisible): Now uses Visible property from
+ HandleData
+ * XplatUIX11.cs: Removed old debug leftovers
+ * XplatUIX11.cs (DefWndProc): Added WM_ERASEBKGND handler
+ * Control.cs (WndProc): Removed old debug leftovers,
+ streamlined handling of WM_WINDOWPOSCHANGED, removed un-
+ needed WM_SIZE handling
+
+2004-11-11 Jackson Harper <jackson@ximian.com>
+
+ * OwnerDrawPropertyBag.cs:
+ * TreeViewImageIndexConverter.cs: Initial implementation
+
+2004-11-10 Jackson Harper <jackson@ximian.com>
+
+ * ThemeWin32Classic.cs:
+ * TabControl.cs: instead of moving tabs by the slider pos just
+ start drawing at the tab that is offset by the slider. This way
+ scrolling always moves by exactly one tab.
+
+2004-11-10 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: You can only scroll left when the slider has
+ already ben moved right.
+
+2004-11-10 Jackson Harper <jackson@ximian.com>
+
+ * ThemeWin32Classic.cs: Do not draw the selected tab if its not in
+ the clip area.
+
+2004-11-10 Jackson Harper <jackson@ximian.com>
+
+ * ThemeWin32Classic.cs: Don't bother drawing tabs outside of the
+ clip area.
+
+2004-11-09 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs (CalcXPos): New helper method so we can determine
+ the proper place to start drawing vertical tabs.
+ * ThemeWin32Classic.cs (DrawTab): Draw right aligned tabs.
+
+2004-11-09 Jackson Harper <jackson@ximian.com>
+
+ * TabControl.cs: Calculate sizing and rects for left aligned tabs.
+ * ThemeWin32Classic.cs (GetTabControl*ScrollRect): Only handle Top
+ and Bottom, left and right are illegal values for this and
+ multiline is enabled when the alignment is set to left or right.
+ (DrawTab): Each alignment block should draw the text itself now
+ because Left requires special love. Also add rendering for Left
+ aligned tabs.
+
+2004-11-09 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Form.cs, MainMenu.cs, MenuAPI.cs: fixes menu navigation, fixes popups,
+ does not destroy the windows, removes debugging messages
+
+2004-11-09 jba <jba-mono@optusnet.com.au>
+
+ * ThemeWin32Classic.cs
+ (DrawButtonBase): Fix verticle text rect clipping in windows
+ (DrawCheckBox): Fix CheckAlign.TopCenter and CheckAlign.BottomCenter
+ rendering and incorrect text rect clipping
+ (DrawRadioButton): Fix CheckAlign.TopCenter and CheckAlign.BottomCenter
+ rendering and incorrect text rect clipping
+
+2004-11-08 Jackson Harper <jackson@ximian.com>
+
+ * ThemeWin32Classic.cs (DrawTabControl): Render tabs from top to
+ bottom when they are bottom aligned so the bottoms of the tabs get
+ displayed.
+ * TabControl.cs (DropRow): Move rows up instead of down when the
+ tab control is bottom aligned.
+
+2004-11-08 13:59 pbartok
+
+ * XplatUIX11.cs:
+ - Added handling for various window styles
+ - Added handling for popup windows
+ - Added SetTopmost handling
+
+2004-11-08 13:55 pbartok
+
+ * XplatUIWin32.cs:
+ - Added argument to SetTopmost method
+ - Fixed broken ClientToScreen function
+
+2004-11-08 13:53 pbartok
+
+ * XplatUIStructs.cs:
+ - Added missing WS_EX styles
+
+2004-11-08 13:53 pbartok
+
+ * XplatUI.cs, XplatUIDriver.cs:
+ - Added argument to SetTopmost
+
+2004-11-08 13:52 pbartok
+
+ * X11Structs.cs:
+ - Added XSetWindowAttributes structure
+ - Improved XWindowAttributes structure
+ - Added SetWindowValuemask enum
+ - Added window creation arguments enum
+ - Added gravity enum
+ - Added Motif hints structure
+ - Added various Motif flags and enums
+ - Added PropertyMode enum for property functions
+
+2004-11-08 13:50 pbartok
+
+ * Form.cs:
+ - Fixed arguments for updated SetTopmost method
+
+2004-11-08 13:49 pbartok
+
+ * ToolTip.cs:
+ - Fixed arguments for updated SetTopmost function
+ - Fixed usage of PointToClient
+
+2004-11-08 13:44 pbartok
+
+ * MenuAPI.cs:
+ - Added Clipping of children and siblings
+
+2004-11-08 13:41 pbartok
+
+ * MainMenu.cs:
+ - Removed SetMenuBarWindow call. We do this in Form.cs
+
+2004-11-08 13:40 jackson
+
+ * TabControl.cs, Theme.cs, ThemeWin32Classic.cs: Render the little
+ scrolling jimmi in the correct location with bottom aligned tabs
+
+2004-11-08 13:36 pbartok
+
+ * ContainerControl.cs:
+ - Implemented BindingContext
+ - Implemented ParentForm
+
+2004-11-08 12:46 jackson
+
+ * TabControl.cs: Put bottom rendered tabs in the right location
+
+2004-11-08 07:15 jordi
+
+ * ScrollBar.cs, ThemeWin32Classic.cs: fixes vertical scrollbar and
+ removes dead code
+
+2004-11-05 17:30 jackson
+
+ * TabControl.cs: When selected tabs are expanded make sure they
+ don't go beyond the edges of the tab control
+
+2004-11-05 14:57 jackson
+
+ * TabControl.cs: Reset show_slider so if the control is resized to
+ a size where it is no longer needed it's not displayed anymore
+
+2004-11-05 13:16 jackson
+
+ * TabControl.cs: Make tab pages non visible when added to the
+ control
+
+2004-11-05 12:42 jackson
+
+ * TabControl.cs: Implement SizeMode.FillToRight
+
+2004-11-05 12:16 jackson
+
+ * Control.cs: Do not call CreateHandle if the handle is already
+ created
+
+2004-11-05 11:46 jackson
+
+ * TabControl.cs: Remove superflous call to CalcTabRows
+
+2004-11-05 09:07 jackson
+
+ * XplatUIX11.cs: Update for Mono.Posix changes
+
+2004-11-05 07:00 ravindra
+
+ * ListView.cs, ListViewItem.cs: Implemented some methods and fixed
+ scrolling.
+
+2004-11-04 22:47 jba
+
+ * ThemeWin32Classic.cs:
+ - Fix Button rendering for FlatStyle = Flat or Popup
+ - Fix RadioButton and CheckBox rendering when Appearance = Button
+ (normal and flatstyle).
+ - Correct outer rectangle color when drawing focus rectangle
+ - Adjust button bounds to be 1 px smaller when focused
+ - Make button not draw sunken 3d border when pushed (windows compat)
+ - Fix CPDrawBorder3D to not make bottom right hand corner rounded
+ - Offset the text in RadioButton and Checkbox when being rendered as
+ a button.
+ - Hover and Click behaviour for Colored FlatStyle.Flat and Popup
+ radiobuttons
+ - Fixed disabled rendering for colored flatstyle radiobuttons (both)
+ - Fixed disabled text rendering for normally rendered radiobuttons
+
+2004-11-04 10:26 jackson
+
+ * TabControl.cs: Recalculate tab rows when resizing
+
+2004-11-04 07:47 jordi
+
+ * Form.cs, MainMenu.cs, Menu.cs, MenuAPI.cs, MenuItem.cs:
+ collection completion, drawing issues, missing features
+
+2004-11-04 05:03 ravindra
+
+ * ScrollBar.cs:
+ - We need to recalculate the Thumb area when
+ LargeChange/maximum/minimum values are changed.
+ - We set the 'pos' in UpdatePos() method to minimum, if it's less
+ than minimum. This is required to handle the case if large_change is
+ more than max, and use LargeChange property instead of large_change
+ variable.
+ - We return max+1 when large_change is more than max, like MS does.
+
+2004-11-04 04:29 ravindra
+
+ * ColumnHeader.cs, ListView.cs, ListViewItem.cs:
+ - Changed default value signatures (prefixed all with ListView).
+ - Fixed/implemented layout LargeIcon, SmallIcon and List views for
+ ListView.
+ - Fixed calculations for ListViewItem and implemented Clone()
+ method.
+
+2004-11-04 04:26 ravindra
+
+ * Theme.cs, ThemeWin32Classic.cs:
+ - Changed default ListView values signatures (prefixed all with
+ ListView).
+ - Fixed default size values for VScrollBar and HScrollBar.
+ - Fixed DrawListViewItem method.
+
+2004-11-04 04:05 ravindra
+
+ * ColumnHeaderStyle.cs: Typo. It should be Nonclickable.
+
+2004-11-04 04:04 ravindra
+
+ * ImageList.cs: Implemented the missing overload for Draw method.
+
+2004-11-03 19:29 jackson
+
+ * TabControl.cs: Handle dropping rows on selection properly
+
+2004-11-03 11:59 jackson
+
+ * TabControl.cs: remove debug code
+
+2004-11-03 11:52 jackson
+
+ * TabControl.cs, ThemeWin32Classic.cs: Initial implementation of
+ the scrolly widgerywoo
+
+2004-11-02 13:52 jackson
+
+ * TabControl.cs: Resize the tab pages and tabs when the tab control
+ is resized
+
+2004-11-02 13:40 jackson
+
+ * TabControl.cs, ThemeWin32Classic.cs: Move the row with the
+ selected tab to the bottom
+
+2004-11-02 13:39 jackson
+
+ * TabPage.cs: Store the tab pages row
+
+2004-11-02 12:33 jordi
+
+ * MenuItem.cs: fixes handle creation
+
+2004-11-02 11:42 jackson
+
+ * TabControl.cs: signature fix
+
+2004-11-02 08:56 jackson
+
+ * TabControl.cs: Calculate whether the tab is on an edge properly.
+ Remove top secret debugging code
+
+2004-11-01 19:57 jackson
+
+ * TabControl.cs: Add click handling, and proper sizing
+
+2004-11-01 19:47 jackson
+
+ * Theme.cs, ThemeWin32Classic.cs: New rendering and sizing code for
+ tab controls
+
+2004-11-01 19:39 jackson
+
+ * TabPage.cs: add internal property to store the bounds of a tab
+ page
+
+2004-10-30 04:23 ravindra
+
+ * Theme.cs, ThemeWin32Classic.cs: Drawing ListView and some default
+ values.
+
+2004-10-30 04:21 ravindra
+
+ * ListView.cs, ListViewItem.cs: Added support for scrolling and
+ fixed calculations.
+
+2004-10-30 03:06 pbartok
+
+ * XplatUIX11.cs:
+ - Removed extension of DllImported libs
+
+2004-10-29 09:55 jordi
+
+ * Form.cs, MainMenu.cs, Menu.cs, MenuAPI.cs, MenuItem.cs: Menu key
+ navigation, itemcollection completion, menu fixes
+
+2004-10-27 22:58 pbartok
+
+ * XplatUIX11.cs:
+ - Now throws a nice error message when no X display could be opened
+
+2004-10-26 13:51 jordi
+
+ * ListView.cs: removes warning
+
+2004-10-26 03:55 ravindra
+
+ * ColumnHeader.cs, ListView.cs, ListViewItem.cs,
+ ThemeWin32Classic.cs: Some formatting for my last checkins.
+
+2004-10-26 03:36 ravindra
+
+ * ThemeWin32Classic.cs: Implemented DetailView drawing for ListView
+ control and default values.
+
+2004-10-26 03:35 ravindra
+
+ * Theme.cs: Added some default values for ListView control.
+
+2004-10-26 03:33 ravindra
+
+ * ToolBar.cs: ToolBar should use the user specified button size, if
+ there is any. Added a size_specified flag for the same.
+
+2004-10-26 03:33 ravindra
+
+ * ColumnHeader.cs: Added some internal members and calculations for
+ ColumnHeader.
+
+2004-10-26 03:32 ravindra
+
+ * ListViewItem.cs: Calculations for ListViewItem.
+
+2004-10-26 03:31 ravindra
+
+ * ListView.cs: Added some internal members and calculations for
+ ListView.
+
+2004-10-22 13:31 jordi
+
+ * MenuAPI.cs: speedup menus drawing
+
+2004-10-22 13:16 jackson
+
+ * XplatUIX11.cs: Make sure to update exposed regions when adding an
+ expose event
+
+2004-10-22 11:49 jackson
+
+ * Control.cs: oops
+
+2004-10-22 11:41 jackson
+
+ * Control.cs: Check to see if the window should have its background
+ repainted by X when drawing.
+
+2004-10-22 11:31 jackson
+
+ * XplatUIX11.cs: When invalidating areas only use XClearArea if
+ clear is true, this way we do not get flicker from X repainting the
+ background
+
+2004-10-22 11:28 jackson
+
+ * XEventQueue.cs: Queue properly
+
+2004-10-21 09:38 jackson
+
+ * XEventQueue.cs: Fix access modifier
+
+2004-10-21 09:36 jackson
+
+ * XEventQueue.cs: Don't loose messages
+
+2004-10-21 09:22 jackson
+
+ * XEventQueue.cs: Don't loose messages
+
+2004-10-20 04:15 jordi
+
+ * BootMode.cs: enum need it by SystemInfo
+
+2004-10-19 21:58 pbartok
+
+ * XplatUIWin32.cs:
+ - Small sanity check
+
+2004-10-19 21:56 pbartok
+
+ * Form.cs:
+ - Added private FormParentWindow class which acts as the container
+ for our form and as the non-client area where menus are drawn
+ - Added/Moved required tie-ins to Jordi's menus
+ - Fixed/Implemented the FormStartPosition functionality
+
+2004-10-19 21:52 pbartok
+
+ * Control.cs:
+ - Removed unneeded locals
+ - Added code to all size and location properties to understand and
+ deal with the parent container of Form
+
+2004-10-19 21:33 pbartok
+
+ * Application.cs:
+ - Fixed to deal with new Form subclasses for menus
+
+2004-10-19 17:48 jackson
+
+ * XEventQueue.cs: commit correct version of file
+
+2004-10-19 16:50 jackson
+
+ * XEventQueue.cs, XplatUIX11.cs: New optimized event queue
+
+2004-10-19 16:15 jordi
+
+ * MenuAPI.cs: MenuBarCalcSize returns the height
+
+2004-10-19 08:31 pbartok
+
+ * Control.cs:
+ - Added missing call to PreProcessMessage before calling OnXXXKey
+ methods
+
+2004-10-19 00:04 ravindra
+
+ * ToolTip.cs: Fixed constructor.
+
+2004-10-18 09:31 jordi
+
+ * MenuAPI.cs: menuitems in menubars do not have shortcuts
+
+2004-10-18 09:26 jordi
+
+ * MenuItem.cs: fixes MenuItem class signature
+
+2004-10-18 08:56 jordi
+
+ * MenuAPI.cs: prevents windows from showing in the taskbar
+
+2004-10-18 00:28 ravindra
+
+ * ToolTip.cs: Suppressed a warning message.
+
+2004-10-18 00:27 ravindra
+
+ * Control.cs: Default value of visible property must be true.
+
+2004-10-17 23:19 pbartok
+
+ * ToolTip.cs:
+ - Complete implementation
+
+2004-10-17 23:19 pbartok
+
+ * XplatUIX11.cs:
+ - Added EnableWindow method
+ - Added SetModal stub
+ - Added generation of WM_ACTIVATE message (still needs testing)
+ - Added SetTopMost stub
+ - Changes to deal with VirtualKeys being moved to XplatUIStructs.cs
+
+2004-10-17 23:17 pbartok
+
+ * XplatUIWin32.cs:
+ - Removed VirtualKeys to XplatUIStructs
+ - Implemented SetTopMost method
+ - Implemented EnableWindow method
+ - Bugfix in ScreenToClient()
+ - Bugfixes in ClientToScreen()
+
+2004-10-17 22:51 pbartok
+
+ * XplatUIStructs.cs:
+ - Added WS_EX styles to WindowStyles enumeration
+
+2004-10-17 22:50 pbartok
+
+ * XplatUI.cs, XplatUIDriver.cs:
+ - Added method for enabling/disabling windows
+ - Added method for setting window modality
+ - Added method for setting topmost window
+
+2004-10-17 22:49 pbartok
+
+ * ThemeWin32Classic.cs:
+ - Added ToolTip drawing code
+
+2004-10-17 22:49 pbartok
+
+ * Theme.cs:
+ - Added ToolTip abstracts
+
+2004-10-17 22:47 pbartok
+
+ * Form.cs:
+ - Fixed Form.ControlCollection to handle owner relations
+ - Added Owner/OwnedForms handling
+ - Implemented Z-Ordering for owned forms
+ - Removed unneeded private overload of ShowDialog
+ - Fixed ShowDialog, added the X11 incarnation of modal handling (or
+ so I hope)
+ - Fixed Close(), had wrong default
+ - Added firing of OnLoad event
+ - Added some commented out debug code for Ownership handling
+
+2004-10-17 22:16 pbartok
+
+ * Control.cs:
+ - Fixed/implemented flat list of controls
+
+2004-10-17 22:14 pbartok
+
+ * Application.cs:
+ - Added code to simulate modal dialogs on Win32
+
+2004-10-17 16:11 jordi
+
+ * ScrollBar.cs: disabled scrollbar should not honor any keyboard or
+ mouse event
+
+2004-10-17 13:39 jordi
+
+ * MenuAPI.cs: menu drawing fixes
+
+2004-10-15 09:10 ravindra
+
+ * StructFormat.cs: General Enum.
+
+2004-10-15 09:09 ravindra
+
+ * SizeGripStyle.cs: Enum for Form.
+
+2004-10-15 09:08 ravindra
+
+ * Theme.cs, ThemeWin32Classic.cs: Added ColumnHeaderHeight property
+ in Theme for ListView.
+
+2004-10-15 09:06 ravindra
+
+ * ColumnHeader.cs: Flushing some formatting changes.
+
+2004-10-15 09:05 ravindra
+
+ * ListViewItem.cs: Implemented GetBounds method and fixed coding
+ style.
+
+2004-10-15 09:03 ravindra
+
+ * ListView.cs: Implemented Paint method and fixed coding style.
+
+2004-10-15 07:34 jordi
+
+ * MenuAPI.cs: fix for X11
+
+2004-10-15 07:32 ravindra
+
+ * ButtonBase.cs, CheckBox.cs, RadioButton.cs:
+ - Renamed Paint() method to Draw() for clarity. Also, moved
+ DrawImage() to OnPaint().
+
+2004-10-15 07:25 ravindra
+
+ * CheckBox.cs, RadioButton.cs:
+ - Removed Redraw (), we get it from ButtonBase.
+ - Implemented Paint (), to do class specific painting.
+
+2004-10-15 07:16 ravindra
+
+ * ButtonBase.cs:
+ - Redraw () is not virtual now.
+ - Added an internal virtual method Paint (), so that
+ derived classes can do their painting on their own.
+ - Modified OnPaint () to call Paint ().
+
+2004-10-15 06:43 jordi
+
+ * ContextMenu.cs, DrawItemEventHandler.cs, Form.cs, MainMenu.cs,
+ MenuAPI.cs, MenuItem.cs: menu work, mainmenu, subitems, etc
+
+2004-10-15 00:30 ravindra
+
+ * MessageBox.cs:
+ - MessageBox on windows does not have min/max buttons.
+ This change in CreateParams fixes this on Windows. We
+ still need to implement this windowstyle behavior in
+ our X11 driver.
+
+2004-10-14 05:14 ravindra
+
+ * ToolBar.cs:
+ - Changed Redraw () to do a Refresh () always.
+ - Fixed the MouseMove event handling when mouse is pressed,
+ ie drag event handling.
+ - Replaced the usage of ToolBarButton.Pressed property to
+ ToolBarButton.pressed internal variable.
+
+2004-10-14 05:10 ravindra
+
+ * ToolBarButton.cs:
+ - Added an internal member 'inside' to handle mouse move
+ with mouse pressed ie mouse drag event.
+ - Changed 'Pressed' property to return true only when
+ 'inside' and 'pressed' are both true.
+ - Some coding style love.
+
+2004-10-14 00:17 ravindra
+
+ * Form.cs: Fixed class signature. ShowDialog (Control) is not a
+ public method.
+
+2004-10-14 00:15 ravindra
+
+ * ButtonBase.cs: Redraw () related improvements.
+
+2004-10-14 00:14 ravindra
+
+ * MessageBox.cs: Moved InitFormSize () out of Paint method and
+ removed unnecessary calls to Button.Show () method.
+
+2004-10-13 17:50 pbartok
+
+ * XplatUIX11.cs:
+ - Formatting fix
+ - Removed destroying of window until we solve the problem of X
+ destroying the window before us on shutdown
+
+2004-10-13 16:32 pbartok
+
+ * ButtonBase.cs:
+ - Now Redraws on MouseUp for FlatStyle Flat and Popup
+
+2004-10-13 14:18 pbartok
+
+ * XplatUIX11.cs:
+ - Added code to destroy the X window
+
+2004-10-13 14:18 pbartok
+
+ * XplatUIWin32.cs:
+ - Added code to destroy a window
+
+2004-10-13 14:12 pbartok
+
+ * ButtonBase.cs:
+ - Added the Redraw on Resize that got dropped in the last rev
+
+2004-10-13 09:06 pbartok
+
+ * ThemeWin32Classic.cs:
+ - Path from John BouAntoun:
+ * Fix check rendering (centre correctly for normal style, offset
+ correctly for FlatStyle).
+ * Fix border color usage (use backcolor) for FlatStyle.Popup
+ * Use checkbox.Capture instead of checkbox.is_pressed when
+ rendering flatstyle states.
+
+2004-10-12 21:48 pbartok
+
+ * ThemeWin32Classic.cs:
+ - Removed all occurences of SystemColors and replaced them with the
+ matching theme color
+
+2004-10-12 21:41 pbartok
+
+ * ThemeWin32Classic.cs:
+ - From John BouAntoun: Added an overload to CPDrawBorder3D to allow
+ him using the function for flatstyle drawing
+ - Changed functions to use the new version of CPDrawBorder3D
+
+2004-10-12 21:15 pbartok
+
+ * ControlPaint.cs:
+ - Fixed Dark(), DarkDark(), Light() and LightLight() methods to
+ match MS documentation. They need to return defined colors if the
+ passed color matches the configured control color. Thanks to John
+ BouAntoun for pointing this out.
+
+2004-10-12 20:57 pbartok
+
+ * Control.cs:
+ - Fix from John BouAntoun: Raise ForeColorChanged event when text
+ color is changed
+
+2004-10-12 20:46 pbartok
+
+ * CheckBox.cs:
+ - Fix from John BouAntoun: Now properly sets the Appearance property
+
+2004-10-12 20:45 pbartok
+
+ * ThemeWin32Classic.cs:
+ - Fixes from John BouAntoun: now handles forecolors and backcolors
+ for flatstyle rendered controls much better; It also fixes normal
+ checkbox rendering when pushed or disabled.
+
+2004-10-08 02:50 jordi
+
+ * Form.cs, MainMenu.cs, Menu.cs, MenuAPI.cs, MenuItem.cs: more menu
+ work
+
+2004-10-07 08:56 jordi
+
+ * ThemeWin32Classic.cs: Removes deletion of cached brushes
+
+2004-10-06 03:59 jordi
+
+ * Control.cs, StatusBar.cs, ThemeWin32Classic.cs, ToolBar.cs,
+ XplatUIWin32.cs: removes warnings from compilation
+
+2004-10-05 12:23 jackson
+
+ * RadioButton.cs: Fix ctor
+
+2004-10-05 11:10 pbartok
+
+ * MessageBox.cs:
+ - Partial implementation by Benjamin Dasnois
+
+2004-10-05 10:15 jackson
+
+ * ThemeWin32Classic.cs: Improve rendering of the radio button patch
+ by John BouAntoun
+
+2004-10-05 03:07 ravindra
+
+ * ToolBar.cs:
+ - Removed a private method, Draw ().
+ - Fixed the ButtonDropDown event handling.
+ - Fixed MouseMove event handling.
+
+2004-10-05 03:04 ravindra
+
+ * ThemeWin32Classic.cs:
+ - Added DrawListView method and ListViewDefaultSize property.
+ - Changed ControlPaint method calls to CPDrawXXX wherever possible.
+ - Changed DOS style CRLF to Unix format (dos2unix).
+
+2004-10-05 03:03 ravindra
+
+ * Theme.cs:
+ - Added DrawListView method and ListViewDefaultSize property.
+
+2004-10-05 02:42 ravindra
+
+ * ToolBarButton.cs: Added an internal member dd_pressed to handle
+ clicks on DropDown arrow.
+
+2004-10-04 22:56 jackson
+
+ * ButtonBase.cs, Label.cs, MenuAPI.cs, ProgressBar.cs,
+ ScrollBar.cs, StatusBar.cs, ToolBar.cs, TrackBar.cs: Let the base
+ Control handle the buffers, derived classes should not have to
+ CreateBuffers themselves.
+
+2004-10-04 21:20 jackson
+
+ * StatusBar.cs: The control handles resizing the buffers now.
+
+2004-10-04 21:18 jackson
+
+ * Control.cs: When resizing the buffers should be invalidated. This
+ should be handled in Control not in derived classes.
+
+2004-10-04 14:45 jackson
+
+ * TabPage.cs: oops
+
+2004-10-04 02:14 pbartok
+
+ * LeftRightAlignment.cs:
+ - Initial check-in
+
+2004-10-04 01:09 jordi
+
+ * ThemeWin32Classic.cs: fixes right button position causing right
+ button not showing on horizontal scrollbars
+
+2004-10-02 13:12 pbartok
+
+ * XplatUIX11.cs:
+ - Simplified the Invalidate method by using an X call instead of
+ generating the expose ourselves
+ - Added an expose when the window background is changed
+ - Implemented ClientToScreen method
+
+2004-10-02 13:08 pbartok
+
+ * XplatUIWin32.cs:
+ - Added Win32EnableWindow method (test for implementing modal
+ dialogs)
+ - Added ClientToScreen method and imports
+
+2004-10-02 13:07 pbartok
+
+ * XplatUI.cs, XplatUIDriver.cs:
+ - Added ClientToScreen coordinate translation method
+
+2004-10-02 13:06 pbartok
+
+ * KeyPressEventArgs.cs:
+ - Fixed access level for constructor
+
+2004-10-02 13:06 pbartok
+
+ * NativeWindow.cs:
+ - Changed access level for the window_collection hash table
+
+2004-10-02 13:05 pbartok
+
+ * Form.cs:
+ - Added KeyPreview property
+ - Added Menu property (still incomplete, pending Jordi's menu work)
+ - Implemented ProcessCmdKey
+ - Implemented ProcessDialogKey
+ - Implemented ProcessKeyPreview
+
+2004-10-02 13:02 pbartok
+
+ * Control.cs:
+ - Added private method to get the Control object from the window
+ handle
+ - Implemented ContextMenu property
+ - Implemented PointToScreen
+ - Implemented PreProcessMessage
+ - Implemented IsInputChar
+ - Implemented IsInputKey
+ - Implemented ProcessCmdKey
+ - Completed ProcessKeyEventArgs
+ - Fixed message loop to call the proper chain of functions on key
+ events
+ - Implemented ProcessDialogChar
+ - Implemented ProcessDialogKey
+ - Implemented ProcessKeyMessage
+ - Implemented ProcessKeyPreview
+ - Added RaiseDragEvent stub (MS internal method)
+ - Added RaiseKeyEvent stub (MS internal method)
+ - Added RaiseMouseEvent stub (MS Internal method)
+ - Added RaisePaintEvent stub (MS Internal method)
+ - Added ResetMouseEventArgs stub (MS Internal method)
+ - Implemented RtlTranslateAlignment
+ - Implemented RtlTranslateContent
+ - Implemented RtlTranslateHorizontal
+ - Implemented RtlTranslateLeftRight
+ - Added generation of KeyPress event
+
+2004-10-02 05:57 ravindra
+
+ * ListViewItem.cs: Added attributes.
+
+2004-10-02 05:32 ravindra
+
+ * ListView.cs: Added attributes.
+
+2004-10-01 11:53 jackson
+
+ * Form.cs: Implement the Close method so work on MessageBox can
+ continue.
+
+2004-09-30 14:06 pbartok
+
+ * XplatUIX11.cs:
+ - Bug fixes
+
+2004-09-30 11:34 jackson
+
+ * RadioButton.cs: Fix typo. Patch by John BouAntoun.
+
+2004-09-30 07:26 ravindra
+
+ * ListViewItemConverter.cs: Converter for ListViewItem.
+
+2004-09-30 07:26 ravindra
+
+ * SortOrder.cs: Enum for ListView control.
+
+2004-09-30 07:25 ravindra
+
+ * ColumnHeader.cs: Supporting class for ListView control.
+
+2004-09-30 07:24 ravindra
+
+ * ListView.cs, ListViewItem.cs: Initial implementation.
+
+2004-09-30 07:20 ravindra
+
+ * ItemActivation.cs: Enum for ListView Control.
+
+2004-09-29 20:29 pbartok
+
+ * XplatUIX11.cs:
+ - Added lookup of pixel value for background color; tries to get a
+ color 'close' to the requested color, it avoids having to create a
+ colormap. Depending on the display this could mean the used color
+ is slightly off the desired color. Might have to change it to a more
+ resource intensive colormap approach, but it will work as a
+ workaround to avoid red screens.
+
+2004-09-29 14:27 jackson
+
+ * XplatUIX11.cs: Set the X DisplayHandle in System.Drawing
+
+2004-09-28 12:44 pbartok
+
+ * ButtonBase.cs, CheckBox.cs, ControlPaint.cs, GroupBox.cs,
+ HScrollBar.cs, Label.cs, LinkLabel.cs, Panel.cs, PictureBox.cs,
+ ProgressBar.cs, RadioButton.cs, ScrollBar.cs, StatusBar.cs,
+ Theme.cs, ThemeGtk.cs, ThemeWin32Classic.cs, ToolBar.cs,
+ TrackBar.cs, VScrollBar.cs:
+ - Streamlined Theme interfaces:
+ * Each DrawXXX method for a control now is passed the object for
+ the control to be drawn in order to allow accessing any state the
+ theme might require
+
+ * ControlPaint methods for the theme now have a CP prefix to avoid
+ name clashes with the Draw methods for controls
+
+ * Every control now retrieves it's DefaultSize from the current
+ theme
+
+2004-09-28 12:17 jackson
+
+ * Button.cs: Do not redraw OnClick MouseUp/Down will handle the
+ drawing
+
+2004-09-24 14:57 jackson
+
+ * XplatUIX11.cs: Don't lock/enqueue/dequeue for unhandled messages.
+ Gives us a nice little performance boost.
+
+2004-09-24 12:02 jackson
+
+ * TabAlignment.cs, TabAppearance.cs, TabControl.cs, TabDrawMode.cs,
+ TabPage.cs, TabSizeMode.cs: Partial implementation of the Tab
+ Control and supporting classes. Initial checkin
+
+2004-09-23 13:08 jackson
+
+ * Form.cs: Temp build fixage
+
+2004-09-23 01:39 ravindra
+
+ * ItemChangedEventArgs.cs, ItemChangedEventHandler.cs,
+ ItemCheckEventArgs.cs, ItemCheckEventHandler.cs,
+ ItemDragEventArgs.cs, ItemDragEventHandler.cs,
+ LabelEditEventArgs.cs, LabelEditEventHandler.cs: EventArgs and
+ EventHandlers needed by ListView Control.
+
+2004-09-22 14:12 pbartok
+
+ * ScrollableControl.cs:
+ - Implemented DockPadding property
+ - Implemented AutoScroll property
+ - Implemented AutoScrollMargin property
+ - Implemented AutoScrollMinSize property
+ - Implemented AutoScrollPosition property
+ - Implemented DisplayRectangle property (still incomplete)
+ - Implemented CreateParams property
+ - Implemented HScroll property
+ - Implemented VScroll property
+ - Implemented OnVisibleChanged property
+
+2004-09-22 14:09 pbartok
+
+ * Form.cs:
+ - Added Form.ControllCollection class
+ - Added handling for Form owners: Owner, OwnedForms, AddOwnedForm,
+ RemoveOwnedForm (still incomplete, missing on-top and common
+ minimize/maximize behaviour)
+ - Added StartPosition property (still incomplete, does not use when
+ creating the form)
+ - Added ShowDialog() methods (still incomplete, missing forcing the
+ dialog modal)
+
+2004-09-22 14:05 pbartok
+
+ * Application.cs:
+ - Added message loop for modal dialogs
+
+2004-09-22 14:02 pbartok
+
+ * GroupBox.cs:
+ - Fixed wrong types for events
+
+2004-09-22 14:00 pbartok
+
+ * Shortcut.cs, FormWindowState.cs:
+ - Fixed wrong values
+
+2004-09-22 12:01 jackson
+
+ * Control.cs: Text is never null
+
+2004-09-20 22:14 pbartok
+
+ * XplatUIWin32.cs:
+ - Fixed accessibility level for Idle handler
+
+2004-09-20 18:54 jackson
+
+ * Application.cs, XplatUI.cs, XplatUIDriver.cs, XplatUIWin32.cs,
+ XplatUIX11.cs: New message loop that uses poll so we don't get a
+ busy loop
+
+2004-09-17 10:43 pbartok
+
+ * ScrollBar.cs:
+ - Fixed behaviour of arrow buttons. Now properly behaves like
+ Buttons (and like Microsoft's scrollbar arrow buttons)
+
+2004-09-17 10:14 pbartok
+
+ * ScrollBar.cs:
+ - Added missing release of keyboard/mouse capture
+
+2004-09-17 06:18 jordi
+
+ * ContextMenu.cs, MainMenu.cs, Menu.cs, MenuAPI.cs, MenuItem.cs,
+ Theme.cs: Very early menu support
+
+2004-09-16 17:45 pbartok
+
+ * XplatUIWin32.cs:
+ - Fixed sending a window to the front
+ - Added overload for SetWindowPos to avoid casting
+
+2004-09-16 17:44 pbartok
+
+ * Control.cs:
+ - Added SendToBack and BringToFront methods
+
+2004-09-16 07:00 ravindra
+
+ * Copyright: Added Novell URL.
+
+2004-09-16 07:00 ravindra
+
+ * ToolBar.cs: Invalidate should be done before redrawing.
+
+2004-09-15 21:19 ravindra
+
+ * ColumnHeaderStyle.cs: Enum for ListView Control.
+
+2004-09-15 21:18 ravindra
+
+ * ColumnClickEventArgs.cs, ColumnClickEventHandler.cs: Event for
+ ListView Control.
+
+2004-09-13 18:26 jackson
+
+ * Timer.cs, XplatUIX11.cs: Remove test code so timers are updated
+ properly
+
+2004-09-13 18:13 jackson
+
+ * Timer.cs, X11Structs.cs, XplatUIX11.cs: Timers are now handled in
+ a second thread and post messages into the main threads message
+ queue. This makes timing much more consistent. Both win2K and XP
+ have a minimum timer value of 15 milliseconds, so we now do this
+ too.
+
+2004-09-13 15:18 pbartok
+
+ * X11Structs.cs, XplatUI.cs, XplatUIDriver.cs, XplatUIWin32.cs,
+ XplatUIX11.cs:
+ - Added Z-Ordering methods
+
+2004-09-13 10:56 pbartok
+
+ * Form.cs:
+ - Fixed #region names
+ - Moved properties and methods into their proper #regions
+
+2004-09-13 10:51 pbartok
+
+ * Form.cs:
+ - Added Accept and CancelButton properties
+ - Added ProcessDialogKey() method
+
+2004-09-13 08:18 pbartok
+
+ * IWindowTarget.cs:
+ - Initial check-in
+
+2004-09-10 21:50 pbartok
+
+ * Control.cs:
+ - Added DoDragDrop() [incomplete]
+ - Properly implemented 'Visible' handling
+ - Added SetVisibleCore()
+ - Implemented FindChildAtPoint()
+ - Implemented GetContainerControl()
+ - Implemented Hide()
+
+2004-09-10 19:28 pbartok
+
+ * Control.cs:
+ - Moved methods into their appropriate #regions
+ - Reordered methods within regions alphabetically
+
+2004-09-10 18:57 pbartok
+
+ * XplatUIX11.cs, XplatUI.cs, XplatUIDriver.cs, XplatUIWin32.cs:
+ - Added method to retrieve text from window
+
+2004-09-10 18:56 pbartok
+
+ * Control.cs:
+ - Moved some internal functions into the internal region
+ - Implemented FontHeight
+ - Implemented RenderRightToLeft
+ - Implemented ResizeRedraw
+ - Implemented ShowFocusCues
+ - Implemented ShowKeyboardCues
+ - Implemented FromChildHandle
+ - Implemented FromHandle
+ - Implemented IsMnemonic
+ - Implemented ReflectMessage
+ - All public and protected Static Methods are now complete
+
+2004-09-10 16:54 pbartok
+
+ * Control.cs:
+ - Implemented remaining missing public instance properties
+ - Alphabetized some out of order properties
+
+2004-09-10 05:51 ravindra
+
+ * PictureBox.cs: Added a check for null image.
+
+2004-09-10 00:59 jordi
+
+ * GroupBox.cs: remove cvs tag
+
+2004-09-09 05:25 ravindra
+
+ * ToolBar.cs: Make redraw accessible from ToolBarButton.
+
+2004-09-09 05:23 ravindra
+
+ * ToolBarButton.cs: Changes in ToolBarButton need to make it's
+ parent redraw.
+
+2004-09-09 02:28 pbartok
+
+ * ThemeWin32Classic.cs:
+ - Improve disabled string look
+
+2004-09-09 01:15 jordi
+
+ * MeasureItemEventArgs.cs, MeasureItemEventHandler.cs: measureitem
+ args and handler
+
+2004-09-08 23:56 ravindra
+
+ * ItemBoundsPortion.cs: It's enum, not a class!
+
+2004-09-08 23:47 ravindra
+
+ * FormBorderStyle.cs, FormStartPosition.cs, FormWindowState.cs:
+ Enums for Form.
+
+2004-09-08 21:13 ravindra
+
+ * ItemBoundsPortion.cs, ListViewAlignment.cs, View.cs: Enums for
+ ListView control.
+
+2004-09-08 21:03 ravindra
+
+ * ThemeWin32Classic.cs: PictureBox would not draw a null image to
+ avoid crash.
+
+2004-09-08 21:01 ravindra
+
+ * ScrollableControl.cs: Removed unreachable code.
+
+2004-09-08 06:45 jordi
+
+ * MenuMerge.cs, Shortcut.cs: enumerations need it by menus
+
+2004-09-08 01:00 jackson
+
+ * XplatUIX11.cs: Only run the timers when updating the message
+ queue. This effectively gives X messages a higher priority then
+ timer messages. Timers still need love though
+
+2004-09-07 14:01 jackson
+
+ * XplatUIX11.cs: Do not call XDestroyWindow, X has already done
+ this for us and the handle is no longer valid.
+
+2004-09-07 13:59 jackson
+
+ * HandleData.cs, XplatUIX11.cs: First steps towards a new X event
+ loop that manages to not crash. TODO: Add poll and cleanup timers
+
+2004-09-07 11:12 jordi
+
+ * GroupBox.cs, Theme.cs, ThemeWin32Classic.cs: GroupBox control
+
+2004-09-07 03:40 jordi
+
+ * Label.cs, LinkLabel.cs, Theme.cs, ThemeWin32Classic.cs: LinkLabel
+ fixes, methods, multiple links
+
+2004-09-06 06:55 jordi
+
+ * Control.cs: Caches ClientRectangle rectangle value
+
+2004-09-05 02:03 jordi
+
+ * ScrollBar.cs, ThemeWin32Classic.cs: fixes bugs, adds flashing on
+ certain situations
+
+2004-09-04 11:10 jordi
+
+ * Label.cs: Refresh when font changed
+
+2004-09-02 16:24 pbartok
+
+ * Control.cs:
+ - Added sanity check to creation of double buffer bitmap
+
+2004-09-02 16:24 pbartok
+
+ * ButtonBase.cs:
+ - Fixed selection of text color
+ - Fixed handling of resize event; now properly recreates double
+ buffering bitmap
+ - Added missing assignment of TextAlignment
+ - Added proper default for TextAlignment
+
+2004-09-02 14:26 pbartok
+
+ * RadioButton.cs:
+ - Added missing RadioButton.RadioButtonAccessibleObject class
+
+2004-09-02 14:26 pbartok
+
+ * Control.cs:
+ - Added missing Control.ControlAccessibleObject class
+ - Started to implement Select()ion mechanisms, still very incomplete
+
+2004-09-02 14:25 pbartok
+
+ * AccessibleObject.cs:
+ - Added missing methods
+
+2004-09-02 14:23 pbartok
+
+ * AccessibleNavigation.cs, AccessibleSelection.cs:
+ - Initial check-in
+
+2004-09-02 10:32 jordi
+
+ * Theme.cs, ThemeGtk.cs, ThemeWin32Classic.cs: implements resource
+ pool for pens, brushes, and hatchbruses
+
+2004-09-01 15:30 jackson
+
+ * StatusBar.cs: Fix typo
+
+2004-09-01 14:44 pbartok
+
+ * RadioButton.cs:
+ - Fixed state
+
+2004-09-01 14:39 pbartok
+
+ * Button.cs, RadioButton.cs:
+ - Functional initial check-in
+
+2004-09-01 14:01 pbartok
+
+ * CheckBox.cs:
+ - Added missing default
+ - Added missing region mark
+
+2004-09-01 09:10 jordi
+
+ * Label.cs: fixes method signatures, new methods, events, fixes
+ autosize
+
+2004-09-01 07:19 jordi
+
+ * Control.cs: Init string variables with an empty object
+
+2004-09-01 04:20 jordi
+
+ * Control.cs: fires OnFontChanged event
+
+2004-08-31 20:07 pbartok
+
+ * ButtonBase.cs:
+ - Enabled display of strings
+
+2004-08-31 20:05 pbartok
+
+ * Form.cs:
+ - Added (partial) implementation of DialogResult; rest needs to be
+ implemented when the modal loop code is done
+
+2004-08-31 19:55 pbartok
+
+ * CheckBox.cs:
+ - Fixed to match the removal of the needs_redraw concept
+
+2004-08-31 19:55 pbartok
+
+ * ButtonBase.cs:
+ - Removed the rather odd split between 'needs redraw' and redrawing
+ - Now handles the events that require regeneration (ambient
+ properties and size)
+
+2004-08-31 19:41 pbartok
+
+ * Control.cs:
+ - Added firing of BackColorChanged event
+ - Added TopLevelControl property
+ - Fixed handling of WM_ERASEBKGRND message
+
+2004-08-31 12:49 pbartok
+
+ * ButtonBase.cs:
+ - Removed debug
+ - Minor fixes
+
+2004-08-31 12:48 pbartok
+
+ * CheckBox.cs:
+ - Finished (famous last words)
+
+2004-08-31 04:35 jordi
+
+ * ScrollBar.cs: adds autorepeat timer, uses a single timer, fixes
+ scrolling bugs, adds new methods
+
+2004-08-30 14:42 pbartok
+
+ * CheckBox.cs:
+ - Implemented CheckBox drawing code
+
+2004-08-30 14:42 pbartok
+
+ * ButtonBase.cs:
+ - Made Redraw() and CheckRedraw() virtual
+ - Improved mouse up/down/move logic to properly track buttons
+
+2004-08-30 09:44 pbartok
+
+ * CheckBox.cs:
+ - Updated to fix broken build. Not complete yet.
+
+2004-08-30 09:28 pbartok
+
+ * CheckState.cs:
+ - Initial checkin
+
+2004-08-30 09:17 pbartok
+
+ * Appearance.cs:
+ - Initial check-in
+
+2004-08-27 16:12 ravindra
+
+ * ToolBarButton.cs: Added TypeConverter attribute.
+
+2004-08-27 16:07 ravindra
+
+ * ImageIndexConverter.cs: Implemented.
+
+2004-08-27 14:17 pbartok
+
+ * Control.cs:
+ - Removed unneeded stack vars
+ - First attempt to fix sizing issues when layout is suspended
+
+2004-08-25 15:35 jordi
+
+ * ScrollBar.cs: more fixes to scrollbar
+
+2004-08-25 14:04 ravindra
+
+ * Theme.cs, ThemeWin32Classic.cs, ToolBar.cs, ToolBarButton.cs:
+ Added the missing divider code and grip for ToolBar Control.
+
+2004-08-25 13:20 pbartok
+
+ * Control.cs:
+ - Control now properly passes the ambient background color to child
+ controls
+
+2004-08-25 13:20 jordi
+
+ * ScrollBar.cs: small bug fix regarding bar position
+
+2004-08-25 12:33 pbartok
+
+ * Timer.cs:
+ - Now only calls SetTimer or KillTimer if the enabled state has
+ changed
+
+2004-08-25 12:33 pbartok
+
+ * XplatUIWin32.cs:
+ - Fixed timer handling, now seems to work
+ - Improved error message for window creation
+
+2004-08-25 12:32 pbartok
+
+ * Control.cs:
+ - Fixed generation of MouseUp message
+
+2004-08-25 12:29 jordi
+
+ * ProgressBar.cs, ThemeWin32Classic.cs: new methods, properties,
+ and fixes for progressbar
+
+2004-08-24 18:43 ravindra
+
+ * ThemeWin32Classic.cs, ToolBar.cs: Fixed wrapping related issues
+ in ToolBar control.
+
+2004-08-24 17:15 pbartok
+
+ * Panel.cs:
+ - Added #region
+ - Added missing events
+ - Alphabetized
+
+2004-08-24 17:14 pbartok
+
+ * StatusBar.cs, PictureBox.cs:
+ - Now uses Control's CreateParams
+
+2004-08-24 16:36 pbartok
+
+ * XplatUIX11.cs:
+ - Fixed background color handling
+ - Fixed sending of enter/leave events on a grab
+
+2004-08-24 16:35 pbartok
+
+ * X11Structs.cs:
+ - Refined definitions for CrossingEvent
+
+2004-08-24 12:37 jordi
+
+ * ScrollBar.cs, Theme.cs, ThemeGtk.cs, ThemeWin32Classic.cs: fixes
+ formmating, methods signature, and adds missing events
+
+2004-08-24 12:24 jordi
+
+ * Control.cs: fire OnEnabledChanged event
+
+2004-08-24 11:17 pbartok
+
+ * XplatUIWin32.cs:
+ - Implemented SetTimer() and KillTimer()
+
+2004-08-24 11:16 pbartok
+
+ * XplatUIX11.cs:
+ - Now uses Remove instead of Add to kill the timer
+
+2004-08-24 10:16 jackson
+
+ * PictureBox.cs, Theme.cs, ThemeWin32Classic.cs: Handle drawing
+ picture boxes in the theme now. Draw picture box borders and obey
+ sizing modes
+
+2004-08-24 05:49 jackson
+
+ * Timer.cs: Remove top secret debugging code
+
+2004-08-24 05:34 jackson
+
+ * PictureBox.cs: Temp hack to make picture boxes draw their full
+ image
+
+2004-08-24 05:29 jackson
+
+ * Timer.cs, XplatUI.cs, XplatUIDriver.cs, XplatUIWin32.cs,
+ XplatUIX11.cs: Move timers to the driver level. On X they are
+ queued by the driver and checked on idle.
+
+2004-08-24 01:07 jackson
+
+ * XplatUIX11.cs: Use a queue for async messages instead of passing
+ them as ClientMessages since that was totally broken. Also simply
+ check for events and return an idle message if none are found. This
+ gives us an idle handler, and prevents deadlocking when no messages
+ are in the queue.
+
+2004-08-23 18:19 ravindra
+
+ * XplatUIWin32.cs: Removed the unwanted destructor.
+
+2004-08-23 17:27 pbartok
+
+ * ButtonBase.cs:
+ - Finishing touches. Works now, just needs some optimizations.
+
+2004-08-23 16:53 jordi
+
+ * ScrollBar.cs: small fix
+
+2004-08-23 16:45 pbartok
+
+ * Application.cs:
+ - Removed debug output
+ - Simplifications
+
+2004-08-23 16:43 jordi
+
+ * ScrollBar.cs: [no log message]
+
+2004-08-23 16:10 pbartok
+
+ * Form.cs:
+ - Fixed handling of WM_CLOSE message
+ - Removed debug output
+
+2004-08-23 16:09 pbartok
+
+ * Application.cs:
+ - Added handling of Idle event
+ - Added handling of form closing
+ - Fixed reporting of MessageLoop property
+ - Removed some unneeded code, should provide a bit of a speedup
+
+2004-08-23 15:22 pbartok
+
+ * Control.cs:
+ - Added InitLayout() method
+ - Added code to properly perform layout when Anchor or Dock property
+ is changed
+ - Changed 'interpretation' of ResumeLayout. MS seems to have a
+ LAMESPEC, tried to do it in a way that makes sense
+
+2004-08-23 14:10 jordi
+
+ * HScrollBar.cs, ScrollBar.cs, TrackBar.cs, VScrollBar.cs: fixes
+ properties and methods
+
+2004-08-23 13:55 pbartok
+
+ * Control.cs:
+ - Properly fixed Jordi's last fix
+ - Now uses Cursor's Position property instead of calling XplatUI
+ directly
+
+2004-08-23 13:44 jordi
+
+ * PaintEventHandler.cs: Adding missing attribute
+
+2004-08-23 13:39 pbartok
+
+ * Cursor.cs:
+ - Implemented Position property
+
+2004-08-23 13:39 pbartok
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIWin32.cs:
+ - Added method to move mouse cursor
+
+2004-08-23 13:39 pbartok
+
+ * XplatUIX11.cs:
+ - Fixed setting of background color
+ - Added method to move mouse cursor
+
+2004-08-23 13:16 jordi
+
+ * Control.cs: avoids null exception
+
+2004-08-22 17:46 jackson
+
+ * PictureBox.cs, PictureBoxSizeMode.cs: Initial implementation of
+ PictureBox
+
+2004-08-22 17:40 jackson
+
+ * XplatUIX11.cs: Add some missing locks
+
+2004-08-22 15:10 pbartok
+
+ * Control.cs, Form.cs:
+ - Removed OverlappedWindow style from Control, instead it's default
+ now is child
+ - Made form windows OverlappedWindow by default
+
+2004-08-22 13:34 jackson
+
+ * ScrollBar.cs: Update the position through the Value property so
+ the OnValueChanged event is raised.
+
+2004-08-22 12:04 pbartok
+
+ * SWF.csproj:
+ - Added Cursor.cs and UserControl.cs
+
+2004-08-22 12:03 pbartok
+
+ * Cursor.cs:
+ - Started implementation, not usable yet
+
+2004-08-22 12:00 pbartok
+
+ * UserControl.cs:
+ - Implemented UserControl (complete)
+
+2004-08-21 19:20 ravindra
+
+ * ToolBar.cs: Correcting the formatting mess of VS.NET.
+
+2004-08-21 18:49 ravindra
+
+ * ToolBar.cs: Probably this completes the missing attributes in
+ toolbar control.
+
+2004-08-21 18:03 ravindra
+
+ * ToolBar.cs, ToolBarButton.cs, ToolBarButtonClickEventArgs.cs:
+ Fixed toolbar control signatures.
+
+2004-08-21 16:32 pbartok
+
+ * LinkLabel.cs:
+ - Signature Fixes
+
+2004-08-21 16:30 pbartok
+
+ * Label.cs:
+ - Signature fixes
+
+2004-08-21 16:19 pbartok
+
+ * Control.cs, Label.cs:
+ - Signature fixes
+
+2004-08-21 15:57 pbartok
+
+ * ButtonBase.cs:
+ - Added loads of debug output for development
+ - Fixed typo in method name
+
+2004-08-21 15:52 pbartok
+
+ * ToolBarButtonClickEventArgs.cs:
+ - Added missing base class
+
+2004-08-21 14:53 pbartok
+
+ * Control.cs:
+ - Updated to match new GrabWindow signature
+
+2004-08-21 14:51 pbartok
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIWin32.cs, XplatUIX11.cs:
+ - Added method to get default display size
+
+2004-08-21 14:23 pbartok
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIWin32.cs, XplatUIX11.cs:
+ - Added method to query current grab state
+ - Added argument to allow confining a grab to a window
+
+2004-08-21 14:22 pbartok
+
+ * Keys.cs:
+ - Added [Flags] attribute so that modifiers can be used in bitwise
+ ops
+
+2004-08-21 14:21 pbartok
+
+ * TrackBar.cs, ScrollBar.cs:
+ - Replaced direct XplatUI calls with their Control counterpart
+
+2004-08-21 13:32 pbartok
+
+ * Control.cs:
+ - Implemented Created property
+
+2004-08-21 13:28 pbartok
+
+ * Control.cs:
+ - Implemented ContainsFocus
+
+2004-08-21 13:26 pbartok
+
+ * Control.cs:
+ - Implemented CausesValidation
+
+2004-08-21 13:21 pbartok
+
+ * Control.cs:
+ - Implemented CanFocus
+ - Implemented CanSelect
+ - Implemented Capture
+
+2004-08-21 12:35 pbartok
+
+ * XplatUIWin32.cs:
+ - Fixed bug with Async message handling
+ - Implemented getting the ModifierKeys
+
+2004-08-21 12:32 jackson
+
+ * AsyncMethodResult.cs: Make sure we have the mutex before we
+ release it. Fixes BeginInvoke on windows
+
+2004-08-21 11:31 pbartok
+
+ * XplatUIWin32.cs, XplatUIX11.cs:
+ - Drivers now return proper mouse state
+
+2004-08-21 10:54 jackson
+
+ * Control.cs: Implement EndInvoke
+
+2004-08-21 10:48 jackson
+
+ * Timer.cs: Remove unneeded finalizer
+
+2004-08-20 19:52 ravindra
+
+ * ThemeWin32Classic.cs, ToolBar.cs, ToolBarButton.cs: Improvments
+ in mouse event handling in the ToolBar control.
+
+2004-08-20 19:50 ravindra
+
+ * ImageList.cs: Changed draw method to use the arguments passed in
+ to draw the image.
+
+2004-08-20 18:58 pbartok
+
+ * XplatUIStructs.cs:
+ - Added private message for async communication
+
+2004-08-20 17:38 ravindra
+
+ * Control.cs: Made RightToLeft property virtual and removed a
+ Console.WriteLine.
+
+2004-08-20 14:39 jordi
+
+ * ThemeGtk.cs: use style_attach
+
+2004-08-20 14:39 pbartok
+
+ * XplatUIWin32.cs:
+ - Added jackson's Async code from X11 to Win32
+
+2004-08-20 14:09 pbartok
+
+ * SWF.csproj:
+ - Added all new files
+
+2004-08-20 14:09 pbartok
+
+ * Control.cs:
+ - Added call to set window background color
+
+2004-08-20 14:03 pbartok
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIX11.cs:
+ - Added method for setting the window background
+
+2004-08-20 14:02 pbartok
+
+ * XplatUIWin32.cs:
+ - Added method for setting the background color
+ - Added handling for erasing the window background
+
+2004-08-20 13:45 jordi
+
+ * TrackBar.cs: fixes timer, new properties and methods
+
+2004-08-20 13:34 jackson
+
+ * ScrollBar.cs: Use the SWF timer so callbacks are run in the
+ correct thread
+
+2004-08-20 13:22 jackson
+
+ * Timer.cs: Timer Tick events are now handed through Controls Async
+ mechanism so the callbacks are executed in the same thread as X
+
+2004-08-20 13:19 jackson
+
+ * XplatUIDriver.cs: Expose functionality to send async messages
+ through the driver
+
+2004-08-20 13:18 jackson
+
+ * Control.cs: Implement Begininvoke
+
+2004-08-20 13:14 jackson
+
+ * XplatUI.cs, XplatUIWin32.cs: Expose functionality to send async
+ messages through the driver
+
+2004-08-20 13:12 jackson
+
+ * XplatUIX11.cs: Lock before all X operations. Also added Async
+ method functionality through XSendEvent
+
+2004-08-20 13:11 jackson
+
+ * X11Structs.cs: Use IntPtrs for ClientMessage extra data (TODO:
+ This will screw up on 64 bit systems)
+
+2004-08-20 13:10 jackson
+
+ * AsyncMethodData.cs, AsyncMethodResult.cs: Classes for sending
+ Async messages through X/Win32
+
+2004-08-19 19:39 pbartok
+
+ * XplatUIX11.cs:
+ - Updated code to match new HandleData.DeviceContext type
+
+2004-08-19 19:38 pbartok
+
+ * HandleData.cs:
+ - Made DeviceContext a generic object to allow usage from various
+ drivers
+ - Added support for queueing Windows messages
+
+2004-08-19 19:37 pbartok
+
+ * XplatUIWin32.cs:
+ - Added generation of MouseEnter, MouseLeave and MouseHover events
+ - Added cleanup on EndPaint
+
+2004-08-19 19:17 pbartok
+
+ * Control.cs:
+ - Added handling of WM_MOUSEHOVER
+ - Worked around 'bug' in Win32 WM_MOUSE_ENTER/WM_MOUSE_LEAVE driver
+ code
+
+2004-08-19 18:55 jordi
+
+ * ThemeGtk.cs: fixes button order
+
+2004-08-19 18:12 jordi
+
+ * Theme.cs, ThemeWin32Classic.cs: fixes methods signature
+
+2004-08-19 17:09 pbartok
+
+ * Control.cs:
+ - Added Right property
+ - Added RightToLeft property
+
+2004-08-19 16:27 jordi
+
+ * ThemeGtk.cs: experimental GTK theme support
+
+2004-08-19 16:26 jordi
+
+ * ITheme.cs, Theme.cs: move themes from an interface to a class
+
+2004-08-19 16:25 jordi
+
+ * Control.cs, ScrollBar.cs, ThemeEngine.cs, ThemeWin32Classic.cs:
+ theme enhancaments
+
+2004-08-19 16:04 pbartok
+
+ * XplatUIX11.cs:
+ - Added colormap basics
+ - Added a way to re-initialize with a different display handle
+ - Fixed setting of the window background color
+ - Added various X11 imports related to colors and colormaps
+
+2004-08-19 15:51 pbartok
+
+ * X11Structs.cs:
+ - Removed packing hints (Paolo suggested this a while back)
+ - fixed colormap type
+ - Added default Atom types
+ - Added Screen and color structs and enums
+
+2004-08-19 15:39 pbartok
+
+ * ImageList.cs:
+ - Added missing Draw() method
+ - Added missing RecreateHandle event
+
+2004-08-19 15:30 pbartok
+
+ * Form.cs:
+ - Added handling of WM_CLOSE
+
+2004-08-18 13:16 jordi
+
+ * ITheme.cs, ThemeWin32Classic.cs, XplatUIWin32.cs: Move colors to
+ a table
+
+2004-08-18 09:56 jordi
+
+ * ScrollBar.cs: fixes to scrollbar: steps and multiple timers
+
+2004-08-17 15:31 ravindra
+
+ * SWF.csproj: Updated project.
+
+2004-08-17 15:25 pbartok
+
+ * Control.cs:
+ - Drawing improvement; don't call UpdateBounds if we are not visible
+ (or have been minimized)
+
+2004-08-17 15:24 pbartok
+
+ * XplatUIWin32.cs:
+ - Finished IsVisible
+ - Added Win32GetWindowPlacement
+
+2004-08-17 15:08 jackson
+
+ * Panel.cs: Initial checkin of the Panel
+
+2004-08-17 14:25 pbartok
+
+ * Control.cs:
+ - Fixed broken handling of default window sizes
+
+2004-08-17 13:29 jackson
+
+ * ThemeWin32Classic.cs: Don't use KnownColor to create colours. It
+ has a large startup time.
+
+2004-08-17 10:25 jackson
+
+ * HandleData.cs: union areas properly
+
+2004-08-17 10:12 jackson
+
+ * HandleData.cs: union areas properly
+
+2004-08-16 20:00 ravindra
+
+ * ToolBar.cs, ToolBarButton.cs: Added attributes.
+
+2004-08-16 18:48 ravindra
+
+ * ToolBar.cs: Added attributes.
+
+2004-08-16 17:17 ravindra
+
+ * SWF.csproj: Updated project.
+
+2004-08-16 17:16 jackson
+
+ * XplatUIX11.cs: Check for more expose events before sending a
+ WM_PAINT so they can all be grouped together. This makes dragging a
+ window across another window redraw in a sane way.
+
+2004-08-16 15:47 pbartok
+
+ * Control.cs:
+ - Added handling of WM_MOUSE_ENTER & WM_MOUSE_LEAVE to
+ support OnMouseEnter/Leave()
+ - Added WS_CLIPSIBLINGS and WS_CLIPCHILDREN window styles to improve
+ exposure handling
+
+2004-08-16 15:46 pbartok
+
+ * XplatUIStructs.cs, XplatUIX11.cs:
+ - Added WM_MOUSE_ENTER & WM_MOUSE_LEAVE to support
+ OnMouseEnter/Leave()
+
+2004-08-16 15:34 jackson
+
+ * XplatUIX11.cs: Group multiple expose events in HandleData, make
+ sure messages get the message field set to WM_NULL if they are not
+ handled.
+
+2004-08-16 15:24 jackson
+
+ * HandleData.cs: HandleData is used for storing message information
+ for window handles
+
+2004-08-15 17:23 ravindra
+
+ * ColorDepth.cs: Added attribute.
+
+2004-08-15 17:23 ravindra
+
+ * SWF.csproj: Updated project for ToolBar Control.
+
+2004-08-15 17:20 ravindra
+
+ * ITheme.cs, ThemeWin32Classic.cs: Changes to Theme for ToolBar
+ control and also dos2unix format.
+
+2004-08-15 17:13 ravindra
+
+ * ToolBar.cs, ToolBarAppearance.cs, ToolBarButton.cs,
+ ToolBarButtonClickEventArgs.cs,
+ ToolBarButtonClickEventHandler.cs, ToolBarButtonStyle.cs,
+ ToolBarTextAlign.cs: First Implementation of ToolBar control.
+
+2004-08-15 15:31 pbartok
+
+ * ButtonBase.cs:
+ - First (mostly) working version
+
+2004-08-13 16:15 pbartok
+
+ * Control.cs:
+ - Fixed Anchor default
+
+2004-08-13 15:43 pbartok
+
+ * Control.cs:
+ - Changed GetCursorPos signature
+
+2004-08-13 15:42 pbartok
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIWin32.cs:
+ - Changed signature for GetCursorPos
+
+2004-08-13 15:25 pbartok
+
+ * XplatUIX11.cs:
+ - Cleanup
+ - Fixed resizing/exposure handling
+
+2004-08-13 15:22 jordi
+
+ * ThemeWin32Classic.cs: removes redundant code and fixes issues
+ with tickposition
+
+2004-08-13 14:55 jordi
+
+ * TrackBar.cs: change from wndproc to events
+
+2004-08-13 13:00 jordi
+
+ * Control.cs, XplatUI.cs, XplatUIDriver.cs, XplatUIWin32.cs,
+ XplatUIX11.cs: implements PointToClient (ScreenToClient)
+
+2004-08-13 12:53 pbartok
+
+ * XplatUIWin32.cs:
+ - Changed GetWindowPos to also provide client area size
+ - Fixed broken prototypes for several win32 functions
+
+2004-08-13 12:53 pbartok
+
+ * XplatUI.cs, XplatUIDriver.cs:
+ - Changed GetWindowPos to also provide client area size
+
+2004-08-13 12:52 pbartok
+
+ * XplatUIX11.cs:
+ - Added generation of WM_POSCHANGED
+ - Changed GetWindowPos to also provide client area size
+
+2004-08-13 12:52 pbartok
+
+ * Control.cs:
+ - Added Dispose() and destructor
+ - Fixed resizing and bounds calculation
+ - Fixed Layout
+ - Added memory savings for invisible windows
+
+2004-08-13 12:46 jordi
+
+ * TrackBar.cs: adds timer and grap window
+
+2004-08-13 10:25 jackson
+
+ * Timer.cs: SWF Timer
+
+2004-08-12 16:59 pbartok
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIWin32.cs, XplatUIX11.cs:
+ - Implemented method to get current mouse position
+
+2004-08-12 14:29 jordi
+
+ * ITheme.cs, ThemeWin32Classic.cs, TrackBar.cs: Trackbar
+ enhancement, fix mouse problems, highli thumb, etc
+
+2004-08-12 13:31 pbartok
+
+ * Control.cs:
+ - Fixed Anchoring bugs
+
+2004-08-12 13:01 jackson
+
+ * StatusBar.cs: Don't forget things
+
+2004-08-12 12:54 jackson
+
+ * ThemeWin32Classic.cs: Handle owner draw status bars
+
+2004-08-12 12:54 jackson
+
+ * StatusBar.cs: Implement missing properties, events, and methods.
+ Handle mouse clicking
+
+2004-08-12 10:19 jackson
+
+ * StatusBarPanelClickEventArgs.cs,
+ StatusBarPanelClickEventHandler.cs: Classes for handling status
+ bar panel click events
+
+2004-08-12 10:10 jackson
+
+ * Control.cs: Add missing properties
+
+2004-08-12 09:46 pbartok
+
+ * BindingsManagerBase.cs:
+ - Name changed to BindingManagerBase.cs
+
+2004-08-12 09:25 jordi
+
+ * ScrollableControl.cs: calls ctrlbase instead of exeception
+
+2004-08-11 16:28 pbartok
+
+ * InputLanguageChangingEventArgs.cs:
+ - Never check in before compiling. Fixes the last check-in
+
+2004-08-11 16:26 pbartok
+
+ * InputLanguageChangingEventArgs.cs:
+ - More signature fixes
+
+2004-08-11 16:20 pbartok
+
+ * BindingManagerBase.cs, BindingMemberInfo.cs, ContainerControl.cs,
+ Control.cs, ControlEventArgs.cs, ControlPaint.cs, Form.cs,
+ ImageListStreamer.cs, InputLanguage.cs,
+ InputLanguageChangedEventArgs.cs,
+ InputLanguageChangingEventArgs.cs, Keys.cs, LayoutEventArgs.cs,
+ LinkArea.cs, Message.cs, MouseEventArgs.cs, NativeWindow.cs,
+ ScrollEventArgs.cs, ScrollableControl.cs, XplatUI.cs,
+ XplatUIDriver.cs, XplatUIWin32.cs, XplatUIX11.cs:
+ - Signature fixes
+
+2004-08-11 16:16 pbartok
+
+ * Application.cs:
+ - Fixed Signature
+ - Added .Net 1.1 method
+
+2004-08-11 15:25 pbartok
+
+ * SWF.csproj:
+ - Fixed BindingManagerBase.cs filename
+
+2004-08-11 15:22 pbartok
+
+ * BindingManagerBase.cs:
+ - Was checked in with wrong filename
+
+2004-08-11 14:50 pbartok
+
+ * SWF.csproj:
+ - Updated
+
+2004-08-11 13:41 jordi
+
+ * XplatUIWin32.cs: Fixes ClientRect
+
+2004-08-11 13:19 pbartok
+
+ * Control.cs, XplatUI.cs, XplatUIDriver.cs, XplatUIWin32.cs,
+ XplatUIX11.cs:
+ - We had SetWindowPos and MoveWindow to set window positions and
+ size, removed MoveWindow. We have GetWindowPos, so it made sense to
+ keep SetWindowPos as matching counterpart
+ - Added some X11 sanity checking
+
+2004-08-11 12:59 pbartok
+
+ * Control.cs:
+ - Major cleanup of my SetBounds/SetBoundsCore/UpdateBounds mess
+ (It seems that SetBounds is just a front for SetBoundsCore and
+ SetBoundsCore updates the underlying window system and
+ UpdateBounds is responsible for updating the variables associated
+ with the Control and sending the events)
+ - Major cleanup of Size handling; we now have two sizes, client_size
+ and bounds. Bounds defines the window with decorations, client_size
+ without them.
+
+2004-08-11 12:55 pbartok
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIWin32.cs, XplatUIX11.cs:
+ - Added method to calculate difference between decorated window and
+ raw client area
+
+2004-08-11 12:54 pbartok
+
+ * Label.cs:
+ - Forcing redraw on resize
+
+2004-08-11 11:43 pbartok
+
+ * ImageList.cs:
+ - Removed disposing of the actual images when the list is disposed
+
+2004-08-11 09:13 pbartok
+
+ * Control.cs:
+ - Now properly reparents windows
+
+2004-08-11 08:37 pbartok
+
+ * Control.cs:
+ - Duh!
+
+2004-08-11 07:47 pbartok
+
+ * Control.cs:
+ - Rewrote the collection stuff. Might not be as fast now, not
+ keeping the number of children around and accessible directly, but
+ it's more straightforward
+
+2004-08-11 07:44 pbartok
+
+ * AccessibleObject.cs:
+ - Fixed to match ControlCollection rewrite
+
+2004-08-11 07:43 pbartok
+
+ * ImageList.cs:
+ - Added missing creation of the collection list
+
+2004-08-10 20:08 jackson
+
+ * StatusBar.cs: Get the paint message from WndProc
+
+2004-08-10 19:31 jackson
+
+ * ThemeWin32Classic.cs: Create Brushes as little as possible
+
+2004-08-10 19:20 jackson
+
+ * UICues.cs: Add Flags attribute
+
+2004-08-10 19:19 jackson
+
+ * StatusBarPanel.cs: Signature cleanup
+
+2004-08-10 19:10 jackson
+
+ * StatusBarDrawItemEventArgs.cs, StatusBarDrawItemEventHandler.cs:
+ Initial implementation of status bar item drawing
+
+2004-08-10 17:27 jordi
+
+ * TrackBar.cs: add missing methods, properties, and restructure to
+ hide extra ones
+
+2004-08-10 16:24 jackson
+
+ * AccessibleStates.cs, Border3DSide.cs, Border3DStyle.cs,
+ ButtonState.cs, ControlStyles.cs, DragDropEffects.cs: Add flags
+ attribute
+
+2004-08-10 13:21 jordi
+
+ * ITheme.cs, ScrollBar.cs, ThemeWin32Classic.cs: scrollbar
+ enhancements and standarize on win colors defaults
+
+2004-08-10 12:52 jackson
+
+ * DrawItemEventArgs.cs, DrawItemState.cs, ITheme.cs,
+ ThemeWin32Classic.cs: Implement DrawItem functionality
+
+2004-08-10 12:47 jordi
+
+ * XplatUIWin32.cs: Calls InvalidateRect before UpdateWindow
+
+2004-08-10 12:32 jordi
+
+ * Control.cs: throw ontextchange event
+
+2004-08-10 11:43 pbartok
+
+ * Control.cs:
+ - Added more to the still unfinished Dock/Anchor layout code
+
+2004-08-10 11:39 pbartok
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIX11.cs:
+ - Added GetWindowPos method
+
+2004-08-10 11:36 pbartok
+
+ * XplatUIWin32.cs:
+ - Implemented several methods
+
+2004-08-10 09:47 jackson
+
+ * TrackBar.cs: Allow control to handle buffering
+
+2004-08-10 09:41 jackson
+
+ * ProgressBar.cs, ScrollBar.cs: Allow control to handle buffering
+
+2004-08-10 09:24 jackson
+
+ * Label.cs, LinkLabel.cs: Let Control handle buffering.
+
+2004-08-10 09:09 jackson
+
+ * StatusBar.cs: Let Control handle all the buffering.
+
+2004-08-10 09:08 jackson
+
+ * Control.cs: Control will now handle the buffering code, so each
+ control does not have to implement this.
+
+2004-08-10 08:34 jackson
+
+ * XplatUIDriver.cs: Use default colors from the theme
+
+2004-08-09 17:12 pbartok
+
+ * ImageList.cs:
+ - Fixed several bugs Ravindra pointed out
+
+2004-08-09 16:11 pbartok
+
+ * Control.cs:
+ - Added incomplete dock layout code
+ - Added support for mouse wheel
+
+2004-08-09 16:09 pbartok
+
+ * XplatUIX11.cs:
+ - Added handling for middle and right mousebutton
+ - Added handling for mouse wheel
+ - Added handling for key state and mouse state and position
+ - Now properly generates WM_xBUTTONx messages and WM_MOUSEWHEEL
+ messages
+
+2004-08-09 15:40 jackson
+
+ * StatusBarPanel.cs, StatusBarPanelAutoSize.cs,
+ StatusBarPanelBorderStyle.cs, StatusBarPanelStyle.cs: Initial
+ checkin
+
+2004-08-09 15:37 jackson
+
+ * StatusBar.cs: Initial implementation of StatusBar
+
+2004-08-09 15:36 jackson
+
+ * ITheme.cs: Add support for drawing status bar and getting status
+ bar item sizes
+
+2004-08-09 15:35 pbartok
+
+ * MouseButtons.cs:
+ - Fixed values
+
+2004-08-09 15:34 jackson
+
+ * ThemeWin32Classic.cs: Add support for drawing status bar and get
+ status bar item sizes
+
+2004-08-09 15:21 jackson
+
+ * ThemeWin32Classic.cs: Use known colors for default control
+ colours
+
+2004-08-09 15:12 jackson
+
+ * ThemeWin32Classic.cs: Make the default font static, it is static
+ in control so this doesn't change functionality and creating fonts
+ is sloooooow.
+
+2004-08-09 14:56 pbartok
+
+ * X11Structs.cs:
+ - Added GrabMode enum
+
+2004-08-09 14:55 pbartok
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIWin32.cs, XplatUIX11.cs:
+ - Removed Run method, was only required for initial development
+
+2004-08-09 14:51 pbartok
+
+ * XplatUI.cs, XplatUIDriver.cs, XplatUIWin32.cs, XplatUIX11.cs:
+ - Implemented GrabWindow/ReleaseWindow methods to allow pointer
+ capture
+
+2004-08-09 13:48 pbartok
+
+ * XplatUIX11.cs:
+ - Fixed default sizing for child windows
+
+2004-08-09 12:56 pbartok
+
+ * XplatUIX11.cs:
+ - Added generation of WM_DESTROY message
+ - Added handling of window manager induced shutdown
+
+2004-08-09 11:31 jackson
+
+ * ThemeWin32Classic.cs: New names for control properties
+
+2004-08-09 11:25 jackson
+
+ * Control.cs: Use new color names
+
+2004-08-09 11:02 jackson
+
+ * XplatUI.cs: Get default window properties from the theme
+
+2004-08-09 11:01 jackson
+
+ * ITheme.cs: The theme engine now controls default window
+ properties
+
+2004-08-09 11:00 jackson
+
+ * ThemeWin32Classic.cs: Add default window color properties
+
+2004-08-09 10:17 jackson
+
+ * ThemeWin32Classic.cs: Use correct default back color
+
+2004-08-09 10:05 jackson
+
+ * XplatUIWin32.cs, XplatUIX11.cs: These properties are handled by
+ the theme now.
+
+2004-08-09 09:56 jackson
+
+ * XplatUI.cs: Remove defaults, these are handled by the theme now.
+
+2004-08-09 09:54 jackson
+
+ * Control.cs: Get default properties from the theme.
+
+2004-08-09 09:53 jackson
+
+ * ITheme.cs: Themes now handle default control properties
+
+2004-08-09 09:53 jackson
+
+ * ThemeWin32Classic.cs: Themes now handle default control
+ properties so coloring will be consistent
+
+2004-08-08 16:54 jordi
+
+ * ITheme.cs, ThemeWin32Classic.cs: Label BorderStyles
+
+2004-08-08 15:08 jordi
+
+ * XplatUIX11.cs: fixes keyboard crash
+
+2004-08-08 13:47 jordi
+
+ * Label.cs: add cvs header info
+
+2004-08-08 12:09 jackson
+
+ * ThemeWin32Classic.cs: Add pen_buttonface
+
+2004-08-08 11:52 jordi
+
+ * Label.cs, LinkLabel.cs: [no log message]
+
+2004-08-08 11:34 jordi
+
+ * ThemeWin32Classic.cs: Use Windows Standard Colours
+
+2004-08-07 17:32 jordi
+
+ * TrackBar.cs: throw exceptions of invalid enums values
+
+2004-08-07 17:31 jordi
+
+ * Label.cs, LinkLabel.cs, ThemeWin32Classic.cs: fixes label bug and
+ draw method name
+
+2004-08-07 16:56 jackson
+
+ * HorizontalAlignment.cs: Initial checkin
+
+2004-08-07 13:16 jordi
+
+ * Label.cs, LinkLabel.cs: throw exceptions, fixes events, missing
+ methods
+
+2004-08-07 13:05 jordi
+
+ * ITheme.cs, ThemeWin32Classic.cs: Theme colour support and
+ GetSysColor defines
+
+2004-08-06 18:01 pbartok
+
+ * ThemeWin32Classic.cs:
+ - Fixed some rounding issues with float/int
+
+2004-08-06 18:00 jackson
+
+ * DockStyle.cs, AnchorStyles.cs:
+
+ Add flags and serializable attributes.
+
+2004-08-06 17:46 pbartok
+
+ * XplatUIX11.cs:
+ - Implemented GetParent
+
+2004-08-06 17:18 pbartok
+
+ * TrackBar.cs:
+ - Fixed some rounding issues with float/int
+
+2004-08-06 17:17 pbartok
+
+ * X11Structs.cs, XplatUIX11.cs:
+ - Fixed Refresh and Invalidate
+
+2004-08-06 15:30 pbartok
+
+ * Control.cs, X11Structs.cs, XplatUIX11.cs:
+ - Fixed recursive loop when resizing
+ - Improved/fixed redrawing on expose messages
+
+2004-08-06 09:53 jordi
+
+ * Control.cs, X11Structs.cs, XplatUIWin32.cs, XplatUIX11.cs: X11
+ keyboard navigation
+
+2004-08-06 08:02 pbartok
+
+ * X11Structs.cs, XplatUIX11.cs:
+ - Fixed reparenting
+ - Fixed window border creation
+
+2004-08-05 15:38 pbartok
+
+ * XplatUIX11.cs:
+ - Attempted fix for reparenting problems
+
+2004-08-04 15:14 pbartok
+
+ * Control.cs:
+ - Fixed Invalidation bug (calculated wrong client area)
+ - Added ClientSize setter
+
+2004-08-04 15:13 pbartok
+
+ * Form.cs:
+ - Added AutoScale properties
+
+2004-08-04 15:13 pbartok
+
+ * SWF.csproj:
+ - Added latest files
+
+2004-08-04 14:11 pbartok
+
+ * Control.cs, XplatUI.cs, XplatUIDriver.cs, XplatUIWin32.cs,
+ XplatUIX11.cs:
+ - Added Invalidate handling
+
+2004-08-03 17:09 jordi
+
+ * XplatUIDriver.cs: fixes spelling mistake
+
+2004-07-27 09:53 jordi
+
+ * TrackBar.cs: fixes trackbar events, def classname, methods
+ signature
+
+2004-07-27 09:29 jordi
+
+ * ScrollBar.cs: fixes scrollbar events
+
+2004-07-27 04:38 jordi
+
+ * Control.cs: changes to be able to run winforms samples
+
+2004-07-26 11:42 jordi
+
+ * ControlPaint.cs, ITheme.cs, ProgressBar.cs, ScrollBar.cs,
+ ThemeEngine.cs, ThemeWin32Classic.cs, TrackBar.cs: Theme support
+
+2004-07-26 05:41 jordi
+
+ * MessageBox.cs, MessageBoxButtons.cs, MessageBoxDefaultButton.cs,
+ MessageBoxIcon.cs, MessageBoxOptions.cs: initial messagebox
+ implementation
+
+2004-07-22 09:22 jordi
+
+ * LinkLabel.cs, LinkLabelLinkClickedEventHandler.cs: link label:
+ check link overlapping, implement events, and fixes
+
+2004-07-21 10:28 jordi
+
+ * DialogResult.cs, IButtonControl.cs: fixes comments filenames
+
+2004-07-21 10:19 jordi
+
+ * DialogResult.cs, IButtonControl.cs, Label.cs, LinkArea.cs,
+ LinkBehavior.cs, LinkClickedEventArgs.cs, LinkLabel.cs,
+ LinkLabelLinkClickedEventArgs.cs,
+ LinkLabelLinkClickedEventHandler.cs, LinkState.cs,
+ XplatUIWin32.cs, LinkClickedEventHandler.cs: LinkLabel control
+ implementation
+
+2004-07-19 13:09 jordi
+
+ * Control.cs, Label.cs: label control re-written: added missing
+ functionlity, events, and properties
+
+2004-07-19 10:49 jordi
+
+ * Control.cs: fixes SetBounds logic
+
+2004-07-19 01:29 jordi
+
+ * Control.cs: Call RefreshWindow only if the window has created
+
+2004-07-15 14:05 pbartok
+
+ * ColorDepth.cs, ImageList.cs, ImageListStreamer.cs, SWF.csproj:
+ - Implemented ImageList and ImageList.ImageCollection classes
+ - Added ColorDepth enumeration
+ - Updated SWF VS.Net project
+
+2004-07-15 11:06 jordi
+
+ * XplatUIStructs.cs: added MsgButons enum
+
+2004-07-15 11:03 jordi
+
+ * Control.cs: added basic mouse handeling events
+
+2004-07-15 03:38 jordi
+
+ * Orientation.cs, TickStyle.cs, TrackBar.cs: Horizontal and
+ Vertical TrackBar control implementation
+
+2004-07-13 09:33 jordi
+
+ * HScrollBar.cs, VScrollBar.cs: vertical and hort. classes commit
+
+2004-07-13 09:31 jordi
+
+ * Control.cs, Form.cs: commit: new properties and fixes form size
+ problems
+
+2004-07-09 14:13 miguel
+
+ * ProgressBar.cs: Spelling
+
+2004-07-09 11:25 pbartok
+
+ * ProgressBar.cs:
+ - Removed usage of Rectangle for drawing. Miguel pointed out it's
+ faster
+
+2004-07-09 11:17 miguel
+
+ * ProgressBar.cs: 2004-07-09 Miguel de Icaza <miguel@ximian.com>
+
+ * ProgressBar.cs: Fixed spelling for `block'
+
+ drawProgressBar: renamed to `DrawProgressBar' to follow the coding
+ style guidelines.
+
+ Avoid using the += on rect.X, that exposed a bug in the compiler.
+
+2004-07-08 23:21 pbartok
+
+ * AccessibleObject.cs, AccessibleRole.cs, AccessibleStates.cs,
+ AnchorStyles.cs, Application.cs, ApplicationContext.cs,
+ BaseCollection.cs, Binding.cs, BindingContext.cs,
+ BindingMemberInfo.cs, BindingsCollection.cs,
+ BindingsManagerBase.cs, Border3DSide.cs, Border3DStyle.cs,
+ BorderStyle.cs, BoundsSpecified.cs, ButtonBorderStyle.cs,
+ ButtonState.cs, CaptionButton.cs, CheckBox.cs,
+ ContainerControl.cs, Control.cs, ControlEventArgs.cs,
+ ControlEventHandler.cs, ControlPaint.cs, ControlStyles.cs,
+ ConvertEventArgs.cs, ConvertEventHandler.cs, Copyright,
+ CreateParams.cs, DockStyle.cs, DragAction.cs, DragDropEffects.cs,
+ DragEventArgs.cs, DragEventHandler.cs, FlatStyle.cs, Form.cs,
+ FrameStyle.cs, GiveFeedbackEventArgs.cs,
+ GiveFeedbackEventHandler.cs, HelpEventArgs.cs,
+ HelpEventHandler.cs, IContainerControl.cs, IDataObject.cs,
+ IMessageFilter.cs, IWin32Window.cs, ImeMode.cs, InputLanguage.cs,
+ InputLanguageChangedEventArgs.cs,
+ InputLanguageChangedEventHandler.cs,
+ InputLanguageChangingEventArgs.cs,
+ InputLanguageChangingEventHandler.cs, InputLanguageCollection.cs,
+ InvalidateEventArgs.cs, InvalidateEventHandler.cs,
+ KeyEventArgs.cs, KeyEventHandler.cs, KeyPressEventArgs.cs,
+ KeyPressEventHandler.cs, Keys.cs, Label.cs, LayoutEventArgs.cs,
+ LayoutEventHandler.cs, MenuGlyph.cs, Message.cs, MouseButtons.cs,
+ MouseEventArgs.cs, MouseEventHandler.cs, NativeWindow.cs,
+ PaintEventArgs.cs, PaintEventHandler.cs, ProgressBar.cs,
+ QueryAccessibilityHelpEventArgs.cs,
+ QueryAccessibilityHelpEventHandler.cs,
+ QueryContinueDragEventArgs.cs, QueryContinueDragEventHandler.cs,
+ RightToLeft.cs, SWF.csproj, SWF.csproj.user, ScrollBar.cs,
+ ScrollBars.cs, ScrollButton.cs, ScrollEventArgs.cs,
+ ScrollEventHandler.cs, ScrollEventType.cs, ScrollableControl.cs,
+ TODO, TODOAttribute.cs, UICues.cs, UICuesEventArgs.cs,
+ UICuesEventHandler.cs, X11Structs.cs, XplatUI.cs,
+ XplatUIDriver.cs, XplatUIStructs.cs, XplatUIWin32.cs,
+ XplatUIX11.cs, lang.cs:
+ - Initial check-in
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CharacterCasing.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CharacterCasing.cs
new file mode 100644
index 00000000000..7556cd89b1a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CharacterCasing.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum CharacterCasing {
+ Normal = 0,
+ Upper = 1,
+ Lower = 2
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CheckBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CheckBox.cs
new file mode 100644
index 00000000000..4f76fa7ddcc
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CheckBox.cs
@@ -0,0 +1,346 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Dennis Hayes dennish@raytek.com
+// Peter Bartok pbartok@novell.com
+//
+
+// COMPLETE
+
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [DefaultProperty("Checked")]
+ [DefaultEvent("CheckedChanged")]
+ public class CheckBox : ButtonBase {
+ #region Local Variables
+ internal Appearance appearance;
+ internal bool auto_check;
+ internal ContentAlignment check_alignment;
+ internal CheckState check_state;
+ internal bool three_state;
+ #endregion // Local Variables
+
+ #region CheckBoxAccessibleObject Subclass
+ [ComVisible(true)]
+ public class CheckBoxAccessibleObject : ButtonBaseAccessibleObject {
+ #region CheckBoxAccessibleObject Local Variables
+ private CheckBox owner;
+ #endregion // CheckBoxAccessibleObject Local Variables
+
+ #region CheckBoxAccessibleObject Constructors
+ public CheckBoxAccessibleObject(Control owner) : base(owner) {
+ this.owner = (CheckBox)owner;
+ }
+ #endregion // CheckBoxAccessibleObject Constructors
+
+ #region CheckBoxAccessibleObject Properties
+ public override string DefaultAction {
+ get {
+ return "Select";
+ }
+ }
+
+ public override AccessibleRole Role {
+ get {
+ return AccessibleRole.CheckButton;
+ }
+ }
+
+ public override AccessibleStates State {
+ get {
+ AccessibleStates retval;
+
+ retval = AccessibleStates.Default;
+
+ if (owner.check_state == CheckState.Checked) {
+ retval |= AccessibleStates.Checked;
+ }
+
+ if (owner.Focused) {
+ retval |= AccessibleStates.Focused;
+ }
+
+ if (owner.CanFocus) {
+ retval |= AccessibleStates.Focusable;
+ }
+
+ return retval;
+ }
+ }
+ #endregion // CheckBoxAccessibleObject Properties
+ }
+ #endregion // CheckBoxAccessibleObject Sub-class
+
+ #region Public Constructors
+ public CheckBox() {
+ appearance = Appearance.Normal;
+ auto_check = true;
+ check_alignment = ContentAlignment.MiddleLeft;
+ text_alignment = ContentAlignment.MiddleLeft;
+ SetStyle(ControlStyles.StandardDoubleClick, false);
+ }
+ #endregion // Public Constructors
+
+ #region Internal Methods
+ internal override void Draw (PaintEventArgs pe) {
+ ThemeEngine.Current.DrawCheckBox (pe.Graphics, this.ClientRectangle, this);
+ }
+
+ internal override void HaveDoubleClick() {
+ if (DoubleClick != null) DoubleClick(this, EventArgs.Empty);
+ }
+ #endregion // Internal Methods
+
+ #region Public Instance Properties
+ [DefaultValue(Appearance.Normal)]
+ [Localizable(true)]
+ public Appearance Appearance {
+ get {
+ return appearance;
+ }
+
+ set {
+ if (value != appearance) {
+ appearance = value;
+ if (AppearanceChanged != null) {
+ AppearanceChanged(this, EventArgs.Empty);
+ }
+ Redraw();
+ }
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool AutoCheck {
+ get {
+ return auto_check;
+ }
+
+ set {
+ auto_check = value;
+ }
+ }
+
+ [Bindable(true)]
+ [Localizable(true)]
+ [DefaultValue(ContentAlignment.MiddleLeft)]
+ public ContentAlignment CheckAlign {
+ get {
+ return check_alignment;
+ }
+
+ set {
+ if (value != check_alignment) {
+ check_alignment = value;
+
+ Redraw();
+ }
+ }
+ }
+
+ [Bindable(true)]
+ [RefreshProperties(RefreshProperties.All)]
+ [DefaultValue(false)]
+ public bool Checked {
+ get {
+ if (check_state != CheckState.Unchecked) {
+ return true;
+ }
+ return false;
+ }
+
+ set {
+ if (value && (check_state != CheckState.Checked)) {
+ check_state = CheckState.Checked;
+ Redraw();
+ OnCheckedChanged(EventArgs.Empty);
+ } else if (!value && (check_state != CheckState.Unchecked)) {
+ check_state = CheckState.Unchecked;
+ Redraw();
+ OnCheckedChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ [DefaultValue(CheckState.Unchecked)]
+ [RefreshProperties(RefreshProperties.All)]
+ [Bindable(true)]
+ public CheckState CheckState {
+ get {
+ return check_state;
+ }
+
+ set {
+ if (value != check_state) {
+ bool was_checked = (check_state != CheckState.Unchecked);
+
+ check_state = value;
+
+ if (was_checked != (check_state != CheckState.Unchecked)) {
+ OnCheckedChanged(EventArgs.Empty);
+ }
+
+ OnCheckStateChanged(EventArgs.Empty);
+ Redraw();
+ }
+ }
+ }
+
+ [DefaultValue(ContentAlignment.MiddleLeft)]
+ [Localizable(true)]
+ public override ContentAlignment TextAlign {
+ get {
+ return text_alignment;
+ }
+
+ set {
+ if (value != text_alignment) {
+ text_alignment = value;
+ Redraw();
+ }
+ }
+ }
+
+
+ [DefaultValue(false)]
+ public bool ThreeState {
+ get {
+ return three_state;
+ }
+
+ set {
+ three_state = value;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Properties
+ protected override CreateParams CreateParams {
+ get {
+ return base.CreateParams;
+ }
+ }
+
+ protected override Size DefaultSize {
+ get {
+ return new Size(104, 24);
+ }
+ }
+ #endregion // Protected Instance Properties
+
+ #region Public Instance Methods
+ public override string ToString() {
+ return base.ToString() + ", CheckState: " + (int)check_state;
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected override AccessibleObject CreateAccessibilityInstance() {
+ AccessibleObject ao;
+
+ ao = base.CreateAccessibilityInstance ();
+ ao.role = AccessibleRole.CheckButton;
+
+ return ao;
+ }
+
+ protected virtual void OnAppearanceChanged(EventArgs e) {
+ if (AppearanceChanged != null) {
+ AppearanceChanged(this, e);
+ }
+ }
+
+ protected virtual void OnCheckedChanged(EventArgs e) {
+ if (CheckedChanged != null) {
+ CheckedChanged(this, e);
+ }
+ }
+
+ protected virtual void OnCheckStateChanged(EventArgs e) {
+ if (CheckStateChanged != null) {
+ CheckStateChanged(this, e);
+ }
+ }
+
+ protected override void OnClick(EventArgs e) {
+ if (auto_check) {
+ switch(check_state) {
+ case CheckState.Unchecked: {
+ if (three_state) {
+ CheckState = CheckState.Indeterminate;
+ } else {
+ CheckState = CheckState.Checked;
+ }
+ break;
+ }
+
+ case CheckState.Indeterminate: {
+ CheckState = CheckState.Checked;
+ break;
+ }
+
+ case CheckState.Checked: {
+ CheckState = CheckState.Unchecked;
+ break;
+ }
+ }
+ }
+
+ base.OnClick (e);
+ }
+
+ protected override void OnHandleCreated(EventArgs e) {
+ base.OnHandleCreated (e);
+ }
+
+ protected override void OnMouseUp(MouseEventArgs mevent) {
+ base.OnMouseUp (mevent);
+ }
+
+ protected override bool ProcessMnemonic(char charCode) {
+ if (IsMnemonic(charCode, Text) == true) {
+ Select();
+ OnClick(EventArgs.Empty);
+ return true;
+ }
+
+ return base.ProcessMnemonic(charCode);
+ }
+ #endregion // Protected Instance Methods
+
+ #region Events
+ public event EventHandler AppearanceChanged;
+ public event EventHandler CheckedChanged;
+ public event EventHandler CheckStateChanged;
+ #endregion // Events
+
+ #region Events
+ [Browsable(false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public event EventHandler DoubleClick;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CheckState.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CheckState.cs
new file mode 100644
index 00000000000..9267454ba3f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CheckState.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum CheckState {
+ Unchecked = 0,
+ Checked = 1,
+ Indeterminate = 2
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CheckedListBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CheckedListBox.cs
new file mode 100644
index 00000000000..2e1e6e74345
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CheckedListBox.cs
@@ -0,0 +1,685 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+//
+
+// COMPLETE
+
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Reflection;
+
+namespace System.Windows.Forms
+{
+
+ public class CheckedListBox : ListBox
+ {
+ private CheckedIndexCollection checked_indices;
+ private CheckedItemCollection checked_items;
+ private bool check_onclick;
+ private bool three_dcheckboxes;
+
+ public CheckedListBox ()
+ {
+ items = new CheckedListBox.ObjectCollection (this);
+ checked_indices = new CheckedIndexCollection (this);
+ checked_items = new CheckedItemCollection (this);
+ check_onclick = false;
+ three_dcheckboxes = false;
+ listbox_info.item_height = FontHeight + 2;
+ SetStyle (ControlStyles.ResizeRedraw, true);
+ }
+
+ #region events
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler Click;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler DataSourceChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler DisplayMemberChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event DrawItemEventHandler DrawItem;
+ public event ItemCheckEventHandler ItemCheck;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event MeasureItemEventHandler MeasureItem;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler ValueMemberChanged;
+ #endregion Events
+
+ #region Public Properties
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public CheckedListBox.CheckedIndexCollection CheckedIndices {
+ get {return checked_indices; }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public CheckedListBox.CheckedItemCollection CheckedItems {
+ get {return checked_items; }
+ }
+
+ [DefaultValue (false)]
+ public bool CheckOnClick {
+ get { return check_onclick; }
+ set { check_onclick = value; }
+ }
+
+ protected override CreateParams CreateParams {
+ get { return base.CreateParams;}
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Browsable (false)]
+ public new object DataSource {
+ get { return base.DataSource; }
+ set { base.DataSource = value; }
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Browsable (false)]
+ public new string DisplayMember {
+ get { return base.DisplayMember; }
+ set { base.DisplayMember = value; }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override DrawMode DrawMode {
+ get { return DrawMode.Normal; }
+ set { /* Not possible */ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override int ItemHeight {
+ get { return listbox_info.item_height; }
+ set { /* Not possible */ }
+ }
+
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
+ [Localizable (true)]
+ [Editor ("System.Windows.Forms.Design.ListControlStringCollectionEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
+ public new CheckedListBox.ObjectCollection Items {
+ get { return (CheckedListBox.ObjectCollection) base.Items; }
+ }
+
+ public override SelectionMode SelectionMode {
+ get { return base.SelectionMode; }
+ set {
+ if (value == SelectionMode.MultiSimple || value == SelectionMode.MultiExtended)
+ throw new InvalidEnumArgumentException ("Multi selection modes not supported");
+
+ base.SelectionMode = value;
+ }
+ }
+
+ [DefaultValue (false)]
+ public bool ThreeDCheckBoxes {
+ get { return three_dcheckboxes; }
+ set {
+ if (three_dcheckboxes == value)
+ return;
+
+ three_dcheckboxes = value;
+ Refresh ();
+ }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new string ValueMember {
+ get { return base.ValueMember; }
+ set { base.ValueMember = value; }
+ }
+
+ #endregion Public Properties
+
+ #region Public Methods
+
+ protected override AccessibleObject CreateAccessibilityInstance ()
+ {
+ return base.CreateAccessibilityInstance ();
+ }
+
+ protected override ListBox.ObjectCollection CreateItemCollection ()
+ {
+ return new ObjectCollection (this);
+ }
+
+ public bool GetItemChecked (int index)
+ {
+ return (GetItemCheckState (index) != CheckState.Unchecked);
+ }
+
+ public CheckState GetItemCheckState (int index)
+ {
+ if (index < 0 || index >= Items.Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ return (Items.GetListBoxItem (index)).State;
+ }
+
+ protected override void OnBackColorChanged (EventArgs e)
+ {
+ base.OnBackColorChanged (e);
+ }
+
+ protected override void OnClick (EventArgs e)
+ {
+ base.OnClick (e);
+
+ if (Click != null)
+ Click (this, EventArgs.Empty);
+ }
+
+ protected override void OnDrawItem (DrawItemEventArgs e)
+ {
+ ThemeEngine.Current.DrawCheckedListBoxItem (this, e);
+ }
+
+ protected override void OnFontChanged (EventArgs e)
+ {
+ base.OnFontChanged (e);
+ }
+
+ protected override void OnHandleCreated (EventArgs e)
+ {
+ base.OnHandleCreated (e);
+ }
+
+ protected virtual void OnItemCheck (ItemCheckEventArgs ice)
+ {
+ if (ItemCheck != null)
+ ItemCheck (this, ice);
+ }
+
+ protected override void OnKeyPress (KeyPressEventArgs e)
+ {
+ base.OnKeyPress (e);
+
+ if (e.KeyChar == ' ') { // Space should check focused item
+ if (focused_item != -1) {
+ SetItemChecked (focused_item, !GetItemChecked (focused_item));
+ }
+ }
+ }
+
+ protected override void OnMeasureItem (MeasureItemEventArgs e)
+ {
+ if (MeasureItem != null)
+ MeasureItem (this, e);
+ }
+
+ protected override void OnSelectedIndexChanged (EventArgs e)
+ {
+ base.OnSelectedIndexChanged (e);
+ }
+
+ public void SetItemChecked (int index, bool value)
+ {
+ SetItemCheckState (index, value ? CheckState.Checked : CheckState.Unchecked);
+ }
+
+ public void SetItemCheckState (int index, CheckState value)
+ {
+ if (index < 0 || index >= Items.Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ if (!Enum.IsDefined (typeof (CheckState), value))
+ throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for CheckState", value));
+
+ CheckState old_value = (Items.GetListBoxItem (index)).State;
+
+ if (old_value == value)
+ return;
+
+ (Items.GetListBoxItem (index)).State = value;
+
+ Rectangle invalidate = GetItemDisplayRectangle (index, LBoxInfo.top_item);
+
+ switch (value) {
+ case CheckState.Checked:
+ checked_indices.AddIndex (index);
+ checked_items.AddObject (Items[index]);
+ break;
+ case CheckState.Unchecked:
+ checked_indices.RemoveIndex (index);
+ checked_items.RemoveObject (Items[index]);
+ break;
+ case CheckState.Indeterminate:
+ default:
+ break;
+ }
+
+ OnItemCheck (new ItemCheckEventArgs (index, value, old_value));
+
+ if (ClientRectangle.Contains (invalidate))
+ Invalidate (invalidate);
+ }
+
+ protected override void WmReflectCommand (ref Message m)
+ {
+ base.WmReflectCommand (ref m);
+ }
+
+ protected override void WndProc (ref Message m)
+ {
+ base.WndProc (ref m);
+ }
+
+ #endregion Public Methods
+
+ #region Private Methods
+
+ internal override void OnMouseDownLB (object sender, MouseEventArgs e)
+ {
+ Rectangle hit_rect;
+ CheckState value = CheckState.Checked;
+ bool set_value = false;
+ int index = IndexFromPointDisplayRectangle (e.X, e.Y);
+
+ if (Click != null) {
+ if (e.Button == MouseButtons.Left) {
+ Click (this, e);
+ }
+ }
+
+ if (index == -1)
+ return;
+
+ /* CheckBox hit */
+ hit_rect = GetItemDisplayRectangle (index, LBoxInfo.top_item); // Full item rect
+ hit_rect.X += ThemeEngine.Current.CheckedListBoxCheckRectangle().X;
+ hit_rect.Y += ThemeEngine.Current.CheckedListBoxCheckRectangle().Y;
+ hit_rect.Width = ThemeEngine.Current.CheckedListBoxCheckRectangle().Width;
+ hit_rect.Height = ThemeEngine.Current.CheckedListBoxCheckRectangle().Height;
+
+ if ((Items.GetListBoxItem (index)).State == CheckState.Checked) { //From checked to unchecked
+ value = CheckState.Unchecked;
+ set_value = true;
+ } else {
+
+ if (check_onclick) {
+ set_value = true;
+ } else {
+ if ((Items.GetListBoxItem (index)).Selected == true)
+ set_value = true;
+ }
+ }
+
+ if (set_value)
+ SetItemCheckState (index, value);
+
+ SelectedItemFromNavigation (index);
+ SetFocusedItem (index);
+ }
+
+ internal override void UpdateItemInfo (UpdateOperation operation, int first, int last)
+ {
+ base.UpdateItemInfo (operation, first, last);
+ CheckedItems.ReCreate ();
+ CheckedIndices.ReCreate ();
+ }
+
+ #endregion Private Methods
+
+ public class ObjectCollection : ListBox.ObjectCollection
+ {
+ private CheckedListBox owner;
+
+ public ObjectCollection (CheckedListBox owner) : base (owner)
+ {
+ this.owner = owner;
+ }
+
+ public int Add (object item, bool isChecked)
+ {
+ if (isChecked)
+ return Add (item, CheckState.Checked);
+
+ return Add (item, CheckState.Unchecked);
+
+ }
+
+ public int Add (object item, CheckState check)
+ {
+ int cnt = object_items.Count;
+ ListBox.ListBoxItem box_item = new ListBox.ListBoxItem (cnt);
+ box_item.State = check;
+ object_items.Add (item);
+ listbox_items.Add (box_item);
+ if (check == CheckState.Checked)
+ owner.OnItemCheck (new ItemCheckEventArgs (cnt, check, CheckState.Unchecked));
+ owner.UpdateItemInfo (UpdateOperation.AddItems, cnt, cnt);
+ return cnt;
+ }
+ }
+
+ /*
+ CheckedListBox.CheckedIndexCollection
+ */
+ public class CheckedIndexCollection : IList, ICollection, IEnumerable
+ {
+ private CheckedListBox owner;
+ private ArrayList indices = new ArrayList ();
+
+ internal CheckedIndexCollection (CheckedListBox owner)
+ {
+ this.owner = owner;
+ }
+
+ #region Public Properties
+ public virtual int Count {
+ get { return indices.Count; }
+ }
+
+ public virtual bool IsReadOnly {
+ get { return true;}
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return false; }
+ }
+
+ bool IList.IsFixedSize{
+ get { return true; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return this; }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int this[int index] {
+ get {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ return (int) indices[index];
+ }
+ }
+ #endregion Public Properties
+
+ public bool Contains (int index)
+ {
+ return indices.Contains (index);
+ }
+
+
+ public virtual void CopyTo (Array dest, int index)
+ {
+ indices.CopyTo (dest, index);
+ }
+
+ public virtual IEnumerator GetEnumerator ()
+ {
+ return indices.GetEnumerator ();
+ }
+
+ int IList.Add (object value)
+ {
+ throw new NotSupportedException ();
+ }
+
+ void IList.Clear ()
+ {
+ throw new NotSupportedException ();
+ }
+
+ bool IList.Contains (object index)
+ {
+ return Contains ((int)index);
+ }
+
+ int IList.IndexOf (object index)
+ {
+ return IndexOf ((int) index);
+ }
+
+ void IList.Insert (int index, object value)
+ {
+ throw new NotSupportedException ();
+ }
+
+ void IList.Remove (object value)
+ {
+ throw new NotSupportedException ();
+ }
+
+ void IList.RemoveAt (int index)
+ {
+ throw new NotSupportedException ();
+ }
+
+ object IList.this[int index]{
+ get {return indices[index]; }
+ set {throw new NotImplementedException (); }
+ }
+
+ public int IndexOf (int index)
+ {
+ return indices.IndexOf (index);
+ }
+
+ #region Private Methods
+
+ internal void AddIndex (int index)
+ {
+ indices.Add (index);
+ }
+
+ internal void ClearIndices ()
+ {
+ indices.Clear ();
+ }
+
+ internal void RemoveIndex (int index)
+ {
+ indices.Remove (index);
+ }
+
+ internal void ReCreate ()
+ {
+ indices.Clear ();
+
+ for (int i = 0; i < owner.Items.Count; i++) {
+ ListBox.ListBoxItem item = owner.Items.GetListBoxItem (i);
+
+ if (item.State == CheckState.Checked)
+ indices.Add (item.Index);
+ }
+ }
+
+ #endregion Private Methods
+ }
+
+ /*
+ CheckedItemCollection
+ */
+ public class CheckedItemCollection : IList, ICollection, IEnumerable
+ {
+ private CheckedListBox owner;
+ private ArrayList object_items = new ArrayList ();
+
+ internal CheckedItemCollection (CheckedListBox owner)
+ {
+ this.owner = owner;
+ }
+
+ #region Public Properties
+ public virtual int Count {
+ get { return object_items.Count; }
+ }
+
+ public virtual bool IsReadOnly {
+ get { return true; }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public virtual object this [int index] {
+ get {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ return object_items[index];
+ }
+ set {throw new NotSupportedException ();}
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return true; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return this; }
+ }
+
+ bool IList.IsFixedSize {
+ get { return true; }
+ }
+
+ object IList.this[int index] {
+ get { return object_items[index]; }
+ set { throw new NotSupportedException (); }
+ }
+
+ #endregion Public Properties
+
+ #region Public Methods
+ public virtual bool Contains (object selectedObject)
+ {
+ return object_items.Contains (selectedObject);
+ }
+
+ public virtual void CopyTo (Array dest, int index)
+ {
+ object_items.CopyTo (dest, index);
+ }
+
+ int IList.Add (object value)
+ {
+ throw new NotSupportedException ();
+ }
+
+ void IList.Clear ()
+ {
+ throw new NotSupportedException ();
+ }
+
+ bool IList.Contains (object selectedIndex)
+ {
+ throw new NotImplementedException ();
+ }
+
+ void IList.Insert (int index, object value)
+ {
+ throw new NotSupportedException ();
+ }
+
+ void IList.Remove (object value)
+ {
+ throw new NotSupportedException ();
+ }
+
+ void IList.RemoveAt (int index)
+ {
+ throw new NotSupportedException ();
+ }
+
+ public int IndexOf (object item)
+ {
+ return object_items.IndexOf (item);
+ }
+
+ public virtual IEnumerator GetEnumerator ()
+ {
+ return object_items.GetEnumerator ();
+ }
+
+ #endregion Public Methods
+
+ #region Private Methods
+ internal void AddObject (object obj)
+ {
+ object_items.Add (obj);
+ }
+
+ internal void ClearObjects ()
+ {
+ object_items.Clear ();
+ }
+
+ internal void ReCreate ()
+ {
+ object_items.Clear ();
+
+ for (int i = 0; i < owner.Items.Count; i++) {
+ ListBox.ListBoxItem item = owner.Items.GetListBoxItem (i);
+
+ if (item.State == CheckState.Checked)
+ object_items.Add (owner.Items[item.Index]);
+ }
+ }
+
+ internal void RemoveObject (object obj)
+ {
+ object_items.Remove (obj);
+ }
+ #endregion Private Methods
+ }
+#if NET_2_0
+
+ public bool UseCompatibleTextRendering {
+ get {
+ return use_compatible_text_rendering;
+ }
+
+ set {
+ use_compatible_text_rendering = value;
+ }
+ }
+#endif
+
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Clipboard.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Clipboard.cs
new file mode 100644
index 00000000000..7dcd7f36cd3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Clipboard.cs
@@ -0,0 +1,142 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+using System;
+using System.Drawing;
+using System.IO;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ public sealed class Clipboard {
+ #region Local Variables
+ #endregion // Local Variables
+
+ #region Constructors
+ private Clipboard() {
+ }
+ #endregion // Constructors
+
+ #region Private Methods
+ private static bool ConvertToClipboardData(ref int type, object obj, out byte[] data) {
+ data = null;
+ return false;
+ }
+
+ private static bool ConvertFromClipboardData(int type, IntPtr data, out object obj) {
+ obj = null;
+ if (data == IntPtr.Zero) {
+ return false;
+ }
+ return false;
+ }
+ #endregion // Private Methods
+
+ #region Public Static Methods
+ public static IDataObject GetDataObject() {
+ DataObject clipboard;
+ IntPtr clipboard_handle;
+ int[] native_formats;
+ DataFormats.Format item_format;
+ object managed_clipboard_item;
+ XplatUI.ClipboardToObject converter;
+
+ converter = new XplatUI.ClipboardToObject(ConvertFromClipboardData);
+
+ clipboard_handle = XplatUI.ClipboardOpen();
+ native_formats = XplatUI.ClipboardAvailableFormats(clipboard_handle);
+ if (native_formats == null) {
+ return null; // Clipboard empty
+ }
+
+ // Build the IDataObject
+ clipboard = new DataObject();
+ for (int i = 0; i < native_formats.Length; i++) {
+ // We might get a format we don't understand or know
+ item_format = DataFormats.GetFormat(native_formats[i]);
+
+ if (item_format != null) {
+ managed_clipboard_item = XplatUI.ClipboardRetrieve(clipboard_handle, native_formats[i], converter);
+
+ if (managed_clipboard_item != null) {
+ clipboard.SetData(item_format.Name, managed_clipboard_item);
+ // We don't handle 'bitmap' since it involves handles, so we'll equate it to dib
+ if (item_format.Name == DataFormats.Dib) {
+ clipboard.SetData(DataFormats.Bitmap, managed_clipboard_item);
+ }
+ }
+ }
+ }
+
+ XplatUI.ClipboardClose(clipboard_handle);
+
+ return clipboard;
+ }
+
+ public static void SetDataObject(object data) {
+ SetDataObject(data, true);
+
+ }
+
+ public static void SetDataObject(object data, bool copy) {
+ IntPtr clipboard_handle;
+ XplatUI.ObjectToClipboard converter;
+ int native_format;
+ DataFormats.Format item_format;
+
+ converter = new XplatUI.ObjectToClipboard(ConvertToClipboardData);
+
+ clipboard_handle = XplatUI.ClipboardOpen();
+ XplatUI.ClipboardStore(clipboard_handle, null, 0, null); // Empty clipboard
+
+ native_format = -1;
+
+ if (data is IDataObject) {
+ string[] formats;
+
+ formats = ((IDataObject)data).GetFormats();
+ for (int i = 0; i < formats.Length; i++) {
+ item_format = DataFormats.GetFormat(formats[i]);
+ if ((item_format != null) && (item_format.Name != DataFormats.StringFormat)) {
+ native_format = item_format.Id;
+ }
+
+ XplatUI.ClipboardStore(clipboard_handle, ((IDataObject)data).GetData(formats[i]), native_format, converter);
+ }
+ } else {
+ item_format = DataFormats.Format.Find(data.GetType().FullName);
+ if ((item_format != null) && (item_format.Name != DataFormats.StringFormat)) {
+ native_format = item_format.Id;
+ }
+
+ XplatUI.ClipboardStore(clipboard_handle, data, native_format, converter);
+ }
+ XplatUI.ClipboardClose(clipboard_handle);
+ }
+ #endregion // Public Static Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColorDepth.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColorDepth.cs
new file mode 100644
index 00000000000..60cfe634745
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColorDepth.cs
@@ -0,0 +1,38 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ [Serializable]
+ public enum ColorDepth {
+ Depth4Bit = 4,
+ Depth8Bit = 8,
+ Depth16Bit = 16,
+ Depth24Bit = 24,
+ Depth32Bit = 32
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColorDialog.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColorDialog.cs
new file mode 100644
index 00000000000..53a0ef554a2
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColorDialog.cs
@@ -0,0 +1,1898 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Alexander Olk xenomorph2@onlinehome.de
+//
+
+// COMPLETE
+
+using System.ComponentModel;
+using System.Drawing;
+using System.Globalization;
+using System.Resources;
+using System;
+
+namespace System.Windows.Forms {
+ [DefaultProperty ("Color")]
+ public class ColorDialog : CommonDialog {
+ #region Local Variables
+ private bool allowFullOpen = true;
+ private bool anyColor = false;
+ private Color color;
+ private int[] customColors = null;
+ private bool fullOpen = false;
+ private bool showHelp = false;
+ private bool solidColorOnly = false;
+
+ private Panel selectedColorPanel;
+ private BaseColorControl baseColorControl;
+ private ColorMatrixControl colorMatrixControl;
+ private BrightnessControl brightnessControl;
+ private TriangleControl triangleControl;
+
+ private Button okButton;
+ private Button cancelButton;
+ private Button helpButton;
+ private Button addColoursButton;
+ private Button defineColoursButton;
+
+ private TextBox hueTextBox;
+ private TextBox satTextBox;
+ private TextBox briTextBox;
+ private TextBox redTextBox;
+ private TextBox greenTextBox;
+ private TextBox blueTextBox;
+
+ private Label briLabel;
+ private Label satLabel;
+ private Label hueLabel;
+ private Label colorBaseLabel;
+ private Label greenLabel;
+ private Label blueLabel;
+ private Label redLabel;
+ #endregion // Local Variables
+
+ #region Public Constructors
+ public ColorDialog () : base()
+ {
+ form.SuspendLayout ();
+
+ form.Text = "Color";
+
+ form.Size = new Size (221, 332); // 300
+
+ form.FormBorderStyle = FormBorderStyle.FixedDialog;
+ form.MaximizeBox = false;
+
+ satTextBox = new TextBox ();
+ briTextBox = new TextBox ();
+ blueTextBox = new TextBox ();
+ greenTextBox = new TextBox ();
+ redTextBox = new TextBox ();
+ hueTextBox = new TextBox ();
+
+ redLabel = new Label ();
+ blueLabel = new Label ();
+ greenLabel = new Label ();
+ colorBaseLabel = new Label ();
+ hueLabel = new Label ();
+ satLabel = new Label ();
+ briLabel = new Label ();
+
+ okButton = new Button ();
+ cancelButton = new Button ();
+ helpButton = new Button ();
+ defineColoursButton = new Button ();
+ addColoursButton = new Button ();
+
+ baseColorControl = new BaseColorControl (this);
+ colorMatrixControl = new ColorMatrixControl (this);
+ brightnessControl = new BrightnessControl (this);
+ triangleControl = new TriangleControl (this);
+
+ selectedColorPanel = new Panel ();
+
+ // hueTextBox
+ hueTextBox.Location = new Point (324, 203);
+ hueTextBox.Size = new Size (27, 21);
+ hueTextBox.TabIndex = 11;
+ hueTextBox.TextAlign = HorizontalAlignment.Right;
+ hueTextBox.MaxLength = 3;
+ // satTextBox
+ satTextBox.Location = new Point (324, 225);
+ satTextBox.Size = new Size (27, 21);
+ satTextBox.TabIndex = 15;
+ satTextBox.TextAlign = HorizontalAlignment.Right;
+ satTextBox.MaxLength = 3;
+ // greenTextBox
+ greenTextBox.Location = new Point (404, 225);
+ greenTextBox.Size = new Size (27, 21);
+ greenTextBox.TabIndex = 18;
+ greenTextBox.TextAlign = HorizontalAlignment.Right;
+ greenTextBox.MaxLength = 3;
+ // briTextBox
+ briTextBox.Location = new Point (324, 247);
+ briTextBox.Size = new Size (27, 21);
+ briTextBox.TabIndex = 16;
+ briTextBox.TextAlign = HorizontalAlignment.Right;
+ briTextBox.MaxLength = 3;
+ // blueTextBox
+ blueTextBox.Location = new Point (404, 247);
+ blueTextBox.Size = new Size (27, 21);
+ blueTextBox.TabIndex = 19;
+ blueTextBox.TextAlign = HorizontalAlignment.Right;
+ blueTextBox.MaxLength = 3;
+ // redTextBox
+ redTextBox.Location = new Point (404, 203);
+ redTextBox.Size = new Size (27, 21);
+ redTextBox.TabIndex = 17;
+ redTextBox.TextAlign = HorizontalAlignment.Right;
+ redTextBox.MaxLength = 3;
+
+ // redLabel
+ redLabel.FlatStyle = FlatStyle.System;
+ redLabel.Location = new Point (361, 206);
+ redLabel.Size = new Size (40, 16);
+ redLabel.TabIndex = 25;
+ redLabel.Text = Locale.GetText ("Red") + ":";
+ redLabel.TextAlign = ContentAlignment.MiddleRight;
+ // blueLabel
+ blueLabel.FlatStyle = FlatStyle.System;
+ blueLabel.Location = new Point (361, 250);
+ blueLabel.Size = new Size (40, 16);
+ blueLabel.TabIndex = 26;
+ blueLabel.Text = Locale.GetText ("Blue") + ":";
+ blueLabel.TextAlign = ContentAlignment.MiddleRight;
+ // greenLabel
+ greenLabel.FlatStyle = FlatStyle.System;
+ greenLabel.Location = new Point (361, 228);
+ greenLabel.Size = new Size (40, 16);
+ greenLabel.TabIndex = 27;
+ greenLabel.Text = Locale.GetText ("Green") + ":";
+ greenLabel.TextAlign = ContentAlignment.MiddleRight;
+ // colorBaseLabel
+ colorBaseLabel.Location = new Point (228, 247);
+ colorBaseLabel.Size = new Size (60, 25);
+ colorBaseLabel.TabIndex = 28;
+ colorBaseLabel.Text = Locale.GetText ("Color");
+ colorBaseLabel.TextAlign = ContentAlignment.MiddleCenter;
+ // hueLabel
+ hueLabel.FlatStyle = FlatStyle.System;
+ hueLabel.Location = new Point (287, 206);
+ hueLabel.Size = new Size (36, 16);
+ hueLabel.TabIndex = 23;
+ hueLabel.Text = Locale.GetText ("Hue") + ":";
+ hueLabel.TextAlign = ContentAlignment.MiddleRight;
+ // satLabel
+ satLabel.FlatStyle = FlatStyle.System;
+ satLabel.Location = new Point (287, 228);
+ satLabel.Size = new Size (36, 16);
+ satLabel.TabIndex = 22;
+ satLabel.Text = Locale.GetText ("Sat") + ":";
+ satLabel.TextAlign = ContentAlignment.MiddleRight;
+ // briLabel
+ briLabel.FlatStyle = FlatStyle.System;
+ briLabel.Location = new Point (287, 250);
+ briLabel.Size = new Size (36, 16);
+ briLabel.TabIndex = 24;
+ briLabel.Text = Locale.GetText ("Bri") + ":";
+ briLabel.TextAlign = ContentAlignment.MiddleRight;
+
+ // defineColoursButton
+ defineColoursButton.FlatStyle = FlatStyle.System;
+ defineColoursButton.Location = new Point (5, 244);
+ defineColoursButton.Size = new Size (210, 22);
+ defineColoursButton.TabIndex = 6;
+ defineColoursButton.Text = Locale.GetText ("Define Colours >>");
+ // okButton
+ okButton.FlatStyle = FlatStyle.System;
+ okButton.Location = new Point (5, 271);
+ okButton.Size = new Size (66, 22);
+ okButton.TabIndex = 0;
+ okButton.Text = Locale.GetText ("OK");
+ // cancelButton
+ cancelButton.FlatStyle = FlatStyle.System;
+ cancelButton.Location = new Point (78, 271);
+ cancelButton.Size = new Size (66, 22);
+ cancelButton.TabIndex = 1;
+ cancelButton.Text = Locale.GetText ("Cancel");
+ // helpButton
+ helpButton.FlatStyle = FlatStyle.System;
+ helpButton.Location = new Point (149, 271);
+ helpButton.Size = new Size (66, 22);
+ helpButton.TabIndex = 5;
+ helpButton.Text = Locale.GetText ("Help");
+ helpButton.Hide ();
+
+ // addColoursButton
+ addColoursButton.FlatStyle = FlatStyle.System;
+ addColoursButton.Location = new Point (227, 271);
+ addColoursButton.Size = new Size (213, 22);
+ addColoursButton.TabIndex = 7;
+ addColoursButton.Text = Locale.GetText ("Add Colours");
+
+ // baseColorControl
+ baseColorControl.Location = new Point (3, 6);
+ baseColorControl.Size = new Size (212, 231);
+ baseColorControl.TabIndex = 13;
+ // colorMatrixControl
+ colorMatrixControl.Location = new Point (227, 7);
+ colorMatrixControl.Size = new Size (179, 190);
+ colorMatrixControl.TabIndex = 14;
+ // triangleControl
+ triangleControl.Location = new Point (432, 0);
+ triangleControl.Size = new Size (16, 204);
+ triangleControl.TabIndex = 12;
+ // brightnessControl
+ brightnessControl.Location = new Point (415, 7);
+ brightnessControl.Size = new Size (14, 190);
+ brightnessControl.TabIndex = 20;
+
+ // selectedColorPanel
+ selectedColorPanel.BackColor = SystemColors.Desktop;
+ selectedColorPanel.BorderStyle = BorderStyle.Fixed3D;
+ selectedColorPanel.Location = new Point (227, 202);
+ selectedColorPanel.Size = new Size (60, 42);
+ selectedColorPanel.TabIndex = 10;
+
+ form.Controls.Add (hueTextBox);
+ form.Controls.Add (satTextBox);
+ form.Controls.Add (briTextBox);
+ form.Controls.Add (redTextBox);
+ form.Controls.Add (greenTextBox);
+ form.Controls.Add (blueTextBox);
+
+ form.Controls.Add (defineColoursButton);
+ form.Controls.Add (okButton);
+ form.Controls.Add (cancelButton);
+ form.Controls.Add (addColoursButton);
+
+ form.Controls.Add (baseColorControl);
+ form.Controls.Add (colorMatrixControl);
+ form.Controls.Add (brightnessControl);
+ form.Controls.Add (triangleControl);
+
+ form.Controls.Add (colorBaseLabel);
+ form.Controls.Add (greenLabel);
+ form.Controls.Add (blueLabel);
+ form.Controls.Add (redLabel);
+ form.Controls.Add (briLabel);
+ form.Controls.Add (hueLabel);
+ form.Controls.Add (satLabel);
+
+ form.Controls.Add (selectedColorPanel);
+
+ form.ResumeLayout (false);
+
+ Color = Color.Black;
+
+ defineColoursButton.Click += new EventHandler (OnClickButtonDefineColours);
+ addColoursButton.Click += new EventHandler (OnClickButtonAddColours);
+ helpButton.Click += new EventHandler (OnClickHelpButton);
+ cancelButton.Click += new EventHandler (OnClickCancelButton);
+ okButton.Click += new EventHandler (OnClickOkButton);
+
+ hueTextBox.KeyPress += new KeyPressEventHandler (OnKeyPressTextBoxes);
+ satTextBox.KeyPress += new KeyPressEventHandler (OnKeyPressTextBoxes);
+ briTextBox.KeyPress += new KeyPressEventHandler (OnKeyPressTextBoxes);
+ redTextBox.KeyPress += new KeyPressEventHandler (OnKeyPressTextBoxes);
+ greenTextBox.KeyPress += new KeyPressEventHandler (OnKeyPressTextBoxes);
+ blueTextBox.KeyPress += new KeyPressEventHandler (OnKeyPressTextBoxes);
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public Color Color {
+ get {
+ return color;
+ }
+
+ set {
+ if (color != value) {
+ color = value;
+
+ baseColorControl.SetColor (color);
+ }
+ }
+ }
+
+ [DefaultValue(true)]
+ public virtual bool AllowFullOpen {
+ get {
+ return allowFullOpen;
+ }
+
+ set {
+ if (allowFullOpen != value) {
+ allowFullOpen = value;
+
+ if (!allowFullOpen)
+ defineColoursButton.Enabled = false;
+ else
+ defineColoursButton.Enabled = true;
+ }
+ }
+ }
+
+ // Currently AnyColor internally is always true
+ // Does really anybody still use 256 or less colors ???
+ // Naw, cairo only supports 24bit anyway - pdb
+ [DefaultValue(false)]
+ public virtual bool AnyColor {
+ get {
+ return anyColor;
+ }
+
+ set {
+ anyColor = value;
+ }
+ }
+
+ [DefaultValue(false)]
+ public virtual bool FullOpen {
+ get {
+ return fullOpen;
+ }
+
+ set {
+ if (fullOpen != value) {
+ fullOpen = value;
+
+ if (fullOpen && allowFullOpen) {
+ defineColoursButton.Enabled = false;
+
+ colorMatrixControl.ColorToShow = baseColorControl.ColorToShow;
+
+ form.Size = new Size (448, 332);
+ } else {
+ if (allowFullOpen)
+ defineColoursButton.Enabled = true;
+
+ form.Size = new Size (221, 332); // 300
+ }
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public int[] CustomColors {
+ get {
+ return customColors;
+ }
+
+ set {
+ if (allowFullOpen) {
+ customColors = value;
+
+ baseColorControl.SetCustomColors ();
+ }
+ }
+ }
+
+ [DefaultValue(false)]
+ public virtual bool ShowHelp {
+ get {
+ return showHelp;
+ }
+
+ set {
+ if (showHelp != value) {
+ showHelp = value;
+ if (showHelp)
+ helpButton.Show ();
+ else
+ helpButton.Hide ();
+ }
+ }
+ }
+
+ [DefaultValue(false)]
+ public virtual bool SolidColorOnly {
+ get {
+ return solidColorOnly;
+ }
+
+ set {
+ solidColorOnly = value;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public override void Reset ()
+ {
+ AllowFullOpen = true;
+ anyColor = false;
+ Color = Color.Black;
+ CustomColors = null;
+ FullOpen = false;
+ ShowHelp = false;
+ solidColorOnly = false;
+ }
+
+ public override string ToString ()
+ {
+ return base.ToString () + ", Color: " + Color.ToString ();
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Properties
+ protected virtual IntPtr Instance {
+ get {
+ // MS Internal
+ return (IntPtr)GetHashCode ();
+ }
+ }
+
+ protected virtual int Options {
+ get {
+ // MS Internal
+ return 0;
+ }
+ }
+ #endregion // Protected Instance Properties
+
+ #region Protected Instance Methods
+ protected override bool RunDialog (IntPtr hwndOwner)
+ {
+ // currently needed, otherwise there are a lot of drawing artefacts/transparent controls if the same dialog gets opened again
+ form.Refresh ();
+
+ return true;
+ }
+ #endregion // Protected Instance Methods
+
+ #region Private Methods
+ void OnClickCancelButton (object sender, EventArgs e)
+ {
+ form.DialogResult = DialogResult.Cancel;
+ }
+
+ void OnClickOkButton (object sender, EventArgs e)
+ {
+ form.DialogResult = DialogResult.OK;
+ }
+
+ void OnClickButtonAddColours (object sender, EventArgs e)
+ {
+ baseColorControl.SetUserColor (selectedColorPanel.BackColor);
+ }
+
+ void OnClickButtonDefineColours (object sender, EventArgs e)
+ {
+ if (allowFullOpen) {
+ defineColoursButton.Enabled = false;
+
+ colorMatrixControl.ColorToShow = baseColorControl.ColorToShow;
+
+ form.Size = new Size (448, 332);
+ }
+ }
+
+ // FIXME: Is this correct ?
+ void OnClickHelpButton (object sender, EventArgs e)
+ {
+ OnHelpRequest (e);
+ }
+
+ // not working 100 %, S.W.F.TextBox isn't finished yet
+ void OnKeyPressTextBoxes (object sender, KeyPressEventArgs e)
+ {
+ // accept only '0', '1', ... , '9'
+ // 48 = '0', 57 = '9'
+ if (e.KeyChar < (char)48 || e.KeyChar > (char)57)
+ e.Handled = true;
+
+ TextChangedTextBoxes (sender);
+ }
+
+ // not working 100 %, S.W.F.TextBox isn't finished yet
+ void TextChangedTextBoxes (object sender)
+ {
+ if (((TextBox)sender).Text.Length == 0)
+ return;
+
+ int val;
+
+ if (sender == hueTextBox) {
+ val = System.Convert.ToInt32 (hueTextBox.Text);
+
+ if (val > 240) {
+ val = 240;
+ hueTextBox.Text = val.ToString ();
+ } else
+ if (val < 0) {
+ val = 0;
+ hueTextBox.Text = val.ToString ();
+ }
+
+ UpdateFromHSBTextBoxes ();
+
+ UpdateControls (selectedColorPanel.BackColor);
+ } else
+ if (sender == satTextBox) {
+ val = System.Convert.ToInt32 (satTextBox.Text);
+
+ if (val > 239) {
+ val = 239;
+ satTextBox.Text = val.ToString ();
+ } else
+ if (val < 0) {
+ val = 0;
+ satTextBox.Text = val.ToString ();
+ }
+
+ UpdateFromHSBTextBoxes ();
+
+ UpdateControls (selectedColorPanel.BackColor);
+ } else
+ if (sender == briTextBox) {
+ val = System.Convert.ToInt32 (briTextBox.Text);
+
+ if (val > 239) {
+ val = 239;
+ briTextBox.Text = val.ToString ();
+ } else
+ if (val < 0) {
+ val = 0;
+ briTextBox.Text = val.ToString ();
+ }
+
+ UpdateFromHSBTextBoxes ();
+
+ UpdateControls (selectedColorPanel.BackColor);
+ } else
+ if (sender == redTextBox) {
+ val = System.Convert.ToInt32 (redTextBox.Text);
+
+ if (val > 255) {
+ val = 255;
+ redTextBox.Text = val.ToString ();
+ } else
+ if (val < 0) {
+ val = 0;
+ redTextBox.Text = val.ToString ();
+ }
+
+ UpdateFromRGBTextBoxes ();
+ } else
+ if (sender == greenTextBox) {
+ val = System.Convert.ToInt32 (greenTextBox.Text);
+
+ if (val > 255) {
+ val = 255;
+ greenTextBox.Text = val.ToString ();
+ } else
+ if (val < 0) {
+ val = 0;
+ greenTextBox.Text = val.ToString ();
+ }
+
+ UpdateFromRGBTextBoxes ();
+ } else
+ if (sender == blueTextBox) {
+ val = System.Convert.ToInt32 (blueTextBox.Text);
+
+ if (val > 255) {
+ val = 255;
+ blueTextBox.Text = val.ToString ();
+ } else
+ if (val < 0) {
+ val = 0;
+ blueTextBox.Text = val.ToString ();
+ }
+
+ UpdateFromRGBTextBoxes ();
+ }
+ }
+
+ internal void UpdateControls (Color acolor)
+ {
+ selectedColorPanel.BackColor = acolor;
+ colorMatrixControl.ColorToShow = acolor;
+ brightnessControl.ColorToShow = acolor;
+ triangleControl.ColorToShow = acolor;
+ }
+
+ internal void UpdateRGBTextBoxes (Color acolor)
+ {
+ redTextBox.Text = acolor.R.ToString ();
+ greenTextBox.Text = acolor.G.ToString ();
+ blueTextBox.Text = acolor.B.ToString ();
+ }
+
+ internal void UpdateHSBTextBoxes (Color acolor)
+ {
+ HSB hsb = HSB.RGB2HSB (acolor);
+
+ hueTextBox.Text = hsb.hue.ToString ();
+ satTextBox.Text = hsb.sat.ToString ();
+ briTextBox.Text = hsb.bri.ToString ();
+ }
+
+ internal void UpdateFromHSBTextBoxes ()
+ {
+ Color col = HSB.HSB2RGB (System.Convert.ToInt32 (hueTextBox.Text),
+ System.Convert.ToInt32 (satTextBox.Text),
+ System.Convert.ToInt32 (briTextBox.Text));
+
+ selectedColorPanel.BackColor = col;
+ UpdateRGBTextBoxes (col);
+ }
+
+ internal void UpdateFromRGBTextBoxes ()
+ {
+ Color col = Color.FromArgb (System.Convert.ToInt32 (redTextBox.Text),
+ System.Convert.ToInt32 (greenTextBox.Text),
+ System.Convert.ToInt32 (blueTextBox.Text));
+
+ selectedColorPanel.BackColor = col;
+
+ UpdateHSBTextBoxes (col);
+
+ UpdateFromHSBTextBoxes ();
+
+ UpdateControls (col);
+ }
+ #endregion
+
+ #region Internal structs and classes
+ internal struct HSB {
+ public int hue;
+ public int sat;
+ public int bri;
+
+ public static HSB RGB2HSB (Color color)
+ {
+ HSB hsb = new HSB ();
+
+ hsb.hue = (int)((color.GetHue () / 360.0f) * 241);
+ hsb.sat = (int)(color.GetSaturation () * 241);
+ hsb.bri = (int)(color.GetBrightness () * 240);
+
+ if (hsb.hue > 240) hsb.hue = 240;
+ if (hsb.sat > 240) hsb.sat = 240;
+ if (hsb.bri > 239) hsb.bri = 239;
+
+ return hsb;
+ }
+
+ // not using ControlPaint HBS2Color, this algo is more precise
+ public static Color HSB2RGB (int hue, int saturation, int brightness)
+ {
+ if (hue > 240)
+ hue = 240;
+ else
+ if (hue < 0)
+ hue = 0;
+
+ if (saturation > 240)
+ saturation = 240;
+ else
+ if (saturation < 0)
+ saturation = 0;
+
+ if (brightness > 239)
+ brightness = 239;
+ else
+ if (brightness < 0)
+ brightness = 0;
+
+ float H = hue / 240.0f;
+ float S = saturation / 240.0f;
+ float L = brightness / 239.0f;
+
+ float r = 0, g = 0, b = 0;
+ float d1, d2;
+
+ if (L == 0) {
+ r = g = b = 0;
+ } else {
+ if (S == 0) {
+ r = g = b = L;
+ } else {
+ d2 = (L <= 0.5f) ? L * (1.0f + S) : L + S - (L * S);
+ d1 = 2.0f * L - d2;
+
+ float[] d3 = new float [] { H + 1.0f / 3.0f , H, H - 1.0f / 3.0f };
+ float[] rgb = new float [] { 0,0,0 };
+
+ for (int i = 0; i < 3; i++) {
+ if (d3 [i] < 0)
+ d3 [i] += 1.0f;
+ if (d3 [i] > 1.0f)
+ d3 [i] -= 1.0f;
+
+ if (6.0f * d3 [i] < 1.0f)
+ rgb [i] = d1 + (d2 - d1) * d3 [i] * 6.0f;
+ else
+ if (2.0f * d3 [i] < 1.0f)
+ rgb [i] = d2;
+ else
+ if (3.0f * d3 [i] < 2.0f)
+ rgb [i] = (d1 + (d2 - d1) * ((2.0f / 3.0f) - d3 [i]) * 6.0f);
+ else
+ rgb [i] = d1;
+ }
+
+ r = rgb [0];
+ g = rgb [1];
+ b = rgb [2];
+ }
+ }
+
+ r = 255.0f * r;
+ g = 255.0f * g;
+ b = 255.0f * b;
+
+ if (r < 1)
+ r = 0.0f;
+ else
+ if (r > 255.0f)
+ r = 255.0f;
+
+ if (g < 1)
+ g = 0.0f;
+ else
+ if (g > 255.0f)
+ g = 255.0f;
+
+ if (b < 1)
+ b = 0.0f;
+ else
+ if (b > 255.0f)
+ b = 255.0f;
+
+ return Color.FromArgb ((int)r, (int)g, (int)b);
+ }
+
+ public static int Brightness (Color color)
+ {
+ return (int)(color.GetBrightness () * 240);
+ }
+
+ public static void GetHueSaturation (Color color, out int hue, out int sat)
+ {
+ hue = (int)((color.GetHue () / 360.0f) * 241);
+ sat = (int)(color.GetSaturation () * 241);
+ }
+
+ // only for testing
+ // there are some small glitches, but it is still better than ControlPaint implementation
+ public static void TestColor (Color color)
+ {
+ Console.WriteLine ("Color: " + color);
+ HSB hsb = HSB.RGB2HSB (color);
+ Console.WriteLine ("RGB2HSB: " + hsb.hue + ", " + hsb.sat + ", " + hsb.bri);
+ Console.WriteLine ("HSB2RGB: " + HSB.HSB2RGB (hsb.hue, hsb.sat, hsb.bri));
+ Console.WriteLine ();
+ }
+ }
+
+ internal class BaseColorControl : Control {
+ internal class SmallColorControl : Control {
+ private Color internalcolor;
+
+ private bool isSelected = false;
+
+ public SmallColorControl (Color color)
+ {
+ SuspendLayout ();
+
+ this.internalcolor = color;
+
+ Size = new Size (25, 23);
+
+ ResumeLayout (false);
+
+ SetStyle (ControlStyles.DoubleBuffer, true);
+ SetStyle (ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle (ControlStyles.UserPaint, true);
+ SetStyle (ControlStyles.Selectable, true);
+ }
+
+ public bool IsSelected {
+ set {
+ isSelected = value;
+ Invalidate ();
+ }
+ }
+
+ public Color InternalColor {
+ set {
+ internalcolor = value;
+ Invalidate ();
+ }
+
+ get {
+ return internalcolor;
+ }
+ }
+
+ protected override void OnPaint (PaintEventArgs pe)
+ {
+ base.OnPaint (pe);
+
+// pe.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (BackColor), 0, 0, 26, 23);
+
+ pe.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (internalcolor),
+ new Rectangle (4, 4, 17, 15));
+
+ DrawBorder (pe.Graphics, new Rectangle (4, 4, 17, 15));
+
+ if (isSelected) {
+ pe.Graphics.DrawRectangle (ThemeEngine.Current.ResPool.GetPen (Color.Black),
+ new Rectangle (2, 2, 20, 18));
+ }
+
+ if (Focused) {
+ ControlPaint.DrawFocusRectangle (
+ pe.Graphics, new Rectangle (0, 0, 25, 23)
+ );
+ }
+ }
+
+ protected override void OnClick (EventArgs e)
+ {
+ Focus ();
+ IsSelected = true;
+
+ base.OnClick (e);
+ }
+
+
+ protected override void OnLostFocus (EventArgs e)
+ {
+ Invalidate ();
+
+ base.OnLostFocus (e);
+ }
+
+ private void DrawBorder (Graphics dc, Rectangle rect)
+ {
+ Pen pen = ThemeEngine.Current.ResPool.GetPen (Color.Black);
+ dc.DrawLine (pen, rect.X, rect.Y, rect.X, rect.Bottom - 1);
+ dc.DrawLine (pen, rect.X + 1, rect.Y, rect.Right - 1, rect.Y);
+ }
+ }
+
+ private SmallColorControl[] smallColorControl;
+
+ private SmallColorControl[] userSmallColorControl;
+
+ private Label userColorLabel;
+ private Label baseColorLabel;
+
+ private SmallColorControl selectedSmallColorControl;
+
+ private int currentlyUsedUserSmallColorControl = 0;
+ private int[] customColors = null;
+
+ private ColorDialog colorDialog = null;
+
+ public BaseColorControl (ColorDialog colorDialog)
+ {
+ this.colorDialog = colorDialog;
+
+ userSmallColorControl = new SmallColorControl [16];
+ userSmallColorControl [0] = new SmallColorControl (Color.White);
+ userSmallColorControl [1] = new SmallColorControl (Color.White);
+ userSmallColorControl [2] = new SmallColorControl (Color.White);
+ userSmallColorControl [3] = new SmallColorControl (Color.White);
+ userSmallColorControl [4] = new SmallColorControl (Color.White);
+ userSmallColorControl [5] = new SmallColorControl (Color.White);
+ userSmallColorControl [6] = new SmallColorControl (Color.White);
+ userSmallColorControl [7] = new SmallColorControl (Color.White);
+ userSmallColorControl [8] = new SmallColorControl (Color.White);
+ userSmallColorControl [9] = new SmallColorControl (Color.White);
+ userSmallColorControl [10] = new SmallColorControl (Color.White);
+ userSmallColorControl [11] = new SmallColorControl (Color.White);
+ userSmallColorControl [12] = new SmallColorControl (Color.White);
+ userSmallColorControl [13] = new SmallColorControl (Color.White);
+ userSmallColorControl [14] = new SmallColorControl (Color.White);
+ userSmallColorControl [15] = new SmallColorControl (Color.White);
+
+ smallColorControl = new SmallColorControl [48];
+ smallColorControl [0] = new SmallColorControl (Color.FromArgb (((Byte)(255)), ((Byte)(128)), ((Byte)(138))));
+ smallColorControl [1] = new SmallColorControl (Color.FromArgb (((Byte)(128)), ((Byte)(128)), ((Byte)(64))));
+ smallColorControl [2] = new SmallColorControl (Color.Gray);
+ smallColorControl [3] = new SmallColorControl (Color.FromArgb (((Byte)(128)), ((Byte)(0)), ((Byte)(255))));
+ smallColorControl [4] = new SmallColorControl (Color.Silver);
+ smallColorControl [5] = new SmallColorControl (Color.FromArgb (((Byte)(64)), ((Byte)(128)), ((Byte)(128))));
+ smallColorControl [6] = new SmallColorControl (Color.White);
+ smallColorControl [7] = new SmallColorControl (Color.FromArgb (((Byte)(64)), ((Byte)(0)), ((Byte)(64))));
+ smallColorControl [8] = new SmallColorControl (Color.FromArgb (((Byte)(255)), ((Byte)(128)), ((Byte)(64))));
+ smallColorControl [9] = new SmallColorControl (Color.FromArgb (((Byte)(128)), ((Byte)(64)), ((Byte)(64))));
+ smallColorControl [10] = new SmallColorControl (Color.Teal);
+ smallColorControl [11] = new SmallColorControl (Color.Lime);
+ smallColorControl [12] = new SmallColorControl (Color.FromArgb (((Byte)(128)), ((Byte)(128)), ((Byte)(255))));
+ smallColorControl [13] = new SmallColorControl (Color.FromArgb (((Byte)(0)), ((Byte)(64)), ((Byte)(128))));
+ smallColorControl [14] = new SmallColorControl (Color.FromArgb (((Byte)(255)), ((Byte)(0)), ((Byte)(128))));
+ smallColorControl [15] = new SmallColorControl (Color.FromArgb (((Byte)(128)), ((Byte)(255)), ((Byte)(0))));
+ smallColorControl [16] = new SmallColorControl (Color.FromArgb (((Byte)(0)), ((Byte)(255)), ((Byte)(64))));
+ smallColorControl [17] = new SmallColorControl (Color.Red);
+ smallColorControl [18] = new SmallColorControl (Color.FromArgb (((Byte)(255)), ((Byte)(128)), ((Byte)(0))));
+ smallColorControl [19] = new SmallColorControl (Color.FromArgb (((Byte)(255)), ((Byte)(128)), ((Byte)(255))));
+ smallColorControl [20] = new SmallColorControl (Color.Fuchsia);
+ smallColorControl [21] = new SmallColorControl (Color.Aqua);
+ smallColorControl [22] = new SmallColorControl (Color.FromArgb (((Byte)(128)), ((Byte)(255)), ((Byte)(128))));
+ smallColorControl [23] = new SmallColorControl (Color.FromArgb (((Byte)(128)), ((Byte)(255)), ((Byte)(255))));
+ smallColorControl [24] = new SmallColorControl (Color.FromArgb (((Byte)(0)), ((Byte)(128)), ((Byte)(255))));
+ smallColorControl [25] = new SmallColorControl (Color.FromArgb (((Byte)(128)), ((Byte)(64)), ((Byte)(0))));
+ smallColorControl [26] = new SmallColorControl (Color.FromArgb (((Byte)(64)), ((Byte)(0)), ((Byte)(0))));
+ smallColorControl [27] = new SmallColorControl (Color.Maroon);
+ smallColorControl [28] = new SmallColorControl (Color.Purple);
+ smallColorControl [29] = new SmallColorControl (Color.FromArgb (((Byte)(0)), ((Byte)(0)), ((Byte)(160))));
+ smallColorControl [30] = new SmallColorControl (Color.Blue);
+ smallColorControl [31] = new SmallColorControl (Color.FromArgb (((Byte)(0)), ((Byte)(128)), ((Byte)(64))));
+ smallColorControl [32] = new SmallColorControl (Color.Green);
+ smallColorControl [33] = new SmallColorControl (Color.Yellow);
+ smallColorControl [34] = new SmallColorControl (Color.FromArgb (((Byte)(128)), ((Byte)(128)), ((Byte)(192))));
+ smallColorControl [35] = new SmallColorControl (Color.FromArgb (((Byte)(0)), ((Byte)(128)), ((Byte)(192))));
+ smallColorControl [36] = new SmallColorControl (Color.FromArgb (((Byte)(128)), ((Byte)(0)), ((Byte)(64))));
+ smallColorControl [37] = new SmallColorControl (Color.FromArgb (((Byte)(255)), ((Byte)(128)), ((Byte)(192))));
+ smallColorControl [38] = new SmallColorControl (Color.FromArgb (((Byte)(0)), ((Byte)(255)), ((Byte)(128))));
+ smallColorControl [39] = new SmallColorControl (Color.FromArgb (((Byte)(255)), ((Byte)(255)), ((Byte)(128))));
+ smallColorControl [40] = new SmallColorControl (Color.FromArgb (((Byte)(0)), ((Byte)(64)), ((Byte)(0))));
+ smallColorControl [41] = new SmallColorControl (Color.FromArgb (((Byte)(0)), ((Byte)(64)), ((Byte)(64))));
+ smallColorControl [42] = new SmallColorControl (Color.Navy);
+ smallColorControl [43] = new SmallColorControl (Color.FromArgb (((Byte)(0)), ((Byte)(0)), ((Byte)(64))));
+ smallColorControl [44] = new SmallColorControl (Color.FromArgb (((Byte)(64)), ((Byte)(0)), ((Byte)(64))));
+ smallColorControl [45] = new SmallColorControl (Color.FromArgb (((Byte)(64)), ((Byte)(0)), ((Byte)(128))));
+ smallColorControl [46] = new SmallColorControl (Color.Black); //Black
+ smallColorControl [47] = new SmallColorControl (Color.Olive);
+
+ baseColorLabel = new Label ();
+ userColorLabel = new Label ();
+
+ SuspendLayout ();
+
+ // colorPanel1
+ smallColorControl [0].Location = new Point (0, 15);
+ smallColorControl [0].TabIndex = 51;
+ smallColorControl [0].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel2
+ smallColorControl [1].Location = new Point (50, 130);
+ smallColorControl [1].TabIndex = 92;
+ smallColorControl [1].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel3
+ smallColorControl [2].Location = new Point (75, 130);
+ smallColorControl [2].TabIndex = 93;
+ smallColorControl [2].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel4
+ smallColorControl [3].Location = new Point (175, 84);
+ smallColorControl [3].TabIndex = 98;
+ smallColorControl [3].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel5
+ smallColorControl [4].Location = new Point (125, 130);
+ smallColorControl [4].TabIndex = 95;
+ smallColorControl [4].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel6
+ smallColorControl [5].Location = new Point (100, 130);
+ smallColorControl [5].TabIndex = 94;
+ smallColorControl [5].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel7
+ smallColorControl [6].Location = new Point (175, 130);
+ smallColorControl [6].TabIndex = 97;
+ smallColorControl [6].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel8
+ smallColorControl [7].Location = new Point (150, 130);
+ smallColorControl [7].TabIndex = 96;
+ smallColorControl [7].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel9
+ smallColorControl [8].Location = new Point (25, 61);
+ smallColorControl [8].TabIndex = 68;
+ smallColorControl [8].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel10
+ smallColorControl [9].Location = new Point (0, 61);
+ smallColorControl [9].TabIndex = 67;
+ smallColorControl [9].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel11
+ smallColorControl [10].Location = new Point (75, 61);
+ smallColorControl [10].TabIndex = 70;
+ smallColorControl [10].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel12
+ smallColorControl [11].Location = new Point (50, 61);
+ smallColorControl [11].TabIndex = 69;
+ smallColorControl [11].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel13
+ smallColorControl [12].Location = new Point (125, 61);
+ smallColorControl [12].TabIndex = 72;
+ smallColorControl [12].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel14
+ smallColorControl [13].Location = new Point (100, 61);
+ smallColorControl [13].TabIndex = 71;
+ smallColorControl [13].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel15
+ smallColorControl [14].Location = new Point (175, 61);
+ smallColorControl [14].TabIndex = 74;
+ smallColorControl [14].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel16
+ smallColorControl [15].Location = new Point (50, 38);
+ smallColorControl [15].TabIndex = 61;
+ smallColorControl [15].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel17
+ smallColorControl [16].Location = new Point (75, 38);
+ smallColorControl [16].TabIndex = 62;
+ smallColorControl [16].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel18
+ smallColorControl [17].Location = new Point (0, 38);
+ smallColorControl [17].TabIndex = 59;
+ smallColorControl [17].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel19
+ smallColorControl [18].Location = new Point (25, 84);
+ smallColorControl [18].TabIndex = 75;
+ smallColorControl [18].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel20
+ smallColorControl [19].Location = new Point (175, 15);
+ smallColorControl [19].TabIndex = 58;
+ smallColorControl [19].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel21
+ smallColorControl [20].Location = new Point (175, 38);
+ smallColorControl [20].TabIndex = 66;
+ smallColorControl [20].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel22
+ smallColorControl [21].Location = new Point (100, 38);
+ smallColorControl [21].TabIndex = 63;
+ smallColorControl [21].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel23
+ smallColorControl [22].Location = new Point (50, 15);
+ smallColorControl [22].TabIndex = 53;
+ smallColorControl [22].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel24
+ smallColorControl [23].Location = new Point (100, 15);
+ smallColorControl [23].TabIndex = 55;
+ smallColorControl [23].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel25
+ smallColorControl [24].Location = new Point (125, 15);
+ smallColorControl [24].TabIndex = 56;
+ smallColorControl [24].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel26
+ smallColorControl [25].Location = new Point (25, 107);
+ smallColorControl [25].TabIndex = 83;
+ smallColorControl [25].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel27
+ smallColorControl [26].Location = new Point (0, 107);
+ smallColorControl [26].TabIndex = 82;
+ smallColorControl [26].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel28
+ smallColorControl [27].Location = new Point (0, 84);
+ smallColorControl [27].TabIndex = 81;
+ smallColorControl [27].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel29
+ smallColorControl [28].Location = new Point (150, 84);
+ smallColorControl [28].TabIndex = 80;
+ smallColorControl [28].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel30
+ smallColorControl [29].Location = new Point (125, 84);
+ smallColorControl [29].TabIndex = 79;
+ smallColorControl [29].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel31
+ smallColorControl [30].Location = new Point (100, 84);
+ smallColorControl [30].TabIndex = 78;
+ smallColorControl [30].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel32
+ smallColorControl [31].Location = new Point (75, 84);
+ smallColorControl [31].TabIndex = 77;
+ smallColorControl [31].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel33
+ smallColorControl [32].Location = new Point (50, 84);
+ smallColorControl [32].TabIndex = 76;
+ smallColorControl [32].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel34
+ smallColorControl [33].Location = new Point (25, 38);
+ smallColorControl [33].TabIndex = 60;
+ smallColorControl [33].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel35
+ smallColorControl [34].Location = new Point (150, 38);
+ smallColorControl [34].TabIndex = 65;
+ smallColorControl [34].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel36
+ smallColorControl [35].Location = new Point (125, 38);
+ smallColorControl [35].TabIndex = 64;
+ smallColorControl [35].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel37
+ smallColorControl [36].Location = new Point (150, 61);
+ smallColorControl [36].TabIndex = 73;
+ smallColorControl [36].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel38
+ smallColorControl [37].Location = new Point (150, 15);
+ smallColorControl [37].TabIndex = 57;
+ smallColorControl [37].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel39
+ smallColorControl [38].Location = new Point (75, 15);
+ smallColorControl [38].TabIndex = 54;
+ smallColorControl [38].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel40
+ smallColorControl [39].Location = new Point (25, 15);
+ smallColorControl [39].TabIndex = 52;
+ smallColorControl [39].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel41
+ smallColorControl [40].Location = new Point (50, 107);
+ smallColorControl [40].TabIndex = 84;
+ smallColorControl [40].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel42
+ smallColorControl [41].Location = new Point (75, 107);
+ smallColorControl [41].TabIndex = 85;
+ smallColorControl [41].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel43
+ smallColorControl [42].Location = new Point (100, 107);
+ smallColorControl [42].TabIndex = 86;
+ smallColorControl [42].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel44
+ smallColorControl [43].Location = new Point (125, 107);
+ smallColorControl [43].TabIndex = 87;
+ smallColorControl [43].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel45
+ smallColorControl [44].Location = new Point (150, 107);
+ smallColorControl [44].TabIndex = 88;
+ smallColorControl [44].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel46
+ smallColorControl [45].Location = new Point (175, 107);
+ smallColorControl [45].TabIndex = 89;
+ smallColorControl [45].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel47
+ smallColorControl [46].Location = new Point (0, 130);
+ smallColorControl [46].TabIndex = 90;
+ smallColorControl [46].Click += new EventHandler (OnSmallColorControlClick);
+ // colorPanel48
+ smallColorControl [47].Location = new Point (25, 130);
+ smallColorControl [47].TabIndex = 91;
+ smallColorControl [47].Click += new EventHandler (OnSmallColorControlClick);
+
+ // userColorPane1
+ userSmallColorControl [0].Location = new Point (0, 180);
+ userSmallColorControl [0].TabIndex = 99;
+ userSmallColorControl [0].Click += new EventHandler (OnSmallColorControlClick);
+ // userColorPanel2
+ userSmallColorControl [1].Location = new Point (0, 203);
+ userSmallColorControl [1].TabIndex = 108;
+ userSmallColorControl [1].Click += new EventHandler (OnSmallColorControlClick);
+ // userColorPanel13
+ userSmallColorControl [2].Location = new Point (25, 180);
+ userSmallColorControl [2].TabIndex = 100;
+ userSmallColorControl [2].Click += new EventHandler (OnSmallColorControlClick);
+ // userColorPanel4
+ userSmallColorControl [3].Location = new Point (25, 203);
+ userSmallColorControl [3].TabIndex = 109;
+ userSmallColorControl [3].Click += new EventHandler (OnSmallColorControlClick);
+ // userColorPanel5
+ userSmallColorControl [4].Location = new Point (50, 180);
+ userSmallColorControl [4].TabIndex = 101;
+ userSmallColorControl [4].Click += new EventHandler (OnSmallColorControlClick);
+ // userColorPanel6
+ userSmallColorControl [5].Location = new Point (50, 203);
+ userSmallColorControl [5].TabIndex = 110;
+ userSmallColorControl [5].Click += new EventHandler (OnSmallColorControlClick);
+ // userColorPanel7
+ userSmallColorControl [6].Location = new Point (75, 180);
+ userSmallColorControl [6].TabIndex = 102;
+ userSmallColorControl [6].Click += new EventHandler (OnSmallColorControlClick);
+ // userColorPanel8
+ userSmallColorControl [7].Location = new Point (75, 203);
+ userSmallColorControl [7].TabIndex = 111;
+ userSmallColorControl [7].Click += new EventHandler (OnSmallColorControlClick);
+ // userColorPanel9
+ userSmallColorControl [8].Location = new Point (100, 180);
+ userSmallColorControl [8].TabIndex = 103;
+ userSmallColorControl [8].Click += new EventHandler (OnSmallColorControlClick);
+ // userColorPanel10
+ userSmallColorControl [9].Location = new Point (100, 203);
+ userSmallColorControl [9].TabIndex = 112;
+ userSmallColorControl [9].Click += new EventHandler (OnSmallColorControlClick);
+ // userColorPanel11
+ userSmallColorControl [10].Location = new Point (125, 180);
+ userSmallColorControl [10].TabIndex = 105;
+ userSmallColorControl [10].Click += new EventHandler (OnSmallColorControlClick);
+ // userColorPanel2
+ userSmallColorControl [11].Location = new Point (125, 203);
+ userSmallColorControl [11].TabIndex = 113;
+ userSmallColorControl [11].Click += new EventHandler (OnSmallColorControlClick);
+ // userColorPanel13
+ userSmallColorControl [12].Location = new Point (150, 180);
+ userSmallColorControl [12].TabIndex = 106;
+ userSmallColorControl [12].Click += new EventHandler (OnSmallColorControlClick);
+ // userColorPanel4
+ userSmallColorControl [13].Location = new Point (150, 203);
+ userSmallColorControl [13].TabIndex = 114;
+ userSmallColorControl [13].Click += new EventHandler (OnSmallColorControlClick);
+ // userColorPanel15
+ userSmallColorControl [14].Location = new Point (175, 180);
+ userSmallColorControl [14].TabIndex = 107;
+ userSmallColorControl [14].Click += new EventHandler (OnSmallColorControlClick);
+ // userColorPanel16
+ userSmallColorControl [15].Location = new Point (175, 203);
+ userSmallColorControl [15].TabIndex = 115;
+ userSmallColorControl [15].Click += new EventHandler (OnSmallColorControlClick);
+
+ // baseColorLabel
+ baseColorLabel.Location = new Point (2, 0);
+ baseColorLabel.Size = new Size (200, 12);
+ baseColorLabel.TabIndex = 5;
+ baseColorLabel.Text = Locale.GetText ("Base Colours") + ":";
+ // userColorLabel
+ userColorLabel.FlatStyle = FlatStyle.System;
+ userColorLabel.Location = new Point (2, 164);
+ userColorLabel.Size = new Size (200, 14);
+ userColorLabel.TabIndex = 104;
+ userColorLabel.Text = Locale.GetText ("User Colors") + ":";
+
+ Controls.Add (userSmallColorControl [7]);
+ Controls.Add (userSmallColorControl [6]);
+ Controls.Add (userSmallColorControl [5]);
+ Controls.Add (userSmallColorControl [4]);
+ Controls.Add (userSmallColorControl [3]);
+ Controls.Add (userSmallColorControl [2]);
+ Controls.Add (userSmallColorControl [1]);
+ Controls.Add (userSmallColorControl [0]);
+ Controls.Add (userSmallColorControl [15]);
+ Controls.Add (userSmallColorControl [14]);
+ Controls.Add (userSmallColorControl [13]);
+ Controls.Add (userSmallColorControl [12]);
+ Controls.Add (userSmallColorControl [11]);
+ Controls.Add (userSmallColorControl [10]);
+ Controls.Add (userSmallColorControl [9]);
+ Controls.Add (userSmallColorControl [8]);
+
+ Controls.Add (smallColorControl [0]);
+ Controls.Add (smallColorControl [3]);
+ Controls.Add (smallColorControl [6]);
+ Controls.Add (smallColorControl [7]);
+ Controls.Add (smallColorControl [4]);
+ Controls.Add (smallColorControl [5]);
+ Controls.Add (smallColorControl [2]);
+ Controls.Add (smallColorControl [1]);
+ Controls.Add (smallColorControl [47]);
+ Controls.Add (smallColorControl [46]);
+ Controls.Add (smallColorControl [45]);
+ Controls.Add (smallColorControl [44]);
+ Controls.Add (smallColorControl [43]);
+ Controls.Add (smallColorControl [42]);
+ Controls.Add (smallColorControl [41]);
+ Controls.Add (smallColorControl [40]);
+ Controls.Add (smallColorControl [25]);
+ Controls.Add (smallColorControl [26]);
+ Controls.Add (smallColorControl [27]);
+ Controls.Add (smallColorControl [28]);
+ Controls.Add (smallColorControl [29]);
+ Controls.Add (smallColorControl [30]);
+ Controls.Add (smallColorControl [31]);
+ Controls.Add (smallColorControl [32]);
+ Controls.Add (smallColorControl [18]);
+ Controls.Add (smallColorControl [14]);
+ Controls.Add (smallColorControl [36]);
+ Controls.Add (smallColorControl [12]);
+ Controls.Add (smallColorControl [13]);
+ Controls.Add (smallColorControl [10]);
+ Controls.Add (smallColorControl [11]);
+ Controls.Add (smallColorControl [8]);
+ Controls.Add (smallColorControl [9]);
+ Controls.Add (smallColorControl [20]);
+ Controls.Add (smallColorControl [34]);
+ Controls.Add (smallColorControl [35]);
+ Controls.Add (smallColorControl [21]);
+ Controls.Add (smallColorControl [16]);
+ Controls.Add (smallColorControl [15]);
+ Controls.Add (smallColorControl [33]);
+ Controls.Add (smallColorControl [17]);
+ Controls.Add (smallColorControl [19]);
+ Controls.Add (smallColorControl [37]);
+ Controls.Add (smallColorControl [24]);
+ Controls.Add (smallColorControl [23]);
+ Controls.Add (smallColorControl [38]);
+ Controls.Add (smallColorControl [22]);
+ Controls.Add (smallColorControl [39]);
+
+ Controls.Add (userColorLabel);
+ Controls.Add (baseColorLabel);
+
+ Size = new Size (212, 238);
+
+ ResumeLayout (false);
+ }
+
+ private void CheckIfColorIsInPanel (Color color)
+ {
+ // check if we have a panel with a BackColor = color...
+ for (int i = 0; i < smallColorControl.Length; i++) {
+ if (smallColorControl [i].InternalColor == color) {
+ selectedSmallColorControl = smallColorControl [i];
+ selectedSmallColorControl.IsSelected = true;
+ break;
+ }
+ }
+ }
+
+ void OnSmallColorControlClick (object sender, EventArgs e)
+ {
+ // previous selected smallcolorcontrol
+ if (selectedSmallColorControl != (SmallColorControl)sender)
+ selectedSmallColorControl.IsSelected = false;
+
+ selectedSmallColorControl = (SmallColorControl)sender;
+
+ TriangleControl.CurrentBrightness = HSB.Brightness (selectedSmallColorControl.InternalColor);
+
+ colorDialog.UpdateControls (selectedSmallColorControl.InternalColor);
+ colorDialog.UpdateRGBTextBoxes (selectedSmallColorControl.InternalColor);
+ colorDialog.UpdateHSBTextBoxes (selectedSmallColorControl.InternalColor);
+ }
+
+ public Color ColorToShow {
+ get {
+ return selectedSmallColorControl.InternalColor;
+ }
+ }
+
+
+ public void SetColor (Color acolor)
+ {
+ if (selectedSmallColorControl != null)
+ selectedSmallColorControl.IsSelected = false;
+
+ CheckIfColorIsInPanel (acolor);
+
+ TriangleControl.CurrentBrightness = HSB.Brightness (acolor);
+
+ colorDialog.UpdateControls (acolor);
+ colorDialog.UpdateRGBTextBoxes (acolor);
+ colorDialog.UpdateHSBTextBoxes (acolor);
+ }
+
+ public void SetUserColor (Color col)
+ {
+ userSmallColorControl [currentlyUsedUserSmallColorControl].InternalColor = col;
+
+ // check if this.customColors already exists
+ if (customColors == null) {
+ customColors = new int [16];
+ int white = Color.White.ToArgb ();
+
+ for (int i = 0; i < customColors.Length; i++)
+ customColors [i] = white;
+ }
+
+ customColors [currentlyUsedUserSmallColorControl] = col.ToArgb ();
+
+ // update ColorDialog dialog property
+ colorDialog.CustomColors = customColors;
+
+ currentlyUsedUserSmallColorControl++;
+ if (currentlyUsedUserSmallColorControl > 15)
+ currentlyUsedUserSmallColorControl = 0;
+ }
+
+ public void SetCustomColors ()
+ {
+ int[] customColors = colorDialog.CustomColors;
+
+ if (customColors != null) {
+ for (int i = 0; i < customColors.Length; i++) {
+ userSmallColorControl [i].InternalColor = Color.FromArgb (customColors [i]);
+ }
+ } else {
+ for (int i = 0; i < userSmallColorControl.Length; i++) {
+ userSmallColorControl [i].InternalColor = Color.White;
+ }
+ }
+ }
+ }
+
+ internal class ColorMatrixControl : Panel {
+ internal class DrawingBitmap {
+ private Bitmap bitmap;
+
+ public DrawingBitmap (Size size)
+ {
+ bitmap = new Bitmap (size.Width, size.Height);
+
+ float hueadd = 241.0f / (size.Width - 1);
+ float satsub = 241.0f / (size.Height - 1);
+ float satpos = 240.0f;
+
+ // paint the matrix to the bitmap
+ for (int height = 0; height < size.Height; height++) {
+ float huepos = 0.0f;
+
+ for (int width = 0; width < size.Width; width++) {
+ HSB hsb = new HSB ();
+
+ hsb.hue = (int)huepos;
+ hsb.sat = (int)satpos;
+ hsb.bri = 120; // paint it with 120 to get a nice bitmap
+
+ bitmap.SetPixel (width, height, HSB.HSB2RGB (hsb.hue, hsb.sat, hsb.bri));
+
+ huepos += hueadd;
+ }
+
+ satpos -= satsub;
+ }
+ }
+
+ public Bitmap Bitmap {
+ set {
+ bitmap = value;
+ }
+
+ get {
+ return bitmap;
+ }
+ }
+ }
+
+ internal class CrossCursor {
+ private Bitmap bitmap;
+
+ private Color cursorColor;
+
+ public CrossCursor ()
+ {
+ bitmap = new Bitmap (22, 22);
+
+ cursorColor = Color.Black;
+
+ Draw ();
+ }
+
+ public void Draw ()
+ {
+ using (Pen pen = new Pen (ThemeEngine.Current.ResPool.GetSolidBrush (cursorColor), 3)) {
+ using (Graphics graphics = Graphics.FromImage (bitmap)) {
+ graphics.DrawLine (pen, 11, 0, 11, 7);
+ graphics.DrawLine (pen, 11, 14, 11, 21);
+ graphics.DrawLine (pen, 0, 11, 7, 11);
+ graphics.DrawLine (pen, 14, 11, 21, 11);
+ }
+ }
+ }
+
+ public Bitmap Bitmap {
+ set {
+ bitmap = value;
+ }
+
+ get {
+ return bitmap;
+ }
+ }
+
+ public Color CursorColor {
+ set {
+ cursorColor = value;
+ }
+
+ get {
+ return cursorColor;
+ }
+ }
+ }
+
+ private DrawingBitmap drawingBitmap = null;
+
+ private CrossCursor crossCursor = new CrossCursor();
+
+ private bool mouseButtonDown = false;
+
+ private bool drawCross = true;
+
+ private Color color;
+
+ private int currentXPos;
+ private int currentYPos;
+
+ private float xstep;
+ private float ystep;
+
+ private ColorDialog colorDialog;
+
+ public ColorMatrixControl (ColorDialog colorDialog)
+ {
+ this.colorDialog = colorDialog;
+
+ SuspendLayout ();
+
+ BorderStyle = BorderStyle.Fixed3D;
+ Location = new Point (0, 0);
+ Size = new Size (179, 190);
+ TabIndex = 0;
+ TabStop = false;
+
+ ResumeLayout (false);
+
+ xstep = 241.0f / (ClientSize.Width - 1);
+ ystep = 241.0f / (ClientSize.Height - 1);
+
+ SetStyle (ControlStyles.DoubleBuffer, true);
+ SetStyle (ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle (ControlStyles.UserPaint, true);
+ }
+
+ protected override void OnPaint (PaintEventArgs e)
+ {
+ if (drawingBitmap == null)
+ drawingBitmap = new DrawingBitmap (ClientSize);
+
+ Draw (e);
+
+ base.OnPaint (e);
+ }
+
+ private void Draw (PaintEventArgs e)
+ {
+ e.Graphics.DrawImage (drawingBitmap.Bitmap, ClientRectangle.X, ClientRectangle.Y);
+
+ // drawCross is false if the mouse gets moved...
+ if (drawCross) {
+ e.Graphics.DrawImage (crossCursor.Bitmap, currentXPos - 11 , currentYPos - 11);
+ }
+ }
+
+ protected override void OnMouseDown (MouseEventArgs e)
+ {
+ mouseButtonDown = true;
+ currentXPos = e.X;
+ currentYPos = e.Y;
+ if (drawCross) {
+ drawCross = false;
+ Invalidate ();
+ Update ();
+ }
+
+ UpdateControls ();
+
+ base.OnMouseDown (e);
+ }
+
+ protected override void OnMouseMove (MouseEventArgs e)
+ {
+ if (mouseButtonDown)
+ if ((e.X < ClientSize.Width && e.X >= 0) && (e.Y < ClientSize.Height && e.Y >= 0)) {
+ currentXPos = e.X;
+ currentYPos = e.Y;
+ UpdateControls ();
+ }
+
+ base.OnMouseMove (e);
+ }
+
+ protected override void OnMouseUp (MouseEventArgs e)
+ {
+ mouseButtonDown = false;
+ drawCross = true;
+ Invalidate ();
+ Update ();
+ }
+
+ public Color ColorToShow {
+ set {
+ ComputePos (value);
+ }
+ }
+
+ private void ComputePos (Color acolor)
+ {
+ if (acolor != color) {
+ color = acolor;
+
+ HSB hsb = HSB.RGB2HSB (color);
+
+ currentXPos = (int)((float)hsb.hue / xstep);
+ currentYPos = ClientSize.Height - 1 - (int)((float)hsb.sat / ystep);
+
+ if (currentXPos < 0)
+ currentXPos = 0;
+ if (currentYPos < 0)
+ currentYPos = 0;
+
+ Invalidate ();
+ Update ();
+ }
+ }
+
+ private Color GetColorFromHSB ()
+ {
+ int hue = (int)((float)currentXPos * xstep);
+ int sat = 240 - ((int)((float)currentYPos * ystep));
+ int bri = TriangleControl.CurrentBrightness;
+
+ return HSB.HSB2RGB (hue, sat, bri);
+ }
+
+ private void UpdateControls ()
+ {
+ Color tmpColor = GetColorFromHSB ();
+
+ // update the brightness control
+ colorDialog.brightnessControl.ShowColor ((int)((float)currentXPos * xstep), 240 - ((int)((float)currentYPos * ystep)));
+
+ // update saturation text box
+ int satvalue = (240 - ((int)((float)currentYPos * ystep)));
+ colorDialog.satTextBox.Text = satvalue.ToString ();
+
+ // update hue text box
+ colorDialog.hueTextBox.Text = ((int)((float)currentXPos * xstep)).ToString ();
+
+ // update the main selected color panel
+ colorDialog.selectedColorPanel.BackColor = tmpColor;
+
+ // and finally the rgb text boxes
+ colorDialog.UpdateRGBTextBoxes (tmpColor);
+ }
+ }
+
+
+ internal class BrightnessControl : Panel {
+ internal class DrawingBitmap {
+ private Bitmap bitmap;
+
+ public DrawingBitmap ()
+ {
+ bitmap = new Bitmap (14, 190);
+ }
+
+ public Bitmap Bitmap {
+ set {
+ bitmap = value;
+ }
+
+ get {
+ return bitmap;
+ }
+ }
+
+ // only hue and saturation are needed.
+ // color will be computed with an iteration
+ public void Draw (int hue, int sat)
+ {
+ float brisub = 240.0f / 190.0f;
+ float bri = 240.0f;
+
+ for (int height = 0; height < 190; height++) {
+ for (int width = 0; width < 14; width++) {
+ Color pixcolor = HSB.HSB2RGB (hue, sat, (int)bri);
+ bitmap.SetPixel (width, height, pixcolor);
+ }
+ bri = bri - brisub;
+ }
+ }
+ }
+
+ private const float step = 240.0f/189.0f;
+
+ private DrawingBitmap bitmap;
+
+ private ColorDialog colorDialog = null;
+
+ public BrightnessControl (ColorDialog colorDialog)
+ {
+ this.colorDialog = colorDialog;
+
+ bitmap = new DrawingBitmap ();
+
+ SuspendLayout ();
+
+ BorderStyle = BorderStyle.Fixed3D;
+ Location = new Point (0, 0);
+ Size = new Size (14, 190);
+ TabIndex = 0;
+ TabStop = false;
+ Size = new Size (14, 190);
+
+ ResumeLayout (false);
+
+ SetStyle (ControlStyles.DoubleBuffer, true);
+ SetStyle (ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle (ControlStyles.UserPaint, true);
+ }
+
+
+ protected override void OnPaint (PaintEventArgs e)
+ {
+ e.Graphics.DrawImage (bitmap.Bitmap, 0, 0);
+
+ base.OnPaint (e);
+ }
+
+ protected override void OnMouseDown (MouseEventArgs e)
+ {
+ colorDialog.triangleControl.TrianglePosition = (int)((float)(189 - e.Y) * step);
+
+ base.OnMouseDown (e);
+ }
+
+ // this one is for ColorMatrixControl
+ public void ShowColor (int hue, int sat)
+ {
+ bitmap.Draw (hue, sat);
+ Invalidate ();
+ Update ();
+ }
+
+ // this one for the other controls
+ public Color ColorToShow {
+ set {
+ int hue, sat;
+ HSB.GetHueSaturation (value, out hue, out sat);
+ bitmap.Draw (hue, sat);
+ Invalidate ();
+ Update ();
+ }
+ }
+ }
+
+
+ internal class TriangleControl : Panel {
+ private bool mouseButtonDown = false;
+
+ private int currentTrianglePosition = 195;
+// private Rectangle clipRectangle;
+
+ private const float briStep = 239.0f/186.0f;
+
+ private static int currentBrightness = 0;
+
+ private ColorDialog colorDialog;
+
+ public TriangleControl (ColorDialog colorDialog)
+ {
+ this.colorDialog = colorDialog;
+
+ SuspendLayout ();
+
+ Size = new Size (16, 203);
+
+ ResumeLayout (false);
+
+ SetStyle (ControlStyles.DoubleBuffer, true);
+ SetStyle (ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle (ControlStyles.UserPaint, true);
+ }
+
+ public static int CurrentBrightness {
+ set {
+ currentBrightness = value;
+ }
+
+ get {
+ return currentBrightness;
+ }
+ }
+
+ protected override void OnPaint (PaintEventArgs e)
+ {
+ Draw (e);
+
+ base.OnPaint (e);
+ }
+
+ private void Draw (PaintEventArgs e)
+ {
+ e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (BackColor), new Rectangle (0, 0, 16, 203));
+
+ Point[] trianglePoints = new Point [3]
+ {
+ new Point (0, currentTrianglePosition),
+ new Point (8, currentTrianglePosition - 8),
+ new Point (8, currentTrianglePosition + 8)
+ };
+
+ e.Graphics.FillPolygon (ThemeEngine.Current.ResPool.GetSolidBrush (Color.Black), trianglePoints);
+ }
+
+ protected override void OnMouseDown (MouseEventArgs e)
+ {
+ if (e.Y > 195 || e.Y < 9) return; // helper until Cursor.Clip works
+
+ mouseButtonDown = true;
+ currentTrianglePosition = e.Y;
+
+ // Cursor.Clip doesn't yet work in Managed.Windows.Forms
+// clipRectangle = Cursor.Clip;
+// Point p = Location;
+// p.Y += 8;
+// Size s = Size;
+// s.Width -= 5;
+// s.Height -= 16;
+// Cursor.Clip = new Rectangle( Parent.PointToScreen( p ), s );
+
+ colorDialog.briTextBox.Text = TrianglePosition.ToString ();
+ colorDialog.UpdateFromHSBTextBoxes ();
+
+ Invalidate ();
+ Update ();
+
+ base.OnMouseDown (e);
+ }
+
+ protected override void OnMouseMove (MouseEventArgs e)
+ {
+ if (mouseButtonDown)
+ if (e.Y < 196 && e.Y > 8) {
+ currentTrianglePosition = e.Y;
+
+ colorDialog.briTextBox.Text = TrianglePosition.ToString ();
+ colorDialog.UpdateFromHSBTextBoxes ();
+
+ Invalidate ();
+ Update ();
+ }
+
+ base.OnMouseMove (e);
+ }
+
+ protected override void OnMouseUp (MouseEventArgs e)
+ {
+ mouseButtonDown = false;
+// Cursor.Clip = clipRectangle;
+
+ base.OnMouseUp (e);
+ }
+
+ public int TrianglePosition {
+ get {
+ float tmp = (float)(currentTrianglePosition - 9);
+ tmp = tmp * briStep;
+
+ int retval = 239 - (int)tmp;
+
+ TriangleControl.CurrentBrightness = retval;
+
+ return retval;
+ }
+
+ set {
+ float tmp = (float)value / briStep;
+ currentTrianglePosition = 186 - (int)tmp + 9;
+
+ colorDialog.briTextBox.Text = TrianglePosition.ToString ();
+
+ colorDialog.UpdateFromHSBTextBoxes ();
+
+ Invalidate ();
+ Update ();
+ }
+ }
+
+ public Color ColorToShow {
+ set {
+ SetColor (value);
+ }
+ }
+
+ public void SetColor (Color color)
+ {
+ int pos_raw = HSB.Brightness (color);
+
+ float tmp = (float)pos_raw / briStep;
+ currentTrianglePosition = 186 - (int)tmp + 9;
+
+ colorDialog.briTextBox.Text = TrianglePosition.ToString ();
+
+ Invalidate ();
+ }
+ }
+ #endregion
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnClickEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnClickEventArgs.cs
new file mode 100644
index 00000000000..0cfa29b7059
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnClickEventArgs.cs
@@ -0,0 +1,52 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Ravindra (rkumar@novell.com)
+//
+
+
+// COMPLETE
+
+using System;
+
+namespace System.Windows.Forms
+{
+ public class ColumnClickEventArgs : EventArgs
+ {
+ private int column;
+
+ #region Public Constructors
+ public ColumnClickEventArgs (int column)
+ {
+ this.column = column;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public int Column {
+ get {
+ return column;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnClickEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnClickEventHandler.cs
new file mode 100644
index 00000000000..7ecd08627ad
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnClickEventHandler.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Ravindra (rkumar@novell.com)
+//
+
+
+// COMPLETE
+
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public delegate void ColumnClickEventHandler (object sender, ColumnClickEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs
new file mode 100644
index 00000000000..f689f182023
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs
@@ -0,0 +1,207 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+
+// COMPLETE
+
+
+using System.ComponentModel;
+using System.Drawing;
+
+namespace System.Windows.Forms
+{
+ [DefaultProperty ("Text")]
+ [DesignTimeVisible (false)]
+ [ToolboxItem (false)]
+ public class ColumnHeader : Component, ICloneable
+ {
+ #region Instance Variables
+ private StringFormat format = new StringFormat ();
+ private string text = "ColumnHeader";
+ private HorizontalAlignment text_alignment = HorizontalAlignment.Left;
+ private int width = ThemeEngine.Current.ListViewDefaultColumnWidth;
+
+ // internal variables
+ internal Rectangle column_rect = Rectangle.Empty;
+ internal bool pressed = false;
+ internal ListView owner;
+ #endregion // Instance Variables
+
+ #region Internal Constructor
+ internal ColumnHeader (ListView owner, string text,
+ HorizontalAlignment alignment, int width)
+ {
+ this.owner = owner;
+ this.text = text;
+ this.width = width;
+ this.text_alignment = alignment;
+ CalcColumnHeader ();
+ }
+ #endregion // Internal Constructor
+
+ #region Public Constructors
+ public ColumnHeader () { }
+ #endregion // Public Constructors
+
+ #region Private Internal Methods Properties
+ // Since this class inherits from MarshalByRef,
+ // we can't do ColumnHeader.column_rect.XXX. Hence,
+ // we have some of the following properties to work around CS0197.
+ internal bool Pressed {
+ get { return this.pressed; }
+ }
+
+ internal int X {
+ get { return this.column_rect.X; }
+ set { this.column_rect.X = value; }
+ }
+
+ internal int Y {
+ get { return this.column_rect.Y; }
+ set { this.column_rect.Y = value; }
+ }
+
+ internal int Wd {
+ get { return this.column_rect.Width; }
+ set { this.column_rect.Width = value; }
+ }
+
+ internal int Ht {
+ get { return this.column_rect.Height; }
+ set { this.column_rect.Height = value; }
+ }
+
+ internal Rectangle Rect {
+ get { return this.column_rect; }
+ }
+
+ internal StringFormat Format {
+ get { return this.format; }
+ }
+
+ internal void CalcColumnHeader ()
+ {
+ if (text_alignment == HorizontalAlignment.Center)
+ format.Alignment = StringAlignment.Center;
+ else if (text_alignment == HorizontalAlignment.Right)
+ format.Alignment = StringAlignment.Far;
+ else
+ format.Alignment = StringAlignment.Near;
+ format.LineAlignment = StringAlignment.Center;
+ format.Trimming = StringTrimming.EllipsisWord;
+ // text is wrappable only in LargeIcon and SmallIcon views
+ format.FormatFlags = StringFormatFlags.NoWrap;
+
+ if (width >= 0) {
+ this.column_rect.Width = width;
+ if (owner != null)
+ this.column_rect.Height = owner.Font.Height + 5 ;
+ else
+ this.column_rect.Height = ThemeEngine.Current.DefaultFont.Height + 5;
+ }
+ else if (this.Index != -1)
+ this.column_rect.Size = owner.GetChildColumnSize (this.Index);
+ else
+ this.column_rect.Size = Size.Empty;
+ }
+ #endregion // Private Internal Methods Properties
+
+ #region Public Instance Properties
+ [Browsable (false)]
+ public int Index {
+ get {
+ if (owner != null && owner.Columns != null
+ && owner.Columns.Contains (this)) {
+ return owner.Columns.IndexOf (this);
+ }
+ return -1;
+ }
+ }
+
+ [Browsable (false)]
+ public ListView ListView {
+ get { return owner; }
+ }
+
+ [Localizable (true)]
+ public string Text {
+ get { return text; }
+ set {
+ text = value;
+ if (owner != null)
+ owner.Redraw (true);
+ }
+ }
+
+ [DefaultValue (HorizontalAlignment.Left)]
+ [Localizable (true)]
+ public HorizontalAlignment TextAlign {
+ get { return text_alignment; }
+ set {
+ text_alignment = value;
+ if (owner != null)
+ owner.Redraw (true);
+ }
+ }
+
+ [DefaultValue (60)]
+ [Localizable (true)]
+ public int Width {
+ get { return width; }
+ set {
+ width = value;
+ if (owner != null)
+ owner.Redraw (true);
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Methods
+ public virtual object Clone ()
+ {
+ ColumnHeader columnHeader = new ColumnHeader ();
+ columnHeader.text = text;
+ columnHeader.text_alignment = text_alignment;
+ columnHeader.width = width;
+ columnHeader.owner = owner;
+ columnHeader.format = (StringFormat) Format.Clone ();
+ columnHeader.column_rect = Rectangle.Empty;
+ return columnHeader;
+ }
+
+ public override string ToString ()
+ {
+ return string.Format ("ColumnHeader: Text: {0}", text);
+ }
+ #endregion // Public Methods
+
+ #region Protected Methods
+ protected override void Dispose (bool disposing)
+ {
+ base.Dispose (disposing);
+ }
+ #endregion // Protected Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeaderStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeaderStyle.cs
new file mode 100644
index 00000000000..5be7b5887a5
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeaderStyle.cs
@@ -0,0 +1,36 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Ravindra (rkumar@novell.com)
+//
+// COMPLETE
+//
+
+namespace System.Windows.Forms
+{
+ public enum ColumnHeaderStyle
+ {
+ None = 0,
+ Nonclickable = 1,
+ Clickable = 2
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnStyle.cs
new file mode 100644
index 00000000000..fe6f87b41c0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnStyle.cs
@@ -0,0 +1,59 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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:
+// Miguel de Icaza (miguel@gnome.org)
+//
+// (C) 2004 Novell, Inc.
+//
+
+#if NET_2_0
+namespace System.Windows.Forms {
+
+ public class ColumnStyle : TableLayoutSettings.Style {
+ float width;
+
+ public ColumnStyle ()
+ {
+ }
+
+ public ColumnStyle (SizeType st)
+ {
+ size_type = st;
+ }
+
+ public ColumnStyle (SizeType st, float width)
+ {
+ size_type = st;
+ this.width = width;
+ }
+
+ public float Width {
+ get {
+ return width;
+ }
+
+ set {
+ width = value;
+ }
+ }
+ }
+}
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs
new file mode 100644
index 00000000000..b8f01f654eb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs
@@ -0,0 +1,2017 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Reflection;
+using System.ComponentModel.Design;
+using System.ComponentModel.Design.Serialization;
+using System.Runtime.InteropServices;
+
+
+namespace System.Windows.Forms
+{
+
+ [DefaultProperty("Items")]
+ [DefaultEvent("SelectedIndexChanged")]
+ [Designer ("System.Windows.Forms.Design.ComboBoxDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ public class ComboBox : ListControl
+ {
+ private DrawMode draw_mode;
+ private ComboBoxStyle dropdown_style;
+ private int dropdown_width;
+ private const int preferred_height = 20;
+ private int selected_index;
+ private object selected_item;
+ internal ObjectCollection items = null;
+ private bool suspend_ctrlupdate;
+ private int maxdrop_items;
+ private bool integral_height;
+ private bool sorted;
+ internal ComboBoxInfo combobox_info;
+ private readonly int def_button_width = 16;
+ private bool clicked;
+ private int max_length;
+ private ComboListBox listbox_ctrl;
+ private TextBox textbox_ctrl;
+ private bool process_textchanged_event;
+
+ [ComVisible(true)]
+ public class ChildAccessibleObject : AccessibleObject {
+ private ComboBox owner;
+ private IntPtr handle;
+
+ public ChildAccessibleObject (ComboBox owner, IntPtr handle) {
+ this.owner = owner;
+ this.handle = handle;
+ }
+
+ public override string Name {
+ get {
+ return base.Name;
+ }
+ }
+
+
+ }
+
+ internal class ComboBoxInfo
+ {
+ internal int item_height; /* Item's height */
+ internal Rectangle textarea; /* Rectangle of the editable text area */
+ internal Rectangle textarea_drawable; /* Rectangle of the editable text area - decorations - button if present*/
+ internal Rectangle button_rect;
+ internal bool show_button; /* Is the DropDown button shown? */
+ internal ButtonState button_status; /* Drop button status */
+ internal int original_height; /* Control's height is recalculated for not Simple Styles */
+ internal Rectangle listbox_area; /* ListBox area in Simple combox, not used in the rest */
+ internal bool droppeddown; /* Is the associated ListBox dropped down? */
+ internal int combosimple_height; /* Simple default height */
+
+ public ComboBoxInfo ()
+ {
+ button_status = ButtonState.Normal;
+ show_button = false;
+ item_height = 0;
+ droppeddown = false;
+ original_height = -1;
+ combosimple_height = 150;
+ }
+ }
+
+ internal class ComboBoxItem
+ {
+ internal int Index;
+ internal int ItemHeight; /* Only used for OwnerDrawVariable */
+
+ public ComboBoxItem (int index)
+ {
+ Index = index;
+ ItemHeight = -1;
+ }
+ }
+
+ public ComboBox ()
+ {
+ items = new ObjectCollection (this);
+ listbox_ctrl = null;
+ textbox_ctrl = null;
+ combobox_info = new ComboBoxInfo ();
+ combobox_info.item_height = FontHeight + 2;
+ dropdown_style = (ComboBoxStyle)(-1);
+ DropDownStyle = ComboBoxStyle.DropDown;
+ BackColor = ThemeEngine.Current.ColorWindow;
+ draw_mode = DrawMode.Normal;
+ selected_index = -1;
+ selected_item = null;
+ maxdrop_items = 8;
+ suspend_ctrlupdate = false;
+ clicked = false;
+ dropdown_width = -1;
+ max_length = 0;
+ integral_height = true;
+ process_textchanged_event = true;
+ has_focus = false;
+
+ /* Events */
+ MouseDown += new MouseEventHandler (OnMouseDownCB);
+ MouseUp += new MouseEventHandler (OnMouseUpCB);
+ MouseMove += new MouseEventHandler (OnMouseMoveCB);
+ KeyDown +=new KeyEventHandler(OnKeyDownCB);
+ }
+
+ #region events
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler BackgroundImageChanged;
+
+ public event DrawItemEventHandler DrawItem;
+ public event EventHandler DropDown;
+ public event EventHandler DropDownStyleChanged;
+ public event MeasureItemEventHandler MeasureItem;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event PaintEventHandler Paint;
+
+ public event EventHandler SelectedIndexChanged;
+ public event EventHandler SelectionChangeCommitted;
+ #endregion Events
+
+ #region Public Properties
+ public override Color BackColor {
+ get { return base.BackColor; }
+ set {
+ if (base.BackColor == value)
+ return;
+
+ base.BackColor = value;
+ Refresh ();
+ }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override Image BackgroundImage {
+ get { return base.BackgroundImage; }
+ set {
+ if (base.BackgroundImage == value)
+ return;
+
+ base.BackgroundImage = value;
+
+ if (BackgroundImageChanged != null)
+ BackgroundImageChanged (this, EventArgs.Empty);
+
+ Refresh ();
+ }
+ }
+
+ protected override CreateParams CreateParams {
+ get { return base.CreateParams;}
+ }
+
+ protected override Size DefaultSize {
+ get { return new Size (121, PreferredHeight); }
+ }
+
+ [RefreshProperties(RefreshProperties.Repaint)]
+ [DefaultValue (DrawMode.Normal)]
+ public DrawMode DrawMode {
+ get { return draw_mode; }
+
+ set {
+ if (!Enum.IsDefined (typeof (DrawMode), value))
+ throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for DrawMode", value));
+
+ if (draw_mode == value)
+ return;
+
+ draw_mode = value;
+ Refresh ();
+ }
+ }
+
+ [DefaultValue (ComboBoxStyle.DropDown)]
+ [RefreshProperties(RefreshProperties.Repaint)]
+ public ComboBoxStyle DropDownStyle {
+ get { return dropdown_style; }
+
+ set {
+
+ if (!Enum.IsDefined (typeof (ComboBoxStyle), value))
+ throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for ComboBoxStyle", value));
+
+ if (dropdown_style == value)
+ return;
+
+ if (dropdown_style == ComboBoxStyle.Simple) {
+ if (listbox_ctrl != null) {
+ Controls.RemoveImplicit (listbox_ctrl);
+ listbox_ctrl.Dispose ();
+ listbox_ctrl = null;
+ Height = combobox_info.original_height;
+ }
+ }
+
+ if (dropdown_style != ComboBoxStyle.DropDownList && value == ComboBoxStyle.DropDownList) {
+ if (textbox_ctrl != null) {
+ Controls.RemoveImplicit (textbox_ctrl);
+ textbox_ctrl.Dispose ();
+ textbox_ctrl = null;
+ }
+ }
+
+ dropdown_style = value;
+
+ if (dropdown_style == ComboBoxStyle.Simple) {
+ CBoxInfo.show_button = false;
+ combobox_info.original_height = Height;
+ Height = combobox_info.combosimple_height;
+
+ CreateComboListBox ();
+
+ if (IsHandleCreated == true) {
+ Controls.AddImplicit (listbox_ctrl);
+ }
+ }
+ else {
+ CBoxInfo.show_button = true;
+ CBoxInfo.button_status = ButtonState.Normal;
+ }
+
+ if (dropdown_style != ComboBoxStyle.DropDownList && textbox_ctrl == null) {
+ textbox_ctrl = new FixedSizeTextBox ();
+ textbox_ctrl.BorderStyle = BorderStyle.None;
+ textbox_ctrl.TextChanged += new EventHandler (OnTextChangedEdit);
+ textbox_ctrl.KeyPress += new KeyPressEventHandler(textbox_ctrl_KeyPress);
+ textbox_ctrl.KeyDown += new KeyEventHandler (OnKeyDownCB);
+ textbox_ctrl.GotFocus += new EventHandler(textbox_ctrl_GotFocus);
+ textbox_ctrl.LostFocus += new EventHandler(textbox_ctrl_LostFocus);
+
+ if (IsHandleCreated == true) {
+ Controls.AddImplicit (textbox_ctrl);
+ }
+ }
+
+ if (DropDownStyleChanged != null)
+ DropDownStyleChanged (this, EventArgs.Empty);
+
+ CalcTextArea ();
+ Refresh ();
+ }
+ }
+
+ public int DropDownWidth {
+ get {
+ if (dropdown_width == -1)
+ return Width;
+
+ return dropdown_width;
+ }
+ set {
+ if (dropdown_width == value)
+ return;
+
+ if (value < 1)
+ throw new ArgumentException ("The DropDownWidth value is less than one");
+
+ dropdown_width = value;
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public bool DroppedDown {
+ get {
+ if (dropdown_style == ComboBoxStyle.Simple)
+ return true;
+
+ return CBoxInfo.droppeddown;
+ }
+ set {
+ if (dropdown_style == ComboBoxStyle.Simple)
+ return;
+
+
+ if (value == true) {
+ DropDownListBox ();
+ }
+ else {
+ listbox_ctrl.Hide ();
+ }
+
+ if (DropDown != null)
+ DropDown (this, EventArgs.Empty);
+ }
+ }
+
+ public override bool Focused {
+ get { return base.Focused; }
+ }
+
+ public override Color ForeColor {
+ get { return base.ForeColor; }
+ set {
+ if (base.ForeColor == value)
+ return;
+
+ base.ForeColor = value;
+ Refresh ();
+ }
+ }
+
+ [DefaultValue (true)]
+ [Localizable (true)]
+ public bool IntegralHeight {
+ get { return integral_height; }
+ set {
+ if (integral_height == value)
+ return;
+
+ integral_height = value;
+ Refresh ();
+ }
+ }
+
+ [Localizable (true)]
+ public int ItemHeight {
+ get { return combobox_info.item_height; }
+ set {
+ if (value < 0)
+ throw new ArgumentException ("The item height value is less than zero");
+
+ combobox_info.item_height = value;
+ CalcTextArea ();
+ Refresh ();
+ }
+ }
+
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
+ [Localizable (true)]
+ [Editor ("System.Windows.Forms.Design.ListControlStringCollectionEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
+ public ComboBox.ObjectCollection Items {
+ get { return items; }
+ }
+
+ [DefaultValue (8)]
+ [Localizable (true)]
+ public int MaxDropDownItems {
+ get { return maxdrop_items; }
+ set {
+ if (maxdrop_items == value)
+ return;
+
+ maxdrop_items = value;
+ }
+ }
+
+ [DefaultValue (0)]
+ [Localizable (true)]
+ public int MaxLength {
+ get { return max_length; }
+ set {
+ if (max_length == value)
+ return;
+
+ max_length = value;
+
+ if (dropdown_style != ComboBoxStyle.DropDownList) {
+
+ if (value < 0) {
+ value = 0;
+ }
+
+ textbox_ctrl.MaxLength = value;
+ }
+ }
+ }
+
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [Browsable (false)]
+ public int PreferredHeight {
+ get { return preferred_height; }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public override int SelectedIndex {
+ get { return selected_index; }
+ set {
+ if (value <= -2 || value >= Items.Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ if (selected_index == value)
+ return;
+
+ selected_index = value;
+
+ if (dropdown_style != ComboBoxStyle.DropDownList) {
+ if (selected_index != -1) {
+ SetControlText (GetItemText (Items[selected_index]));
+ } else {
+ SetControlText("");
+ }
+ }
+
+ OnSelectedIndexChanged (new EventArgs ());
+ OnSelectedValueChanged (new EventArgs ());
+ OnSelectedItemChanged (new EventArgs ());
+ Refresh ();
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [Bindable(true)]
+ public object SelectedItem {
+ get {
+ if (selected_index !=-1 && Items !=null && Items.Count > 0)
+ return Items[selected_index];
+ else
+ return null;
+ }
+ set {
+ int index = Items.IndexOf (value);
+
+ if (index == -1)
+ return;
+
+ if (selected_index == index)
+ return;
+
+ selected_index = index;
+
+ if (dropdown_style != ComboBoxStyle.DropDownList) {
+ SetControlText (GetItemText (Items[selected_index]));
+ }
+
+ OnSelectedItemChanged (new EventArgs ());
+ Refresh ();
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public string SelectedText {
+ get {
+ if (dropdown_style == ComboBoxStyle.DropDownList)
+ return "";
+
+ return textbox_ctrl.SelectedText;
+ }
+ set {
+ if (dropdown_style == ComboBoxStyle.DropDownList) {
+ return;
+ }
+
+ textbox_ctrl.SelectedText = value;
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public int SelectionLength {
+ get {
+ if (dropdown_style == ComboBoxStyle.DropDownList)
+ return 0;
+
+ return textbox_ctrl.SelectionLength;
+ }
+ set {
+ if (dropdown_style == ComboBoxStyle.DropDownList)
+ return;
+
+ if (textbox_ctrl.SelectionLength == value)
+ return;
+
+ textbox_ctrl.SelectionLength = value;
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public int SelectionStart {
+ get {
+ if (dropdown_style == ComboBoxStyle.DropDownList)
+ return 0;
+
+ return textbox_ctrl.SelectionStart;
+ }
+ set {
+ if (dropdown_style == ComboBoxStyle.DropDownList)
+ return;
+
+ if (textbox_ctrl.SelectionStart == value)
+ return;
+
+ textbox_ctrl.SelectionStart = value;
+ }
+ }
+
+ [DefaultValue (false)]
+ public bool Sorted {
+ get { return sorted; }
+
+ set {
+ if (sorted == value)
+ return;
+
+ sorted = value;
+ }
+ }
+
+ [Bindable (true)]
+ [Localizable (true)]
+ public override string Text {
+ get {
+ if (dropdown_style != ComboBoxStyle.DropDownList) {
+ if (textbox_ctrl != null) {
+ return textbox_ctrl.Text;
+ }
+ }
+
+ if (SelectedItem != null) {
+ return GetItemText (SelectedItem);
+ }
+
+ return base.Text;
+ }
+ set {
+ if (value == null) {
+ SelectedIndex = -1;
+ return;
+ }
+
+ int index = FindString (value);
+
+ if (index != -1) {
+ SelectedIndex = index;
+ return;
+ }
+
+ if (dropdown_style != ComboBoxStyle.DropDownList) {
+ textbox_ctrl.Text = GetItemText (value);
+ }
+ }
+ }
+
+ #endregion Public Properties
+
+ #region Private Properties
+ internal ComboBoxInfo CBoxInfo {
+ get { return combobox_info; }
+ }
+
+ #endregion Private Properties
+
+ #region Public Methods
+ protected virtual void AddItemsCore (object[] value)
+ {
+
+ }
+
+ public void BeginUpdate ()
+ {
+ suspend_ctrlupdate = true;
+ }
+
+ protected override void Dispose (bool disposing)
+ {
+ if (disposing == true) {
+ if (listbox_ctrl != null) {
+ listbox_ctrl.Dispose ();
+ Controls.RemoveImplicit (listbox_ctrl);
+ listbox_ctrl = null;
+ }
+
+ if (textbox_ctrl != null) {
+ Controls.RemoveImplicit (textbox_ctrl);
+ textbox_ctrl.Dispose ();
+ textbox_ctrl = null;
+ }
+ }
+
+ base.Dispose (disposing);
+ }
+
+ public void EndUpdate ()
+ {
+ suspend_ctrlupdate = false;
+ UpdatedItems ();
+ }
+
+ public int FindString (string s)
+ {
+ return FindString (s, -1);
+ }
+
+ public int FindString (string s, int startIndex)
+ {
+ if (Items.Count == 0)
+ return -1; // No exception throwing if empty
+
+ if (startIndex < -1 || startIndex >= Items.Count - 1)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ startIndex++;
+ for (int i = startIndex; i < Items.Count; i++) {
+ if ((GetItemText (Items[i])).StartsWith (s))
+ return i;
+ }
+
+ return -1;
+ }
+
+ public int FindStringExact (string s)
+ {
+ return FindStringExact (s, -1);
+ }
+
+ public int FindStringExact (string s, int startIndex)
+ {
+ if (Items.Count == 0)
+ return -1; // No exception throwing if empty
+
+ if (startIndex < -1 || startIndex >= Items.Count - 1)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ startIndex++;
+ for (int i = startIndex; i < Items.Count; i++) {
+ if ((GetItemText (Items[i])).Equals (s))
+ return i;
+ }
+
+ return -1;
+ }
+
+ public int GetItemHeight (int index)
+ {
+ if (DrawMode == DrawMode.OwnerDrawVariable && IsHandleCreated == true) {
+
+ if (index < 0 || index >= Items.Count )
+ throw new ArgumentOutOfRangeException ("The item height value is less than zero");
+
+ if ((Items.GetComboBoxItem (index)).ItemHeight != -1) {
+ return (Items.GetComboBoxItem (index)).ItemHeight;
+ }
+
+ MeasureItemEventArgs args = new MeasureItemEventArgs (DeviceContext, index, ItemHeight);
+ OnMeasureItem (args);
+ (Items.GetComboBoxItem (index)).ItemHeight = args.ItemHeight;
+ return args.ItemHeight;
+ }
+
+ return ItemHeight;
+ }
+
+ protected override bool IsInputKey (Keys keyData)
+ {
+ switch (keyData) {
+ case Keys.Up:
+ case Keys.Down:
+ case Keys.PageUp:
+ case Keys.PageDown:
+ return true;
+
+ default:
+ return false;
+ }
+ }
+
+ protected override void OnBackColorChanged (EventArgs e)
+ {
+ base.OnBackColorChanged (e);
+ }
+
+ protected override void OnDataSourceChanged (EventArgs e)
+ {
+ base.OnDataSourceChanged (e);
+ BindDataItems (items);
+
+ if (DataSource == null || DataManager == null) {
+ SelectedIndex = -1;
+ }
+ else {
+ SelectedIndex = DataManager.Position;
+ }
+ }
+
+ protected override void OnDisplayMemberChanged (EventArgs e)
+ {
+ base.OnDisplayMemberChanged (e);
+
+ if (DataManager == null || !IsHandleCreated)
+ return;
+
+ BindDataItems (items);
+ SelectedIndex = DataManager.Position;
+ }
+
+ protected virtual void OnDrawItem (DrawItemEventArgs e)
+ {
+ if (DrawItem != null && (DrawMode == DrawMode.OwnerDrawFixed || DrawMode == DrawMode.OwnerDrawVariable)) {
+ DrawItem (this, e);
+ return;
+ }
+
+ ThemeEngine.Current.DrawComboBoxItem (this, e);
+ }
+
+ protected virtual void OnDropDown (EventArgs e)
+ {
+ if (DropDown != null)
+ DropDown (this, e);
+ }
+
+ protected virtual void OnDropDownStyleChanged (EventArgs e)
+ {
+ if (DropDownStyleChanged != null)
+ DropDownStyleChanged (this, e);
+ }
+
+ protected override void OnFontChanged (EventArgs e)
+ {
+ base.OnFontChanged (e);
+
+ if (textbox_ctrl != null) {
+ textbox_ctrl.Font = Font;
+ }
+
+ combobox_info.item_height = FontHeight + 2;
+ CalcTextArea ();
+ }
+
+ protected override void OnForeColorChanged (EventArgs e)
+ {
+ base.OnForeColorChanged (e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void OnGotFocus (EventArgs e) {
+ has_focus = true;
+ Invalidate ();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void OnLostFocus (EventArgs e) {
+ has_focus = false;
+ Invalidate ();
+ }
+
+ protected override void OnHandleCreated (EventArgs e)
+ {
+ base.OnHandleCreated (e);
+
+ if (listbox_ctrl != null) {
+ Controls.AddImplicit (listbox_ctrl);
+
+ if (dropdown_style == ComboBoxStyle.Simple)
+ Height = combobox_info.combosimple_height;
+
+ }
+
+ if (textbox_ctrl != null) {
+ Controls.AddImplicit (textbox_ctrl);
+ }
+
+ CalcTextArea ();
+ }
+
+ protected override void OnHandleDestroyed (EventArgs e)
+ {
+ base.OnHandleDestroyed (e);
+ }
+
+ protected override void OnKeyPress (KeyPressEventArgs e)
+ {
+ base.OnKeyPress (e);
+ }
+
+ protected virtual void OnMeasureItem (MeasureItemEventArgs e)
+ {
+ if (MeasureItem != null)
+ MeasureItem (this, e);
+ }
+
+ protected override void OnParentBackColorChanged (EventArgs e)
+ {
+ base.OnParentBackColorChanged (e);
+ }
+
+ protected override void OnResize (EventArgs e)
+ {
+ base.OnResize (e);
+ AdjustHeightForDropDown ();
+
+ if (listbox_ctrl != null)
+ listbox_ctrl.CalcListBoxArea ();
+
+ CalcTextArea ();
+ }
+
+ protected override void OnSelectedIndexChanged (EventArgs e)
+ {
+ base.OnSelectedIndexChanged (e);
+
+ if (SelectedIndexChanged != null)
+ SelectedIndexChanged (this, e);
+ }
+
+ protected virtual void OnSelectedItemChanged (EventArgs e)
+ {
+
+ }
+
+ protected override void OnSelectedValueChanged (EventArgs e)
+ {
+ base.OnSelectedValueChanged (e);
+ }
+
+ protected virtual void OnSelectionChangeCommitted (EventArgs e)
+ {
+ if (SelectionChangeCommitted != null)
+ SelectionChangeCommitted (this, e);
+ }
+
+ protected override void RefreshItem (int index)
+ {
+ if (index < 0 || index >= Items.Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ if (draw_mode == DrawMode.OwnerDrawVariable) {
+ (Items.GetComboBoxItem (index)).ItemHeight = -1;
+ }
+ }
+
+ public void Select (int start, int lenght)
+ {
+ if (start < 0)
+ throw new ArgumentException ("Start cannot be less than zero");
+
+ if (lenght < 0)
+ throw new ArgumentException ("Start cannot be less than zero");
+
+ if (dropdown_style == ComboBoxStyle.DropDownList)
+ return;
+
+ textbox_ctrl.Select (start, lenght);
+ }
+
+ public void SelectAll ()
+ {
+ if (dropdown_style == ComboBoxStyle.DropDownList)
+ return;
+
+ textbox_ctrl.SelectAll ();
+ }
+
+ protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified)
+ {
+ base.SetBoundsCore (x, y, width, height, specified);
+ }
+
+ protected override void SetItemCore (int index, object value)
+ {
+ if (index < 0 || index >= Items.Count)
+ return;
+
+ Items[index] = value;
+ }
+
+ protected override void SetItemsCore (IList value)
+ {
+ Items.AddRange (value);
+ }
+
+ public override string ToString ()
+ {
+ return base.ToString () + ", Items.Count:" + Items.Count;
+ }
+
+ protected override void WndProc (ref Message m)
+ {
+
+ switch ((Msg) m.Msg) {
+
+ case Msg.WM_PAINT: {
+ PaintEventArgs paint_event;
+ paint_event = XplatUI.PaintEventStart (Handle, true);
+ OnPaintCB (paint_event);
+ XplatUI.PaintEventEnd (Handle, true);
+ return;
+ }
+
+ case Msg.WM_ERASEBKGND:
+ m.Result = (IntPtr) 1;
+ return;
+
+ default:
+ break;
+ }
+
+ base.WndProc (ref m);
+
+ }
+
+ #endregion Public Methods
+
+ #region Private Methods
+
+ private void AdjustHeightForDropDown ()
+ {
+ if (dropdown_style == ComboBoxStyle.Simple)
+ return;
+
+ int new_height = combobox_info.item_height + ThemeEngine.Current.DrawComboBoxEditDecorationTop () +
+ ThemeEngine.Current.DrawComboBoxEditDecorationBottom () + 2;
+
+ if (Height == new_height)
+ return;
+
+ combobox_info.original_height = Height;
+ Height = new_height;
+ }
+
+ private void textbox_ctrl_KeyPress(object sender, KeyPressEventArgs e)
+ {
+ OnKeyPress (e);
+ }
+
+ private void textbox_ctrl_GotFocus(object sender, EventArgs e )
+ {
+ OnGotFocus(e);
+ }
+
+ private void textbox_ctrl_LostFocus(object sender, EventArgs e )
+ {
+ OnLostFocus(e);
+ }
+
+ // Calcs the text area size
+ internal void CalcTextArea ()
+ {
+ combobox_info.textarea = ClientRectangle;
+
+ /* Edit area */
+ combobox_info.textarea.Height = ItemHeight + ThemeEngine.Current.DrawComboBoxEditDecorationTop () +
+ ThemeEngine.Current.DrawComboBoxEditDecorationBottom () + 2;
+ // TODO: Does the +2 change at different font resolutions?
+
+ /* Edit area - minus decorations (text drawable area) */
+ combobox_info.textarea_drawable = combobox_info.textarea;
+ combobox_info.textarea_drawable.Y += ThemeEngine.Current.DrawComboBoxEditDecorationTop ();
+ combobox_info.textarea_drawable.X += ThemeEngine.Current.DrawComboBoxEditDecorationLeft ();
+ combobox_info.textarea_drawable.Height -= ThemeEngine.Current.DrawComboBoxEditDecorationBottom ();
+ combobox_info.textarea_drawable.Height -= ThemeEngine.Current.DrawComboBoxEditDecorationTop();
+ combobox_info.textarea_drawable.Width -= ThemeEngine.Current.DrawComboBoxEditDecorationRight ();
+ combobox_info.textarea_drawable.Width -= ThemeEngine.Current.DrawComboBoxEditDecorationLeft ();
+
+ /* Non-drawable area */
+ Region area = new Region (ClientRectangle);
+ area.Exclude (combobox_info.textarea);
+ RectangleF bounds = area.GetBounds (DeviceContext);
+ combobox_info.listbox_area = new Rectangle ((int)bounds.X, (int)bounds.Y,
+ (int)bounds.Width, (int)bounds.Height);
+
+ if (CBoxInfo.show_button) {
+ combobox_info.textarea_drawable.Width -= def_button_width;
+
+ combobox_info.button_rect = new Rectangle (combobox_info.textarea_drawable.X + combobox_info.textarea_drawable.Width,
+ combobox_info.textarea_drawable.Y, def_button_width, combobox_info.textarea_drawable.Height);
+
+ }
+
+ if (dropdown_style != ComboBoxStyle.DropDownList) { /* There is an edit control*/
+ if (textbox_ctrl != null) {
+ textbox_ctrl.Location = new Point (combobox_info.textarea_drawable.X, combobox_info.textarea_drawable.Y);
+ textbox_ctrl.Size = new Size (combobox_info.textarea_drawable.Width, combobox_info.textarea_drawable.Height);
+ }
+ }
+
+ if (listbox_ctrl != null && dropdown_style == ComboBoxStyle.Simple) {
+ listbox_ctrl.Location = new Point (combobox_info.textarea.X, combobox_info.textarea.Y +
+ combobox_info.textarea.Height);
+ listbox_ctrl.CalcListBoxArea ();
+ }
+
+ area.Dispose ();
+ }
+
+ private void CreateComboListBox ()
+ {
+ listbox_ctrl = new ComboListBox (this);
+ }
+
+ internal void Draw (Rectangle clip, Graphics dc)
+ {
+ // No edit control, we paint the edit ourselfs
+ if (dropdown_style == ComboBoxStyle.DropDownList) {
+ DrawItemState state = DrawItemState.None;
+ Rectangle item_rect = combobox_info.textarea_drawable;
+ item_rect.Height = ItemHeight + 2;
+
+ if (has_focus == true) {
+ state = DrawItemState.Selected;
+ state |= DrawItemState.Focus;
+ }
+
+ state |= DrawItemState.ComboBoxEdit;
+ OnDrawItem (new DrawItemEventArgs (dc, Font, item_rect,
+ selected_index, state, ForeColor, BackColor));
+ }
+
+ if (DropDownStyle == ComboBoxStyle.Simple && clip.IntersectsWith (combobox_info.listbox_area) == true) {
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (Parent.BackColor),
+ combobox_info.listbox_area);
+ }
+
+ if (CBoxInfo.show_button) {
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ThemeEngine.Current.ColorControl),
+ combobox_info.button_rect);
+
+ ThemeEngine.Current.CPDrawComboButton (dc,
+ combobox_info.button_rect, combobox_info.button_status);
+ }
+
+ ThemeEngine.Current.DrawComboBoxEditDecorations (dc, this, combobox_info.textarea);
+ }
+
+ internal void DropDownListBox ()
+ {
+ if (DropDownStyle == ComboBoxStyle.Simple)
+ return;
+
+ if (listbox_ctrl == null) {
+ CreateComboListBox ();
+ }
+
+ listbox_ctrl.Location = PointToScreen (new Point (combobox_info.textarea.X, combobox_info.textarea.Y +
+ combobox_info.textarea.Height));
+
+ if (listbox_ctrl.ShowWindow () == true) {
+ CBoxInfo.droppeddown = true;
+ }
+
+ combobox_info.button_status = ButtonState.Pushed;
+ if (dropdown_style == ComboBoxStyle.DropDownList) {
+ Invalidate (combobox_info.textarea_drawable);
+ }
+ }
+
+ internal void DropDownListBoxFinished ()
+ {
+ if (DropDownStyle == ComboBoxStyle.Simple)
+ return;
+
+ combobox_info.button_status = ButtonState.Normal;
+ Invalidate (combobox_info.button_rect);
+ CBoxInfo.droppeddown = false;
+ clicked = false;
+ }
+
+ private int FindStringCaseInsensitive (string search)
+ {
+ if (search.Length == 0) {
+ return -1;
+ }
+
+ for (int i = 0; i < Items.Count; i++)
+ {
+ if (String.Compare (GetItemText (Items[i]), 0, search, 0, search.Length, true) == 0)
+ return i;
+ }
+
+ return -1;
+ }
+
+ private void OnKeyDownCB(object sender, KeyEventArgs e)
+ {
+ switch (e.KeyCode)
+ {
+ case Keys.Up:
+ SelectedIndex = Math.Max(SelectedIndex-1, 0);
+ break;
+
+ case Keys.Down:
+ SelectedIndex = Math.Min(SelectedIndex+1, Items.Count-1);
+ break;
+
+ case Keys.PageUp:
+ if (listbox_ctrl != null)
+ SelectedIndex = Math.Max(SelectedIndex- (listbox_ctrl.page_size-1), 0);
+ break;
+
+ case Keys.PageDown:
+ if (listbox_ctrl != null)
+ SelectedIndex = Math.Min(SelectedIndex+(listbox_ctrl.page_size-1), Items.Count-1);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ internal virtual void OnMouseDownCB (object sender, MouseEventArgs e)
+ {
+ /* Click On button*/
+ Rectangle hit_rect;
+
+ if (dropdown_style == ComboBoxStyle.DropDownList) {
+ hit_rect = combobox_info.textarea;
+ } else {
+ hit_rect = combobox_info.button_rect;
+ }
+
+ if (hit_rect.Contains (e.X, e.Y)) {
+ if (clicked == false) {
+ clicked = true;
+ DropDownListBox ();
+ } else {
+ listbox_ctrl.Hide ();
+ DropDownListBoxFinished ();
+ }
+
+ Invalidate (combobox_info.button_rect);
+ }
+ }
+
+ internal virtual void OnMouseMoveCB (object sender, MouseEventArgs e)
+ {
+ /* When there are no items, act as a regular button */
+ if (clicked == true && Items.Count == 0 &&
+ combobox_info.button_rect.Contains (e.X, e.Y) == false) {
+ DropDownListBoxFinished ();
+ }
+ }
+
+ internal virtual void OnMouseUpCB (object sender, MouseEventArgs e)
+ {
+ /* Click on button*/
+ if (clicked == true && combobox_info.button_rect.Contains (e.X, e.Y)) {
+ DropDownListBoxFinished ();
+ }
+ }
+
+ private void OnPaintCB (PaintEventArgs pevent)
+ {
+ if (Width <= 0 || Height <= 0 || Visible == false || suspend_ctrlupdate == true)
+ return;
+
+ /* Copies memory drawing buffer to screen*/
+ Draw (ClientRectangle, pevent.Graphics);
+
+ if (Paint != null)
+ Paint (this, pevent);
+ }
+
+ private void OnTextChangedEdit (object sender, EventArgs e)
+ {
+ if (process_textchanged_event == false)
+ return;
+
+ int item = FindStringCaseInsensitive (textbox_ctrl.Text);
+
+ if (item == -1)
+ return;
+
+ if (listbox_ctrl != null) {
+ listbox_ctrl.SetTopItem (item);
+ listbox_ctrl.SetHighLightedItem (Items[item]);
+ }
+ }
+
+ internal void SetControlText (string s)
+ {
+ process_textchanged_event = false;
+ textbox_ctrl.Text = s;
+ process_textchanged_event = true;
+ }
+
+ private void UpdatedItems ()
+ {
+ if (listbox_ctrl != null) {
+ listbox_ctrl.UpdateLastVisibleItem ();
+ listbox_ctrl.CalcListBoxArea ();
+ listbox_ctrl.Refresh ();
+ }
+ }
+
+ #endregion Private Methods
+
+
+ /*
+ ComboBox.ObjectCollection
+ */
+ [ListBindableAttribute (false)]
+ public class ObjectCollection : IList, ICollection, IEnumerable
+ {
+
+ private ComboBox owner;
+ internal ArrayList object_items = new ArrayList ();
+ internal ArrayList combobox_items = new ArrayList ();
+
+ public ObjectCollection (ComboBox owner)
+ {
+ this.owner = owner;
+ }
+
+ #region Public Properties
+ public virtual int Count {
+ get { return object_items.Count; }
+ }
+
+ public virtual bool IsReadOnly {
+ get { return false; }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public virtual object this [int index] {
+ get {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ return object_items[index];
+ }
+ set {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ object_items[index] = value;
+ }
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return false; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return this; }
+ }
+
+ bool IList.IsFixedSize {
+ get { return false; }
+ }
+
+ #endregion Public Properties
+
+ #region Private Properties
+ internal ArrayList ObjectItems {
+ get { return object_items;}
+ set {
+ object_items = value;
+ }
+ }
+
+ internal ArrayList ListBoxItems {
+ get { return combobox_items;}
+ set {
+ combobox_items = value;
+ }
+ }
+ #endregion Private Properties
+
+ #region Public Methods
+ public int Add (object item)
+ {
+ int idx;
+
+ idx = AddItem (item);
+ owner.UpdatedItems ();
+ return idx;
+ }
+
+ public void AddRange (object[] items)
+ {
+ foreach (object mi in items)
+ AddItem (mi);
+
+ owner.UpdatedItems ();
+ }
+
+ public virtual void Clear ()
+ {
+ owner.selected_index = -1;
+ object_items.Clear ();
+ combobox_items.Clear ();
+ owner.UpdatedItems ();
+ owner.Refresh ();
+ }
+
+ public virtual bool Contains (object obj)
+ {
+ return object_items.Contains (obj);
+ }
+
+ public void CopyTo (object[] dest, int arrayIndex)
+ {
+ object_items.CopyTo (dest, arrayIndex);
+ }
+
+ void ICollection.CopyTo (Array dest, int index)
+ {
+ object_items.CopyTo (dest, index);
+ }
+
+ public virtual IEnumerator GetEnumerator ()
+ {
+ return object_items.GetEnumerator ();
+ }
+
+ int IList.Add (object item)
+ {
+ return Add (item);
+ }
+
+ public virtual int IndexOf (object value)
+ {
+ return object_items.IndexOf (value);
+ }
+
+ public virtual void Insert (int index, object item)
+ {
+ if (index < 0 || index > Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ ObjectCollection new_items = new ObjectCollection (owner);
+ object sel_item = owner.SelectedItem;
+
+ owner.BeginUpdate ();
+
+ for (int i = 0; i < index; i++) {
+ new_items.AddItem (ObjectItems[i]);
+ }
+
+ new_items.AddItem (item);
+
+ for (int i = index; i < Count; i++){
+ new_items.AddItem (ObjectItems[i]);
+ }
+
+ ObjectItems = new_items.ObjectItems;
+ ListBoxItems = new_items.ListBoxItems;
+
+ if (sel_item != null) {
+ int idx = IndexOf (sel_item);
+ owner.selected_index = idx;
+ owner.listbox_ctrl.SetHighLightedItem (owner.Items[idx]);
+ }
+
+ owner.EndUpdate (); // Calls UpdatedItems
+ }
+
+ public virtual void Remove (object value)
+ {
+ if (IndexOf (value) == owner.SelectedIndex)
+ owner.SelectedItem = null;
+
+ RemoveAt (IndexOf (value));
+
+ }
+
+ public virtual void RemoveAt (int index)
+ {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ if (index == owner.SelectedIndex)
+ owner.SelectedItem = null;
+
+ object_items.RemoveAt (index);
+ combobox_items.RemoveAt (index);
+ owner.UpdatedItems ();
+ }
+ #endregion Public Methods
+
+ #region Private Methods
+ private int AddItem (object item)
+ {
+ int cnt = object_items.Count;
+ object_items.Add (item);
+ combobox_items.Add (new ComboBox.ComboBoxItem (cnt));
+ return cnt;
+ }
+
+ internal void AddRange (IList items)
+ {
+ foreach (object mi in items)
+ AddItem (mi);
+
+ owner.UpdatedItems ();
+ }
+
+ internal ComboBox.ComboBoxItem GetComboBoxItem (int index)
+ {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ return (ComboBox.ComboBoxItem) combobox_items[index];
+ }
+
+ internal void SetComboBoxItem (ComboBox.ComboBoxItem item, int index)
+ {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ combobox_items[index] = item;
+ }
+
+ #endregion Private Methods
+ }
+
+ /*
+ class ComboListBox
+ */
+ internal class ComboListBox : Control
+ {
+ private ComboBox owner;
+ private VScrollBarLB vscrollbar_ctrl;
+ private int top_item; /* First item that we show the in the current page */
+ private int last_item; /* Last visible item */
+ public object highlighted_item; /* Item that is currently selected */
+ internal int page_size; /* Number of listbox items per page */
+ private Rectangle textarea_drawable; /* Rectangle of the drawable text area */
+
+ internal enum ItemNavigation
+ {
+ First,
+ Last,
+ Next,
+ Previous,
+ NextPage,
+ PreviousPage,
+ }
+
+ class VScrollBarLB : VScrollBar
+ {
+ public VScrollBarLB ()
+ {
+ }
+
+ public void FireMouseDown (MouseEventArgs e)
+ {
+ OnMouseDown (e);
+ }
+
+ public void FireMouseUp (MouseEventArgs e)
+ {
+ OnMouseUp (e);
+ }
+
+ public void FireMouseMove (MouseEventArgs e)
+ {
+ OnMouseMove (e);
+ }
+
+ }
+
+ public ComboListBox (ComboBox owner) : base ()
+ {
+ this.owner = owner;
+ top_item = 0;
+ last_item = 0;
+ page_size = 0;
+ highlighted_item = null;
+
+ MouseDown += new MouseEventHandler (OnMouseDownPUW);
+ MouseUp += new MouseEventHandler (OnMouseUpPUW);
+ MouseMove += new MouseEventHandler (OnMouseMovePUW);
+ KeyDown += new KeyEventHandler (OnKeyDownPUW);
+ Paint += new PaintEventHandler (OnPaintPUW);
+ SetStyle (ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle (ControlStyles.ResizeRedraw | ControlStyles.Opaque, true);
+ }
+
+ protected override CreateParams CreateParams
+ {
+ get {
+ CreateParams cp = base.CreateParams;
+ if (owner != null && owner.DropDownStyle != ComboBoxStyle.Simple) {
+ cp.Style ^= (int) WindowStyles.WS_CHILD;
+ cp.Style |= (int) WindowStyles.WS_POPUP;
+ cp.ExStyle |= (int)(WindowExStyles.WS_EX_TOOLWINDOW | WindowExStyles.WS_EX_TOPMOST);
+ }
+ return cp;
+ }
+ }
+
+ #region Private Methods
+ // Calcs the listbox area
+ internal void CalcListBoxArea ()
+ {
+ int width, height;
+ int item_height = owner.ItemHeight;
+ bool show_scrollbar = false;
+
+ if (owner.DropDownStyle == ComboBoxStyle.Simple) {
+ width = owner.CBoxInfo.listbox_area.Width;
+ height = owner.CBoxInfo.listbox_area.Height;
+
+ if (owner.IntegralHeight == true) {
+ int remaining = (height -
+ ThemeEngine.Current.DrawComboListBoxDecorationBottom (owner.DropDownStyle) -
+ ThemeEngine.Current.DrawComboListBoxDecorationTop (owner.DropDownStyle)) %
+ (item_height - 2);
+
+ if (remaining > 0) {
+ height -= remaining;
+ }
+ }
+ }
+ else { // DropDown or DropDownList
+
+ width = owner.DropDownWidth;
+ int count = (owner.Items.Count <= owner.MaxDropDownItems) ? owner.Items.Count : owner.MaxDropDownItems;
+
+ if (owner.DrawMode == DrawMode.OwnerDrawVariable) {
+ height = 0;
+ for (int i = 0; i < count; i++) {
+ height += owner.GetItemHeight (i);
+ }
+
+ } else {
+ height = (item_height - 2) * count;
+ }
+
+
+ height += ThemeEngine.Current.DrawComboListBoxDecorationBottom (owner.DropDownStyle);
+ height += ThemeEngine.Current.DrawComboListBoxDecorationTop (owner.DropDownStyle);
+ }
+
+ if (owner.Items.Count <= owner.MaxDropDownItems) {
+
+ /* Does not need vertical scrollbar*/
+ if (vscrollbar_ctrl != null) {
+ vscrollbar_ctrl.Visible = false;
+ }
+ }
+ else {
+ /* Need vertical scrollbar */
+ if (vscrollbar_ctrl == null) {
+ vscrollbar_ctrl = new VScrollBarLB ();
+ vscrollbar_ctrl.Minimum = 0;
+ vscrollbar_ctrl.SmallChange = 1;
+ vscrollbar_ctrl.LargeChange = 1;
+ vscrollbar_ctrl.Maximum = 0;
+ vscrollbar_ctrl.ValueChanged += new EventHandler (VerticalScrollEvent);
+
+ Controls.AddImplicit (vscrollbar_ctrl);
+ }
+
+ vscrollbar_ctrl.Height = height - ThemeEngine.Current.DrawComboListBoxDecorationBottom (owner.DropDownStyle) -
+ ThemeEngine.Current.DrawComboListBoxDecorationTop (owner.DropDownStyle);
+
+ vscrollbar_ctrl.Location = new Point (width - vscrollbar_ctrl.Width - ThemeEngine.Current.DrawComboListBoxDecorationRight (owner.DropDownStyle),
+ ThemeEngine.Current.DrawComboListBoxDecorationTop (owner.DropDownStyle));
+
+ vscrollbar_ctrl.Maximum = owner.Items.Count - (owner.DropDownStyle == ComboBoxStyle.Simple ? page_size : owner.maxdrop_items);
+ show_scrollbar = vscrollbar_ctrl.Visible = true;
+
+ int hli = GetHighLightedIndex ();
+ if (hli > 0) {
+ hli = Math.Min (hli, vscrollbar_ctrl.Maximum);
+ vscrollbar_ctrl.Value = hli;
+ }
+ }
+
+ Size = new Size (width, height);
+ textarea_drawable = ClientRectangle;
+ textarea_drawable.Width = width;
+ textarea_drawable.Height = height;
+
+ // Exclude decorations
+ textarea_drawable.X += ThemeEngine.Current.DrawComboListBoxDecorationLeft (owner.DropDownStyle);
+ textarea_drawable.Y += ThemeEngine.Current.DrawComboListBoxDecorationTop (owner.DropDownStyle);
+ textarea_drawable.Width -= ThemeEngine.Current.DrawComboListBoxDecorationRight (owner.DropDownStyle);
+ textarea_drawable.Width -= ThemeEngine.Current.DrawComboListBoxDecorationLeft (owner.DropDownStyle);
+ textarea_drawable.Height -= ThemeEngine.Current.DrawComboListBoxDecorationBottom (owner.DropDownStyle);
+ textarea_drawable.Height -= ThemeEngine.Current.DrawComboListBoxDecorationTop (owner.DropDownStyle);
+
+ if (vscrollbar_ctrl != null && show_scrollbar)
+ textarea_drawable.Width -= vscrollbar_ctrl.Width;
+
+ last_item = LastVisibleItem ();
+ page_size = textarea_drawable.Height / (item_height - 2);
+ }
+
+ private void Draw (Rectangle clip, Graphics dc)
+ {
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush
+ (owner.BackColor), clip);
+
+ if (owner.Items.Count > 0) {
+ Rectangle item_rect;
+ DrawItemState state = DrawItemState.None;
+
+ for (int i = top_item; i <= last_item; i++) {
+ item_rect = GetItemDisplayRectangle (i, top_item);
+
+ if (clip.IntersectsWith (item_rect) == false)
+ continue;
+
+ /* Draw item */
+ state = DrawItemState.None;
+
+ if (i == GetHighLightedIndex () ) {
+ state |= DrawItemState.Selected;
+
+ if (owner.DropDownStyle == ComboBoxStyle.DropDownList) {
+ state |= DrawItemState.Focus;
+ }
+ }
+
+ owner.OnDrawItem (new DrawItemEventArgs (dc, owner.Font, item_rect,
+ i, state, owner.ForeColor, owner.BackColor));
+ }
+ }
+
+ ThemeEngine.Current.DrawComboListBoxDecorations (dc, owner, ClientRectangle);
+ }
+
+ public int GetHighLightedIndex ()
+ {
+ return owner.Items.IndexOf (highlighted_item);
+ }
+
+ public object GetHighLightedItem ()
+ {
+ return highlighted_item;
+ }
+
+ private Rectangle GetItemDisplayRectangle (int index, int first_displayble)
+ {
+ if (index < 0 || index >= owner.Items.Count)
+ throw new ArgumentOutOfRangeException ("GetItemRectangle index out of range.");
+
+ Rectangle item_rect = new Rectangle ();
+ int height = owner.GetItemHeight (index);
+
+ item_rect.X = ThemeEngine.Current.DrawComboListBoxDecorationRight (owner.DropDownStyle);
+ item_rect.Width = textarea_drawable.Width;
+ item_rect.Y = ((height - 2) * (index - first_displayble));
+
+ if (owner.dropdown_style == ComboBoxStyle.Simple)
+ item_rect.Y += 2;
+
+ item_rect.Height = height;
+ return item_rect;
+ }
+
+ public void HideWindow ()
+ {
+ if (owner.DropDownStyle == ComboBoxStyle.Simple)
+ return;
+
+ Capture = false;
+ Hide ();
+ highlighted_item = -1;
+ owner.DropDownListBoxFinished ();
+ }
+
+ private int IndexFromPointDisplayRectangle (int x, int y)
+ {
+ for (int i = top_item; i <= last_item; i++) {
+ if (GetItemDisplayRectangle (i, top_item).Contains (x, y) == true)
+ return i;
+ }
+
+ return -1;
+ }
+
+ protected override bool IsInputKey (Keys keyData)
+ {
+ return owner.IsInputKey (keyData);
+ }
+
+ private int LastVisibleItem ()
+ {
+ Rectangle item_rect;
+ int top_y = textarea_drawable.Y + textarea_drawable.Height;
+ int i = 0;
+
+ for (i = top_item; i < owner.Items.Count; i++) {
+ item_rect = GetItemDisplayRectangle (i, top_item);
+ if (item_rect.Y + item_rect.Height > top_y) {
+ return i;
+ }
+ }
+ return i - 1;
+ }
+
+ private void NavigateItemVisually (ItemNavigation navigation)
+ {
+ int item = -1;
+
+ switch (navigation) {
+ case ItemNavigation.Next: {
+ if (GetHighLightedIndex () + 1 < owner.Items.Count) {
+
+ if (GetHighLightedIndex () + 1 > last_item) {
+ top_item++;
+ vscrollbar_ctrl.Value = top_item;
+ }
+ item = GetHighLightedIndex () + 1;
+ }
+ break;
+ }
+
+ case ItemNavigation.Previous: {
+ if (GetHighLightedIndex () > 0) {
+
+ if (GetHighLightedIndex () - 1 < top_item) {
+ top_item--;
+ vscrollbar_ctrl.Value = top_item;
+ }
+ item = GetHighLightedIndex () - 1;
+ }
+ break;
+ }
+
+ case ItemNavigation.NextPage: {
+ if (GetHighLightedIndex () + page_size - 1 >= owner.Items.Count) {
+ top_item = owner.Items.Count - page_size;
+ vscrollbar_ctrl.Value = top_item;
+ item = owner.Items.Count - 1;
+ }
+ else {
+ if (GetHighLightedIndex () + page_size - 1 > last_item) {
+ top_item = GetHighLightedIndex ();
+ vscrollbar_ctrl.Value = GetHighLightedIndex ();
+ }
+
+ item = GetHighLightedIndex () + page_size - 1;
+ }
+ break;
+ }
+
+ case ItemNavigation.PreviousPage: {
+
+ /* Go to the first item*/
+ if (GetHighLightedIndex () - (page_size - 1) <= 0) {
+
+ top_item = 0;
+ vscrollbar_ctrl.Value = top_item;
+ item = 0;
+ }
+ else { /* One page back */
+ if (GetHighLightedIndex () - (page_size - 1) < top_item) {
+ top_item = GetHighLightedIndex () - (page_size - 1);
+ vscrollbar_ctrl.Value = top_item;
+ }
+
+ item = GetHighLightedIndex () - (page_size - 1);
+ }
+
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ if (item != -1) {
+ SetHighLightedItem (owner.Items[item]);
+
+ owner.OnSelectionChangeCommitted (new EventArgs ());
+
+ if (owner.DropDownStyle == ComboBoxStyle.Simple) {
+ owner.SetControlText (owner.GetItemText (owner.Items[item]));
+ }
+ }
+ }
+
+ private void OnKeyDownPUW (object sender, KeyEventArgs e)
+ {
+ switch (e.KeyCode) {
+ case Keys.Up:
+ NavigateItemVisually (ItemNavigation.Previous);
+ break;
+
+ case Keys.Down:
+ NavigateItemVisually (ItemNavigation.Next);
+ break;
+
+ case Keys.PageUp:
+ NavigateItemVisually (ItemNavigation.PreviousPage);
+ break;
+
+ case Keys.PageDown:
+ NavigateItemVisually (ItemNavigation.NextPage);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ public void SetHighLightedItem (object item)
+ {
+ Rectangle invalidate = Rectangle.Empty;
+ int hli;
+
+ if (GetHighLightedItem () == item)
+ return;
+
+ /* Previous item */
+ hli = GetHighLightedIndex ();
+ if (hli != -1) {
+ invalidate = GetItemDisplayRectangle (hli, top_item);
+ }
+
+ highlighted_item = item;
+
+ if (highlighted_item != null) {
+ /* Current item */
+ invalidate = Rectangle.Union (invalidate,
+ GetItemDisplayRectangle (GetHighLightedIndex (), top_item));
+
+ }
+
+ if (ClientRectangle.IntersectsWith (invalidate))
+ Invalidate (invalidate);
+ }
+
+ public void SetTopItem (int item)
+ {
+ top_item = item;
+ UpdateLastVisibleItem ();
+ Refresh ();
+ }
+
+ private void OnMouseDownPUW (object sender, MouseEventArgs e)
+ {
+ Rectangle scrollbar_screenrect;
+ Point mouse_screen, scrollbar_screen;
+ mouse_screen = PointToScreen (new Point (e.X, e.Y));
+
+ /* Click on an element ? */
+ int index = IndexFromPointDisplayRectangle (e.X, e.Y);
+ if (index != -1) {
+ owner.SelectedIndex = index;
+ SetHighLightedItem (owner.Items[index]);
+ owner.OnSelectionChangeCommitted (new EventArgs ());
+ HideWindow ();
+ return;
+ }
+
+ if (owner.DropDownStyle == ComboBoxStyle.Simple)
+ return;
+
+ /* Reroute event to scrollbar */
+ if (vscrollbar_ctrl != null && vscrollbar_ctrl.Visible == true) {
+ scrollbar_screenrect = vscrollbar_ctrl.ClientRectangle;
+ scrollbar_screen = PointToScreen (vscrollbar_ctrl.Location);
+ scrollbar_screenrect.X = scrollbar_screen.X;
+ scrollbar_screenrect.Y = scrollbar_screen.Y;
+
+ if (scrollbar_screenrect.Contains (mouse_screen)){
+ Point pnt_client = vscrollbar_ctrl.PointToClient (mouse_screen);
+ vscrollbar_ctrl.FireMouseDown (new MouseEventArgs (e.Button, e.Clicks,
+ pnt_client.X, pnt_client.Y, e.Delta));
+ } else { /* Click in a non-client area*/
+ HideWindow ();
+ }
+ } else { /* Click in a non-client area*/
+ HideWindow ();
+ }
+ }
+
+ private void OnMouseMovePUW (object sender, MouseEventArgs e)
+ {
+ if (owner.DropDownStyle == ComboBoxStyle.Simple)
+ return;
+
+ int index = IndexFromPointDisplayRectangle (e.X, e.Y);
+
+ if (index != -1) {
+ SetHighLightedItem (owner.Items[index]);
+ return;
+ }
+
+ if (owner.DropDownStyle == ComboBoxStyle.Simple)
+ return;
+
+ /* Reroute event to scrollbar */
+ if (vscrollbar_ctrl != null && vscrollbar_ctrl.Visible == true) {
+ Rectangle scrollbar_screenrect;
+ Point mouse_screen, scrollbar_screen;
+ mouse_screen = PointToScreen (new Point (e.X, e.Y));
+
+ scrollbar_screenrect = vscrollbar_ctrl.ClientRectangle;
+ scrollbar_screen = PointToScreen (vscrollbar_ctrl.Location);
+ scrollbar_screenrect.X = scrollbar_screen.X;
+ scrollbar_screenrect.Y = scrollbar_screen.Y;
+
+ if (scrollbar_screenrect.Contains (mouse_screen)){
+ Point pnt_client = vscrollbar_ctrl.PointToClient (mouse_screen);
+
+ vscrollbar_ctrl.FireMouseMove (new MouseEventArgs (e.Button, e.Clicks,
+ pnt_client.X, pnt_client.Y, e.Delta));
+ }
+ }
+ }
+
+ private void OnMouseUpPUW (object sender, MouseEventArgs e)
+ {
+ if (owner.DropDownStyle == ComboBoxStyle.Simple)
+ return;
+
+ /* Reroute event to scrollbar */
+ Rectangle scrollbar_screenrect;
+ Point mouse_screen, scrollbar_screen;
+ mouse_screen = PointToScreen (new Point (e.X, e.Y));
+
+ if (vscrollbar_ctrl != null && vscrollbar_ctrl.Visible == true) {
+ scrollbar_screenrect = vscrollbar_ctrl.ClientRectangle;
+ scrollbar_screen = PointToScreen (vscrollbar_ctrl.Location);
+ scrollbar_screenrect.X = scrollbar_screen.X;
+ scrollbar_screenrect.Y = scrollbar_screen.Y;
+
+ if (scrollbar_screenrect.Contains (mouse_screen)){
+ Point pnt_client = vscrollbar_ctrl.PointToClient (mouse_screen);
+
+ vscrollbar_ctrl.FireMouseUp (new MouseEventArgs (e.Button, e.Clicks,
+ pnt_client.X, pnt_client.Y, e.Delta));
+ }
+ }
+ }
+
+ private void OnPaintPUW (Object o, PaintEventArgs pevent)
+ {
+ Draw (pevent.ClipRectangle,pevent.Graphics);
+ }
+
+ public bool ShowWindow ()
+ {
+ if (owner.DropDownStyle != ComboBoxStyle.Simple && owner.Items.Count == 0)
+ return false;
+
+ SetHighLightedItem (owner.SelectedItem);
+ int index = GetHighLightedIndex ();
+
+ CalcListBoxArea ();
+ Show ();
+
+ if (owner.DropDownStyle != ComboBoxStyle.Simple) {
+ Capture = true;
+ }
+
+ Refresh ();
+
+ if (owner.DropDown != null) {
+ owner.DropDown (owner, EventArgs.Empty);
+ }
+
+ return true;
+ }
+
+ public void UpdateLastVisibleItem ()
+ {
+ last_item = LastVisibleItem ();
+ }
+
+ // Value Changed
+ private void VerticalScrollEvent (object sender, EventArgs e)
+ {
+ if (top_item == vscrollbar_ctrl.Value)
+ return;
+
+ top_item = vscrollbar_ctrl.Value;
+ UpdateLastVisibleItem ();
+ Refresh ();
+ }
+
+ #endregion Private Methods
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBoxStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBoxStyle.cs
new file mode 100644
index 00000000000..d2c576bd751
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBoxStyle.cs
@@ -0,0 +1,37 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+
+using System;
+
+namespace System.Windows.Forms {
+
+ public enum ComboBoxStyle
+ {
+ Simple = 0,
+ DropDown = 1,
+ DropDownList = 2,
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CommonDialog.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CommonDialog.cs
new file mode 100644
index 00000000000..dd201b049a4
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CommonDialog.cs
@@ -0,0 +1,142 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// NOT COMPLETE
+
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+ [ToolboxItemFilter("System.Windows.Forms")]
+ public abstract class CommonDialog : System.ComponentModel.Component {
+ #region DialogForm
+ internal class DialogForm : Form {
+ #region DialogForm Local Variables
+ protected CommonDialog owner;
+ #endregion DialogForm Local Variables
+
+ #region DialogForm Constructors
+ internal DialogForm(CommonDialog owner) {
+ this.owner = owner;
+ }
+ #endregion DialogForm Constructors
+
+ #region Protected Instance Properties
+ protected override CreateParams CreateParams {
+ get {
+ CreateParams cp;
+
+ ControlBox = true;
+ MinimizeBox = false;
+ MaximizeBox = false;
+
+ cp = base.CreateParams;
+
+ cp.Style = (int)(WindowStyles.WS_POPUP | WindowStyles.WS_CAPTION | WindowStyles.WS_SYSMENU | WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_CLIPSIBLINGS);
+ if (!is_enabled) {
+ cp.Style |= (int)(WindowStyles.WS_DISABLED);
+ }
+
+ return cp;
+ }
+ }
+ #endregion // Protected Instance Properties
+
+ #region Internal Methods
+ internal DialogResult RunDialog () {
+ this.StartPosition = FormStartPosition.CenterScreen;
+
+ owner.InitFormsSize (this);
+
+ this.ShowDialog ();
+
+ return this.DialogResult;
+
+ }
+ #endregion Internal Methods
+ }
+ #endregion DialogForm
+
+ #region Local Variables
+ internal DialogForm form;
+ #endregion Local Variables
+
+ #region Public Constructors
+ public CommonDialog() {
+ form = new DialogForm(this);
+ }
+ #endregion Public Constructors
+
+ #region Internal Methods
+ internal virtual void InitFormsSize(Form form) {
+ // Override this to set a default size for the form
+ form.Width = 200;
+ form.Height = 200;
+ }
+ #endregion Internal Methods
+
+ #region Public Instance Methods
+ public abstract void Reset();
+
+ public DialogResult ShowDialog() {
+ return ShowDialog(null);
+ }
+
+ public DialogResult ShowDialog(IWin32Window ownerWin32) {
+ DialogResult result;
+
+ // Prep the dialog
+ RunDialog(form.Handle);
+
+ // Run
+ result = form.ShowDialog(ownerWin32);
+
+ return form.DialogResult;
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected virtual IntPtr HookProc(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam) {
+ return IntPtr.Zero;
+ }
+
+ protected virtual void OnHelpRequest(EventArgs e) {
+ if (HelpRequest != null) {
+ HelpRequest(this, e);
+ }
+ }
+
+ protected virtual IntPtr OwnerWndProc(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam) {
+ return IntPtr.Zero;
+ }
+
+ protected abstract bool RunDialog(IntPtr hwndOwner);
+ #endregion // Protected Instance Methods
+
+ #region Events
+ public event EventHandler HelpRequest;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComponentModel.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComponentModel.cs
new file mode 100644
index 00000000000..4db46afe02c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComponentModel.cs
@@ -0,0 +1,54 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+// NOT COMPLETE
+
+using System;
+using System.ComponentModel.Design;
+
+namespace System.Windows.Forms.ComponentModel.Com2Interop {
+ public class Com2Variant {
+ public Com2Variant() {
+ throw new NotImplementedException();
+ }
+ }
+
+ public interface ICom2PropertyPageDisplayService {
+ void ShowPropertyPage(string title, object component, int dispid, Guid pageGuid, IntPtr parentHandle);
+ }
+
+ public interface IComPropertyBrowser {
+ bool InPropertySet {
+ get ;
+ }
+ void DropDownDone();
+ bool EnsurePendingChangesCommitted();
+ void HandleF4();
+ void LoadState(Microsoft.Win32.RegistryKey key);
+ void SaveState(Microsoft.Win32.RegistryKey key);
+ event ComponentRenameEventHandler ComComponentNameChanged;
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContainerControl.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContainerControl.cs
new file mode 100644
index 00000000000..276f9baf6f8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContainerControl.cs
@@ -0,0 +1,343 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// NOT COMPLETE
+
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+ public class ContainerControl : ScrollableControl, IContainerControl {
+ private Control active_control;
+ private Control focused_control;
+ private Control unvalidated_control;
+#if NET_2_0
+ private SizeF auto_scale_dimensions;
+ private AutoScaleMode auto_scale_mode;
+#endif
+
+ #region Public Constructors
+ public ContainerControl() {
+ active_control = null;
+ focused_control = null;
+ unvalidated_control = null;
+ ControlRemoved += new ControlEventHandler(OnControlRemoved);
+#if NET_2_0
+ auto_scale_dimensions = SizeF.Empty;
+ auto_scale_mode = AutoScaleMode.None;
+#endif
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ [Browsable (false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Control ActiveControl {
+ get {
+ return active_control;
+ }
+
+ set {
+ if ((active_control==value) || (value==null)) {
+ return;
+ }
+
+ active_control = value;
+
+ if (!Contains(value) && this != value) {
+ throw new ArgumentException("Not a child control");
+ }
+
+ if (this is Form)
+ CheckAcceptButton();
+
+ // Scroll control into view
+
+ // Let the control know it's selected
+ Select(value);
+ }
+ }
+
+#if NET_2_0
+ public SizeF AutoScaleDimensions {
+ get {
+ return auto_scale_dimensions;
+ }
+
+ set {
+ auto_scale_dimensions = value;
+ }
+ }
+
+ public SizeF AutoScaleFactor {
+ get {
+ if (auto_scale_dimensions.IsEmpty) {
+ return new SizeF(1f, 1f);
+ }
+ return new SizeF(CurrentAutoScaleDimensions.Width / auto_scale_dimensions.Width,
+ CurrentAutoScaleDimensions.Height / auto_scale_dimensions.Height);
+ }
+ }
+
+
+ [MonoTODO("Call scaling method")]
+ public virtual AutoScaleMode AutoScaleMode {
+ get {
+ return auto_scale_mode;
+ }
+ set {
+ if (auto_scale_mode != value) {
+ auto_scale_mode = value;
+
+ // Trigger scaling
+ }
+ }
+ }
+#endif // NET_2_0
+
+ [Browsable (false)]
+ public override BindingContext BindingContext {
+ get {
+ if (base.BindingContext == null) {
+ base.BindingContext = new BindingContext();
+ }
+ return base.BindingContext;
+ }
+
+ set {
+ base.BindingContext = value;
+ }
+ }
+
+#if NET_2_0
+ [MonoTODO("Revisit when System.Drawing.GDI.WindowsGraphics.GetTextMetrics is done or come up with other cross-plat avg. font width calc method")]
+ public SizeF CurrentAutoScaleDimensions {
+ get {
+ switch(auto_scale_mode) {
+ case AutoScaleMode.Dpi: {
+ Bitmap bmp;
+ Graphics g;
+ SizeF size;
+
+ bmp = new Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
+ g = Graphics.FromImage(bmp);
+ size = new SizeF(g.DpiX, g.DpiY);
+ g.Dispose();
+ bmp.Dispose();
+ return size;
+ }
+
+ case AutoScaleMode.Font: {
+ // http://msdn2.microsoft.com/en-us/library/system.windows.forms.containercontrol.currentautoscaledimensions(VS.80).aspx
+ // Implement System.Drawing.GDI.WindowsGraphics.GetTextMetrics first...
+ break;
+ }
+ }
+
+ return auto_scale_dimensions;
+ }
+ }
+#endif
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Form ParentForm {
+ get {
+ Control parent;
+
+ parent = this.parent;
+
+ while (parent != null) {
+ if (parent is Form) {
+ return (Form)parent;
+ }
+ parent = parent.parent;
+ }
+
+ return null;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Methods
+ protected override CreateParams CreateParams {
+ get {
+ return base.CreateParams;
+ }
+ }
+ #endregion // Public Instance Methods
+
+ #region Public Instance Methods
+ [MonoTODO]
+ static bool ValidateWarned;
+ public bool Validate() {
+ //throw new NotImplementedException();
+ if (!ValidateWarned) {
+ Console.WriteLine("ContainerControl.Validate is not yet implemented");
+ ValidateWarned = true;
+ }
+ return true;
+ }
+
+ bool IContainerControl.ActivateControl(Control control) {
+ return Select(control);
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ protected override void AdjustFormScrollbars(bool displayScrollbars) {
+ base.AdjustFormScrollbars(displayScrollbars);
+ }
+
+ protected override void Dispose(bool disposing) {
+ base.Dispose(disposing);
+ }
+
+ // LAMESPEC This used to be documented, but it's not in code
+ // and no longer listed in MSDN2
+ // [EditorBrowsable (EditorBrowsableState.Advanced)]
+ // protected override void OnControlRemoved(ControlEventArgs e) {
+ private void OnControlRemoved(object sender, ControlEventArgs e) {
+ if (e.Control == this.unvalidated_control) {
+ this.unvalidated_control = null;
+ }
+
+ if (e.Control == this.active_control) {
+ this.unvalidated_control = null;
+ }
+
+ // base.OnControlRemoved(e);
+ }
+
+ protected override void OnCreateControl() {
+ base.OnCreateControl();
+ // MS seems to call this here, it gets the whole databinding process started
+ OnBindingContextChanged (EventArgs.Empty);
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ protected override bool ProcessDialogChar(char charCode) {
+ if (GetTopLevel()) {
+ if (ProcessMnemonic(charCode)) {
+ return true;
+ }
+ }
+ return base.ProcessDialogChar(charCode);
+ }
+
+ protected override bool ProcessDialogKey(Keys keyData) {
+ Keys key;
+ bool forward;
+
+ key = keyData & Keys.KeyCode;
+ forward = true;
+
+ switch (key) {
+ case Keys.Tab: {
+ if (ProcessTabKey((Control.ModifierKeys & Keys.Shift) == 0)) {
+ return true;
+ }
+ break;
+ }
+
+ case Keys.Left: {
+ forward = false;
+ goto case Keys.Down;
+ }
+
+ case Keys.Up: {
+ forward = false;
+ goto case Keys.Down;
+ }
+
+ case Keys.Right: {
+ goto case Keys.Down;
+ }
+ case Keys.Down: {
+ if (SelectNextControl(active_control, forward, false, false, true)) {
+ return true;
+ }
+ break;
+ }
+
+
+ }
+ return base.ProcessDialogKey(keyData);
+ }
+
+ protected override bool ProcessMnemonic(char charCode) {
+ bool wrapped;
+ Control c;
+
+ wrapped = false;
+ c = active_control;
+
+ do {
+ c = GetNextControl(c, true);
+ if (c != null) {
+ // This is stupid. I want to be able to call c.ProcessMnemonic directly
+ if (c.ProcessControlMnemonic(charCode)) {
+ return(true);
+ }
+ continue;
+ } else {
+ if (wrapped) {
+ break;
+ }
+ wrapped = true;
+ }
+ } while (c != active_control);
+
+ return false;
+ }
+
+ protected virtual bool ProcessTabKey(bool forward) {
+ return SelectNextControl(active_control, forward, true, true, true);
+ }
+
+ protected override void Select(bool directed, bool forward) {
+ base.Select(directed, forward);
+ }
+
+ protected virtual void UpdateDefaultButton() {
+ // MS Internal
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ protected override void WndProc(ref Message m) {
+ base.WndProc(ref m);
+ }
+ #endregion // Protected Instance Methods
+
+ internal virtual void CheckAcceptButton()
+ {
+ // do nothing here, only called if it is a Form
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContentsResizedEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContentsResizedEventArgs.cs
new file mode 100644
index 00000000000..765276f6cda
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContentsResizedEventArgs.cs
@@ -0,0 +1,51 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+using System.Drawing;
+
+namespace System.Windows.Forms {
+ public class ContentsResizedEventArgs : EventArgs {
+ #region Local Variables
+ Rectangle rect;
+ #endregion // Local Variables
+
+ #region Public Constructors
+ public ContentsResizedEventArgs(Rectangle newRectangle) {
+ rect = newRectangle;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public Rectangle NewRectangle {
+ get {
+ return rect;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContentsResizedEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContentsResizedEventHandler.cs
new file mode 100644
index 00000000000..6a9f6d840a0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContentsResizedEventHandler.cs
@@ -0,0 +1,31 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void ContentsResizedEventHandler(object sender, ContentsResizedEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContextMenu.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContextMenu.cs
new file mode 100644
index 00000000000..cb78a9fb6d0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContextMenu.cs
@@ -0,0 +1,98 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+//
+
+
+// COMPLETE
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+
+namespace System.Windows.Forms
+{
+ [DefaultEvent("Popup")]
+ public class ContextMenu : Menu
+ {
+ private RightToLeft right_to_left;
+ private Control src_control;
+
+ #region Events
+ public event EventHandler Popup;
+ #endregion Events
+
+ public ContextMenu () : base (null)
+ {
+ right_to_left = RightToLeft.Inherit;
+ }
+
+ public ContextMenu (MenuItem[] items) : base (items)
+ {
+ right_to_left = RightToLeft.Inherit;
+ }
+
+ #region Public Properties
+ [Localizable(true)]
+ public virtual RightToLeft RightToLeft {
+ get { return right_to_left; }
+ set { right_to_left = value; }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Control SourceControl {
+ get { return src_control; }
+ }
+
+ #endregion Public Properties
+
+ #region Public Methods
+
+ protected internal virtual void OnPopup (EventArgs e)
+ {
+ if (Popup != null)
+ Popup (this, e);
+ }
+
+ public void Show (Control control, Point pos)
+ {
+ if (control == null)
+ throw new ArgumentException ();
+
+ src_control = control;
+
+ OnPopup (EventArgs.Empty);
+ pos = control.PointToScreen (pos);
+ MenuTracker.TrackPopupMenu (this, pos);
+ }
+
+ #endregion Public Methods
+
+
+ }
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
new file mode 100644
index 00000000000..e6eaebddd02
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
@@ -0,0 +1,4517 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+// Partially based on work by:
+// Aleksey Ryabchuk ryabchuk@yahoo.com
+// Alexandre Pigolkine pigolkine@gmx.de
+// Dennis Hayes dennish@raytek.com
+// Jaak Simm jaaksimm@firm.ee
+// John Sohn jsohn@columbus.rr.com
+//
+
+// COMPLETE
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.ComponentModel.Design.Serialization;
+using System.Collections;
+using System.Diagnostics;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Security;
+using System.Threading;
+
+
+namespace System.Windows.Forms
+{
+ [Designer("System.Windows.Forms.Design.ControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ [DefaultProperty("Text")]
+ [DefaultEvent("Click")]
+ [DesignerSerializer("System.Windows.Forms.Design.ControlCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
+ [ToolboxItemFilter("System.Windows.Forms")]
+ public class Control : Component, ISynchronizeInvoke, IWin32Window
+ {
+ #region Local Variables
+
+ // Basic
+ internal Rectangle bounds; // bounding rectangle for control (client area + decorations)
+ internal object creator_thread; // thread that created the control
+ internal ControlNativeWindow window; // object for native window handle
+ internal string name; // for object naming
+
+ // State
+ internal bool is_created; // true if OnCreateControl has been sent
+ internal bool has_focus; // true if control has focus
+ internal bool is_visible; // true if control is visible
+ internal bool is_entered; // is the mouse inside the control?
+ internal bool is_enabled; // true if control is enabled (usable/not grayed out)
+ internal bool is_selected; // true if control is selected
+ internal bool is_accessible; // true if the control is visible to accessibility applications
+ internal bool is_captured; // tracks if the control has captured the mouse
+ internal bool is_toplevel; // tracks if the control is a toplevel window
+ internal bool is_recreating; // tracks if the handle for the control is being recreated
+ internal bool causes_validation; // tracks if validation is executed on changes
+ internal int tab_index; // position in tab order of siblings
+ internal bool tab_stop = true; // is the control a tab stop?
+ internal bool is_disposed; // has the window already been disposed?
+ internal Size client_size; // size of the client area (window excluding decorations)
+ internal Rectangle client_rect; // rectangle with the client area (window excluding decorations)
+ internal ControlStyles control_style; // rather win32-specific, style bits for control
+ internal ImeMode ime_mode = ImeMode.Inherit;
+ internal bool layout_pending; // true if our parent needs to re-layout us
+ internal object control_tag; // object that contains data about our control
+ internal int mouse_clicks; // Counter for mouse clicks
+ internal Cursor cursor; // Cursor for the window
+ internal bool allow_drop; // true if the control accepts droping objects on it
+
+ // Visuals
+ internal Color foreground_color; // foreground color for control
+ internal Color background_color; // background color for control
+ internal Image background_image; // background image for control
+ internal Font font; // font for control
+ internal string text; // window/title text for control
+ internal BorderStyle border_style; // Border style of control
+
+ // Layout
+ internal AnchorStyles anchor_style; // anchoring requirements for our control
+ internal DockStyle dock_style; // docking requirements for our control (supercedes anchoring)
+ internal int dist_left; // distance to the left border of the parent
+ internal int dist_top; // distance to the top border of the parent
+ internal int dist_right; // distance to the right border of the parent
+ internal int dist_bottom; // distance to the bottom border of the parent
+
+ // to be categorized...
+ static internal ArrayList controls = new ArrayList(); // All of the application's controls, in a flat list
+ internal ControlCollection child_controls; // our children
+ internal Control parent; // our parent control
+ internal AccessibleObject accessibility_object; // object that contains accessibility information about our control
+ internal BindingContext binding_context; // TODO
+ internal RightToLeft right_to_left; // drawing direction for control
+ internal int layout_suspended;
+ internal ContextMenu context_menu; // Context menu associated with the control
+
+ private Graphics dc_mem; // Graphics context for double buffering
+ private Bitmap bmp_mem; // Bitmap for double buffering control
+ private bool needs_redraw = true;
+
+ private ControlBindingsCollection data_bindings;
+
+#if NET_2_0
+ internal bool use_compatible_text_rendering;
+ private Padding padding;
+#endif
+
+ #endregion // Local Variables
+
+ #region Private Classes
+ // This helper class allows us to dispatch messages to Control.WndProc
+ internal class ControlNativeWindow : NativeWindow {
+ private Control owner;
+
+ public ControlNativeWindow(Control control) : base() {
+ this.owner=control;
+ }
+
+
+ public Control Owner {
+ get {
+ return owner;
+ }
+ }
+
+ static internal Control ControlFromHandle(IntPtr hWnd) {
+ ControlNativeWindow window;
+
+ window = (ControlNativeWindow)window_collection[hWnd];
+ if (window != null) {
+ return window.owner;
+ }
+
+ return null;
+ }
+
+ protected override void WndProc(ref Message m) {
+ owner.WndProc(ref m);
+ }
+ }
+ #endregion
+
+ #region Public Classes
+ [ComVisible(true)]
+ public class ControlAccessibleObject : AccessibleObject {
+ #region ControlAccessibleObject Local Variables
+ private Control owner;
+ #endregion // ControlAccessibleObject Local Variables
+
+ #region ControlAccessibleObject Constructors
+ public ControlAccessibleObject(Control ownerControl) {
+ this.owner = ownerControl;
+ }
+ #endregion // ControlAccessibleObject Constructors
+
+ #region ControlAccessibleObject Public Instance Properties
+ public override string DefaultAction {
+ get {
+ return base.DefaultAction;
+ }
+ }
+
+ public override string Description {
+ get {
+ return base.Description;
+ }
+ }
+
+ public IntPtr Handle {
+ get {
+ return owner.Handle;
+ }
+
+ set {
+ // We don't want to let them set it
+ }
+ }
+
+ public override string Help {
+ get {
+ return base.Help;
+ }
+ }
+
+ public override string KeyboardShortcut {
+ get {
+ return base.KeyboardShortcut;
+ }
+ }
+
+ public override string Name {
+ get {
+ return base.Name;
+ }
+
+ set {
+ base.Name = value;
+ }
+ }
+
+ public Control Owner {
+ get {
+ return owner;
+ }
+ }
+
+ public override AccessibleObject Parent {
+ get {
+ return base.Parent;
+ }
+ }
+
+
+ public override AccessibleRole Role {
+ get {
+ return base.Role;
+ }
+ }
+ #endregion // ControlAccessibleObject Public Instance Properties
+
+ #region ControlAccessibleObject Public Instance Methods
+ public override int GetHelpTopic(out string FileName) {
+ return base.GetHelpTopic (out FileName);
+ }
+
+ [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
+ public void NotifyClients(AccessibleEvents accEvent) {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
+ public void NotifyClients(AccessibleEvents accEvent, int childID) {
+ throw new NotImplementedException();
+ }
+
+ public override string ToString() {
+ return "ControlAccessibleObject: Owner = " + owner.ToString() + ", Text: " + owner.text;
+ }
+
+ #endregion // ControlAccessibleObject Public Instance Methods
+ }
+
+ [DesignerSerializer("System.Windows.Forms.Design.ControlCollectionCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
+ [ListBindable(false)]
+ public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
+ #region ControlCollection Local Variables
+ private ArrayList list;
+ internal ArrayList impl_list;
+ private Control [] all_controls;
+ internal Control owner;
+ #endregion // ControlCollection Local Variables
+
+ #region ControlCollection Public Constructor
+ public ControlCollection(Control owner) {
+ this.owner=owner;
+ this.list=new ArrayList();
+ }
+ #endregion
+
+ #region ControlCollection Public Instance Properties
+ public int Count {
+ get {
+ return list.Count;
+ }
+ }
+
+ public virtual bool IsReadOnly {
+ get {
+ return list.IsReadOnly;
+ }
+ }
+
+ public virtual Control this[int index] {
+ get {
+ if (index < 0 || index >= list.Count) {
+ throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
+ }
+ return (Control)list[index];
+ }
+ }
+ #endregion // ControlCollection Public Instance Properties
+
+ #region ControlCollection Private Instance Methods
+ public virtual void Add (Control value)
+ {
+ if (value == null)
+ return;
+
+ if (Contains (value)) {
+ owner.PerformLayout();
+ return;
+ }
+
+ if (value.tab_index == -1) {
+ int end;
+ int index;
+ int use;
+
+ use = 0;
+ end = owner.child_controls.Count;
+ for (int i = 0; i < end; i++) {
+ index = owner.child_controls[i].tab_index;
+ if (index >= use) {
+ use = index + 1;
+ }
+ }
+ value.tab_index = use;
+ }
+
+ if (value.parent != null) {
+ value.parent.Controls.Remove(value);
+ }
+
+ all_controls = null;
+ list.Add (value);
+
+ value.ChangeParent(owner);
+
+ value.InitLayout();
+
+ owner.UpdateZOrder();
+ owner.PerformLayout(value, "Parent");
+ owner.OnControlAdded(new ControlEventArgs(value));
+ }
+
+ internal void AddToList (Control c)
+ {
+ all_controls = null;
+ list.Add (c);
+ }
+
+ internal virtual void AddImplicit (Control control)
+ {
+ if (impl_list == null)
+ impl_list = new ArrayList ();
+ all_controls = null;
+ impl_list.Add (control);
+
+ control.ChangeParent (owner);
+ control.InitLayout ();
+ owner.UpdateZOrder ();
+ owner.PerformLayout (control, "Parent");
+ owner.OnControlAdded (new ControlEventArgs (control));
+ }
+
+ public virtual void AddRange (Control[] controls)
+ {
+ if (controls == null)
+ throw new ArgumentNullException ("controls");
+
+ owner.SuspendLayout ();
+
+ try {
+ for (int i = 0; i < controls.Length; i++)
+ Add (controls[i]);
+ } finally {
+ owner.ResumeLayout ();
+ }
+ }
+
+ internal virtual void AddRangeImplicit (Control [] controls)
+ {
+ if (controls == null)
+ throw new ArgumentNullException ("controls");
+
+ owner.SuspendLayout ();
+
+ try {
+ for (int i = 0; i < controls.Length; i++)
+ AddImplicit (controls [i]);
+ } finally {
+ owner.ResumeLayout ();
+ }
+ }
+
+ public virtual void Clear ()
+ {
+ all_controls = null;
+
+ // MS sends remove events in reverse order
+ while (list.Count > 0) {
+ RemoveAt(list.Count - 1);
+ }
+ }
+
+ internal virtual void ClearImplicit ()
+ {
+ if (impl_list == null)
+ return;
+ all_controls = null;
+ impl_list.Clear ();
+ }
+
+ public bool Contains (Control value)
+ {
+ for (int i = list.Count; i > 0; ) {
+ i--;
+
+ if (list [i] == value) {
+ // Do we need to do anything here?
+ return true;
+ }
+ }
+ return false;
+ }
+
+ internal bool ImplicitContains (Control value)
+ {
+ if (impl_list == null)
+ return false;
+
+ for (int i = impl_list.Count; i > 0; ) {
+ i--;
+
+ if (impl_list [i] == value) {
+ // Do we need to do anything here?
+ return true;
+ }
+ }
+ return false;
+ }
+
+ internal bool AllContains (Control value)
+ {
+ return Contains (value) || ImplicitContains (value);
+ }
+
+ public virtual void CopyTo (Array array, int index)
+ {
+ list.CopyTo(array, index);
+ }
+
+ public override bool Equals(object other) {
+ if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
+ return(true);
+ } else {
+ return(false);
+ }
+ }
+
+ public int GetChildIndex(Control child) {
+ return GetChildIndex(child, false);
+ }
+
+ public int GetChildIndex(Control child, bool throwException) {
+ int index;
+
+ index=list.IndexOf(child);
+
+ if (index==-1 && throwException) {
+ throw new ArgumentException("Not a child control", "child");
+ }
+ return index;
+ }
+
+ public IEnumerator GetEnumerator() {
+ return list.GetEnumerator();
+ }
+
+ internal IEnumerator GetAllEnumerator ()
+ {
+ Control [] res = GetAllControls ();
+ return res.GetEnumerator ();
+ }
+
+ internal Control [] GetAllControls ()
+ {
+ if (all_controls != null)
+ return all_controls;
+
+ if (impl_list == null)
+ return (Control []) list.ToArray (typeof (Control));
+
+ Control [] res = new Control [list.Count + impl_list.Count];
+ impl_list.CopyTo (res);
+ list.CopyTo (res, impl_list.Count);
+
+ return res;
+ }
+
+ public override int GetHashCode() {
+ return base.GetHashCode();
+ }
+
+ public int IndexOf(Control control) {
+ return list.IndexOf(control);
+ }
+
+ public virtual void Remove(Control value) {
+ all_controls = null;
+
+ owner.PerformLayout(value, "Parent");
+ owner.OnControlRemoved(new ControlEventArgs(value));
+ list.Remove(value);
+
+ value.ChangeParent(null);
+
+ owner.UpdateZOrder();
+ }
+
+ internal virtual void RemoveImplicit (Control control)
+ {
+ if (impl_list != null) {
+ all_controls = null;
+ owner.PerformLayout (control, "Parent");
+ owner.OnControlRemoved (new ControlEventArgs (control));
+ impl_list.Remove (control);
+ }
+ control.ChangeParent (null);
+ owner.UpdateZOrder ();
+ }
+
+ public void RemoveAt(int index) {
+ if (index < 0 || index >= list.Count) {
+ throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
+ }
+ Remove ((Control)list[index]);
+ }
+
+ public void SetChildIndex(Control child, int newIndex) {
+ int old_index;
+
+ old_index=list.IndexOf(child);
+ if (old_index==-1) {
+ throw new ArgumentException("Not a child control", "child");
+ }
+
+ if (old_index==newIndex) {
+ return;
+ }
+
+ list.RemoveAt(old_index);
+
+ if (newIndex>list.Count) {
+ list.Add(child);
+ } else {
+ list.Insert(newIndex, child);
+ }
+ owner.UpdateZOrder();
+ }
+ #endregion // ControlCollection Private Instance Methods
+
+ #region ControlCollection Interface Properties
+ object IList.this[int index] {
+ get {
+ if (index<0 || index>=list.Count) {
+ throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
+ }
+ return this[index];
+ }
+
+ set {
+ if (!(value is Control)) {
+ throw new ArgumentException("Object of type Control required", "value");
+ }
+
+ list[index]=(Control)value;
+ }
+ }
+
+ bool IList.IsFixedSize {
+ get {
+ return false;
+ }
+ }
+
+ bool IList.IsReadOnly {
+ get {
+ return list.IsReadOnly;
+ }
+ }
+
+ bool ICollection.IsSynchronized {
+ get {
+ return list.IsSynchronized;
+ }
+ }
+
+ object ICollection.SyncRoot {
+ get {
+ return list.SyncRoot;
+ }
+ }
+ #endregion // ControlCollection Interface Properties
+
+ #region ControlCollection Interface Methods
+ int IList.Add(object value) {
+ if (value == null) {
+ throw new ArgumentNullException("value", "Cannot add null controls");
+ }
+
+ if (!(value is Control)) {
+ throw new ArgumentException("Object of type Control required", "value");
+ }
+
+ return list.Add(value);
+ }
+
+ bool IList.Contains(object value) {
+ if (!(value is Control)) {
+ throw new ArgumentException("Object of type Control required", "value");
+ }
+
+ return this.Contains((Control) value);
+ }
+
+ int IList.IndexOf(object value) {
+ if (!(value is Control)) {
+ throw new ArgumentException("Object of type Control required", "value");
+ }
+
+ return this.IndexOf((Control) value);
+ }
+
+ void IList.Insert(int index, object value) {
+ if (!(value is Control)) {
+ throw new ArgumentException("Object of type Control required", "value");
+ }
+ all_controls = null;
+ list.Insert(index, value);
+ }
+
+ void IList.Remove(object value) {
+ if (!(value is Control)) {
+ throw new ArgumentException("Object of type Control required", "value");
+ }
+ all_controls = null;
+ list.Remove(value);
+ }
+
+ void ICollection.CopyTo(Array array, int index) {
+ if (list.Count>0) {
+ list.CopyTo(array, index);
+ }
+ }
+
+ Object ICloneable.Clone() {
+ ControlCollection clone = new ControlCollection(this.owner);
+ clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
+ return clone;
+ }
+ #endregion // ControlCollection Interface Methods
+ }
+ #endregion // ControlCollection Class
+
+ #region Public Constructors
+ public Control() {
+
+ anchor_style = AnchorStyles.Top | AnchorStyles.Left;
+
+ is_created = false;
+ is_visible = true;
+ is_captured = false;
+ is_disposed = false;
+ is_enabled = true;
+ is_entered = false;
+ layout_pending = false;
+ is_toplevel = false;
+ causes_validation = true;
+ has_focus = false;
+ layout_suspended = 0;
+ mouse_clicks = 1;
+ tab_index = -1;
+ cursor = null;
+ right_to_left = RightToLeft.Inherit;
+ border_style = BorderStyle.None;
+ background_color = Color.Empty;
+ dist_left = 0;
+ dist_right = 0;
+ dist_top = 0;
+ dist_bottom = 0;
+
+#if NET_2_0
+ use_compatible_text_rendering = Application.use_compatible_text_rendering;
+ padding = new Padding(0);
+#endif
+
+ control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
+ ControlStyles.Selectable | ControlStyles.StandardClick |
+ ControlStyles.StandardDoubleClick;
+
+ parent = null;
+ background_image = null;
+ text = string.Empty;
+ name = string.Empty;
+
+ window = new ControlNativeWindow(this);
+ child_controls = CreateControlsInstance();
+ client_size = new Size(DefaultSize.Width, DefaultSize.Height);
+ client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
+ XplatUI.CalculateWindowRect(ref client_rect, CreateParams.Style, CreateParams.ExStyle, null, out bounds);
+ if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
+ bounds.X=-1;
+ bounds.Y=-1;
+ }
+ }
+
+ public Control(Control parent, string text) : this() {
+ Text=text;
+ Parent=parent;
+ }
+
+ public Control(Control parent, string text, int left, int top, int width, int height) : this() {
+ Parent=parent;
+ bounds.X=left;
+ bounds.Y=top;
+ bounds.Width=width;
+ bounds.Height=height;
+ SetBoundsCore(left, top, width, height, BoundsSpecified.All);
+ Text=text;
+ }
+
+ public Control(string text) : this() {
+ Text=text;
+ }
+
+ public Control(string text, int left, int top, int width, int height) : this() {
+ bounds.X=left;
+ bounds.Y=top;
+ bounds.Width=width;
+ bounds.Height=height;
+ SetBoundsCore(left, top, width, height, BoundsSpecified.All);
+ Text=text;
+ }
+
+ private delegate void RemoveDelegate(object c);
+
+ protected override void Dispose(bool disposing) {
+ is_disposed = true;
+ if (dc_mem!=null) {
+ dc_mem.Dispose();
+ dc_mem=null;
+ }
+
+ if (bmp_mem!=null) {
+ bmp_mem.Dispose();
+ bmp_mem=null;
+ }
+
+ if (this.InvokeRequired) {
+ if (Application.MessageLoop) {
+ this.BeginInvokeInternal(new MethodInvoker(DestroyHandle), null, true);
+ this.BeginInvokeInternal(new RemoveDelegate(controls.Remove), new object[] {this}, true);
+ }
+ } else {
+ DestroyHandle();
+ controls.Remove(this);
+ }
+ }
+ #endregion // Public Constructors
+
+ #region Internal Properties
+ internal BorderStyle InternalBorderStyle {
+ get {
+ return border_style;
+ }
+
+ set {
+ if (!Enum.IsDefined (typeof (BorderStyle), value))
+ throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
+
+ if (border_style != value) {
+ border_style = value;
+
+ if (IsHandleCreated) {
+ XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
+ Refresh();
+ }
+ }
+ }
+ }
+ #endregion // Internal Properties
+
+ #region Private & Internal Methods
+ internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args, bool disposing) {
+ AsyncMethodResult result;
+ AsyncMethodData data;
+
+ if (!disposing) {
+ Control p;
+
+ p = this;
+ do {
+ if (!p.IsHandleCreated) {
+ throw new InvalidOperationException("Cannot call Invoke or InvokeAsync on a control until the window handle is created");
+ }
+ p = p.parent;
+ } while (p != null);
+ }
+
+ result = new AsyncMethodResult ();
+ data = new AsyncMethodData ();
+
+ data.Method = method;
+ data.Args = args;
+ data.Result = result;
+
+#if NET_2_0
+ if (!ExecutionContext.IsFlowSuppressed ()) {
+ data.Context = ExecutionContext.Capture ();
+ }
+#else
+#if !MWF_ON_MSRUNTIME
+ if (SecurityManager.SecurityEnabled) {
+ data.Stack = CompressedStack.GetCompressedStack ();
+ }
+#endif
+#endif
+
+ XplatUI.SendAsyncMethod (data);
+ return result;
+ }
+
+
+ internal void PointToClient (ref int x, ref int y)
+ {
+ XplatUI.ScreenToClient (Handle, ref x, ref y);
+ }
+
+ internal void PointToScreen (ref int x, ref int y)
+ {
+ XplatUI.ClientToScreen (Handle, ref x, ref y);
+ }
+
+ private bool IsRecreating {
+ get {
+ if (is_recreating) {
+ return true;
+ }
+
+ if (parent != null) {
+ return parent.IsRecreating;
+ }
+
+ return false;
+ }
+ }
+
+ private bool ParentIsRecreating {
+ get {
+ if (parent != null) {
+ return parent.IsRecreating;
+ }
+ return false;
+ }
+ }
+
+ internal Graphics DeviceContext {
+ get {
+ if (dc_mem==null) {
+ CreateBuffers(this.Width, this.Height);
+ }
+ return dc_mem;
+ }
+ }
+
+ private Bitmap ImageBuffer {
+ get {
+ if (bmp_mem==null) {
+ CreateBuffers(this.Width, this.Height);
+ }
+ return bmp_mem;
+ }
+ }
+
+ internal void CreateBuffers (int width, int height) {
+ if (dc_mem != null) {
+ dc_mem.Dispose ();
+ }
+ if (bmp_mem != null)
+ bmp_mem.Dispose ();
+
+ if (width < 1) {
+ width = 1;
+ }
+
+ if (height < 1) {
+ height = 1;
+ }
+
+ bmp_mem = new Bitmap (width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
+ dc_mem = Graphics.FromImage (bmp_mem);
+ needs_redraw = true;
+ }
+
+ internal void InvalidateBuffers ()
+ {
+ if (dc_mem != null) {
+ dc_mem.Dispose ();
+ }
+ if (bmp_mem != null)
+ bmp_mem.Dispose ();
+
+ dc_mem = null;
+ bmp_mem = null;
+ needs_redraw = true;
+ }
+
+ internal static void SetChildColor(Control parent) {
+ Control child;
+
+ for (int i=0; i < parent.child_controls.Count; i++) {
+ child=parent.child_controls[i];
+ if (child.child_controls.Count>0) {
+ SetChildColor(child);
+ }
+ }
+
+ }
+
+ internal bool Select(Control control) {
+ Control parent;
+ IContainerControl container;
+
+ if (control == null) {
+ return false;
+ }
+
+ parent = control.parent;
+
+ if (((control.control_style & ControlStyles.Selectable) !=0) && (parent != null)) {
+ while (parent != null) {
+ if (!parent.Visible || !parent.is_enabled) {
+ return false;
+ }
+ parent = parent.parent;
+ }
+ }
+
+ control.is_selected = true;
+
+ container = GetContainerControl();
+ if (container != null) {
+ container.ActiveControl = control;
+ }
+ if (control.IsHandleCreated) {
+ XplatUI.SetFocus(control.window.Handle);
+ }
+ return true;
+ }
+
+ internal virtual void DoDefaultAction() {
+ // Only here to be overriden by our actual controls; this is needed by the accessibility class
+ }
+
+ internal static int LowOrder (int param) {
+ return ((int)(short)(param & 0xffff));
+ }
+
+ internal static int HighOrder (int param) {
+ return ((int)(short)(param >> 16));
+ }
+
+ // This method exists so controls overriding OnPaintBackground can have default background painting done
+ internal virtual void PaintControlBackground (PaintEventArgs pevent)
+ {
+ if (background_image == null) {
+ pevent.Graphics.FillRectangle(ThemeEngine.Current.ResPool.GetSolidBrush(BackColor), new Rectangle(pevent.ClipRectangle.X - 1, pevent.ClipRectangle.Y - 1, pevent.ClipRectangle.Width + 2, pevent.ClipRectangle.Height + 2));
+ return;
+ }
+
+ DrawBackgroundImage (pevent.Graphics);
+ }
+
+ void DrawBackgroundImage (Graphics g)
+ {
+ using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
+ g.FillRectangle (b, ClientRectangle);
+ }
+ }
+
+ internal virtual void DndEnter (DragEventArgs e)
+ {
+ try {
+ OnDragEnter (e);
+ } catch { }
+ }
+
+ internal virtual void DndOver (DragEventArgs e)
+ {
+ try {
+ OnDragOver (e);
+ } catch { }
+ }
+
+ internal virtual void DndDrop (DragEventArgs e)
+ {
+ try {
+ OnDragDrop (e);
+ } catch (Exception exc) {
+ Console.Error.WriteLine ("MWF: Exception while dropping:");
+ Console.Error.WriteLine (exc);
+ }
+ }
+
+ internal virtual void DndLeave (EventArgs e)
+ {
+ try {
+ OnDragLeave (e);
+ } catch { }
+ }
+
+ internal virtual void DndFeedback(GiveFeedbackEventArgs e)
+ {
+ try {
+ OnGiveFeedback(e);
+ } catch { }
+ }
+
+ internal virtual void DndContinueDrag(QueryContinueDragEventArgs e)
+ {
+ try {
+ OnQueryContinueDrag(e);
+ } catch { }
+ }
+
+ internal static MouseButtons FromParamToMouseButtons (int param) {
+ MouseButtons buttons = MouseButtons.None;
+
+ if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
+ buttons |= MouseButtons.Left;
+
+ if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
+ buttons |= MouseButtons.Middle;
+
+ if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
+ buttons |= MouseButtons.Right;
+
+ return buttons;
+
+ }
+
+ internal virtual bool ProcessControlMnemonic(char charCode) {
+ return ProcessMnemonic(charCode);
+ }
+
+ private static Control FindFlatForward(Control container, Control start) {
+ Control found;
+ int index;
+ int end;
+
+ found = null;
+ end = container.child_controls.Count;
+
+ if (start != null) {
+ index = start.tab_index;
+ } else {
+ index = -1;
+ }
+
+ for (int i = 0; i < end; i++) {
+ if (found == null) {
+ if (container.child_controls[i].tab_index > index) {
+ found = container.child_controls[i];
+ }
+ } else if (found.tab_index > container.child_controls[i].tab_index) {
+ if (container.child_controls[i].tab_index > index) {
+ found = container.child_controls[i];
+ }
+ }
+ }
+ return found;
+ }
+
+ private static Control FindControlForward(Control container, Control start) {
+ Control found;
+ Control p;
+
+ found = null;
+
+ if (start != null) {
+ if ((start is IContainerControl) || start.GetStyle(ControlStyles.ContainerControl)) {
+ found = FindControlForward(start, null);
+ if (found != null) {
+ return found;
+ }
+ }
+
+ p = start.parent;
+ while (p != container) {
+ found = FindFlatForward(p, start);
+ if (found != null) {
+ return found;
+ }
+ start = p;
+ p = p.parent;
+ }
+ }
+ return FindFlatForward(container, start);
+ }
+
+ private static Control FindFlatBackward(Control container, Control start) {
+ Control found;
+ int index;
+ int end;
+
+ found = null;
+ end = container.child_controls.Count;
+
+ if (start != null) {
+ index = start.tab_index;
+ } else {
+ // FIXME: Possible speed-up: Keep the highest taborder index in the container
+ index = -1;
+ for (int i = 0; i < end; i++) {
+ if (container.child_controls[i].tab_index > index) {
+ index = container.child_controls[i].tab_index;
+ }
+ }
+ index++;
+ }
+
+ for (int i = 0; i < end; i++) {
+ if (found == null) {
+ if (container.child_controls[i].tab_index < index) {
+ found = container.child_controls[i];
+ }
+ } else if (found.tab_index < container.child_controls[i].tab_index) {
+ if (container.child_controls[i].tab_index < index) {
+ found = container.child_controls[i];
+ }
+ }
+ }
+ return found;
+ }
+
+ private static Control FindControlBackward(Control container, Control start) {
+ Control found;
+
+ found = null;
+
+ if (start != null) {
+ found = FindFlatBackward(start.parent, start);
+ if (found == null && start.parent != container) {
+ return start.parent;
+ }
+ }
+ if (found == null) {
+ found = FindFlatBackward(container, start);
+ }
+
+ while ((found != null) && ((found is IContainerControl) || found.GetStyle(ControlStyles.ContainerControl))) {
+ found = FindControlBackward(found, null);
+ if (found != null) {
+ return found;
+ }
+ }
+
+ return found;
+ }
+
+ private void HandleClick(int clicks, MouseEventArgs me) {
+ if (GetStyle(ControlStyles.StandardClick)) {
+ if ((clicks > 1) && GetStyle(ControlStyles.StandardDoubleClick)) {
+#if !NET_2_0
+ OnDoubleClick(EventArgs.Empty);
+ } else {
+ OnClick(EventArgs.Empty);
+#else
+ OnDoubleClick(me);
+ } else {
+ OnClick(me);
+#endif
+ }
+ }
+ }
+
+ private void CheckDataBindings ()
+ {
+ if (data_bindings == null)
+ return;
+
+ BindingContext binding_context = BindingContext;
+ foreach (Binding binding in data_bindings) {
+ binding.Check (binding_context);
+ }
+ }
+
+
+ private void ChangeParent(Control new_parent) {
+ bool pre_enabled;
+ bool pre_visible;
+ Font pre_font;
+ Color pre_fore_color;
+ Color pre_back_color;
+ RightToLeft pre_rtl;
+
+ // These properties are inherited from our parent
+ // Get them pre parent-change and then send events
+ // if they are changed after we have our new parent
+ pre_enabled = Enabled;
+ pre_visible = Visible;
+ pre_font = Font;
+ pre_fore_color = ForeColor;
+ pre_back_color = BackColor;
+ pre_rtl = RightToLeft;
+ // MS doesn't seem to send a CursorChangedEvent
+
+ parent = new_parent;
+
+ if (IsHandleCreated && (new_parent != null) && new_parent.IsHandleCreated) {
+ XplatUI.SetParent(Handle, new_parent.Handle);
+ }
+
+ OnParentChanged(EventArgs.Empty);
+
+ if (pre_enabled != Enabled) {
+ OnEnabledChanged(EventArgs.Empty);
+ }
+
+ if (pre_visible != Visible) {
+ OnVisibleChanged(EventArgs.Empty);
+ }
+
+ if (pre_font != Font) {
+ OnFontChanged(EventArgs.Empty);
+ }
+
+ if (pre_fore_color != ForeColor) {
+ OnForeColorChanged(EventArgs.Empty);
+ }
+
+ if (pre_back_color != BackColor) {
+ OnBackColorChanged(EventArgs.Empty);
+ }
+
+ if (pre_rtl != RightToLeft) {
+ // MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
+ // because when RTL changes they have to recreate the win32 control
+ // We don't really need that (until someone runs into compatibility issues)
+ OnRightToLeftChanged(EventArgs.Empty);
+ }
+
+ if ((new_parent != null) && new_parent.Created && !Created) {
+ CreateControl();
+ }
+
+ if ((binding_context == null) && Created) {
+ OnBindingContextChanged(EventArgs.Empty);
+ }
+ }
+
+ private void UpdateDistances() {
+ if ((parent != null) && (parent.layout_suspended == 0)) {
+ dist_left = bounds.X;
+ dist_top = bounds.Y;
+ dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
+ dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
+ }
+ }
+ #endregion // Private & Internal Methods
+
+ #region Public Static Properties
+ public static Color DefaultBackColor {
+ get {
+ return ThemeEngine.Current.DefaultControlBackColor;
+ }
+ }
+
+ public static Font DefaultFont {
+ get {
+ return ThemeEngine.Current.DefaultFont;
+ }
+ }
+
+ public static Color DefaultForeColor {
+ get {
+ return ThemeEngine.Current.DefaultControlForeColor;
+ }
+ }
+
+ public static Keys ModifierKeys {
+ get {
+ return XplatUI.State.ModifierKeys;
+ }
+ }
+
+ public static MouseButtons MouseButtons {
+ get {
+ return XplatUI.State.MouseButtons;
+ }
+ }
+
+ public static Point MousePosition {
+ get {
+ return Cursor.Position;
+ }
+ }
+
+#if NET_2_0
+ [MonoTODO]
+ public static bool CheckForIllegalCrossThreadCalls
+ {
+ set {
+ }
+ get {
+ return false;
+ }
+ }
+#endif
+ #endregion // Public Static Properties
+
+ #region Public Instance Properties
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public AccessibleObject AccessibilityObject {
+ get {
+ if (accessibility_object==null) {
+ accessibility_object=CreateAccessibilityInstance();
+ }
+ return accessibility_object;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string AccessibleDefaultActionDescription {
+ get {
+ return AccessibilityObject.default_action;
+ }
+
+ set {
+ AccessibilityObject.default_action=value;
+ }
+ }
+
+ [Localizable(true)]
+ [DefaultValue(null)]
+ public string AccessibleDescription {
+ get {
+ return AccessibilityObject.description;
+ }
+
+ set {
+ AccessibilityObject.description=value;
+ }
+ }
+
+ [Localizable(true)]
+ [DefaultValue(null)]
+ public string AccessibleName {
+ get {
+ return AccessibilityObject.Name;
+ }
+
+ set {
+ AccessibilityObject.Name=value;
+ }
+ }
+
+ [DefaultValue(AccessibleRole.Default)]
+ [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
+ public AccessibleRole AccessibleRole {
+ get {
+ return AccessibilityObject.role;
+ }
+
+ set {
+ AccessibilityObject.role=value;
+ }
+ }
+
+ [DefaultValue(false)]
+ public virtual bool AllowDrop {
+ get {
+ return allow_drop;
+ }
+
+ set {
+ if (allow_drop == value)
+ return;
+ allow_drop = value;
+ UpdateStyles();
+ XplatUI.SetAllowDrop (Handle, value);
+ }
+ }
+
+ [Localizable(true)]
+ [RefreshProperties(RefreshProperties.Repaint)]
+ [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
+ public virtual AnchorStyles Anchor {
+ get {
+ return anchor_style;
+ }
+
+ set {
+ anchor_style=value;
+
+ if (parent != null) {
+ parent.PerformLayout(this, "Parent");
+ }
+ }
+ }
+
+#if NET_2_0
+ // XXX: Implement me!
+ bool auto_size;
+
+ public virtual bool AutoSize {
+ get {
+ Console.Error.WriteLine("Unimplemented: Control::get_AutoSize()");
+ return auto_size;
+ }
+ set {
+ Console.Error.WriteLine("Unimplemented: Control::set_AutoSize(bool)");
+ auto_size = value;
+ }
+ }
+#endif // NET_2_0
+
+ [DispId(-501)]
+ public virtual Color BackColor {
+ get {
+ if (background_color.IsEmpty) {
+ if (parent!=null) {
+ return parent.BackColor;
+ }
+ return DefaultBackColor;
+ }
+ return background_color;
+ }
+
+ set {
+ background_color=value;
+ SetChildColor(this);
+ OnBackColorChanged(EventArgs.Empty);
+ Invalidate();
+ }
+ }
+
+ [Localizable(true)]
+ [DefaultValue(null)]
+ public virtual Image BackgroundImage {
+ get {
+ return background_image;
+ }
+
+ set {
+ if (background_image!=value) {
+ background_image=value;
+ OnBackgroundImageChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public virtual BindingContext BindingContext {
+ get {
+ if (binding_context != null)
+ return binding_context;
+ if (Parent == null)
+ return null;
+ binding_context = Parent.BindingContext;
+ return binding_context;
+ }
+ set {
+ if (binding_context != value) {
+ binding_context = value;
+ OnBindingContextChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int Bottom {
+ get {
+ return bounds.Y+bounds.Height;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Rectangle Bounds {
+ get {
+ return this.bounds;
+ }
+
+ set {
+ SetBoundsCore(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool CanFocus {
+ get {
+ if (IsHandleCreated && Visible && Enabled) {
+ return true;
+ }
+ return false;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool CanSelect {
+ get {
+ Control parent;
+
+ if (!GetStyle(ControlStyles.Selectable)) {
+ return false;
+ }
+
+ parent = this;
+ while (parent != null) {
+ if (!parent.is_visible || !parent.is_enabled) {
+ return false;
+ }
+
+ parent = parent.parent;
+ }
+ return true;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool Capture {
+ get {
+ return this.is_captured;
+ }
+
+ set {
+ if (this.IsHandleCreated) {
+ if (value && !is_captured) {
+ is_captured = true;
+ XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
+ } else if (!value && is_captured) {
+ XplatUI.UngrabWindow(this.window.Handle);
+ is_captured = false;
+ }
+ }
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool CausesValidation {
+ get {
+ return this.causes_validation;
+ }
+
+ set {
+ if (this.causes_validation != value) {
+ causes_validation = value;
+ OnCausesValidationChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Rectangle ClientRectangle {
+ get {
+ client_rect.Width = client_size.Width;
+ client_rect.Height = client_size.Height;
+ return client_rect;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Size ClientSize {
+ get {
+#if notneeded
+ if ((this is Form) && (((Form)this).form_parent_window != null)) {
+ return ((Form)this).form_parent_window.ClientSize;
+ }
+#endif
+
+ return client_size;
+ }
+
+ set {
+ this.SetClientSizeCore(value.Width, value.Height);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [DescriptionAttribute("ControlCompanyNameDescr")]
+ public String CompanyName {
+ get {
+ return "Mono Project, Novell, Inc.";
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool ContainsFocus {
+ get {
+ if (this.Focused) {
+ return true;
+ }
+
+ for (int i=0; i < child_controls.Count; i++) {
+ if (child_controls[i].ContainsFocus) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ [DefaultValue(null)]
+ public virtual ContextMenu ContextMenu {
+ get {
+ return context_menu;
+ }
+
+ set {
+ if (context_menu != value) {
+ context_menu = value;
+ OnContextMenuChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ControlCollection Controls {
+ get {
+ return this.child_controls;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool Created {
+ get {
+ return (!is_disposed && is_created);
+ }
+ }
+
+ [AmbientValue(null)]
+ public virtual Cursor Cursor {
+ get {
+ if (cursor != null) {
+ return cursor;
+ }
+
+ if (parent != null) {
+ return parent.Cursor;
+ }
+
+ return Cursors.Default;
+ }
+
+ set {
+ if (cursor != value) {
+ Point pt;
+
+ cursor = value;
+
+ if (IsHandleCreated) {
+ pt = Cursor.Position;
+
+ if (bounds.Contains(pt)) {
+ if (GetChildAtPoint(pt) == null) {
+ if (cursor != null) {
+ XplatUI.SetCursor(window.Handle, cursor.handle);
+ } else {
+ if (parent != null) {
+ XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
+ } else {
+ XplatUI.SetCursor(window.Handle, Cursors.def.handle);
+ }
+ }
+ }
+ }
+ }
+
+ OnCursorChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ [ParenthesizePropertyName(true)]
+ [RefreshProperties(RefreshProperties.All)]
+ public ControlBindingsCollection DataBindings {
+ get {
+ if (data_bindings == null)
+ data_bindings = new ControlBindingsCollection (this);
+ return data_bindings;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public virtual Rectangle DisplayRectangle {
+ get {
+ return ClientRectangle;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool Disposing {
+ get {
+ return is_disposed;
+ }
+ }
+
+ [Localizable(true)]
+ [RefreshProperties(RefreshProperties.Repaint)]
+ [DefaultValue(DockStyle.None)]
+ public virtual DockStyle Dock {
+ get {
+ return dock_style;
+ }
+
+ set {
+ if (dock_style == value) {
+ return;
+ }
+
+ dock_style = value;
+
+ if (parent != null) {
+ parent.PerformLayout(this, "Parent");
+ }
+
+ OnDockChanged(EventArgs.Empty);
+ }
+ }
+
+ [DispId(-514)]
+ [Localizable(true)]
+ public bool Enabled {
+ get {
+ if (!is_enabled) {
+ return false;
+ }
+
+ if (parent != null) {
+ return parent.Enabled;
+ }
+
+ return true;
+ }
+
+ set {
+ if (is_enabled == value) {
+ return;
+ }
+
+ if (IsHandleCreated) {
+ if (this is Form) {
+ if (((Form)this).context == null) {
+ XplatUI.EnableWindow(window.Handle, value);
+ }
+ } else {
+ XplatUI.EnableWindow(window.Handle, value);
+ }
+ }
+ is_enabled = value;
+ Refresh();
+ OnEnabledChanged (EventArgs.Empty);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public virtual bool Focused {
+ get {
+ return this.has_focus;
+ }
+ }
+
+ [DispId(-512)]
+ [AmbientValue(null)]
+ [Localizable(true)]
+ public virtual Font Font {
+ get {
+ if (font != null) {
+ return font;
+ }
+
+ if (Parent != null && Parent.Font != null) {
+ return Parent.Font;
+ }
+
+ return DefaultFont;
+ }
+
+ set {
+ if (font != null && font.Equals (value)) {
+ return;
+ }
+
+ font = value;
+ Invalidate();
+ OnFontChanged (EventArgs.Empty);
+ }
+ }
+
+ [DispId(-513)]
+ public virtual Color ForeColor {
+ get {
+ if (foreground_color.IsEmpty) {
+ if (parent!=null) {
+ return parent.ForeColor;
+ }
+ return DefaultForeColor;
+ }
+ return foreground_color;
+ }
+
+ set {
+ if (foreground_color != value) {
+ foreground_color=value;
+ Invalidate();
+ OnForeColorChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ [DispId(-515)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public IntPtr Handle { // IWin32Window
+ get {
+ if (!IsHandleCreated) {
+ CreateHandle();
+ }
+ return window.Handle;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool HasChildren {
+ get {
+ if (this.child_controls.Count>0) {
+ return true;
+ }
+ return false;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Always)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int Height {
+ get {
+ return this.bounds.Height;
+ }
+
+ set {
+ SetBoundsCore(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
+ }
+ }
+
+ [AmbientValue(ImeMode.Inherit)]
+ [Localizable(true)]
+ public ImeMode ImeMode {
+ get {
+ if (ime_mode == DefaultImeMode) {
+ if (parent != null)
+ return parent.ImeMode;
+ else
+ return ImeMode.NoControl; // default value
+ }
+ return ime_mode;
+ }
+
+ set {
+ if (ime_mode != value) {
+ ime_mode = value;
+
+ OnImeModeChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool InvokeRequired { // ISynchronizeInvoke
+ get {
+ if (creator_thread != null && creator_thread!=Thread.CurrentThread) {
+ return true;
+ }
+ return false;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool IsAccessible {
+ get {
+ return is_accessible;
+ }
+
+ set {
+ is_accessible = value;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool IsDisposed {
+ get {
+ return this.is_disposed;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool IsHandleCreated {
+ get {
+ if ((window != null) && (window.Handle != IntPtr.Zero)) {
+ return true;
+ }
+
+ return false;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Always)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int Left {
+ get {
+ return this.bounds.X;
+ }
+
+ set {
+ SetBoundsCore(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
+ }
+ }
+
+ [Localizable(true)]
+ public Point Location {
+ get {
+ return new Point(bounds.X, bounds.Y);
+ }
+
+ set {
+ SetBoundsCore(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
+ }
+ }
+
+ [Browsable(false)]
+ public string Name {
+ get {
+ return name;
+ }
+
+ set {
+ name = value;
+ }
+ }
+
+#if NET_2_0
+ [Localizable(true)]
+ public Padding Padding {
+ get {
+ return padding;
+ }
+
+ set {
+ padding = value;
+ }
+ }
+#endif
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Control Parent {
+ get {
+ return this.parent;
+ }
+
+ set {
+ if (value == this) {
+ throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
+ }
+
+ if (parent!=value) {
+ if (value==null) {
+ parent.Controls.Remove(this);
+ return;
+ }
+
+ value.Controls.Add(this);
+ }
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string ProductName {
+ get {
+ Type t = typeof (AssemblyProductAttribute);
+ Assembly assembly = GetType().Module.Assembly;
+ object [] attrs = assembly.GetCustomAttributes (t, false);
+ AssemblyProductAttribute a = null;
+ // On MS we get a NullRefException if product attribute is not
+ // set.
+ if (attrs != null && attrs.Length > 0)
+ a = (AssemblyProductAttribute) attrs [0];
+ return a.Product;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string ProductVersion {
+ get {
+ Type t = typeof (AssemblyVersionAttribute);
+ Assembly assembly = GetType().Module.Assembly;
+ object [] attrs = assembly.GetCustomAttributes (t, false);
+ if (attrs == null || attrs.Length < 1)
+ return "1.0.0.0";
+ return ((AssemblyVersionAttribute)attrs [0]).Version;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool RecreatingHandle {
+ get {
+ return is_recreating;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Region Region {
+ get {
+ return new Region(this.bounds);
+ }
+
+ set {
+ Graphics g;
+ RectangleF r;
+
+ g = this.CreateGraphics();
+ r = value.GetBounds(g);
+
+ SetBounds((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height);
+
+ g.Dispose();
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int Right {
+ get {
+ return this.bounds.X+this.bounds.Width;
+ }
+ }
+
+ [AmbientValue(RightToLeft.Inherit)]
+ [Localizable(true)]
+ public virtual RightToLeft RightToLeft {
+ get {
+ if (right_to_left == RightToLeft.Inherit) {
+ if (parent != null)
+ return parent.RightToLeft;
+ else
+ return RightToLeft.No; // default value
+ }
+ return right_to_left;
+ }
+
+ set {
+ if (value != right_to_left) {
+ right_to_left = value;
+ OnRightToLeftChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public override ISite Site {
+ get {
+ return base.Site;
+ }
+
+ set {
+ base.Site = value;
+
+ AmbientProperties ap = (AmbientProperties) value.GetService (typeof (AmbientProperties));
+ if (ap != null) {
+ BackColor = ap.BackColor;
+ ForeColor = ap.ForeColor;
+ Cursor = ap.Cursor;
+ Font = ap.Font;
+ }
+ }
+ }
+
+ [Localizable(true)]
+ public Size Size {
+ get {
+ return new Size(Width, Height);
+ }
+
+ set {
+ SetBoundsCore(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
+ }
+ }
+
+ [Localizable(true)]
+ [MergableProperty(false)]
+ public int TabIndex {
+ get {
+ if (tab_index != -1) {
+ return tab_index;
+ }
+ return 0;
+ }
+
+ set {
+ if (tab_index != value) {
+ tab_index = value;
+ OnTabIndexChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ [DispId(-516)]
+ [DefaultValue(true)]
+ public bool TabStop {
+ get {
+ return tab_stop;
+ }
+
+ set {
+ if (tab_stop != value) {
+ tab_stop = value;
+ OnTabStopChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ [Localizable(false)]
+ [Bindable(true)]
+ [TypeConverter(typeof(StringConverter))]
+ [DefaultValue(null)]
+ public object Tag {
+ get {
+ return control_tag;
+ }
+
+ set {
+ control_tag = value;
+ }
+ }
+
+ [DispId(-517)]
+ [Localizable(true)]
+ [BindableAttribute(true)]
+ public virtual string Text {
+ get {
+ // Our implementation ignores ControlStyles.CacheText - we always cache
+ return this.text;
+ }
+
+ set {
+ if (value == null) {
+ value = String.Empty;
+ }
+
+ if (text!=value) {
+ text=value;
+ if (IsHandleCreated) {
+ XplatUI.Text(Handle, text);
+ }
+ OnTextChanged (EventArgs.Empty);
+ }
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Always)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int Top {
+ get {
+ return this.bounds.Y;
+ }
+
+ set {
+ SetBoundsCore(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Control TopLevelControl {
+ get {
+ Control p = this;
+
+ while (p.parent != null) {
+ p = p.parent;
+ }
+
+ return p;
+ }
+ }
+
+ [Localizable(true)]
+ public bool Visible {
+ get {
+ if (!is_visible) {
+ return false;
+ } else if (parent != null) {
+ return parent.Visible;
+ }
+
+ return true;
+ }
+
+ set {
+ SetVisibleCore(value);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Always)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int Width {
+ get {
+ return this.bounds.Width;
+ }
+
+ set {
+ SetBoundsCore(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public IWindowTarget WindowTarget {
+ get {
+ return null;
+ }
+
+ set {
+ ; // MS Internal
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Properties
+ protected virtual CreateParams CreateParams {
+ get {
+ CreateParams create_params = new CreateParams();
+
+ try {
+ create_params.Caption = Text;
+ }
+ catch {
+ create_params.Caption = text;
+ }
+
+ try {
+ create_params.X = Left;
+ }
+ catch {
+ create_params.X = this.bounds.X;
+ }
+
+ try {
+ create_params.Y = Top;
+ }
+ catch {
+ create_params.Y = this.bounds.Y;
+ }
+
+ try {
+ create_params.Width = Width;
+ }
+ catch {
+ create_params.Width = this.bounds.Width;
+ }
+
+ try {
+ create_params.Height = Height;
+ }
+ catch {
+ create_params.Height = this.bounds.Height;
+ }
+
+
+ create_params.ClassName = XplatUI.DefaultClassName;
+ create_params.ClassStyle = 0;
+ create_params.ExStyle = 0;
+ create_params.Param = 0;
+
+ if (allow_drop) {
+ create_params.ExStyle |= (int)WindowExStyles.WS_EX_ACCEPTFILES;
+ }
+
+ if ((parent!=null) && (parent.IsHandleCreated)) {
+ create_params.Parent = parent.Handle;
+ }
+
+ create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
+
+ if (is_visible) {
+ create_params.Style |= (int)WindowStyles.WS_VISIBLE;
+ }
+
+ if (!is_enabled) {
+ create_params.Style |= (int)WindowStyles.WS_DISABLED;
+ }
+
+ switch (border_style) {
+ case BorderStyle.FixedSingle:
+ create_params.Style |= (int) WindowStyles.WS_BORDER;
+ break;
+ case BorderStyle.Fixed3D:
+ create_params.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
+ break;
+ }
+
+ return create_params;
+ }
+ }
+
+ protected virtual ImeMode DefaultImeMode {
+ get {
+ return ImeMode.Inherit;
+ }
+ }
+
+ protected virtual Size DefaultSize {
+ get {
+ return new Size(0, 0);
+ }
+ }
+
+ protected int FontHeight {
+ get {
+ return Font.Height;
+ }
+
+ set {
+ ;; // Nothing to do
+ }
+ }
+
+ protected bool RenderRightToLeft {
+ get {
+ return (this.right_to_left == RightToLeft.Yes);
+ }
+ }
+
+ protected bool ResizeRedraw {
+ get {
+ return GetStyle(ControlStyles.ResizeRedraw);
+ }
+
+ set {
+ SetStyle(ControlStyles.ResizeRedraw, value);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ protected virtual bool ShowFocusCues {
+ get {
+ return true;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ protected bool ShowKeyboardCues {
+ get {
+ return true;
+ }
+ }
+ #endregion // Protected Instance Properties
+
+ #region Public Static Methods
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public static Control FromChildHandle(IntPtr handle) {
+ IEnumerator control = Control.controls.GetEnumerator();
+
+ while (control.MoveNext()) {
+ if (((Control)control.Current).window.Handle == handle) {
+ // Found it
+ if (((Control)control.Current).Parent != null) {
+ return ((Control)control.Current).Parent;
+ }
+ }
+ }
+ return null;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public static Control FromHandle(IntPtr handle) {
+#if not
+ IEnumerator control = Control.controls.GetEnumerator();
+
+ while (control.MoveNext()) {
+ if (((Control)control.Current).window.Handle == handle) {
+ // Found it
+ return ((Control)control.Current);
+ }
+ }
+
+ return null;
+#else
+ return Control.ControlNativeWindow.ControlFromHandle(handle);
+#endif
+ }
+
+ public static bool IsMnemonic(char charCode, string text) {
+ int amp;
+
+ amp = text.IndexOf('&');
+
+ if (amp != -1) {
+ if (amp + 1 < text.Length) {
+ if (text[amp + 1] != '&') {
+ if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+ #endregion
+
+ #region Protected Static Methods
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
+ Control c;
+
+ c = Control.FromHandle(hWnd);
+
+ if (c != null) {
+ c.WndProc(ref m);
+ return true;
+ }
+ return false;
+ }
+ #endregion
+
+ #region Public Instance Methods
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public IAsyncResult BeginInvoke(Delegate method) {
+ object [] prms = null;
+ if (method is EventHandler)
+ prms = new object [] { this, EventArgs.Empty };
+ return BeginInvokeInternal(method, prms, false);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public IAsyncResult BeginInvoke (Delegate method, object[] args) {
+ return BeginInvokeInternal (method, args, false);
+ }
+
+ public void BringToFront() {
+ if ((parent != null) && (parent.child_controls[0]!=this)) {
+ if (parent.child_controls.Contains(this)) {
+ parent.child_controls.SetChildIndex(this, 0);
+ }
+ } else if (parent != null) {
+ if (parent.child_controls.impl_list != null) {
+ Control last_impl = (Control) parent.child_controls.impl_list [parent.child_controls.impl_list.Count - 1];
+ if (IsHandleCreated) {
+ XplatUI.SetZOrder (this.window.Handle, last_impl.Handle, false, false);
+ }
+ } else {
+ if (IsHandleCreated) {
+ XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, true, false);
+ }
+ }
+ }
+
+ if (parent != null) {
+ parent.Refresh();
+ }
+ }
+
+ public bool Contains(Control ctl) {
+ while (ctl != null) {
+ ctl = ctl.parent;
+ if (ctl == this) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void CreateControl() {
+ if (is_created) {
+ return;
+ }
+
+ if (!IsHandleCreated) {
+ CreateHandle();
+ }
+
+ if (!is_created) {
+ is_created = true;
+ }
+
+ Control [] controls = child_controls.GetAllControls ();
+ for (int i=0; i<controls.Length; i++) {
+ controls [i].CreateControl ();
+ }
+
+ UpdateZOrder();
+
+ if (binding_context == null) { // seem to be sent whenever it's null?
+ OnBindingContextChanged(EventArgs.Empty);
+ }
+
+ OnCreateControl();
+ }
+
+ public Graphics CreateGraphics() {
+ if (!IsHandleCreated) {
+ this.CreateHandle();
+ }
+ return Graphics.FromHwnd(this.window.Handle);
+ }
+
+ public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
+ return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public object EndInvoke (IAsyncResult async_result) {
+ AsyncMethodResult result = (AsyncMethodResult) async_result;
+ return result.EndInvoke ();
+ }
+
+ public Form FindForm() {
+ Control c;
+
+ c = this;
+ while (c != null) {
+ if (c is Form) {
+ return (Form)c;
+ }
+ c = c.Parent;
+ }
+ return null;
+ }
+
+ public bool Focus() {
+ if (CanFocus && IsHandleCreated && !has_focus) {
+ XplatUI.SetFocus(window.Handle);
+ }
+ return has_focus;
+ }
+
+ public Control GetChildAtPoint(Point pt) {
+ // Microsoft's version of this function doesn't seem to work, so I can't check
+ // if we only consider children or also grandchildren, etc.
+ // I'm gonna say 'children only'
+ for (int i=0; i<child_controls.Count; i++) {
+ if (child_controls[i].Bounds.Contains(pt)) {
+ return child_controls[i];
+ }
+ }
+ return null;
+ }
+
+ public IContainerControl GetContainerControl() {
+ Control current = this;
+
+ while (current!=null) {
+ if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
+ return (IContainerControl)current;
+ }
+ current = current.parent;
+ }
+ return null;
+ }
+
+ public Control GetNextControl(Control ctl, bool forward) {
+ // If we're not a container we don't play
+ if (!(this is IContainerControl) && !this.GetStyle(ControlStyles.ContainerControl)) {
+ return null;
+ }
+
+ // If ctl is not contained by this, we start at the first child of this
+ if (!this.Contains(ctl)) {
+ ctl = null;
+ }
+
+ // Search through our controls, starting at ctl, stepping into children as we encounter them
+ // try to find the control with the tabindex closest to our own, or, if we're looking into
+ // child controls, the one with the smallest tabindex
+ if (forward) {
+ return FindControlForward(this, ctl);
+ }
+ return FindControlBackward(this, ctl);
+ }
+
+ public void Hide() {
+ this.Visible = false;
+ }
+
+ public void Invalidate() {
+ Invalidate(ClientRectangle, false);
+ }
+
+ public void Invalidate(bool invalidateChildren) {
+ Invalidate(ClientRectangle, invalidateChildren);
+ }
+
+ public void Invalidate(System.Drawing.Rectangle rc) {
+ Invalidate(rc, false);
+ }
+
+ public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
+ if (!IsHandleCreated || !Visible || rc.Width == 0 || rc.Height == 0) {
+ return;
+ }
+
+ NotifyInvalidate(rc);
+
+ XplatUI.Invalidate(Handle, rc, false);
+
+ if (invalidateChildren) {
+ Control [] controls = child_controls.GetAllControls ();
+ for (int i=0; i<controls.Length; i++)
+ controls [i].Invalidate ();
+ }
+ OnInvalidated(new InvalidateEventArgs(rc));
+ }
+
+ public void Invalidate(System.Drawing.Region region) {
+ Invalidate(region, false);
+ }
+
+ public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
+ RectangleF bounds = region.GetBounds (CreateGraphics ());
+ Invalidate (new Rectangle ((int) bounds.X, (int) bounds.Y, (int) bounds.Width, (int) bounds.Height),
+ invalidateChildren);
+ }
+
+ public object Invoke (Delegate method) {
+ object [] prms = null;
+ if (method is EventHandler)
+ prms = new object [] { this, EventArgs.Empty };
+
+ return Invoke(method, prms);
+ }
+
+ public object Invoke (Delegate method, object[] args) {
+ if (!this.InvokeRequired) {
+ return method.DynamicInvoke(args);
+ }
+
+ IAsyncResult result = BeginInvoke (method, args);
+ return EndInvoke(result);
+ }
+
+ internal object InvokeInternal (Delegate method, bool disposing) {
+ return InvokeInternal(method, null, disposing);
+ }
+
+ internal object InvokeInternal (Delegate method, object[] args, bool disposing) {
+ if (!this.InvokeRequired) {
+ return method.DynamicInvoke(args);
+ }
+
+ IAsyncResult result = BeginInvokeInternal (method, args, disposing);
+ return EndInvoke(result);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public void PerformLayout() {
+ PerformLayout(null, null);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public void PerformLayout(Control affectedControl, string affectedProperty) {
+ LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
+
+ if (layout_suspended > 0) {
+ layout_pending = true;
+ return;
+ }
+
+ layout_pending = false;
+
+ // Prevent us from getting messed up
+ layout_suspended++;
+
+ // Perform all Dock and Anchor calculations
+ try {
+ Control child;
+ AnchorStyles anchor;
+ Rectangle space;
+
+ space= DisplayRectangle;
+
+ // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
+ Control [] controls = child_controls.GetAllControls ();
+ for (int i = controls.Length - 1; i >= 0; i--) {
+ child = controls [i];
+
+ if (!child.Visible) {
+ continue;
+ }
+
+ switch (child.Dock) {
+ case DockStyle.None: {
+ // Do nothing
+ break;
+ }
+
+ case DockStyle.Left: {
+ child.SetBounds(space.Left, space.Y, child.Width, space.Height);
+ space.X+=child.Width;
+ space.Width-=child.Width;
+ break;
+ }
+
+ case DockStyle.Top: {
+ child.SetBounds(space.Left, space.Y, space.Width, child.Height);
+ space.Y+=child.Height;
+ space.Height-=child.Height;
+ break;
+ }
+
+ case DockStyle.Right: {
+ child.SetBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
+ space.Width-=child.Width;
+ break;
+ }
+
+ case DockStyle.Bottom: {
+ child.SetBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
+ space.Height-=child.Height;
+ break;
+ }
+ }
+ }
+
+ for (int i = controls.Length - 1; i >= 0; i--) {
+ child=controls[i];
+
+ if (child.Visible && (child.Dock == DockStyle.Fill)) {
+ child.SetBounds(space.Left, space.Top, space.Width, space.Height);
+ space.Width=0;
+ space.Height=0;
+ }
+ }
+
+ space=DisplayRectangle;
+
+ for (int i=0; i < controls.Length; i++) {
+ int left;
+ int top;
+ int width;
+ int height;
+
+ child = controls[i];
+
+ // If the control is docked we don't need to do anything
+ if (child.Dock != DockStyle.None) {
+ continue;
+ }
+
+ anchor = child.Anchor;
+
+ left = child.Left;
+ top = child.Top;
+ width = child.Width;
+ height = child.Height;
+
+ if ((anchor & AnchorStyles.Left) !=0 ) {
+ if ((anchor & AnchorStyles.Right) != 0) {
+ width = space.Width - child.dist_right - left;
+ } else {
+ ; // Left anchored only, nothing to be done
+ }
+ } else if ((anchor & AnchorStyles.Right) != 0) {
+ left = space.Width - child.dist_right - width;
+ } else {
+ // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
+ // This calculates from scratch every time:
+ left = child.dist_left + (space.Width - (child.dist_left + width + child.dist_right)) / 2;
+ }
+
+ if ((anchor & AnchorStyles.Top) !=0 ) {
+ if ((anchor & AnchorStyles.Bottom) != 0) {
+ height = space.Height - child.dist_bottom - top;
+ } else {
+ ; // Top anchored only, nothing to be done
+ }
+ } else if ((anchor & AnchorStyles.Bottom) != 0) {
+ top = space.Height - child.dist_bottom - height;
+ } else {
+ // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
+ // This calculates from scratch every time:
+ top = child.dist_top + (space.Height - (child.dist_top + height + child.dist_bottom)) / 2;
+ }
+
+ // Sanity
+ if (width < 0) {
+ width=0;
+ }
+
+ if (height < 0) {
+ height=0;
+ }
+
+ child.SetBounds(left, top, width, height);
+ }
+
+ // Let everyone know
+ OnLayout(levent);
+ }
+
+ // Need to make sure we decremend layout_suspended
+ finally {
+ layout_suspended--;
+ }
+ }
+
+ public Point PointToClient (Point p) {
+ int x = p.X;
+ int y = p.Y;
+
+ XplatUI.ScreenToClient (Handle, ref x, ref y);
+
+ return new Point (x, y);
+ }
+
+ public Point PointToScreen(Point p) {
+ int x = p.X;
+ int y = p.Y;
+
+ XplatUI.ClientToScreen(Handle, ref x, ref y);
+
+ return new Point(x, y);
+ }
+
+ public virtual bool PreProcessMessage(ref Message msg) {
+ Keys key_data;
+
+ if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
+ key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
+
+ if (!ProcessCmdKey(ref msg, key_data)) {
+ if (IsInputKey(key_data)) {
+ return false;
+ }
+
+ return ProcessDialogKey(key_data);
+ }
+
+ return true;
+ } else if (msg.Msg == (int)Msg.WM_CHAR) {
+ if (IsInputChar((char)msg.WParam)) {
+ return false;
+ }
+ } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
+ if (IsInputChar((char)msg.WParam)) {
+ return false;
+ }
+ return ProcessDialogChar((char)msg.WParam);
+ }
+ return false;
+ }
+
+ public Rectangle RectangleToClient(Rectangle r) {
+ return new Rectangle(PointToClient(r.Location), r.Size);
+ }
+
+ public Rectangle RectangleToScreen(Rectangle r) {
+ return new Rectangle(PointToScreen(r.Location), r.Size);
+ }
+
+ public virtual void Refresh() {
+ if (IsHandleCreated == true) {
+
+ Invalidate();
+ XplatUI.UpdateWindow(window.Handle);
+
+ Control [] controls = child_controls.GetAllControls ();
+ for (int i=0; i < controls.Length; i++) {
+ controls[i].Refresh();
+ }
+
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual void ResetBackColor() {
+ background_color = Color.Empty;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [MonoTODO]
+ public void ResetBindings() {
+ // Do something
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual void ResetCursor() {
+ Cursor = null;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual void ResetFont() {
+ font = null;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual void ResetForeColor() {
+ foreground_color = Color.Empty;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetImeMode() {
+ ime_mode = DefaultImeMode;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual void ResetRightToLeft() {
+ right_to_left = RightToLeft.Inherit;
+ }
+
+ public virtual void ResetText() {
+ text = String.Empty;
+ }
+
+ public void ResumeLayout() {
+ ResumeLayout (true);
+ }
+
+ public void ResumeLayout(bool performLayout) {
+ if (layout_suspended > 0) {
+ layout_suspended--;
+ }
+
+ if (layout_suspended == 0) {
+ Control [] controls = child_controls.GetAllControls ();
+ for (int i=0; i<controls.Length; i++) {
+ controls [i].UpdateDistances ();
+ }
+
+ if (performLayout && layout_pending) {
+ PerformLayout();
+ }
+ }
+ }
+
+ public void Scale(float ratio) {
+ ScaleCore(ratio, ratio);
+ }
+
+ public void Scale(float dx, float dy) {
+ ScaleCore(dx, dy);
+ }
+
+ public void Select() {
+ Select(false, false);
+ }
+
+ public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
+ Control c;
+
+ c = ctl;
+ do {
+ c = GetNextControl(c, forward);
+ if (c == null) {
+ if (wrap) {
+ wrap = false;
+ continue;
+ }
+ break;
+ }
+
+ if (c.CanSelect && ((c.parent == ctl.parent) || nested) && (c.tab_stop || !tabStopOnly)) {
+ Select(c);
+ return true;
+ }
+ } while (c != ctl); // If we wrap back to ourselves we stop
+
+ return false;
+ }
+
+ public void SendToBack() {
+ if ((parent != null) && (parent.child_controls[parent.child_controls.Count-1]!=this)) {
+ if (parent.child_controls.Contains(this)) {
+ parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
+ }
+ }
+
+ if (IsHandleCreated) {
+ XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, false, true);
+ }
+
+ if (parent != null) {
+ parent.Refresh();
+ }
+ }
+
+ public void SetBounds(int x, int y, int width, int height) {
+ SetBoundsCore(x, y, width, height, BoundsSpecified.All);
+ }
+
+ public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
+ SetBoundsCore(x, y, width, height, specified);
+ }
+
+ public void Show() {
+ if (!is_created) {
+ this.CreateControl();
+ }
+
+ this.Visible=true;
+ }
+
+ public void SuspendLayout() {
+ layout_suspended++;
+ }
+
+ public void Update() {
+ needs_redraw = true;
+ if (IsHandleCreated) {
+ XplatUI.UpdateWindow(window.Handle);
+ }
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
+ protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
+ throw new NotImplementedException();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual AccessibleObject CreateAccessibilityInstance() {
+ return new Control.ControlAccessibleObject(this);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual ControlCollection CreateControlsInstance() {
+ return new ControlCollection(this);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void CreateHandle() {
+ if (IsDisposed) {
+ throw new ObjectDisposedException(Name);
+ }
+
+ if (IsHandleCreated && !is_recreating) {
+ return;
+ }
+
+ window.CreateHandle(CreateParams);
+
+ if (window.Handle != IntPtr.Zero) {
+ if (!controls.Contains(window.Handle)) {
+ controls.Add(this);
+ }
+
+ creator_thread = Thread.CurrentThread;
+
+ XplatUI.EnableWindow(window.Handle, is_enabled);
+
+ // Set our handle with our parent
+ if ((parent != null) && (parent.IsHandleCreated)) {
+ XplatUI.SetParent(window.Handle, parent.Handle);
+ }
+
+ // Set our handle as parent for our children
+ Control [] children;
+
+ children = child_controls.GetAllControls ();
+ for (int i = 0; i < children.Length; i++ ) {
+ if (children[i].IsHandleCreated) {
+ XplatUI.SetParent(children[i].Handle, window.Handle);
+ }
+ }
+
+ // Find out where the window manager placed us
+ UpdateStyles();
+ if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
+ XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
+ }
+ UpdateBounds();
+
+ OnHandleCreated(EventArgs.Empty);
+ }
+
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void DefWndProc(ref Message m) {
+ window.DefWndProc(ref m);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void DestroyHandle() {
+ if (IsHandleCreated) {
+ if (window != null) {
+ window.DestroyHandle();
+ }
+ }
+ }
+
+ protected bool GetStyle(ControlStyles flag) {
+ return (control_style & flag) != 0;
+ }
+
+ protected bool GetTopLevel() {
+ return is_toplevel;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void InitLayout() {
+ UpdateDistances();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
+ toInvoke.OnGotFocus(e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
+ toInvoke.OnLostFocus(e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void InvokeOnClick(Control toInvoke, EventArgs e) {
+ toInvoke.OnClick(e);
+ }
+
+ protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
+ toInvoke.OnPaint(e);
+ }
+
+ protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
+ toInvoke.OnPaintBackground(e);
+ }
+
+ protected virtual bool IsInputChar (char charCode) {
+ return true;
+ }
+
+ protected virtual bool IsInputKey (Keys keyData) {
+ // Doc says this one calls IsInputChar; not sure what to do with that
+ return false;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
+ // override me?
+ }
+
+ protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
+ if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
+ return true;
+ }
+
+ if (parent != null) {
+ return parent.ProcessCmdKey(ref msg, keyData);
+ }
+
+ return false;
+ }
+
+ protected virtual bool ProcessDialogChar(char charCode) {
+ if (parent != null) {
+ return parent.ProcessDialogChar (charCode);
+ }
+
+ return false;
+ }
+
+ protected virtual bool ProcessDialogKey (Keys keyData) {
+ if (parent != null) {
+ return parent.ProcessDialogKey (keyData);
+ }
+
+ return false;
+ }
+
+ protected virtual bool ProcessKeyEventArgs (ref Message msg)
+ {
+ KeyEventArgs key_event;
+
+ switch (msg.Msg) {
+ case (int)Msg.WM_SYSKEYDOWN:
+ case (int)Msg.WM_KEYDOWN: {
+ key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
+ OnKeyDown (key_event);
+ return key_event.Handled;
+ }
+
+ case (int)Msg.WM_SYSKEYUP:
+ case (int)Msg.WM_KEYUP: {
+ key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
+ OnKeyUp (key_event);
+ return key_event.Handled;
+ }
+
+ case (int)Msg.WM_SYSCHAR:
+ case (int)Msg.WM_CHAR: {
+ KeyPressEventArgs key_press_event;
+
+ key_press_event = new KeyPressEventArgs((char)msg.WParam);
+ OnKeyPress(key_press_event);
+ return key_press_event.Handled;
+ }
+
+ default: {
+ break;
+ }
+ }
+
+ return false;
+ }
+
+ protected internal virtual bool ProcessKeyMessage(ref Message msg) {
+ if (parent != null) {
+ if (parent.ProcessKeyPreview(ref msg)) {
+ return true;
+ }
+ }
+
+ return ProcessKeyEventArgs(ref msg);
+ }
+
+ protected virtual bool ProcessKeyPreview(ref Message msg) {
+ if (parent != null) {
+ return parent.ProcessKeyPreview(ref msg);
+ }
+
+ return false;
+ }
+
+ protected virtual bool ProcessMnemonic(char charCode) {
+ // override me
+ return false;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void RaiseDragEvent(object key, DragEventArgs e) {
+ // MS Internal
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void RaiseKeyEvent(object key, KeyEventArgs e) {
+ // MS Internal
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void RaiseMouseEvent(object key, MouseEventArgs e) {
+ // MS Internal
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void RaisePaintEvent(object key, PaintEventArgs e) {
+ // MS Internal
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void RecreateHandle() {
+ is_recreating=true;
+
+ if (IsHandleCreated) {
+ DestroyHandle();
+ // WM_DESTROY will CreateHandle for us
+ } else {
+ if (!is_created) {
+ CreateControl();
+ } else {
+ CreateHandle();
+ }
+ }
+
+ is_recreating = false;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void ResetMouseEventArgs() {
+ // MS Internal
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
+ if (right_to_left == RightToLeft.No) {
+ return align;
+ }
+
+ switch (align) {
+ case ContentAlignment.TopLeft: {
+ return ContentAlignment.TopRight;
+ }
+
+ case ContentAlignment.TopRight: {
+ return ContentAlignment.TopLeft;
+ }
+
+ case ContentAlignment.MiddleLeft: {
+ return ContentAlignment.MiddleRight;
+ }
+
+ case ContentAlignment.MiddleRight: {
+ return ContentAlignment.MiddleLeft;
+ }
+
+ case ContentAlignment.BottomLeft: {
+ return ContentAlignment.BottomRight;
+ }
+
+ case ContentAlignment.BottomRight: {
+ return ContentAlignment.BottomLeft;
+ }
+
+ default: {
+ // if it's center it doesn't change
+ return align;
+ }
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
+ if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
+ return align;
+ }
+
+ if (align == HorizontalAlignment.Left) {
+ return HorizontalAlignment.Right;
+ }
+
+ // align must be HorizontalAlignment.Right
+ return HorizontalAlignment.Left;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
+ if (right_to_left == RightToLeft.No) {
+ return align;
+ }
+
+ if (align == LeftRightAlignment.Left) {
+ return LeftRightAlignment.Right;
+ }
+
+ // align must be LeftRightAlignment.Right;
+ return LeftRightAlignment.Left;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
+ return RtlTranslateAlignment(align);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
+ return RtlTranslateAlignment(align);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
+ return RtlTranslateAlignment(align);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void ScaleCore(float dx, float dy) {
+ Point location;
+ Size size;
+
+ SuspendLayout();
+
+ location = new Point((int)(Left * dx), (int)(Top * dy));
+ size = this.ClientSize;
+
+ if (!GetStyle(ControlStyles.FixedWidth)) {
+ size.Width = (int)(size.Width * dx);
+ }
+
+ if (!GetStyle(ControlStyles.FixedHeight)) {
+ size.Height = (int)(size.Height * dy);
+ }
+
+ SetBoundsCore(location.X, location.Y, size.Width, size.Height, BoundsSpecified.All);
+
+ /* Now scale our children */
+ Control [] controls = child_controls.GetAllControls ();
+ for (int i=0; i < controls.Length; i++) {
+ controls[i].Scale(dx, dy);
+ }
+
+ ResumeLayout();
+ }
+
+ protected virtual void Select(bool directed, bool forward) {
+ int index;
+ bool result;
+
+ if (!directed) {
+ // Select this control
+ Select(this);
+ return;
+ }
+
+ if (parent == null) {
+ return;
+ }
+
+ // FIXME - this thing is doing the wrong stuff, needs to be similar to SelectNextControl
+
+ index = parent.child_controls.IndexOf(this);
+ result = false;
+
+ do {
+ if (forward) {
+ if ((index+1) < parent.child_controls.Count) {
+ index++;
+ } else {
+ index = 0;
+ }
+ } else {
+ if (index>0) {
+ index++;
+ } else {
+ index = parent.child_controls.Count-1;
+ }
+ }
+ result = Select(parent.child_controls[index]);
+ } while (!result && parent.child_controls[index] != this);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
+ // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
+ if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
+ x = Left;
+ }
+
+ if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
+ y = Top;
+ }
+
+ if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
+ width = Width;
+ }
+
+ if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
+ height = Height;
+ }
+
+ if (IsHandleCreated) {
+ XplatUI.SetWindowPos(Handle, x, y, width, height);
+ }
+
+ UpdateBounds(x, y, width, height);
+
+ UpdateDistances();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void SetClientSizeCore(int x, int y) {
+ // Calculate the actual window size from the client size (it usually stays the same or grows)
+ Rectangle ClientRect;
+ Rectangle WindowRect;
+ CreateParams cp;
+
+ ClientRect = new Rectangle(0, 0, x, y);
+ cp = this.CreateParams;
+
+ if (XplatUI.CalculateWindowRect(ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect)==false) {
+ return;
+ }
+
+ SetBoundsCore(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void SetStyle(ControlStyles flag, bool value) {
+ if (value) {
+ control_style |= flag;
+ } else {
+ control_style &= ~flag;
+ }
+ OnStyleChanged(EventArgs.Empty);
+ }
+
+ protected void SetTopLevel(bool value) {
+ if ((GetTopLevel() != value) && (parent != null)) {
+ throw new Exception();
+ }
+
+ if (this is Form) {
+ if (value == true) {
+ if (!Visible) {
+ Visible = true;
+ }
+ } else {
+ if (Visible) {
+ Visible = false;
+ }
+ }
+ }
+ is_toplevel = value;
+ }
+
+ protected virtual void SetVisibleCore(bool value) {
+ if (value!=is_visible) {
+ is_visible=value;
+
+ if (IsHandleCreated) {
+ XplatUI.SetVisible(Handle, value);
+ // Explicitly move Toplevel windows to where we want them;
+ // apparently moving unmapped toplevel windows doesn't work
+ if (is_visible && (this is Form)) {
+ XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
+ }
+ }
+
+ if (is_visible && !is_created) {
+ CreateControl();
+ }
+
+ OnVisibleChanged(EventArgs.Empty);
+
+ if (value == false && parent != null) {
+ Control container;
+
+ // Need to start at parent, GetContainerControl might return ourselves if we're a container
+ container = (Control)parent.GetContainerControl();
+ if (container != null) {
+ container.SelectNextControl(this, true, true, true, true);
+ }
+ }
+
+ if (parent != null) {
+ parent.PerformLayout(this, "visible");
+ } else {
+ PerformLayout(this, "visible");
+ }
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void UpdateBounds() {
+ int x;
+ int y;
+ int width;
+ int height;
+ int client_width;
+ int client_height;
+
+ if (!IsHandleCreated) {
+ CreateHandle();
+ }
+
+ XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
+
+ UpdateBounds(x, y, width, height, client_width, client_height);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void UpdateBounds(int x, int y, int width, int height) {
+ CreateParams cp;
+ Rectangle rect;
+
+ // Calculate client rectangle
+ rect = new Rectangle(0, 0, 0, 0);
+ cp = CreateParams;
+
+ XplatUI.CalculateWindowRect(ref rect, cp.Style, cp.ExStyle, cp.menu, out rect);
+ UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
+ // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
+ bool moved = false;
+ bool resized = false;
+
+ // Needed to generate required notifications
+ if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
+ moved=true;
+ }
+
+ if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
+ resized=true;
+ }
+
+ bounds.X=x;
+ bounds.Y=y;
+ bounds.Width=width;
+ bounds.Height=height;
+
+ client_size.Width=clientWidth;
+ client_size.Height=clientHeight;
+
+ if (moved) {
+ OnLocationChanged(EventArgs.Empty);
+ }
+
+ if (resized) {
+ OnSizeChanged(EventArgs.Empty);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void UpdateStyles() {
+ if (!IsHandleCreated) {
+ return;
+ }
+
+ XplatUI.SetWindowStyle(window.Handle, CreateParams);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void UpdateZOrder() {
+ Control [] controls;
+ if (!IsHandleCreated) {
+ return;
+ }
+
+ controls = child_controls.GetAllControls ();
+ for (int i = 1; i < controls.Length; i++ ) {
+ XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
+ }
+ }
+
+ protected virtual void WndProc(ref Message m) {
+#if debug
+ Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), (Msg)m.Msg);
+#endif
+ if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
+ OnNotifyMessage(m);
+ }
+
+ switch((Msg)m.Msg) {
+ case Msg.WM_DESTROY: {
+ OnHandleDestroyed(EventArgs.Empty);
+ window.InvalidateHandle();
+
+ if (ParentIsRecreating) {
+ RecreateHandle();
+ } else if (is_recreating) {
+ CreateHandle();
+ }
+ return;
+ }
+
+ case Msg.WM_WINDOWPOSCHANGED: {
+ if (Visible) {
+ UpdateBounds();
+ if (GetStyle(ControlStyles.ResizeRedraw)) {
+ Invalidate();
+ }
+ }
+ return;
+ }
+
+ case Msg.WM_PAINT: {
+ PaintEventArgs paint_event;
+
+ paint_event = XplatUI.PaintEventStart(Handle, true);
+
+ if (!needs_redraw) {
+ // Just blit the previous image
+ paint_event.Graphics.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
+ XplatUI.PaintEventEnd(Handle, true);
+ return;
+ }
+
+ Graphics dc = null;
+ if (ThemeEngine.Current.DoubleBufferingSupported)
+ if ((control_style & ControlStyles.DoubleBuffer) != 0) {
+ dc = paint_event.SetGraphics (DeviceContext);
+ }
+
+ OnPaintBackground(paint_event);
+ // Leave out for now, our controls can do Paint += ... as well
+ //OnPaintInternal(paint_event);
+ OnPaint(paint_event);
+
+ if (ThemeEngine.Current.DoubleBufferingSupported)
+ if ((control_style & ControlStyles.DoubleBuffer) != 0) {
+ dc.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
+ paint_event.SetGraphics (dc);
+ needs_redraw = false;
+ }
+
+ XplatUI.PaintEventEnd(Handle, true);
+
+ return;
+ }
+
+ case Msg.WM_ERASEBKGND: {
+ // The DefWndProc will never have to handle this, we always paint the background in managed code
+ m.Result = (IntPtr)1;
+ return;
+ }
+
+ case Msg.WM_LBUTTONUP: {
+ MouseEventArgs me;
+
+ me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
+ mouse_clicks,
+ LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0);
+
+ HandleClick(mouse_clicks, me);
+ OnMouseUp (me);
+
+ if (Capture) {
+ Capture = false;
+ }
+
+ if (mouse_clicks > 1) {
+ mouse_clicks = 1;
+ }
+ return;
+ }
+
+ case Msg.WM_LBUTTONDOWN: {
+ if (CanSelect && !is_selected) {
+ Select(this);
+ }
+ Capture = true;
+ OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
+ mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0));
+
+ return;
+ }
+
+ case Msg.WM_LBUTTONDBLCLK: {
+ Capture = true;
+ mouse_clicks++;
+ OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
+ mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0));
+
+ return;
+ }
+
+ case Msg.WM_MBUTTONUP: {
+ MouseEventArgs me;
+
+ me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
+ mouse_clicks,
+ LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0);
+
+ HandleClick(mouse_clicks, me);
+ OnMouseUp (me);
+ if (Capture) {
+ Capture = false;
+ }
+ if (mouse_clicks > 1) {
+ mouse_clicks = 1;
+ }
+ return;
+ }
+
+ case Msg.WM_MBUTTONDOWN: {
+ Capture = true;
+ OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
+ mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0));
+
+ return;
+ }
+
+ case Msg.WM_MBUTTONDBLCLK: {
+ Capture = true;
+ mouse_clicks++;
+ OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
+ mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0));
+ return;
+ }
+
+ case Msg.WM_RBUTTONUP: {
+ MouseEventArgs me;
+
+ if (context_menu != null) {
+ context_menu.Show(this, new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ())));
+ }
+ me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
+ mouse_clicks,
+ LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0);
+
+ HandleClick(mouse_clicks, me);
+ OnMouseUp (me);
+
+ if (Capture) {
+ Capture = false;
+ }
+
+ if (mouse_clicks > 1) {
+ mouse_clicks = 1;
+ }
+ return;
+ }
+
+ case Msg.WM_RBUTTONDOWN: {
+ Capture = true;
+ OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
+ mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0));
+ return;
+ }
+
+ case Msg.WM_RBUTTONDBLCLK: {
+ Capture = true;
+ mouse_clicks++;
+ OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
+ mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0));
+ return;
+ }
+
+ case Msg.WM_MOUSEWHEEL: {
+
+ OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
+ mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ HighOrder(m.WParam.ToInt32())));
+ return;
+ }
+
+
+ case Msg.WM_MOUSEMOVE: {
+ OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
+ mouse_clicks,
+ LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0));
+ return;
+ }
+
+ case Msg.WM_MOUSE_ENTER: {
+ if (is_entered) {
+ return;
+ }
+ is_entered = true;
+ OnMouseEnter(EventArgs.Empty);
+ return;
+ }
+
+ case Msg.WM_MOUSE_LEAVE: {
+ is_entered=false;
+ OnMouseLeave(EventArgs.Empty);
+ return;
+ }
+
+ case Msg.WM_MOUSEHOVER: {
+ OnMouseHover(EventArgs.Empty);
+ return;
+ }
+
+ case Msg.WM_SYSKEYUP: {
+ if (ProcessKeyMessage(ref m)) {
+ m.Result = IntPtr.Zero;
+ return;
+ }
+
+ if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
+ Form form;
+
+ form = FindForm();
+ if (form != null && form.ActiveMenu != null) {
+ form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
+ }
+ }
+
+ DefWndProc (ref m);
+ return;
+ }
+
+ case Msg.WM_SYSKEYDOWN:
+ case Msg.WM_KEYDOWN:
+ case Msg.WM_KEYUP:
+ case Msg.WM_SYSCHAR:
+ case Msg.WM_CHAR: {
+ if (ProcessKeyMessage(ref m)) {
+ m.Result = IntPtr.Zero;
+ return;
+ }
+ DefWndProc (ref m);
+ return;
+ }
+
+ case Msg.WM_HELP: {
+ Point mouse_pos;
+ if (m.LParam != IntPtr.Zero) {
+ HELPINFO hi;
+
+ hi = new HELPINFO();
+
+ hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
+ mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
+ } else {
+ mouse_pos = Control.MousePosition;
+ }
+ OnHelpRequested(new HelpEventArgs(mouse_pos));
+ m.Result = (IntPtr)1;
+ return;
+ }
+
+ case Msg.WM_KILLFOCUS: {
+ OnLeave(EventArgs.Empty);
+ if (CausesValidation) {
+ CancelEventArgs e;
+ e = new CancelEventArgs(false);
+
+ OnValidating(e);
+
+ if (e.Cancel) {
+ Focus();
+ return;
+ }
+
+ OnValidated(EventArgs.Empty);
+ }
+
+ this.has_focus = false;
+ this.is_selected = false;
+ OnLostFocus(EventArgs.Empty);
+ return;
+ }
+
+ case Msg.WM_SETFOCUS: {
+ OnEnter(EventArgs.Empty);
+ this.has_focus = true;
+ OnGotFocus(EventArgs.Empty);
+ return;
+ }
+
+
+ case Msg.WM_SYSCOLORCHANGE: {
+ ThemeEngine.Current.ResetDefaults();
+ OnSystemColorsChanged(EventArgs.Empty);
+ return;
+ }
+
+
+ case Msg.WM_SETCURSOR: {
+ if ((cursor == null) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
+ DefWndProc(ref m);
+ return;
+ }
+
+ XplatUI.SetCursor(window.Handle, cursor.handle);
+ m.Result = (IntPtr)1;
+
+ return;
+ }
+
+ default: {
+ DefWndProc(ref m);
+ return;
+ }
+ }
+ }
+ #endregion // Public Instance Methods
+
+ #region OnXXX methods
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnBackColorChanged(EventArgs e) {
+ if (BackColorChanged!=null) BackColorChanged(this, e);
+ for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnBackgroundImageChanged(EventArgs e) {
+ if (BackgroundImageChanged!=null) BackgroundImageChanged(this, e);
+ for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnBindingContextChanged(EventArgs e) {
+ CheckDataBindings ();
+ if (BindingContextChanged!=null) {
+ BindingContextChanged(this, e);
+ }
+ for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnCausesValidationChanged(EventArgs e) {
+ if (CausesValidationChanged!=null) CausesValidationChanged(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnChangeUICues(UICuesEventArgs e) {
+ if (ChangeUICues!=null) ChangeUICues(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnClick(EventArgs e) {
+ if (Click!=null) Click(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnContextMenuChanged(EventArgs e) {
+ if (ContextMenuChanged!=null) ContextMenuChanged(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnControlAdded(ControlEventArgs e) {
+ if (ControlAdded!=null) ControlAdded(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnControlRemoved(ControlEventArgs e) {
+ if (ControlRemoved!=null) ControlRemoved(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnCreateControl() {
+ // Override me!
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnCursorChanged(EventArgs e) {
+ if (CursorChanged!=null) CursorChanged(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnDockChanged(EventArgs e) {
+ if (DockChanged!=null) DockChanged(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnDoubleClick(EventArgs e) {
+ if (DoubleClick!=null) DoubleClick(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnDragDrop(DragEventArgs drgevent) {
+ if (DragDrop!=null) DragDrop(this, drgevent);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnDragEnter(DragEventArgs drgevent) {
+ if (DragEnter!=null) DragEnter(this, drgevent);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnDragLeave(EventArgs e) {
+ if (DragLeave!=null) DragLeave(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnDragOver(DragEventArgs drgevent) {
+ if (DragOver!=null) DragOver(this, drgevent);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnEnabledChanged(EventArgs e) {
+ if (EnabledChanged!=null) EnabledChanged(this, e);
+ for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentEnabledChanged(e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnEnter(EventArgs e) {
+ if (Enter!=null) Enter(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnFontChanged(EventArgs e) {
+ if (FontChanged!=null) FontChanged(this, e);
+ for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnForeColorChanged(EventArgs e) {
+ if (ForeColorChanged!=null) ForeColorChanged(this, e);
+ for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
+ if (GiveFeedback!=null) GiveFeedback(this, gfbevent);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnGotFocus(EventArgs e) {
+ if (GotFocus!=null) GotFocus(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnHandleCreated(EventArgs e) {
+ if (HandleCreated!=null) HandleCreated(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnHandleDestroyed(EventArgs e) {
+ if (HandleDestroyed!=null) HandleDestroyed(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnHelpRequested(HelpEventArgs hevent) {
+ if (HelpRequested!=null) HelpRequested(this, hevent);
+ }
+
+ protected virtual void OnImeModeChanged(EventArgs e) {
+ if (ImeModeChanged!=null) ImeModeChanged(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnInvalidated(InvalidateEventArgs e) {
+ needs_redraw = true;
+ if (Invalidated!=null) Invalidated(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnKeyDown(KeyEventArgs e) {
+ if (KeyDown!=null) KeyDown(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnKeyPress(KeyPressEventArgs e) {
+ if (KeyPress!=null) KeyPress(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnKeyUp(KeyEventArgs e) {
+ if (KeyUp!=null) KeyUp(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnLayout(LayoutEventArgs levent) {
+ if (Layout!=null) Layout(this, levent);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnLeave(EventArgs e) {
+ if (Leave!=null) Leave(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnLocationChanged(EventArgs e) {
+ OnMove(e);
+ if (LocationChanged!=null) LocationChanged(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnLostFocus(EventArgs e) {
+ if (LostFocus!=null) LostFocus(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnMouseDown(MouseEventArgs e) {
+ if (MouseDown!=null) MouseDown(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnMouseEnter(EventArgs e) {
+ if (MouseEnter!=null) MouseEnter(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnMouseHover(EventArgs e) {
+ if (MouseHover!=null) MouseHover(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnMouseLeave(EventArgs e) {
+ if (MouseLeave!=null) MouseLeave(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnMouseMove(MouseEventArgs e) {
+ if (MouseMove!=null) MouseMove(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnMouseUp(MouseEventArgs e) {
+ if (MouseUp!=null) MouseUp(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnMouseWheel(MouseEventArgs e) {
+ if (MouseWheel!=null) MouseWheel(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnMove(EventArgs e) {
+ if (Move!=null) Move(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnNotifyMessage(Message m) {
+ // Override me!
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnPaint(PaintEventArgs e) {
+ if (Paint!=null) Paint(this, e);
+ }
+
+ internal virtual void OnPaintInternal(PaintEventArgs e) {
+ // Override me
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnPaintBackground(PaintEventArgs pevent) {
+ PaintControlBackground (pevent);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnParentBackColorChanged(EventArgs e) {
+ if (background_color.IsEmpty && background_image==null) {
+ Invalidate();
+ OnBackColorChanged(e);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
+ if (background_color.IsEmpty && background_image==null) {
+ Invalidate();
+ OnBackgroundImageChanged(e);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnParentBindingContextChanged(EventArgs e) {
+ if (binding_context==null) {
+ binding_context=Parent.binding_context;
+ OnBindingContextChanged(e);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnParentChanged(EventArgs e) {
+ if (ParentChanged!=null) ParentChanged(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnParentEnabledChanged(EventArgs e) {
+ if (is_enabled != Parent.is_enabled) {
+ is_enabled=Parent.is_enabled;
+ Invalidate();
+ if (EnabledChanged != null) {
+ EnabledChanged(this, e);
+ }
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnParentFontChanged(EventArgs e) {
+ if (font==null) {
+ Invalidate();
+ OnFontChanged(e);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnParentForeColorChanged(EventArgs e) {
+ if (foreground_color.IsEmpty) {
+ Invalidate();
+ OnForeColorChanged(e);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnParentRightToLeftChanged(EventArgs e) {
+ if (right_to_left==RightToLeft.Inherit) {
+ Invalidate();
+ OnRightToLeftChanged(e);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnParentVisibleChanged(EventArgs e) {
+ if (is_visible) {
+ OnVisibleChanged(e);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
+ if (QueryContinueDrag!=null) QueryContinueDrag(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnResize(EventArgs e) {
+ if (Resize!=null) Resize(this, e);
+
+ PerformLayout(this, "bounds");
+
+ if (parent != null) {
+ parent.PerformLayout();
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnRightToLeftChanged(EventArgs e) {
+ if (RightToLeftChanged!=null) RightToLeftChanged(this, e);
+ for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnSizeChanged(EventArgs e) {
+ InvalidateBuffers ();
+ OnResize(e);
+ if (SizeChanged!=null) SizeChanged(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnStyleChanged(EventArgs e) {
+ if (StyleChanged!=null) StyleChanged(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnSystemColorsChanged(EventArgs e) {
+ if (SystemColorsChanged!=null) SystemColorsChanged(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnTabIndexChanged(EventArgs e) {
+ if (TabIndexChanged!=null) TabIndexChanged(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnTabStopChanged(EventArgs e) {
+ if (TabStopChanged!=null) TabStopChanged(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnTextChanged(EventArgs e) {
+ if (TextChanged!=null) TextChanged(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnValidated(EventArgs e) {
+ if (Validated!=null) Validated(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
+ if (Validating!=null) Validating(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnVisibleChanged(EventArgs e) {
+ if ((parent != null) && !Created && Visible) {
+ if (!is_disposed) {
+ CreateControl();
+ PerformLayout();
+ }
+ }
+
+ needs_redraw = true;
+
+ if (VisibleChanged!=null) VisibleChanged(this, e);
+
+ // We need to tell our kids
+ for (int i=0; i<child_controls.Count; i++) {
+ if (child_controls[i].Visible) {
+ child_controls[i].OnParentVisibleChanged(e);
+ }
+ }
+ }
+ #endregion // OnXXX methods
+
+ #region Events
+ public event EventHandler BackColorChanged;
+ public event EventHandler BackgroundImageChanged;
+ public event EventHandler BindingContextChanged;
+ public event EventHandler CausesValidationChanged;
+ public event UICuesEventHandler ChangeUICues;
+ public event EventHandler Click;
+ public event EventHandler ContextMenuChanged;
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ public event ControlEventHandler ControlAdded;
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ public event ControlEventHandler ControlRemoved;
+
+ [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
+ public event EventHandler CursorChanged;
+ public event EventHandler DockChanged;
+ public event EventHandler DoubleClick;
+ public event DragEventHandler DragDrop;
+ public event DragEventHandler DragEnter;
+ public event EventHandler DragLeave;
+ public event DragEventHandler DragOver;
+ public event EventHandler EnabledChanged;
+ public event EventHandler Enter;
+ public event EventHandler FontChanged;
+ public event EventHandler ForeColorChanged;
+ public event GiveFeedbackEventHandler GiveFeedback;
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ public event EventHandler GotFocus;
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ public event EventHandler HandleCreated;
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ public event EventHandler HandleDestroyed;
+
+ public event HelpEventHandler HelpRequested;
+ public event EventHandler ImeModeChanged;
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ public event InvalidateEventHandler Invalidated;
+
+ public event KeyEventHandler KeyDown;
+ public event KeyPressEventHandler KeyPress;
+ public event KeyEventHandler KeyUp;
+ public event LayoutEventHandler Layout;
+ public event EventHandler Leave;
+ public event EventHandler LocationChanged;
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ public event EventHandler LostFocus;
+
+ public event MouseEventHandler MouseDown;
+ public event EventHandler MouseEnter;
+ public event EventHandler MouseHover;
+ public event EventHandler MouseLeave;
+ public event MouseEventHandler MouseMove;
+ public event MouseEventHandler MouseUp;
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [Browsable(false)]
+ public event MouseEventHandler MouseWheel;
+
+ public event EventHandler Move;
+ public event PaintEventHandler Paint;
+ public event EventHandler ParentChanged;
+ public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp;
+ public event QueryContinueDragEventHandler QueryContinueDrag;
+ public event EventHandler Resize;
+ public event EventHandler RightToLeftChanged;
+ public event EventHandler SizeChanged;
+ public event EventHandler StyleChanged;
+ public event EventHandler SystemColorsChanged;
+ public event EventHandler TabIndexChanged;
+ public event EventHandler TabStopChanged;
+ public event EventHandler TextChanged;
+ public event EventHandler Validated;
+ public event CancelEventHandler Validating;
+ public event EventHandler VisibleChanged;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlBindingsCollection.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlBindingsCollection.cs
new file mode 100644
index 00000000000..263f8c14b98
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlBindingsCollection.cs
@@ -0,0 +1,144 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Reflection;
+
+
+namespace System.Windows.Forms {
+ [DefaultEvent("CollectionChanged")]
+ [Editor("System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing, typeof(System.Drawing.Design.UITypeEditor))]
+ [TypeConverter("System.Windows.Forms.Design.ControlBindingsConverter, " + Consts.AssemblySystem_Design)]
+ public class ControlBindingsCollection : BindingsCollection {
+ #region Fields
+ private Control control;
+ #endregion // Fields
+
+ #region Constructors
+ internal ControlBindingsCollection (Control control) {
+ this.control = control;
+ }
+ #endregion // Constructors
+
+ #region Public Instance Properties
+ public Control Control {
+ get {
+ return control;
+ }
+ }
+
+ public Binding this[string propertyName] {
+ get {
+ foreach (Binding b in base.List) {
+ if (b.PropertyName == propertyName) {
+ return b;
+ }
+ }
+ return null;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public new void Add (Binding binding)
+ {
+ AddCore (binding);
+ OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Add, binding));
+ }
+
+ public Binding Add (string property_name, object data_source, string data_member)
+ {
+ if (data_source == null) {
+ throw new ArgumentNullException ("DataSource cannot be null.");
+ }
+
+ Binding res = new Binding (property_name, data_source, data_member);
+ Add (res);
+ return res;
+ }
+
+ public void Clear() {
+ base.Clear();
+ }
+
+ public void Remove(Binding binding) {
+ if (binding == null) {
+ throw new NullReferenceException("The binding is null");
+ }
+
+ base.Remove(binding);
+ }
+
+ public void RemoveAt(int index) {
+ if (index < 0 || index >= base.List.Count) {
+ throw new ArgumentOutOfRangeException("index");
+ }
+
+ base.RemoveAt(index);
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected override void AddCore (Binding binding)
+ {
+ if (binding == null)
+ throw new ArgumentNullException ("dataBinding");
+
+ if (binding.Control != null && binding.Control != control)
+ throw new ArgumentException ("dataBinding belongs to another BindingsCollection");
+
+ for (int i = 0; i < Count; i++) {
+ Binding bnd = this [i];
+ if (bnd == null || bnd.PropertyName.Length == 0 || binding.PropertyName.Length == 0) {
+ continue;
+ }
+
+ if (String.Compare (bnd.PropertyName, binding.PropertyName, true) == 0) {
+ throw new ArgumentException ("The binding is already in the collection");
+ }
+ }
+
+ binding.SetControl (control);
+ binding.Check (control.BindingContext);
+ base.AddCore (binding);
+ }
+
+ protected override void ClearCore() {
+ base.ClearCore ();
+ }
+
+ protected override void RemoveCore(Binding dataBinding) {
+ if (dataBinding == null) {
+ throw new ArgumentNullException ("dataBinding");
+ }
+
+ base.RemoveCore (dataBinding);
+ }
+ #endregion // Protected Instance Methods
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlEventArgs.cs
new file mode 100644
index 00000000000..8b055659f45
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlEventArgs.cs
@@ -0,0 +1,48 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public class ControlEventArgs : EventArgs {
+ private Control control;
+
+ #region Public Constructors
+ public ControlEventArgs(Control control) {
+ this.control=control;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public Control Control {
+ get {
+ return this.control;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlEventHandler.cs
new file mode 100644
index 00000000000..56b3183fa67
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlEventHandler.cs
@@ -0,0 +1,32 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void ControlEventHandler (object sender, ControlEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlPaint.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlPaint.cs
new file mode 100644
index 00000000000..77251c49607
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlPaint.cs
@@ -0,0 +1,476 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// NOT COMPLETE
+
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+
+namespace System.Windows.Forms {
+ public sealed class ControlPaint {
+ #region Local Variables
+ static int RGBMax=255;
+ static int HLSMax=255;
+ #endregion // Local Variables
+
+ #region Private Enumerations
+
+
+ #region Constructor
+ // Prevent a public constructor from being created
+ private ControlPaint() {
+ }
+ #endregion // Constructor
+
+
+ #endregion // Private Enumerations
+
+ #region Helpers
+ private static Color Win32ToColor(int Win32Color) {
+ return(Color.FromArgb(
+ (int)(Win32Color) & 0xff0000 >> 16, // blue
+ (int)(Win32Color) & 0xff00 >> 8, // green
+ (int)(Win32Color) & 0xff // red
+ ));
+ }
+
+ internal static void Color2HBS(Color color, out int h, out int l, out int s) {
+ int r;
+ int g;
+ int b;
+ int cMax;
+ int cMin;
+ int rDelta;
+ int gDelta;
+ int bDelta;
+
+ r=color.R;
+ g=color.G;
+ b=color.B;
+
+ cMax = Math.Max(Math.Max(r, g), b);
+ cMin = Math.Min(Math.Min(r, g), b);
+
+ l = (((cMax+cMin)*HLSMax)+RGBMax)/(2*RGBMax);
+
+ if (cMax==cMin) { // Achromatic
+ h=0; // h undefined
+ s=0;
+ return;
+ }
+
+ /* saturation */
+ if (l<=(HLSMax/2)) {
+ s=(((cMax-cMin)*HLSMax)+((cMax+cMin)/2))/(cMax+cMin);
+ } else {
+ s=(((cMax-cMin)*HLSMax)+((2*RGBMax-cMax-cMin)/2))/(2*RGBMax-cMax-cMin);
+ }
+
+ /* hue */
+ rDelta=(((cMax-r)*(HLSMax/6))+((cMax-cMin)/2))/(cMax-cMin);
+ gDelta=(((cMax-g)*(HLSMax/6))+((cMax-cMin)/2))/(cMax-cMin);
+ bDelta=(((cMax-b)*(HLSMax/6))+((cMax-cMin)/2))/(cMax-cMin);
+
+ if (r == cMax) {
+ h=bDelta - gDelta;
+ } else if (g == cMax) {
+ h=(HLSMax/3) + rDelta - bDelta;
+ } else { /* B == cMax */
+ h=((2*HLSMax)/3) + gDelta - rDelta;
+ }
+
+ if (h<0) {
+ h+=HLSMax;
+ }
+
+ if (h>HLSMax) {
+ h-=HLSMax;
+ }
+ }
+
+ private static int HueToRGB(int n1, int n2, int hue) {
+ if (hue<0) {
+ hue+=HLSMax;
+ }
+
+ if (hue>HLSMax) {
+ hue -= HLSMax;
+ }
+
+ /* return r,g, or b value from this tridrant */
+ if (hue<(HLSMax/6)) {
+ return(n1+(((n2-n1)*hue+(HLSMax/12))/(HLSMax/6)));
+ }
+
+ if (hue<(HLSMax/2)) {
+ return(n2);
+ }
+
+ if (hue<((HLSMax*2)/3)) {
+ return(n1+(((n2-n1)*(((HLSMax*2)/3)-hue)+(HLSMax/12))/(HLSMax/6)));
+ } else {
+ return(n1);
+ }
+ }
+
+ internal static Color HBS2Color(int hue, int lum, int sat) {
+ int R;
+ int G;
+ int B;
+ int Magic1;
+ int Magic2;
+
+ if (sat == 0) { /* Achromatic */
+ R=G=B=(lum*RGBMax)/HLSMax;
+ // FIXME : Should throw exception if hue!=0
+ } else {
+ if (lum<=(HLSMax/2)) {
+ Magic2=(lum*(HLSMax+sat)+(HLSMax/2))/HLSMax;
+ } else {
+ Magic2=sat+lum-((sat*lum)+(HLSMax/2))/HLSMax;
+ }
+ Magic1=2*lum-Magic2;
+
+ R = Math.Min(255, (HueToRGB(Magic1,Magic2,hue+(HLSMax/3))*RGBMax+(HLSMax/2))/HLSMax);
+ G = Math.Min(255, (HueToRGB(Magic1,Magic2,hue)*RGBMax+(HLSMax/2))/HLSMax);
+ B = Math.Min(255, (HueToRGB(Magic1,Magic2,hue-(HLSMax/3))*RGBMax+(HLSMax/2))/HLSMax);
+ }
+ return(Color.FromArgb(R, G, B));
+ }
+ #endregion // Helpers
+
+ #region Public Static Properties
+ public static Color ContrastControlDark {
+ get { return(SystemColors.ControlDark); }
+ }
+ #endregion // Public Static Properties
+
+ #region Public Static Methods
+ public static IntPtr CreateHBitmap16Bit(Bitmap bitmap, Color background){
+ throw new NotImplementedException ();
+ }
+
+ public static IntPtr CreateHBitmapColorMask(Bitmap bitmap, IntPtr monochromeMask){
+ throw new NotImplementedException ();
+ }
+
+ public static IntPtr CreateHBitmapTransparencyMask(Bitmap bitmap){
+ throw new NotImplementedException ();
+ }
+
+ public static Color Light(Color baseColor) {
+ return Light(baseColor, 0.5f);
+ }
+
+ public static Color Light(Color baseColor,float per) {
+ if (baseColor == ThemeEngine.Current.ColorControl) {
+ int r_sub, g_sub, b_sub;
+ Color color;
+
+ if (per <= 0f)
+ return ThemeEngine.Current.ColorControlLight;
+
+ if (per == 1.0f)
+ return ThemeEngine.Current.ColorControlLightLight;
+
+ r_sub = ThemeEngine.Current.ColorControlLightLight.R - ThemeEngine.Current.ColorControlLight.R;
+ g_sub = ThemeEngine.Current.ColorControlLightLight.G - ThemeEngine.Current.ColorControlLight.G;
+ b_sub = ThemeEngine.Current.ColorControlLightLight.B - ThemeEngine.Current.ColorControlLight.B;
+
+ color = Color.FromArgb (ThemeEngine.Current.ColorControlLight.A,
+ (int) (ThemeEngine.Current.ColorControlLight.R + (r_sub * per)),
+ (int) (ThemeEngine.Current.ColorControlLight.G + (g_sub * per)),
+ (int) (ThemeEngine.Current.ColorControlLight.B + (b_sub * per)));
+
+ return color;
+ }
+
+ int H, I, S;
+
+ ControlPaint.Color2HBS(baseColor, out H, out I, out S);
+ int PreIntensity = Math.Min (255, I + (int) (I * 0.5f));
+ int NewIntensity = Math.Min (255, PreIntensity + (int) (PreIntensity * per));
+ return ControlPaint.HBS2Color(H, NewIntensity, S);
+ }
+
+ public static Color LightLight(Color baseColor) {
+ return Light(baseColor, 1.0f);
+ }
+
+ public static Color Dark(Color baseColor) {
+ return Dark(baseColor, 0.5f);
+ }
+
+ public static Color Dark(Color baseColor,float per) {
+
+ if (baseColor == ThemeEngine.Current.ColorControl) {
+
+ int r_sub, g_sub, b_sub;
+ Color color;
+
+ if (per <= 0f)
+ return ThemeEngine.Current.ColorControlDark;
+
+ if (per == 1.0f)
+ return ThemeEngine.Current.ColorControlDarkDark;
+
+ r_sub = ThemeEngine.Current.ColorControlDarkDark.R - ThemeEngine.Current.ColorControlDark.R;
+ g_sub = ThemeEngine.Current.ColorControlDarkDark.G - ThemeEngine.Current.ColorControlDark.G;
+ b_sub = ThemeEngine.Current.ColorControlDarkDark.B - ThemeEngine.Current.ColorControlDark.B;
+
+ color = Color.FromArgb (ThemeEngine.Current.ColorControlDark.A,
+ (int) (ThemeEngine.Current.ColorControlDark.R + (r_sub * per)),
+ (int) (ThemeEngine.Current.ColorControlDark.G + (g_sub * per)),
+ (int) (ThemeEngine.Current.ColorControlDark.B + (b_sub * per)));
+ return color;
+ }
+
+ int H, I, S;
+
+ ControlPaint.Color2HBS(baseColor, out H, out I, out S);
+ int PreIntensity = Math.Max (0, I - (int) (I * 0.333f));
+ int NewIntensity = Math.Max (0, PreIntensity - (int) (PreIntensity * per));
+ return ControlPaint.HBS2Color(H, NewIntensity, S);
+ }
+
+ public static Color DarkDark(Color baseColor) {
+ return Dark(baseColor, 1.0f);
+ }
+
+ public static void DrawBorder(Graphics graphics, Rectangle bounds, Color color, ButtonBorderStyle style) {
+ int line_width_top_left = 1;
+ int line_width_bottom_right = 1;
+
+ if (style == ButtonBorderStyle.Inset)
+ line_width_top_left = 2;
+ if (style == ButtonBorderStyle.Outset) {
+ line_width_bottom_right = 2;
+ line_width_top_left = 2;
+ }
+
+ DrawBorder(graphics, bounds, color, line_width_top_left, style, color, line_width_top_left, style, color, line_width_bottom_right, style, color, line_width_bottom_right, style);
+ }
+
+ public static void DrawBorder( Graphics graphics, Rectangle bounds, Color leftColor, int leftWidth,
+ ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
+ Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor, int bottomWidth,
+ ButtonBorderStyle bottomStyle) {
+
+ ThemeEngine.Current.CPDrawBorder (graphics, bounds, leftColor, leftWidth,
+ leftStyle, topColor, topWidth, topStyle, rightColor, rightWidth, rightStyle,
+ bottomColor, bottomWidth, bottomStyle);
+ }
+
+
+ public static void DrawBorder3D(Graphics graphics, Rectangle rectangle) {
+ DrawBorder3D(graphics, rectangle, Border3DStyle.Etched, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
+ }
+
+ public static void DrawBorder3D(Graphics graphics, Rectangle rectangle, Border3DStyle style) {
+ DrawBorder3D(graphics, rectangle, style, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
+ }
+
+ public static void DrawBorder3D(Graphics graphics, int x, int y, int width, int height) {
+ DrawBorder3D(graphics, new Rectangle(x, y, width, height), Border3DStyle.Etched, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
+ }
+
+ public static void DrawBorder3D(Graphics graphics, int x, int y, int width, int height, Border3DStyle style) {
+ DrawBorder3D(graphics, new Rectangle(x, y, width, height), style, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
+ }
+
+ public static void DrawBorder3D( Graphics graphics, int x, int y, int width, int height, Border3DStyle style,Border3DSide sides) {
+ DrawBorder3D( graphics, new Rectangle(x, y, width, height), style, sides);
+ }
+
+ public static void DrawBorder3D( Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides) {
+
+ ThemeEngine.Current.CPDrawBorder3D (graphics, rectangle, style, sides);
+ }
+
+ public static void DrawButton( Graphics graphics, int x, int y, int width, int height, ButtonState state) {
+ DrawButton(graphics, new Rectangle(x, y, width, height), state);
+ }
+
+ public static void DrawButton( Graphics graphics, Rectangle rectangle, ButtonState state) {
+
+ ThemeEngine.Current.CPDrawButton (graphics, rectangle, state);
+ }
+
+
+ public static void DrawCaptionButton(Graphics graphics, int x, int y, int width, int height, CaptionButton button, ButtonState state) {
+ DrawCaptionButton(graphics, new Rectangle(x, y, width, height), button, state);
+ }
+
+ public static void DrawCaptionButton(Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state) {
+
+ ThemeEngine.Current.CPDrawCaptionButton (graphics, rectangle, button, state);
+ }
+
+ public static void DrawCheckBox(Graphics graphics, int x, int y, int width, int height, ButtonState state) {
+ DrawCheckBox(graphics, new Rectangle(x, y, width, height), state);
+ }
+
+ public static void DrawCheckBox(Graphics graphics, Rectangle rectangle, ButtonState state) {
+
+ ThemeEngine.Current.CPDrawCheckBox (graphics, rectangle, state);
+ }
+
+ public static void DrawComboButton(Graphics graphics, Rectangle rectangle, ButtonState state) {
+
+ ThemeEngine.Current.CPDrawComboButton (graphics, rectangle, state);
+ }
+
+ public static void DrawComboButton(Graphics graphics, int x, int y, int width, int height, ButtonState state) {
+ DrawComboButton(graphics, new Rectangle(x, y, width, height), state);
+ }
+
+ public static void DrawContainerGrabHandle(Graphics graphics, Rectangle bounds) {
+
+ ThemeEngine.Current.CPDrawContainerGrabHandle (graphics, bounds);
+ }
+
+ public static void DrawFocusRectangle( Graphics graphics, Rectangle rectangle) {
+ DrawFocusRectangle(graphics, rectangle, SystemColors.Control, SystemColors.ControlText);
+ }
+
+ public static void DrawFocusRectangle( Graphics graphics, Rectangle rectangle, Color foreColor, Color backColor) {
+
+ ThemeEngine.Current.CPDrawFocusRectangle (graphics, rectangle, foreColor, backColor);
+ }
+
+ public static void DrawGrabHandle(Graphics graphics, Rectangle rectangle, bool primary, bool enabled) {
+
+ ThemeEngine.Current.CPDrawGrabHandle (graphics, rectangle, primary, enabled);
+ }
+
+ public static void DrawGrid(Graphics graphics, Rectangle area, Size pixelsBetweenDots, Color backColor) {
+
+ ThemeEngine.Current.CPDrawGrid (graphics, area, pixelsBetweenDots, backColor);
+ }
+
+ public static void DrawImageDisabled(Graphics graphics, Image image, int x, int y, Color background) {
+
+ ThemeEngine.Current.CPDrawImageDisabled (graphics, image, x, y, background);
+ }
+
+ public static void DrawLockedFrame(Graphics graphics, Rectangle rectangle, bool primary) {
+
+ ThemeEngine.Current.CPDrawLockedFrame (graphics, rectangle, primary);
+ }
+
+ public static void DrawMenuGlyph(Graphics graphics, Rectangle rectangle, MenuGlyph glyph) {
+
+ ThemeEngine.Current.CPDrawMenuGlyph (graphics, rectangle, glyph, ThemeEngine.Current.ColorMenuText);
+ }
+
+ public static void DrawMenuGlyph(Graphics graphics, int x, int y, int width, int height, MenuGlyph glyph) {
+ DrawMenuGlyph(graphics, new Rectangle(x, y, width, height), glyph);
+ }
+
+ public static void DrawMixedCheckBox(Graphics graphics, Rectangle rectangle, ButtonState state) {
+ DrawCheckBox(graphics, rectangle, state);
+ }
+
+ public static void DrawMixedCheckBox(Graphics graphics, int x, int y, int width, int height, ButtonState state) {
+ DrawMixedCheckBox(graphics, new Rectangle(x, y, width, height), state);
+ }
+
+
+ public static void DrawRadioButton(Graphics graphics, int x, int y, int width, int height, ButtonState state) {
+ DrawRadioButton(graphics, new Rectangle(x, y, width, height), state);
+ }
+
+ public static void DrawRadioButton(Graphics graphics, Rectangle rectangle, ButtonState state) {
+
+ ThemeEngine.Current.CPDrawRadioButton (graphics, rectangle, state);
+ }
+
+ [MonoTODO("Figure out a good System.Drawing way for XOR drawing")]
+ private static bool DRFNotImpl = false;
+ public static void DrawReversibleFrame(Rectangle rectangle, Color backColor, FrameStyle style) {
+ if (!DRFNotImpl) {
+ DRFNotImpl = true;
+ Console.WriteLine("NOT IMPLEMENTED: FillReversibleRectangle(Rectangle rectangle, Color backColor)");
+ }
+ //throw new NotImplementedException();
+ }
+
+ [MonoTODO("Figure out a good System.Drawing way for XOR drawing")]
+ private static bool DRLNotImpl = false;
+ public static void DrawReversibleLine(Point start, Point end, Color backColor) {
+ if (!DRLNotImpl) {
+ DRLNotImpl = true;
+ Console.WriteLine("NOT IMPLEMENTED: FillReversibleRectangle(Rectangle rectangle, Color backColor)");
+ }
+ //throw new NotImplementedException();
+ }
+
+ [MonoTODO("Figure out a good System.Drawing way for XOR drawing")]
+ private static bool FRRNotImpl = false;
+ public static void FillReversibleRectangle(Rectangle rectangle, Color backColor) {
+ if (!FRRNotImpl) {
+ FRRNotImpl = true;
+ Console.WriteLine("NOT IMPLEMENTED: FillReversibleRectangle(Rectangle rectangle, Color backColor)");
+ }
+ //throw new NotImplementedException();
+ }
+
+
+ public static void DrawScrollButton (Graphics graphics, int x, int y, int width, int height, ScrollButton button, ButtonState state) {
+ ThemeEngine.Current.CPDrawScrollButton (graphics, new Rectangle(x, y, width, height), button, state);
+ }
+
+ public static void DrawScrollButton (Graphics graphics, Rectangle rectangle, ScrollButton button, ButtonState state) {
+ ThemeEngine.Current.CPDrawScrollButton (graphics, rectangle, button, state);
+ }
+
+ [MonoTODO]
+ private static bool DSFNotImpl = false;
+ public static void DrawSelectionFrame(Graphics graphics, bool active, Rectangle outsideRect, Rectangle insideRect, Color backColor) {
+ if (!DSFNotImpl) {
+ DSFNotImpl = true;
+ Console.WriteLine("NOT IMPLEMENTED: DrawSelectionFrame(Graphics graphics, bool active, Rectangle outsideRect, Rectangle insideRect, Color backColor)");
+ }
+ //throw new NotImplementedException();
+ }
+
+ public static void DrawSizeGrip (Graphics graphics, Color backColor, Rectangle bounds)
+ {
+ ThemeEngine.Current.CPDrawSizeGrip (graphics, backColor, bounds);
+ }
+
+ public static void DrawSizeGrip(Graphics graphics, Color backColor, int x, int y, int width, int height) {
+ DrawSizeGrip(graphics, backColor, new Rectangle(x, y, width, height));
+ }
+
+ public static void DrawStringDisabled(Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle, StringFormat format) {
+
+ ThemeEngine.Current.CPDrawStringDisabled (graphics, s, font, color, layoutRectangle, format);
+ }
+ #endregion // Public Static Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlStyles.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlStyles.cs
new file mode 100644
index 00000000000..f483d2027f7
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlStyles.cs
@@ -0,0 +1,50 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+
+ [Flags]
+ public enum ControlStyles {
+ ContainerControl = 0x00000001,
+ UserPaint = 0x00000002,
+ Opaque = 0x00000004,
+ ResizeRedraw = 0x00000010,
+ FixedWidth = 0x00000020,
+ FixedHeight = 0x00000040,
+ StandardClick = 0x00000100,
+ Selectable = 0x00000200,
+ UserMouse = 0x00000400,
+ SupportsTransparentBackColor = 0x00000800,
+ StandardDoubleClick = 0x00001000,
+ AllPaintingInWmPaint = 0x00002000,
+ CacheText = 0x00004000,
+ EnableNotifyMessage = 0x00008000,
+ DoubleBuffer = 0x00010000
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ConvertEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ConvertEventArgs.cs
new file mode 100644
index 00000000000..7675c9f4283
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ConvertEventArgs.cs
@@ -0,0 +1,60 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public class ConvertEventArgs : EventArgs {
+ private object object_value;
+ private Type desired_type;
+
+ #region Public Constructors
+ public ConvertEventArgs(object value, Type desiredType) {
+ this.object_value=value;
+ this.desired_type=desiredType;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public Type DesiredType {
+ get {
+ return this.desired_type;
+ }
+ }
+
+ public object Value {
+ get {
+ return this.object_value;
+ }
+
+ set {
+ this.object_value=value;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ConvertEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ConvertEventHandler.cs
new file mode 100644
index 00000000000..f90c1c0cfc4
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ConvertEventHandler.cs
@@ -0,0 +1,31 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void ConvertEventHandler (object sender, ConvertEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Copyright b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Copyright
new file mode 100644
index 00000000000..e35b81540f3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Copyright
@@ -0,0 +1,40 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+//
+//
+//
+
+// NOT COMPLETE
+
+namespace System.Windows.Forms {
+ public class CreateParams {
+ #region Public Constructors
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CreateParams.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CreateParams.cs
new file mode 100644
index 00000000000..137ef905d66
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CreateParams.cs
@@ -0,0 +1,126 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+using System.Collections;
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+ public class CreateParams {
+ #region Local Variables
+ private string caption;
+ private string class_name;
+ private int class_style;
+ private int ex_style;
+ private int x;
+ private int y;
+ private int height;
+ private int width;
+ private int style;
+ private object param;
+ private IntPtr parent;
+ internal Menu menu;
+ #endregion // Local variables
+
+ #region Public Constructors
+ public CreateParams() {
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public string Caption {
+ get { return caption; }
+ set { caption = value; }
+ }
+
+ public string ClassName {
+ get { return class_name; }
+ set { class_name = value; }
+ }
+
+ public int ClassStyle {
+ get { return class_style; }
+ set { class_style = value; }
+ }
+
+ public int ExStyle {
+ get { return ex_style; }
+ set { ex_style = value; }
+ }
+
+ public int X {
+ get { return x; }
+ set { x = value; }
+ }
+
+ public int Y {
+ get { return y; }
+ set { y = value; }
+ }
+
+ public int Width {
+ get { return width; }
+ set { width = value; }
+ }
+
+ public int Height {
+ get { return height; }
+ set { height = value; }
+ }
+
+ public int Style {
+ get { return style; }
+ set { style = value; }
+ }
+
+ public object Param {
+ get { return param; }
+ set { param = value; }
+ }
+
+ public IntPtr Parent {
+ get { return parent; }
+ set { parent = value; }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public override string ToString() {
+ return "CreateParams {'" + class_name +
+ "', '" + caption +
+ "', " + String.Format("0x{0:X}", class_style) +
+ ", " + String.Format("0x{0:X}", ex_style) +
+ ", {" + String.Format("{0}", x) +
+ ", " + String.Format("{0}", y) +
+ ", " + String.Format("{0}", width) +
+ ", " + String.Format("{0}", height) +
+ "}}";
+ }
+ #endregion // Public Instance Methods
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CurrencyManager.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CurrencyManager.cs
new file mode 100644
index 00000000000..6270bb76e66
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CurrencyManager.cs
@@ -0,0 +1,302 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+//
+
+using System;
+using System.Data;
+using System.Reflection;
+using System.Collections;
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+ [DefaultMember("Item")]
+ public class CurrencyManager : BindingManagerBase {
+
+ protected Type finalType;
+ protected int listposition;
+
+ private IList list;
+ private bool binding_suspended;
+
+ internal CurrencyManager (object data_source, string data_member)
+ {
+ if (data_source is IList) {
+ list = (IList) data_source;
+ } else if (data_source is IListSource) {
+ list = ((IListSource) data_source).GetList ();
+ } else {
+ throw new Exception ("Attempted to create currency manager " +
+ "from invalid type: " + data_source.GetType ());
+ }
+
+ if (data_source as ArrayList != null) {
+ finalType = ((ArrayList)data_source).GetType ();
+ } else {
+ if (data_source as Array != null) {
+ finalType = ((Array) data_source).GetType ();
+ } else {
+ finalType = null;
+ }
+ }
+
+ DataTable table = data_source as DataTable;
+ if (table == null && data_source is DataView)
+ table = ((DataView) data_source).Table;
+
+
+ if (table == null) {
+ DataSet dataset = data_source as DataSet;
+ int sp = data_member.IndexOf ('.');
+ if (sp != -1) {
+ data_member = data_member.Substring (0, sp);
+ }
+ if (dataset != null) {
+ table = dataset.Tables [data_member];
+ }
+ }
+
+ if (table != null) {
+ list = new DataView (table);
+ table.Columns.CollectionChanged += new CollectionChangeEventHandler (MetaDataChangedHandler);
+ table.ChildRelations.CollectionChanged += new CollectionChangeEventHandler (MetaDataChangedHandler);
+ table.ParentRelations.CollectionChanged += new CollectionChangeEventHandler (MetaDataChangedHandler);
+ table.Constraints.CollectionChanged += new CollectionChangeEventHandler (MetaDataChangedHandler);
+ }
+ }
+
+ public IList List {
+ get { return list; }
+ }
+
+ public override object Current {
+ get {
+ return list [listposition];
+ }
+ }
+
+ public override int Count {
+ get { return list.Count; }
+ }
+
+ public override int Position {
+ get {
+ return listposition;
+ }
+ set {
+ if (value < 0)
+ value = 0;
+ if (value == list.Count)
+ value = list.Count - 1;
+ if (listposition == value)
+ return;
+ listposition = value;
+ OnCurrentChanged (EventArgs.Empty);
+ OnPositionChanged (EventArgs.Empty);
+ }
+ }
+
+ internal string ListName {
+ get {
+ ITypedList typed = list as ITypedList;
+
+ if (typed == null) {
+ return finalType.Name;
+ } else {
+ return typed.GetListName (null);
+ }
+ }
+ }
+
+ public override PropertyDescriptorCollection GetItemProperties ()
+ {
+ ITypedList typed = list as ITypedList;
+
+ if (list is Array) {
+ Type element = list.GetType ().GetElementType ();
+ return TypeDescriptor.GetProperties (element);
+ }
+
+ if (typed != null) {
+ return typed.GetItemProperties (null);
+ }
+
+ PropertyInfo [] props = finalType.GetProperties ();
+ for (int i = 0; i < props.Length; i++) {
+ if (props [i].Name == "Item") {
+ Type t = props [i].PropertyType;
+ if (t == typeof (object))
+ continue;
+ return GetBrowsableProperties (t);
+ }
+ }
+
+ if (list.Count > 0) {
+ return GetBrowsableProperties (list [0].GetType ());
+ }
+
+ return new PropertyDescriptorCollection (null);
+ }
+
+ public override void RemoveAt (int index)
+ {
+ list.RemoveAt (index);
+ }
+
+ public override void SuspendBinding ()
+ {
+ binding_suspended = true;
+ }
+
+ public override void ResumeBinding ()
+ {
+ binding_suspended = false;
+ }
+
+ internal override bool IsSuspended {
+ get { return binding_suspended; }
+ }
+
+ internal bool CanAddRows {
+ get {
+ if (list as IBindingList == null) {
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ public override void AddNew ()
+ {
+ if (list as IBindingList == null)
+ throw new NotSupportedException ();
+
+ (list as IBindingList).AddNew ();
+ }
+
+ public override void CancelCurrentEdit ()
+ {
+ IEditableObject editable = Current as IEditableObject;
+
+ if (editable == null)
+ return;
+ editable.CancelEdit ();
+ OnItemChanged (new ItemChangedEventArgs (Position));
+ }
+
+ public override void EndCurrentEdit ()
+ {
+ IEditableObject editable = Current as IEditableObject;
+
+ if (editable == null)
+ return;
+ editable.EndEdit ();
+ }
+
+ public void Refresh ()
+ {
+ PullData ();
+ }
+
+ [MonoTODO ("This is just a guess, as I can't figure out how to test this method")]
+ protected void CheckEmpty ()
+ {
+ if (list == null || list.Count < 1)
+ throw new Exception ("List is empty.");
+
+ }
+
+ protected internal override void OnCurrentChanged (EventArgs e)
+ {
+ PullData ();
+
+ if (onCurrentChangedHandler != null) {
+ onCurrentChangedHandler (this, e);
+ }
+ }
+
+ protected virtual void OnItemChanged (ItemChangedEventArgs e)
+ {
+ PushData ();
+
+ if (ItemChanged != null)
+ ItemChanged (this, e);
+ }
+
+ protected virtual void OnPositionChanged (EventArgs e)
+ {
+ if (onPositionChangedHandler == null)
+ return;
+ onPositionChangedHandler (this, e);
+ }
+
+ protected internal override string GetListName (ArrayList accessors)
+ {
+ if (list is ITypedList) {
+ PropertyDescriptor [] pds;
+ pds = new PropertyDescriptor [accessors.Count];
+ accessors.CopyTo (pds, 0);
+ return ((ITypedList) list).GetListName (pds);
+ }
+ return String.Empty;
+ }
+
+ [MonoTODO ("Not totally sure how this works, its doesn't seemt to do a pull/push like i originally assumed")]
+ protected override void UpdateIsBinding ()
+ {
+ UpdateItem ();
+
+ foreach (Binding binding in Bindings)
+ binding.UpdateIsBinding ();
+ }
+
+ private void UpdateItem ()
+ {
+ // Probably should be validating or something here
+ EndCurrentEdit ();
+ }
+
+ internal object GetItem (int index)
+ {
+ return list [index];
+ }
+
+ private PropertyDescriptorCollection GetBrowsableProperties (Type t)
+ {
+ Attribute [] att = new System.Attribute [1];
+ att [0] = new BrowsableAttribute (true);
+ return TypeDescriptor.GetProperties (t, att);
+ }
+
+ private void MetaDataChangedHandler (object sender, CollectionChangeEventArgs e)
+ {
+ if (MetaDataChanged != null)
+ MetaDataChanged (this, EventArgs.Empty);
+ }
+
+ public event ItemChangedEventHandler ItemChanged;
+ public event EventHandler MetaDataChanged;
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Cursor.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Cursor.cs
new file mode 100644
index 00000000000..dfa35258a71
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Cursor.cs
@@ -0,0 +1,729 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// NOT COMPLETE
+
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.IO;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using System.Runtime.Serialization;
+
+namespace System.Windows.Forms {
+ [Editor("System.Drawing.Design.CursorEditor, " + Consts.AssemblySystem_Drawing_Design, typeof(System.Drawing.Design.UITypeEditor))]
+ [Serializable]
+ [TypeConverter(typeof(CursorConverter))]
+ public sealed class Cursor : IDisposable, ISerializable {
+ #region Internal Structs
+ [StructLayout(LayoutKind.Sequential)]
+ private struct CursorDir {
+ internal ushort idReserved; // Reserved
+ internal ushort idType; // resource type (2 for cursors)
+ internal ushort idCount; // how many cursors
+ internal CursorEntry[] idEntries; // the entries for each cursor
+ };
+
+ [StructLayout(LayoutKind.Sequential)]
+ private struct CursorEntry {
+ internal byte width; // Width of cursor
+ internal byte height; // Height of cursor
+ internal byte colorCount; // colors in cursor
+ internal byte reserved; // Reserved
+ internal ushort xHotspot; // Hotspot X
+ internal ushort yHotspot; // Hotspot Y
+ internal ushort bitCount; // Bits per pixel
+ internal uint sizeInBytes; // size of (CursorInfoHeader + ANDBitmap + ORBitmap)
+ internal uint fileOffset; // position in file
+ };
+
+ [StructLayout(LayoutKind.Sequential)]
+ private struct CursorInfoHeader {
+ 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)]
+ private struct CursorImage {
+ internal CursorInfoHeader cursorHeader; // image header
+ internal uint[] cursorColors; // colors table
+ internal byte[] cursorXOR; // bits for XOR mask
+ internal byte[] cursorAND; // bits for AND mask
+ };
+ #endregion // Internal structs
+
+ #region Local Variables
+ private static Cursor current;
+ private CursorDir cursor_dir;
+ private CursorImage[] cursor_data;
+ private int id;
+
+ internal IntPtr handle;
+ private Size size;
+ private Bitmap shape;
+ private Bitmap mask;
+ private Bitmap cursor;
+ internal string name;
+ #endregion // Local Variables
+
+ #region Public Constructors
+ private void CreateCursor(System.IO.Stream stream) {
+ InitFromStream(stream);
+ this.shape = ToBitmap(true, false);
+ this.mask = ToBitmap(false, false);
+ handle = XplatUI.DefineCursor(shape, mask, Color.FromArgb(255, 255, 255), Color.FromArgb(255, 255, 255), cursor_dir.idEntries[id].xHotspot, cursor_dir.idEntries[id].yHotspot);
+ this.shape.Dispose();
+ this.shape = null;
+ this.mask.Dispose();
+ this.mask = null;
+
+ if (handle != IntPtr.Zero) {
+ this.cursor = ToBitmap(true, true);
+ }
+ }
+
+ private Cursor(SerializationInfo info, StreamingContext context) {
+ }
+
+ private Cursor() {
+ }
+
+ ~Cursor() {
+ Dispose();
+ }
+
+ // This is supposed to take a Win32 handle
+ public Cursor(IntPtr handle) {
+ this.handle = handle;
+ }
+
+ public Cursor(System.IO.Stream stream) {
+ CreateCursor(stream);
+ }
+
+ public Cursor(string fileName) : this (new FileStream (fileName, FileMode.Open)) {
+ }
+
+ public Cursor(Type type, string resource) {
+ using (Stream s = type.Assembly.GetManifestResourceStream (type, resource)) {
+ if (s == null) {
+ throw new FileNotFoundException ("Resource name was not found: `" + resource + "'");
+ }
+ CreateCursor(s);
+ }
+ }
+ #endregion // Public Constructors
+
+ #region Public Static Properties
+ public static Rectangle Clip {
+ get {
+ IntPtr handle;
+ bool confined;
+ Rectangle rect;
+ Size size;
+
+ XplatUI.GrabInfo(out handle, out confined, out rect);
+ if (handle != IntPtr.Zero) {
+ return rect;
+ }
+
+ XplatUI.GetDisplaySize(out size);
+ rect.X = 0;
+ rect.Y = 0;
+ rect.Width = size.Width;
+ rect.Height = size.Height;
+ return rect;
+ }
+
+ [MonoTODO("First need to add ability to set cursor clip rectangle to XplatUI drivers to implement this property")]
+ set {
+ ;
+ }
+ }
+
+ [MonoTODO("Implement setting a null cursor, and add XplatUI method to get current cursor")]
+ public static Cursor Current {
+ get {
+ if (current != null) {
+ return current;
+ }
+ return Cursors.Default;
+ }
+
+ set {
+ if (current != value) {
+ current = value;
+ if (value != null){
+ // FIXME - define and set empty cursor
+ current = null;
+ XplatUI.OverrideCursor(IntPtr.Zero);
+ } else
+ XplatUI.OverrideCursor(current.handle);
+ }
+ }
+ }
+
+ public static Point Position {
+ get {
+ int x;
+ int y;
+
+ XplatUI.GetCursorPos (IntPtr.Zero, out x, out y);
+ return new Point (x, y);
+ }
+
+ set {
+ XplatUI.SetCursorPos(IntPtr.Zero, value.X, value.Y);
+ }
+ }
+ #endregion // Public Static Properties
+
+ #region Public Instance Properties
+ public IntPtr Handle {
+ get {
+ return handle;
+ }
+ }
+
+ public Size Size {
+ get {
+ return size;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Static Methods
+ public static void Hide() {
+ XplatUI.ShowCursor(false);
+ }
+
+ public static void Show() {
+ XplatUI.ShowCursor(false);
+ }
+
+ public static bool operator !=(Cursor left, Cursor right) {
+ if ((object)left == (object)right) {
+ return false;
+ }
+
+ if ((object)left == null || (object)right == null) {
+ return true;
+ }
+
+ if (left.handle == right.handle) {
+ return false;
+ }
+ return true;
+ }
+
+
+ public static bool operator ==(Cursor left, Cursor right) {
+ if ((object)left == (object)right) {
+ return true;
+ }
+
+ if ((object)left == null || (object)right == null) {
+ return false;
+ }
+
+ if (left.handle == right.handle) {
+ return true;
+ }
+ return false;
+ }
+ #endregion // Public Static Methods
+
+ #region Public Instance Methods
+ public IntPtr CopyHandle() {
+ return handle;
+ }
+
+ public void Dispose() {
+ if (this.cursor != null) {
+ this.cursor.Dispose();
+ this.cursor = null;
+ }
+
+ if (this.shape != null) {
+ this.shape.Dispose();
+ this.shape = null;
+ }
+
+ if (this.mask != null) {
+ this.mask.Dispose();
+ this.mask = null;
+ }
+
+ GC.SuppressFinalize (this);
+ }
+
+ public void Draw(Graphics g, Rectangle targetRect) {
+ if (this.cursor != null) {
+ g.DrawImage(this.cursor, targetRect);
+ }
+ }
+
+ public void DrawStretched(Graphics g, Rectangle targetRect) {
+ if (this.cursor != null) {
+ g.DrawImage(this.cursor, targetRect, new Rectangle(0, 0, this.cursor.Width, this.cursor.Height), GraphicsUnit.Pixel);
+ }
+ }
+
+ public override bool Equals(object obj) {
+ if ( !(obj is Cursor)) {
+ return false;
+ }
+
+ if (((Cursor)obj).handle == this.handle) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public override int GetHashCode() {
+ return base.GetHashCode ();
+ }
+
+ public override string ToString() {
+ if (name != null) {
+ return "[Cursor:" + name + "]";
+ }
+
+ throw new FormatException("Cannot convert custom cursors to string.");
+ }
+
+ void ISerializable.GetObjectData(SerializationInfo si, StreamingContext context) {
+ MemoryStream ms;
+ BinaryWriter wr;
+ CursorImage ci;
+
+ ms = new MemoryStream();
+ wr = new BinaryWriter(ms);
+ ci = cursor_data[this.id];
+
+ // Build the headers, first the CursorDir
+ wr.Write((ushort)0); // Reserved
+ wr.Write((ushort)2); // Resource type
+ wr.Write((ushort)1); // Count
+
+ // Next the CursorEntry
+ wr.Write((byte)cursor_dir.idEntries[this.id].width);
+ wr.Write((byte)cursor_dir.idEntries[this.id].height);
+ wr.Write((byte)cursor_dir.idEntries[this.id].colorCount);
+ wr.Write((byte)cursor_dir.idEntries[this.id].reserved);
+ wr.Write((ushort)cursor_dir.idEntries[this.id].xHotspot);
+ wr.Write((ushort)cursor_dir.idEntries[this.id].yHotspot);
+ wr.Write((uint)(40 + (ci.cursorColors.Length * 4) + ci.cursorXOR.Length + ci.cursorAND.Length));
+ wr.Write((uint)(6 + 16)); // CursorDir + CursorEntry size
+
+ // Then the CursorInfoHeader
+ wr.Write(ci.cursorHeader.biSize);
+ wr.Write(ci.cursorHeader.biWidth);
+ wr.Write(ci.cursorHeader.biHeight);
+ wr.Write(ci.cursorHeader.biPlanes);
+ wr.Write(ci.cursorHeader.biBitCount);
+ wr.Write(ci.cursorHeader.biCompression);
+ wr.Write(ci.cursorHeader.biSizeImage);
+ wr.Write(ci.cursorHeader.biXPelsPerMeter);
+ wr.Write(ci.cursorHeader.biYPelsPerMeter);
+ wr.Write(ci.cursorHeader.biClrUsed);
+ wr.Write(ci.cursorHeader.biClrImportant);
+ for (int i = 0; i < ci.cursorColors.Length; i++) {
+ wr.Write(ci.cursorColors[i]);
+ }
+ wr.Write(ci.cursorXOR);
+ wr.Write(ci.cursorAND);
+ wr.Flush();
+
+ si.AddValue ("CursorData", ms.ToArray());
+ }
+ #endregion // Public Instance Methods
+
+ #region Private Methods w
+ private void InitFromStream(Stream stream) {
+ ushort entry_count;
+ CursorEntry ce;
+ uint largest;
+
+ //read the cursor header
+ if (stream == null || stream.Length == 0) {
+ throw new System.ArgumentException ("The argument 'stream' must be a picture that can be used as a cursor", "stream");
+ }
+
+ BinaryReader reader = new BinaryReader (stream);
+
+ cursor_dir = new CursorDir ();
+ cursor_dir.idReserved = reader.ReadUInt16();
+ cursor_dir.idType = reader.ReadUInt16();
+ if (cursor_dir.idReserved != 0 || !(cursor_dir.idType == 2 || cursor_dir.idType == 1))
+ throw new System.ArgumentException ("Invalid Argument, format error", "stream");
+
+ entry_count = reader.ReadUInt16();
+ cursor_dir.idCount = entry_count;
+ cursor_dir.idEntries = new CursorEntry[entry_count];
+ cursor_data = new CursorImage[entry_count];
+
+ //now read in the CursorEntry structures
+ for (int i=0; i < entry_count; i++){
+ ce = new CursorEntry();
+
+ ce.width = reader.ReadByte();
+ ce.height = reader.ReadByte();
+ ce.colorCount = reader.ReadByte();
+ ce.reserved = reader.ReadByte();
+ ce.xHotspot = reader.ReadUInt16();
+ ce.yHotspot = reader.ReadUInt16();
+ ce.sizeInBytes = reader.ReadUInt32();
+ ce.fileOffset = reader.ReadUInt32();
+
+ cursor_dir.idEntries[i] = ce;
+ }
+
+ // If we have more than one pick the largest cursor
+ largest = 0;
+ for (int j=0; j < entry_count; j++){
+ if (cursor_dir.idEntries[j].sizeInBytes >= largest) {
+ largest = cursor_dir.idEntries[j].sizeInBytes;
+ this.id = (ushort)j;
+ this.size.Height = cursor_dir.idEntries[j].height;
+ this.size.Width = cursor_dir.idEntries[j].width;
+ }
+ }
+
+ //now read in the cursor data
+ for (int j = 0; j < entry_count; j++) {
+ CursorImage curdata;
+ CursorInfoHeader cih;
+ byte[] buffer;
+ BinaryReader cih_reader;
+ int num_colors;
+ int cursor_height;
+ int bytes_per_line;
+ int xor_size;
+ int and_size;
+
+ curdata = new CursorImage();
+ cih = new CursorInfoHeader();
+
+ stream.Seek (cursor_dir.idEntries[j].fileOffset, SeekOrigin.Begin);
+ buffer = new byte [cursor_dir.idEntries[j].sizeInBytes];
+ stream.Read (buffer, 0, buffer.Length);
+
+ cih_reader = new BinaryReader(new MemoryStream(buffer));
+
+ cih.biSize = cih_reader.ReadUInt32 ();
+ if (cih.biSize != 40) {
+ throw new System.ArgumentException ("Invalid cursor file", "stream");
+ }
+ cih.biWidth = cih_reader.ReadInt32 ();
+ cih.biHeight = cih_reader.ReadInt32 ();
+ cih.biPlanes = cih_reader.ReadUInt16 ();
+ cih.biBitCount = cih_reader.ReadUInt16 ();
+ cih.biCompression = cih_reader.ReadUInt32 ();
+ cih.biSizeImage = cih_reader.ReadUInt32 ();
+ cih.biXPelsPerMeter = cih_reader.ReadInt32 ();
+ cih.biYPelsPerMeter = cih_reader.ReadInt32 ();
+ cih.biClrUsed = cih_reader.ReadUInt32 ();
+ cih.biClrImportant = cih_reader.ReadUInt32 ();
+
+ curdata.cursorHeader = cih;
+
+ //Read the number of colors used and corresponding memory occupied by
+ //color table. Fill this memory chunk into rgbquad[]
+ switch (cih.biBitCount){
+ case 1: num_colors = 2; break;
+ case 4: num_colors = 16; break;
+ case 8: num_colors = 256; break;
+ default: num_colors = 0; break;
+ }
+
+ curdata.cursorColors = new uint[num_colors];
+ for (int i = 0; i < num_colors; i++) {
+ curdata.cursorColors[i] = cih_reader.ReadUInt32 ();
+ }
+
+ //XOR mask is immediately after ColorTable and its size is
+ //icon height* no. of bytes per line
+
+ //cursor height is half of BITMAPINFOHEADER.biHeight, since it contains
+ //both XOR as well as AND mask bytes
+ cursor_height = cih.biHeight/2;
+
+ //bytes per line should should be uint aligned
+ bytes_per_line = ((((cih.biWidth * cih.biPlanes * cih.biBitCount)+ 31)>>5)<<2);
+
+ //Determine the XOR array Size
+ xor_size = bytes_per_line * cursor_height;
+ curdata.cursorXOR = new byte[xor_size];
+ for (int i = 0; i < xor_size; i++) {
+ curdata.cursorXOR[i] = cih_reader.ReadByte();
+ }
+
+ //Determine the AND array size
+ and_size = (int)(cih_reader.BaseStream.Length - cih_reader.BaseStream.Position);
+ curdata.cursorAND = new byte[and_size];
+ for (int i = 0; i < and_size; i++) {
+ curdata.cursorAND[i] = cih_reader.ReadByte();
+ }
+
+ cursor_data[j] = curdata;
+ cih_reader.Close();
+ }
+
+ reader.Close();
+ }
+
+ private Bitmap ToBitmapOld(bool xor, bool transparent) {
+ Bitmap bmp;
+
+ if (cursor_data != null) {
+ MemoryStream stream;
+ BinaryWriter writer;
+ CursorImage ci;
+ uint offset;
+ uint filesize;
+ ushort reserved12;
+ CursorInfoHeader cih;
+ int color_count;
+
+ stream = new MemoryStream();
+ writer = new BinaryWriter (stream);
+
+ ci = cursor_data[this.id];
+
+ try {
+ // write bitmap file header
+ writer.Write ('B');
+ writer.Write ('M');
+
+ // write the file size
+ // file size = bitmapfileheader + bitmapinfo + colorpalette + image bits
+ // sizeof bitmapfileheader = 14 bytes
+ // sizeof bitmapinfo = 40 bytes
+ if (xor) {
+ offset = (uint)(14 + 40 + ci.cursorColors.Length * 4);
+ filesize = (uint)(offset + ci.cursorXOR.Length);
+ } else {
+ offset = (uint)(14 + 40 + 8); // AND mask is always monochrome
+ filesize = (uint)(offset + ci.cursorAND.Length);
+ }
+ writer.Write(filesize);
+
+ // write reserved words
+ reserved12 = 0;
+ writer.Write(reserved12);
+ writer.Write(reserved12);
+
+ // write offset
+ writer.Write (offset);
+
+ // write bitmapfile header
+ cih = ci.cursorHeader;
+ writer.Write(cih.biSize);
+ writer.Write(cih.biWidth);
+ writer.Write(cih.biHeight/2);
+ writer.Write(cih.biPlanes);
+ if (xor) {
+ writer.Write(cih.biBitCount);
+ } else {
+ writer.Write((ushort)1);
+ }
+ writer.Write(cih.biCompression);
+ if (xor) {
+ writer.Write(ci.cursorXOR.Length);
+ } else {
+ writer.Write(ci.cursorAND.Length);
+ }
+ writer.Write(cih.biXPelsPerMeter);
+ writer.Write(cih.biYPelsPerMeter);
+
+ // write color table
+ if (xor) {
+ writer.Write(cih.biClrUsed);
+ writer.Write(cih.biClrImportant);
+ color_count = ci.cursorColors.Length;
+ for (int j = 0; j < color_count; j++) {
+ writer.Write (ci.cursorColors[j]);
+ }
+ } else {
+ // 2 used colors
+ writer.Write(2);
+ // 2 important colors
+ writer.Write(2);
+
+ writer.Write((uint)0x00000000);
+ writer.Write((uint)0x00ffffff);
+ }
+
+ // write image bits
+ if (xor)
+ writer.Write(ci.cursorXOR);
+ else
+ writer.Write(ci.cursorAND);
+
+ writer.Flush();
+
+ bmp = new Bitmap(stream);
+
+ if (transparent) {
+ 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 < cih.biHeight/2; y++) {
+ for (int x = 0; x < cih.biWidth / 8; x++) {
+ for (int bit = 7; bit >= 0; bit--) {
+ if (((ci.cursorAND[y * cih.biWidth / 8 +x] >> bit) & 1) != 0) {
+ bmp.SetPixel(x*8 + 7-bit, cih.biHeight/2 - y - 1, Color.Transparent);
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw e;
+ } finally {
+ writer.Close();
+ }
+ } else {
+ bmp = new Bitmap (32, 32);
+ }
+
+ return bmp;
+ }
+
+ private Bitmap ToBitmap(bool xor, bool transparent) {
+ CursorImage ci;
+ CursorInfoHeader cih;
+ int ncolors;
+ Bitmap bmp;
+ BitmapData bits;
+ ColorPalette pal;
+ int biHeight;
+ int bytesPerLine;
+
+ if (cursor_data == null) {
+ return new Bitmap(32, 32);
+ }
+
+ ci = cursor_data[this.id];
+ cih = ci.cursorHeader;
+ biHeight = cih.biHeight / 2;
+
+ if (!xor) {
+ // The AND mask is 1bit - very straightforward
+ bmp = new Bitmap(cih.biWidth, biHeight, PixelFormat.Format1bppIndexed);
+ pal = bmp.Palette;
+ pal.Entries[0] = Color.FromArgb(0, 0, 0);
+ pal.Entries[1] = Color.FromArgb(unchecked((int)0xffffffffff));
+ bits = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, bmp.PixelFormat);
+
+ for (int y = 0; y < biHeight; y++) {
+ Marshal.Copy(ci.cursorAND, bits.Stride * y, (IntPtr)(bits.Scan0.ToInt64() + bits.Stride * (biHeight - 1 - y)), bits.Stride);
+ }
+
+ bmp.UnlockBits(bits);
+ } else {
+ ncolors = (int)cih.biClrUsed;
+ if (ncolors == 0) {
+ if (cih.biBitCount < 24) {
+ ncolors = (int)(1 << cih.biBitCount);
+ }
+ }
+
+ switch(cih.biBitCount) {
+ case 1: { // Monochrome
+ bmp = new Bitmap(cih.biWidth, biHeight, PixelFormat.Format1bppIndexed);
+ break;
+ }
+
+ case 4: { // 4bpp
+ bmp = new Bitmap(cih.biWidth, biHeight, PixelFormat.Format4bppIndexed);
+ break;
+ }
+
+ case 8: { // 8bpp
+ bmp = new Bitmap(cih.biWidth, biHeight, PixelFormat.Format8bppIndexed);
+ break;
+ }
+
+ case 24:
+ case 32: { // 32bpp
+ bmp = new Bitmap(cih.biWidth, biHeight, PixelFormat.Format32bppArgb);
+ break;
+ }
+
+ default: {
+ throw new Exception("Unexpected number of bits:" + cih.biBitCount.ToString());
+ }
+ }
+
+ if (cih.biBitCount < 24) {
+ pal = bmp.Palette; // Managed palette
+
+ for (int i = 0; i < ci.cursorColors.Length; i++) {
+ pal.Entries[i] = Color.FromArgb((int)ci.cursorColors[i] & unchecked((int)0xff000000));
+ }
+ }
+
+ bytesPerLine = (int)((((cih.biWidth * cih.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(ci.cursorXOR, bytesPerLine * y, (IntPtr)(bits.Scan0.ToInt64() + bits.Stride * (biHeight - 1 - y)), bytesPerLine);
+ }
+
+ bmp.UnlockBits(bits);
+ }
+
+ if (transparent) {
+ 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 < cih.biWidth / 8; x++) {
+ for (int bit = 7; bit >= 0; bit--) {
+ if (((ci.cursorAND[y * cih.biWidth / 8 +x] >> bit) & 1) != 0) {
+ bmp.SetPixel(x*8 + 7-bit, biHeight - y - 1, Color.Transparent);
+ }
+ }
+ }
+ }
+ }
+
+ return bmp;
+ }
+ #endregion // Private Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CursorConverter.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CursorConverter.cs
new file mode 100644
index 00000000000..3f85767bd2e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CursorConverter.cs
@@ -0,0 +1,116 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+using System;
+using System.IO;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Collections;
+using System.ComponentModel;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.Runtime.Serialization;
+
+
+namespace System.Windows.Forms {
+
+ public class CursorConverter : TypeConverter {
+
+ public CursorConverter ()
+ {
+ }
+
+ public override bool CanConvertFrom (ITypeDescriptorContext context, Type source_type)
+ {
+ if (source_type == typeof (byte []))
+ return true;
+ return base.CanConvertFrom (context, source_type);
+ }
+
+ public override bool CanConvertTo (ITypeDescriptorContext context, Type dest_type)
+ {
+ if (dest_type == typeof (byte []))
+ return true;
+ return base.CanConvertTo (context, dest_type);
+ }
+
+ public override object ConvertFrom (ITypeDescriptorContext context,
+ CultureInfo culture, object value)
+ {
+ byte [] val = value as byte [];
+ if (val == null)
+ return base.ConvertFrom (context, culture, value);
+
+ using (MemoryStream s = new MemoryStream (val)) {
+ return new Cursor (s);
+ }
+ }
+
+ public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture,
+ object value, Type dest_type)
+ {
+ if (dest_type == null)
+ throw new ArgumentNullException ("destinationType");
+
+ if ( !(value is Cursor)) {
+ throw new ArgumentException("object must be of class Cursor", "value");
+ }
+
+ if (dest_type == typeof (byte [])) {
+ Cursor c;
+ SerializationInfo si;
+
+ if (value == null) {
+ return new byte [0];
+ }
+
+ c = (Cursor)value;
+
+ si = new SerializationInfo(typeof(Cursor), new FormatterConverter());
+ ((ISerializable)c).GetObjectData(si, new StreamingContext(StreamingContextStates.Remoting));
+
+ return (byte[])si.GetValue("CursorData", typeof(byte[]));
+ }
+ return base.ConvertTo (context, culture, value, dest_type);
+ }
+
+ public override StandardValuesCollection GetStandardValues (ITypeDescriptorContext context)
+ {
+ PropertyDescriptorCollection props = TypeDescriptor.GetProperties (typeof (Cursors));
+ ArrayList vals = new ArrayList ();
+
+ for (int i = 0; i < props.Count; i++)
+ vals.Add (props [i].GetValue (null));
+ return new StandardValuesCollection (vals);
+ }
+
+ public override bool GetStandardValuesSupported (ITypeDescriptorContext context)
+ {
+ return true;
+ }
+ }
+
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Cursors.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Cursors.cs
new file mode 100644
index 00000000000..37decfc21c3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Cursors.cs
@@ -0,0 +1,353 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public sealed class Cursors {
+ #region Local Variables
+ internal static Cursor app_starting;
+ internal static Cursor arrow;
+ internal static Cursor cross;
+ internal static Cursor def;
+ internal static Cursor hand;
+ internal static Cursor help;
+ internal static Cursor hsplit;
+ internal static Cursor ibeam;
+ internal static Cursor no;
+ internal static Cursor no_move_2d;
+ internal static Cursor no_move_horiz;
+ internal static Cursor no_move_vert;
+ internal static Cursor pan_east;
+ internal static Cursor pan_ne;
+ internal static Cursor pan_north;
+ internal static Cursor pan_nw;
+ internal static Cursor pan_se;
+ internal static Cursor pan_south;
+ internal static Cursor pan_sw;
+ internal static Cursor pan_west;
+ internal static Cursor size_all;
+ internal static Cursor size_nesw;
+ internal static Cursor size_ns;
+ internal static Cursor size_nwse;
+ internal static Cursor size_we;
+ internal static Cursor up_arrow;
+ internal static Cursor vsplit;
+ internal static Cursor wait_cursor;
+ #endregion // Local Variables
+
+ #region Constructors
+ private Cursors() {
+ }
+ #endregion // Constructors
+
+ #region Public Static Properties
+ public static Cursor AppStarting {
+ get {
+ if (app_starting == null) {
+ app_starting = new Cursor(XplatUI.DefineStdCursor(StdCursor.AppStarting));
+ app_starting.name = "AppStarting";
+ }
+ return app_starting;
+ }
+ }
+
+ public static Cursor Arrow {
+ get {
+ if (arrow == null) {
+ arrow = new Cursor(XplatUI.DefineStdCursor(StdCursor.Arrow));
+ arrow.name = "Arrow";
+ }
+ return arrow;
+ }
+ }
+
+ public static Cursor Cross {
+ get {
+ if (cross == null) {
+ cross = new Cursor(XplatUI.DefineStdCursor(StdCursor.Cross));
+ cross.name = "Cross";
+ }
+ return cross;
+ }
+ }
+
+ public static Cursor Default {
+ get {
+ if (def == null) {
+ def = new Cursor(XplatUI.DefineStdCursor(StdCursor.Default));
+ def.name = "Default";
+ }
+ return def;
+ }
+ }
+
+ public static Cursor Hand {
+ get {
+ if (hand == null) {
+ hand = new Cursor(XplatUI.DefineStdCursor(StdCursor.Hand));
+ hand.name = "Hand";
+ }
+ return hand;
+ }
+ }
+
+ public static Cursor Help {
+ get {
+ if (help == null) {
+ help = new Cursor(XplatUI.DefineStdCursor(StdCursor.Help));
+ help.name = "Help";
+ }
+ return help;
+ }
+ }
+
+ public static Cursor HSplit {
+ get {
+ if (hsplit == null) {
+ hsplit = new Cursor(XplatUI.DefineStdCursor(StdCursor.HSplit));
+ hsplit.name = "HSplit";
+ }
+ return hsplit;
+ }
+ }
+
+ public static Cursor IBeam {
+ get {
+ if (ibeam == null) {
+ ibeam = new Cursor(XplatUI.DefineStdCursor(StdCursor.IBeam));
+ ibeam.name = "IBeam";
+ }
+ return ibeam;
+ }
+ }
+
+ public static Cursor No {
+ get {
+ if (no == null) {
+ no = new Cursor(XplatUI.DefineStdCursor(StdCursor.No));
+ no.name = "No";
+ }
+ return no;
+ }
+ }
+
+ public static Cursor NoMove2D {
+ get {
+ if (no_move_2d == null) {
+ no_move_2d = new Cursor(XplatUI.DefineStdCursor(StdCursor.NoMove2D));
+ no_move_2d.name = "NoMove2D";
+ }
+ return no_move_2d;
+ }
+ }
+
+ public static Cursor NoMoveHoriz {
+ get {
+ if (no_move_horiz == null) {
+ no_move_horiz = new Cursor(XplatUI.DefineStdCursor(StdCursor.NoMoveHoriz));
+ no_move_horiz.name = "NoMoveHoriz";
+ }
+ return no_move_horiz;
+ }
+ }
+
+ public static Cursor NoMoveVert {
+ get {
+ if (no_move_vert == null) {
+ no_move_vert = new Cursor(XplatUI.DefineStdCursor(StdCursor.NoMoveVert));
+ no_move_vert.name = "NoMoveVert";
+ }
+ return no_move_vert;
+ }
+ }
+
+ public static Cursor PanEast {
+ get {
+ if (pan_east == null) {
+ pan_east = new Cursor(XplatUI.DefineStdCursor(StdCursor.PanEast));
+ pan_east.name = "PanEast";
+ }
+ return pan_east;
+ }
+ }
+
+
+
+
+ public static Cursor PanNE {
+ get {
+ if (pan_ne == null) {
+ pan_ne = new Cursor(XplatUI.DefineStdCursor(StdCursor.PanNE));
+ pan_ne.name = "PanNE";
+ }
+ return pan_ne;
+ }
+ }
+
+
+ public static Cursor PanNorth {
+ get {
+ if (pan_north == null) {
+ pan_north = new Cursor(XplatUI.DefineStdCursor(StdCursor.PanNorth));
+ pan_north.name = "PanNorth";
+ }
+ return pan_north;
+ }
+ }
+
+ public static Cursor PanNW {
+ get {
+ if (pan_nw == null) {
+ pan_nw = new Cursor(XplatUI.DefineStdCursor(StdCursor.PanNW));
+ pan_nw.name = "PanNW";
+ }
+ return pan_nw;
+ }
+ }
+
+ public static Cursor PanSE {
+ get {
+ if (pan_se == null) {
+ pan_se = new Cursor(XplatUI.DefineStdCursor(StdCursor.PanSE));
+ pan_se.name = "PanSE";
+ }
+ return pan_se;
+ }
+ }
+
+ public static Cursor PanSouth {
+ get {
+ if (pan_south == null) {
+ pan_south = new Cursor(XplatUI.DefineStdCursor(StdCursor.PanSouth));
+ pan_south.name = "PanSouth";
+ }
+ return pan_south;
+ }
+ }
+
+ public static Cursor PanSW {
+ get {
+ if (pan_sw == null) {
+ pan_sw = new Cursor(XplatUI.DefineStdCursor(StdCursor.PanSW));
+ pan_sw.name = "PanSW";
+ }
+ return pan_sw;
+ }
+ }
+
+ public static Cursor PanWest {
+ get {
+ if (pan_west == null) {
+ pan_west = new Cursor(XplatUI.DefineStdCursor(StdCursor.PanWest));
+ pan_west.name = "PanWest";
+ }
+ return pan_west;
+ }
+ }
+
+ public static Cursor SizeAll {
+ get {
+ if (size_all == null) {
+ size_all = new Cursor(XplatUI.DefineStdCursor(StdCursor.SizeAll));
+ size_all.name = "SizeAll";
+ }
+ return size_all;
+ }
+ }
+
+ public static Cursor SizeNESW {
+ get {
+ if (size_nesw == null) {
+ size_nesw = new Cursor(XplatUI.DefineStdCursor(StdCursor.SizeNESW));
+ size_nesw.name = "SizeNESW";
+ }
+ return size_nesw;
+ }
+ }
+
+ public static Cursor SizeNS {
+ get {
+ if (size_ns == null) {
+ size_ns = new Cursor(XplatUI.DefineStdCursor(StdCursor.SizeNS));
+ size_ns.name = "SizeNS";
+ }
+ return size_ns;
+ }
+ }
+
+ public static Cursor SizeNWSE {
+ get {
+ if (size_nwse == null) {
+ size_nwse = new Cursor(XplatUI.DefineStdCursor(StdCursor.SizeNWSE));
+ size_nwse.name = "SizeNWSE";
+ }
+ return size_nwse;
+ }
+ }
+
+ public static Cursor SizeWE {
+ get {
+ if (size_we == null) {
+ size_we = new Cursor(XplatUI.DefineStdCursor(StdCursor.SizeWE));
+ size_we.name = "SizeWE";
+ }
+ return size_we;
+ }
+ }
+
+ public static Cursor UpArrow {
+ get {
+ if (up_arrow == null) {
+ up_arrow = new Cursor(XplatUI.DefineStdCursor(StdCursor.UpArrow));
+ up_arrow.name = "UpArrow";
+ }
+ return up_arrow;
+ }
+ }
+
+ public static Cursor VSplit {
+ get {
+ if (vsplit == null) {
+ vsplit = new Cursor(XplatUI.DefineStdCursor(StdCursor.VSplit));
+ vsplit.name = "VSplit";
+ }
+ return vsplit;
+ }
+ }
+
+ public static Cursor WaitCursor {
+ get {
+ if (wait_cursor == null) {
+ wait_cursor = new Cursor(XplatUI.DefineStdCursor(StdCursor.WaitCursor));
+ wait_cursor.name = "WaitCursor";
+ }
+ return wait_cursor;
+ }
+ }
+ #endregion // Public Static Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataFormats.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataFormats.cs
new file mode 100644
index 00000000000..2ddf19f3898
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataFormats.cs
@@ -0,0 +1,215 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+using System;
+using System.Collections;
+using System.Text;
+
+namespace System.Windows.Forms {
+ public class DataFormats {
+ public class Format {
+ static readonly object lockobj = new object ();
+
+ private static Format formats;
+ private string name;
+ private int id;
+ private Format next;
+
+ public Format (string name, int ID)
+ {
+ this.name = name;
+ this.id = ID;
+
+ lock (lockobj) {
+ if (formats == null)
+ formats = this;
+ else {
+ Format f = formats;
+ while (f.next != null)
+ f = f.next;
+ f.next = this;
+ }
+ }
+ }
+
+ #region Public Instance Properties
+ public int Id {
+ get {
+ return this.id;
+ }
+ }
+
+ public string Name {
+ get {
+ return this.name;
+ }
+ }
+
+ internal Format Next {
+ get {
+ return this.next;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Private Methods
+ internal static Format Add(string name) {
+ Format f;
+
+ f = Find(name);
+ if (f == null) {
+ IntPtr cliphandle;
+
+ cliphandle = XplatUI.ClipboardOpen();
+ f = new Format(name, XplatUI.ClipboardGetID(cliphandle, name));
+ XplatUI.ClipboardClose(cliphandle);
+ }
+ return f;
+ }
+
+ internal static Format Add(int id) {
+ Format f;
+
+ f = Find(id);
+ if (f == null) {
+ f = new Format("Format"+id.ToString(), id);
+ }
+ return f;
+ }
+
+ internal static Format Find(int id) {
+ Format f;
+
+ f = formats;
+ while ((f != null) && (f.Id != id)) {
+ f = f.next;
+ }
+ return f;
+ }
+
+ internal static Format Find(string name) {
+ Format f;
+
+ f = formats;
+ while ((f != null) && (!f.Name.Equals(name))) {
+ f = f.next;
+ }
+ return f;
+ }
+
+ internal static Format List {
+ get {
+ return formats;
+ }
+ }
+ #endregion // Private Methods
+
+ }
+
+ private DataFormats () {}
+
+ #region Public Static Fields
+ public static readonly string Bitmap = "Bitmap";
+ public static readonly string CommaSeparatedValue = "Csv";
+ public static readonly string Dib = "DeviceIndependentBitmap";
+ public static readonly string Dif = "DataInterchangeFormat";
+ public static readonly string EnhancedMetafile = "EnhancedMetafile";
+ public static readonly string FileDrop = "FileDrop";
+ public static readonly string Html = "HTML Format";
+ public static readonly string Locale = "Locale";
+ public static readonly string MetafilePict = "MetaFilePict";
+ public static readonly string OemText = "OEMText";
+ public static readonly string Palette = "Palette";
+ public static readonly string PenData = "PenData";
+ public static readonly string Riff = "RiffAudio";
+ public static readonly string Rtf = "Rich Text Format";
+ public static readonly string Serializable = "WindowsForms10PersistentObject";
+ public static readonly string StringFormat = "System.String";
+ public static readonly string SymbolicLink = "SymbolicLink";
+ public static readonly string Text = "Text";
+ public static readonly string Tiff = "Tiff";
+ public static readonly string UnicodeText = "UnicodeText";
+ public static readonly string WaveAudio = "WaveAudio";
+ #endregion // Public Static Fields
+
+ private static object lock_object = new object ();
+ private static bool initialized;
+
+ public static Format GetFormat (int ID)
+ {
+ lock (lock_object) {
+ if (!initialized)
+ Init ();
+ return Format.Find (ID);
+ }
+ }
+
+ public static Format GetFormat (string format)
+ {
+ lock (lock_object) {
+ if (!initialized)
+ Init ();
+ return Format.Add (format);
+ }
+ }
+
+ // Assumes we are locked on the lock_object when it is called
+ private static void Init ()
+ {
+ if (initialized)
+ return;
+ IntPtr cliphandle = XplatUI.ClipboardOpen();
+
+ new Format (Text, XplatUI.ClipboardGetID (cliphandle, Text));
+ new Format (Bitmap, XplatUI.ClipboardGetID (cliphandle, Bitmap));
+ new Format (MetafilePict, XplatUI.ClipboardGetID (cliphandle, MetafilePict));
+ new Format (SymbolicLink, XplatUI.ClipboardGetID (cliphandle, SymbolicLink));
+ new Format (Dif, XplatUI.ClipboardGetID (cliphandle, Dif)) ;
+ new Format (Tiff, XplatUI.ClipboardGetID (cliphandle, Tiff));
+ new Format (OemText, XplatUI.ClipboardGetID (cliphandle, OemText));
+ new Format (Dib, XplatUI.ClipboardGetID (cliphandle, Dib));
+ new Format (Palette, XplatUI.ClipboardGetID (cliphandle, Palette));
+ new Format (PenData, XplatUI.ClipboardGetID (cliphandle, PenData));
+ new Format (Riff, XplatUI.ClipboardGetID (cliphandle, Riff));
+ new Format (WaveAudio, XplatUI.ClipboardGetID (cliphandle, WaveAudio));
+ new Format (UnicodeText, XplatUI.ClipboardGetID (cliphandle, UnicodeText));
+ new Format (EnhancedMetafile, XplatUI.ClipboardGetID (cliphandle, EnhancedMetafile));
+ new Format (FileDrop, XplatUI.ClipboardGetID (cliphandle, FileDrop));
+ new Format (Locale, XplatUI.ClipboardGetID (cliphandle, Locale));
+ new Format (CommaSeparatedValue, XplatUI.ClipboardGetID (cliphandle, CommaSeparatedValue));
+ new Format (Html, XplatUI.ClipboardGetID (cliphandle, Html));
+ new Format (Rtf, XplatUI.ClipboardGetID (cliphandle, Rtf));
+ new Format (Serializable, XplatUI.ClipboardGetID (cliphandle, Serializable));
+ new Format (StringFormat, XplatUI.ClipboardGetID (cliphandle, StringFormat));
+
+ XplatUI.ClipboardClose (cliphandle);
+
+ initialized = true;
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs
new file mode 100644
index 00000000000..019f6ee91ce
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs
@@ -0,0 +1,2249 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+// NOT COMPLETE
+
+
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Collections;
+
+namespace System.Windows.Forms
+{
+ [DefaultEvent("Navigate")]
+ [DefaultProperty("DataSource")]
+ [Designer("System.Windows.Forms.Design.DataGridDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ public class DataGrid : Control, ISupportInitialize, IDataGridEditingService
+ {
+ [Flags]
+ [Serializable]
+ public enum HitTestType
+ {
+ None = 0,
+ Cell = 1,
+ ColumnHeader = 2,
+ RowHeader = 4,
+ ColumnResize = 8,
+ RowResize = 16,
+ Caption = 32,
+ ParentRows = 64
+ }
+
+ public sealed class HitTestInfo
+ {
+ public static readonly HitTestInfo Nowhere = null;
+
+ #region Local Variables
+ internal int column;
+ internal int row;
+ internal HitTestType type;
+ #endregion // Local Variables
+
+ #region Private Constructors
+ internal HitTestInfo ()
+ {
+ column = -1;
+ row = -1;
+ type = HitTestType.None;
+ }
+ #endregion
+
+
+ #region Public Instance Properties
+ public int Column {
+ get { return column; }
+ }
+
+ public int Row {
+ get { return row; }
+ }
+ public DataGrid.HitTestType Type {
+ get { return type; }
+ }
+ #endregion //Public Instance Properties
+
+ public override bool Equals (object o)
+ {
+ if (!(o is HitTestInfo))
+ return false;
+
+ HitTestInfo obj = (HitTestInfo) o;
+ return (obj.Column == column && obj.Row == row && obj.Type ==type);
+ }
+
+ public override int GetHashCode ()
+ {
+ return row ^ column;
+ }
+
+ public override string ToString ()
+ {
+ return "{ " + type + "," + row + "," + column + "}";
+ }
+
+ }
+
+ #region Local Variables
+ private static readonly Color def_alternating_backcolor = ThemeEngine.Current.DataGridAlternatingBackColor;
+ private static readonly Color def_background_color = ThemeEngine.Current.DataGridBackgroundColor;
+ private static readonly Color def_caption_backcolor = ThemeEngine.Current.DataGridCaptionBackColor;
+ private static readonly Color def_caption_forecolor = ThemeEngine.Current.DataGridCaptionForeColor;
+ private static readonly Color def_gridline_color = ThemeEngine.Current.DataGridGridLineColor;
+ private static readonly Color def_header_backcolor = ThemeEngine.Current.DataGridHeaderBackColor;
+ private static readonly Font def_header_font = ThemeEngine.Current.DefaultFont;
+ private static readonly Color def_header_forecolor = ThemeEngine.Current.DataGridHeaderForeColor;
+ private static readonly Color def_link_hovercolor = ThemeEngine.Current.DataGridLinkHoverColor;
+ private static readonly Color def_parentrowsback_color = ThemeEngine.Current.DataGridParentRowsBackColor;
+ private static readonly Color def_parentrowsfore_color = ThemeEngine.Current.DataGridParentRowsForeColor;
+ private static readonly Color def_selection_backcolor = ThemeEngine.Current.DataGridSelectionBackColor;
+ private static readonly Color def_selection_forecolor = ThemeEngine.Current.DataGridSelectionForeColor;
+ private static readonly Color def_link_color = ThemeEngine.Current.DataGridLinkColor;
+ internal readonly int def_preferredrow_height;
+
+ private bool allow_navigation;
+ private bool allow_sorting;
+ private Color alternating_backcolor;
+ private Color backColor;
+ private Color background_color;
+ private Color caption_backcolor;
+ private Font caption_font;
+ private Color caption_forecolor;
+ private string caption_text;
+ internal bool caption_visible;
+ internal bool columnheaders_visible;
+ private object datasource;
+ private object real_datasource;
+ private string datamember;
+ private int firstvisible_column;
+ private bool flatmode;
+ private Color gridline_color;
+ private DataGridLineStyle gridline_style;
+ private Color header_backcolor;
+ private Color header_forecolor;
+ private Font header_font;
+ private Color link_color;
+ private Color link_hovercolor;
+ private Color parentrowsback_color;
+ private Color parentrowsfore_color;
+ private bool parentrows_visible;
+ private int preferredcolumn_width;
+ private int preferredrow_height;
+ private bool _readonly;
+ internal bool rowheaders_visible;
+ private Color selection_backcolor;
+ private Color selection_forecolor;
+ private int rowheaders_width;
+ internal int visiblecolumn_count;
+ internal int visiblerow_count;
+ internal int first_visiblecolumn;
+ private GridTableStylesCollection styles_collection;
+ private DataGridParentRowsLabelStyle parentrowslabel_style;
+ internal DataGridCell current_cell;
+ private DataGridTableStyle default_style;
+ private DataGridTableStyle current_style;
+ internal HScrollBar horiz_scrollbar;
+ internal VScrollBar vert_scrollbar;
+ internal DataGridDrawing grid_drawing;
+ internal int first_visiblerow;
+ internal int horz_pixeloffset;
+ internal bool is_editing; // Current cell is edit mode
+ internal bool is_changing; // Indicates if current cell is been changed (in edit mode)
+ internal bool is_adding; // Indicates when we are adding a row
+ private Hashtable selected_rows;
+ private bool ctrl_pressed;
+ private bool shift_pressed;
+ private bool begininit;
+ private CurrencyManager cached_currencymgr;
+ private CurrencyManager cached_currencymgr_events;
+ private bool accept_listmgrevents;
+ #endregion // Local Variables
+
+ #region Public Constructors
+ public DataGrid ()
+ {
+ grid_drawing = new DataGridDrawing (this);
+ allow_navigation = true;
+ allow_sorting = true;
+ begininit = false;
+ backColor = ThemeEngine.Current.DataGridBackColor;
+ alternating_backcolor = def_alternating_backcolor;
+ background_color = def_background_color;
+ border_style = BorderStyle.Fixed3D;
+ caption_backcolor = def_caption_backcolor;
+ caption_font = null;
+ caption_forecolor = def_caption_forecolor;
+ caption_text = string.Empty;
+ caption_visible = true;
+ columnheaders_visible = true;
+ datasource = null;
+ real_datasource = null;
+ datamember = string.Empty;
+ firstvisible_column = 0;
+ flatmode = false;
+ gridline_color = def_gridline_color;
+ gridline_style = DataGridLineStyle.Solid;
+ header_backcolor = def_header_backcolor;
+ header_forecolor = def_header_forecolor;
+ header_font = def_header_font;
+ link_color = def_link_color;
+ link_hovercolor = def_link_hovercolor;
+ parentrowsback_color = def_parentrowsback_color;
+ parentrowsfore_color = def_parentrowsfore_color;
+ parentrows_visible = true;
+ preferredcolumn_width = ThemeEngine.Current.DataGridPreferredColumnWidth;
+ _readonly = false;
+ rowheaders_visible = true;
+ selection_backcolor = def_selection_backcolor;
+ selection_forecolor = def_selection_forecolor;
+ rowheaders_width = 35;
+ visiblecolumn_count = 0;
+ visiblerow_count = 0;
+ current_cell = new DataGridCell ();
+ first_visiblerow = 0;
+ first_visiblecolumn = 0;
+ horz_pixeloffset = 0;
+ is_editing = false;
+ is_changing = false;
+ is_adding = false;
+ parentrowslabel_style = DataGridParentRowsLabelStyle.Both;
+ selected_rows = new Hashtable ();
+ ctrl_pressed = false;
+ shift_pressed = false;
+ preferredrow_height = def_preferredrow_height = FontHeight + 3;
+ cached_currencymgr_events = cached_currencymgr = null;
+ accept_listmgrevents = true;
+
+ default_style = new DataGridTableStyle (true);
+ styles_collection = new GridTableStylesCollection (this);
+ styles_collection.CollectionChanged += new CollectionChangeEventHandler (OnTableStylesCollectionChanged);
+
+ CurrentTableStyle = default_style;
+
+ horiz_scrollbar = new ImplicitHScrollBar ();
+ horiz_scrollbar.Scroll += new ScrollEventHandler (GridHScrolled);
+ vert_scrollbar = new ImplicitVScrollBar ();
+ vert_scrollbar.Scroll += new ScrollEventHandler (GridVScrolled);
+ KeyUp += new KeyEventHandler (OnKeyUpDG);
+
+ SetStyle (ControlStyles.UserMouse, true);
+
+ }
+
+ #endregion // Public Constructor
+
+ #region Public Instance Properties
+
+ [DefaultValue(true)]
+ public bool AllowNavigation {
+ get {
+ return allow_navigation;
+ }
+
+ set {
+ if (allow_navigation != value) {
+ allow_navigation = value;
+ OnAllowNavigationChanged (EventArgs.Empty);
+ }
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool AllowSorting {
+ get {
+ return allow_sorting;
+ }
+
+ set {
+ if (allow_sorting != value) {
+ allow_sorting = value;
+ }
+ }
+ }
+
+ public Color AlternatingBackColor {
+ get {
+ return alternating_backcolor;
+ }
+
+ set {
+ if (alternating_backcolor != value) {
+ alternating_backcolor = value;
+ Refresh ();
+ }
+ }
+ }
+
+ public override Color BackColor {
+ get {
+ return backColor;
+ }
+ set {
+ backColor = value;
+ }
+ }
+
+ public Color BackgroundColor {
+ get {
+ return background_color;
+ }
+ set {
+ if (background_color != value) {
+ background_color = value;
+ OnBackgroundColorChanged (EventArgs.Empty);
+ Refresh ();
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Image BackgroundImage {
+ get {
+ return base.BackgroundImage;
+ }
+
+ set {
+ base.BackgroundImage = value;
+ }
+ }
+
+ [DispId(-504)]
+ [DefaultValue(BorderStyle.Fixed3D)]
+ public BorderStyle BorderStyle {
+ get { return InternalBorderStyle; }
+ set {
+ InternalBorderStyle = value;
+ CalcAreasAndInvalidate ();
+ OnBorderStyleChanged (EventArgs.Empty);
+ }
+ }
+
+ public Color CaptionBackColor {
+ get {
+ return caption_backcolor;
+ }
+
+ set {
+ if (caption_backcolor != value) {
+ caption_backcolor = value;
+ grid_drawing.InvalidateCaption ();
+ }
+ }
+ }
+
+ [Localizable(true)]
+ [AmbientValue(null)]
+ public Font CaptionFont {
+ get {
+ if (caption_font == null) {
+ return Font;
+ }
+
+ return caption_font;
+ }
+
+ set {
+ if (caption_font != null && caption_font.Equals (value)) {
+ return;
+ }
+
+ caption_font = value;
+ CalcAreasAndInvalidate ();
+ }
+ }
+
+ public Color CaptionForeColor {
+ get {
+ return caption_forecolor;
+ }
+
+ set {
+ if (caption_forecolor != value) {
+ caption_forecolor = value;
+ grid_drawing.InvalidateCaption ();
+ }
+ }
+ }
+
+ [Localizable(true)]
+ [DefaultValue("")]
+ public string CaptionText {
+ get {
+ return caption_text;
+ }
+
+ set {
+ if (caption_text != value) {
+ caption_text = value;
+ grid_drawing.InvalidateCaption ();
+ }
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool CaptionVisible {
+ get {
+ return caption_visible;
+ }
+
+ set {
+ if (caption_visible != value) {
+ caption_visible = value;
+ CalcAreasAndInvalidate ();
+ OnCaptionVisibleChanged (EventArgs.Empty);
+ }
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool ColumnHeadersVisible {
+ get {
+ return columnheaders_visible;
+ }
+
+ set {
+ if (columnheaders_visible != value) {
+ columnheaders_visible = value;
+ CalcAreasAndInvalidate ();
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public DataGridCell CurrentCell {
+ get {
+ return current_cell;
+ }
+
+ set {
+ if (current_cell.Equals (value))
+ return;
+
+ if (value.RowNumber >= RowsCount) {
+ value.RowNumber = RowsCount == 0 ? 0 : RowsCount - 1;
+ }
+
+ if (value.ColumnNumber >= CurrentTableStyle.GridColumnStyles.Count) {
+ value.ColumnNumber = CurrentTableStyle.GridColumnStyles.Count == 0 ? 0: CurrentTableStyle.GridColumnStyles.Count - 1;
+ }
+
+ SetCurrentCell (value);
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int CurrentRowIndex {
+ get {
+ if (ListManager == null) {
+ return -1;
+ }
+
+ return current_cell.RowNumber;
+ }
+
+ set {
+ if (current_cell.RowNumber != value) {
+ CurrentCell = new DataGridCell (value, current_cell.ColumnNumber);
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Cursor Cursor {
+ get {
+ return base.Cursor;
+ }
+ set {
+ base.Cursor = value;
+ }
+ }
+
+ [DefaultValue(null)]
+ [Editor ("System.Windows.Forms.Design.DataMemberListEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
+ public string DataMember {
+ get { return datamember; }
+ set {
+ if (SetDataMember (value)) {
+ SetDataSource (datasource);
+ if (styles_collection.Contains (value) == true) {
+ CurrentTableStyle = styles_collection[value];
+ current_style.CreateColumnsForTable (false);
+ } else {
+ CurrentTableStyle = default_style;
+ current_style.GridColumnStyles.Clear ();
+ current_style.CreateColumnsForTable (false);
+ }
+ }
+ }
+ }
+
+ [DefaultValue(null)]
+ [RefreshProperties(RefreshProperties.Repaint)]
+ [TypeConverter("System.Windows.Forms.Design.DataSourceConverter, " + Consts.AssemblySystem_Design)]
+ public object DataSource {
+ get {
+ return datasource;
+ }
+
+ set {
+ if (SetDataSource (value)) {
+ SetNewDataSource ();
+ }
+ }
+ }
+
+ protected override Size DefaultSize {
+ get {
+ return new Size (130, 80);
+ }
+ }
+
+ [Browsable(false)]
+ public int FirstVisibleColumn {
+ get {
+ return firstvisible_column;
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool FlatMode {
+ get {
+ return flatmode;
+ }
+
+ set {
+ if (flatmode != value) {
+ flatmode = value;
+ OnFlatModeChanged (EventArgs.Empty);
+ Refresh ();
+ }
+ }
+ }
+
+ public override Color ForeColor {
+ get {
+ return base.ForeColor;
+ }
+
+ set {
+ base.ForeColor = value;
+ }
+ }
+
+ public Color GridLineColor {
+ get {
+ return gridline_color;
+ }
+
+ set {
+ if (value == Color.Empty) {
+ throw new ArgumentException ("Color.Empty value is invalid.");
+ }
+
+ if (gridline_color != value) {
+ gridline_color = value;
+ Refresh ();
+ }
+ }
+ }
+
+ [DefaultValue(DataGridLineStyle.Solid)]
+ public DataGridLineStyle GridLineStyle {
+ get {
+ return gridline_style;
+ }
+
+ set {
+ if (gridline_style != value) {
+ gridline_style = value;
+ Refresh ();
+ }
+ }
+ }
+
+ public Color HeaderBackColor {
+ get {
+ return header_backcolor;
+ }
+
+ set {
+ if (value == Color.Empty) {
+ throw new ArgumentException ("Color.Empty value is invalid.");
+ }
+
+ if (header_backcolor != value) {
+ header_backcolor = value;
+ Refresh ();
+ }
+ }
+ }
+
+ public Font HeaderFont {
+ get {
+ return header_font;
+ }
+
+ set {
+ if (header_font != null && !header_font.Equals (value)) {
+ header_font = value;
+ CalcAreasAndInvalidate ();
+ }
+ }
+ }
+
+ public Color HeaderForeColor {
+ get {
+ return header_forecolor;
+ }
+
+ set {
+ if (header_forecolor != value) {
+ header_forecolor = value;
+ Refresh ();
+ }
+ }
+ }
+
+ protected ScrollBar HorizScrollBar {
+ get {
+ return horiz_scrollbar;
+ }
+ }
+
+ public object this [DataGridCell cell] {
+ get {
+ return this [cell.RowNumber, cell.ColumnNumber];
+ }
+
+ set {
+ this [cell.RowNumber, cell.ColumnNumber] = value;
+ }
+ }
+
+ public object this [int rowIndex, int columnIndex] {
+ get {
+ return CurrentTableStyle.GridColumnStyles[columnIndex].GetColumnValueAtRow (ListManager,
+ rowIndex);
+ }
+
+ set {
+ CurrentTableStyle.GridColumnStyles[columnIndex].SetColumnValueAtRow (ListManager,
+ rowIndex, value);
+ }
+ }
+
+ public Color LinkColor {
+ get {
+ return link_color;
+ }
+ set {
+ if (link_color != value) {
+ link_color = value;
+ Refresh ();
+ }
+ }
+ }
+
+ [ComVisible(false)]
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Color LinkHoverColor {
+ get {
+ return link_hovercolor;
+ }
+
+ set {
+ if (link_hovercolor != value) {
+ link_hovercolor = value;
+ Refresh ();
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected internal CurrencyManager ListManager {
+ get {
+ if (BindingContext == null || DataSource == null) {
+ return null;
+ }
+
+ if (cached_currencymgr != null) {
+ return cached_currencymgr;
+ }
+
+ // If we bind real_datasource object we do not get the events from ListManger
+ // since the object is not the datasource and does not match
+ cached_currencymgr = (CurrencyManager) BindingContext [real_datasource, DataMember];
+ cached_currencymgr_events = (CurrencyManager) BindingContext [real_datasource, DataMember];
+ ConnectListManagerEvents ();
+ return cached_currencymgr;
+ }
+
+ set {
+ throw new NotSupportedException ("Operation is not supported.");
+ }
+ }
+
+ public Color ParentRowsBackColor {
+ get {
+ return parentrowsback_color;
+ }
+
+ set {
+ if (parentrowsback_color != value) {
+ parentrowsback_color = value;
+ if (parentrows_visible) {
+ Refresh ();
+ }
+ }
+ }
+ }
+
+ public Color ParentRowsForeColor {
+ get {
+ return parentrowsfore_color;
+ }
+
+ set {
+ if (parentrowsfore_color != value) {
+ parentrowsfore_color = value;
+ if (parentrows_visible) {
+ Refresh ();
+ }
+ }
+ }
+ }
+
+ [DefaultValue(DataGridParentRowsLabelStyle.Both)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public DataGridParentRowsLabelStyle ParentRowsLabelStyle {
+ get {
+ return parentrowslabel_style;
+ }
+
+ set {
+ if (parentrowslabel_style != value) {
+ parentrowslabel_style = value;
+ if (parentrows_visible) {
+ Refresh ();
+ }
+
+ OnParentRowsLabelStyleChanged (EventArgs.Empty);
+ }
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool ParentRowsVisible {
+ get {
+ return parentrows_visible;
+ }
+
+ set {
+ if (parentrows_visible != value) {
+ parentrows_visible = value;
+ CalcAreasAndInvalidate ();
+ OnParentRowsVisibleChanged (EventArgs.Empty);
+ }
+ }
+ }
+
+ // Settting this property seems to have no effect.
+ [DefaultValue(75)]
+ [TypeConverter(typeof(DataGridPreferredColumnWidthTypeConverter))]
+ public int PreferredColumnWidth {
+ get {
+ return preferredcolumn_width;
+ }
+
+ set {
+ if (value < 0) {
+ throw new ArgumentException ("PreferredColumnWidth is less than 0");
+ }
+
+ if (preferredcolumn_width != value) {
+ preferredcolumn_width = value;
+ Refresh ();
+ }
+ }
+ }
+
+ public int PreferredRowHeight {
+ get {
+ return preferredrow_height;
+ }
+
+ set {
+ if (preferredrow_height != value) {
+ preferredrow_height = value;
+ CalcAreasAndInvalidate ();
+ }
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool ReadOnly {
+ get {
+ return _readonly;
+ }
+
+ set {
+ if (_readonly != value) {
+ _readonly = value;
+ OnReadOnlyChanged (EventArgs.Empty);
+ CalcAreasAndInvalidate ();
+ }
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool RowHeadersVisible {
+ get {
+ return rowheaders_visible;
+ }
+
+ set {
+ if (rowheaders_visible != value) {
+ rowheaders_visible = value;
+ CalcAreasAndInvalidate ();
+ }
+ }
+ }
+
+ [DefaultValue(35)]
+ public int RowHeaderWidth {
+ get {
+ return rowheaders_width;
+ }
+
+ set {
+ if (rowheaders_width != value) {
+ rowheaders_width = value;
+ CalcAreasAndInvalidate ();
+ }
+ }
+ }
+
+ public Color SelectionBackColor {
+ get {
+ return selection_backcolor;
+ }
+
+ set {
+ if (selection_backcolor != value) {
+ selection_backcolor = value;
+ Refresh ();
+ }
+ }
+ }
+
+ public Color SelectionForeColor {
+ get {
+ return selection_forecolor;
+ }
+
+ set {
+ if (selection_forecolor != value) {
+ selection_forecolor = value;
+ Refresh ();
+ }
+ }
+ }
+
+ public override ISite Site {
+ get {
+ return base.Site;
+ }
+ set {
+ base.Site = value;
+ }
+ }
+
+ [Localizable(true)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public GridTableStylesCollection TableStyles {
+ get { return styles_collection; }
+ }
+
+ [Bindable(false)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override string Text {
+ get {
+ return base.Text;
+ }
+ set {
+ base.Text = value;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected ScrollBar VertScrollBar {
+ get {
+ return vert_scrollbar;
+ }
+ }
+
+ [Browsable(false)]
+ public int VisibleColumnCount {
+ get {
+ return visiblecolumn_count;
+ }
+ }
+
+ // Calculated at DataGridDrawing.CalcRowsHeaders
+ [Browsable(false)]
+ public int VisibleRowCount {
+ get {
+ return visiblerow_count;
+ }
+ }
+
+ #endregion // Public Instance Properties
+
+ #region Private Instance Properties
+ internal DataGridTableStyle CurrentTableStyle {
+ get {
+ return current_style;
+ }
+ set {
+ current_style = value;
+ current_style.DataGrid = this;
+ CalcAreasAndInvalidate ();
+ }
+ }
+
+ internal int FirstVisibleRow {
+ get { return first_visiblerow; }
+ set { first_visiblerow = value;}
+ }
+
+ internal int RowsCount {
+ get {
+ if (ListManager != null) {
+ return ListManager.Count;
+ }
+
+ return 0;
+ }
+ }
+
+ internal int RowHeight {
+ get {
+ if (CurrentTableStyle.CurrentPreferredRowHeight > Font.Height + 3 + 1 /* line */) {
+ return CurrentTableStyle.CurrentPreferredRowHeight;
+
+ } else {
+ return Font.Height + 3 + 1 /* line */;
+ }
+ }
+ }
+
+ internal bool ShowEditRow {
+ get {
+ if (ListManager != null && ListManager.CanAddRows == false) {
+ return false;
+ }
+
+ return _readonly == false;
+ }
+ }
+
+ // It should only be shown if there are relations that
+ // we do not support right now
+ internal bool ShowParentRowsVisible {
+ get {
+ //See parentrows_visible;
+ return false;
+ }
+ }
+
+ #endregion Private Instance Properties
+
+ #region Public Instance Methods
+
+ [MonoTODO]
+ public virtual bool BeginEdit (DataGridColumnStyle gridColumn, int rowNumber)
+ {
+ return false;
+ }
+
+ public virtual void BeginInit ()
+ {
+ begininit = true;
+ }
+
+ protected virtual void CancelEditing ()
+ {
+ if (current_cell.ColumnNumber < CurrentTableStyle.GridColumnStyles.Count) {
+ CurrentTableStyle.GridColumnStyles[current_cell.ColumnNumber].Abort (current_cell.RowNumber);
+ }
+
+ if (is_adding == true) {
+ ListManager.RemoveAt (RowsCount - 1);
+ is_adding = false;
+ }
+
+ is_editing = false;
+ is_changing = false;
+ InvalidateCurrentRowHeader ();
+ }
+
+ [MonoTODO]
+ public void Collapse (int row)
+ {
+
+ }
+
+ protected internal virtual void ColumnStartedEditing (Control editingControl)
+ {
+
+ }
+
+ protected internal virtual void ColumnStartedEditing (Rectangle bounds)
+ {
+
+ }
+
+ protected override AccessibleObject CreateAccessibilityInstance ()
+ {
+ return base.CreateAccessibilityInstance ();
+ }
+
+ protected virtual DataGridColumnStyle CreateGridColumn (PropertyDescriptor prop)
+ {
+ return CreateGridColumn (prop, false);
+ }
+
+ protected virtual DataGridColumnStyle CreateGridColumn (PropertyDescriptor prop, bool isDefault)
+ {
+ throw new NotImplementedException();
+ }
+
+ protected override void Dispose (bool disposing)
+ {
+ base.Dispose (disposing);
+ }
+
+ public virtual bool EndEdit (DataGridColumnStyle gridColumn, int rowNumber, bool shouldAbort)
+ {
+ if (is_adding == true) {
+ if (shouldAbort) {
+ ListManager.CancelCurrentEdit ();
+ } else {
+ ListManager.EndCurrentEdit ();
+ CalcAreasAndInvalidate ();
+ }
+ is_adding = false;
+ }
+
+ if (shouldAbort || gridColumn.ParentReadOnly ==true) {
+ gridColumn.Abort (rowNumber);
+ } else {
+ gridColumn.Commit (ListManager, rowNumber);
+ }
+
+ is_editing = false;
+ is_changing = false;
+ InvalidateCurrentRowHeader ();
+ return true;
+ }
+
+ public virtual void EndInit ()
+ {
+ begininit = false;
+ }
+
+ public void Expand (int row)
+ {
+
+ }
+
+ public Rectangle GetCellBounds (DataGridCell cell)
+ {
+ return GetCellBounds (cell.RowNumber, cell.ColumnNumber);
+ }
+
+ public Rectangle GetCellBounds (int row, int col)
+ {
+ return grid_drawing.GetCellBounds (row, col);
+ }
+
+ public Rectangle GetCurrentCellBounds ()
+ {
+ return GetCellBounds (current_cell.RowNumber, current_cell.ColumnNumber);
+ }
+
+ protected virtual string GetOutputTextDelimiter ()
+ {
+ return string.Empty;
+ }
+
+ protected virtual void GridHScrolled (object sender, ScrollEventArgs se)
+ {
+ if (se.NewValue == horz_pixeloffset ||
+ se.Type == ScrollEventType.EndScroll) {
+ return;
+ }
+
+ ScrollToColumnInPixels (se.NewValue);
+ }
+
+ protected virtual void GridVScrolled (object sender, ScrollEventArgs se)
+ {
+ int old_first_visiblerow = first_visiblerow;
+ first_visiblerow = se.NewValue;
+ grid_drawing.UpdateVisibleRowCount ();
+
+ if (first_visiblerow == old_first_visiblerow) {
+ return;
+ }
+ ScrollToRow (old_first_visiblerow, first_visiblerow);
+ }
+
+ public HitTestInfo HitTest (Point position)
+ {
+ return HitTest (position.X, position.Y);
+ }
+
+ public HitTestInfo HitTest (int x, int y)
+ {
+ return grid_drawing.HitTest (x, y);
+ }
+
+ [MonoTODO]
+ public bool IsExpanded (int rowNumber)
+ {
+ return false;
+ }
+
+ public bool IsSelected (int row)
+ {
+ return selected_rows[row] != null;
+ }
+
+ [MonoTODO]
+ public void NavigateBack ()
+ {
+
+ }
+
+ [MonoTODO]
+ public void NavigateTo (int rowNumber, string relationName)
+ {
+
+ }
+
+ protected virtual void OnAllowNavigationChanged (EventArgs e)
+ {
+ if (AllowNavigationChanged != null) {
+ AllowNavigationChanged (this, e);
+ }
+ }
+
+ protected void OnBackButtonClicked (object sender, EventArgs e)
+ {
+ if (BackButtonClick != null) {
+ BackButtonClick (sender, e);
+ }
+ }
+
+ protected override void OnBackColorChanged (EventArgs e)
+ {
+ base.OnBackColorChanged (e);
+ }
+
+ protected virtual void OnBackgroundColorChanged (EventArgs e)
+ {
+ if (BackgroundColorChanged != null) {
+ BackgroundColorChanged (this, e);
+ }
+ }
+
+ protected override void OnBindingContextChanged( EventArgs e)
+ {
+ base.OnBindingContextChanged (e);
+
+ current_style.CreateColumnsForTable (false);
+ CalcAreasAndInvalidate ();
+ }
+
+ protected virtual void OnBorderStyleChanged (EventArgs e)
+ {
+ if (BorderStyleChanged != null) {
+ BorderStyleChanged (this, e);
+ }
+ }
+
+ protected virtual void OnCaptionVisibleChanged (EventArgs e)
+ {
+ if (CaptionVisibleChanged != null) {
+ CaptionVisibleChanged (this, e);
+ }
+ }
+
+ protected virtual void OnCurrentCellChanged (EventArgs e)
+ {
+ if (CurrentCellChanged != null) {
+ CurrentCellChanged (this, e);
+ }
+ }
+
+ protected virtual void OnDataSourceChanged (EventArgs e)
+ {
+ if (DataSourceChanged != null) {
+ DataSourceChanged (this, e);
+ }
+ }
+
+ protected override void OnEnter (EventArgs e)
+ {
+ base.OnEnter (e);
+ }
+
+ protected virtual void OnFlatModeChanged (EventArgs e)
+ {
+ if (FlatModeChanged != null) {
+ FlatModeChanged (this, e);
+ }
+ }
+
+ protected override void OnFontChanged (EventArgs e)
+ {
+ grid_drawing.CalcGridAreas ();
+ base.OnFontChanged (e);
+ }
+
+ protected override void OnForeColorChanged (EventArgs e)
+ {
+ base.OnForeColorChanged (e);
+ }
+
+ protected override void OnHandleCreated (EventArgs e)
+ {
+ base.OnHandleCreated (e);
+ grid_drawing.CalcGridAreas ();
+ }
+
+ protected override void OnHandleDestroyed (EventArgs e)
+ {
+ base.OnHandleDestroyed (e);
+ }
+
+ protected override void OnKeyDown (KeyEventArgs ke)
+ {
+ base.OnKeyDown (ke);
+
+ if (ProcessGridKey (ke) == true) {
+ ke.Handled = true;
+ }
+
+ if (CurrentTableStyle.GridColumnStyles.Count > 0) {
+ CurrentTableStyle.GridColumnStyles[current_cell.ColumnNumber].OnKeyDown
+ (ke, current_cell.RowNumber, current_cell.ColumnNumber);
+ }
+ }
+
+ protected override void OnKeyPress (KeyPressEventArgs kpe)
+ {
+ base.OnKeyPress (kpe);
+ }
+
+ protected override void OnLayout (LayoutEventArgs levent)
+ {
+ base.OnLayout (levent);
+ CalcAreasAndInvalidate ();
+ }
+
+ protected override void OnLeave (EventArgs e)
+ {
+ base.OnLeave (e);
+ }
+
+ protected override void OnMouseDown (MouseEventArgs e)
+ {
+ base.OnMouseDown (e);
+
+ HitTestInfo testinfo;
+ testinfo = grid_drawing.HitTest (e.X, e.Y);
+
+ switch (testinfo.type) {
+ case HitTestType.Cell:
+ {
+ if (testinfo.Row < 0 || testinfo.Column < 0)
+ break;
+
+ DataGridCell new_cell = new DataGridCell (testinfo.Row, testinfo.Column);
+
+ if ((new_cell.Equals (current_cell) == false) || (!is_editing)) {
+ CancelEditing ();
+ SetCurrentCell (new_cell);
+ EditCell (current_cell);
+
+ } else {
+ CurrentTableStyle.GridColumnStyles[testinfo.Column].OnMouseDown (e, testinfo.Row, testinfo.Column);
+ }
+
+ break;
+ }
+ case HitTestType.RowHeader:
+ {
+ if (ctrl_pressed == false && shift_pressed == false) {
+ ResetSelection (); // Invalidates selected rows
+ }
+
+ if (shift_pressed == true) {
+ ShiftSelection (testinfo.Row);
+ } else { // ctrl_pressed or single item
+ Select (testinfo.Row);
+ }
+
+ CancelEditing ();
+ CurrentCell = new DataGridCell (testinfo.Row, current_cell.ColumnNumber);
+ OnRowHeaderClick (EventArgs.Empty);
+ break;
+ }
+
+ case HitTestType.ColumnHeader:
+ {
+ if (CurrentTableStyle.GridColumnStyles.Count == 0)
+ break;
+
+ if (allow_sorting == false)
+ break;
+
+ if (ListManager.List is IBindingList == false)
+ break;
+
+ ListSortDirection direction = ListSortDirection.Ascending;
+ PropertyDescriptor prop = CurrentTableStyle.GridColumnStyles[testinfo.Column].PropertyDescriptor;
+ IBindingList list = (IBindingList) ListManager.List;
+
+ if (list.SortProperty != null) {
+ CurrentTableStyle.GridColumnStyles[list.SortProperty].ArrowDrawingMode
+ = DataGridColumnStyle.ArrowDrawing.No;
+ }
+
+ if (prop == list.SortProperty && list.SortDirection == ListSortDirection.Ascending) {
+ direction = ListSortDirection.Descending;
+ }
+
+ CurrentTableStyle.GridColumnStyles[testinfo.Column].ArrowDrawingMode =
+ direction == ListSortDirection.Ascending ?
+ DataGridColumnStyle.ArrowDrawing.Ascending : DataGridColumnStyle.ArrowDrawing.Descending;
+
+ list.ApplySort (prop, direction);
+ Refresh ();
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+
+ protected override void OnMouseLeave (EventArgs e)
+ {
+ base.OnMouseLeave (e);
+ }
+
+ protected override void OnMouseMove (MouseEventArgs e)
+ {
+ base.OnMouseMove (e);
+ }
+
+ protected override void OnMouseUp (MouseEventArgs e)
+ {
+ base.OnMouseUp (e);
+ }
+
+ protected override void OnMouseWheel (MouseEventArgs e)
+ {
+ base.OnMouseWheel (e);
+
+ if (ctrl_pressed == false) { // scroll horizontal
+ if (e.Delta > 0) {
+ if (current_cell.RowNumber > 0) {
+ CurrentCell = new DataGridCell (current_cell.RowNumber - 1, current_cell.ColumnNumber);
+ }
+ }
+ else {
+ if (current_cell.RowNumber < RowsCount - 1) {
+ CurrentCell = new DataGridCell (current_cell.RowNumber + 1, current_cell.ColumnNumber);
+ }
+ }
+ } else {
+ if (e.Delta > 0) {
+ if (current_cell.ColumnNumber > 0) {
+ CurrentCell = new DataGridCell (current_cell.RowNumber, current_cell.ColumnNumber - 1);
+ }
+ }
+ else {
+ if (current_cell.ColumnNumber < CurrentTableStyle.GridColumnStyles.Count - 1) {
+ CurrentCell = new DataGridCell (current_cell.RowNumber, current_cell.ColumnNumber + 1);
+ }
+ }
+ }
+ }
+
+ protected void OnNavigate (NavigateEventArgs e)
+ {
+ if (Navigate != null) {
+ Navigate (this, e);
+ }
+ }
+
+ protected override void OnPaint (PaintEventArgs pe)
+ {
+ ThemeEngine.Current.DataGridPaint (pe, this);
+ }
+
+ protected override void OnPaintBackground (PaintEventArgs ebe)
+ {
+ }
+
+ protected virtual void OnParentRowsLabelStyleChanged (EventArgs e)
+ {
+ if (ParentRowsLabelStyleChanged != null) {
+ ParentRowsLabelStyleChanged (this, e);
+ }
+ }
+
+ protected virtual void OnParentRowsVisibleChanged (EventArgs e)
+ {
+ if (ParentRowsVisibleChanged != null) {
+ ParentRowsVisibleChanged (this, e);
+ }
+ }
+
+ protected virtual void OnReadOnlyChanged (EventArgs e)
+ {
+ if (ReadOnlyChanged != null) {
+ ReadOnlyChanged (this, e);
+ }
+ }
+
+ protected override void OnResize (EventArgs e)
+ {
+ base.OnResize (e);
+ }
+
+ protected void OnRowHeaderClick (EventArgs e)
+ {
+ if (RowHeaderClick != null) {
+ RowHeaderClick (this, e);
+ }
+ }
+
+ protected void OnScroll (EventArgs e)
+ {
+ if (Scroll != null) {
+ Scroll (this, e);
+ }
+ }
+
+ protected void OnShowParentDetailsButtonClicked (object sender, EventArgs e)
+ {
+ if (ShowParentDetailsButtonClick != null) {
+ ShowParentDetailsButtonClick (sender, e);
+ }
+ }
+
+ protected override bool ProcessDialogKey (Keys keyData)
+ {
+ return base.ProcessDialogKey (keyData);
+ }
+
+ protected bool ProcessGridKey (KeyEventArgs ke)
+ {
+ if (RowsCount == 0) {
+ return false;
+ }
+
+ switch (ke.KeyCode) {
+ case Keys.ControlKey:
+ ctrl_pressed = true;
+ break;
+ case Keys.ShiftKey:
+ shift_pressed = true;
+ break;
+ case Keys.Up:
+ {
+ if (current_cell.RowNumber > 0) {
+ CurrentCell = new DataGridCell (current_cell.RowNumber - 1, current_cell.ColumnNumber);
+ EditCell (current_cell);
+ }
+ break;
+ }
+ case Keys.Down:
+ {
+ if (current_cell.RowNumber < RowsCount - 1) {
+ CurrentCell = new DataGridCell (current_cell.RowNumber + 1, current_cell.ColumnNumber);
+ EditCell (current_cell);
+ }
+ break;
+ }
+
+ case Keys.Enter: {
+ if (current_cell.RowNumber + 1 == RowsCount) {
+ DataGridCell new_cell = new DataGridCell (current_cell.RowNumber + 1, current_cell.ColumnNumber);
+
+ SetCurrentCell (new_cell);
+ EditCell (current_cell);
+ }
+ break;
+ }
+
+ case Keys.Tab: {
+ if (current_cell.ColumnNumber + 1 < CurrentTableStyle.GridColumnStyles.Count) {
+ CurrentCell = new DataGridCell (current_cell.RowNumber, current_cell.ColumnNumber + 1);
+ EditCell (current_cell);
+ } else if (current_cell.RowNumber + 1 < RowsCount) {
+ CurrentCell = new DataGridCell (current_cell.RowNumber + 1, 0);
+ EditCell (current_cell);
+ } else if ((current_cell.RowNumber + 1 == RowsCount) && (current_cell.ColumnNumber + 1 == CurrentTableStyle.GridColumnStyles.Count)) {
+ int new_row;
+ int new_col;
+
+ new_row = current_cell.RowNumber;
+ new_col = current_cell.ColumnNumber + 1;
+ if (new_col >= CurrentTableStyle.GridColumnStyles.Count) {
+ new_row++;
+ new_col = 0;
+ }
+ DataGridCell new_cell = new DataGridCell (new_row, new_col);
+
+ SetCurrentCell (new_cell);
+ EditCell (current_cell);
+ }
+ break;
+ }
+
+ case Keys.Right:
+ {
+ if (current_cell.ColumnNumber + 1 < CurrentTableStyle.GridColumnStyles.Count) {
+ CurrentCell = new DataGridCell (current_cell.RowNumber, current_cell.ColumnNumber + 1);
+ EditCell (current_cell);
+ } else if (current_cell.RowNumber + 1 < RowsCount) {
+ CurrentCell = new DataGridCell (current_cell.RowNumber + 1, 0);
+ EditCell (current_cell);
+ }
+ break;
+ }
+ case Keys.Left:
+ {
+ if (current_cell.ColumnNumber > 0) {
+ CurrentCell = new DataGridCell (current_cell.RowNumber, current_cell.ColumnNumber - 1);
+ EditCell (current_cell);
+ } else if (current_cell.RowNumber > 0) {
+ CurrentCell = new DataGridCell (current_cell.RowNumber - 1, CurrentTableStyle.GridColumnStyles.Count - 1);
+ EditCell (current_cell);
+ }
+ break;
+ }
+ case Keys.PageUp:
+ {
+ if (current_cell.RowNumber > grid_drawing.VLargeChange) {
+ CurrentCell = new DataGridCell (current_cell.RowNumber - grid_drawing.VLargeChange, current_cell.ColumnNumber);
+ } else {
+ CurrentCell = new DataGridCell (0, current_cell.ColumnNumber);
+ }
+
+ EditCell (current_cell);
+ break;
+ }
+ case Keys.PageDown:
+ {
+ if (current_cell.RowNumber + grid_drawing.VLargeChange < RowsCount) {
+ CurrentCell = new DataGridCell (current_cell.RowNumber + grid_drawing.VLargeChange, current_cell.ColumnNumber);
+ } else {
+ CurrentCell = new DataGridCell (RowsCount - 1, current_cell.ColumnNumber);
+ }
+
+ EditCell (current_cell);
+ break;
+ }
+ case Keys.Home:
+ {
+ CurrentCell = new DataGridCell (current_cell.RowNumber, 0);
+ EditCell (current_cell);
+ break;
+ }
+ case Keys.End:
+ {
+ CurrentCell = new DataGridCell (current_cell.RowNumber, CurrentTableStyle.GridColumnStyles.Count - 1);
+ EditCell (current_cell);
+ break;
+ }
+ case Keys.Delete:
+ {
+ foreach (int row in selected_rows.Keys) {
+ ListManager.RemoveAt (row);
+ }
+ selected_rows.Clear ();
+ CalcAreasAndInvalidate ();
+ break;
+ }
+ default:
+ return false; // message not processed
+ }
+
+ return true; // message processed
+ }
+
+ // Called from DataGridTextBox
+ internal bool ProcessKeyPreviewInternal(ref Message m) {
+ Keys key = (Keys) m.WParam.ToInt32 ();
+ KeyEventArgs ke = new KeyEventArgs (key);
+ if (ProcessGridKey (ke) == true) {
+ return true;
+ }
+ return false;
+ }
+
+ protected override bool ProcessKeyPreview (ref Message m)
+ {
+ if (ProcessKeyPreviewInternal(ref m)) {
+ return true;
+ }
+ return base.ProcessKeyPreview (ref m);
+ }
+
+ protected bool ProcessTabKey (Keys keyData)
+ {
+ return false;
+ }
+
+ public void ResetAlternatingBackColor ()
+ {
+ alternating_backcolor = def_alternating_backcolor;
+ }
+
+ public override void ResetBackColor ()
+ {
+ backColor = ThemeEngine.Current.DataGridBackColor;
+ }
+
+ public override void ResetForeColor ()
+ {
+ base.ResetForeColor ();
+ }
+
+ public void ResetGridLineColor ()
+ {
+ gridline_color = def_gridline_color;
+ }
+
+ public void ResetHeaderBackColor ()
+ {
+ header_backcolor = def_header_backcolor;
+ }
+
+ public void ResetHeaderFont ()
+ {
+ header_font = def_header_font;
+ }
+
+ public void ResetHeaderForeColor ()
+ {
+ header_forecolor = def_header_forecolor;
+ }
+
+ public void ResetLinkColor ()
+ {
+ link_color = def_link_color;
+ }
+
+ public void ResetLinkHoverColor ()
+ {
+ link_hovercolor = def_link_hovercolor;
+ }
+
+ protected void ResetSelection ()
+ {
+ foreach (int row in selected_rows.Keys) {
+ grid_drawing.InvalidateRow (row);
+ grid_drawing.InvalidateRowHeader (row);
+ }
+
+ selected_rows.Clear ();
+ }
+
+ public void ResetSelectionBackColor ()
+ {
+ selection_backcolor = def_selection_backcolor;
+ }
+
+ public void ResetSelectionForeColor ()
+ {
+ selection_forecolor = def_selection_forecolor;
+ }
+
+ public void Select (int row)
+ {
+ if (selected_rows[row] == null) {
+ selected_rows.Add (row, true);
+ } else {
+ selected_rows[row] = true;
+ }
+
+ grid_drawing.InvalidateRow (row);
+ }
+
+ public void SetDataBinding (object dataSource, string dataMember)
+ {
+ dataMember = null;
+ SetDataSource (dataSource);
+ SetDataMember (dataMember);
+ SetNewDataSource ();
+ }
+
+ protected virtual bool ShouldSerializeAlternatingBackColor ()
+ {
+ return (alternating_backcolor != def_alternating_backcolor);
+ }
+
+ protected virtual bool ShouldSerializeBackgroundColor ()
+ {
+ return (background_color != def_background_color);
+ }
+
+ protected virtual bool ShouldSerializeCaptionBackColor ()
+ {
+ return (caption_backcolor != def_caption_backcolor);
+ }
+
+ protected virtual bool ShouldSerializeCaptionForeColor ()
+ {
+ return (caption_forecolor != def_caption_forecolor);
+ }
+
+ protected virtual bool ShouldSerializeGridLineColor ()
+ {
+ return (gridline_color != def_gridline_color);
+ }
+
+ protected virtual bool ShouldSerializeHeaderBackColor ()
+ {
+ return (header_backcolor != def_header_backcolor);
+ }
+
+ protected bool ShouldSerializeHeaderFont ()
+ {
+ return (header_font != def_header_font);
+ }
+
+ protected virtual bool ShouldSerializeHeaderForeColor ()
+ {
+ return (header_forecolor != def_header_forecolor);
+ }
+
+ protected virtual bool ShouldSerializeLinkHoverColor ()
+ {
+ return (link_hovercolor != def_link_hovercolor);
+ }
+
+ protected virtual bool ShouldSerializeParentRowsBackColor ()
+ {
+ return (parentrowsback_color != def_parentrowsback_color);
+ }
+
+ protected virtual bool ShouldSerializeParentRowsForeColor ()
+ {
+ return (parentrowsback_color != def_parentrowsback_color);
+ }
+
+ protected bool ShouldSerializePreferredRowHeight ()
+ {
+ return (preferredrow_height != def_preferredrow_height);
+ }
+
+ protected bool ShouldSerializeSelectionBackColor ()
+ {
+ return (selection_backcolor != def_selection_backcolor);
+ }
+
+ protected virtual bool ShouldSerializeSelectionForeColor ()
+ {
+ return (selection_forecolor != def_selection_forecolor);
+ }
+
+ public void SubObjectsSiteChange (bool site)
+ {
+
+ }
+
+ public void UnSelect (int row)
+ {
+ selected_rows.Remove (row);
+ grid_drawing.InvalidateRow (row);
+
+ }
+ #endregion // Public Instance Methods
+
+ #region Private Instance Methods
+
+ internal void CalcAreasAndInvalidate ()
+ {
+ grid_drawing.CalcGridAreas ();
+ Invalidate ();
+ }
+
+ private void ConnectListManagerEvents ()
+ {
+ cached_currencymgr_events.CurrentChanged += new EventHandler (OnListManagerCurrentChanged);
+ }
+
+ private void DisconnectListManagerEvents ()
+ {
+
+ }
+
+ // EndEdit current editing operation
+ internal virtual bool EndEdit (bool shouldAbort)
+ {
+ return EndEdit (CurrentTableStyle.GridColumnStyles[current_cell.ColumnNumber],
+ current_cell.RowNumber, shouldAbort);
+ }
+
+ private void EnsureCellVisilibility (DataGridCell cell)
+ {
+ if (cell.ColumnNumber <= first_visiblecolumn ||
+ cell.ColumnNumber + 1 >= first_visiblecolumn + visiblecolumn_count) {
+
+ first_visiblecolumn = grid_drawing.GetFirstColumnForColumnVisilibility (first_visiblecolumn, cell.ColumnNumber);
+
+ int pixel = grid_drawing.GetColumnStartingPixel (first_visiblecolumn);
+ ScrollToColumnInPixels (pixel);
+ }
+
+ if (cell.RowNumber < first_visiblerow ||
+ cell.RowNumber + 1 >= first_visiblerow + visiblerow_count) {
+
+ if (cell.RowNumber + 1 >= first_visiblerow + visiblerow_count) {
+ int old_first_visiblerow = first_visiblerow;
+ first_visiblerow = 1 + cell.RowNumber - visiblerow_count;
+ grid_drawing.UpdateVisibleRowCount ();
+ ScrollToRow (old_first_visiblerow, first_visiblerow);
+ }else {
+ int old_first_visiblerow = first_visiblerow;
+ first_visiblerow = cell.RowNumber;
+ grid_drawing.UpdateVisibleRowCount ();
+ ScrollToRow (old_first_visiblerow, first_visiblerow);
+ }
+
+ vert_scrollbar.Value = first_visiblerow;
+ }
+ }
+
+ internal IEnumerable GetDataSource (object source, string member)
+ {
+ IListSource src = (IListSource) source;
+ IList list = src.GetList();
+ IListSource listsource;
+ ITypedList typedlist;
+
+ if (source is IEnumerable) {
+ return (IEnumerable) source;
+ }
+
+ if(src.ContainsListCollection == false) {
+ return list;
+ }
+
+ listsource = (IListSource) source;
+
+ if (listsource == null) {
+ return null;
+ }
+
+ list = src.GetList ();
+
+ if (list == null) {
+ return null;
+ }
+
+ typedlist = (ITypedList) list;
+
+ if (typedlist == null) {
+ return null;
+ }
+
+ PropertyDescriptorCollection col = typedlist.GetItemProperties (new PropertyDescriptor [0]);
+ PropertyDescriptor prop = col.Find (member, true);
+
+ if (prop == null) {
+ if (col.Count > 0) {
+ prop = col[0];
+
+ if (prop == null) {
+ return null;
+ }
+ }
+ }
+
+ IEnumerable result = (IEnumerable)(prop.GetValue (list[0]));
+ return result;
+
+ }
+
+ internal void InvalidateCurrentRowHeader ()
+ {
+ grid_drawing.InvalidateRowHeader (current_cell.RowNumber);
+ }
+
+ private void SetCurrentCell (DataGridCell value)
+ {
+ if (current_cell.Equals (value))
+ return;
+
+ CancelEditing ();
+
+ int old_row = current_cell.RowNumber;
+
+ EnsureCellVisilibility (value);
+ current_cell = value;
+
+ if (current_cell.RowNumber != old_row) {
+ grid_drawing.InvalidateRowHeader (old_row);
+ }
+
+ accept_listmgrevents = false;
+
+ if (cached_currencymgr_events != null) {
+ cached_currencymgr_events.Position = current_cell.RowNumber;
+ }
+ accept_listmgrevents = true;
+ InvalidateCurrentRowHeader ();
+ OnCurrentCellChanged (EventArgs.Empty);
+ }
+
+ private bool SetDataMember (string member)
+ {
+ if (member == datamember) {
+ return false;
+ }
+
+ datamember = member;
+ real_datasource = GetDataSource (datasource, member);
+ DisconnectListManagerEvents ();
+ cached_currencymgr = cached_currencymgr_events = null;
+ return true;
+ }
+
+ private bool SetDataSource (object source)
+ {
+
+ if (source != null && source as IListSource != null && source as IList != null) {
+ throw new Exception ("Wrong complex data binding source");
+ }
+
+ current_cell = new DataGridCell ();
+ datasource = source;
+ DisconnectListManagerEvents ();
+ cached_currencymgr = cached_currencymgr_events = null;
+ try {
+ real_datasource = GetDataSource (datasource, DataMember);
+ }catch (Exception e) {
+ real_datasource = source;
+ }
+
+ OnDataSourceChanged (EventArgs.Empty);
+ return true;
+ }
+
+ private void SetNewDataSource ()
+ {
+ if (ListManager != null && TableStyles[datamember] == null) {
+ current_style.GridColumnStyles.Clear ();
+ }
+ current_style.CreateColumnsForTable (false);
+ CalcAreasAndInvalidate ();
+ }
+
+ private void OnKeyUpDG (object sender, KeyEventArgs e)
+ {
+ switch (e.KeyCode) {
+ case Keys.ControlKey:
+ ctrl_pressed = false;
+ break;
+ case Keys.ShiftKey:
+ shift_pressed = false;
+ break;
+ default:
+ break;
+ }
+ }
+
+ private void OnListManagerCurrentChanged (object sender, EventArgs e)
+ {
+ if (accept_listmgrevents == false) {
+ return;
+ }
+
+ CurrentCell = new DataGridCell (cached_currencymgr_events.Position, current_cell.RowNumber);
+ }
+
+ private void OnTableStylesCollectionChanged (object sender, CollectionChangeEventArgs e)
+ {
+ if (ListManager == null)
+ return;
+
+ switch (e.Action){
+ case CollectionChangeAction.Add: {
+ if (e.Element != null && String.Compare (ListManager.ListName, ((DataGridTableStyle)e.Element).MappingName, true) == 0) {
+ CurrentTableStyle = (DataGridTableStyle)e.Element;
+ ((DataGridTableStyle) e.Element).CreateColumnsForTable (false);
+ }
+ break;
+ }
+
+ case CollectionChangeAction.Remove: {
+ if (e.Element != null && String.Compare (ListManager.ListName, ((DataGridTableStyle)e.Element).MappingName, true) == 0) {
+ CurrentTableStyle = default_style;
+ current_style.GridColumnStyles.Clear ();
+ current_style.CreateColumnsForTable (false);
+ }
+ break;
+ }
+
+
+ case CollectionChangeAction.Refresh: {
+ if (e.Element != null && String.Compare (ListManager.ListName, ((DataGridTableStyle)e.Element).MappingName, true) == 0) {
+ CurrentTableStyle = (DataGridTableStyle)e.Element;
+ ((DataGridTableStyle) e.Element).CreateColumnsForTable (false);
+ } else {
+ CurrentTableStyle = default_style;
+ current_style.GridColumnStyles.Clear ();
+ current_style.CreateColumnsForTable (false);
+
+ }
+ break;
+
+ }
+ }
+ CalcAreasAndInvalidate ();
+ }
+
+ private void EditCell (DataGridCell cell)
+ {
+ ResetSelection (); // Invalidates selected rows
+ is_editing = false;
+ is_changing = false;
+
+ if (ShowEditRow && is_adding == false && cell.RowNumber >= RowsCount) {
+ ListManager.AddNew ();
+ is_adding = true;
+ Invalidate (); // We have just added a new row
+ }
+
+ CurrentTableStyle.GridColumnStyles[cell.ColumnNumber].Edit (ListManager,
+ cell.RowNumber, GetCellBounds (cell.RowNumber, cell.ColumnNumber),
+ _readonly, string.Empty, true);
+ }
+
+ private void ShiftSelection (int index)
+ {
+ int shorter_item = -1, dist = RowsCount + 1, cur_dist;
+
+ foreach (int row in selected_rows.Keys) {
+
+ if (row > index) {
+ cur_dist = row - index;
+ }
+ else {
+ cur_dist = index - row;
+ }
+
+ if (cur_dist < dist) {
+ dist = cur_dist;
+ shorter_item = row;
+ }
+ }
+
+ if (shorter_item != -1) {
+ int start, end;
+
+ if (shorter_item > index) {
+ start = index;
+ end = shorter_item;
+ } else {
+ start = shorter_item;
+ end = index;
+ }
+
+ ResetSelection ();
+ for (int idx = start; idx <= end; idx++) {
+ Select (idx);
+ }
+ }
+ }
+
+ private void ScrollToColumnInPixels (int pixel)
+ {
+ Rectangle invalidate = new Rectangle ();
+ Rectangle invalidate_column = new Rectangle ();
+
+ if (pixel > horz_pixeloffset) { // ScrollRight
+ int pixels = pixel - horz_pixeloffset;
+
+ horz_pixeloffset = horiz_scrollbar.Value = pixel;
+ grid_drawing.UpdateVisibleColumn ();
+
+ // Columns header
+ invalidate_column.X = grid_drawing.ColumnsHeadersArea.X + grid_drawing.ColumnsHeadersArea.Width - pixels;
+ invalidate_column.Y = grid_drawing.ColumnsHeadersArea.Y;
+ invalidate_column.Width = pixels;
+ invalidate_column.Height = grid_drawing.ColumnsHeadersArea.Height;
+ XplatUI.ScrollWindow (Handle, grid_drawing.ColumnsHeadersArea, -pixels, 0, false);
+
+ // Cells
+ invalidate.X = grid_drawing.CellsArea.X + grid_drawing.CellsArea.Width - pixels;
+ invalidate.Y = grid_drawing.CellsArea.Y;
+ invalidate.Width = pixels;
+ invalidate.Height = grid_drawing.CellsArea.Height;
+
+
+ if (columnheaders_visible == true) {
+ invalidate.Y -= grid_drawing.ColumnsHeadersArea.Height;
+ invalidate.Height += grid_drawing.ColumnsHeadersArea.Height;
+ }
+
+ XplatUI.ScrollWindow (Handle, grid_drawing.CellsArea, -pixels, 0, false);
+ Invalidate (invalidate_column);
+ Invalidate (invalidate);
+
+
+ } else {
+ int pixels = horz_pixeloffset - pixel;
+ Rectangle area = grid_drawing.CellsArea;
+
+ horz_pixeloffset = horiz_scrollbar.Value = pixel;
+ grid_drawing.UpdateVisibleColumn ();
+
+ // Columns header
+ invalidate_column.X = grid_drawing.ColumnsHeadersArea.X;
+ invalidate_column.Y = grid_drawing.ColumnsHeadersArea.Y;
+ invalidate_column.Width = pixels;
+ invalidate_column.Height = grid_drawing.ColumnsHeadersArea.Height;
+ //XplatUI.ScrollWindow (Handle, grid_drawing.ColumnsHeadersArea, pixels, 0, false);
+
+ // Cells
+ invalidate.X = grid_drawing.CellsArea.X;
+ invalidate.Y = grid_drawing.CellsArea.Y;
+ invalidate.Width = pixels;
+ invalidate.Height = grid_drawing.CellsArea.Height;
+
+ if (columnheaders_visible == true) {
+ invalidate.Y -= grid_drawing.ColumnsHeadersArea.Height;
+ invalidate.Height += grid_drawing.ColumnsHeadersArea.Height;
+ area.Y -= grid_drawing.ColumnsHeadersArea.Height;
+ area.Height += grid_drawing.ColumnsHeadersArea.Height;
+ }
+
+ XplatUI.ScrollWindow (Handle, area, pixels, 0, false);
+ Invalidate (invalidate);
+ }
+
+ }
+
+ private void ScrollToRow (int old_row, int new_row)
+ {
+ Rectangle invalidate = new Rectangle ();
+
+ if (new_row > old_row) { // Scrolldown
+ int scrolled_rows = new_row - old_row;
+ int pixels = scrolled_rows * RowHeight;
+ Rectangle rows_area = grid_drawing.CellsArea; // Cells area - partial rows space
+ rows_area.Height = grid_drawing.CellsArea.Height - grid_drawing.CellsArea.Height % RowHeight;
+
+ invalidate.X = grid_drawing.CellsArea.X;
+ invalidate.Y = grid_drawing.CellsArea.Y + rows_area.Height - pixels;
+ invalidate.Width = grid_drawing.CellsArea.Width;
+ invalidate.Height = pixels;
+
+ XplatUI.ScrollWindow (Handle, rows_area, 0, -pixels, false);
+
+ } else { // ScrollUp
+ int scrolled_rows = old_row - new_row;
+ int pixels = scrolled_rows * RowHeight;
+
+ invalidate.X = grid_drawing.CellsArea.X;
+ invalidate.Y = grid_drawing.CellsArea.Y;
+ invalidate.Width = grid_drawing.CellsArea.Width;
+ invalidate.Height = pixels;
+ XplatUI.ScrollWindow (Handle, grid_drawing.CellsArea, 0, pixels, false);
+ }
+
+ // Right now we use ScrollWindow Invalidate, let's leave remarked it here for X11 if need it
+ //Invalidate (invalidate);
+ Invalidate (grid_drawing.RowsHeadersArea);
+ }
+
+ #endregion Private Instance Methods
+
+
+ #region Events
+ public event EventHandler AllowNavigationChanged;
+ public event EventHandler BackButtonClick;
+ public event EventHandler BackgroundColorChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler BackgroundImageChanged;
+
+ public event EventHandler BorderStyleChanged;
+ public event EventHandler CaptionVisibleChanged;
+ public event EventHandler CurrentCellChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler CursorChanged;
+
+ public event EventHandler DataSourceChanged;
+ public event EventHandler FlatModeChanged;
+ public event NavigateEventHandler Navigate;
+ public event EventHandler ParentRowsLabelStyleChanged;
+ public event EventHandler ParentRowsVisibleChanged;
+ public event EventHandler ReadOnlyChanged;
+ protected event EventHandler RowHeaderClick;
+ public event EventHandler Scroll;
+ public event EventHandler ShowParentDetailsButtonClick;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler TextChanged;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridBoolColumn.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridBoolColumn.cs
new file mode 100644
index 00000000000..06358d1202b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridBoolColumn.cs
@@ -0,0 +1,384 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+// NOT COMPLETE
+
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Diagnostics;
+using System.Collections;
+
+namespace System.Windows.Forms
+{
+ public class DataGridBoolColumn : DataGridColumnStyle
+ {
+ [Flags]
+ private enum CheckState {
+ Checked = 0x00000001,
+ UnChecked = 0x00000002,
+ Null = 0x00000004,
+ Selected = 0x00000008
+ }
+
+ #region Local Variables
+ private bool allownull;
+ private object falsevalue;
+ private object nullvalue;
+ private object truevalue;
+ private Hashtable checkboxes_state;
+ #endregion // Local Variables
+
+ #region Constructors
+ public DataGridBoolColumn () : base ()
+ {
+ CommonConstructor ();
+ }
+
+ public DataGridBoolColumn (PropertyDescriptor prop) : base (prop)
+ {
+ CommonConstructor ();
+ }
+
+ public DataGridBoolColumn (PropertyDescriptor prop, bool isDefault) : base (prop)
+ {
+ CommonConstructor ();
+ is_default = isDefault;
+ }
+
+ private void CommonConstructor ()
+ {
+ allownull = true;
+ falsevalue = false;
+ nullvalue = null;
+ truevalue = true;
+ checkboxes_state = new Hashtable ();
+ }
+
+ #endregion
+
+ #region Public Instance Properties
+ [DefaultValue(true)]
+ public bool AllowNull {
+ get {
+ return allownull;
+ }
+ set {
+ if (value != allownull) {
+ allownull = value;
+
+ if (AllowNullChanged != null) {
+ AllowNullChanged (this, EventArgs.Empty);
+ }
+ }
+ }
+ }
+
+ [TypeConverter(typeof(System.ComponentModel.StringConverter))]
+ public object FalseValue {
+ get {
+ return falsevalue;
+ }
+ set {
+ if (value != falsevalue) {
+ falsevalue = value;
+
+ if (FalseValueChanged != null) {
+ FalseValueChanged (this, EventArgs.Empty);
+ }
+ }
+ }
+ }
+
+ [TypeConverter(typeof(System.ComponentModel.StringConverter))]
+ public object NullValue {
+ get {
+ return nullvalue;
+ }
+ set {
+ if (value != nullvalue) {
+ nullvalue = value;
+ }
+ }
+ }
+
+ [TypeConverter(typeof(System.ComponentModel.StringConverter))]
+ public object TrueValue {
+ get {
+ return truevalue;
+ }
+ set {
+ if (value != truevalue) {
+ truevalue = value;
+
+ if (TrueValueChanged != null) {
+ TrueValueChanged (this, EventArgs.Empty);
+ }
+ }
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ protected internal override void Abort (int rowNum)
+ {
+ SetState (rowNum, GetState (null, rowNum) & ~CheckState.Selected);
+ grid.Invalidate (grid.GetCurrentCellBounds ());
+ }
+
+ protected internal override bool Commit (CurrencyManager source, int rowNum)
+ {
+ SetColumnValueAtRow (source, rowNum, FromStateToValue (GetState (source, rowNum)));
+ SetState (rowNum, GetState (source, rowNum) & ~CheckState.Selected);
+ grid.Invalidate (grid.GetCurrentCellBounds ());
+ return true;
+ }
+
+ [MonoTODO]
+ protected internal override void ConcedeFocus ()
+ {
+
+ }
+
+ protected internal override void Edit (CurrencyManager source, int rowNum, Rectangle bounds, bool readOnly, string instantText, bool cellIsVisible)
+ {
+ SetState (rowNum, GetState (source, rowNum) | CheckState.Selected);
+ grid.Invalidate (grid.GetCurrentCellBounds ());
+ }
+
+ [MonoTODO]
+ protected internal override void EnterNullValue ()
+ {
+
+ }
+
+ protected internal override object GetColumnValueAtRow (CurrencyManager lm, int row)
+ {
+ object obj = base.GetColumnValueAtRow (lm, row);
+
+ if (obj.Equals (nullvalue)) {
+ return Convert.DBNull;
+ }
+
+ if (obj.Equals (truevalue)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ protected internal override int GetMinimumHeight ()
+ {
+ return ThemeEngine.Current.DataGridMinimumColumnCheckBoxHeight;
+ }
+
+ protected internal override int GetPreferredHeight (Graphics g, object value)
+ {
+ return ThemeEngine.Current.DataGridMinimumColumnCheckBoxHeight;
+ }
+
+ protected internal override Size GetPreferredSize (Graphics g, object value)
+ {
+ return new Size (ThemeEngine.Current.DataGridMinimumColumnCheckBoxWidth, ThemeEngine.Current.DataGridMinimumColumnCheckBoxHeight);
+ }
+
+ protected internal override void Paint (Graphics g, Rectangle bounds, CurrencyManager source, int rowNum)
+ {
+ Paint (g, bounds, source, rowNum, false);
+ }
+
+ protected internal override void Paint (Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, bool alignToRight)
+ {
+ Paint (g, bounds, source, rowNum, ThemeEngine.Current.ResPool.GetSolidBrush (DataGridTableStyle.BackColor),
+ ThemeEngine.Current.ResPool.GetSolidBrush (DataGridTableStyle.ForeColor), alignToRight);
+ }
+
+ protected internal override void Paint (Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight)
+ {
+ Size chkbox_size = GetPreferredSize (g, null);
+ Rectangle rect = new Rectangle ();
+ ButtonState state;
+ chkbox_size.Width -= 2;
+ chkbox_size.Height -= 2;
+ rect.X = bounds.X + ((bounds.Width - chkbox_size.Width) / 2);
+ rect.Y = bounds.Y + ((bounds.Height - chkbox_size.Height) / 2);
+ rect.Width = chkbox_size.Width;
+ rect.Height = chkbox_size.Height;
+
+ // If the cell is selected
+ if ((GetState (source, rowNum) & CheckState.Selected) == CheckState.Selected) {
+ backBrush = ThemeEngine.Current.ResPool.GetSolidBrush (grid.SelectionBackColor);
+ }
+
+ g.FillRectangle (backBrush, bounds);
+
+ switch (GetState (source, rowNum) & ~CheckState.Selected) {
+ case CheckState.Checked:
+ state = ButtonState.Checked;
+ break;
+ case CheckState.Null:
+ state = ButtonState.Inactive;
+ break;
+ case CheckState.UnChecked:
+ default:
+ state = ButtonState.Normal;
+ break;
+ }
+
+ ThemeEngine.Current.CPDrawCheckBox (g, rect, state);
+ PaintGridLine (g, bounds);
+ }
+
+ protected internal override void SetColumnValueAtRow (CurrencyManager lm, int row, object obj)
+ {
+ object value = null;
+
+ if (obj.Equals (nullvalue)) {
+ value = Convert.DBNull;
+ } else {
+ if (obj.Equals (truevalue)) {
+ value = true;
+ }
+ }
+
+ base.SetColumnValueAtRow (lm, row, value);
+ }
+ #endregion // Public Instance Methods
+
+ #region Private Instance Methods
+ internal static bool CanRenderType (Type type)
+ {
+ return (type == typeof (Boolean));
+ }
+
+ private object FromStateToValue (CheckState state)
+ {
+ state = state & ~CheckState.Selected;
+
+ if ((state & CheckState.Checked) == CheckState.Checked) {
+ return truevalue;
+ }
+
+ if ((state & CheckState.Null) == CheckState.Null) {
+ return nullvalue;
+ }
+
+ return falsevalue;
+ }
+
+ private CheckState FromValueToState (object obj)
+ {
+ if (obj.Equals (truevalue)) {
+ return CheckState.Checked;
+ }
+
+ if (obj.Equals (nullvalue)) {
+ return CheckState.Null;
+ }
+
+ return CheckState.UnChecked;
+ }
+
+ private CheckState GetState (CurrencyManager source, int row)
+ {
+ CheckState state;
+
+ if (checkboxes_state[row] == null) {
+ object value = GetColumnValueAtRow (source, row);
+ state = FromValueToState (value);
+ checkboxes_state.Add (row, state);
+ } else {
+ state = (CheckState) checkboxes_state[row];
+ }
+
+ return state;
+ }
+
+ private CheckState GetNextState (CheckState state)
+ {
+ CheckState new_state;
+ bool selected = ((state & CheckState.Selected) == CheckState.Selected);
+
+ switch (state & ~CheckState.Selected) {
+ case CheckState.Checked:
+ new_state = CheckState.Null;
+ break;
+ case CheckState.Null:
+ new_state = CheckState.UnChecked;
+ break;
+ case CheckState.UnChecked:
+ default:
+ new_state = CheckState.Checked;
+ break;
+ }
+
+ if (selected) {
+ new_state = new_state | CheckState.Selected;
+ }
+
+ return new_state;
+ }
+
+ internal override void OnKeyDown (KeyEventArgs ke, int row, int column)
+ {
+ CheckState state = GetNextState (GetState (null, row));
+
+ if (ke.KeyCode == Keys.Space) {
+ grid.is_changing = true;
+ grid.InvalidateCurrentRowHeader ();
+ checkboxes_state[row] = state;
+ grid.Invalidate (grid.GetCellBounds (row, column));
+ }
+ }
+
+ internal override void OnMouseDown (MouseEventArgs e, int row, int column)
+ {
+ CheckState state = GetNextState (GetState (null, row));
+
+ grid.is_changing = true;
+ grid.InvalidateCurrentRowHeader ();
+ SetState (row, state);
+ grid.Invalidate (grid.GetCellBounds (row, column));
+ }
+
+ private void SetState (int row, CheckState state)
+ {
+ if (checkboxes_state[row] == null) {
+ checkboxes_state.Add (row, state);
+ } else {
+ checkboxes_state[row] = state;
+ }
+ }
+
+ #endregion Private Instance Methods
+
+ #region Events
+ public event EventHandler AllowNullChanged;
+ public event EventHandler FalseValueChanged;
+ public event EventHandler TrueValueChanged;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridCell.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridCell.cs
new file mode 100644
index 00000000000..5249b6e5743
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridCell.cs
@@ -0,0 +1,85 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Diagnostics;
+
+namespace System.Windows.Forms
+{
+ public struct DataGridCell
+ {
+ #region Local Variables
+ private int row;
+ private int column;
+ #endregion // Local Variables
+
+ #region Constructors
+ public DataGridCell (int r, int c)
+ {
+ row = r;
+ column = c;
+ }
+ #endregion
+
+ #region Public Instance Properties
+ public int ColumnNumber {
+ get { return column; }
+ set { column = value; }
+ }
+
+ public int RowNumber {
+ get { return row; }
+ set { row = value; }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public override bool Equals (object o)
+ {
+ if (!(o is DataGridCell))
+ return false;
+
+ DataGridCell obj = (DataGridCell) o;
+ return (obj.ColumnNumber == column && obj.RowNumber == row);
+
+ }
+
+ public override int GetHashCode ()
+ {
+ return row ^ column;
+ }
+
+ public override string ToString ()
+ {
+ return "DataGridCell {RowNumber = " + row +", ColumnNumber = " + column + "}";
+ }
+
+ #endregion // Public Instance Methods
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridColumnStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridColumnStyle.cs
new file mode 100644
index 00000000000..a2993173201
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridColumnStyle.cs
@@ -0,0 +1,602 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+// NOT COMPLETE
+
+using System.Drawing;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using System.Diagnostics;
+
+namespace System.Windows.Forms
+{
+ [DesignTimeVisible(false)]
+ [DefaultProperty("Header")]
+ [ToolboxItem(false)]
+ public abstract class DataGridColumnStyle : Component, IDataGridColumnStyleEditingNotificationService
+ {
+ [ComVisible(true)]
+ protected class DataGridColumnHeaderAccessibleObject : AccessibleObject
+ {
+ #region Local Variables
+ private DataGridColumnStyle owner;
+ #endregion
+
+ #region Constructors
+ public DataGridColumnHeaderAccessibleObject (DataGridColumnStyle columnstyle)
+ {
+ owner = columnstyle;
+ }
+ #endregion //Constructors
+
+ #region Public Instance Properties
+ [MonoTODO]
+ public override Rectangle Bounds {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public override string Name {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ protected DataGridColumnStyle Owner {
+ get { return owner; }
+ }
+
+ public override AccessibleObject Parent {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public override AccessibleRole Role {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+ #endregion
+
+ #region Public Instance Methods
+ [MonoTODO]
+ public override AccessibleObject Navigate (AccessibleNavigation navdir)
+ {
+ throw new NotImplementedException ();
+ }
+ #endregion Public Instance Methods
+ }
+
+ protected class CompModSwitches
+ {
+ public CompModSwitches ()
+ {
+ }
+
+ #region Public Instance Methods
+ [MonoTODO]
+ public static TraceSwitch DGEditColumnEditing {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+ #endregion Public Instance Methods
+ }
+
+ internal enum ArrowDrawing
+ {
+ No = 0,
+ Ascending = 1,
+ Descending = 2
+ }
+
+ #region Local Variables
+ internal HorizontalAlignment alignment;
+ private int fontheight;
+ internal DataGridTableStyle table_style;
+ private string header_text;
+ private string mapping_name;
+ private string null_text;
+ private PropertyDescriptor property_descriptor;
+ private bool _readonly;
+ private int width;
+ internal bool is_default;
+ internal DataGrid grid;
+ private DataGridColumnHeaderAccessibleObject accesible_object;
+ private StringFormat string_format_hdr;
+ static string def_null_text = "(null)";
+ private ArrowDrawing arrow_drawing = ArrowDrawing.No;
+ #endregion // Local Variables
+
+ #region Constructors
+ public DataGridColumnStyle ()
+ {
+ CommmonConstructor ();
+ property_descriptor = null;
+ }
+
+ public DataGridColumnStyle (PropertyDescriptor prop)
+ {
+ CommmonConstructor ();
+ property_descriptor = prop;
+ }
+
+ private void CommmonConstructor ()
+ {
+ fontheight = -1;
+ table_style = null;
+ header_text = string.Empty;
+ mapping_name = string.Empty;
+ null_text = def_null_text;
+ accesible_object = new DataGridColumnHeaderAccessibleObject (this);
+ _readonly = false;
+ width = -1;
+ grid = null;
+ is_default = false;
+ alignment = HorizontalAlignment.Left;
+ string_format_hdr = new StringFormat ();
+ string_format_hdr.FormatFlags |= StringFormatFlags.NoWrap;
+ string_format_hdr.LineAlignment = StringAlignment.Center;
+ }
+
+ #endregion
+
+ #region Public Instance Properties
+ [Localizable(true)]
+ [DefaultValue(HorizontalAlignment.Left)]
+ public virtual HorizontalAlignment Alignment {
+ get {
+ return alignment;
+ }
+ set {
+ if (value != alignment) {
+ alignment = value;
+
+ if (table_style != null && table_style.DataGrid != null) {
+ table_style.DataGrid.Invalidate ();
+ }
+
+ if (AlignmentChanged != null) {
+ AlignmentChanged (this, EventArgs.Empty);
+ }
+ }
+ }
+ }
+
+ [Browsable(false)]
+ public virtual DataGridTableStyle DataGridTableStyle {
+ get {
+ return table_style;
+ }
+ }
+
+ protected int FontHeight {
+ get {
+ if (fontheight != -1) {
+ return fontheight;
+ }
+
+ if (table_style != null) {
+ //return table_style.DataGrid.FontHeight
+ return -1;
+ }
+
+ // TODO: Default Datagrid font height
+ return -1;
+ }
+ }
+
+ [Browsable(false)]
+ public AccessibleObject HeaderAccessibleObject {
+ get {
+ return accesible_object;
+ }
+ }
+
+ [Localizable(true)]
+ public virtual string HeaderText {
+ get {
+ return header_text;
+ }
+ set {
+ if (value != header_text) {
+ header_text = value;
+
+ if (table_style != null && table_style.DataGrid != null) {
+ table_style.DataGrid.Invalidate ();
+ }
+
+ if (HeaderTextChanged != null) {
+ HeaderTextChanged (this, EventArgs.Empty);
+ }
+ }
+ }
+ }
+
+ [Editor("System.Windows.Forms.Design.DataGridColumnStyleMappingNameEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
+ [Localizable(true)]
+ public string MappingName {
+ get {
+ return mapping_name;
+ }
+ set {
+ if (value != mapping_name) {
+ mapping_name = value;
+
+ if (MappingNameChanged != null) {
+ MappingNameChanged (this, EventArgs.Empty);
+ }
+ }
+ }
+ }
+
+ [Localizable(true)]
+ public virtual string NullText {
+ get {
+ return null_text;
+ }
+ set {
+ if (value != null_text) {
+ null_text = value;
+
+ if (table_style != null && table_style.DataGrid != null) {
+ table_style.DataGrid.Invalidate ();
+ }
+
+ if (NullTextChanged != null) {
+ NullTextChanged (this, EventArgs.Empty);
+ }
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DefaultValue(null)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public virtual PropertyDescriptor PropertyDescriptor {
+ get {
+ return property_descriptor;
+ }
+ set {
+ if (value != property_descriptor) {
+ property_descriptor = value;
+
+ if (PropertyDescriptorChanged != null) {
+ PropertyDescriptorChanged (this, EventArgs.Empty);
+ }
+ }
+ }
+ }
+
+ [DefaultValue(false)]
+ public virtual bool ReadOnly {
+ get {
+ return _readonly;
+ }
+ set {
+ if (value != _readonly) {
+ _readonly = value;
+
+ if (table_style != null && table_style.DataGrid != null) {
+ table_style.DataGrid.CalcAreasAndInvalidate ();
+ }
+
+ if (ReadOnlyChanged != null) {
+ ReadOnlyChanged (this, EventArgs.Empty);
+ }
+ }
+ }
+ }
+
+ [DefaultValue(100)]
+ [Localizable(true)]
+ public virtual int Width {
+ get {
+ return width;
+ }
+ set {
+ if (value != width) {
+ width = value;
+
+ if (table_style != null && table_style.DataGrid != null) {
+ table_style.DataGrid.CalcAreasAndInvalidate ();
+ }
+
+ if (WidthChanged != null) {
+ WidthChanged (this, EventArgs.Empty);
+ }
+ }
+ }
+ }
+
+ #endregion // Public Instance Properties
+
+ #region Private Instance Properties
+
+ internal ArrowDrawing ArrowDrawingMode {
+ get { return arrow_drawing; }
+ set { arrow_drawing = value; }
+ }
+
+ // The logic seems to be that:
+ // - If DataGrid.ReadOnly is true all the tables and columns are readonly ignoring other settings
+ // - If DataGridTableStyle.ReadOnly is true all columns are readonly ignoring other settings
+ // - If DataGrid.ReadOnly and DataGridTableStyle.ReadOnly are false, the columns settings are mandatory
+ //
+ internal bool ParentReadOnly {
+ get {
+ if (grid != null) {
+ if (grid.ReadOnly == true) {
+ return true;
+ }
+
+ if (grid.ListManager != null && grid.ListManager.CanAddRows == false) {
+ return true;
+ }
+ }
+
+ if (table_style != null) {
+ if (table_style.ReadOnly == true) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }
+
+ internal DataGridTableStyle TableStyle {
+ set { table_style = value; }
+ }
+
+ internal bool IsDefault {
+ get { return is_default; }
+ }
+ #endregion Private Instance Properties
+
+ #region Public Instance Methods
+ protected internal abstract void Abort (int rowNum);
+
+ [MonoTODO]
+ protected void BeginUpdate ()
+ {
+
+ }
+
+ protected void CheckValidDataSource (CurrencyManager value)
+ {
+ if (value == null) {
+ throw new ArgumentNullException ("CurrencyManager cannot be null");
+ }
+
+ if (property_descriptor == null) {
+ throw new ApplicationException ("The PropertyDescriptor for this column is a null reference");
+ }
+ }
+
+ [MonoTODO]
+ protected internal virtual void ColumnStartedEditing (Control editingControl)
+ {
+
+ }
+
+ protected internal abstract bool Commit (CurrencyManager dataSource, int rowNum);
+
+
+ protected internal virtual void ConcedeFocus ()
+ {
+
+ }
+
+ protected virtual AccessibleObject CreateHeaderAccessibleObject ()
+ {
+ return new DataGridColumnHeaderAccessibleObject (this);
+ }
+
+ protected internal virtual void Edit (CurrencyManager source, int rowNum, Rectangle bounds, bool readOnly)
+ {
+ Edit (source, rowNum, bounds, readOnly, string.Empty);
+ }
+
+ protected internal virtual void Edit (CurrencyManager source, int rowNum, Rectangle bounds, bool readOnly, string instantText)
+ {
+ Edit (source, rowNum, bounds, readOnly, instantText, true);
+ }
+
+ protected internal abstract void Edit (CurrencyManager source, int rowNum, Rectangle bounds, bool readOnly, string instantText, bool cellIsVisible);
+
+
+ [MonoTODO]
+ protected void EndUpdate ()
+ {
+
+ }
+
+ protected internal virtual void EnterNullValue () {}
+
+ protected internal virtual object GetColumnValueAtRow (CurrencyManager source, int rowNum)
+ {
+ CheckValidDataSource (source);
+ return property_descriptor.GetValue (source.GetItem (rowNum));
+ }
+
+ protected internal abstract int GetMinimumHeight ();
+
+ protected internal abstract int GetPreferredHeight (Graphics g, object value);
+
+ protected internal abstract Size GetPreferredSize (Graphics g, object value);
+
+ void IDataGridColumnStyleEditingNotificationService.ColumnStartedEditing (Control editingControl)
+ {
+
+ }
+
+ protected virtual void Invalidate ()
+ {
+ grid.grid_drawing.InvalidateColumn (this);
+ }
+
+ protected internal abstract void Paint (Graphics g, Rectangle bounds, CurrencyManager source, int rowNum);
+ protected internal abstract void Paint (Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, bool alignToRight);
+
+ protected internal virtual void Paint (Graphics g, Rectangle bounds, CurrencyManager source, int rowNum,
+ Brush backBrush, Brush foreBrush, bool alignToRight) {}
+
+ protected internal virtual void ReleaseHostedControl () {}
+
+ public void ResetHeaderText ()
+ {
+ HeaderText = string.Empty;
+ }
+
+ protected internal virtual void SetColumnValueAtRow (CurrencyManager source, int rowNum, object value)
+ {
+ CheckValidDataSource (source);
+ property_descriptor.SetValue (source.GetItem (rowNum), value);
+ }
+
+ protected virtual void SetDataGrid (DataGrid value)
+ {
+ grid = value;
+
+ if (property_descriptor != null || value == null || value.ListManager == null) {
+ return;
+ }
+
+ PropertyDescriptorCollection propcol = value.ListManager.GetItemProperties ();
+ for (int i = 0; i < propcol.Count ; i++) {
+ if (propcol[i].Name == mapping_name) {
+ property_descriptor = propcol[i];
+ break;
+ }
+ }
+ }
+
+ protected virtual void SetDataGridInColumn (DataGrid value)
+ {
+ SetDataGrid (value);
+ }
+
+ internal void SetDataGridInternal (DataGrid value)
+ {
+ SetDataGridInColumn (value);
+ }
+
+ protected internal virtual void UpdateUI (CurrencyManager source, int rowNum, string instantText)
+ {
+
+ }
+ #endregion // Public Instance Methods
+
+ #region Private Instance Methods
+ virtual internal void OnMouseDown (MouseEventArgs e, int row, int column) {}
+ virtual internal void OnKeyDown (KeyEventArgs ke, int row, int column) {}
+
+ internal void PaintHeader (Graphics g, Rectangle bounds, int colNum)
+ {
+ // Background
+ g.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (DataGridTableStyle.CurrentHeaderBackColor),
+ bounds);
+
+ if (grid.FlatMode == false) {
+
+ // Paint Borders
+ g.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlLight),
+ bounds.X, bounds.Y, bounds.X + bounds.Width, bounds.Y);
+
+ if (colNum == 0) {
+ g.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlLight),
+ bounds.X, bounds.Y, bounds.X, bounds.Y + bounds.Height);
+ } else {
+ g.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlLight),
+ bounds.X, bounds.Y + 2, bounds.X, bounds.Y + bounds.Height - 2);
+ }
+
+ g.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlDark),
+ bounds.X + bounds.Width - 1, bounds.Y + 2 , bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 2);
+ }
+
+ bounds.X += 2;
+ bounds.Width -= 2;
+ g.DrawString (HeaderText, DataGridTableStyle.HeaderFont, ThemeEngine.Current.ResPool.GetSolidBrush (DataGridTableStyle.CurrentHeaderForeColor),
+ bounds, string_format_hdr);
+
+ if (arrow_drawing != ArrowDrawing.No) {
+ // Draw 6 x 6
+ Point pnt = new Point (bounds.X + bounds.Width - 12, bounds.Y + ((bounds.Height - 6)/2));
+
+ if (arrow_drawing == ArrowDrawing.Ascending) {
+ g.DrawLine (SystemPens.ControlLightLight, pnt.X + 6, pnt.Y + 6, pnt.X + 3, pnt.Y);
+ g.DrawLine (SystemPens.ControlDark, pnt.X, pnt.Y + 6, pnt.X + 6, pnt.Y + 6);
+ g.DrawLine (SystemPens.ControlDark, pnt.X, pnt.Y + 6, pnt.X + 3, pnt.Y);
+ } else {
+ g.DrawLine (SystemPens.ControlLightLight, pnt.X + 6, pnt.Y, pnt.X + 3, pnt.Y + 6);
+ g.DrawLine (SystemPens.ControlDark, pnt.X, pnt.Y, pnt.X + 6, pnt.Y);
+ g.DrawLine (SystemPens.ControlDark, pnt.X, pnt.Y, pnt.X + 3, pnt.Y + 6);
+ }
+
+ }
+ }
+
+ internal void PaintNewRow (Graphics g, Rectangle bounds, Brush backBrush, Brush foreBrush)
+ {
+ g.FillRectangle (backBrush, bounds);
+ PaintGridLine (g, bounds);
+ }
+
+ internal void PaintGridLine (Graphics g, Rectangle bounds)
+ {
+ if (table_style.CurrentGridLineStyle != DataGridLineStyle.Solid) {
+ return;
+ }
+
+ g.DrawLine (ThemeEngine.Current.ResPool.GetPen (table_style.CurrentGridLineColor),
+ bounds.X, bounds.Y + bounds.Height - 1, bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
+
+ g.DrawLine (ThemeEngine.Current.ResPool.GetPen (table_style.CurrentGridLineColor),
+ bounds.X + bounds.Width - 1, bounds.Y , bounds.X + bounds.Width - 1, bounds.Y + bounds.Height);
+ }
+
+ #endregion Private Instance Methods
+
+
+ #region Events
+ public event EventHandler AlignmentChanged;
+ public event EventHandler FontChanged;
+ public event EventHandler HeaderTextChanged;
+ public event EventHandler MappingNameChanged;
+ public event EventHandler NullTextChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public event EventHandler PropertyDescriptorChanged;
+ public event EventHandler ReadOnlyChanged;
+ public event EventHandler WidthChanged;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridDrawingLogic.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridDrawingLogic.cs
new file mode 100644
index 00000000000..d568cacad5b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridDrawingLogic.cs
@@ -0,0 +1,617 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+// Datagrid drawing logic
+//
+
+// NOT COMPLETE
+
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+namespace System.Windows.Forms
+{
+ internal class DataGridDrawing
+ {
+ #region Local Variables
+
+ private DataGrid grid;
+
+ // Areas
+ internal Rectangle caption_area;
+ internal Rectangle parent_rows;
+ internal Rectangle columnshdrs_area; // Used columns header area
+ internal int columnshdrs_maxwidth; // Total width (max width) for columns headrs
+ internal Rectangle rowshdrs_area; // Used Headers rows area
+ internal int rowshdrs_maxheight; // Total height for rows (max height)
+ internal Rectangle cells_area;
+ internal Font font_newrow = new Font (FontFamily.GenericSansSerif, 16);
+ #endregion // Local Variables
+
+
+ public DataGridDrawing (DataGrid datagrid)
+ {
+ grid = datagrid;
+ }
+
+ #region Public Instance Methods
+
+ // Calc the max with of all columns
+ internal int CalcAllColumnsWidth ()
+ {
+ int width = 0;
+ int cnt = grid.CurrentTableStyle.GridColumnStyles.Count;
+
+ for (int col = 0; col < cnt; col++) {
+ width += grid.CurrentTableStyle.GridColumnStyles[col].Width;
+ }
+
+ return width;
+ }
+
+ // Gets a column from a pixel
+ public int FromPixelToColumn (int pixel)
+ {
+ int width = 0;
+ int cnt = grid.CurrentTableStyle.GridColumnStyles.Count;
+
+ if (cnt == 0)
+ return 0;
+
+ if (grid.CurrentTableStyle.CurrentRowHeadersVisible)
+ width += rowshdrs_area.X + rowshdrs_area.Width;
+
+ for (int col = 0; col < cnt; col++) {
+ width += grid.CurrentTableStyle.GridColumnStyles[col].Width;
+
+ if (pixel < width)
+ return col;
+ }
+
+ return cnt - 1;
+ }
+
+ //
+ public int GetColumnStartingPixel (int my_col)
+ {
+ int width = 0;
+ int cnt = grid.CurrentTableStyle.GridColumnStyles.Count;
+
+ for (int col = 0; col < cnt; col++) {
+
+ if (my_col == col)
+ return width;
+
+ width += grid.CurrentTableStyle.GridColumnStyles[col].Width;
+ }
+
+ return 0;
+ }
+
+ // Which column has to be the first visible column to ensure a column visibility
+ public int GetFirstColumnForColumnVisilibility (int current_first_visiblecolumn, int column)
+ {
+ int new_col = column;
+ int width = 0;
+
+ if (column > current_first_visiblecolumn) { // Going forward
+ for (new_col = column; new_col >= 0; new_col--){
+ width += grid.CurrentTableStyle.GridColumnStyles[new_col].Width;
+
+ if (width >= cells_area.Width)
+ return new_col + 1;
+ //return new_col < grid.CurrentTableStyle.GridColumnStyles.Count ? new_col + 1 : grid.CurrentTableStyle.GridColumnStyles.Count;
+ }
+ return 0;
+ } else {
+ return column;
+ }
+ }
+
+ public void CalcGridAreas ()
+ {
+ if (grid.IsHandleCreated == false) // Delay calculations until the handle is created
+ return;
+
+ /* Order is important. E.g. row headers max. height depends on caption */
+ grid.horz_pixeloffset = 0;
+ CalcCaption ();
+ CalcParentRows ();
+ CalcRowsHeaders ();
+ CalcColumnsHeader ();
+ CalcCellsArea ();
+
+ UpdateVisibleRowCount (); // need it to be able to calcultate the need of horz scrollbar
+ if (SetUpVerticalScrollBar ()) { // We need a Vertical ScrollBar
+
+ if (grid.ShowParentRowsVisible) {
+ parent_rows.Width -= grid.vert_scrollbar.Width;
+ }
+
+ if (grid.columnheaders_visible == false || grid.CurrentTableStyle.GridColumnStyles.Count == 0) {
+ if (columnshdrs_area.X + columnshdrs_area.Width > grid.vert_scrollbar.Location.X) {
+ columnshdrs_area.Width -= grid.vert_scrollbar.Width;
+ }
+ }
+
+ if (cells_area.X + cells_area.Width >= grid.vert_scrollbar.Location.X) {
+ cells_area.Width -= grid.vert_scrollbar.Width;
+ }
+ }
+
+ if (SetUpHorizontalScrollBar ()) { // We need a Horizontal ScrollBar
+ cells_area.Height -= grid.horiz_scrollbar.Height;
+
+ if (rowshdrs_area.Y + rowshdrs_area.Height > grid.ClientRectangle.Y + grid.ClientRectangle.Height) {
+ rowshdrs_area.Height -= grid.horiz_scrollbar.Height;
+ rowshdrs_maxheight -= grid.horiz_scrollbar.Height;
+ }
+ }
+
+ // Reajust scrollbars to avoid overlapping at the corners
+ if (grid.vert_scrollbar.Visible && grid.horiz_scrollbar.Visible) {
+ grid.horiz_scrollbar.Width -= grid.vert_scrollbar.Width;
+ grid.vert_scrollbar.Height -= grid.horiz_scrollbar.Height;
+ }
+
+ UpdateVisibleColumn ();
+ UpdateVisibleRowCount ();
+
+ //Console.WriteLine ("DataGridDrawing.CalcGridAreas caption_area:{0}", caption_area);
+ //Console.WriteLine ("DataGridDrawing.CalcGridAreas parent_rows:{0}", parent_rows);
+ //Console.WriteLine ("DataGridDrawing.CalcGridAreas rowshdrs_area:{0}", rowshdrs_area);
+ //Console.WriteLine ("DataGridDrawing.CalcGridAreas columnshdrs_area:{0}", columnshdrs_area);
+ //Console.WriteLine ("DataGridDrawing.CalcGridAreas cells:{0}", cells_area);
+ }
+
+ public void CalcCaption ()
+ {
+ if (grid.caption_visible == false) {
+ caption_area = Rectangle.Empty;
+ return;
+ }
+
+ caption_area.X = grid.ClientRectangle.X;
+ caption_area.Y = grid.ClientRectangle.Y;
+ caption_area.Width = grid.ClientRectangle.Width;
+ caption_area.Height = grid.CaptionFont.Height + 6;
+
+ //Console.WriteLine ("DataGridDrawing.CalcCaption {0}", caption_area);
+ }
+
+ public void CalcCellsArea ()
+ {
+ if (grid.caption_visible) {
+ cells_area.Y = caption_area.Y + caption_area.Height;
+ } else {
+ cells_area.Y = grid.ClientRectangle.Y;
+ }
+
+ if (grid.ShowParentRowsVisible) {
+ cells_area.Y += parent_rows.Height;
+ }
+
+ if (!(grid.columnheaders_visible == false || grid.CurrentTableStyle.GridColumnStyles.Count == 0)) {
+ cells_area.Y += columnshdrs_area.Height;
+ }
+
+ cells_area.X = grid.ClientRectangle.X + rowshdrs_area.Width;
+ cells_area.Width = grid.ClientRectangle.X + grid.ClientRectangle.Width - cells_area.X;
+ cells_area.Height = grid.ClientRectangle.Y + grid.ClientRectangle.Height - cells_area.Y;
+
+ //Console.WriteLine ("DataGridDrawing.CalcCellsArea {0}", cells_area);
+ }
+
+ public void CalcColumnsHeader ()
+ {
+ int width_all_cols, max_width_cols;
+
+ if (grid.columnheaders_visible == false || grid.CurrentTableStyle.GridColumnStyles.Count == 0) {
+ columnshdrs_area = Rectangle.Empty;
+ return;
+ }
+
+ if (grid.caption_visible) {
+ columnshdrs_area.Y = caption_area.Y + caption_area.Height;
+ } else {
+ columnshdrs_area.Y = grid.ClientRectangle.Y;
+ }
+
+ if (grid.ShowParentRowsVisible) {
+ columnshdrs_area.Y += parent_rows.Height;
+ }
+
+ columnshdrs_area.X = grid.ClientRectangle.X;
+ columnshdrs_area.Height = ColumnsHeaderHeight;
+ width_all_cols = CalcAllColumnsWidth ();
+
+ // TODO: take into account Scrollbars
+ columnshdrs_maxwidth = grid.ClientRectangle.X + grid.ClientRectangle.Width - columnshdrs_area.X;
+ max_width_cols = columnshdrs_maxwidth;
+
+ if (grid.CurrentTableStyle.CurrentRowHeadersVisible) {
+ max_width_cols -= grid.RowHeaderWidth;
+ }
+
+ if (width_all_cols > max_width_cols) {
+ columnshdrs_area.Width = columnshdrs_maxwidth;
+ } else {
+ columnshdrs_area.Width = width_all_cols;
+
+ if (grid.CurrentTableStyle.CurrentRowHeadersVisible) {
+ columnshdrs_area.Width += grid.RowHeaderWidth;
+ }
+ }
+
+ //Console.WriteLine ("DataGridDrawing.CalcColumnsHeader {0}", columnshdrs_area);
+ }
+
+ public void CalcParentRows ()
+ {
+ if (grid.ShowParentRowsVisible == false) {
+ parent_rows = Rectangle.Empty;
+ return;
+ }
+
+ if (grid.caption_visible) {
+ parent_rows.Y = caption_area.Y + caption_area.Height;
+
+ } else {
+ parent_rows.Y = grid.ClientRectangle.Y;
+ }
+
+ parent_rows.X = grid.ClientRectangle.X;
+ parent_rows.Width = grid.ClientRectangle.Width;
+ parent_rows.Height = grid.CaptionFont.Height + 3;
+
+ //Console.WriteLine ("DataGridDrawing.CalcParentRows {0}", parent_rows);
+ }
+
+ public void CalcRowsHeaders ()
+ {
+ if (grid.CurrentTableStyle.CurrentRowHeadersVisible == false) {
+ rowshdrs_area = Rectangle.Empty;
+ return;
+ }
+
+ if (grid.caption_visible) {
+ rowshdrs_area.Y = caption_area.Y + caption_area.Height;
+ } else {
+ rowshdrs_area.Y = grid.ClientRectangle.Y;
+ }
+
+ if (grid.ShowParentRowsVisible) {
+ rowshdrs_area.Y += parent_rows.Height;
+ }
+
+ if (!(grid.columnheaders_visible == false || grid.CurrentTableStyle.GridColumnStyles.Count == 0)) { // first block is painted by ColumnHeader
+ rowshdrs_area.Y += ColumnsHeaderHeight;
+ }
+
+ rowshdrs_area.X = grid.ClientRectangle.X;
+ rowshdrs_area.Width = grid.RowHeaderWidth;
+ rowshdrs_area.Height = grid.visiblerow_count * grid.RowHeight;
+ rowshdrs_maxheight = grid.ClientRectangle.Height + grid.ClientRectangle.Y - rowshdrs_area.Y;
+
+ //Console.WriteLine ("DataGridDrawing.CalcRowsHeaders {0} {1}", rowshdrs_area,
+ // rowshdrs_maxheight);
+ }
+
+ public void UpdateVisibleColumn ()
+ {
+ if (grid.CurrentTableStyle.GridColumnStyles.Count == 0) {
+ grid.visiblecolumn_count = 0;
+ return;
+ }
+
+ int col;
+ int max_pixel = grid.horz_pixeloffset + cells_area.Width;
+ grid.first_visiblecolumn = FromPixelToColumn (grid.horz_pixeloffset);
+
+ col = FromPixelToColumn (max_pixel);
+
+ grid.visiblecolumn_count = 1 + col - grid.first_visiblecolumn;
+
+ if (grid.first_visiblecolumn + grid.visiblecolumn_count + 1 < grid.CurrentTableStyle.GridColumnStyles.Count) {
+ grid.visiblecolumn_count++; // Partially visible column
+ }
+ }
+
+ public void UpdateVisibleRowCount ()
+ {
+ int max_height = cells_area.Height;
+ int total_rows = grid.RowsCount;
+
+ if (grid.ShowEditRow && grid.RowsCount > 0) {
+ total_rows++;
+ }
+
+ int rows_height = (total_rows - grid.first_visiblerow) * grid.RowHeight;
+ int max_rows = max_height / grid.RowHeight;
+
+ if (max_rows > total_rows) {
+ max_rows = total_rows;
+ }
+
+ if (rows_height > cells_area.Height) {
+ grid.visiblerow_count = max_rows;
+ } else {
+ grid.visiblerow_count = total_rows;
+ }
+
+ CalcRowsHeaders (); // Height depends on num of visible rows
+
+ if (grid.visiblerow_count + grid.first_visiblerow > total_rows)
+ grid.visiblerow_count = total_rows - grid.first_visiblerow;
+
+ if (grid.visiblerow_count < max_rows) {
+ grid.visiblerow_count = max_rows;
+ grid.first_visiblerow = total_rows - max_rows;
+ grid.Invalidate ();
+ }
+
+ }
+
+ // From Point to Cell
+ public DataGrid.HitTestInfo HitTest (int x, int y)
+ {
+ DataGrid.HitTestInfo hit = new DataGrid.HitTestInfo ();
+
+ // TODO: Add missing ColumnResize and RowResize checks
+ if (columnshdrs_area.Contains (x, y)) {
+ hit.type = DataGrid.HitTestType.ColumnHeader;
+ hit.column = FromPixelToColumn (x + grid.horz_pixeloffset);
+ return hit;
+ }
+
+ if (rowshdrs_area.Contains (x, y)) {
+ hit.type = DataGrid.HitTestType.RowHeader;
+ int posy;
+ int rcnt = grid.FirstVisibleRow + grid.VisibleRowCount;
+ for (int r = grid.FirstVisibleRow; r < rcnt; r++) {
+ posy = cells_area.Y + ((r - grid.FirstVisibleRow) * grid.RowHeight);
+ if (y <= posy + grid.RowHeight) { // Found row
+ hit.row = r;
+ break;
+ }
+ }
+ return hit;
+ }
+
+ if (caption_area.Contains (x, y)) {
+ hit.type = DataGrid.HitTestType.Caption;
+ return hit;
+ }
+
+ if (parent_rows.Contains (x, y)) {
+ hit.type = DataGrid.HitTestType.ParentRows;
+ return hit;
+ }
+
+ int pos_y, pos_x, width;
+ int rowcnt = grid.FirstVisibleRow + grid.VisibleRowCount;
+ for (int row = grid.FirstVisibleRow; row < rowcnt; row++) {
+ pos_y = cells_area.Y + ((row - grid.FirstVisibleRow) * grid.RowHeight);
+
+ if (y <= pos_y + grid.RowHeight) { // Found row
+ hit.row = row;
+ hit.type = DataGrid.HitTestType.Cell;
+ int col_pixel;
+ int column_cnt = grid.first_visiblecolumn + grid.visiblecolumn_count;
+ for (int column = grid.first_visiblecolumn; column < column_cnt; column++) {
+
+ col_pixel = GetColumnStartingPixel (column);
+ pos_x = cells_area.X + col_pixel - grid.horz_pixeloffset;
+ width = grid.CurrentTableStyle.GridColumnStyles[column].Width;
+
+ if (x <= pos_x + width) { // Column found
+ hit.column = column;
+ break;
+ }
+ }
+
+ break;
+ }
+ }
+
+ return hit;
+ }
+
+ public Rectangle GetCellBounds (int row, int col)
+ {
+ Rectangle bounds = new Rectangle ();
+ int col_pixel;
+
+ bounds.Width = grid.CurrentTableStyle.GridColumnStyles[col].Width;
+ bounds.Height = grid.RowHeight;
+ bounds.Y = cells_area.Y + ((row - grid.FirstVisibleRow) * grid.RowHeight);
+ col_pixel = GetColumnStartingPixel (col);
+ bounds.X = cells_area.X + col_pixel - grid.horz_pixeloffset;
+ return bounds;
+ }
+
+ public void InvalidateCaption ()
+ {
+ if (caption_area.IsEmpty)
+ return;
+
+ grid.Invalidate (caption_area);
+ }
+
+
+ public void InvalidateRow (int row)
+ {
+ if (row < grid.FirstVisibleRow || row > grid.FirstVisibleRow + grid.VisibleRowCount) {
+ return;
+ }
+
+ Rectangle rect_row = new Rectangle ();
+
+ rect_row.X = cells_area.X;
+ rect_row.Width = cells_area.Width;
+ rect_row.Height = grid.RowHeight;
+ rect_row.Y = cells_area.Y + ((row - grid.FirstVisibleRow) * grid.RowHeight);
+ grid.Invalidate (rect_row);
+ }
+
+ public void InvalidateRowHeader (int row)
+ {
+ Rectangle rect_rowhdr = new Rectangle ();
+ rect_rowhdr.X = rowshdrs_area.X;
+ rect_rowhdr.Width = rowshdrs_area.Width;
+ rect_rowhdr.Height = grid.RowHeight;
+ rect_rowhdr.Y = rowshdrs_area.Y + ((row - grid.FirstVisibleRow) * grid.RowHeight);
+ grid.Invalidate (rect_rowhdr);
+ }
+
+ public void InvalidateColumn (DataGridColumnStyle column)
+ {
+ Rectangle rect_col = new Rectangle ();
+ int col_pixel;
+ int col = -1;
+
+ col = grid.CurrentTableStyle.GridColumnStyles.IndexOf (column);
+
+ if (col == -1) {
+ return;
+ }
+
+ rect_col.Width = column.Width;
+ col_pixel = GetColumnStartingPixel (col);
+ rect_col.X = cells_area.X + col_pixel - grid.horz_pixeloffset;
+ rect_col.Y = cells_area.Y;
+ rect_col.Height = cells_area.Height;
+ grid.Invalidate (rect_col);
+ }
+
+ // Return true if the scrollbar is needed
+ public bool SetUpHorizontalScrollBar ()
+ {
+ int width_all = CalcAllColumnsWidth ();
+
+ if (width_all <= cells_area.Width) {
+ grid.horiz_scrollbar.Visible = false;
+ grid.Controls.Remove (grid.horiz_scrollbar);
+ return false;
+ }
+
+ grid.horiz_scrollbar.Location = new Point (grid.ClientRectangle.X, grid.ClientRectangle.Y +
+ grid.ClientRectangle.Height - grid.horiz_scrollbar.Height);
+
+ grid.horiz_scrollbar.Size = new Size (grid.ClientRectangle.Width,
+ grid.horiz_scrollbar.Height);
+
+ grid.horiz_scrollbar.Maximum = width_all;// - cells_area.Width;
+ grid.horiz_scrollbar.LargeChange = cells_area.Width;
+ grid.Controls.Add (grid.horiz_scrollbar);
+ grid.horiz_scrollbar.Visible = true;
+ return true;
+ }
+
+ // Return true if the scrollbar is needed
+ public bool SetUpVerticalScrollBar ()
+ {
+ int y, height;
+ int allrows = grid.RowsCount;
+
+ if (grid.ShowEditRow && grid.RowsCount > 0) {
+ allrows++;
+ }
+
+ if (grid.visiblerow_count == allrows) {
+ grid.vert_scrollbar.Visible = false;
+ grid.Controls.Remove (grid.vert_scrollbar);
+ return false;
+ }
+
+ if (grid.caption_visible) {
+ y = grid.ClientRectangle.Y + caption_area.Height;
+ height = grid.ClientRectangle.Height - caption_area.Height;
+ } else {
+ y = grid.ClientRectangle.Y;
+ height = grid.ClientRectangle.Height;
+ }
+
+ grid.vert_scrollbar.Location = new Point (grid.ClientRectangle.X +
+ grid.ClientRectangle.Width - grid.vert_scrollbar.Width, y);
+
+ grid.vert_scrollbar.Size = new Size (grid.vert_scrollbar.Width,
+ height);
+
+ grid.vert_scrollbar.Maximum = grid.RowsCount;
+
+ if (grid.ShowEditRow && grid.RowsCount > 0) {
+ grid.vert_scrollbar.Maximum++;
+ }
+
+ grid.vert_scrollbar.LargeChange = VLargeChange;
+
+ grid.Controls.Add (grid.vert_scrollbar);
+ grid.vert_scrollbar.Visible = true;
+ return true;
+ }
+
+ #endregion // Public Instance Methods
+
+ #region Instance Properties
+ public Rectangle CellsArea {
+ get {
+ return cells_area;
+ }
+ }
+
+ // Returns the ColumnsHeader area excluding the rectangle shared with RowsHeader
+ public Rectangle ColumnsHeadersArea {
+ get {
+ Rectangle columns_area = columnshdrs_area;
+
+ if (grid.CurrentTableStyle.CurrentRowHeadersVisible) {
+ columns_area.X += grid.RowHeaderWidth;
+ columns_area.Width -= grid.RowHeaderWidth;
+ }
+ return columns_area;
+ }
+ }
+
+ public int ColumnsHeaderHeight {
+ get {
+ return grid.CurrentTableStyle.HeaderFont.Height + 6;
+ }
+ }
+
+ public Rectangle RowsHeadersArea {
+ get {
+ return rowshdrs_area;
+ }
+ }
+
+ public int VLargeChange {
+ get {
+ return cells_area.Height / grid.RowHeight;
+ }
+ }
+
+ #endregion Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridLineStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridLineStyle.cs
new file mode 100644
index 00000000000..64c554a6882
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridLineStyle.cs
@@ -0,0 +1,33 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum DataGridLineStyle {
+ None = 0,
+ Solid = 1
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridParentRowsLabelStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridParentRowsLabelStyle.cs
new file mode 100644
index 00000000000..1cbab2626de
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridParentRowsLabelStyle.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum DataGridParentRowsLabelStyle {
+ None = 0,
+ TableName = 1,
+ ColumnName = 2,
+ Both = 3
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridPreferredColumnWidthTypeConverter.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridPreferredColumnWidthTypeConverter.cs
new file mode 100644
index 00000000000..f5b31089298
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridPreferredColumnWidthTypeConverter.cs
@@ -0,0 +1,69 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+using System;
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+ public class DataGridPreferredColumnWidthTypeConverter : TypeConverter {
+ #region Public Constructors
+ public DataGridPreferredColumnWidthTypeConverter() {
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Methods
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
+ if ((sourceType == typeof(string)) || (sourceType == typeof(int))) {
+ return true;
+ }
+ return base.CanConvertFrom (context, sourceType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+ if (value is string) {
+ if (((string)value).Equals("AutoColumnResize (-1)")) {
+ return -1;
+ }
+
+ return Int32.Parse((string)value);
+ }
+ return base.ConvertFrom (context, culture, value);
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) {
+ if (destinationType == typeof(String)) {
+ if ((int)value == -1) {
+ return "AutoColumnResize (-1)";
+ }
+
+ }
+ return base.ConvertTo (context, culture, value, destinationType);
+ }
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTableStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTableStyle.cs
new file mode 100644
index 00000000000..0adef2569a5
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTableStyle.cs
@@ -0,0 +1,937 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+//
+// Peter Bartok <pbartok@novell.com>
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+// NOT COMPLETE
+//
+
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Data;
+using System.Xml;
+using System.Runtime.Serialization;
+
+namespace System.Windows.Forms
+{
+ [DesignTimeVisible(false)]
+ [ToolboxItem(false)]
+ public class DataGridTableStyle : Component, IDataGridEditingService
+ {
+ public static DataGridTableStyle DefaultTableStyle = new DataGridTableStyle (true);
+
+ #region Local Variables
+ private static readonly Color def_alternating_backcolor = SystemColors.Window;
+ private static readonly Color def_backcolor = SystemColors.Window;
+ private static readonly Color def_forecolor = SystemColors.WindowText;
+ private static readonly Color def_gridline_color = SystemColors.Control;
+ private static readonly Color def_header_backcolor = SystemColors.Control;
+ private static readonly Font def_header_font = null;
+ private static readonly Color def_header_forecolor = SystemColors.ControlText;
+ private static readonly Color def_link_color = SystemColors.HotTrack;
+ private static readonly Color def_link_hovercolor = SystemColors.HotTrack;
+ private static readonly Color def_selection_backcolor = SystemColors.ActiveCaption;
+ private static readonly Color def_selection_forecolor = SystemColors.ActiveCaptionText;
+
+ private bool allow_sorting;
+ private DataGrid datagrid;
+ private Color header_forecolor;
+ private string mapping_name;
+ private Color alternating_backcolor;
+ private bool columnheaders_visible;
+ private GridColumnStylesCollection column_styles;
+ private Color gridline_color;
+ private DataGridLineStyle gridline_style;
+ private Color header_backcolor;
+ private Font header_font;
+ private Color link_color;
+ private Color link_hovercolor;
+ private int preferredcolumn_width;
+ private int preferredrow_height;
+ private bool _readonly;
+ private bool rowheaders_visible;
+ private Color selection_backcolor;
+ private Color selection_forecolor;
+ private int rowheaders_width;
+ private Color backcolor;
+ private Color forecolor;
+ private bool is_default;
+ CurrencyManager manager;
+ #endregion // Local Variables
+
+ #region Constructors
+ public DataGridTableStyle ()
+ {
+ CommonConstructor ();
+ is_default = false;
+ }
+
+ public DataGridTableStyle (bool isDefaultTableStyle)
+ {
+ CommonConstructor ();
+ is_default = isDefaultTableStyle;
+ }
+
+ // TODO: What to do with the CurrencyManager
+ public DataGridTableStyle (CurrencyManager listManager)
+ {
+ CommonConstructor ();
+ is_default = false;
+ manager = listManager;
+ }
+
+ private void CommonConstructor ()
+ {
+ allow_sorting = true;
+ datagrid = null;
+ header_forecolor = def_header_forecolor;
+ mapping_name = string.Empty;
+ column_styles = new GridColumnStylesCollection (this);
+
+ alternating_backcolor = def_alternating_backcolor;
+ columnheaders_visible = true;
+ gridline_color = def_gridline_color;
+ gridline_style = DataGridLineStyle.Solid;
+ header_backcolor = def_header_backcolor;
+ header_font = def_header_font;
+ link_color = def_link_color;
+ link_hovercolor = def_link_hovercolor;
+ preferredcolumn_width = ThemeEngine.Current.DataGridPreferredColumnWidth;
+ preferredrow_height = ThemeEngine.Current.DefaultFont.Height + 3;
+ _readonly = false;
+ rowheaders_visible = true;
+ selection_backcolor = def_selection_backcolor;
+ selection_forecolor = def_selection_forecolor;
+ rowheaders_width = 35;
+ backcolor = def_backcolor;
+ forecolor = def_forecolor;
+ }
+ #endregion
+
+ #region Public Instance Properties
+ [DefaultValue(true)]
+ public bool AllowSorting {
+ get {
+ return allow_sorting;
+ }
+
+ set {
+ if (allow_sorting != value) {
+ allow_sorting = value;
+ OnAllowSortingChanged (EventArgs.Empty);
+
+ if (datagrid != null) {
+ datagrid.Refresh ();
+ }
+ }
+ }
+ }
+
+ public Color AlternatingBackColor {
+ get {
+ return alternating_backcolor;
+ }
+
+ set {
+ if (alternating_backcolor != value) {
+ alternating_backcolor = value;
+ OnAlternatingBackColorChanged (EventArgs.Empty);
+
+ if (datagrid != null) {
+ datagrid.Refresh ();
+ }
+ }
+ }
+ }
+
+ public Color BackColor {
+ get {
+ return backcolor;
+ }
+
+ set {
+ if (backcolor != value) {
+ backcolor = value;
+ OnBackColorChanged (EventArgs.Empty);
+
+ if (datagrid != null) {
+ datagrid.Refresh ();
+ }
+ }
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool ColumnHeadersVisible {
+ get {
+ return columnheaders_visible;
+ }
+
+ set {
+ if (columnheaders_visible != value) {
+ columnheaders_visible = value;
+ OnColumnHeadersVisibleChanged (EventArgs.Empty);
+
+ if (datagrid != null) {
+ datagrid.Refresh ();
+ }
+ }
+ }
+ }
+
+ [Browsable(false)]
+ public virtual DataGrid DataGrid {
+ get {
+ return datagrid;
+ }
+
+ set {
+ if (datagrid != value) {
+ datagrid = value;
+ }
+ }
+ }
+
+ public Color ForeColor {
+ get {
+ return forecolor;
+ }
+
+ set {
+ if (forecolor != value) {
+ forecolor = value;
+ OnForeColorChanged (EventArgs.Empty);
+
+ if (datagrid != null) {
+ datagrid.Refresh ();
+ }
+ }
+ }
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ [Localizable(true)]
+ public virtual GridColumnStylesCollection GridColumnStyles {
+ get { return column_styles; }
+ }
+
+ public Color GridLineColor {
+ get {
+ return gridline_color;
+ }
+
+ set {
+ if (gridline_color != value) {
+ gridline_color = value;
+ OnGridLineColorChanged (EventArgs.Empty);
+
+ if (datagrid != null) {
+ datagrid.Refresh ();
+ }
+ }
+ }
+ }
+
+ [DefaultValue(DataGridLineStyle.Solid)]
+ public DataGridLineStyle GridLineStyle {
+ get {
+ return gridline_style;
+ }
+
+ set {
+ if (gridline_style != value) {
+ gridline_style = value;
+ OnGridLineStyleChanged (EventArgs.Empty);
+
+ if (datagrid != null) {
+ datagrid.Refresh ();
+ }
+ }
+ }
+ }
+
+ public Color HeaderBackColor {
+ get {
+ return header_backcolor;
+ }
+
+ set {
+ if (value == Color.Empty) {
+ throw new ArgumentNullException ("Color.Empty value is invalid.");
+ }
+
+ if (header_backcolor != value) {
+ header_backcolor = value;
+ OnHeaderBackColorChanged (EventArgs.Empty);
+
+ if (datagrid != null) {
+ datagrid.Refresh ();
+ }
+ }
+ }
+ }
+
+ [AmbientValue(null)]
+ [Localizable(true)]
+ public Font HeaderFont {
+ get {
+ if (header_font != null)
+ return header_font;
+
+ if (datagrid != null)
+ return datagrid.HeaderFont;
+
+ return ThemeEngine.Current.DefaultFont;
+ }
+
+ set {
+ if (header_font != value) {
+ header_font = value;
+ OnHeaderFontChanged (EventArgs.Empty);
+
+ if (datagrid != null) {
+ datagrid.Refresh ();
+ }
+ }
+ }
+ }
+
+ public Color HeaderForeColor {
+ get {
+ return header_forecolor;
+ }
+
+ set {
+
+ if (header_forecolor != value) {
+ header_forecolor = value;
+
+ if (datagrid != null) {
+ datagrid.Refresh ();
+ }
+
+ OnHeaderForeColorChanged (EventArgs.Empty);
+ }
+ }
+ }
+
+ public Color LinkColor {
+ get {
+ return link_color;
+ }
+
+ set {
+ if (link_color != value) {
+ link_color = value;
+
+ if (datagrid != null) {
+ datagrid.Refresh ();
+ }
+
+ OnLinkColorChanged (EventArgs.Empty);
+ }
+ }
+ }
+
+ [ComVisible(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [Browsable(false)]
+ public Color LinkHoverColor {
+ get {
+ return link_hovercolor;
+ }
+
+ set {
+ if (link_hovercolor != value) {
+ link_hovercolor = value;
+ OnLinkHoverColorChanged (EventArgs.Empty);
+ }
+ }
+ }
+
+ [Editor("System.Windows.Forms.Design.DataGridTableStyleMappingNameEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
+ public string MappingName {
+ get {
+ return mapping_name;
+ }
+
+ set {
+ if (mapping_name != value) {
+ mapping_name = value;
+ OnMappingNameChanged (EventArgs.Empty);
+ }
+ }
+ }
+
+ [DefaultValue(75)]
+ [TypeConverter(typeof(DataGridPreferredColumnWidthTypeConverter))]
+ [Localizable(true)]
+ public int PreferredColumnWidth {
+ get {
+ return preferredcolumn_width;
+ }
+
+ set {
+ if (value < 0) {
+ throw new ArgumentException ("PreferredColumnWidth is less than 0");
+ }
+
+ if (preferredcolumn_width != value) {
+ preferredcolumn_width = value;
+ OnPreferredColumnWidthChanged (EventArgs.Empty);
+ }
+ }
+ }
+
+ [Localizable(true)]
+ public int PreferredRowHeight {
+ get {
+ return preferredrow_height;
+ }
+
+ set {
+ if (preferredrow_height != value) {
+ preferredrow_height = value;
+ OnPreferredRowHeightChanged (EventArgs.Empty);
+ }
+ }
+ }
+
+ [DefaultValue(false)]
+ public virtual bool ReadOnly {
+ get {
+ return _readonly;
+ }
+
+ set {
+ if (_readonly != value) {
+ _readonly = value;
+ OnReadOnlyChanged (EventArgs.Empty);
+ }
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool RowHeadersVisible {
+ get {
+ return rowheaders_visible;
+ }
+
+ set {
+ if (rowheaders_visible != value) {
+ rowheaders_visible = value;
+ OnRowHeadersVisibleChanged (EventArgs.Empty);
+ }
+ }
+ }
+
+ [DefaultValue(35)]
+ [Localizable(true)]
+ public int RowHeaderWidth {
+ get {
+ return rowheaders_width;
+ }
+
+ set {
+ if (rowheaders_width != value) {
+ rowheaders_width = value;
+ OnRowHeaderWidthChanged (EventArgs.Empty);
+ }
+ }
+ }
+
+ public Color SelectionBackColor {
+ get {
+ return selection_backcolor;
+ }
+
+ set {
+ if (selection_backcolor != value) {
+ selection_backcolor = value;
+ OnSelectionBackColorChanged (EventArgs.Empty);
+ }
+ }
+ }
+
+ [Description("The foreground color for the current data grid row")]
+ public Color SelectionForeColor {
+ get {
+ return selection_forecolor;
+ }
+
+ set {
+ if (selection_forecolor != value) {
+ selection_forecolor = value;
+ OnSelectionForeColorChanged (EventArgs.Empty);
+ }
+ }
+ }
+
+ #endregion // Public Instance Properties
+
+ #region Private Instance Properties
+ internal DataGridLineStyle CurrentGridLineStyle {
+ get {
+ if (is_default && datagrid != null) {
+ return datagrid.GridLineStyle;
+ }
+
+ return gridline_style;
+ }
+ }
+
+ internal Color CurrentGridLineColor {
+ get {
+ if (is_default && datagrid != null) {
+ return datagrid.GridLineColor;
+ }
+
+ return gridline_color;
+ }
+ }
+
+ internal Color CurrentHeaderBackColor {
+ get {
+ if (is_default && datagrid != null) {
+ return datagrid.HeaderBackColor;
+ }
+
+ return header_backcolor;
+ }
+ }
+
+ internal Color CurrentHeaderForeColor {
+ get {
+ if (is_default && datagrid != null) {
+ return datagrid.HeaderForeColor;
+ }
+
+ return header_forecolor;
+ }
+ }
+
+ internal int CurrentPreferredColumnWidth {
+ get {
+ if (is_default && datagrid != null) {
+ return datagrid.PreferredColumnWidth;
+ }
+
+ return preferredcolumn_width;
+ }
+ }
+
+ internal int CurrentPreferredRowHeight {
+ get {
+ if (is_default && datagrid != null) {
+ return datagrid.PreferredRowHeight;
+ }
+
+ return preferredrow_height;
+ }
+ }
+
+ internal bool CurrentRowHeadersVisible {
+ get {
+ if (is_default && datagrid != null) {
+ return datagrid.RowHeadersVisible;
+ }
+
+ return rowheaders_visible;
+ }
+ }
+
+
+ #endregion Private Instance Properties
+
+ #region Public Instance Methods
+
+ [MonoTODO]
+ public virtual bool BeginEdit (DataGridColumnStyle gridColumn, int rowNumber)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected internal virtual DataGridColumnStyle CreateGridColumn (PropertyDescriptor prop)
+ {
+ return CreateGridColumn (prop, false);
+ }
+
+ protected internal virtual DataGridColumnStyle CreateGridColumn (PropertyDescriptor prop, bool isDefault)
+ {
+ if (DataGridBoolColumn.CanRenderType (prop.PropertyType)) {
+ return new DataGridBoolColumn (prop, isDefault);
+ }
+
+ if (DataGridTextBoxColumn.CanRenderType (prop.PropertyType)) {
+
+ // At least to special cases with formats
+ if (prop.PropertyType.Equals (typeof (DateTime))) {
+ return new DataGridTextBoxColumn (prop, "d", isDefault);
+ }
+
+ if (prop.PropertyType.Equals (typeof (Int32)) ||
+ prop.PropertyType.Equals (typeof (Int16))) {
+ return new DataGridTextBoxColumn (prop, "G", isDefault);
+ }
+
+ return new DataGridTextBoxColumn (prop, isDefault);
+ }
+
+ throw new NotImplementedException ();
+ }
+
+ protected override void Dispose (bool disposing)
+ {
+ base.Dispose (disposing);
+ }
+
+ [MonoTODO]
+ public virtual bool EndEdit ( DataGridColumnStyle gridColumn, int rowNumber, bool shouldAbort)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected virtual void OnAllowSortingChanged (EventArgs e)
+ {
+ if (AllowSortingChanged != null) {
+ AllowSortingChanged (this, e);
+ }
+ }
+
+ protected virtual void OnAlternatingBackColorChanged (EventArgs e)
+ {
+ if (AlternatingBackColorChanged != null) {
+ AlternatingBackColorChanged (this, e);
+ }
+ }
+
+ protected virtual void OnBackColorChanged (EventArgs e)
+ {
+ if (BackColorChanged != null) {
+ BackColorChanged (this, e);
+ }
+ }
+
+ protected virtual void OnColumnHeadersVisibleChanged (EventArgs e)
+ {
+ if (ColumnHeadersVisibleChanged != null) {
+ ColumnHeadersVisibleChanged (this, e);
+ }
+ }
+
+ protected virtual void OnForeColorChanged (EventArgs e)
+ {
+ if (ForeColorChanged != null) {
+ ForeColorChanged (this, e);
+ }
+ }
+
+ protected virtual void OnGridLineColorChanged (EventArgs e)
+ {
+ if (GridLineColorChanged != null) {
+ GridLineColorChanged (this, e);
+ }
+ }
+
+ protected virtual void OnGridLineStyleChanged (EventArgs e)
+ {
+ if (GridLineStyleChanged != null) {
+ GridLineStyleChanged (this, e);
+ }
+ }
+
+ protected virtual void OnHeaderBackColorChanged (EventArgs e)
+ {
+ if (HeaderBackColorChanged != null) {
+ HeaderBackColorChanged (this, e);
+ }
+ }
+
+ protected virtual void OnHeaderFontChanged (EventArgs e)
+ {
+ if (HeaderFontChanged != null) {
+ HeaderFontChanged (this, e);
+ }
+ }
+
+ protected virtual void OnHeaderForeColorChanged (EventArgs e)
+ {
+ if (HeaderForeColorChanged != null) {
+ HeaderForeColorChanged (this, e);
+ }
+ }
+
+ protected virtual void OnLinkColorChanged (EventArgs e)
+ {
+ if (LinkColorChanged != null) {
+ LinkColorChanged (this, e);
+ }
+ }
+
+ protected virtual void OnLinkHoverColorChanged (EventArgs e)
+ {
+ if (LinkHoverColorChanged != null) {
+ LinkHoverColorChanged (this, e);
+ }
+ }
+
+ protected virtual void OnMappingNameChanged (EventArgs e)
+ {
+ if (MappingNameChanged != null) {
+ MappingNameChanged(this, e);
+ }
+ }
+
+ protected virtual void OnPreferredColumnWidthChanged (EventArgs e)
+ {
+ if (PreferredColumnWidthChanged != null) {
+ PreferredColumnWidthChanged (this, e);
+ }
+ }
+
+ protected virtual void OnPreferredRowHeightChanged (EventArgs e)
+ {
+ if (PreferredRowHeightChanged != null) {
+ PreferredRowHeightChanged (this, e);
+ }
+ }
+
+ protected virtual void OnReadOnlyChanged (EventArgs e)
+ {
+ if (ReadOnlyChanged != null) {
+ ReadOnlyChanged (this, e);
+ }
+ }
+
+ protected virtual void OnRowHeadersVisibleChanged (EventArgs e)
+ {
+ if (RowHeadersVisibleChanged != null) {
+ RowHeadersVisibleChanged (this, e);
+ }
+ }
+
+ protected virtual void OnRowHeaderWidthChanged (EventArgs e)
+ {
+ if (RowHeaderWidthChanged != null) {
+ RowHeaderWidthChanged (this, e);
+ }
+ }
+
+ protected virtual void OnSelectionBackColorChanged (EventArgs e)
+ {
+ if (SelectionBackColorChanged != null) {
+ SelectionBackColorChanged (this, e);
+ }
+ }
+
+ protected virtual void OnSelectionForeColorChanged (EventArgs e)
+ {
+ if (SelectionForeColorChanged != null) {
+ SelectionForeColorChanged (this, e);
+ }
+ }
+
+ public void ResetAlternatingBackColor ()
+ {
+ AlternatingBackColor = def_alternating_backcolor;
+ }
+
+ public void ResetBackColor ()
+ {
+ BackColor = def_backcolor;
+ }
+
+ public void ResetForeColor ()
+ {
+ ForeColor = def_forecolor;
+ }
+
+ public void ResetGridLineColor ()
+ {
+ GridLineColor = def_gridline_color;
+ }
+
+ public void ResetHeaderBackColor ()
+ {
+ HeaderBackColor = def_header_backcolor;
+ }
+
+ public void ResetHeaderFont ()
+ {
+ HeaderFont = def_header_font;
+ }
+
+ public void ResetHeaderForeColor ()
+ {
+ HeaderForeColor = def_header_forecolor;
+ }
+
+ public void ResetLinkColor ()
+ {
+ LinkColor = def_link_color;
+ }
+
+ public void ResetLinkHoverColor ()
+ {
+ LinkHoverColor = def_link_hovercolor;
+ }
+
+ public void ResetSelectionBackColor ()
+ {
+ SelectionBackColor = def_selection_backcolor;
+ }
+
+ public void ResetSelectionForeColor ()
+ {
+ SelectionForeColor = def_selection_forecolor;
+ }
+
+ protected virtual bool ShouldSerializeAlternatingBackColor ()
+ {
+ return (alternating_backcolor != def_alternating_backcolor);
+ }
+
+ protected bool ShouldSerializeBackColor ()
+ {
+ return (backcolor != def_backcolor);
+ }
+
+ protected bool ShouldSerializeForeColor ()
+ {
+ return (forecolor != def_forecolor);
+ }
+
+ protected virtual bool ShouldSerializeGridLineColor ()
+ {
+ return (gridline_color != def_gridline_color);
+ }
+
+ protected virtual bool ShouldSerializeHeaderBackColor ()
+ {
+ return (header_backcolor != def_header_backcolor);
+ }
+
+ protected virtual bool ShouldSerializeHeaderForeColor ()
+ {
+ return (header_forecolor != def_header_forecolor);
+ }
+
+ protected virtual bool ShouldSerializeLinkColor ()
+ {
+ return (link_color != def_link_color);
+ }
+
+ protected virtual bool ShouldSerializeLinkHoverColor ()
+ {
+ return (link_hovercolor != def_link_hovercolor);
+ }
+
+ protected bool ShouldSerializePreferredRowHeight ()
+ {
+ return (preferredrow_height != datagrid.def_preferredrow_height);
+ }
+
+ protected bool ShouldSerializeSelectionBackColor ()
+ {
+ return (selection_backcolor != def_selection_backcolor);
+ }
+
+ protected virtual bool ShouldSerializeSelectionForeColor ()
+ {
+ return (selection_forecolor != def_selection_forecolor);
+ }
+ #endregion // Protected Instance Methods
+
+ #region Private Instance Properties
+ // Create column styles for this TableStyle
+ internal void CreateColumnsForTable (bool onlyBind)
+ {
+ CurrencyManager mgr = null;
+ mgr = datagrid.ListManager;
+
+ if (mgr == null) {
+ return;
+ }
+
+ PropertyDescriptorCollection propcol = mgr.GetItemProperties ();
+
+ for (int i = 0; i < propcol.Count; i++)
+ {
+ // The column style is already provided by the user
+ if (column_styles[propcol[i].Name] != null) {
+ column_styles[propcol[i].Name].table_style = this;
+ column_styles[propcol[i].Name].SetDataGridInternal (datagrid);
+ continue;
+ }
+
+ if (onlyBind == true) {
+ continue;
+ }
+
+
+ // TODO: What to do with relations?
+ if (propcol[i].ComponentType.ToString () == "System.Data.DataTablePropertyDescriptor") {
+ Console.WriteLine ("CreateColumnsForTable::System.Data.DataTablePropertyDescriptor");
+
+ } else {
+ DataGridColumnStyle st = CreateGridColumn (propcol[i], true);
+ st.grid = datagrid;
+ st.MappingName = propcol[i].Name;
+ st.HeaderText = propcol[i].Name;
+ st.Width = CurrentPreferredColumnWidth;
+ column_styles.Add (st);
+ }
+ }
+
+ }
+
+ #endregion Private Instance Properties
+
+ #region Events
+ public event EventHandler AllowSortingChanged;
+ public event EventHandler AlternatingBackColorChanged;
+ public event EventHandler BackColorChanged;
+ public event EventHandler ColumnHeadersVisibleChanged;
+ public event EventHandler ForeColorChanged;
+ public event EventHandler GridLineColorChanged;
+ public event EventHandler GridLineStyleChanged;
+ public event EventHandler HeaderBackColorChanged;
+ public event EventHandler HeaderFontChanged;
+ public event EventHandler HeaderForeColorChanged;
+ public event EventHandler LinkColorChanged;
+ public event EventHandler LinkHoverColorChanged;
+ public event EventHandler MappingNameChanged;
+ public event EventHandler PreferredColumnWidthChanged;
+ public event EventHandler PreferredRowHeightChanged;
+ public event EventHandler ReadOnlyChanged;
+ public event EventHandler RowHeadersVisibleChanged;
+ public event EventHandler RowHeaderWidthChanged;
+ public event EventHandler SelectionBackColorChanged;
+ public event EventHandler SelectionForeColorChanged;
+ #endregion // Events
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBox.cs
new file mode 100644
index 00000000000..d4c2e458495
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBox.cs
@@ -0,0 +1,184 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+// NOT COMPLETE
+
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Diagnostics;
+
+namespace System.Windows.Forms
+{
+ [DefaultProperty("GridEditName")]
+ [DesignTimeVisible(false)]
+ [ToolboxItem(false)]
+ public class DataGridTextBox : TextBox
+ {
+
+ #region Local Variables
+ private bool isedit;
+ private DataGrid grid;
+ #endregion // Local Variables
+
+ #region Constructors
+ public DataGridTextBox ()
+ {
+ isedit = true;
+ grid = null;
+ accepts_tab = true;
+
+ SetStyle (ControlStyles.UserPaint | ControlStyles.StandardClick | ControlStyles.StandardDoubleClick, false);
+ SetStyle (ControlStyles.FixedHeight, true);
+ }
+ #endregion
+
+ #region Public Instance Properties
+ public bool IsInEditOrNavigateMode {
+ get {
+ return isedit;
+ }
+ set {
+ if (value != isedit) {
+ isedit = value;
+ }
+ }
+ }
+
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ protected override void OnKeyPress (KeyPressEventArgs e)
+ {
+ grid.is_changing = true;
+ grid.InvalidateCurrentRowHeader ();
+ base.OnKeyPress (e);
+ }
+
+ protected override void OnMouseWheel (MouseEventArgs e)
+ {
+ base.OnMouseWheel (e);
+ }
+
+ protected internal override bool ProcessKeyMessage (ref Message m)
+ {
+ Keys key = (Keys) m.WParam.ToInt32 ();
+
+ // If we decide DataGrid needs to process we call grid.ProcessKeyPreviewInternal and return true
+ // If we want TextBox to handle the key , we return false;
+
+ // We only care about KEYDOWN messages
+ if (m.Msg != (int)Msg.WM_KEYDOWN) {
+ return false;
+ }
+
+ // Anything with control key pressed is for DataGrid
+ if ((Control.ModifierKeys & Keys.Control) != 0) {
+ return grid.ProcessKeyPreviewInternal(ref m);
+ }
+
+ if (isedit) {
+ switch (key) {
+ case Keys.F2: {
+ this.SelectionStart = this.Text.Length;
+ this.SelectionLength = 0;
+ return true;
+ }
+
+ case Keys.Up:
+ case Keys.Down:
+ case Keys.PageDown:
+ case Keys.PageUp: {
+ isedit = false;
+ grid.EndEdit(false);
+ grid.ProcessKeyPreviewInternal(ref m);
+ return true;
+ }
+
+ case Keys.Escape: {
+ isedit = false;
+ grid.EndEdit (true);
+ return true;
+ }
+
+ case Keys.Enter: {
+ isedit = false;
+ grid.EndEdit (false);
+ grid.ProcessKeyPreviewInternal(ref m);
+ return true;
+ }
+
+ case Keys.Left: {
+ if (base.SelectionStart == 0) {
+ isedit = false;
+ grid.EndEdit (false);
+ grid.ProcessKeyPreviewInternal(ref m);
+ return true;
+ }
+ return false;
+ }
+
+ case Keys.Right: {
+ // Arrow keys go right until we hit the end of the text
+ if ((base.SelectionStart + base.SelectionLength) == base.Text.Length) {
+ isedit = false;
+ grid.EndEdit (false);
+ grid.ProcessKeyPreviewInternal(ref m);
+ return true;
+ }
+ return false;
+ }
+
+ case Keys.Tab: {
+ isedit = false;
+ grid.EndEdit(false);
+ grid.ProcessKeyPreviewInternal(ref m);
+ return true;
+ }
+
+ default: {
+ return base.ProcessKeyMessage(ref m);
+ }
+ }
+ }
+
+ return base.ProcessKeyMessage(ref m);
+ }
+
+ public void SetDataGrid (DataGrid parentGrid)
+ {
+ grid = parentGrid;
+ }
+
+ protected override void WndProc (ref Message m)
+ {
+ base.WndProc (ref m);
+ }
+
+ #endregion // Public Instance Methods
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBoxColumn.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBoxColumn.cs
new file mode 100644
index 00000000000..aaadefded4f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBoxColumn.cs
@@ -0,0 +1,342 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+// NOT COMPLETE
+
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Diagnostics;
+
+namespace System.Windows.Forms
+{
+ public class DataGridTextBoxColumn : DataGridColumnStyle
+ {
+ #region Local Variables
+ private string format;
+ private IFormatProvider format_provider = null;
+ private StringFormat string_format = new StringFormat ();
+ private DataGridTextBox textbox = null;
+ private static readonly int offset_x = 2;
+ private static readonly int offset_y = 2;
+ #endregion // Local Variables
+
+ #region Constructors
+ public DataGridTextBoxColumn ()
+ {
+ format = string.Empty;
+ }
+
+ public DataGridTextBoxColumn (PropertyDescriptor prop) : base (prop)
+ {
+ format = string.Empty;
+ }
+
+ public DataGridTextBoxColumn (PropertyDescriptor prop, bool isDefault) : base (prop)
+ {
+ format = string.Empty;
+ is_default = isDefault;
+ }
+
+ public DataGridTextBoxColumn (PropertyDescriptor prop, string format) : base (prop)
+ {
+ this.format = format;
+ }
+
+ public DataGridTextBoxColumn (PropertyDescriptor prop, string format, bool isDefault) : base (prop)
+ {
+ this.format = format;
+ is_default = isDefault;
+ }
+
+ #endregion
+
+ #region Public Instance Properties
+ [Editor("System.Windows.Forms.Design.DataGridColumnStyleFormatEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
+ public string Format {
+ get {
+ return format;
+ }
+ set {
+ if (value != format) {
+ format = value;
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public IFormatProvider FormatInfo {
+ get {
+ return format_provider;
+ }
+ set {
+ if (value != format_provider) {
+ format_provider = value;
+ }
+ }
+ }
+
+ [DefaultValue(null)]
+ public override PropertyDescriptor PropertyDescriptor {
+ set {
+ base.PropertyDescriptor = value;
+ }
+ }
+
+ public override bool ReadOnly {
+ get {
+ return base.ReadOnly;
+ }
+ set {
+ base.ReadOnly = value;
+ }
+ }
+
+ [Browsable(false)]
+ public virtual TextBox TextBox {
+ get {
+ EnsureTextBox();
+ return textbox;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+
+
+ protected internal override void Abort (int rowNum)
+ {
+ EndEdit ();
+ }
+
+ protected internal override bool Commit (CurrencyManager dataSource, int rowNum)
+ {
+ string text;
+
+ if (textbox.Text == NullText) {
+ text = string.Empty;
+ } else {
+ text = textbox.Text;
+ }
+
+ try {
+ SetColumnValueAtRow (dataSource, rowNum, text);
+ }
+
+ catch (Exception e) {
+ string message = "The data entered in column ["+ MappingName +"] has an invalid format.";
+ MessageBox.Show( message);
+ }
+
+
+ EndEdit ();
+ return true;
+ }
+
+ [MonoTODO]
+ protected internal override void ConcedeFocus ()
+ {
+
+ }
+
+ protected internal override void Edit (CurrencyManager source, int rowNum, Rectangle bounds, bool _ro, string instantText, bool cellIsVisible)
+ {
+ object obj;
+
+ EnsureTextBox();
+
+ textbox.TextAlign = alignment;
+
+ if ((ParentReadOnly == true) ||
+ (ParentReadOnly == false && ReadOnly == true) ||
+ (ParentReadOnly == false && _ro == true)) {
+ textbox.ReadOnly = true;
+ } else {
+ textbox.ReadOnly = false;
+ }
+
+ textbox.Location = new Point (bounds.X + offset_x, bounds.Y + offset_y);
+ textbox.Size = new Size (bounds.Width - offset_x, bounds.Height - offset_y);
+
+ obj = GetColumnValueAtRow (source, rowNum);
+ textbox.Text = GetFormattedString (obj);
+
+ textbox.Visible = cellIsVisible;
+ textbox.Focus ();
+ textbox.SelectAll ();
+ }
+
+ protected void EndEdit ()
+ {
+ ReleaseHostedControl ();
+ grid.Invalidate (grid.GetCurrentCellBounds ());
+ }
+
+ protected internal override void EnterNullValue ()
+ {
+ if (textbox != null) {
+ textbox.Text = NullText;
+ }
+ }
+
+ protected internal override int GetMinimumHeight ()
+ {
+ return FontHeight + 3;
+ }
+
+ [MonoTODO]
+ protected internal override int GetPreferredHeight (Graphics g, object value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected internal override Size GetPreferredSize (Graphics g, object value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected void HideEditBox ()
+ {
+
+ }
+
+ protected internal override void Paint (Graphics g, Rectangle bounds, CurrencyManager source, int rowNum)
+ {
+ Paint (g, bounds, source, rowNum, false);
+ }
+
+ protected internal override void Paint (Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, bool alignToRight)
+ {
+ Paint (g, bounds, source, rowNum, ThemeEngine.Current.ResPool.GetSolidBrush (DataGridTableStyle.BackColor),
+ ThemeEngine.Current.ResPool.GetSolidBrush (DataGridTableStyle.ForeColor), alignToRight);
+ }
+
+ protected internal override void Paint (Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight)
+ {
+ object obj;
+ obj = GetColumnValueAtRow (source, rowNum);
+
+ PaintText (g, bounds, GetFormattedString (obj), backBrush, foreBrush, alignToRight);
+ }
+
+ protected void PaintText (Graphics g, Rectangle bounds, string text, bool alignToRight)
+ {
+ PaintText (g, bounds, text, ThemeEngine.Current.ResPool.GetSolidBrush (DataGridTableStyle.BackColor),
+ ThemeEngine.Current.ResPool.GetSolidBrush (DataGridTableStyle.ForeColor), alignToRight);
+ }
+
+ protected void PaintText (Graphics g, Rectangle textBounds, string text, Brush backBrush, Brush foreBrush, bool alignToRight)
+ {
+ if (alignToRight == true) {
+ string_format.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
+ } else {
+ string_format.FormatFlags &= ~StringFormatFlags.DirectionRightToLeft;
+ }
+
+ switch (alignment) {
+ case HorizontalAlignment.Center:
+ string_format.Alignment = StringAlignment.Center;
+ break;
+ case HorizontalAlignment.Right:
+ string_format.Alignment = StringAlignment.Far;
+ break;
+ default:
+ string_format.Alignment = StringAlignment.Near;
+ break;
+ }
+
+ g.FillRectangle (backBrush, textBounds);
+ PaintGridLine (g, textBounds);
+
+ textBounds.Y += offset_y;
+ textBounds.Height -= offset_y;
+
+ string_format.FormatFlags |= StringFormatFlags.NoWrap;
+ g.DrawString (text, DataGridTableStyle.DataGrid.Font, foreBrush, textBounds, string_format);
+
+ }
+
+ protected internal override void ReleaseHostedControl ()
+ {
+ if (textbox != null) {
+ DataGridTableStyle.DataGrid.Controls.Remove (textbox);
+ textbox.Dispose ();
+ textbox = null;
+ }
+ }
+
+ protected override void SetDataGridInColumn (DataGrid value)
+ {
+ base.SetDataGridInColumn (value);
+ }
+
+ protected internal override void UpdateUI (CurrencyManager source, int rowNum, string instantText)
+ {
+
+ }
+
+ #endregion // Public Instance Methods
+
+
+ #region Private Instance Methods
+
+ // We use DataGridTextBox to render everything that DataGridBoolColumn does not
+ internal static bool CanRenderType (Type type)
+ {
+ return (type != typeof (Boolean));
+ }
+
+ private string GetFormattedString (object obj)
+ {
+ if (obj == DBNull.Value) {
+ return NullText;
+ }
+
+ if (format != null && obj as IFormattable != null) {
+ return ((IFormattable)obj).ToString (format, format_provider);
+ }
+
+ return obj.ToString ();
+
+ }
+
+ private void EnsureTextBox() {
+ if (textbox == null) {
+ textbox = new DataGridTextBox ();
+ textbox.SetDataGrid (DataGridTableStyle.DataGrid);
+ textbox.Multiline = true;
+ textbox.BorderStyle = BorderStyle.None;
+ textbox.Visible = false;
+
+ DataGridTableStyle.DataGrid.Controls.Add (textbox);
+ }
+ }
+ #endregion Private Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs
new file mode 100644
index 00000000000..4ec44b314cc
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs
@@ -0,0 +1,2985 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using System.Drawing;
+using System.Collections;
+
+namespace System.Windows.Forms {
+
+ [ComVisibleAttribute(true)]
+ [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
+ public class DataGridView : Control, ISupportInitialize {
+
+ private DataGridViewAdvancedBorderStyle adjustedTopLeftHeaderBorderStyle;
+ private DataGridViewAdvancedBorderStyle advancedCellBorderStyle;
+ private DataGridViewAdvancedBorderStyle advancedColumnHeadersBorderStyle;
+ private DataGridViewAdvancedBorderStyle advancedRowHeadersBorderStyle;
+ private bool allowUserToAddRows;
+ private bool allowUserToDeleteRows;
+ private bool allowUserToOrderColumns;
+ private bool allowUserToResizeColumns;
+ private bool allowUserToResizeRows;
+ private DataGridViewCellStyle alternatingRowsDefaultCellStyle;
+ private bool autoGenerateColumns;
+ private bool autoSize;
+ private DataGridViewAutoSizeColumnsMode autoSizeColumnsMode;
+ private DataGridViewAutoSizeRowsMode autoSizeRowsMode;
+ private Color backColor;
+ private Color backgroundColor;
+ private Image backgroundImage;
+ private ImageLayout backgroundImageLayout;
+ private BorderStyle borderStyle;
+ private DataGridViewCellBorderStyle cellBorderStyle;
+ private DataGridViewClipboardCopyMode clipboardCopyMode;
+ private DataGridViewHeaderBorderStyle columnHeadersBorderStyle;
+ private DataGridViewCellStyle columnHeadersDefaultCellStyle;
+ private int columnHeadersHeight;
+ private DataGridViewColumnHeadersHeightSizeMode columnHeadersHeightSizeMode;
+ private bool columnHeadersVisible;
+ private DataGridViewColumnCollection columns;
+ private DataGridViewCell currentCell;
+ private Point currentCellAddress;
+ private DataGridViewRow currentRow;
+ private string dataMember;
+ private object dataSource;
+ private DataGridViewCellStyle defaultCellStyle;
+ private Control editingControl;
+ private DataGridViewEditMode editMode;
+ private bool enableHeadersVisualStyles;
+ private DataGridViewCell firstDisplayedCell;
+ private int firstDisplayedScrollingColumnHiddenWidth;
+ private int firstDisplayedScrollingColumnIndex;
+ private int firstDisplayedScrollingRowIndex;
+ private Font font = Control.DefaultFont;
+ private Color foreColor = Control.DefaultForeColor;
+ private Color gridColor = Color.FromKnownColor(KnownColor.ControlDarkDark);
+ private int horizontalScrollingOffset;
+ private bool isCurrentCellDirty;
+ private bool isCurrentRowDirty;
+ private bool multiSelect;
+ private bool readOnly;
+ private DataGridViewHeaderBorderStyle rowHeadersBorderStyle;
+ private DataGridViewCellStyle rowHeadersDefaultCellStyle;
+ private bool rowHeadersVisible;
+ private int rowHeadersWidth;
+ private DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode;
+ private DataGridViewRowCollection rows;
+ private DataGridViewCellStyle rowsDefaultCellStyle;
+ private DataGridViewRow rowTemplate;
+ private ScrollBars scrollBars;
+ private DataGridViewSelectionMode selectionMode;
+ private bool showCellErrors;
+ private bool showCellToolTips;
+ private bool showEditingIcon;
+ private bool showRowErrors;
+ private DataGridViewColumn sortedColumn = null;
+ private SortOrder sortOrder;
+ private bool standardTab;
+ private string text;
+ private DataGridViewHeaderCell topLeftHeaderCell;
+ private Cursor userSetCursor;
+ private int verticalScrollingOffset;
+ private bool virtualMode;
+ private Size defaultSize;
+ private HScrollBar horizontalScrollBar;
+ private VScrollBar verticalScrollBar;
+
+ internal int gridWidth;
+ internal int gridHeight;
+
+ public DataGridView () {
+ adjustedTopLeftHeaderBorderStyle = new DataGridViewAdvancedBorderStyle();
+ adjustedTopLeftHeaderBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Single;
+ advancedCellBorderStyle = new DataGridViewAdvancedBorderStyle();
+ advancedCellBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Single;
+ advancedColumnHeadersBorderStyle = new DataGridViewAdvancedBorderStyle();
+ advancedColumnHeadersBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Single;
+ advancedRowHeadersBorderStyle = new DataGridViewAdvancedBorderStyle();
+ advancedRowHeadersBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Single;
+ alternatingRowsDefaultCellStyle = new DataGridViewCellStyle();
+ allowUserToAddRows = true;
+ allowUserToDeleteRows = true;
+ allowUserToOrderColumns = false;
+ allowUserToResizeColumns = true;
+ allowUserToResizeRows = true;
+ autoGenerateColumns = true;
+ autoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
+ autoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;
+ backColor = Control.DefaultBackColor;
+ backgroundColor = SystemColors.AppWorkspace;
+ borderStyle = BorderStyle.FixedSingle;
+ cellBorderStyle = DataGridViewCellBorderStyle.None;
+ clipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithAutoHeaderText;
+ columnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
+ columnHeadersDefaultCellStyle = new DataGridViewCellStyle();
+ columnHeadersDefaultCellStyle.BackColor = SystemColors.Control;
+ columnHeadersDefaultCellStyle.ForeColor = SystemColors.WindowText;
+ columnHeadersDefaultCellStyle.SelectionBackColor = SystemColors.Highlight;
+ columnHeadersDefaultCellStyle.SelectionForeColor = SystemColors.HighlightText;
+ columnHeadersDefaultCellStyle.Font = this.Font;
+ columnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
+ columnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.True;
+ columnHeadersHeight = 23;
+ columnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
+ columnHeadersVisible = true;
+ columns = CreateColumnsInstance();
+ columns.CollectionChanged += OnColumnCollectionChanged;
+ dataMember = String.Empty;
+ defaultCellStyle = (DataGridViewCellStyle) columnHeadersDefaultCellStyle.Clone();
+ editMode = DataGridViewEditMode.EditOnKeystrokeOrF2;
+ multiSelect = true;
+ readOnly = false;
+ rowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
+ rowHeadersDefaultCellStyle = (DataGridViewCellStyle) defaultCellStyle.Clone();
+ rowHeadersVisible = true;
+ rowHeadersWidth = 43;
+ rowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.EnableResizing;
+ rows = CreateRowsInstance();
+ rowsDefaultCellStyle = new DataGridViewCellStyle();
+ selectionMode = DataGridViewSelectionMode.RowHeaderSelect;
+ showCellErrors = true;
+ showEditingIcon = true;
+ userSetCursor = Cursor.Current;
+ virtualMode = false;
+
+ horizontalScrollBar = new HScrollBar();
+ horizontalScrollBar.Dock = DockStyle.Bottom;
+ horizontalScrollBar.Scroll += OnHScrollBarScroll;
+ horizontalScrollBar.Visible = false;
+ verticalScrollBar = new VScrollBar();
+ verticalScrollBar.Dock = DockStyle.Right;
+ verticalScrollBar.Scroll += OnVScrollBarScroll;
+ verticalScrollBar.Visible = false;
+ }
+
+ public void BeginInit () {
+ }
+
+ public void EndInit () {
+ }
+
+ // Propiedades
+
+ public virtual DataGridViewAdvancedBorderStyle AdjustedTopLeftHeaderBorderStyle {
+ get { return adjustedTopLeftHeaderBorderStyle; }
+ }
+
+ public DataGridViewAdvancedBorderStyle AdvancedCellBorderStyle {
+ get { return advancedCellBorderStyle; }
+ }
+
+ public DataGridViewAdvancedBorderStyle AdvancedColumnHeadersBorderStyle {
+ get { return advancedColumnHeadersBorderStyle; }
+ }
+
+ public DataGridViewAdvancedBorderStyle AdvancedRowHeadersBorderStyle {
+ get { return advancedRowHeadersBorderStyle; }
+ }
+
+ public bool AllowUserToAddRows {
+ get { return allowUserToAddRows; }
+ set {
+ if (allowUserToAddRows != value) {
+ allowUserToAddRows = value;
+ OnAllowUserToAddRowsChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public bool AllowUserToDeleteRows {
+ get { return allowUserToDeleteRows; }
+ set {
+ if (allowUserToDeleteRows != value) {
+ allowUserToDeleteRows = value;
+ OnAllowUserToDeleteRowsChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public bool AllowUserToOrderColumns {
+ get { return allowUserToOrderColumns; }
+ set {
+ if (allowUserToOrderColumns != value) {
+ allowUserToOrderColumns = value;
+ OnAllowUserToOrderColumnsChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public bool AllowUserToResizeColumns {
+ get { return allowUserToResizeColumns; }
+ set {
+ if (allowUserToResizeColumns != value) {
+ allowUserToResizeColumns = value;
+ OnAllowUserToResizeColumnsChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public bool AllowUserToResizeRows {
+ get { return allowUserToResizeRows; }
+ set {
+ if (allowUserToResizeRows != value) {
+ allowUserToResizeRows = value;
+ OnAllowUserToResizeRowsChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public DataGridViewCellStyle AlternatingRowsDefaultCellStyle {
+ get { return alternatingRowsDefaultCellStyle; }
+ set {
+ if (alternatingRowsDefaultCellStyle != value) {
+ alternatingRowsDefaultCellStyle = value;
+ OnAlternatingRowsDefaultCellStyleChanged(EventArgs.Empty);
+ Invalidate();
+ }
+ }
+ }
+
+ public bool AutoGenerateColumns {
+ get { return autoGenerateColumns; }
+ set {
+ if (autoGenerateColumns != value) {
+ autoGenerateColumns = value;
+ OnAutoGenerateColumnsChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ //public override bool AutoSize {
+ public bool AutoSize {
+ get { return autoSize; }
+ set {
+ if (autoSize != value) {
+ autoSize = value;
+ //OnAutoSizeChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public DataGridViewAutoSizeColumnsMode AutoSizeColumnsMode {
+ get { return autoSizeColumnsMode; }
+ set {
+ if (!Enum.IsDefined(typeof(DataGridViewAutoSizeColumnsMode), value)) {
+ throw new InvalidEnumArgumentException("Value is not valid DataGridViewAutoSizeColumnsMode.");
+ }
+ if (value == DataGridViewAutoSizeColumnsMode.ColumnHeader && columnHeadersVisible == false) {
+ foreach (DataGridViewColumn col in columns) {
+ if (col.AutoSizeMode == DataGridViewAutoSizeColumnMode.NotSet) {
+ throw new InvalidOperationException("Cant set this property to ColumnHeader in this DataGridView.");
+ }
+ }
+ }
+ if (value == DataGridViewAutoSizeColumnsMode.Fill) {
+ foreach (DataGridViewColumn col in columns) {
+ if (col.AutoSizeMode == DataGridViewAutoSizeColumnMode.NotSet) {
+ if (col.Frozen) {
+ throw new InvalidOperationException("Cant set this property to Fill in this DataGridView.");
+ }
+ }
+ }
+ }
+ autoSizeColumnsMode = value;
+ }
+ }
+
+ public DataGridViewAutoSizeRowsMode AutoSizeRowsMode {
+ get { return autoSizeRowsMode; }
+ set {
+ if (autoSizeRowsMode != value) {
+ if (!Enum.IsDefined(typeof(DataGridViewAutoSizeRowsMode), value)) {
+ throw new InvalidEnumArgumentException("Value is not valid DataGridViewRowsMode.");
+ }
+ if ((value == DataGridViewAutoSizeRowsMode.AllHeaders || value == DataGridViewAutoSizeRowsMode.DisplayedHeaders) && rowHeadersVisible == false) {
+ throw new InvalidOperationException("Cant set this property to AllHeaders or DisplayedHeaders in this DataGridView.");
+ }
+ autoSizeRowsMode = value;
+ OnAutoSizeRowsModeChanged(new DataGridViewAutoSizeModeEventArgs(false));
+ ////////////////////////////////////////////////////////////////
+ }
+ }
+ }
+
+ public override Color BackColor {
+ get { return backColor; }
+ set {
+ if (backColor != value) {
+ backColor = value;
+ OnBackColorChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public Color BackgroundColor {
+ get { return backgroundColor; }
+ set {
+ if (backgroundColor != value) {
+ if (value == Color.Empty) {
+ throw new ArgumentException("Cant set an Empty color.");
+ }
+ backgroundColor = value;
+ OnBackgroundColorChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public override Image BackgroundImage {
+ get { return backgroundImage; }
+ set {
+ if (backgroundImage != value) {
+ backgroundImage = value;
+ OnBackgroundImageChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ //public override ImageLayout BackgroundImageLayout {
+ public ImageLayout BackgroundImageLayout {
+ get { return backgroundImageLayout; }
+ set {
+ if (backgroundImageLayout != value) {
+ backgroundImageLayout = value;
+ //OnBackgroundImageLayoutChanged(EventArg.Empty);
+ }
+ }
+ }
+
+ public BorderStyle BorderStyle {
+ get { return borderStyle; }
+ set {
+ if (borderStyle != value) {
+ if (!Enum.IsDefined(typeof(BorderStyle), value)) {
+ throw new InvalidEnumArgumentException("Invalid border style.");
+ }
+ borderStyle = value;
+ OnBorderStyleChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public DataGridViewCellBorderStyle CellBorderStyle {
+ get { return cellBorderStyle; }
+ set {
+ if (cellBorderStyle != value) {
+ cellBorderStyle = value;
+ OnCellBorderStyleChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public DataGridViewClipboardCopyMode ClipboardCopyMode {
+ get { return clipboardCopyMode; }
+ set { clipboardCopyMode = value; }
+ }
+
+ public int ColumnCount {
+ get { return columns.Count; }
+ set {
+ if (value < 0) {
+ throw new ArgumentException("ColumnCount must be >= 0.");
+ }
+ if (dataSource != null) {
+ throw new InvalidOperationException("Cant change column count if DataSource is set.");
+ }
+ if (value < columns.Count) {
+ for (int i = value; i < columns.Count; i++) {
+ columns.RemoveAt(i);
+ }
+ }
+ else if (value > columns.Count) {
+ for (int i = 0; i < value; i++) {
+ DataGridViewColumn col = new DataGridViewColumn();
+ columns.Add(col);
+ }
+ }
+ }
+ }
+
+ public DataGridViewHeaderBorderStyle ColumnHeadersBorderStyle {
+ get { return columnHeadersBorderStyle; }
+ set {
+ if (columnHeadersBorderStyle != value) {
+ columnHeadersBorderStyle = value;
+ OnColumnHeadersBorderStyleChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public DataGridViewCellStyle ColumnHeadersDefaultCellStyle {
+ get { return columnHeadersDefaultCellStyle; }
+ set {
+ if (columnHeadersDefaultCellStyle != value) {
+ columnHeadersDefaultCellStyle = value;
+ OnColumnHeadersDefaultCellStyleChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public int ColumnHeadersHeight {
+ get { return columnHeadersHeight; }
+ set {
+ if (columnHeadersHeight != value) {
+ if (value < 4) {
+ throw new ArgumentException("Column headers height cant be less than 4.");
+ }
+ columnHeadersHeight = value;
+ OnColumnHeadersHeightChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public DataGridViewColumnHeadersHeightSizeMode ColumnHeadersHeightSizeMode {
+ get { return columnHeadersHeightSizeMode; }
+ set {
+ if (columnHeadersHeightSizeMode != value) {
+ if (!Enum.IsDefined(typeof(DataGridViewColumnHeadersHeightSizeMode), value)) {
+ throw new InvalidEnumArgumentException("Value is not a valid DataGridViewColumnHeadersHeightSizeMode.");
+ }
+ columnHeadersHeightSizeMode = value;
+ OnColumnHeadersHeightSizeModeChanged(new DataGridViewAutoSizeModeEventArgs(false));
+ }
+ }
+ }
+
+ public bool ColumnHeadersVisible {
+ get { return columnHeadersVisible; }
+ set { columnHeadersVisible = value; }
+ }
+
+ public DataGridViewColumnCollection Columns {
+ get { return columns; }
+ }
+
+ public DataGridViewCell CurrentCell {
+ get { return currentCell; }
+ set {
+ /////////////////////////////////////////////////////
+ /// *** InvalidOperationException ***
+ /// Changes to the specified cell cannot be committed
+ /// to the data cache, or the new cell is in a hidden
+ /// row.
+ /////////////////////////////////////////////////////
+ if (value.DataGridView != this) {
+ throw new ArgumentException("The cell is not in this DataGridView.");
+ }
+ currentCell = value;
+ }
+ }
+
+ public Point CurrentCellAddress {
+ get { return currentCellAddress; }
+ }
+
+ public DataGridViewRow CurrentRow {
+ get { return currentRow; }
+ }
+
+ public string DataMember {
+ get { return dataMember; }
+ set {
+ if (dataMember != value) {
+ dataMember = value;
+ OnDataMemberChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public object DataSource {
+ get { return dataSource; }
+ set {
+ if (dataSource != value) {
+ /* The System.Windows.Forms.DataGridView class supports the standard Windows Forms data-binding model. This means the data source can be of any type that implements:
+ - the System.Collections.IList interface, including one-dimensional arrays.
+ - the System.ComponentModel.IListSource interface, such as the System.Data.DataTable and System.Data.DataSet classes.
+ - the System.ComponentModel.IBindingList interface, such as the System.ComponentModel.Collections.BindingList<> class.
+ - the System.ComponentModel.IBindingListView interface, such as the System.Windows.Forms.BindingSource class.
+ */
+ if (!(value is IList) && !(value is IListSource) && !(value is IBindingList) && !(value is IBindingListView)) {
+ throw new NotSupportedException("Type cant be binded.");
+ }
+ dataSource = value;
+ OnDataSourceChanged(EventArgs.Empty);
+ // DataBinding
+ if (value is IList) {
+ BindIList(value as IList);
+ }
+ else if (value is IListSource) {
+ BindIListSource(value as IListSource);
+ }
+ else if (value is IBindingList) {
+ BindIBindingList(value as IBindingList);
+ }
+ else if (value is IBindingListView) {
+ BindIBindingListView(value as IBindingListView);
+ //bool cosa = ((value as IBindingListView).SortDescriptions as IList).IsFixedSize;
+ }
+ OnDataBindingComplete(new DataGridViewBindingCompleteEventArgs(ListChangedType.Reset));
+ }
+ }
+ }
+
+ public DataGridViewCellStyle DefaultCellStyle {
+ get { return defaultCellStyle; }
+ set {
+ if (defaultCellStyle != value) {
+ defaultCellStyle = value;
+ OnDefaultCellStyleChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public override Rectangle DisplayRectangle {
+ get { return base.DisplayRectangle; }
+ }
+
+ public Control EditingControl {
+ get {
+ if (currentCell == null || !currentCell.IsInEditMode) {
+ return null;
+ }
+ return (Control) Activator.CreateInstance(currentCell.EditType);
+ }
+ }
+
+ public Panel EditingPanel {
+ get { throw new NotImplementedException(); }
+ }
+
+ public DataGridViewEditMode EditMode {
+ get { return editMode; }
+ set {
+ if (editMode != value) {
+ editMode = value;
+ OnEditModeChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public bool EnableHeadersVisualStyles {
+ get { return enableHeadersVisualStyles; }
+ set { enableHeadersVisualStyles = value; }
+ }
+
+ public DataGridViewCell FirstDisplayedCell {
+ get { return firstDisplayedCell; }
+ set {
+ if (value.DataGridView != this) {
+ throw new ArgumentException("The cell is not in this DataGridView.");
+ }
+ firstDisplayedCell = value;
+ }
+ }
+
+ public int FirstDisplayedScrollingColumnHiddenWidth {
+ get { return firstDisplayedScrollingColumnHiddenWidth; }
+ }
+
+ public int FirstDisplayedScrollingColumnIndex {
+ get { return firstDisplayedScrollingColumnIndex; }
+ set { firstDisplayedScrollingColumnIndex = value; }
+ }
+
+ public int FirstDisplayedScrollingRowIndex {
+ get { return firstDisplayedScrollingRowIndex; }
+ set { firstDisplayedScrollingRowIndex = value; }
+ }
+
+ public override Font Font {
+ get { return font; }
+ set {
+ if (font != value) {
+ font = value;
+ OnFontChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public override Color ForeColor {
+ get { return foreColor; }
+ set {
+ if (foreColor != value) {
+ foreColor = value;
+ OnForeColorChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public Color GridColor {
+ get { return gridColor; }
+ set {
+ if (gridColor != value) {
+ if (value == Color.Empty) {
+ throw new ArgumentException("Cant set an Empty color.");
+ }
+ gridColor = value;
+ OnGridColorChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public int HorizontalScrollingOffset {
+ get { return horizontalScrollingOffset; }
+ set { horizontalScrollingOffset = value; }
+ }
+
+ public bool IsCurrentCellDirty {
+ get { return isCurrentCellDirty; }
+ }
+
+ public bool IsCurrentCellInEditMode {
+ get {
+ if (currentCell == null) {
+ return false;
+ }
+ return currentCell.IsInEditMode;
+ }
+ }
+
+ public bool IsCurrentRowDirty {
+ get {
+ if (!virtualMode) {
+ return IsCurrentCellDirty;
+ }
+ // Calcular
+ throw new NotImplementedException();
+ }
+ }
+
+ public DataGridViewCell this [int columnIndex, int rowIndex] {
+ get { return rows[rowIndex].Cells[columnIndex]; }
+ set { rows[rowIndex].Cells[columnIndex] = value; }
+ }
+
+ public DataGridViewCell this [string columnName, int rowIndex] {
+ get {
+ int columnIndex = -1;
+ foreach (DataGridViewColumn col in columns) {
+ if (col.Name == columnName) {
+ columnIndex = col.Index;
+ break;
+ }
+ }
+ return this[columnIndex, rowIndex];
+ }
+ set {
+ int columnIndex = -1;
+ foreach (DataGridViewColumn col in columns) {
+ if (col.Name == columnName) {
+ columnIndex = col.Index;
+ break;
+ }
+ }
+ this[columnIndex, rowIndex] = value;
+ }
+ }
+
+ public bool MultiSelect {
+ get { return multiSelect; }
+ set {
+ if (multiSelect != value) {
+ multiSelect = value;
+ OnMultiSelectChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public int NewRowIndex {
+ get {
+ if (!allowUserToAddRows) {
+ return -1;
+ }
+ return rows.Count - 1;
+ }
+ }
+
+ public new Padding Padding {
+ get { return Padding.Empty; }
+ set { }
+ }
+
+ public bool ReadOnly {
+ get { return readOnly; }
+ set {
+ if (readOnly != value) {
+ readOnly = value;
+ OnReadOnlyChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public int RowCount {
+ get { return rows.Count; }
+ set {
+ if (value < 0) {
+ throw new ArgumentException("RowCount must be >= 0.");
+ }
+ if (value < 1 && allowUserToAddRows) {
+ throw new ArgumentException("RowCount must be >= 1 if AllowUserToAddRows is true.");
+ }
+ if (dataSource != null) {
+ throw new InvalidOperationException("Cant change row count if DataSource is set.");
+ }
+ if (value < rows.Count) {
+ for (int i = value; i < rows.Count; i++) {
+ rows.RemoveAt(i);
+ }
+ }
+ else if (value > rows.Count) {
+ for (int i = 0; i < value; i++) {
+ // DataGridViewRow row = new DataGridViewRow(); //(DataGridViewRow) rowTemplate.Clone();
+ DataGridViewRow row = (DataGridViewRow) rowTemplate.Clone();
+ rows.Add(row);
+ foreach (DataGridViewColumn col in columns) {
+ row.Cells.Add(col.CellTemplate.Clone() as DataGridViewCell);
+ }
+ }
+ }
+ if (ColumnCount == 0) {
+ ///////////////////////////////////////////////////////////////
+ //columns.Add(new DataGridViewTextBoxColumn());
+ throw new NotImplementedException();
+ }
+ }
+ }
+
+ public DataGridViewHeaderBorderStyle RowHeadersBorderStyle {
+ get { return rowHeadersBorderStyle; }
+ set {
+ if (rowHeadersBorderStyle != value) {
+ rowHeadersBorderStyle = value;
+ OnRowHeadersBorderStyleChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public DataGridViewCellStyle RowHeadersDefaultCellStyle {
+ get { return rowHeadersDefaultCellStyle; }
+ set {
+ if (rowHeadersDefaultCellStyle != value) {
+ rowHeadersDefaultCellStyle = value;
+ OnRowHeadersDefaultCellStyleChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public bool RowHeadersVisible {
+ get { return rowHeadersVisible; }
+ set { rowHeadersVisible = value; }
+ }
+
+ public int RowHeadersWidth {
+ get { return rowHeadersWidth; }
+ set {
+ if (rowHeadersWidth != value) {
+ if (value < 4) {
+ throw new ArgumentException("RowHeadersWidth cant be less than 4.");
+ }
+ rowHeadersWidth = value;
+ OnRowHeadersWidthChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public DataGridViewRowHeadersWidthSizeMode RowHeadersWidthSizeMode {
+ get { return rowHeadersWidthSizeMode; }
+ set {
+ if (rowHeadersWidthSizeMode != value) {
+ if (!Enum.IsDefined(typeof(DataGridViewRowHeadersWidthSizeMode), value)) {
+ throw new InvalidEnumArgumentException("Value is not valid DataGridViewRowHeadersWidthSizeMode.");
+ }
+ rowHeadersWidthSizeMode = value;
+ OnRowHeadersWidthSizeModeChanged(new DataGridViewAutoSizeModeEventArgs(false));
+ }
+ }
+ }
+
+ public DataGridViewRowCollection Rows {
+ get { return rows; }
+ }
+
+ public DataGridViewCellStyle RowsDefaultCellStyle {
+ get { return rowsDefaultCellStyle; }
+ set {
+ if (rowsDefaultCellStyle != value) {
+ rowsDefaultCellStyle = value;
+ OnRowsDefaultCellStyleChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public DataGridViewRow RowTemplate {
+ get {
+ if (rowTemplate == null) {
+ return new DataGridViewRow();
+ }
+ return rowTemplate;
+ }
+ set {
+ rowTemplate = value;
+ rowTemplate.SetDataGridView(this);
+ }
+ }
+
+ public ScrollBars ScrollBars {
+ get { return scrollBars; }
+ set {
+ if (!Enum.IsDefined(typeof(ScrollBars), value)) {
+ throw new InvalidEnumArgumentException("Invalid ScrollBars value.");
+ }
+ ////////////////////////////////////////////////////////////
+ /// *** InvalidOperationException ***
+ /// The System.Windows.Forms.DataGridView is unable to
+ /// scroll due to a cell change that cannot be committed
+ /// or canceled.
+ ///////////////////////////////////////////////////////////
+ scrollBars = value;
+ }
+ }
+
+ public DataGridViewSelectedCellCollection SelectedCells {
+ get {
+ DataGridViewSelectedCellCollection selectedCells = new DataGridViewSelectedCellCollection();
+ foreach (DataGridViewRow row in rows) {
+ foreach (DataGridViewCell cell in row.Cells) {
+ if (cell.Selected) {
+ selectedCells.InternalAdd(cell);
+ }
+ }
+ }
+ return selectedCells;
+ }
+ }
+
+ public DataGridViewSelectedColumnCollection SelectedColumns {
+ get {
+ DataGridViewSelectedColumnCollection selectedColumns = new DataGridViewSelectedColumnCollection();
+ if (selectionMode == DataGridViewSelectionMode.FullColumnSelect || selectionMode == DataGridViewSelectionMode.ColumnHeaderSelect) {
+ foreach (DataGridViewColumn col in columns) {
+ if (col.Selected) {
+ selectedColumns.InternalAdd(col);
+ }
+ }
+ }
+ return selectedColumns;
+ }
+ }
+
+ public DataGridViewSelectedRowCollection SelectedRows {
+ get {
+ DataGridViewSelectedRowCollection selectedRows = new DataGridViewSelectedRowCollection();
+ if (selectionMode == DataGridViewSelectionMode.FullColumnSelect || selectionMode == DataGridViewSelectionMode.RowHeaderSelect) {
+ foreach (DataGridViewRow row in rows) {
+ if (row.Selected) {
+ selectedRows.InternalAdd(row);
+ }
+ }
+ }
+ return selectedRows;
+ }
+ }
+
+ public DataGridViewSelectionMode SelectionMode {
+ get { return selectionMode; }
+ set {
+ if (!Enum.IsDefined(typeof(DataGridViewSelectionMode), value)) {
+ throw new InvalidEnumArgumentException("Value is not valid DataGridViewSelectionMode.");
+ }
+ selectionMode = value;
+ }
+ }
+
+ public bool ShowCellErrors {
+ get { return showCellErrors; }
+ set { showCellErrors = value; }
+ }
+
+ public bool ShowCellToolTips {
+ get { return showCellToolTips; }
+ set { showCellToolTips = value; }
+ }
+
+ public bool ShowEditingIcon {
+ get { return showEditingIcon; }
+ set { showEditingIcon = value; }
+ }
+
+ public bool ShowRowErrors {
+ get { return showRowErrors; }
+ set { showRowErrors = value; }
+ }
+
+ public DataGridViewColumn SortedColumn {
+ get { return sortedColumn; }
+ }
+
+ public SortOrder SortOrder {
+ get { return sortOrder; }
+ }
+
+ public bool StandardTab {
+ get { return standardTab; }
+ set { standardTab = value; }
+ }
+
+ public override string Text {
+ get { return text; }
+ set { text = value; }
+ }
+
+ public DataGridViewHeaderCell TopLeftHeaderCell {
+ get { return topLeftHeaderCell; }
+ set { topLeftHeaderCell = value; }
+ }
+
+ public Cursor UserSetCursor {
+ get { return userSetCursor; }
+ }
+
+ public int VerticalScrollingOffset {
+ get { return verticalScrollingOffset; }
+ }
+
+ public bool VirtualMode {
+ get { return virtualMode; }
+ set { virtualMode = value; }
+ }
+
+ public event EventHandler AllowUserToAddRowsChanged;
+
+ public event EventHandler AllowUserToDeleteRowsChanged;
+
+ public event EventHandler AllowUserToOrderColumnsChanged;
+
+ public event EventHandler AllowUserToResizeColumnsChanged;
+
+ public event EventHandler AllowUserToResizeRowsChanged;
+
+ public event EventHandler AlternatingRowsDefaultCellStyleChanged;
+
+ public event EventHandler AutoGenerateColumnsChanged;
+
+ public new event EventHandler AutoSizeChanged;
+
+ public event DataGridViewAutoSizeColumnModeEventHandler AutoSizeColumnModeChanged;
+
+ public event DataGridViewAutoSizeColumnsModeEventHandler AutoSizeColumnsModeChanged;
+
+ public event DataGridViewAutoSizeModeEventHandler AutoSizeRowsModeChanged;
+
+ public new event EventHandler BackColorChanged;
+
+ public event EventHandler BackgroundColorChanged;
+
+ public new event EventHandler BackgroundImageChanged;
+
+ public new event EventHandler BackgroundImageLayoutChanged;
+
+ public event EventHandler BorderStyleChanged;
+
+ public event QuestionEventHandler CancelRowEdit;
+
+ public event DataGridViewCellCancelEventHandler CellBeginEdit;
+
+ public event EventHandler CellBorderStyleChanged;
+
+ public event DataGridViewCellEventHandler CellClick;
+
+ public event DataGridViewCellEventHandler CellContentClick;
+
+ public event DataGridViewCellEventHandler CellContentDoubleClick;
+
+ public event DataGridViewCellEventHandler CellContextMenuStripChanged;
+
+ public event DataGridViewCellContextMenuStripNeededEventHandler CellContextMenuStripNeeded;
+
+ public event DataGridViewCellEventHandler CellDoubleClick;
+
+ public event DataGridViewCellEventHandler CellEndEdit;
+
+ public event DataGridViewCellEventHandler CellEnter;
+
+ public event DataGridViewCellEventHandler CellErrorTextChanged;
+
+ public event DataGridViewCellErrorTextNeededEventHandler CellErrorTextNeeded;
+
+ public event DataGridViewCellFormattingEventHandler CellFormatting;
+
+ public event DataGridViewCellEventHandler CellLeave;
+
+ public event DataGridViewCellMouseEventHandler CellMouseClick;
+
+ public event DataGridViewCellMouseEventHandler CellMouseDoubleClick;
+
+ public event DataGridViewCellMouseEventHandler CellMouseDown;
+
+ public event DataGridViewCellEventHandler CellMouseEnter;
+
+ public event DataGridViewCellEventHandler CellMouseLeave;
+
+ public event DataGridViewCellMouseEventHandler CellMouseMove;
+
+ public event DataGridViewCellMouseEventHandler CellMouseUp;
+
+ public event DataGridViewCellPaintingEventHandler CellPainting;
+
+ public event DataGridViewCellParsingEventHandler CellParsing;
+
+ public event DataGridViewCellStateChangedEventHandler CellStateChanged;
+
+ public event DataGridViewCellEventHandler CellStyleChanged;
+
+ public event DataGridViewCellStyleContentChangedEventHandler CellStyleContentChanged;
+
+ public event DataGridViewCellEventHandler CellToolTipTextChanged;
+
+ public event DataGridViewCellToolTipTextNeededEventHandler CellToolTipTextNeeded;
+
+ public event DataGridViewCellEventHandler CellValidated;
+
+ public event DataGridViewCellValidatingEventHandler CellValidating;
+
+ public event DataGridViewCellEventHandler CellValueChanged;
+
+ public event DataGridViewCellValueEventHandler CellValueNeeded;
+
+ public event DataGridViewCellValueEventHandler CellValuePushed;
+
+ public event DataGridViewColumnEventHandler ColumnAdded;
+
+ public event DataGridViewColumnEventHandler ColumnContextMenuStripChanged;
+
+ public event DataGridViewColumnEventHandler ColumnDataPropertyNameChanged;
+
+ public event DataGridViewColumnEventHandler ColumnDefaultCellStyleChanged;
+
+ public event DataGridViewColumnEventHandler ColumnDisplayIndexChanged;
+
+ public event DataGridViewColumnDividerDoubleClickEventHandler ColumnDividerDoubleClick;
+
+ public event DataGridViewColumnEventHandler ColumnDividerWidthChanged;
+
+ public event DataGridViewColumnEventHandler ColumnHeaderCellChanged;
+
+ public event DataGridViewCellMouseEventHandler ColumnHeaderMouseClick;
+
+ public event DataGridViewCellMouseEventHandler ColumnHeaderMouseDoubleClick;
+
+ public event EventHandler ColumnHeadersBorderStyleChanged;
+
+ public event EventHandler ColumnHeadersDefaultCellStyleChanged;
+
+ public event EventHandler ColumnHeadersHeightChanged;
+
+ public event DataGridViewAutoSizeModeEventHandler ColumnHeadersHeightSizeModeChanged;
+
+ public event DataGridViewColumnEventHandler ColumnMinimumWidthChanged;
+
+ public event DataGridViewColumnEventHandler ColumnNameChanged;
+
+ public event DataGridViewColumnEventHandler ColumnRemoved;
+
+ public event DataGridViewColumnEventHandler ColumnSortModeChanged;
+
+ public event DataGridViewColumnStateChangedEventHandler ColumnStateChanged;
+
+ public event DataGridViewColumnEventHandler ColumnToolTipTextChanged;
+
+ public event DataGridViewColumnEventHandler ColumnWidthChanged;
+
+ public event EventHandler CurrentCellChanged;
+
+ public event EventHandler CurrentCellDirtyStateChanged;
+
+ public event DataGridViewBindingCompleteEventHandler DataBindingComplete;
+
+ public event DataGridViewDataErrorEventHandler DataError;
+
+ public event EventHandler DataMemberChanged;
+
+ public event EventHandler DataSourceChanged;
+
+ public event EventHandler DefaultCellStyleChanged;
+
+ public event DataGridViewRowEventHandler DefaultValuesNeeded;
+
+ public event DataGridViewEditingControlShowingEventHandler EditingControlShowing;
+
+ public event EventHandler EditModeChanged;
+
+ public new event EventHandler FontChanged;
+
+ public new event EventHandler ForeColorChanged;
+
+ public event EventHandler GridColorChanged;
+
+ public event EventHandler MultiSelectChanged;
+
+ public event DataGridViewRowEventHandler NewRowNeeded;
+
+ public event EventHandler ReadOnlyChanged;
+
+ public event DataGridViewRowEventHandler RowContextMenuStripChanged;
+
+ public event DataGridViewRowContextMenuStripNeededEventHandler RowContextMenuStripNeeded;
+
+ public event DataGridViewRowEventHandler RowDefaultCellStyleChanged;
+
+ public event QuestionEventHandler RowDirtyStateNeeded;
+
+ public event DataGridViewRowDividerDoubleClickEventHandler RowDividerDoubleClick;
+
+ public event DataGridViewRowEventHandler RowDividerHeightChanged;
+
+ public event DataGridViewCellEventHandler RowEnter;
+
+ public event DataGridViewRowEventHandler RowErrorTextChanged;
+
+ public event DataGridViewRowErrorTextNeededEventHandler RowErrorTextNeeded;
+
+ public event DataGridViewRowEventHandler RowHeaderCellChanged;
+
+ public event DataGridViewCellMouseEventHandler RowHeaderMouseClick;
+
+ public event DataGridViewCellMouseEventHandler RowHeaderMouseDoubleClick;
+
+ public event EventHandler RowHeadersBorderStyleChanged;
+
+ public event EventHandler RowHeadersDefaultCellStyleChanged;
+
+ public event EventHandler RowHeadersWidthChanged;
+
+ public event DataGridViewAutoSizeModeEventHandler RowHeadersWidthSizeModeChanged;
+
+ public event DataGridViewRowEventHandler RowHeightChanged;
+
+ public event DataGridViewRowHeightInfoNeededEventHandler RowHeightInfoNeeded;
+
+ public event DataGridViewRowHeightInfoPushedEventHandler RowHeightInfoPushed;
+
+ public event DataGridViewCellEventHandler RowLeave;
+
+ public event DataGridViewRowEventHandler RowMinimumHeightChanged;
+
+ public event DataGridViewRowPostPaintEventHandler RowPostPaint;
+
+ public event DataGridViewRowPrePaintEventHandler RowPrePaint;
+
+ public event DataGridViewRowsAddedEventHandler RowsAdded;
+
+ public event EventHandler RowsDefaultCellStyleChanged;
+
+ public event DataGridViewRowsRemovedEventHandler RowsRemoved;
+
+ public event DataGridViewRowStateChangedEventHandler RowStateChanged;
+
+ public event DataGridViewRowEventHandler RowUnshared;
+
+ public event DataGridViewCellEventHandler RowValidated;
+
+ public event DataGridViewCellCancelEventHandler RowValidating;
+
+ public event ScrollEventHandler Scroll;
+
+ public event EventHandler SelectionChanged;
+
+ public event DataGridViewSortCompareEventHandler SortCompare;
+
+ public event EventHandler Sorted;
+
+ public event DataGridViewRowEventHandler UserAddedRow;
+
+ public event DataGridViewRowEventHandler UserDeletedRow;
+
+ public event DataGridViewRowCancelEventHandler UserDeletingRow;
+
+ public new event EventHandler StyleChanged;
+
+ public new event EventHandler TextChanged;
+
+ public virtual DataGridViewAdvancedBorderStyle AdjustColumnHeaderBorderStyle (DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput, DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder, bool isFirstDisplayedColumn, bool isLastVisibleColumn) {
+ return (DataGridViewAdvancedBorderStyle) dataGridViewAdvancedBorderStyleInput.Clone();
+ }
+
+ public bool AreAllCellsSelected (bool includeInvisibleCells) {
+ foreach (DataGridViewRow row in rows) {
+ foreach (DataGridViewCell cell in row.Cells) {
+ if (includeInvisibleCells == false && cell.Visible == false) {
+ continue;
+ }
+ if (!cell.Selected) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ public void AutoResizeColumn (int columnIndex) {
+ throw new NotImplementedException();
+ }
+
+ public void AutoResizeColumn (int columnIndex, DataGridViewAutoSizeColumnMode autoSizeColumnMode) {
+ throw new NotImplementedException();
+ }
+
+ public void AutoResizeColumnHeadersHeight () {
+ throw new NotImplementedException();
+ }
+
+ public void AutoResizeColumnHeadersHeight (int columnIndex) {
+ throw new NotImplementedException();
+ }
+
+ public void AutoResizeColumns () {
+ throw new NotImplementedException();
+ }
+
+ public void AutoResizeColumns (DataGridViewAutoSizeColumnsMode autoSizeColumnsMode) {
+ throw new NotImplementedException();
+ }
+
+ public void AutoResizeRow (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ public void AutoResizeRow (int rowIndex, DataGridViewAutoSizeRowMode autoSizeRowMode) {
+ throw new NotImplementedException();
+ }
+
+ public void AutoResizeRowHeadersWidth (DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode) {
+ throw new NotImplementedException();
+ }
+
+ public void AutoResizeRowHeadersWidth (int rowIndex, DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode) {
+ throw new NotImplementedException();
+ }
+
+ public void AutoResizeRows () {
+ throw new NotImplementedException();
+ }
+
+ public void AutoResizeRows (DataGridViewAutoSizeRowsMode autoSizeRowsMode) {
+ if (!Enum.IsDefined(typeof(DataGridViewAutoSizeRowsMode), autoSizeRowsMode)) {
+ throw new InvalidEnumArgumentException("Parameter AutoSizeRowsMode is not valid DataGridViewRowsMode.");
+ }
+ if ((autoSizeRowsMode == DataGridViewAutoSizeRowsMode.AllHeaders || autoSizeRowsMode == DataGridViewAutoSizeRowsMode.DisplayedHeaders) && rowHeadersVisible == false) {
+ throw new InvalidOperationException("Parameter AutoSizeRowsMode cant be AllHeaders or DisplayedHeaders in this DataGridView.");
+ }
+ if (autoSizeRowsMode == DataGridViewAutoSizeRowsMode.None) {
+ throw new ArgumentException("Parameter AutoSieRowsMode cant be None.");
+ }
+ }
+
+ public virtual bool BeginEdit (bool selectAll) {
+ throw new NotImplementedException();
+ }
+
+ public bool CancelEdit () {
+ throw new NotImplementedException();
+ }
+
+ public void ClearSelection () {
+ foreach (DataGridViewCell cell in SelectedCells) {
+ cell.Selected = false;
+ }
+ }
+
+ public bool CommitEdit (DataGridViewDataErrorContexts context) {
+ throw new NotImplementedException();
+ }
+
+ public int DisplayedColumnCount (bool includePartialColumns) {
+ /////////////////////// PartialColumns?
+ int result = 0;
+ foreach (DataGridViewColumn col in columns) {
+ if (col.Visible) {
+ result++;
+ }
+ }
+ return result;
+ }
+
+ public int DisplayedRowCount (bool includePartialRow) {
+ /////////////////////// PartialRows?
+ int result = 0;
+ foreach (DataGridViewRow row in rows) {
+ if (row.Visible) {
+ result++;
+ }
+ }
+ return result;
+ }
+
+ public bool EndEdit () {
+ throw new NotImplementedException();
+ }
+
+ public bool EndEdit (DataGridViewDataErrorContexts context) {
+ throw new NotImplementedException();
+ }
+
+ public int GetCellCount (DataGridViewElementStates includeFilter) {
+ int result = 0;
+ foreach (DataGridViewRow row in rows) {
+ foreach (DataGridViewCell cell in row.Cells) {
+ if ((cell.State & includeFilter) != 0) {
+ result++;
+ }
+ }
+ }
+ return result;
+ }
+
+ public Rectangle GetCellDisplayRectangle (int columnIndex, int rowIndex, bool cutOverflow) {
+ if (columnIndex < 0 || columnIndex >= columns.Count) {
+ throw new ArgumentOutOfRangeException("Column index is out of range.");
+ }
+ throw new NotImplementedException();
+ }
+
+ public virtual DataObject GetClipboardContent () {
+ throw new NotImplementedException();
+ }
+
+ public Rectangle GetColumnDisplayRectangle (int columnIndex, bool cutOverflow) {
+ throw new NotImplementedException();
+ }
+
+ public Rectangle GetRowDisplayRectangle (int rowIndex, bool cutOverflow) {
+ throw new NotImplementedException();
+ }
+
+ public HitTestInfo HitTest (int x, int y) {
+ ///////////////////////////////////////////////////////
+ x += horizontalScrollingOffset;
+ y += verticalScrollingOffset;
+ int rowIndex = -1;
+ int totalHeight = (columnHeadersVisible)? 1 + columnHeadersHeight : 1;
+ if (columnHeadersVisible && y <= totalHeight) {
+ rowIndex = -1;
+ }
+ else {
+ foreach (DataGridViewRow row in rows.RowIndexSortedArrayList) {
+ totalHeight += row.Height;
+ if (y <= totalHeight) {
+ rowIndex = row.Index;
+ break;
+ }
+ totalHeight++; // sumar el ancho de las lineas...
+ }
+ }
+ int colIndex = -1;
+ int totalWidth = (rowHeadersVisible)? 1 + rowHeadersWidth : 1;
+ if (rowHeadersVisible && x <= totalWidth) {
+ colIndex = -1;
+ }
+ else {
+ foreach (DataGridViewColumn col in columns.ColumnDisplayIndexSortedArrayList) {
+ totalWidth += col.Width;
+ if (x <= totalWidth) {
+ colIndex = col.Index;
+ break;
+ }
+ totalWidth++;
+ }
+ }
+ HitTestInfo result = new HitTestInfo(colIndex, x, rowIndex, y, (colIndex >= 0 && rowIndex >= 0)? DataGridViewHitTestType.Cell : DataGridViewHitTestType.None);
+ return result;
+ }
+
+ public void InvalidateCell (DataGridViewCell dataGridViewCell) {
+ if (dataGridViewCell == null) {
+ throw new ArgumentNullException("Cell is null");
+ }
+ if (dataGridViewCell.DataGridView != this) {
+ throw new ArgumentException("The specified cell does not belong to this DataGridView.");
+ }
+ throw new NotImplementedException();
+ }
+
+ public void InvalidateCell (int columnIndex, int rowIndex) {
+ if (columnIndex < 0 || columnIndex >= columns.Count) {
+ throw new ArgumentOutOfRangeException("Column index is out of range.");
+ }
+ if (rowIndex < 0 || rowIndex >= rows.Count) {
+ throw new ArgumentOutOfRangeException("Row index is out of range.");
+ }
+ foreach (DataGridViewRow row in rows) {
+ foreach (DataGridViewCell cell in row.Cells) {
+ if (cell.RowIndex == rowIndex && cell.ColumnIndex == columnIndex) {
+ InvalidateCell(cell); //// O al revés, que el otro llame a este !!!
+ return;
+ }
+ }
+ }
+ }
+
+ public void InvalidateColumn (int columnIndex) {
+ if (columnIndex < 0 || columnIndex >= columns.Count) {
+ throw new ArgumentOutOfRangeException("Column index is out of range.");
+ }
+ throw new NotImplementedException();
+ }
+
+ public void InvalidateRow (int rowIndex) {
+ if (rowIndex < 0 || rowIndex >= rows.Count) {
+ throw new ArgumentOutOfRangeException("Row index is out of range.");
+ }
+ throw new NotImplementedException();
+ }
+
+ public virtual void NotifyCurrentCellDirty (bool dirty) {
+ throw new NotImplementedException();
+ }
+
+ public bool RefreshEdit () {
+ throw new NotImplementedException();
+ }
+
+ public override void ResetText () {
+ throw new NotImplementedException();
+ }
+
+ public void SelectAll () {
+ switch (selectionMode) {
+ case DataGridViewSelectionMode.FullRowSelect:
+ foreach (DataGridViewRow row in rows) {
+ (row as DataGridViewBand).Selected = true;
+ }
+ break;
+ case DataGridViewSelectionMode.FullColumnSelect:
+ foreach (DataGridViewColumn col in columns) {
+ (col as DataGridViewBand).Selected = true;
+ }
+ break;
+ default:
+ foreach (DataGridViewRow row in rows) {
+ foreach (DataGridViewCell cell in row.Cells) {
+ cell.Selected = true;
+ }
+ }
+ break;
+ }
+ }
+
+ public virtual void Sort (IComparer comparer) {
+ throw new NotImplementedException();
+ }
+
+ public virtual void Sort (DataGridViewColumn dataGridViewColumn, ListSortDirection direction) {
+ throw new NotImplementedException();
+ }
+
+ public void UpdateCellErrorText (int columnIndex, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ public void UpdateRowErrorText (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ public void UpdateRowErrorText (int rowIndexStart, int rowIndexEnd) {
+ throw new NotImplementedException();
+ }
+
+ public void UpdateRowHeightInfo (int rowIndex, bool updateToEnd) {
+ throw new NotImplementedException();
+ }
+
+ protected override Size DefaultSize {
+ get { return defaultSize; }
+ }
+
+ protected ScrollBar HorizontalScrollBar {
+ get { return horizontalScrollBar; }
+ }
+
+ protected ScrollBar VerticalScrollBar {
+ get { return verticalScrollBar; }
+ }
+
+ protected void AutoResizeColumn (int columnIndex, DataGridViewAutoSizeColumnMode autoSizeColumnMode, bool fixedHeight) {
+ throw new NotImplementedException();
+ }
+
+ protected void AutoResizeColumnHeadersHeight (bool fixedRowHeadersWidth, bool fixedColumnsWidth) {
+ throw new NotImplementedException();
+ }
+
+ protected void AutoResizeColumnHeadersHeight (int columnIndex, bool fixedRowHeadersWidth, bool fixedColumnWidth) {
+ throw new NotImplementedException();
+ }
+
+ protected void AutoResizeColumns (DataGridViewAutoSizeColumnsMode autoSizeColumnsMode, bool fixedHeight) {
+ throw new NotImplementedException();
+ }
+
+ protected void AutoResizeRow (int rowIndex, DataGridViewAutoSizeRowMode autoSizeRowMode, bool fixedWidth) {
+ throw new NotImplementedException();
+ }
+
+ protected void AutoResizeRowHeadersWidth (DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode, bool fixedColumnHeadersHeight, bool fixedRowsHeight) {
+ throw new NotImplementedException();
+ }
+
+ protected void AutoResizeRowHeadersWidth (int rowIndex, DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode, bool fixedColumnHeadersHeight, bool fixedRowHeight) {
+ throw new NotImplementedException();
+ }
+
+ protected void AutoResizeRows (DataGridViewAutoSizeRowsMode autoSizeRowsMode, bool fixedWidth) {
+ throw new NotImplementedException();
+ }
+
+ protected void AutoResizeRows (int rowIndexStart, int rowsCount, DataGridViewAutoSizeRowMode autoSizeRowMode, bool fixedWidth) {
+ throw new NotImplementedException();
+ }
+
+ protected void ClearSelection (int columnIndexException, int rowIndexException, bool selectExceptionElement) {
+ if (columnIndexException >= columns.Count) {
+ throw new ArgumentOutOfRangeException("ColumnIndexException is greater than the highest column index.");
+ }
+ if (selectionMode == DataGridViewSelectionMode.FullRowSelect) {
+ if (columnIndexException < -1) {
+ throw new ArgumentOutOfRangeException("ColumnIndexException is less than -1.");
+ }
+ }
+ else {
+ if (columnIndexException < 0) {
+ throw new ArgumentOutOfRangeException("ColumnIndexException is less than 0.");
+ }
+ }
+ if (rowIndexException >= rows.Count) {
+ throw new ArgumentOutOfRangeException("RowIndexException is greater than the highest row index.");
+ }
+ if (selectionMode == DataGridViewSelectionMode.FullColumnSelect) {
+ if (rowIndexException < -1) {
+ throw new ArgumentOutOfRangeException("RowIndexException is less than -1.");
+ }
+ }
+ else {
+ if (rowIndexException < 0) {
+ throw new ArgumentOutOfRangeException("RowIndexException is less than 0.");
+ }
+ }
+ switch (selectionMode) {
+ case DataGridViewSelectionMode.FullRowSelect:
+ foreach (DataGridViewRow row in rows) {
+ if (selectExceptionElement && row.Index == rowIndexException) {
+ continue;
+ }
+ row.Selected = false;
+ }
+ break;
+ case DataGridViewSelectionMode.FullColumnSelect:
+ foreach (DataGridViewColumn col in columns) {
+ if (selectExceptionElement && col.Index == columnIndexException) {
+ continue;
+ }
+ col.Selected = false;
+ }
+ break;
+ default:
+ foreach (DataGridViewCell cell in SelectedCells) {
+ if (selectExceptionElement && cell.RowIndex == rowIndexException && cell.ColumnIndex == columnIndexException) {
+ continue;
+ }
+ cell.Selected = false;
+ }
+ break;
+ }
+ }
+
+ protected override AccessibleObject CreateAccessibilityInstance () {
+ return new DataGridViewAccessibleObject(this);
+ }
+
+ protected virtual DataGridViewColumnCollection CreateColumnsInstance () {
+ return new DataGridViewColumnCollection(this);
+ }
+
+ protected override Control.ControlCollection CreateControlsInstance () {
+ return base.CreateControlsInstance(); //new Control.ControlCollection(this);
+ }
+
+ protected virtual DataGridViewRowCollection CreateRowsInstance () {
+ return new DataGridViewRowCollection(this);
+ }
+
+ protected override void Dispose (bool disposing) {
+ }
+
+ //protected override AccessibleObject GetAccessibilityObjectById (int objectId) {
+ protected AccessibleObject GetAccessibilityObjectById (int objectId) {
+ throw new NotImplementedException();
+ }
+
+ protected override bool IsInputChar (char charCode) {
+ return base.IsInputChar(charCode);
+ //throw new NotImplementedException();
+ }
+
+ protected override bool IsInputKey (Keys keyData) {
+ return base.IsInputKey(keyData);
+ //throw new NotImplementedException();
+ }
+
+ protected virtual void OnAllowUserToAddRowsChanged (EventArgs e) {
+ if (AllowUserToAddRowsChanged != null) {
+ AllowUserToAddRowsChanged(this, e);
+ }
+ }
+
+ protected virtual void OnAllowUserToDeleteRowsChanged (EventArgs e) {
+ if (AllowUserToDeleteRowsChanged != null) {
+ AllowUserToDeleteRowsChanged(this, e);
+ }
+ }
+
+ protected virtual void OnAllowUserToOrderColumnsChanged (EventArgs e) {
+ if (AllowUserToOrderColumnsChanged != null) {
+ AllowUserToOrderColumnsChanged(this, e);
+ }
+ }
+
+ protected virtual void OnAllowUserToResizeColumnsChanged (EventArgs e) {
+ if (AllowUserToResizeColumnsChanged != null) {
+ AllowUserToResizeColumnsChanged(this, e);
+ }
+ }
+
+ protected virtual void OnAllowUserToResizeRowsChanged (EventArgs e) {
+ if (AllowUserToResizeRowsChanged != null) {
+ AllowUserToResizeRowsChanged(this, e);
+ }
+ }
+
+ protected virtual void OnAlternatingRowsDefaultCellStyleChanged (EventArgs e) {
+ if (AlternatingRowsDefaultCellStyleChanged != null) {
+ AlternatingRowsDefaultCellStyleChanged(this, e);
+ }
+ }
+
+ protected virtual void OnAutoGenerateColumnsChanged (EventArgs e) {
+ if (AutoGenerateColumnsChanged != null) {
+ AutoGenerateColumnsChanged(this, e);
+ }
+ }
+
+ protected virtual void OnAutoSizeColumnModeChanged (DataGridViewAutoSizeColumnModeEventArgs e) {
+ if (AutoSizeColumnModeChanged != null) {
+ AutoSizeColumnModeChanged(this, e);
+ }
+ }
+
+ protected virtual void OnAutoSizeColumnsModeChanged (DataGridViewAutoSizeColumnsModeEventArgs e) {
+ if (AutoSizeColumnsModeChanged != null) {
+ AutoSizeColumnsModeChanged(this, e);
+ }
+ }
+
+ protected virtual void OnAutoSizeRowsModeChanged (DataGridViewAutoSizeModeEventArgs e) {
+ if (AutoSizeRowsModeChanged != null) {
+ AutoSizeRowsModeChanged(this, e);
+ }
+ }
+
+ protected virtual void OnBackgroundColorChanged (EventArgs e) {
+ if (BackgroundColorChanged != null) {
+ BackgroundColorChanged(this, e);
+ }
+ }
+
+ protected override void OnBindingContextChanged (EventArgs e) {
+ base.OnBindingContextChanged(e);
+ }
+
+ protected virtual void OnBorderStyleChanged (EventArgs e) {
+ if (BorderStyleChanged != null) {
+ BorderStyleChanged(this, e);
+ }
+ }
+
+ protected virtual void OnCancelRowEdit (QuestionEventArgs e) {
+ if (CancelRowEdit != null) {
+ CancelRowEdit(this, e);
+ }
+ }
+
+ protected virtual void OnCellBeginEdit (DataGridViewCellCancelEventArgs e) {
+ if (CellBeginEdit != null) {
+ CellBeginEdit(this, e);
+ }
+ }
+
+ protected virtual void OnCellBorderStyleChanged (EventArgs e) {
+ if (CellBorderStyleChanged != null) {
+ CellBorderStyleChanged(this, e);
+ }
+ }
+
+ protected virtual void OnCellClick (DataGridViewCellEventArgs e) {
+ if (CellClick != null) {
+ CellClick(this, e);
+ }
+ }
+
+ protected virtual void OnCellContentClick (DataGridViewCellEventArgs e) {
+ if (CellContentClick != null) {
+ CellContentClick(this, e);
+ }
+ }
+
+ protected virtual void OnCellContentDoubleClick (DataGridViewCellEventArgs e) {
+ if (CellContentDoubleClick != null) {
+ CellContentDoubleClick(this, e);
+ }
+ }
+
+ protected virtual void OnCellContextMenuStripChanged (DataGridViewCellEventArgs e) {
+ if (CellContextMenuStripChanged != null) {
+ CellContextMenuStripChanged(this, e);
+ }
+ }
+
+ protected virtual void OnCellContextMenuStripNeeded (DataGridViewCellContextMenuStripNeededEventArgs e) {
+ if (CellContextMenuStripNeeded != null) {
+ CellContextMenuStripNeeded(this, e);
+ }
+ }
+
+ protected virtual void OnCellDoubleClick (DataGridViewCellEventArgs e) {
+ if (CellDoubleClick != null) {
+ CellDoubleClick(this, e);
+ }
+ }
+
+ protected virtual void OnCellEndEdit (DataGridViewCellEventArgs e) {
+ if (CellEndEdit != null) {
+ CellEndEdit(this, e);
+ }
+ }
+
+ protected virtual void OnCellEnter (DataGridViewCellEventArgs e) {
+ if (CellEnter != null) {
+ CellEnter(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnCellErrorTextChanged (DataGridViewCellEventArgs e) {
+ if (CellErrorTextChanged != null) {
+ CellErrorTextChanged(this, e);
+ }
+ }
+
+ protected virtual void OnCellErrorTextNeeded (DataGridViewCellErrorTextNeededEventArgs e) {
+ if (CellErrorTextNeeded != null) {
+ CellErrorTextNeeded(this, e);
+ }
+ }
+
+ protected virtual void OnCellFormatting (DataGridViewCellFormattingEventArgs e) {
+ if (CellFormatting != null) {
+ CellFormatting(this, e);
+ }
+ }
+
+ protected virtual void OnCellLeave (DataGridViewCellEventArgs e) {
+ if (CellLeave != null) {
+ CellLeave(this, e);
+ }
+ }
+
+ protected virtual void OnCellMouseClick (DataGridViewCellMouseEventArgs e) {
+ if (CellMouseClick != null) {
+ CellMouseClick(this, e);
+ }
+ }
+
+ protected virtual void OnCellMouseDoubleClick (DataGridViewCellMouseEventArgs e) {
+ if (CellMouseDoubleClick != null) {
+ CellMouseDoubleClick(this, e);
+ }
+ }
+
+ protected virtual void OnCellMouseDown (DataGridViewCellMouseEventArgs e) {
+ if (CellMouseDown != null) {
+ CellMouseDown(this, e);
+ }
+ }
+
+ protected virtual void OnCellMouseEnter (DataGridViewCellEventArgs e) {
+ if (CellMouseEnter != null) {
+ CellMouseEnter(this, e);
+ }
+ }
+
+ protected virtual void OnCellMouseLeave (DataGridViewCellEventArgs e) {
+ if (CellMouseLeave != null) {
+ CellMouseLeave(this, e);
+ }
+ }
+
+ protected virtual void OnCellMouseMove (DataGridViewCellMouseEventArgs e) {
+ if (CellMouseMove != null) {
+ CellMouseMove(this, e);
+ }
+ }
+
+ protected virtual void OnCellMouseUp (DataGridViewCellMouseEventArgs e) {
+ if (CellMouseUp != null) {
+ CellMouseUp(this, e);
+ }
+ }
+
+ protected virtual void OnCellPainting (DataGridViewCellPaintingEventArgs e) {
+ if (CellPainting != null) {
+ CellPainting(this, e);
+ }
+ }
+
+ protected internal virtual void OnCellParsing (DataGridViewCellParsingEventArgs e) {
+ if (CellParsing != null) {
+ CellParsing(this, e);
+ }
+ }
+
+ protected virtual void OnCellStateChanged (DataGridViewCellStateChangedEventArgs e) {
+ if (CellStateChanged != null) {
+ CellStateChanged(this, e);
+ }
+ }
+
+ protected virtual void OnCellStyleChanged (DataGridViewCellEventArgs e) {
+ if (CellStyleChanged != null) {
+ CellStyleChanged(this, e);
+ }
+ }
+
+ protected virtual void OnCellStyleContentChanged (DataGridViewCellStyleContentChangedEventArgs e) {
+ if (CellStyleContentChanged != null) {
+ CellStyleContentChanged(this, e);
+ }
+ }
+
+ protected virtual void OnCellToolTipTextChanged (DataGridViewCellEventArgs e) {
+ if (CellToolTipTextChanged != null) {
+ CellToolTipTextChanged(this, e);
+ }
+ }
+
+ protected virtual void OnCellToolTipTextNeeded (DataGridViewCellToolTipTextNeededEventArgs e) {
+ if (CellToolTipTextNeeded != null) {
+ CellToolTipTextNeeded(this, e);
+ }
+ }
+
+ protected virtual void OnCellValidated (DataGridViewCellEventArgs e) {
+ if (CellValidated != null) {
+ CellValidated(this, e);
+ }
+ }
+
+ protected virtual void OnCellValidating (DataGridViewCellValidatingEventArgs e) {
+ if (CellValidating != null) {
+ CellValidating(this, e);
+ }
+ }
+
+ protected virtual void OnCellValueChanged (DataGridViewCellEventArgs e) {
+ if (CellValueChanged != null) {
+ CellValueChanged(this, e);
+ }
+ }
+
+ protected virtual void OnCellValueNeeded (DataGridViewCellValueEventArgs e) {
+ if (CellValueNeeded != null) {
+ CellValueNeeded(this, e);
+ }
+ }
+
+ protected virtual void OnCellValuePushed (DataGridViewCellValueEventArgs e) {
+ if (CellValuePushed != null) {
+ CellValuePushed(this, e);
+ }
+ }
+
+ protected virtual void OnColumnAdded (DataGridViewColumnEventArgs e) {
+ if (ColumnAdded != null) {
+ ColumnAdded(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnColumnContextMenuStripChanged (DataGridViewColumnEventArgs e) {
+ if (ColumnContextMenuStripChanged != null) {
+ ColumnContextMenuStripChanged(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnColumnDataPropertyNameChanged (DataGridViewColumnEventArgs e) {
+ if (ColumnDataPropertyNameChanged != null) {
+ ColumnDataPropertyNameChanged(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnColumnDefaultCellStyleChanged (DataGridViewColumnEventArgs e) {
+ if (ColumnDefaultCellStyleChanged != null) {
+ ColumnDefaultCellStyleChanged(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnColumnDisplayIndexChanged (DataGridViewColumnEventArgs e) {
+ if (ColumnDisplayIndexChanged != null) {
+ ColumnDisplayIndexChanged(this, e);
+ }
+ }
+
+ protected virtual void OnColumnDividerDoubleClick (DataGridViewColumnDividerDoubleClickEventArgs e) {
+ if (ColumnDividerDoubleClick != null) {
+ ColumnDividerDoubleClick(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnColumnDividerWidthChanged (DataGridViewColumnEventArgs e) {
+ if (ColumnDividerWidthChanged != null) {
+ ColumnDividerWidthChanged(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnColumnHeaderCellChanged (DataGridViewColumnEventArgs e) {
+ if (ColumnHeaderCellChanged != null) {
+ ColumnHeaderCellChanged(this, e);
+ }
+ }
+
+ protected virtual void OnColumnHeaderMouseClick (DataGridViewCellMouseEventArgs e) {
+ if (ColumnHeaderMouseClick != null) {
+ ColumnHeaderMouseClick(this, e);
+ }
+ }
+
+ protected virtual void OnColumnHeaderMouseDoubleClick (DataGridViewCellMouseEventArgs e) {
+ if (ColumnHeaderMouseDoubleClick != null) {
+ ColumnHeaderMouseDoubleClick(this, e);
+ }
+ }
+
+ protected virtual void OnColumnHeadersBorderStyleChanged (EventArgs e) {
+ if (ColumnHeadersBorderStyleChanged != null) {
+ ColumnHeadersBorderStyleChanged(this, e);
+ }
+ }
+
+ protected virtual void OnColumnHeadersDefaultCellStyleChanged (EventArgs e) {
+ if (ColumnHeadersDefaultCellStyleChanged != null) {
+ ColumnHeadersDefaultCellStyleChanged(this, e);
+ }
+ }
+
+ protected virtual void OnColumnHeadersHeightChanged (EventArgs e) {
+ if (ColumnHeadersHeightChanged != null) {
+ ColumnHeadersHeightChanged(this, e);
+ }
+ }
+
+ protected virtual void OnColumnHeadersHeightSizeModeChanged (DataGridViewAutoSizeModeEventArgs e) {
+ if (ColumnHeadersHeightSizeModeChanged != null) {
+ ColumnHeadersHeightSizeModeChanged(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnColumnMinimumWidthChanged (DataGridViewColumnEventArgs e) {
+ if (ColumnMinimumWidthChanged != null) {
+ ColumnMinimumWidthChanged(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnColumnNameChanged (DataGridViewColumnEventArgs e) {
+ if (ColumnNameChanged != null) {
+ ColumnNameChanged(this, e);
+ }
+ }
+
+ protected virtual void OnColumnRemoved (DataGridViewColumnEventArgs e) {
+ if (ColumnRemoved != null) {
+ ColumnRemoved(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnColumnSortModeChanged (DataGridViewColumnEventArgs e) {
+ if (ColumnSortModeChanged != null) {
+ ColumnSortModeChanged(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnColumnStateChanged (DataGridViewColumnStateChangedEventArgs e) {
+ if (ColumnStateChanged != null) {
+ ColumnStateChanged(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnColumnToolTipTextChanged (DataGridViewColumnEventArgs e) {
+ if (ColumnToolTipTextChanged != null) {
+ ColumnToolTipTextChanged(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnColumnWidthChanged (DataGridViewColumnEventArgs e) {
+ if (ColumnWidthChanged != null) {
+ ColumnWidthChanged(this, e);
+ }
+ }
+
+ protected virtual void OnCurrentCellChanged (EventArgs e) {
+ if (CurrentCellChanged != null) {
+ CurrentCellChanged(this, e);
+ }
+ }
+
+ protected virtual void OnCurrentCellDirtyStateChanged (EventArgs e) {
+ if (CurrentCellDirtyStateChanged != null) {
+ CurrentCellDirtyStateChanged(this, e);
+ }
+ }
+
+ protected virtual void OnDataBindingComplete (DataGridViewBindingCompleteEventArgs e) {
+ if (DataBindingComplete != null) {
+ DataBindingComplete(this, e);
+ }
+ }
+
+ protected virtual void OnDataError (bool displayErrorDialogIfNoHandler, DataGridViewDataErrorEventArgs e) {
+ if (DataError != null) {
+ DataError(this, e);
+ }
+ else {
+ if (displayErrorDialogIfNoHandler) {
+ /////////////////////////////////// ERROR DIALOG //////////////////////////////////7
+ }
+ }
+ }
+ protected virtual void OnDataMemberChanged (EventArgs e) {
+ if (DataMemberChanged != null) {
+ DataMemberChanged(this, e);
+ }
+ }
+
+ protected virtual void OnDataSourceChanged (EventArgs e) {
+ if (DataSourceChanged != null) {
+ DataSourceChanged(this, e);
+ }
+ }
+
+ protected virtual void OnDefaultCellStyleChanged (EventArgs e) {
+ if (DefaultCellStyleChanged != null) {
+ DefaultCellStyleChanged(this, e);
+ }
+ }
+
+ protected virtual void OnDefaultValuesNeeded (DataGridViewRowEventArgs e) {
+ if (DefaultValuesNeeded != null) {
+ DefaultValuesNeeded(this, e);
+ }
+ }
+
+ protected override void OnDoubleClick (EventArgs e) {
+ base.OnDoubleClick(e);
+ }
+
+ protected virtual void OnEditingControlShowing (DataGridViewEditingControlShowingEventArgs e) {
+ if (EditingControlShowing != null) {
+ EditingControlShowing(this, e);
+ }
+ }
+
+ protected virtual void OnEditModeChanged (EventArgs e) {
+ if (EditModeChanged != null) {
+ EditModeChanged(this, e);
+ }
+ }
+
+ protected override void OnEnabledChanged (EventArgs e) {
+ base.OnEnabledChanged(e);
+ }
+
+ protected override void OnEnter (EventArgs e ) {
+ base.OnEnter(e);
+ }
+
+ protected override void OnFontChanged (EventArgs e) {
+ base.OnFontChanged(e);
+ if (FontChanged != null) {
+ FontChanged(this, e);
+ }
+ }
+
+ protected override void OnForeColorChanged (EventArgs e) {
+ base.OnForeColorChanged(e);
+ if (ForeColorChanged != null) {
+ ForeColorChanged(this, e);
+ }
+ }
+
+ protected virtual void OnGridColorChanged (EventArgs e) {
+ if (GridColorChanged != null) {
+ GridColorChanged(this, e);
+ }
+ }
+
+ protected override void OnHandleCreated (EventArgs e) {
+ base.OnHandleCreated(e);
+ }
+
+ protected override void OnKeyDown (KeyEventArgs e) {
+ base.OnKeyDown(e);
+ }
+
+ protected override void OnKeyPress (KeyPressEventArgs e) {
+ base.OnKeyPress(e);
+ }
+
+ protected override void OnKeyUp (KeyEventArgs e) {
+ base.OnKeyUp(e);
+ }
+
+ protected override void OnLayout (LayoutEventArgs e) {
+ base.OnLayout(e);
+ }
+
+ protected override void OnLeave (EventArgs e) {
+ base.OnLeave(e);
+ }
+
+ //protected override void OnMouseClick (MouseEventArgs e) {
+ protected void OnMouseClick (MouseEventArgs e) {
+ //base.OnMouseClick(e);
+ //Console.WriteLine("Mouse: Clicks: {0}; Delta: {1}; X: {2}; Y: {3};", e.Clicks, e.Delta, e.X, e.Y);
+ }
+
+ //protected override void OnMouseDoubleClick (MouseEventArgs e) {
+ protected void OnMouseDoubleClick (MouseEventArgs e) {
+ //base.OnMouseDoubleClick(e);
+ }
+
+ protected override void OnMouseDown (MouseEventArgs e) {
+ base.OnMouseDown(e);
+ //Console.WriteLine("Mouse: Clicks: {0}; Delta: {1}; X: {2}; Y: {3};", e.Clicks, e.Delta, e.X, e.Y);
+ HitTestInfo hitTest = HitTest(e.X, e.Y);
+ //Console.WriteLine("HitTest: Column: {0}; Row: {1};", hitTest.ColumnIndex, hitTest.RowIndex);
+ if (hitTest.RowIndex < 0 || hitTest.ColumnIndex < 0) {
+ return;
+ }
+ OnCellClick(new DataGridViewCellEventArgs(hitTest.ColumnIndex, hitTest.RowIndex));
+ DataGridViewRow row = rows[hitTest.RowIndex];
+ DataGridViewCell cell = row.Cells[hitTest.ColumnIndex];
+ ClearSelection(0, 0, false);
+ switch (selectionMode) {
+ case DataGridViewSelectionMode.FullRowSelect:
+ row.Selected = true;
+ break;
+ case DataGridViewSelectionMode.FullColumnSelect:
+ //////////////////
+ break;
+ default:
+ cell.Selected = true;
+ break;
+ }
+ if (cell == currentCell) {
+ currentCell.SetIsInEditMode(true);
+ OnCellBeginEdit(new DataGridViewCellCancelEventArgs(currentCell.ColumnIndex, currentCell.RowIndex));
+ Invalidate();
+ return;
+ }
+ if (currentCell != null) {
+ if (currentCell.IsInEditMode) {
+ currentCell.SetIsInEditMode(false);
+ currentCell.DetachEditingControl();
+ OnCellEndEdit(new DataGridViewCellEventArgs(currentCell.ColumnIndex, currentCell.RowIndex));
+ }
+ OnCellLeave(new DataGridViewCellEventArgs(currentCell.ColumnIndex, currentCell.RowIndex));
+ }
+ currentCell = cell;
+ OnCurrentCellChanged(EventArgs.Empty);
+ OnCellEnter(new DataGridViewCellEventArgs(cell.ColumnIndex, cell.RowIndex));
+ if (editMode == DataGridViewEditMode.EditOnEnter) {
+ currentCell.SetIsInEditMode(true);
+ OnCellBeginEdit(new DataGridViewCellCancelEventArgs(currentCell.ColumnIndex, currentCell.RowIndex));
+ }
+ Invalidate();
+ return;
+ }
+
+ protected override void OnMouseEnter (EventArgs e) {
+ base.OnMouseEnter(e);
+ }
+
+ protected override void OnMouseLeave (EventArgs e) {
+ base.OnMouseLeave(e);
+ }
+
+ protected override void OnMouseMove (MouseEventArgs e) {
+ base.OnMouseMove(e);
+ }
+
+ protected override void OnMouseUp (MouseEventArgs e) {
+ base.OnMouseUp(e);
+ }
+
+ protected override void OnMouseWheel (MouseEventArgs e) {
+ base.OnMouseWheel(e);
+ }
+
+ protected virtual void OnMultiSelectChanged (EventArgs e) {
+ if (MultiSelectChanged != null) {
+ MultiSelectChanged(this, e);
+ }
+ }
+
+ protected virtual void OnNewRowNeeded (DataGridViewRowEventArgs e) {
+ if (NewRowNeeded != null) {
+ NewRowNeeded(this, e);
+ }
+ }
+
+ protected override void OnPaint (PaintEventArgs e) {
+ base.OnPaint(e);
+ Console.WriteLine(e.ClipRectangle);
+ Rectangle bounds = ClientRectangle; //e.ClipRectangle;
+ e.Graphics.FillRectangle(new SolidBrush(backgroundColor), bounds);
+ Pen pen = new Pen(gridColor);
+ pen.Width = 1;
+ int i = 0;
+ ArrayList sortedColumns = columns.ColumnDisplayIndexSortedArrayList;
+ bounds.Y = -verticalScrollingOffset;
+ bounds.X = -horizontalScrollingOffset;
+ gridWidth = 0;
+ foreach (DataGridViewColumn col in sortedColumns) {
+ gridWidth += col.Width;
+ }
+ if (columnHeadersVisible) {
+ Rectangle headerBounds = bounds;
+ if (rowHeadersVisible) {
+ headerBounds.X += rowHeadersWidth;
+ }
+ headerBounds.Height = columnHeadersHeight;
+ int j = 0;
+ foreach (DataGridViewColumn col in sortedColumns) {
+ headerBounds.Width = col.Width;
+ DataGridViewCell cell = col.HeaderCell;
+ DataGridViewCellStyle style = columnHeadersDefaultCellStyle;
+ DataGridViewAdvancedBorderStyle intermediateBorderStyle = (DataGridViewAdvancedBorderStyle) this.AdvancedColumnHeadersBorderStyle.Clone();;
+ DataGridViewAdvancedBorderStyle borderStyle = AdjustColumnHeaderBorderStyle(this.AdvancedColumnHeadersBorderStyle, intermediateBorderStyle, j == 0, j == columns.Count - 1);
+ cell.InternalPaint(e.Graphics, e.ClipRectangle, headerBounds, cell.RowIndex, cell.State, cell.Value, cell.FormattedValue, cell.ErrorText, style, borderStyle, DataGridViewPaintParts.All);
+ headerBounds.X += col.Width;
+ j++;
+ }
+ bounds.Y += columnHeadersHeight;
+ }
+ gridHeight = 0;
+ foreach (DataGridViewRow row in rows) {
+ gridHeight += row.Height;
+ if (rowHeadersVisible) {
+ Rectangle rowHeaderBounds = bounds;
+ rowHeaderBounds.Height = row.Height;
+ rowHeaderBounds.Width = rowHeadersWidth;
+ DataGridViewCell cell = row.HeaderCell;
+ DataGridViewCellStyle style = rowHeadersDefaultCellStyle;
+ DataGridViewAdvancedBorderStyle intermediateBorderStyle = (DataGridViewAdvancedBorderStyle) this.AdvancedRowHeadersBorderStyle.Clone();;
+ DataGridViewAdvancedBorderStyle borderStyle = cell.AdjustCellBorderStyle(this.AdvancedRowHeadersBorderStyle, intermediateBorderStyle, true, true, false, cell.RowIndex == 0);
+ cell.InternalPaint(e.Graphics, e.ClipRectangle, rowHeaderBounds, cell.RowIndex, cell.State, cell.Value, cell.FormattedValue, cell.ErrorText, style, borderStyle, DataGridViewPaintParts.All);
+ //e.Graphics.FillRectangle(new SolidBrush(rowHeadersDefaultCellStyle.BackColor), rowHeadersBounds);
+ bounds.X += rowHeadersWidth;
+ }
+ bounds.Height = row.Height;
+ for (int j = 0; j < sortedColumns.Count; j++) {
+ DataGridViewColumn col = (DataGridViewColumn) sortedColumns[j];
+ foreach (DataGridViewCell cell in row.Cells) {
+ if (cell.ColumnIndex == col.Index) {
+ bounds.Width = col.Width;
+ cell.SetSize(new Size(bounds.Width, bounds.Height));
+ DataGridViewCellStyle style = cell.InheritedStyle;
+ if (cell == currentCell && cell.IsInEditMode) {
+ cell.InitializeEditingControl(cell.RowIndex, cell.FormattedValue, style);
+ cell.PositionEditingControl(true, true, bounds, e.ClipRectangle, style, false, false, (columns[currentCell.ColumnIndex].DisplayIndex == 0), (currentCell.RowIndex == 0));
+ }
+ else {
+ DataGridViewAdvancedBorderStyle intermediateBorderStyle = (DataGridViewAdvancedBorderStyle) this.AdvancedCellBorderStyle.Clone();;
+ DataGridViewAdvancedBorderStyle borderStyle = cell.AdjustCellBorderStyle(this.AdvancedCellBorderStyle, intermediateBorderStyle, true, true, j == 0, cell.RowIndex == 0);
+ OnCellFormatting(new DataGridViewCellFormattingEventArgs(cell.ColumnIndex, cell.RowIndex, cell.Value, cell.FormattedValueType, style));
+ DataGridViewCellPaintingEventArgs args = new DataGridViewCellPaintingEventArgs (this, e.Graphics, e.ClipRectangle, bounds, cell.RowIndex, cell.ColumnIndex, cell.State, cell.Value, cell.FormattedValue, cell.ErrorText, style, borderStyle, DataGridViewPaintParts.All);
+ OnCellPainting(args);
+ if (!args.Handled) {
+ cell.InternalPaint(e.Graphics, e.ClipRectangle, bounds, cell.RowIndex, cell.State, cell.Value, cell.FormattedValue, cell.ErrorText, style, borderStyle, DataGridViewPaintParts.All);
+ }
+ }
+ bounds.X += bounds.Width;
+ }
+ }
+ }
+ bounds.Y += bounds.Height;
+ bounds.X = -horizontalScrollingOffset;
+ i++;
+ }
+ if (rowHeadersVisible) {
+ gridWidth += rowHeadersWidth;
+ }
+ if (columnHeadersVisible) {
+ gridHeight += columnHeadersHeight;
+ }
+ horizontalScrollBar.Visible = false;
+ verticalScrollBar.Visible = false;
+ if (AutoSize) {
+ if (gridWidth > Size.Width || gridHeight > Size.Height) {
+ Size = new Size(gridWidth, gridHeight);
+ }
+ }
+ else {
+ if (gridWidth > Size.Width) {
+ horizontalScrollBar.Visible = true;
+ }
+ if (gridHeight > Size.Height) {
+ verticalScrollBar.Visible = true;
+ }
+ if (horizontalScrollBar.Visible && (gridHeight + horizontalScrollBar.Height) > Size.Height) {
+ verticalScrollBar.Visible = true;
+ }
+ if (verticalScrollBar.Visible && (gridWidth + horizontalScrollBar.Width) > Size.Width) {
+ horizontalScrollBar.Visible = true;
+ }
+ if (horizontalScrollBar.Visible) {
+ horizontalScrollBar.Minimum = 0;
+ if (verticalScrollBar.Visible) {
+ horizontalScrollBar.Maximum = gridWidth - ClientRectangle.Width + verticalScrollBar.Width;
+ }
+ else {
+ horizontalScrollBar.Maximum = gridWidth - ClientRectangle.Width;
+ }
+ horizontalScrollBar.LargeChange = horizontalScrollBar.Maximum / 10;
+ horizontalScrollBar.SmallChange = horizontalScrollBar.Maximum / 20;
+ }
+ if (verticalScrollBar.Visible) {
+ verticalScrollBar.Minimum = 0;
+ if (horizontalScrollBar.Visible) {
+ verticalScrollBar.Maximum = gridHeight - ClientRectangle.Height + horizontalScrollBar.Height;
+ }
+ else {
+ verticalScrollBar.Maximum = gridHeight - ClientRectangle.Height;
+ }
+ verticalScrollBar.LargeChange = verticalScrollBar.Maximum / 10;
+ verticalScrollBar.SmallChange = verticalScrollBar.Maximum / 20;
+ }
+ }
+ if (horizontalScrollBar.Visible && !this.Controls.Contains(horizontalScrollBar)) {
+ this.Controls.Add(horizontalScrollBar);
+ }
+ else if (!horizontalScrollBar.Visible && this.Controls.Contains(horizontalScrollBar)) {
+ this.Controls.Remove(horizontalScrollBar);
+ }
+ if (verticalScrollBar.Visible && !this.Controls.Contains(verticalScrollBar)) {
+ this.Controls.Add(verticalScrollBar);
+ }
+ else if (!verticalScrollBar.Visible && this.Controls.Contains(verticalScrollBar)) {
+ this.Controls.Remove(verticalScrollBar);
+ }
+ }
+
+ protected virtual void OnReadOnlyChanged (EventArgs e) {
+ if (ReadOnlyChanged != null) {
+ ReadOnlyChanged(this, e);
+ }
+ }
+
+ protected override void OnResize (EventArgs e) {
+ base.OnResize(e);
+ horizontalScrollingOffset = ((gridWidth - Size.Width) > 0)? (gridWidth - Size.Width) : 0;
+ verticalScrollingOffset = ((gridHeight - Size.Height) > 0)? (gridHeight - Size.Height) : 0;
+
+ }
+
+ protected override void OnRightToLeftChanged (EventArgs e) {
+ base.OnRightToLeftChanged(e);
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnRowContextMenuStripChanged (DataGridViewRowEventArgs e) {
+ if (RowContextMenuStripChanged != null) {
+ RowContextMenuStripChanged(this, e);
+ }
+ }
+
+ protected virtual void OnRowContextMenuStripNeeded (DataGridViewRowContextMenuStripNeededEventArgs e) {
+ if (RowContextMenuStripNeeded != null) {
+ RowContextMenuStripNeeded(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnRowDefaultCellStyleChanged (DataGridViewRowEventArgs e) {
+ if (RowDefaultCellStyleChanged != null) {
+ RowDefaultCellStyleChanged(this, e);
+ }
+ }
+
+ protected virtual void OnRowDirtyStateNeeded (QuestionEventArgs e) {
+ if (RowDirtyStateNeeded != null) {
+ RowDirtyStateNeeded(this, e);
+ }
+ }
+
+ protected virtual void OnRowDividerDoubleClick (DataGridViewRowDividerDoubleClickEventArgs e) {
+ if (RowDividerDoubleClick != null) {
+ RowDividerDoubleClick(this, e);
+ }
+ }
+
+ protected virtual void OnRowDividerHeightChanged (DataGridViewRowEventArgs e) {
+ if (RowDividerHeightChanged != null) {
+ RowDividerHeightChanged(this, e);
+ }
+ }
+
+ protected virtual void OnRowEnter (DataGridViewCellEventArgs e) {
+ if (RowEnter != null) {
+ RowEnter(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnRowErrorTextChanged (DataGridViewRowEventArgs e) {
+ if (RowErrorTextChanged != null) {
+ RowErrorTextChanged(this, e);
+ }
+ }
+
+ protected virtual void OnRowErrorTextNeeded (DataGridViewRowErrorTextNeededEventArgs e) {
+ if (RowErrorTextNeeded != null) {
+ RowErrorTextNeeded(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnRowHeaderCellChanged (DataGridViewRowEventArgs e) {
+ if (RowHeaderCellChanged != null) {
+ RowHeaderCellChanged(this, e);
+ }
+ }
+
+ protected virtual void OnRowHeaderMouseClick (DataGridViewCellMouseEventArgs e) {
+ if (RowHeaderMouseClick != null) {
+ RowHeaderMouseClick(this, e);
+ }
+ }
+
+ protected virtual void OnRowHeaderMouseDoubleClick (DataGridViewCellMouseEventArgs e) {
+ if (RowHeaderMouseDoubleClick != null) {
+ RowHeaderMouseDoubleClick(this, e);
+ }
+ }
+
+ protected virtual void OnRowHeadersBorderStyleChanged (EventArgs e) {
+ if (RowHeadersBorderStyleChanged != null) {
+ RowHeadersBorderStyleChanged(this, e);
+ }
+ }
+
+ protected virtual void OnRowHeadersDefaultCellStyleChanged (EventArgs e) {
+ if (RowHeadersDefaultCellStyleChanged != null) {
+ RowHeadersDefaultCellStyleChanged(this, e);
+ }
+ }
+
+ protected virtual void OnRowHeadersWidthChanged (EventArgs e) {
+ if (RowHeadersWidthChanged != null) {
+ RowHeadersWidthChanged(this, e);
+ }
+ }
+
+ protected virtual void OnRowHeadersWidthSizeModeChanged (DataGridViewAutoSizeModeEventArgs e) {
+ if (RowHeadersWidthSizeModeChanged != null) {
+ RowHeadersWidthSizeModeChanged(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnRowHeightChanged (DataGridViewRowEventArgs e) {
+ if (RowHeightChanged != null) {
+ RowHeightChanged(this, e);
+ }
+ }
+
+ protected virtual void OnRowHeightInfoNeeded (DataGridViewRowHeightInfoNeededEventArgs e) {
+ if (RowHeightInfoNeeded != null) {
+ RowHeightInfoNeeded(this, e);
+ }
+ }
+
+ protected virtual void OnRowHeightInfoPushed (DataGridViewRowHeightInfoPushedEventArgs e) {
+ if (RowHeightInfoPushed != null) {
+ RowHeightInfoPushed(this, e);
+ }
+ }
+
+ protected virtual void OnRowLeave (DataGridViewCellEventArgs e) {
+ if (RowLeave != null) {
+ RowLeave(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnRowMinimumHeightChanged (DataGridViewRowEventArgs e) {
+ if (RowMinimumHeightChanged != null) {
+ RowMinimumHeightChanged(this, e);
+ }
+ }
+
+ protected internal virtual void OnRowPostPaint (DataGridViewRowPostPaintEventArgs e) {
+ if (RowPostPaint != null) {
+ RowPostPaint(this, e);
+ }
+ }
+
+ protected internal virtual void OnRowPrePaint (DataGridViewRowPrePaintEventArgs e) {
+ if (RowPrePaint != null) {
+ RowPrePaint(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnRowsAdded (DataGridViewRowsAddedEventArgs e) {
+ if (RowsAdded != null) {
+ RowsAdded(this, e);
+ }
+ }
+
+ protected virtual void OnRowsDefaultCellStyleChanged (EventArgs e) {
+ if (RowsDefaultCellStyleChanged != null) {
+ RowsDefaultCellStyleChanged(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnRowsRemoved (DataGridViewRowsRemovedEventArgs e) {
+ if (RowsRemoved != null) {
+ RowsRemoved(this, e);
+ }
+ }
+
+ // In MSDN2 documentation there's no internal here
+ protected internal virtual void OnRowStateChanged (int rowIndex, DataGridViewRowStateChangedEventArgs e) {
+ if (RowStateChanged != null) {
+ RowStateChanged(this, e);
+ }
+ }
+
+ protected virtual void OnRowUnshared (DataGridViewRowEventArgs e) {
+ if (RowUnshared != null) {
+ RowUnshared(this, e);
+ }
+ }
+
+ protected virtual void OnRowValidated (DataGridViewCellEventArgs e) {
+ if (RowValidated != null) {
+ RowValidated(this, e);
+ }
+ }
+
+ protected virtual void OnRowValidating (DataGridViewCellCancelEventArgs e) {
+ if (RowValidating != null) {
+ RowValidating(this, e);
+ }
+ }
+
+ protected virtual void OnScroll (ScrollEventArgs e) {
+ if (Scroll != null) {
+ Scroll(this, e);
+ }
+ }
+
+ protected virtual void OnSelectionChanged (EventArgs e) {
+ if (SelectionChanged != null) {
+ SelectionChanged(this, e);
+ }
+ }
+
+ protected virtual void OnSortCompare (DataGridViewSortCompareEventArgs e) {
+ if (SortCompare != null) {
+ SortCompare(this, e);
+ }
+ }
+
+ protected virtual void OnSorted (EventArgs e) {
+ if (Sorted != null) {
+ Sorted(this, e);
+ }
+ }
+
+ protected virtual void OnUserAddedRow (DataGridViewRowEventArgs e) {
+ if (UserAddedRow != null) {
+ UserAddedRow(this, e);
+ }
+ }
+
+ protected virtual void OnUserDeletedRow (DataGridViewRowEventArgs e) {
+ if (UserDeletedRow != null) {
+ UserDeletedRow(this, e);
+ }
+ }
+
+ protected virtual void OnUserDeletingRow (DataGridViewRowCancelEventArgs e) {
+ if (UserDeletingRow != null) {
+ UserDeletingRow(this, e);
+ }
+ }
+
+ protected override void OnValidating (CancelEventArgs e) {
+ base.OnValidating(e);
+ }
+
+ protected override void OnVisibleChanged (EventArgs e) {
+ base.OnVisibleChanged(e);
+ }
+
+ protected virtual void PaintBackground (Graphics graphics, Rectangle clipBounds, Rectangle gridBounds) {
+ }
+
+ protected bool ProcessAKey (Keys keyData) {
+ throw new NotImplementedException();
+ }
+
+ protected bool ProcessDataGridViewKey (KeyEventArgs e) {
+ throw new NotImplementedException();
+ }
+
+ protected bool ProcessDeleteKey (Keys keyData) {
+ throw new NotImplementedException();
+ }
+
+ protected override bool ProcessDialogKey (Keys keyData) {
+ return base.ProcessDialogKey(keyData);
+ //throw new NotImplementedException();
+ }
+
+ protected bool ProcessDownKey (Keys keyData) {
+ throw new NotImplementedException();
+ }
+
+ protected bool ProcessEndKey (Keys keyData) {
+ throw new NotImplementedException();
+ }
+
+ protected bool ProcessEnterKey (Keys keyData) {
+ throw new NotImplementedException();
+ }
+
+ protected bool ProcessEscapeKey (Keys keyData) {
+ throw new NotImplementedException();
+ }
+
+ protected bool ProcessF2Key (Keys keyData) {
+ throw new NotImplementedException();
+ }
+
+ protected bool ProcessHomeKey (Keys keyData) {
+ throw new NotImplementedException();
+ }
+
+ protected bool ProcessInsertKey (Keys keyData) {
+ throw new NotImplementedException();
+ }
+
+ protected override bool ProcessKeyEventArgs (ref Message m) {
+ return base.ProcessKeyEventArgs(ref m);
+ //throw new NotImplementedException();
+ }
+
+ protected override bool ProcessKeyPreview (ref Message m) {
+ return base.ProcessKeyPreview(ref m);
+ //throw new NotImplementedException();
+ }
+
+ protected bool ProcessLeftKey (Keys keyData) {
+ throw new NotImplementedException();
+ }
+
+ protected bool ProcessNextKey (Keys keyData) {
+ // PAGE DOWN
+ throw new NotImplementedException();
+ }
+
+ protected bool ProcessPriorKey (Keys keyData) {
+ // PAGE UP
+ throw new NotImplementedException();
+ }
+
+ protected bool ProcessRightKey (Keys keyData) {
+ throw new NotImplementedException();
+ }
+
+ protected bool ProcessSpaceKey (Keys keyData) {
+ throw new NotImplementedException();
+ }
+
+ protected bool ProcessTabKey (Keys keyData) {
+ throw new NotImplementedException();
+ }
+
+ protected bool ProcessUpKey (Keys keyData) {
+ throw new NotImplementedException();
+ }
+
+ protected bool ProcessZeroKey (Keys keyData) {
+ throw new NotImplementedException();
+ }
+
+ protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified) {
+ base.SetBoundsCore(x, y, width, height, specified);
+ }
+
+ protected virtual bool SetCurrentCellAddressCore (int columnIndex, int rowIndex, bool setAnchorCellAddress, bool validateCurrentCell, bool throughMouseClick) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual void SetSelectedCellCore (int columnIndex, int rowIndex, bool selected) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual void SetSelectedColumnCore (int columnIndex, bool selected) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual void SetSelectedRowCore (int rowIndex, bool selected) {
+ throw new NotImplementedException();
+ }
+
+ protected override void WndProc (ref Message m) {
+ base.WndProc(ref m);
+ }
+
+ internal void InternalOnCellClick (DataGridViewCellEventArgs e) {
+ OnCellClick(e);
+ }
+
+ internal void InternalOnCellContentClick (DataGridViewCellEventArgs e) {
+ OnCellContentClick(e);
+ }
+
+ internal void InternalOnCellContentDoubleClick (DataGridViewCellEventArgs e) {
+ OnCellContentDoubleClick(e);
+ }
+
+ internal void InternalOnCellValueChanged (DataGridViewCellEventArgs e) {
+ OnCellValueChanged(e);
+ }
+
+ internal void InternalOnDataError (DataGridViewDataErrorEventArgs e) {
+ /////////////// false? ////////////
+ OnDataError(false, e);
+ }
+
+ internal void InternalOnMouseWheel (MouseEventArgs e) {
+ OnMouseWheel(e);
+ }
+
+ internal void OnHScrollBarScroll (object sender, ScrollEventArgs e) {
+ horizontalScrollingOffset = e.NewValue;
+ Invalidate();
+ OnScroll(e);
+ }
+
+ internal void OnVScrollBarScroll (object sender, ScrollEventArgs e) {
+ verticalScrollingOffset = e.NewValue;
+ Invalidate();
+ OnScroll(e);
+ }
+
+ internal void RaiseCellStyleChanged (DataGridViewCellEventArgs e) {
+ OnCellStyleChanged(e);
+ }
+
+ internal void OnColumnCollectionChanged (object sender, CollectionChangeEventArgs e) {
+ switch (e.Action) {
+ case CollectionChangeAction.Add:
+ OnColumnAdded(new DataGridViewColumnEventArgs(e.Element as DataGridViewColumn));
+ break;
+ case CollectionChangeAction.Remove:
+ OnColumnRemoved(new DataGridViewColumnEventArgs(e.Element as DataGridViewColumn));
+ break;
+ case CollectionChangeAction.Refresh:
+ break;
+ }
+ }
+
+ private void BindIList (IList list) {
+ if (list.Count > 0) {
+ DataGridViewCell template = new DataGridViewTextBoxCell();
+ foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(list[0])) {
+ DataGridViewColumn col = new DataGridViewColumn(template);
+ col.Name = property.DisplayName;
+ columns.Add(col);
+ }
+ }
+ foreach (object element in list) {
+ DataGridViewRow row = new DataGridViewRow();
+ rows.InternalAdd(row);
+ PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(element);
+ foreach (PropertyDescriptor property in properties) {
+ DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell();
+ cell.Value = property.GetValue(element);
+ cell.ValueType = property.PropertyType;
+ row.Cells.Add(cell);
+ }
+ }
+ }
+
+ private void BindIListSource (IListSource list) {
+ BindIList(list.GetList());
+ }
+
+ private void BindIBindingList (IBindingList list) {
+ BindIList(list);
+ }
+
+ private void BindIBindingListView (IBindingListView list) {
+ BindIList(list);
+ }
+
+ public sealed class HitTestInfo {
+
+ public static readonly HitTestInfo Nowhere = new HitTestInfo(-1, -1, -1, -1, DataGridViewHitTestType.None);
+
+ private int columnIndex;
+ private int columnX;
+ private int rowIndex;
+ private int rowY;
+ private DataGridViewHitTestType type;
+
+ internal HitTestInfo (int columnIndex, int columnX, int rowIndex, int rowY, DataGridViewHitTestType type) {
+ this.columnIndex = columnIndex;
+ this.columnX = columnX;
+ this.rowIndex = rowIndex;
+ this.rowY = rowY;
+ this.type = type;
+ }
+
+ public int ColumnIndex {
+ get { return columnIndex; }
+ }
+
+ public int ColumnX {
+ get { return columnX; }
+ }
+
+ public int RowIndex {
+ get { return rowIndex; }
+ }
+
+ public int RowY {
+ get { return rowY; }
+ }
+
+ public DataGridViewHitTestType Type {
+ get { return type; }
+ }
+
+ public override bool Equals (object value) {
+ if (value is HitTestInfo) {
+ HitTestInfo aux = (HitTestInfo) value;
+ if (aux.columnIndex == columnIndex && aux.columnX == columnX && aux.rowIndex == rowIndex && aux.rowY == rowY && aux.type == type) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public override int GetHashCode () {
+ return base.GetHashCode();
+ }
+
+ public override string ToString () {
+ return GetType().Name;
+ }
+
+ }
+
+ [ComVisibleAttribute(true)]
+ protected class DataGridViewAccessibleObject : ControlAccessibleObject {
+
+ public DataGridViewAccessibleObject (DataGridView owner) : base (owner){
+ }
+
+ public override AccessibleRole Role {
+ get { return base.Role; }
+ }
+
+ public override AccessibleObject GetChild (int index) {
+ return base.GetChild(index);
+ }
+
+ public override int GetChildCount () {
+ return base.GetChildCount();
+ }
+
+ public override AccessibleObject GetFocused () {
+ return base.GetFocused();
+ }
+
+ public override AccessibleObject GetSelected () {
+ return base.GetSelected();
+ }
+
+ public override AccessibleObject HitTest (int x, int y) {
+ return base.HitTest(x, y);
+ }
+
+ public override AccessibleObject Navigate( AccessibleNavigation navigationDirection) {
+ return base.Navigate(navigationDirection);
+ }
+
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAdvancedBorderStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAdvancedBorderStyle.cs
new file mode 100644
index 00000000000..4c926ba19ac
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAdvancedBorderStyle.cs
@@ -0,0 +1,154 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System;
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+
+ public sealed class DataGridViewAdvancedBorderStyle : ICloneable {
+
+ private DataGridViewAdvancedCellBorderStyle bottom;
+ private DataGridViewAdvancedCellBorderStyle left;
+ private DataGridViewAdvancedCellBorderStyle right;
+ private DataGridViewAdvancedCellBorderStyle top;
+
+ public DataGridViewAdvancedBorderStyle () {
+ All = DataGridViewAdvancedCellBorderStyle.None;
+ }
+
+ public DataGridViewAdvancedCellBorderStyle All {
+ get {
+ if (bottom == left && left == right && right == top) {
+ return bottom;
+ }
+ return DataGridViewAdvancedCellBorderStyle.NotSet;
+ }
+ set {
+ if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
+ throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
+ }
+ bottom = left = right = top = value;
+ }
+ }
+
+ public DataGridViewAdvancedCellBorderStyle Bottom {
+ get { return bottom; }
+ set {
+ if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
+ throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
+ }
+ if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
+ throw new ArgumentException("Invlid Bottom value.");
+ }
+ bottom = value;
+ }
+ }
+
+ public DataGridViewAdvancedCellBorderStyle Left {
+ get { return left; }
+ set {
+ if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
+ throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
+ }
+ if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
+ throw new ArgumentException("Invlid Left value.");
+ }
+ /*
+ if (Control.RightToLeft == true && (value == DataGridViewAdvancedCellBorderStyle.InsetDouble || value == DataGridViewAdvancedCellBorderStyle.OutsetDouble)) {
+ throw new ArgumentException("Invlid Left value.");
+ }
+ */
+ left = value;
+ }
+ }
+
+ public DataGridViewAdvancedCellBorderStyle Right {
+ get { return right; }
+ set {
+ if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
+ throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
+ }
+ if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
+ throw new ArgumentException("Invlid Right value.");
+ }
+ /*
+ if (Control.RightToLeft == false && (value == DataGridViewAdvancedCellBorderStyle.InsetDouble || value == DataGridViewAdvancedCellBorderStyle.OutsetDouble)) {
+ throw new ArgumentException("Invlid Right value.");
+ }
+ */
+ right = value;
+ }
+ }
+
+ public DataGridViewAdvancedCellBorderStyle Top {
+ get { return top; }
+ set {
+ if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
+ throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
+ }
+ if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
+ throw new ArgumentException("Invlid Top value.");
+ }
+ top = value;
+ }
+ }
+
+ public override bool Equals (object other) {
+ if (other is DataGridViewAdvancedBorderStyle) {
+ DataGridViewAdvancedBorderStyle otherAux = (DataGridViewAdvancedBorderStyle) other;
+ return bottom == otherAux.bottom &&
+ left == otherAux.left &&
+ right == otherAux.right &&
+ top == otherAux.top;
+ }
+ return false;
+ }
+
+ public override int GetHashCode () {
+ return base.GetHashCode();
+ }
+
+ public override string ToString () {
+ return String.Format("DataGridViewAdvancedBorderStyle { All={0}, Left={1}, Right={2}, Top={3}, Bottom={4} }", All, Left, Right, Top, Bottom);
+ }
+
+ public object Clone () {
+ DataGridViewAdvancedBorderStyle result = new DataGridViewAdvancedBorderStyle();
+ result.bottom = this.bottom;
+ result.left = this.left;
+ result.right = this.right;
+ result.top = this.top;
+ return result;
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAdvancedCellBorderStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAdvancedCellBorderStyle.cs
new file mode 100644
index 00000000000..80df6be7000
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAdvancedCellBorderStyle.cs
@@ -0,0 +1,43 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public enum DataGridViewAdvancedCellBorderStyle {
+ NotSet = 0,
+ None = 1,
+ Single = 2,
+ Inset = 3,
+ InsetDouble = 4,
+ Outset = 5,
+ OutsetDouble = 6,
+ OutsetPartial = 7
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnMode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnMode.cs
new file mode 100644
index 00000000000..2317b1acdb6
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnMode.cs
@@ -0,0 +1,44 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public enum DataGridViewAutoSizeColumnMode {
+ NotSet = 0,
+ None = 1,
+ ColumnHeader = 2,
+ AllCellsExceptHeader = 4,
+ AllCells = 6,
+ DisplayedCellsExceptHeader = 8,
+ DisplayedCells = 10,
+ Fill = 16
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnModeEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnModeEventArgs.cs
new file mode 100644
index 00000000000..f53b5648af6
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnModeEventArgs.cs
@@ -0,0 +1,53 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewAutoSizeColumnModeEventArgs : EventArgs {
+
+ private DataGridViewColumn dataGridViewColumn;
+ private DataGridViewAutoSizeColumnMode previousMode;
+
+ public DataGridViewAutoSizeColumnModeEventArgs (DataGridViewColumn dataGridViewColumn, DataGridViewAutoSizeColumnMode previousMode) {
+ this.dataGridViewColumn = dataGridViewColumn;
+ this.previousMode = previousMode;
+ }
+
+ public DataGridViewColumn Column {
+ get { return dataGridViewColumn; }
+ }
+
+ public DataGridViewAutoSizeColumnMode PreviousMode {
+ get { return previousMode; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnModeEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnModeEventHandler.cs
new file mode 100644
index 00000000000..4dace6a5858
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnModeEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewAutoSizeColumnModeEventHandler (object sender, DataGridViewAutoSizeColumnModeEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnsMode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnsMode.cs
new file mode 100644
index 00000000000..b36b34de0cc
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnsMode.cs
@@ -0,0 +1,43 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public enum DataGridViewAutoSizeColumnsMode {
+ None = 1,
+ ColumnHeader = 2,
+ AllCellsExceptHeader = 4,
+ AllCells = 6,
+ DisplayedCellsExceptHeader = 8,
+ DisplayedCells = 10,
+ Fill = 16
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnsModeEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnsModeEventArgs.cs
new file mode 100644
index 00000000000..6742b3aa187
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnsModeEventArgs.cs
@@ -0,0 +1,47 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewAutoSizeColumnsModeEventArgs : EventArgs {
+
+ private DataGridViewAutoSizeColumnMode[] previousModes;
+
+ public DataGridViewAutoSizeColumnsModeEventArgs (DataGridViewAutoSizeColumnMode[] previousModes) {
+ this.previousModes = previousModes;
+ }
+
+ public DataGridViewAutoSizeColumnMode[] PreviousModes {
+ get { return previousModes; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnsModeEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnsModeEventHandler.cs
new file mode 100644
index 00000000000..83229f27e2b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeColumnsModeEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewAutoSizeColumnsModeEventHandler (object sender, DataGridViewAutoSizeColumnsModeEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeModeEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeModeEventArgs.cs
new file mode 100644
index 00000000000..88ce4d7b91e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeModeEventArgs.cs
@@ -0,0 +1,47 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewAutoSizeModeEventArgs : EventArgs {
+
+ private bool previousModeAutoSized;
+
+ public DataGridViewAutoSizeModeEventArgs (bool previousModeAutoSized) {
+ this.previousModeAutoSized = previousModeAutoSized;
+ }
+
+ public bool PreviousModeAutoSized {
+ get { return previousModeAutoSized; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeModeEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeModeEventHandler.cs
new file mode 100644
index 00000000000..0e9e703ebfc
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeModeEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewAutoSizeModeEventHandler (object sender, DataGridViewAutoSizeModeEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeRowMode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeRowMode.cs
new file mode 100644
index 00000000000..ad3667651ac
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeRowMode.cs
@@ -0,0 +1,39 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public enum DataGridViewAutoSizeRowMode {
+ RowHeader = 1,
+ AllCellsExceptHeader = 2,
+ AllCells = 3
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeRowsMode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeRowsMode.cs
new file mode 100644
index 00000000000..7656a3c8f99
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewAutoSizeRowsMode.cs
@@ -0,0 +1,43 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public enum DataGridViewAutoSizeRowsMode {
+ None = 0,
+ AllHeaders = 5,
+ AllCellsExceptHeaders = 6,
+ AllCells = 7,
+ DisplayedHeaders = 9,
+ DisplayedCellsExceptHeaders = 10,
+ DisplayedCells = 11
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewBand.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewBand.cs
new file mode 100644
index 00000000000..b65e61559d9
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewBand.cs
@@ -0,0 +1,164 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewBand : DataGridViewElement, ICloneable, IDisposable {
+
+ // private ContextMenuStrip contextMenuStrip = null;
+ private DataGridViewCellStyle defaultCellStyle;
+ private Type defaultHeaderCellType;
+ private bool displayed;
+ private bool frozen = false;
+ private int index = -1;
+ private bool readOnly = false;
+ private DataGridViewTriState resizable = DataGridViewTriState.True;
+ private bool selected = false;
+ private object tag = null;
+ private bool visible = true;
+ private DataGridViewHeaderCell headerCellCore;
+ private bool isRow;
+ private DataGridViewCellStyle inheritedStyle = null;
+
+ ~DataGridViewBand () {
+ Dispose();
+ }
+
+ /*
+ public virtual ContextMenuStrip ContextMenuStrip {get; set;}
+ */
+
+ public virtual DataGridViewCellStyle DefaultCellStyle {
+ get {
+ if (defaultCellStyle == null) {
+ defaultCellStyle = new DataGridViewCellStyle();
+ }
+ return defaultCellStyle;
+ }
+ set { defaultCellStyle = value; }
+ }
+
+ public Type DefaultHeaderCellType {
+ get { return defaultHeaderCellType; }
+ set {
+ if (value.IsSubclassOf(typeof(DataGridViewHeaderCell))) {
+ throw new ArgumentException("Type is not DataGridViewHeaderCell or a derived type.");
+ }
+ defaultHeaderCellType = value;
+ }
+ }
+
+ public virtual bool Displayed {
+ get { return displayed; }
+ }
+
+ public virtual bool Frozen {
+ get { return frozen; }
+ set { frozen = value; }
+ }
+
+ public bool HasDefaultCellStyle {
+ get { return (defaultCellStyle != null); }
+ }
+
+ public int Index {
+ get { return index; }
+ }
+
+ public virtual DataGridViewCellStyle InheritedStyle {
+ get { return inheritedStyle; }
+ }
+
+ public virtual bool ReadOnly {
+ get { return readOnly; }
+ set { readOnly = value; }
+ }
+
+ public virtual DataGridViewTriState Resizable {
+ get { return resizable; }
+ set { resizable = value; }
+ }
+
+ public virtual bool Selected {
+ get { return selected; }
+ set {
+ if (DataGridView == null) {
+ throw new InvalidOperationException("Cant select a row non associated with a DataGridView.");
+ }
+ selected = value;
+ }
+ }
+
+ public object Tag {
+ get { return tag; }
+ set { tag = value; }
+ }
+
+ public virtual bool Visible {
+ get { return visible; }
+ set { visible = value; }
+ }
+
+ public virtual object Clone () {
+ DataGridViewBand result = new DataGridViewBand();
+ //////////////////////////////
+ return result;
+ }
+
+ //public sealed void Dispose () {
+ public void Dispose () {
+ }
+
+ public override string ToString () {
+ return this.GetType().Name + ": " + index.ToString() + ".";
+ }
+
+ protected DataGridViewHeaderCell HeaderCellCore {
+ get { return headerCellCore; }
+ set { headerCellCore = value; }
+ }
+
+ protected bool IsRow {
+ get { return isRow; }
+ }
+
+ protected virtual void Dispose (bool disposing) {
+ }
+
+ protected override void OnDataGridViewChanged () {
+ }
+
+ internal virtual void SetIndex (int index) {
+ this.index = index;
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewBindingCompleteEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewBindingCompleteEventArgs.cs
new file mode 100644
index 00000000000..74eca197157
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewBindingCompleteEventArgs.cs
@@ -0,0 +1,49 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewBindingCompleteEventArgs : EventArgs {
+
+ private ListChangedType listChangedType;
+
+ public DataGridViewBindingCompleteEventArgs (ListChangedType listChangedType) {
+ this.listChangedType = listChangedType;
+ }
+
+ public ListChangedType ListChangedType {
+ get { return listChangedType; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewBindingCompleteEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewBindingCompleteEventHandler.cs
new file mode 100644
index 00000000000..09784515740
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewBindingCompleteEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewBindingCompleteEventHandler (object sender, DataGridViewBindingCompleteEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewButtonCell.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewButtonCell.cs
new file mode 100644
index 00000000000..f786ac3a6e0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewButtonCell.cs
@@ -0,0 +1,199 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+#if NET_2_0
+
+using System.Drawing;
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewButtonCell : DataGridViewCell {
+
+ private FlatStyle flatStyle;
+ private bool useColumnTextForButtonValue;
+
+ public DataGridViewButtonCell () {
+ useColumnTextForButtonValue = false;
+ }
+
+ public override Type EditType {
+ get { return null; }
+ }
+
+ public FlatStyle FlatStyle {
+ get { return flatStyle; }
+ set {
+ if (!Enum.IsDefined(typeof(FlatStyle), value)) {
+ throw new InvalidEnumArgumentException("Value is not valid FlatStyle.");
+ }
+ if (value == FlatStyle.Popup) {
+ throw new Exception("FlatStyle cannot be set to Popup in this control.");
+ }
+ }
+ }
+
+ public override Type FormattedValueType {
+ get { return base.FormattedValueType; }
+ }
+
+ public bool UseColumnTextForButtonValue {
+ get { return useColumnTextForButtonValue; }
+ set { useColumnTextForButtonValue = value; }
+ }
+
+ public override Type ValueType {
+ get { return base.ValueType; }
+ }
+
+ public override object Clone () {
+ DataGridViewButtonCell result = (DataGridViewButtonCell) base.Clone();
+ result.flatStyle = this.flatStyle;
+ result.useColumnTextForButtonValue = this.useColumnTextForButtonValue;
+ return result;
+ }
+
+ public override string ToString () {
+ return GetType().Name + ": RowIndex: " + RowIndex.ToString() + "; ColumnIndex: " + ColumnIndex.ToString() + ";";
+ }
+
+ protected override AccessibleObject CreateAccessibilityInstance () {
+ return new DataGridViewButtonCellAccessibleObject(this);
+ }
+
+ protected override Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override Rectangle GetErrorIconBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override Size GetPreferredSize (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) {
+ throw new NotImplementedException();
+ }
+
+ protected override object GetValue (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override bool KeyDownUnsharesRow (KeyEventArgs e, int rowIndex) {
+ // true if the user pressed the SPACE key without modifier keys; otherwise, false
+ throw new NotImplementedException();
+ }
+
+ protected override bool KeyUpUnsharesRow (KeyEventArgs e, int rowIndex) {
+ // true if the user released the SPACE key; otherwise false
+ throw new NotImplementedException();
+
+ }
+
+ protected override bool MouseDownUnsharesRow (DataGridViewCellMouseEventArgs e) {
+ return (e.Button == MouseButtons.Left);
+ }
+
+ protected override bool MouseEnterUnsharesRow (int rowIndex) {
+ // true if the cell was the last cell receiving a mouse click; otherwise, false.
+ throw new NotImplementedException();
+ }
+
+ protected override bool MouseLeaveUnsharesRow (int rowIndex) {
+ // true if the button displayed by the cell is in the pressed state; otherwise, false.
+ throw new NotImplementedException();
+ }
+
+ protected override bool MouseUpUnsharesRow (DataGridViewCellMouseEventArgs e) {
+ // true if the mouse up was caused by the release of the left mouse button; otherwise false.
+ throw new NotImplementedException();
+ }
+
+ protected override void OnKeyDown (KeyEventArgs e, int rowIndex) {
+ // when activated by the SPACE key, this method updates the cell's user interface
+ throw new NotImplementedException();
+ }
+
+ protected override void OnKeyUp (KeyEventArgs e, int rowIndex) {
+ // when activated by the SPACE key, this method updates the cell's user interface
+ throw new NotImplementedException();
+ }
+
+ protected override void OnLeave (int rowIndex, bool throughMouseClick) {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnMouseDown (DataGridViewCellMouseEventArgs e) {
+ // if activated by depresing the left mouse button, this method updates the cell's user interface
+ throw new NotImplementedException();
+ }
+
+ protected override void OnMouseEnter (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnMouseLeave (int rowIndex) {
+ // if the cell's button is not in its normal state, this method causes the cell's user interface to be updated.
+ throw new NotImplementedException();
+ }
+
+ protected override void OnMouseUp (DataGridViewCellMouseEventArgs e) {
+ // if activated by the left mouse button, this method updates the cell's user interface
+ throw new NotImplementedException();
+ }
+
+ protected override void Paint (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
+ throw new NotImplementedException();
+ }
+
+ protected class DataGridViewButtonCellAccessibleObject : DataGridViewCellAccessibleObject {
+
+ public DataGridViewButtonCellAccessibleObject (DataGridViewCell owner) : base(owner) {
+ }
+
+ public override string DefaultAction {
+ get {
+ if (Owner.ReadOnly) {
+ return "Press";
+ }
+ else {
+ return "";
+ }
+ }
+ }
+
+ public override void DoDefaultAction () {
+ // causes the button in the ButtonCell to be clicked
+ }
+
+ public override int GetChildCount () {
+ return -1;
+ }
+
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewButtonColumn.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewButtonColumn.cs
new file mode 100644
index 00000000000..cce58ec1af2
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewButtonColumn.cs
@@ -0,0 +1,92 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewButtonColumn : DataGridViewColumn {
+
+ private FlatStyle flatStyle;
+ private string text;
+
+ public DataGridViewButtonColumn () {
+ base.CellTemplate = new DataGridViewButtonCell();
+ flatStyle = FlatStyle.Standard;
+ text = String.Empty;
+ }
+
+ public override DataGridViewCell CellTemplate {
+ get { return base.CellTemplate; }
+ set { base.CellTemplate = value as DataGridViewButtonCell; }
+ }
+
+ public override DataGridViewCellStyle DefaultCellStyle {
+ get { return base.DefaultCellStyle; }
+ set { base.DefaultCellStyle = value; }
+ }
+
+ public FlatStyle FlatStyle {
+ get { return flatStyle; }
+ set { flatStyle = value; }
+ }
+
+ public string Text {
+ get { return text; }
+ set { text = value; }
+ }
+
+ public bool UseColumnTextForButtonValue {
+ get {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null when getting this property.");
+ }
+ return (base.CellTemplate as DataGridViewButtonCell).UseColumnTextForButtonValue;
+ }
+ set {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null when setting this property.");
+ }
+ (base.CellTemplate as DataGridViewButtonCell).UseColumnTextForButtonValue = value;
+ }
+ }
+
+ public override object Clone () {
+ DataGridViewButtonColumn col = (DataGridViewButtonColumn) base.Clone();
+ col.flatStyle = this.flatStyle;
+ col.text = this.text;
+ return col;
+ }
+
+ public override string ToString () {
+ throw new NotImplementedException();
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCell.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCell.cs
new file mode 100644
index 00000000000..013702430db
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCell.cs
@@ -0,0 +1,1074 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System;
+using System.Drawing;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+
+ public abstract class DataGridViewCell : DataGridViewElement, ICloneable, IDisposable {
+
+ private DataGridView dataGridViewOwner;
+
+ private AccessibleObject accessibilityObject;
+ private int columnIndex;
+ private Rectangle contentBounds;
+ // private ContextMenuStrip contextMenuStrip;
+ private object defaultNewRowValue;
+ private bool displayed;
+ private object editedFormattedValue;
+ private Type editType;
+ private Rectangle errorIconBounds;
+ private string errorText;
+ private Type formattedValueType;
+ private bool frozen;
+ private DataGridViewElementStates inheritedState;
+ private bool isInEditMode;
+ private DataGridViewColumn owningColumn;
+ private DataGridViewRow owningRow;
+ private Size preferredSize;
+ private bool readOnly;
+ private bool resizable;
+ private bool selected;
+ private Size size;
+ private DataGridViewCellStyle style;
+ private object tag;
+ private string toolTipText;
+ private object valuex;
+ private Type valueType;
+ private bool visible;
+
+ protected DataGridViewCell () {
+ columnIndex = -1;
+ }
+
+ ~DataGridViewCell () {
+ Dispose(false);
+ }
+
+ public AccessibleObject AccessibilityObject {
+ get {
+ if (accessibilityObject == null) {
+ accessibilityObject = CreateAccessibilityInstance();
+ }
+ return accessibilityObject;
+ }
+ }
+
+ public int ColumnIndex {
+ get { return columnIndex; }
+ }
+
+ public Rectangle ContentBounds {
+ get { return contentBounds; }
+ }
+
+ /*
+ public virtual ContextMenuStrip ContextMenuStrip {
+ get { return contextMenuStrip; }
+ set { contextMenuStrip = value; }
+ }
+ */
+
+ public virtual object DefaultNewRowValue {
+ get { return defaultNewRowValue; }
+ }
+
+ public virtual bool Displayed {
+ get { return displayed; }
+ }
+
+ public object EditedFormattedValue {
+ get { return editedFormattedValue; }
+ }
+
+ public virtual Type EditType {
+ get { return editType; }
+ }
+
+ public Rectangle ErrorIconBounds {
+ get { return errorIconBounds; }
+ }
+
+ public string ErrorText {
+ get { return errorText; }
+ set {
+ if (errorText != value) {
+ errorText = value;
+ OnErrorTextChanged(new DataGridViewCellEventArgs(ColumnIndex, RowIndex));
+ }
+ }
+ }
+
+ public object FormattedValue {
+ get {
+ DataGridViewCellStyle style = InheritedStyle;
+ if (style.Format != String.Empty && FormattedValueType == typeof(string)) {
+ return String.Format("{0:" + style.Format + "}", Value);
+ }
+ return Convert.ChangeType(Value, FormattedValueType, style.FormatProvider);
+ }
+ }
+
+ public virtual Type FormattedValueType {
+ get { return formattedValueType; }
+ }
+
+ public virtual bool Frozen {
+ get { return frozen; }
+ }
+
+ public bool HasStyle {
+ get { return style != null; }
+ }
+
+ public DataGridViewElementStates InheritedState {
+ get { return inheritedState; }
+ }
+
+ public DataGridViewCellStyle InheritedStyle {
+ get {
+ DataGridViewCellStyle result = new DataGridViewCellStyle();
+ if (style != null && style.Alignment != DataGridViewContentAlignment.NotSet) {
+ result.Alignment = style.Alignment;
+ }
+ else if (OwningRow != null && OwningRow.DefaultCellStyle.Alignment != DataGridViewContentAlignment.NotSet) {
+ result.Alignment = OwningRow.DefaultCellStyle.Alignment;
+ }
+ else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.Alignment != DataGridViewContentAlignment.NotSet) {
+ result.Alignment = DataGridView.AlternatingRowsDefaultCellStyle.Alignment;
+ }
+ else if (DataGridView.RowsDefaultCellStyle.Alignment != DataGridViewContentAlignment.NotSet) {
+ result.Alignment = DataGridView.RowsDefaultCellStyle.Alignment;
+ }
+ else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.Alignment != DataGridViewContentAlignment.NotSet) {
+ result.Alignment = DataGridView.Columns[ColumnIndex].DefaultCellStyle.Alignment;
+ }
+ else {
+ result.Alignment = DataGridView.DefaultCellStyle.Alignment;
+ }
+ }
+ if (style != null && style.BackColor != Color.Empty) {
+ result.BackColor = style.BackColor;
+ }
+ else if (OwningRow != null && OwningRow.DefaultCellStyle.BackColor != Color.Empty) {
+ result.BackColor = OwningRow.DefaultCellStyle.BackColor;
+ }
+ else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.BackColor != Color.Empty) {
+ result.BackColor = DataGridView.AlternatingRowsDefaultCellStyle.BackColor;
+ }
+ else if (DataGridView.RowsDefaultCellStyle.BackColor != Color.Empty) {
+ result.BackColor = DataGridView.RowsDefaultCellStyle.BackColor;
+ }
+ else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.BackColor != Color.Empty) {
+ result.BackColor = DataGridView.Columns[ColumnIndex].DefaultCellStyle.BackColor;
+ }
+ else {
+ result.BackColor = DataGridView.DefaultCellStyle.BackColor;
+ }
+ }
+ if (style != null && style.Font != null) {
+ result.Font = style.Font;
+ }
+ else if (OwningRow != null && OwningRow.DefaultCellStyle.Font != null) {
+ result.Font = OwningRow.DefaultCellStyle.Font;
+ }
+ else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.Font != null) {
+ result.Font = DataGridView.AlternatingRowsDefaultCellStyle.Font;
+ }
+ else if (DataGridView.RowsDefaultCellStyle.Font != null) {
+ result.Font = DataGridView.RowsDefaultCellStyle.Font;
+ }
+ else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.Font != null) {
+ result.Font = DataGridView.Columns[ColumnIndex].DefaultCellStyle.Font;
+ }
+ else {
+ result.Font = DataGridView.DefaultCellStyle.Font;
+ }
+ }
+ if (style != null && style.ForeColor != Color.Empty) {
+ result.ForeColor = style.ForeColor;
+ }
+ else if (OwningRow != null && OwningRow.DefaultCellStyle.ForeColor != Color.Empty) {
+ result.ForeColor = OwningRow.DefaultCellStyle.ForeColor;
+ }
+ else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.ForeColor != Color.Empty) {
+ result.ForeColor = DataGridView.AlternatingRowsDefaultCellStyle.ForeColor;
+ }
+ else if (DataGridView.RowsDefaultCellStyle.ForeColor != Color.Empty) {
+ result.ForeColor = DataGridView.RowsDefaultCellStyle.ForeColor;
+ }
+ else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.ForeColor != Color.Empty) {
+ result.ForeColor = DataGridView.Columns[ColumnIndex].DefaultCellStyle.ForeColor;
+ }
+ else {
+ result.ForeColor = DataGridView.DefaultCellStyle.ForeColor;
+ }
+ }
+ if (style != null && style.Format != String.Empty) {
+ result.Format = style.Format;
+ }
+ else if (OwningRow != null && OwningRow.DefaultCellStyle.Format != String.Empty) {
+ result.Format = OwningRow.DefaultCellStyle.Format;
+ }
+ else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.Format != String.Empty) {
+ result.Format = DataGridView.AlternatingRowsDefaultCellStyle.Format;
+ }
+ else if (DataGridView.RowsDefaultCellStyle.Format != String.Empty) {
+ result.Format = DataGridView.RowsDefaultCellStyle.Format;
+ }
+ else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.Format != String.Empty) {
+ result.Format = DataGridView.Columns[ColumnIndex].DefaultCellStyle.Format;
+ }
+ else {
+ result.Format = DataGridView.DefaultCellStyle.Format;
+ }
+ }
+ if (style != null && style.FormatProvider != System.Globalization.CultureInfo.CurrentUICulture) {
+ result.FormatProvider = style.FormatProvider;
+ }
+ else if (OwningRow != null && OwningRow.DefaultCellStyle.FormatProvider != System.Globalization.CultureInfo.CurrentUICulture) {
+ result.FormatProvider = OwningRow.DefaultCellStyle.FormatProvider;
+ }
+ else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.FormatProvider != System.Globalization.CultureInfo.CurrentUICulture) {
+ result.FormatProvider = DataGridView.AlternatingRowsDefaultCellStyle.FormatProvider;
+ }
+ else if (DataGridView.RowsDefaultCellStyle.FormatProvider != System.Globalization.CultureInfo.CurrentUICulture) {
+ result.FormatProvider = DataGridView.RowsDefaultCellStyle.FormatProvider;
+ }
+ else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.FormatProvider != System.Globalization.CultureInfo.CurrentUICulture) {
+ result.FormatProvider = DataGridView.Columns[ColumnIndex].DefaultCellStyle.FormatProvider;
+ }
+ else {
+ result.FormatProvider = DataGridView.DefaultCellStyle.FormatProvider;
+ }
+ }
+ if (style != null && (string) style.NullValue != "(null)") {
+ result.NullValue = style.NullValue;
+ }
+ else if (OwningRow != null && (string) OwningRow.DefaultCellStyle.NullValue != "(null)") {
+ result.NullValue = OwningRow.DefaultCellStyle.NullValue;
+ }
+ else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && (string) DataGridView.AlternatingRowsDefaultCellStyle.NullValue != "(null)") {
+ result.NullValue = DataGridView.AlternatingRowsDefaultCellStyle.NullValue;
+ }
+ else if ((string) DataGridView.RowsDefaultCellStyle.NullValue != "(null)") {
+ result.NullValue = DataGridView.RowsDefaultCellStyle.NullValue;
+ }
+ else if (ColumnIndex >= 0 && (string) DataGridView.Columns[ColumnIndex].DefaultCellStyle.NullValue != "(null)") {
+ result.NullValue = DataGridView.Columns[ColumnIndex].DefaultCellStyle.NullValue;
+ }
+ else {
+ result.NullValue = DataGridView.DefaultCellStyle.NullValue;
+ }
+ }
+ if (style != null && style.Padding != Padding.Empty) {
+ result.Padding = style.Padding;
+ }
+ else if (OwningRow != null && OwningRow.DefaultCellStyle.Padding != Padding.Empty) {
+ result.Padding = OwningRow.DefaultCellStyle.Padding;
+ }
+ else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.Padding != Padding.Empty) {
+ result.Padding = DataGridView.AlternatingRowsDefaultCellStyle.Padding;
+ }
+ else if (DataGridView.RowsDefaultCellStyle.Padding != Padding.Empty) {
+ result.Padding = DataGridView.RowsDefaultCellStyle.Padding;
+ }
+ else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.Padding != Padding.Empty) {
+ result.Padding = DataGridView.Columns[ColumnIndex].DefaultCellStyle.Padding;
+ }
+ else {
+ result.Padding = DataGridView.DefaultCellStyle.Padding;
+ }
+ }
+ if (style != null && style.SelectionBackColor != Color.Empty) {
+ result.SelectionBackColor = style.SelectionBackColor;
+ }
+ else if (OwningRow != null && OwningRow.DefaultCellStyle.SelectionBackColor != Color.Empty) {
+ result.SelectionBackColor = OwningRow.DefaultCellStyle.SelectionBackColor;
+ }
+ else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.SelectionBackColor != Color.Empty) {
+ result.SelectionBackColor = DataGridView.AlternatingRowsDefaultCellStyle.SelectionBackColor;
+ }
+ else if (DataGridView.RowsDefaultCellStyle.SelectionBackColor != Color.Empty) {
+ result.SelectionBackColor = DataGridView.RowsDefaultCellStyle.SelectionBackColor;
+ }
+ else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.SelectionBackColor != Color.Empty) {
+ result.SelectionBackColor = DataGridView.Columns[ColumnIndex].DefaultCellStyle.SelectionBackColor;
+ }
+ else {
+ result.SelectionBackColor = DataGridView.DefaultCellStyle.SelectionBackColor;
+ }
+ }
+ if (style != null && style.SelectionForeColor != Color.Empty) {
+ result.SelectionForeColor = style.SelectionForeColor;
+ }
+ else if (OwningRow != null && OwningRow.DefaultCellStyle.SelectionForeColor != Color.Empty) {
+ result.SelectionForeColor = OwningRow.DefaultCellStyle.SelectionForeColor;
+ }
+ else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.SelectionForeColor != Color.Empty) {
+ result.SelectionForeColor = DataGridView.AlternatingRowsDefaultCellStyle.SelectionForeColor;
+ }
+ else if (DataGridView.RowsDefaultCellStyle.SelectionForeColor != Color.Empty) {
+ result.SelectionForeColor = DataGridView.RowsDefaultCellStyle.SelectionForeColor;
+ }
+ else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.SelectionForeColor != Color.Empty) {
+ result.SelectionForeColor = DataGridView.Columns[ColumnIndex].DefaultCellStyle.SelectionForeColor;
+ }
+ else {
+ result.SelectionForeColor = DataGridView.DefaultCellStyle.SelectionForeColor;
+ }
+ }
+ if (style != null && style.Tag != null) {
+ result.Tag = style.Tag;
+ }
+ else if (OwningRow != null && OwningRow.DefaultCellStyle.Tag != null) {
+ result.Tag = OwningRow.DefaultCellStyle.Tag;
+ }
+ else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.Tag != null) {
+ result.Tag = DataGridView.AlternatingRowsDefaultCellStyle.Tag;
+ }
+ else if (DataGridView.RowsDefaultCellStyle.Tag != null) {
+ result.Tag = DataGridView.RowsDefaultCellStyle.Tag;
+ }
+ else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.Tag != null) {
+ result.Tag = DataGridView.Columns[ColumnIndex].DefaultCellStyle.Tag;
+ }
+ else {
+ result.Tag = DataGridView.DefaultCellStyle.Tag;
+ }
+ }
+ if (style != null && style.WrapMode != DataGridViewTriState.NotSet) {
+ result.WrapMode = style.WrapMode;
+ }
+ else if (OwningRow != null && OwningRow.DefaultCellStyle.WrapMode != DataGridViewTriState.NotSet) {
+ result.WrapMode = OwningRow.DefaultCellStyle.WrapMode;
+ }
+ else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.WrapMode != DataGridViewTriState.NotSet) {
+ result.WrapMode = DataGridView.AlternatingRowsDefaultCellStyle.WrapMode;
+ }
+ else if (DataGridView.RowsDefaultCellStyle.WrapMode != DataGridViewTriState.NotSet) {
+ result.WrapMode = DataGridView.RowsDefaultCellStyle.WrapMode;
+ }
+ else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.WrapMode != DataGridViewTriState.NotSet) {
+ result.WrapMode = DataGridView.Columns[ColumnIndex].DefaultCellStyle.WrapMode;
+ }
+ else {
+ result.WrapMode = DataGridView.DefaultCellStyle.WrapMode;
+ }
+ }
+ return result;
+ }
+ }
+
+ public bool IsInEditMode {
+ get { return isInEditMode; }
+ }
+
+ public DataGridViewColumn OwningColumn {
+ get { return owningColumn; }
+ }
+
+ public DataGridViewRow OwningRow {
+ get { return owningRow; }
+ }
+
+ public Size PreferredSize {
+ get { return preferredSize; }
+ }
+
+ public virtual bool ReadOnly {
+ get { return readOnly; }
+ set { readOnly = value; }
+ }
+
+ public virtual bool Resizable {
+ get { return resizable; }
+ }
+
+ public int RowIndex {
+ get {
+ if (owningRow == null) {
+ return -1;
+ }
+ return owningRow.Index;
+ }
+ }
+
+ public virtual bool Selected {
+ get { return selected; }
+ set {
+ if (value != ((State & DataGridViewElementStates.Selected) != 0)) {
+ SetState(State ^ DataGridViewElementStates.Selected);
+ }
+ selected = value;
+ }
+ }
+
+ public Size Size {
+ get { return size; }
+ }
+
+ public DataGridViewCellStyle Style {
+ get {
+ if (style != null) {
+ style = new DataGridViewCellStyle();
+ style.StyleChanged += OnStyleChanged;
+ }
+ return style;
+ }
+ set { style = value; }
+ }
+
+ public object Tag {
+ get { return tag; }
+ set { tag = value; }
+ }
+
+ public string ToolTipText {
+ get { return toolTipText; }
+ set { toolTipText = value; }
+ }
+
+ public object Value {
+ get { return valuex; }
+ set {
+ if (valuex != value) {
+ valuex = value;
+ RaiseCellValueChanged(new DataGridViewCellEventArgs(ColumnIndex, RowIndex));
+ }
+ }
+ }
+
+ public virtual Type ValueType {
+ get { return valueType; }
+ set { valueType = value; }
+ }
+
+ public virtual bool Visible {
+ get { return visible; }
+ }
+
+ public virtual DataGridViewAdvancedBorderStyle AdjustCellBorderStyle (DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput, DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder, bool singleVerticalBorderAdded, bool singleHorizontalBorderAdded, bool isFirstDisplayedColumn, bool isFirstDisplayedRow) {
+ return dataGridViewAdvancedBorderStyleInput;
+ }
+
+ public virtual object Clone () {
+ return this.MemberwiseClone();
+ /*
+ DataGridViewCell result = null; // = new DataGridViewCell();
+ result.accessibilityObject = this.accessibilityObject;
+ result.columnIndex = this.columnIndex;
+ result.contentBounds = this.contentBounds;
+ //result.contextMenuStrip = this.contextMenuStrip;
+ result.defaultNewRowValue = this.defaultNewRowValue;
+ result.displayed = this.displayed;
+ result.editedFormattedValue = this.editedFormattedValue;
+ result.editType = this.editType;
+ result.errorIconBounds = this.errorIconBounds;
+ result.errorText = this.errorText;
+ result.formattedValueType = this.formattedValueType;
+ result.frozen = this.frozen;
+ result.hasStyle = this.hasStyle;
+ result.inheritedState = this.inheritedState;
+ result.inheritedStyle = this.inheritedStyle;
+ result.isInEditMode = this.isInEditMode;
+ result.owningColumn = this.owningColumn;
+ result.owningRow = this.owningRow;
+ result.preferredSize = this.preferredSize;
+ result.readOnly = this.readOnly;
+ result.resizable = this.resizable;
+ result.selected = this.selected;
+ result.size = this.size;
+ result.style = this.style;
+ result.tag = this.tag;
+ result.toolTipText = this.toolTipText;
+ result.valuex = this.valuex;
+ result.valueType = this.valueType;
+ result.visible = this.visible;
+ return result;
+ */
+ }
+
+ public virtual void DetachEditingControl () {
+ }
+
+ //public sealed void Dispose () {
+ public void Dispose () {
+ }
+
+ public Rectangle GetContentBounds (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ public object GetEditedFormattedValue (int rowIndex, DataGridViewDataErrorContexts context) {
+ throw new NotImplementedException();
+ }
+
+ /*
+ public virtual ContextMenuStrip GetInheritedContextMenuStrip (int rowIndex) {
+ }
+ */
+
+ public virtual DataGridViewElementStates GetInheritedState (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ public virtual DataGridViewCellStyle GetInheritedStyle (DataGridViewCellStyle inheritedCellStyle, int rowIndex, bool includeColors) {
+ /*
+ * System.InvalidOperationException :: The cell has no associated System.Windows.Forms.DataGridView, or the cell's System.Windows.Forms.DataGridViewCell.ColumnIndex is less than 0.
+ * System.ArgumentOutOfRangeException :: rowIndex is less than 0, or greater than or equal to the number of rows in the parent System.Windows.Forms.DataGridView.
+ * */
+ throw new NotImplementedException();
+ }
+
+ public virtual void InitializeEditingControl (int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle) {
+ if (DataGridView == null || DataGridView.EditingControl == null) {
+ throw new InvalidOperationException("No editing control defined");
+ }
+ }
+
+ public virtual bool KeyEntersEditMode (KeyEventArgs e) {
+ throw new NotImplementedException();
+ }
+
+ public static int MeasureTextHeight (Graphics graphics, string text, Font font, int maxWidth, TextFormatFlags flags) {
+ if (graphics == null) {
+ throw new ArgumentNullException("Graphics argument null");
+ }
+ if (font == null) {
+ throw new ArgumentNullException("Font argument null");
+ }
+ if (maxWidth < 1) {
+ throw new ArgumentOutOfRangeException("maxWidth is less than 1.");
+ }
+ // if (flags ---> InvalidEnumArgumentException
+ throw new NotImplementedException();
+ }
+
+ public static int MeasureTextHeight (Graphics graphics, string text, Font font, int maxWidth, TextFormatFlags flags, out bool widthTruncated) {
+ throw new NotImplementedException();
+ }
+
+ public static Size MeasureTextPreferredSize (Graphics graphics, string text, Font font, float maxRatio, TextFormatFlags flags) {
+ if (graphics == null) {
+ throw new ArgumentNullException("Graphics argument null");
+ }
+ if (font == null) {
+ throw new ArgumentNullException("Font argument null");
+ }
+ if (maxRatio <= 0) {
+ throw new ArgumentOutOfRangeException("maxRatio is less than or equals to 0.");
+ }
+ throw new NotImplementedException();
+ }
+
+ public static Size MeasureTextSize (Graphics graphics, string text, Font font, TextFormatFlags flags) {
+ /////////////////////////// ¿flags?
+ return graphics.MeasureString(text, font).ToSize();
+ }
+
+ public static int MeasureTextWidth (Graphics graphics, string text, Font font, int maxHeight, TextFormatFlags flags) {
+ if (graphics == null) {
+ throw new ArgumentNullException("Graphics argument null");
+ }
+ if (font == null) {
+ throw new ArgumentNullException("Font argument null");
+ }
+ if (maxHeight < 1) {
+ throw new ArgumentOutOfRangeException("maxHeight is less than 1.");
+ }
+ throw new NotImplementedException();
+ }
+
+ public virtual object ParseFormattedValue (object formattedValue, DataGridViewCellStyle cellStyle, TypeConverter formattedValueTypeConverter, TypeConverter valueTypeConverter) {
+ if (cellStyle == null) {
+ throw new ArgumentNullException("cellStyle is null.");
+ }
+ if (formattedValueType == null) {
+ throw new FormatException("The System.Windows.Forms.DataGridViewCell.FormattedValueType property value is null.");
+ }
+ if (formattedValue == null) {
+ throw new ArgumentException("formattedValue is null.");
+ }
+ if (formattedValue.GetType() != formattedValueType) {
+ }
+ return null;
+ }
+
+ public virtual void PositionEditingControl (bool setLocation, bool setSize, Rectangle cellBounds, Rectangle cellClip, DataGridViewCellStyle cellStyle, bool singleVerticalBorderAdded, bool singleHorizontalBorderAdded, bool isFirstDisplayedColumn, bool isFirstDisplayedRow) {
+ throw new NotImplementedException();
+ }
+
+ public virtual Rectangle PositionEditingPanel (Rectangle cellBounds, Rectangle cellClip, DataGridViewCellStyle cellStyle, bool singleVerticalBorderAdded, bool singleHorizontalBorderAdded, bool isFirstDisplayedColumn, bool isFirstDisplayedRow) {
+ throw new NotImplementedException();
+ }
+
+ public override string ToString () {
+ return String.Format("{0} {RowIndex = {1}, ColumnIndex = {2}}", this.GetType().FullName, RowIndex, columnIndex);
+ }
+
+ protected virtual Rectangle BorderWidths (DataGridViewAdvancedBorderStyle advancedBorderStyle) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual bool ClickUnsharesRow (DataGridViewCellEventArgs e) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual bool ContentClickUnsharesRow (DataGridViewCellEventArgs e) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual bool ContentDoubleClickUnsharesRow (DataGridViewCellEventArgs e) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual AccessibleObject CreateAccessibilityInstance () {
+ return new DataGridViewCellAccessibleObject(this);
+ }
+
+ protected virtual void Dispose (bool disposing) {
+ }
+
+ protected virtual bool DoubleClickUnsharesRow (DataGridViewCellEventArgs e) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual bool EnterUnsharesRow (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual object GetClipboardContent (int rowIndex, bool firstCell, bool lastCell, bool inFirstRow, bool inLastRow, string format) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual Rectangle GetErrorIconBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected internal virtual string GetErrorText (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual object GetFormattedValue (object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual Size GetPreferredSize (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual Size GetSize (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual object GetValue (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual bool KeyDownUnsharesRow (KeyEventArgs e, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual bool KeyPressUnsharesRow (KeyPressEventArgs e, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual bool KeyUpUnsharesRow (KeyEventArgs e, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual bool LeaveUnsharesRow ( int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual bool MouseClickUnsharesRow (DataGridViewCellMouseEventArgs e) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual bool MouseDoubleClickUnsharesRow (DataGridViewCellMouseEventArgs e) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual bool MouseDownUnsharesRow (DataGridViewCellMouseEventArgs e) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual bool MouseEnterUnsharesRow (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual bool MouseLeaveUnsharesRow (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual bool MouseMoveUnsharesRow (DataGridViewCellMouseEventArgs e) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual bool MouseUpUnsharesRow (DataGridViewCellMouseEventArgs e) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual void OnClick (DataGridViewCellEventArgs e) {
+ }
+
+ protected virtual void OnContentClick (DataGridViewCellEventArgs e) {
+ }
+
+ protected virtual void OnContentDoubleClick (DataGridViewCellEventArgs e) {
+ }
+
+ protected override void OnDataGridViewChanged () {
+ }
+
+ protected virtual void OnDoubleClick (DataGridViewCellEventArgs e) {
+ }
+
+ protected virtual void OnEnter (int rowIndex, bool throughMouseClick) {
+ }
+
+ protected virtual void OnKeyDown (KeyEventArgs e, int rowIndex) {
+ }
+
+ protected virtual void OnKeyPress (KeyPressEventArgs e, int rowIndex) {
+ }
+
+ protected virtual void OnKeyUp (KeyEventArgs e, int rowIndex) {
+ }
+
+ protected virtual void OnLeave (int rowIndex, bool throughMouseClick) {
+ }
+
+ protected virtual void OnMouseClick (DataGridViewCellMouseEventArgs e) {
+ }
+
+ protected virtual void OnMouseDoubleClick (DataGridViewCellMouseEventArgs e) {
+ }
+
+ protected virtual void OnMouseDown (DataGridViewCellMouseEventArgs e) {
+ }
+
+ protected virtual void OnMouseEnter (int rowIndex) {
+ }
+
+ protected virtual void OnMouseLeave (int rowIndex) {
+ }
+
+ protected virtual void OnMouseMove (DataGridViewCellMouseEventArgs e) {
+ }
+
+ protected virtual void OnMouseUp (DataGridViewCellMouseEventArgs e) {
+ }
+
+ protected virtual void Paint (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual void PaintBorder (Graphics graphics, Rectangle clipBounds, Rectangle bounds, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle) {
+ Pen pen = new Pen(DataGridView.GridColor);
+ /*
+ switch (advancedBorderStyle.All) {
+ case DataGridViewAdvancedCellBorderStyle.None:
+ break;
+ case DataGridViewAdvancedCellBorderStyle.Single:
+ graphics.DrawRectangle(pen, bounds);
+ break;
+ case DataGridViewAdvancedCellBorderStyle.Inset:
+ bounds.X += 1;
+ bounds.Y += 1;
+ bounds.Width -= 2;
+ bounds.Height -= 2;
+ graphics.DrawRectangle(pen, bounds);
+ break;
+ case DataGridViewAdvancedCellBorderStyle.InsetDouble:
+ case DataGridViewAdvancedCellBorderStyle.Outset:
+ case DataGridViewAdvancedCellBorderStyle.OutsetDouble:
+ case DataGridViewAdvancedCellBorderStyle.OutsetPartial:
+ break;
+ case DataGridViewAdvancedCellBorderStyle.NotSet:
+ */
+ switch (advancedBorderStyle.Left) {
+ case DataGridViewAdvancedCellBorderStyle.None:
+ break;
+ case DataGridViewAdvancedCellBorderStyle.Single:
+ graphics.DrawLine(pen, bounds.X, bounds.Y, bounds.X, bounds.Y + bounds.Height - 1);
+ break;
+ case DataGridViewAdvancedCellBorderStyle.Inset:
+ graphics.DrawLine(pen, bounds.X + 2, bounds.Y, bounds.X + 2, bounds.Y + bounds.Height - 1);
+ break;
+ case DataGridViewAdvancedCellBorderStyle.InsetDouble:
+ case DataGridViewAdvancedCellBorderStyle.Outset:
+ case DataGridViewAdvancedCellBorderStyle.OutsetDouble:
+ graphics.DrawLine(pen, bounds.X, bounds.Y, bounds.X, bounds.Y + bounds.Height - 1);
+ graphics.DrawLine(pen, bounds.X + 2, bounds.Y, bounds.X + 2, bounds.Y + bounds.Height - 1);
+ break;
+ case DataGridViewAdvancedCellBorderStyle.OutsetPartial:
+ break;
+ }
+ switch (advancedBorderStyle.Right) {
+ case DataGridViewAdvancedCellBorderStyle.None:
+ break;
+ case DataGridViewAdvancedCellBorderStyle.Single:
+ graphics.DrawLine(pen, bounds.X + bounds.Width - 1, bounds.Y, bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
+ break;
+ case DataGridViewAdvancedCellBorderStyle.Inset:
+ graphics.DrawLine(pen, bounds.X + bounds.Width + 1, bounds.Y, bounds.X + bounds.Width - 3, bounds.Y + bounds.Height - 1);
+ break;
+ case DataGridViewAdvancedCellBorderStyle.InsetDouble:
+ case DataGridViewAdvancedCellBorderStyle.Outset:
+ case DataGridViewAdvancedCellBorderStyle.OutsetDouble:
+ case DataGridViewAdvancedCellBorderStyle.OutsetPartial:
+ break;
+ }
+ switch (advancedBorderStyle.Top) {
+ case DataGridViewAdvancedCellBorderStyle.None:
+ break;
+ case DataGridViewAdvancedCellBorderStyle.Single:
+ graphics.DrawLine(pen, bounds.X, bounds.Y, bounds.X + bounds.Width - 1, bounds.Y);
+ break;
+ case DataGridViewAdvancedCellBorderStyle.Inset:
+ graphics.DrawLine(pen, bounds.X, bounds.Y + 2, bounds.X + bounds.Width - 1, bounds.Y + bounds.Height + 1);
+ break;
+ case DataGridViewAdvancedCellBorderStyle.InsetDouble:
+ case DataGridViewAdvancedCellBorderStyle.Outset:
+ case DataGridViewAdvancedCellBorderStyle.OutsetDouble:
+ case DataGridViewAdvancedCellBorderStyle.OutsetPartial:
+ break;
+ }
+ switch (advancedBorderStyle.Bottom) {
+ case DataGridViewAdvancedCellBorderStyle.None:
+ break;
+ case DataGridViewAdvancedCellBorderStyle.Single:
+ graphics.DrawLine(pen, bounds.X, bounds.Y + bounds.Height - 1, bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
+ break;
+ case DataGridViewAdvancedCellBorderStyle.Inset:
+ case DataGridViewAdvancedCellBorderStyle.InsetDouble:
+ case DataGridViewAdvancedCellBorderStyle.Outset:
+ case DataGridViewAdvancedCellBorderStyle.OutsetDouble:
+ case DataGridViewAdvancedCellBorderStyle.OutsetPartial:
+ break;
+ }
+ // break;
+ //}
+ }
+
+ protected virtual void PaintErrorIcon (Graphics graphics, Rectangle clipBounds, Rectangle cellValueBounds, string errorText) {
+ throw new NotImplementedException();
+ }
+
+ protected virtual bool SetValue (int rowIndex, object value) {
+ throw new NotImplementedException();
+ }
+
+ private void OnStyleChanged (object sender, EventArgs args) {
+ if (DataGridView != null) {
+ DataGridView.RaiseCellStyleChanged(new DataGridViewCellEventArgs(ColumnIndex, RowIndex));
+ }
+ }
+
+ internal void InternalPaint (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
+ Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
+ }
+
+ internal void SetOwningRow (DataGridViewRow row) {
+ owningRow = row;
+ }
+
+ internal void SetColumnIndex (int index) {
+ columnIndex = index;
+ }
+
+ internal void SetContentBounds (Rectangle bounds) {
+ contentBounds = bounds;
+ }
+
+ internal void SetIsInEditMode (bool isInEditMode) {
+ this.isInEditMode = isInEditMode;
+ }
+
+ internal void SetSize (Size size) {
+ this.size = size;
+ }
+
+ internal void OnErrorTextChanged (DataGridViewCellEventArgs args) {
+ if (DataGridView != null) {
+ DataGridView.OnCellErrorTextChanged(args);
+ }
+ }
+
+ [ComVisibleAttribute(true)]
+ protected class DataGridViewCellAccessibleObject : AccessibleObject {
+
+ private DataGridViewCell dataGridViewCell;
+
+ public DataGridViewCellAccessibleObject () {
+ }
+
+ public DataGridViewCellAccessibleObject (DataGridViewCell cell) {
+ this.dataGridViewCell = cell;
+ }
+
+ public override Rectangle Bounds {
+ get { throw new NotImplementedException(); }
+ }
+
+ public override string DefaultAction {
+ get { return "Edit"; }
+ }
+
+ public override string Name {
+ get { return dataGridViewCell.OwningColumn.HeaderText + ": " + dataGridViewCell.RowIndex.ToString(); }
+ }
+
+ public DataGridViewCell Owner {
+ get { return dataGridViewCell; }
+ set { dataGridViewCell = value; }
+ }
+
+ public override AccessibleObject Parent {
+ get { return dataGridViewCell.OwningRow.AccessibilityObject; }
+ }
+
+ public override AccessibleRole Role {
+ get { return AccessibleRole.Cell; }
+ }
+
+ public override AccessibleStates State {
+ get {
+ if (dataGridViewCell.Selected) {
+ return AccessibleStates.Selected;
+ }
+ else {
+ return AccessibleStates.Focused;
+ }
+ }
+ }
+
+ public override string Value {
+ get {
+ if (dataGridViewCell.FormattedValue == null) {
+ return "(null)";
+ }
+ return dataGridViewCell.FormattedValue.ToString();
+ }
+ }
+
+ public override void DoDefaultAction () {
+ if (dataGridViewCell.DataGridView.EditMode != DataGridViewEditMode.EditProgrammatically) {
+ if (dataGridViewCell.IsInEditMode) {
+ // commit edit
+ }
+ else {
+ // begin edit
+ }
+ }
+ }
+
+ public override AccessibleObject GetChild (int index) {
+ throw new NotImplementedException();
+ }
+
+ public override int GetChildCount () {
+ if (dataGridViewCell.IsInEditMode) {
+ return 1;
+ }
+ return -1;
+ }
+
+ public override AccessibleObject GetFocused () {
+ return null;
+ }
+
+ public override AccessibleObject GetSelected () {
+ return null;
+ }
+
+ public override AccessibleObject Navigate (AccessibleNavigation navigationDirection) {
+ switch (navigationDirection) {
+ case AccessibleNavigation.Right:
+ break;
+ case AccessibleNavigation.Left:
+ break;
+ case AccessibleNavigation.Next:
+ break;
+ case AccessibleNavigation.Previous:
+ break;
+ case AccessibleNavigation.Up:
+ break;
+ case AccessibleNavigation.Down:
+ break;
+ default:
+ return null;
+ }
+ return null;
+ }
+
+ public override void Select (AccessibleSelection flags) {
+ switch (flags) {
+ case AccessibleSelection.TakeFocus:
+ dataGridViewCell.dataGridViewOwner.Focus();
+ break;
+ case AccessibleSelection.TakeSelection:
+ //dataGridViewCell.Focus();
+ break;
+ case AccessibleSelection.AddSelection:
+ dataGridViewCell.dataGridViewOwner.SelectedCells.InternalAdd(dataGridViewCell);
+ break;
+ case AccessibleSelection.RemoveSelection:
+ dataGridViewCell.dataGridViewOwner.SelectedCells.InternalRemove(dataGridViewCell);
+ break;
+ }
+ }
+
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellBorderStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellBorderStyle.cs
new file mode 100644
index 00000000000..bac099e8b83
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellBorderStyle.cs
@@ -0,0 +1,47 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public enum DataGridViewCellBorderStyle {
+ Custom = 0,
+ Single = 1,
+ Raised = 2,
+ Sunken = 3,
+ None = 4,
+ SingleVertical = 5,
+ RaisedVertical = 6,
+ SunkenVertical = 7,
+ SingleHorizontal = 8,
+ RaisedHorizontal = 9,
+ SunkenHorizontal = 10
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellCancelEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellCancelEventArgs.cs
new file mode 100644
index 00000000000..8f009afe0d1
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellCancelEventArgs.cs
@@ -0,0 +1,55 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewCellCancelEventArgs : CancelEventArgs {
+
+ private int columnIndex;
+ private int rowIndex;
+
+ public DataGridViewCellCancelEventArgs (int columnIndex, int rowIndex) {
+ this.columnIndex = columnIndex;
+ this.rowIndex = rowIndex;
+ }
+
+ public int ColumnIndex {
+ get { return columnIndex; }
+ }
+
+ public int RowIndex {
+ get { return rowIndex; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellCancelEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellCancelEventHandler.cs
new file mode 100644
index 00000000000..f98ab541fa7
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellCancelEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewCellCancelEventHandler (object sender, DataGridViewCellCancelEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellCollection.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellCollection.cs
new file mode 100644
index 00000000000..0e696eecde7
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellCollection.cs
@@ -0,0 +1,164 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.ComponentModel;
+using System.Collections;
+
+namespace System.Windows.Forms {
+
+
+ public class DataGridViewCellCollection : BaseCollection, IList, ICollection, IEnumerable {
+
+ private DataGridViewRow dataGridViewRow;
+
+ public DataGridViewCellCollection (DataGridViewRow dataGridViewRow) : base() {
+ this.dataGridViewRow = dataGridViewRow;
+ }
+
+ public bool IsFixedSize {
+ get { return base.List.IsFixedSize; }
+ }
+
+ object IList.this [int index] {
+ get { return this[index]; }
+ set { this[index] = value as DataGridViewCell; }
+ }
+
+ public DataGridViewCell this [int index] {
+ get { return (DataGridViewCell) base.List[index]; }
+ set { Insert(index, value); }
+ }
+
+ public DataGridViewCell this [string columnName] {
+ get {
+ foreach (DataGridViewCell cell in base.List) {
+ if (cell.OwningColumn.Name == columnName) {
+ return cell;
+ }
+ }
+ return null;
+ }
+ set {
+ for (int i = 0; i < base.List.Count; i++) {
+ DataGridViewCell cell = (DataGridViewCell) base.List[i];
+ if (cell.OwningColumn.Name == columnName) {
+ Insert(i, value);
+ return;
+ }
+ }
+ Add(value);
+ }
+ }
+
+ public event CollectionChangeEventHandler CollectionChanged;
+
+ int IList.Add (object o) {
+ return Add(o as DataGridViewCell);
+ }
+
+ public virtual int Add (DataGridViewCell dataGridViewCell) {
+ dataGridViewCell.SetOwningRow(dataGridViewRow);
+ dataGridViewCell.SetColumnIndex(base.List.Count);
+ dataGridViewCell.SetDataGridView(dataGridViewRow.DataGridView);
+ int result = base.List.Add(dataGridViewCell);
+ OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, dataGridViewCell));
+ return result;
+ }
+
+ public virtual void AddRange (params DataGridViewCell[] dataGridViewCells) {
+ foreach (DataGridViewCell cell in dataGridViewCells) {
+ this.Add(cell);
+ }
+ }
+
+ public virtual void Clear () {
+ base.List.Clear();
+ }
+
+ bool IList.Contains (object o) {
+ return Contains(o as DataGridViewCell);
+ }
+
+ public virtual bool Contains (DataGridViewCell dataGridViewCell) {
+ return base.List.Contains(dataGridViewCell);
+ }
+
+ public void CopyTo (DataGridViewCell[] array, int index) {
+ base.List.CopyTo(array, index);
+ }
+
+ int IList.IndexOf (object o) {
+ return IndexOf(o as DataGridViewCell);
+ }
+
+ public int IndexOf (DataGridViewCell dataGridViewCell) {
+ return base.List.IndexOf(dataGridViewCell);
+ }
+
+ void IList.Insert (int index, object o) {
+ Insert(index, o as DataGridViewCell);
+ }
+
+ public virtual void Insert (int index, DataGridViewCell dataGridViewCell) {
+ dataGridViewCell.SetOwningRow(dataGridViewRow);
+ dataGridViewCell.SetColumnIndex(index);
+ dataGridViewCell.SetDataGridView(dataGridViewRow.DataGridView);
+ base.List.Insert(index, dataGridViewCell);
+ OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, dataGridViewCell));
+ }
+
+ void IList.Remove (object o) {
+ Remove(o as DataGridViewCell);
+ }
+
+ public virtual void Remove (DataGridViewCell dataGridViewCell) {
+ base.List.Remove(dataGridViewCell);
+ OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Remove, dataGridViewCell));
+ }
+
+ public virtual void RemoveAt (int index) {
+ DataGridViewCell cell = this[index];
+ base.List.RemoveAt(index);
+ OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Remove, cell));
+ }
+
+ protected override ArrayList List {
+ get { return base.List; }
+ }
+
+ protected void OnCollectionChanged (CollectionChangeEventArgs e) {
+ if (CollectionChanged != null) {
+ CollectionChanged(this, e);
+ }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellContextMenuStripNeededEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellContextMenuStripNeededEventArgs.cs
new file mode 100644
index 00000000000..facb7d14c7a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellContextMenuStripNeededEventArgs.cs
@@ -0,0 +1,49 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewCellContextMenuStripNeededEventArgs : DataGridViewCellEventArgs {
+
+ //private ContextMenuStrip contextMenuStrip;
+
+ public DataGridViewCellContextMenuStripNeededEventArgs (int columnIndex, int rowIndex) : base (columnIndex, rowIndex) {
+ }
+
+ /*
+ public ContextMenuStrip ContextMenuStrip {
+ get { return contextMenuStrip; }
+ set { contextMenuStrip = value; }
+ }
+ */
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellContextMenuStripNeededEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellContextMenuStripNeededEventHandler.cs
new file mode 100644
index 00000000000..f5f1c54a549
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellContextMenuStripNeededEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewCellContextMenuStripNeededEventHandler (object sender, DataGridViewCellContextMenuStripNeededEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellErrorTextNeededEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellErrorTextNeededEventArgs.cs
new file mode 100644
index 00000000000..47e641fc4e2
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellErrorTextNeededEventArgs.cs
@@ -0,0 +1,48 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewCellErrorTextNeededEventArgs : DataGridViewCellEventArgs {
+
+ private string errorText;
+
+ internal DataGridViewCellErrorTextNeededEventArgs (string errorText, int rowIndex, int columnIndex) : base (columnIndex, rowIndex) {
+ this.errorText = errorText;
+ }
+
+ public string ErrorText {
+ get { return errorText; }
+ set { errorText = value; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellErrorTextNeededEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellErrorTextNeededEventHandler.cs
new file mode 100644
index 00000000000..feea38e6e77
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellErrorTextNeededEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewCellErrorTextNeededEventHandler (object sender, DataGridViewCellErrorTextNeededEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellEventArgs.cs
new file mode 100644
index 00000000000..489be1db6e7
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellEventArgs.cs
@@ -0,0 +1,53 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewCellEventArgs : EventArgs {
+
+ private int columnIndex;
+ private int rowIndex;
+
+ public DataGridViewCellEventArgs (int columnIndex, int rowIndex) {
+ this.columnIndex = columnIndex;
+ this.rowIndex = rowIndex;
+ }
+
+ public int ColumnIndex {
+ get { return columnIndex; }
+ }
+
+ public int RowIndex {
+ get { return rowIndex; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellEventHandler.cs
new file mode 100644
index 00000000000..1e73b3f65d9
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewCellEventHandler (object sender, DataGridViewCellEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellFormattingEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellFormattingEventArgs.cs
new file mode 100644
index 00000000000..e822d9d491a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellFormattingEventArgs.cs
@@ -0,0 +1,69 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewCellFormattingEventArgs : ConvertEventArgs {
+
+ private int columnIndex;
+ private DataGridViewCellStyle cellStyle;
+ private bool formattingApplied = false;
+ private int rowIndex;
+
+ public DataGridViewCellFormattingEventArgs (int columnIndex, int rowIndex, object value, Type desiredType, DataGridViewCellStyle cellStyle) : base (value, desiredType) {
+ this.columnIndex = columnIndex;
+ this.rowIndex = rowIndex;
+ this.cellStyle = cellStyle;
+ }
+
+ public DataGridViewCellStyle CellStyle {
+ get { return cellStyle; }
+ set {
+ cellStyle = value;
+ }
+ }
+
+ public int ColumnIndex {
+ get { return columnIndex; }
+ }
+
+ ////////////////////////////////////////////////
+ public bool FormattingApplied {
+ get { return formattingApplied; }
+ set { formattingApplied = value; }
+ }
+
+ public int RowIndex {
+ get { return rowIndex; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellFormattingEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellFormattingEventHandler.cs
new file mode 100644
index 00000000000..c2f1980a0da
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellFormattingEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewCellFormattingEventHandler (object sender, DataGridViewCellFormattingEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellMouseEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellMouseEventArgs.cs
new file mode 100644
index 00000000000..7f2fa85d9e7
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellMouseEventArgs.cs
@@ -0,0 +1,53 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewCellMouseEventArgs : MouseEventArgs {
+
+ private int columnIndex;
+ private int rowIndex;
+
+ public DataGridViewCellMouseEventArgs (int columnIndex, int rowIndex, int localX, int localY, MouseEventArgs e) : base (e.Button, e.Clicks, localX, localY, e.Delta) {
+ this.columnIndex = columnIndex;
+ this.rowIndex = rowIndex;
+ }
+
+ public int ColumnIndex {
+ get { return columnIndex; }
+ }
+
+ public int RowIndex {
+ get { return rowIndex; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellMouseEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellMouseEventHandler.cs
new file mode 100644
index 00000000000..1a04249fa4b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellMouseEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewCellMouseEventHandler (object sender, DataGridViewCellMouseEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellPaintingEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellPaintingEventArgs.cs
new file mode 100644
index 00000000000..10472a20e69
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellPaintingEventArgs.cs
@@ -0,0 +1,157 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.ComponentModel;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewCellPaintingEventArgs : HandledEventArgs {
+
+ private DataGridView dataGridView;
+ private Graphics graphics;
+ private Rectangle clipBounds;
+ private Rectangle cellBounds;
+ private int rowIndex;
+ private int columnIndex;
+ private DataGridViewElementStates cellState;
+ private object cellValue;
+ private object formattedValue;
+ private string errorText;
+ private DataGridViewCellStyle cellStyle;
+ private DataGridViewAdvancedBorderStyle advancedBorderStyle;
+ private DataGridViewPaintParts paintParts;
+
+ public DataGridViewCellPaintingEventArgs (DataGridView dataGridView, Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, int columnIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
+ this.dataGridView = dataGridView;
+ this.graphics = graphics;
+ this.clipBounds = clipBounds;
+ this.cellBounds = cellBounds;
+ this.rowIndex = rowIndex;
+ this.columnIndex = columnIndex;
+ this.cellState = cellState;
+ this.cellValue = value;
+ this.formattedValue = formattedValue;
+ this.errorText = errorText;
+ this.cellStyle = cellStyle;
+ this.advancedBorderStyle = advancedBorderStyle;
+ this.paintParts = paintParts;
+ }
+
+ public DataGridViewAdvancedBorderStyle AdvancedBorderStyle {
+ get { return advancedBorderStyle; }
+ }
+
+ public Rectangle CellBounds {
+ get { return cellBounds; }
+ }
+
+ public DataGridViewCellStyle CellStyle {
+ get { return cellStyle; }
+ }
+
+ public Rectangle ClipBounds {
+ get { return clipBounds; }
+ }
+
+ public int ColumnIndex {
+ get { return columnIndex; }
+ }
+
+ public string ErrorText {
+ get { return errorText; }
+ }
+
+ public object FormattedValue {
+ get { return formattedValue; }
+ }
+
+ public Graphics Graphics {
+ get { return graphics; }
+ }
+
+ public DataGridViewPaintParts PaintParts {
+ get { return paintParts; }
+ }
+
+ public int RowIndex {
+ get { return rowIndex; }
+ }
+
+ public DataGridViewElementStates State {
+ get { return cellState; }
+ }
+
+ public object Value {
+ get { return cellValue; }
+ }
+
+ public void Paint (Rectangle clipBounds, DataGridViewPaintParts paintParts) {
+ if (rowIndex < -1 || rowIndex >= dataGridView.Rows.Count) {
+ throw new InvalidOperationException("Invalid \"RowIndex.\"");
+ }
+ if (columnIndex < -1 || columnIndex >= dataGridView.Columns.Count) {
+ throw new InvalidOperationException("Invalid \"ColumnIndex.\"");
+ }
+ throw new NotImplementedException();
+ }
+
+ public void PaintBackground (Rectangle clipBounds, bool cellsPaintSelectionBackground) {
+ if (rowIndex < -1 || rowIndex >= dataGridView.Rows.Count) {
+ throw new InvalidOperationException("Invalid \"RowIndex.\"");
+ }
+ if (columnIndex < -1 || columnIndex >= dataGridView.Columns.Count) {
+ throw new InvalidOperationException("Invalid \"ColumnIndex.\"");
+ }
+ DataGridViewCell cell = dataGridView.Rows[rowIndex].Cells[columnIndex];
+ Color color;
+ if (cellsPaintSelectionBackground) {
+ color = cell.InheritedStyle.SelectionBackColor;
+ }
+ else {
+ color = cell.InheritedStyle.BackColor;
+ }
+ ///////// NOT CHECKED //////////////
+ graphics.FillRectangle(new SolidBrush(color), clipBounds);
+ }
+
+ public void PaintContent (Rectangle clipBounds) {
+ if (rowIndex < -1 || rowIndex >= dataGridView.Rows.Count) {
+ throw new InvalidOperationException("Invalid \"RowIndex.\"");
+ }
+ if (columnIndex < -1 || columnIndex >= dataGridView.Columns.Count) {
+ throw new InvalidOperationException("Invalid \"ColumnIndex.\"");
+ }
+ throw new NotImplementedException();
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellPaintingEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellPaintingEventHandler.cs
new file mode 100644
index 00000000000..a84e57b4420
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellPaintingEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewCellPaintingEventHandler (object sender, DataGridViewCellPaintingEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellParsingEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellParsingEventArgs.cs
new file mode 100644
index 00000000000..ce491c8b521
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellParsingEventArgs.cs
@@ -0,0 +1,66 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewCellParsingEventArgs : ConvertEventArgs {
+
+ private int columnIndex;
+ private DataGridViewCellStyle inheritedCellStyle;
+ private bool parsingApplied = false;
+ private int rowIndex;
+
+ public DataGridViewCellParsingEventArgs (int columnIndex, int rowIndex, object value, Type desiredType, DataGridViewCellStyle inheritedCellStyle) : base (value, desiredType) {
+ this.columnIndex = columnIndex;
+ this.rowIndex = rowIndex;
+ this.inheritedCellStyle = inheritedCellStyle;
+ }
+
+ public DataGridViewCellStyle InheritedCellStyle {
+ get { return inheritedCellStyle; }
+ set { inheritedCellStyle = value; }
+ }
+
+ public int ColumnIndex {
+ get { return columnIndex; }
+ }
+
+ public bool ParsingApplied {
+ get { return parsingApplied; }
+ set { parsingApplied = value; }
+ }
+
+ public int RowIndex {
+ get { return rowIndex; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellParsingEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellParsingEventHandler.cs
new file mode 100644
index 00000000000..657446250ab
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellParsingEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewCellParsingEventHandler (object sender, DataGridViewCellParsingEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStateChangedEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStateChangedEventArgs.cs
new file mode 100644
index 00000000000..19e0c261469
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStateChangedEventArgs.cs
@@ -0,0 +1,53 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewCellStateChangedEventArgs : EventArgs {
+
+ private DataGridViewCell dataGridViewCell;
+ private DataGridViewElementStates stateChanged;
+
+ public DataGridViewCellStateChangedEventArgs (DataGridViewCell dataGridViewCell, DataGridViewElementStates stateChanged) {
+ this.dataGridViewCell = dataGridViewCell;
+ this.stateChanged = stateChanged;
+ }
+
+ public DataGridViewCell Cell {
+ get { return dataGridViewCell; }
+ }
+
+ public DataGridViewElementStates StateChanged {
+ get { return stateChanged; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStateChangedEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStateChangedEventHandler.cs
new file mode 100644
index 00000000000..3f648ab7601
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStateChangedEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewCellStateChangedEventHandler (object sender, DataGridViewCellStateChangedEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyle.cs
new file mode 100644
index 00000000000..9e0cb067571
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyle.cs
@@ -0,0 +1,286 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.Drawing;
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewCellStyle : ICloneable {
+
+ private DataGridViewContentAlignment alignment;
+ private Color backColor;
+ private object dataSourceNullValue;
+ private Font font;
+ private Color foreColor;
+ private string format;
+ private IFormatProvider formatProvider;
+ private object nullValue;
+ private Padding padding;
+ private Color selectionBackColor;
+ private Color selectionForeColor;
+ private object tag;
+ private DataGridViewTriState wrapMode;
+
+ public DataGridViewCellStyle () {
+ alignment = DataGridViewContentAlignment.NotSet;
+ backColor = Color.Empty;
+ font = null;
+ foreColor = Color.Empty;
+ format = String.Empty;
+ formatProvider = System.Globalization.CultureInfo.CurrentUICulture;
+ nullValue = "(null)";
+ padding = Padding.Empty;
+ selectionBackColor = Color.Empty;
+ selectionForeColor = Color.Empty;
+ tag = null;
+ wrapMode = DataGridViewTriState.NotSet;
+ }
+
+ public DataGridViewCellStyle (DataGridViewCellStyle dataGridViewCellStyle) {
+ ApplyStyle(dataGridViewCellStyle);
+ }
+
+ public DataGridViewContentAlignment Alignment {
+ get { return alignment; }
+ set {
+ if (!Enum.IsDefined(typeof(DataGridViewContentAlignment), value)) {
+ throw new InvalidEnumArgumentException("Value is not valid DataGridViewContentAlignment.");
+ }
+ if (alignment != value) {
+ alignment = value;
+ OnStyleChanged();
+ }
+ }
+ }
+
+ public Color BackColor {
+ get { return backColor; }
+ set {
+ if (backColor != value) {
+ backColor = value;
+ OnStyleChanged();
+ }
+ }
+ }
+
+ public object DataSourceNullValue {
+ get { return dataSourceNullValue; }
+ set {
+ if (dataSourceNullValue != value) {
+ dataSourceNullValue = value;
+ OnStyleChanged();
+ }
+ }
+ }
+
+ public Font Font {
+ get { return font; }
+ set {
+ if (font != value) {
+ font = value;
+ OnStyleChanged();
+ }
+ }
+ }
+
+ public Color ForeColor {
+ get { return foreColor; }
+ set {
+ if (foreColor != value) {
+ foreColor = value;
+ OnStyleChanged();
+ }
+ }
+ }
+
+ public string Format {
+ get { return format; }
+ set {
+ if (format != value) {
+ format = value;
+ OnStyleChanged();
+ }
+ }
+ }
+
+ public IFormatProvider FormatProvider {
+ get { return formatProvider; }
+ set {
+ if (formatProvider != value) {
+ formatProvider = value;
+ OnStyleChanged();
+ }
+ }
+ }
+
+ public bool IsDataSourceNullValueDefault {
+ get { return dataSourceNullValue != null; }
+ }
+
+ public bool IsFormatProviderDefault {
+ get { return formatProvider == System.Globalization.CultureInfo.CurrentUICulture; }
+ }
+
+ public bool IsNullValueDefault {
+ get {
+ if (nullValue is string) {
+ return (string) nullValue == "(null)";
+ }
+ return false;
+ }
+ }
+
+ public object NullValue {
+ get { return nullValue; }
+ set {
+ if (nullValue != value) {
+ nullValue = value;
+ OnStyleChanged();
+ }
+ }
+ }
+
+ public Padding Padding {
+ get { return padding; }
+ set {
+ if (padding != value) {
+ padding = value;
+ OnStyleChanged();
+ }
+ }
+ }
+
+ public Color SelectionBackColor {
+ get { return selectionBackColor; }
+ set {
+ if (value != Color.Empty && (int) value.A != 255) {
+ throw new ArgumentException("BackColor can't have alpha transparency component.");
+ }
+ if (selectionBackColor != value) {
+ selectionBackColor = value;
+ OnStyleChanged();
+ }
+ }
+ }
+
+ public Color SelectionForeColor {
+ get { return selectionForeColor; }
+ set {
+ if (selectionForeColor != value) {
+ selectionForeColor = value;
+ OnStyleChanged();
+ }
+ }
+ }
+
+ public object Tag {
+ get { return tag; }
+ set {
+ if (tag != value) {
+ tag = value;
+ OnStyleChanged();
+ }
+ }
+ }
+
+ public DataGridViewTriState WrapMode {
+ get { return wrapMode; }
+ set {
+ if (!Enum.IsDefined(typeof(DataGridViewTriState), value)) {
+ throw new InvalidEnumArgumentException("Value is not valid DataGridViewTriState.");
+ }
+ if (wrapMode != value) {
+ wrapMode = value;
+ OnStyleChanged();
+ }
+ }
+ }
+
+ public virtual void ApplyStyle (DataGridViewCellStyle dataGridViewCellStyle) {
+ this.alignment = dataGridViewCellStyle.alignment;
+ this.backColor = dataGridViewCellStyle.backColor;
+ this.dataSourceNullValue = dataGridViewCellStyle.dataSourceNullValue;
+ this.font = dataGridViewCellStyle.font;
+ this.foreColor = dataGridViewCellStyle.foreColor;
+ this.format = dataGridViewCellStyle.format;
+ this.formatProvider = dataGridViewCellStyle.formatProvider;
+ this.nullValue = dataGridViewCellStyle.nullValue;
+ this.padding = dataGridViewCellStyle.padding;
+ this.selectionBackColor = dataGridViewCellStyle.selectionBackColor;
+ this.selectionForeColor = dataGridViewCellStyle.selectionForeColor;
+ this.tag = dataGridViewCellStyle.tag;
+ this.wrapMode = dataGridViewCellStyle.wrapMode;
+ }
+
+ public virtual object Clone () {
+ return new DataGridViewCellStyle(this);
+ }
+
+ public override bool Equals (object o) {
+ if (o is DataGridViewCellStyle) {
+ DataGridViewCellStyle o_aux = (DataGridViewCellStyle) o;
+ return this.alignment == o_aux.alignment &&
+ this.backColor == o_aux.backColor &&
+ this.dataSourceNullValue == o_aux.dataSourceNullValue &&
+ this.font == o_aux.font &&
+ this.foreColor == o_aux.foreColor &&
+ this.format == o_aux.format &&
+ this.formatProvider == o_aux.formatProvider &&
+ this.nullValue == o_aux.nullValue &&
+ this.padding == o_aux.padding &&
+ this.selectionBackColor == o_aux.selectionBackColor &&
+ this.selectionForeColor == o_aux.selectionForeColor &&
+ this.tag == o_aux.tag &&
+ this.wrapMode == o_aux.wrapMode;
+ }
+ return false;
+ }
+
+ public override int GetHashCode () {
+ return base.GetHashCode();
+ }
+
+ public override string ToString () {
+ /////////////////////////////////////// COMPROBAR EN Windows ////////////////////////////////
+ return "";
+ }
+
+ internal event EventHandler StyleChanged;
+
+ internal void OnStyleChanged () {
+ if (StyleChanged != null) {
+ StyleChanged(this, EventArgs.Empty);
+ }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyleContentChangedEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyleContentChangedEventArgs.cs
new file mode 100644
index 00000000000..32a1b187e3a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyleContentChangedEventArgs.cs
@@ -0,0 +1,53 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewCellStyleContentChangedEventArgs : EventArgs {
+
+ private DataGridViewCellStyle cellStyle;
+ private DataGridViewCellStyleScopes cellStyleScope;
+
+ internal DataGridViewCellStyleContentChangedEventArgs (DataGridViewCellStyle cellStyle, DataGridViewCellStyleScopes cellStyleScope) {
+ this.cellStyle = cellStyle;
+ this.cellStyleScope = cellStyleScope;
+ }
+
+ public DataGridViewCellStyle CellStyle {
+ get { return cellStyle; }
+ }
+
+ public DataGridViewCellStyleScopes CellStyleScope {
+ get { return cellStyleScope; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyleContentChangedEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyleContentChangedEventHandler.cs
new file mode 100644
index 00000000000..939ba993f1f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyleContentChangedEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewCellStyleContentChangedEventHandler (object sender, DataGridViewCellStyleContentChangedEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyleConverter.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyleConverter.cs
new file mode 100644
index 00000000000..623a5b9daae
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyleConverter.cs
@@ -0,0 +1,50 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+#if NET_2_0
+
+using System.ComponentModel;
+using System.Globalization;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewCellStyleConverter : TypeConverter {
+
+ public DataGridViewCellStyleConverter () {
+ }
+
+ public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType) {
+ throw new NotImplementedException();
+ }
+
+ public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
+ throw new NotImplementedException();
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyleScopes.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyleScopes.cs
new file mode 100644
index 00000000000..ca3c58a6ed8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellStyleScopes.cs
@@ -0,0 +1,45 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ [FlagsAttribute()]
+ public enum DataGridViewCellStyleScopes {
+ None = 0,
+ Cell = 1,
+ Column = 2,
+ Row = 4,
+ DataGridView = 8,
+ ColumnHeaders = 16,
+ RowHeaders = 32,
+ Rows = 64,
+ AlternatingRows = 128
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellToolTipTextNeededEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellToolTipTextNeededEventArgs.cs
new file mode 100644
index 00000000000..5397a381425
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellToolTipTextNeededEventArgs.cs
@@ -0,0 +1,48 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewCellToolTipTextNeededEventArgs : DataGridViewCellEventArgs {
+
+ private string toolTipText;
+
+ internal DataGridViewCellToolTipTextNeededEventArgs (string toolTipText, int rowIndex, int columnIndex) : base (columnIndex, rowIndex) {
+ this.toolTipText = toolTipText;
+ }
+
+ public string ToolTipText {
+ get { return toolTipText; }
+ set { toolTipText = value; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellToolTipTextNeededEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellToolTipTextNeededEventHandler.cs
new file mode 100644
index 00000000000..a0f7334b15a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellToolTipTextNeededEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewCellToolTipTextNeededEventHandler (object sender, DataGridViewCellToolTipTextNeededEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellValidatingEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellValidatingEventArgs.cs
new file mode 100644
index 00000000000..a182080a3fb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellValidatingEventArgs.cs
@@ -0,0 +1,60 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewCellValidatingEventArgs : CancelEventArgs {
+
+ private int columnIndex;
+ private object formattedValue;
+ private int rowIndex;
+
+ public DataGridViewCellValidatingEventArgs (int columnIndex, int rowIndex, object formattedValue) {
+ this.columnIndex = columnIndex;
+ this.rowIndex = rowIndex;
+ }
+
+ public int ColumnIndex {
+ get { return columnIndex; }
+ }
+
+ public object FormattedValue {
+ get { return formattedValue; }
+ }
+
+ public int RowIndex {
+ get { return rowIndex; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellValidatingEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellValidatingEventHandler.cs
new file mode 100644
index 00000000000..0c83d637184
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellValidatingEventHandler.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewCellValidatingEventHandler (object sender, DataGridViewCellValidatingEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellValueEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellValueEventArgs.cs
new file mode 100644
index 00000000000..eeb39b855fa
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellValueEventArgs.cs
@@ -0,0 +1,59 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewCellValueEventArgs : EventArgs {
+
+ private int columnIndex;
+ private int rowIndex;
+ private object cellValue;
+
+ public DataGridViewCellValueEventArgs (int columnIndex, int rowIndex) {
+ this.columnIndex = columnIndex;
+ this.rowIndex = rowIndex;
+ }
+
+ public int ColumnIndex {
+ get { return columnIndex; }
+ }
+
+ public int RowIndex {
+ get { return rowIndex; }
+ }
+
+ public object Value {
+ get { return cellValue; }
+ set { cellValue = value; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellValueEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellValueEventHandler.cs
new file mode 100644
index 00000000000..e48dc062f1a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellValueEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewCellValueEventHandler (object sender, DataGridViewCellValueEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCheckBoxCell.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCheckBoxCell.cs
new file mode 100644
index 00000000000..3ee310891ac
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCheckBoxCell.cs
@@ -0,0 +1,322 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System;
+using System.ComponentModel;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewCheckBoxCell : DataGridViewCell, IDataGridViewEditingCell {
+
+ private object editingCellFormattedValue;
+ private bool editingCellValueChanged;
+ private object falseValue;
+ private FlatStyle flatStyle;
+ private object indeterminateValue;
+ private bool threeState;
+ private object trueValue;
+ private Type valueType;
+
+ public DataGridViewCheckBoxCell () {
+ editingCellValueChanged = false;
+ falseValue = null;
+ flatStyle = FlatStyle.Standard;
+ indeterminateValue = null;
+ threeState = false;
+ trueValue = null;
+ valueType = null;
+ }
+
+ public DataGridViewCheckBoxCell (bool threeState) : this() {
+ }
+
+ public virtual object EditingCellFormattedValue {
+ get { return editingCellFormattedValue; }
+ set {
+ if (FormattedValueType == null || value == null || value.GetType() != FormattedValueType || !(value is Boolean) || !(value is CheckState)) {
+ throw new ArgumentException("Cannot set this property.");
+ }
+ editingCellFormattedValue = value;
+ }
+ }
+
+ public virtual bool EditingCellValueChanged {
+ get { return editingCellValueChanged; }
+ set { editingCellValueChanged = value; }
+ }
+
+ public override Type EditType {
+ get { return null; }
+ }
+
+ public object FalseValue {
+ get { return falseValue; }
+ set { falseValue = value; }
+ }
+
+ public FlatStyle FlatStyle {
+ get { return flatStyle; }
+ set {
+ if (!Enum.IsDefined(typeof(FlatStyle), value)) {
+ throw new InvalidEnumArgumentException("Value is not valid FlatStyle.");
+ }
+ if (value == FlatStyle.Popup) {
+ throw new Exception("FlatStyle cannot be set to Popup in this control.");
+ }
+ }
+ }
+
+ public override Type FormattedValueType {
+ get {
+ if (ThreeState) {
+ return typeof(CheckState);
+ }
+ return typeof(Boolean);
+ }
+ }
+
+ public object IndeterminateValue {
+ get { return indeterminateValue; }
+ set { indeterminateValue = value; }
+ }
+
+ public bool ThreeState {
+ get { return threeState; }
+ set { threeState = value; }
+ }
+
+ public object TrueValue {
+ get { return trueValue; }
+ set { trueValue = value; }
+ }
+
+ public override Type ValueType {
+ get {
+ if (valueType == null) {
+ if (OwningColumn != null) {
+ return OwningColumn.ValueType;
+ }
+ if (ThreeState) {
+ return typeof(CheckState);
+ }
+ return typeof(Boolean);
+ }
+ return valueType;
+ }
+ set { valueType = value; }
+ }
+
+ public override object Clone () {
+ DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell) base.Clone();
+ cell.editingCellValueChanged = this.editingCellValueChanged;
+ cell.falseValue = this.falseValue;
+ cell.flatStyle = this.flatStyle;
+ cell.indeterminateValue = this.indeterminateValue;
+ cell.threeState = this.threeState;
+ cell.trueValue = this.trueValue;
+ cell.valueType = this.valueType;
+ return cell;
+ }
+
+ public virtual object GetEditingCellFormattedValue (DataGridViewDataErrorContexts context) {
+ if (FormattedValueType == null) {
+ throw new InvalidOperationException("FormattedValueType is null.");
+ }
+ if ((context & DataGridViewDataErrorContexts.ClipboardContent) != 0) {
+ return Convert.ToString(Value);
+ }
+ if (ThreeState) {
+ return (CheckState) Value;
+ }
+ return (Boolean) Value;
+ }
+
+ public override object ParseFormattedValue (object formattedValue, DataGridViewCellStyle cellStyle, TypeConverter formattedValueTypeConverter, TypeConverter valueTypeConverter) {
+ if (cellStyle == null) {
+ throw new ArgumentNullException("CellStyle is null");
+ }
+ if (FormattedValueType == null) {
+ throw new FormatException("FormattedValueType is null.");
+ }
+ if (formattedValue == null || formattedValue.GetType() != FormattedValueType) {
+ throw new ArgumentException("FormattedValue is null or is not instance of FormattedValueType.");
+ }
+ throw new NotImplementedException();
+ }
+
+ public virtual void PrepareEditingCellForEdit (bool selectAll) {
+ }
+
+ public override string ToString () {
+ return GetType().Name + ": RowIndex: " + RowIndex.ToString() + "; ColumnIndex: " + ColumnIndex.ToString() + ";";
+ }
+
+ protected override bool ContentClickUnsharesRow (DataGridViewCellEventArgs e) {
+ return this.IsInEditMode;
+ }
+
+ //protected override bool ContentDoubleClickUnsaresRow (DataGridViewCellEventArgs e) {
+ protected bool ContentDoubleClickUnsaresRow (DataGridViewCellEventArgs e) {
+ return this.IsInEditMode;
+ }
+
+ protected override AccessibleObject CreateAccessibilityInstance () {
+ return new DataGridViewCheckBoxCellAccessibleObject(this);
+ }
+
+ protected override Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override Rectangle GetErrorIconBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ //protected override object GetFormttedValue (object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context) {
+ protected object GetFormttedValue (object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context) {
+ if (DataGridView == null) {
+ return null;
+ }
+ throw new NotImplementedException();
+ }
+
+ protected override Size GetPreferredSize (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) {
+ throw new NotImplementedException();
+ }
+
+ protected override object GetValue (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override bool KeyDownUnsharesRow (KeyEventArgs e, int rowIndex) {
+ // true if the user pressed the SPACE key without modifier keys; otherwise, false
+ throw new NotImplementedException();
+ }
+
+ protected override bool KeyUpUnsharesRow (KeyEventArgs e, int rowIndex) {
+ // true if the user released the SPACE key; otherwise false
+ throw new NotImplementedException();
+
+ }
+
+ protected override bool MouseDownUnsharesRow (DataGridViewCellMouseEventArgs e) {
+ return (e.Button == MouseButtons.Left);
+ }
+
+ protected override bool MouseEnterUnsharesRow (int rowIndex) {
+ // true if the cell was the last cell receiving a mouse click; otherwise, false.
+ throw new NotImplementedException();
+ }
+
+ protected override bool MouseLeaveUnsharesRow (int rowIndex) {
+ // true if the button displayed by the cell is in the pressed state; otherwise, false.
+ throw new NotImplementedException();
+ }
+
+ protected override bool MouseUpUnsharesRow (DataGridViewCellMouseEventArgs e) {
+ // true if the mouse up was caused by the release of the left mouse button; otherwise false.
+ throw new NotImplementedException();
+ }
+
+ protected override void OnContentClick (DataGridViewCellEventArgs e) {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnContentDoubleClick (DataGridViewCellEventArgs e) {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnKeyDown (KeyEventArgs e, int rowIndex) {
+ // when activated by the SPACE key, this method updates the cell's user interface
+ throw new NotImplementedException();
+ }
+
+ protected override void OnKeyUp (KeyEventArgs e, int rowIndex) {
+ // when activated by the SPACE key, this method updates the cell's user interface
+ throw new NotImplementedException();
+ }
+
+ protected override void OnLeave (int rowIndex, bool throughMouseClick) {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnMouseDown (DataGridViewCellMouseEventArgs e) {
+ // if activated by depresing the left mouse button, this method updates the cell's user interface
+ throw new NotImplementedException();
+ }
+
+ protected override void OnMouseEnter (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnMouseLeave (int rowIndex) {
+ // if the cell's button is not in its normal state, this method causes the cell's user interface to be updated.
+ throw new NotImplementedException();
+ }
+
+ protected override void OnMouseUp (DataGridViewCellMouseEventArgs e) {
+ // if activated by the left mouse button, this method updates the cell's user interface
+ throw new NotImplementedException();
+ }
+
+ protected override void Paint (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
+ throw new NotImplementedException();
+ }
+
+ protected class DataGridViewCheckBoxCellAccessibleObject : DataGridViewCellAccessibleObject {
+
+ public DataGridViewCheckBoxCellAccessibleObject (DataGridViewCell owner) : base(owner) {
+ }
+
+ public override string DefaultAction {
+ get {
+ if (Owner.ReadOnly) {
+ return "";
+ }
+ // return "Press to check" if the check box is not selected
+ // and "Press to uncheck" if the check box is selected
+ throw new NotImplementedException();
+ }
+ }
+
+ public override void DoDefaultAction () {
+ // change the state of the check box
+ }
+
+ public override int GetChildCount () {
+ return -1;
+ }
+
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCheckBoxColumn.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCheckBoxColumn.cs
new file mode 100644
index 00000000000..13004b293b9
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCheckBoxColumn.cs
@@ -0,0 +1,134 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewCheckBoxColumn : DataGridViewColumn {
+
+ public DataGridViewCheckBoxColumn (bool threeState) {
+ CellTemplate = new DataGridViewCheckBoxCell();
+ (CellTemplate as DataGridViewCheckBoxCell).ThreeState = threeState;
+ }
+
+ public DataGridViewCheckBoxColumn () : this (false) {
+ }
+
+ public override DataGridViewCell CellTemplate {
+ get { return base.CellTemplate; }
+ set { base.CellTemplate = value as DataGridViewCheckBoxCell; }
+ }
+
+ public override DataGridViewCellStyle DefaultCellStyle {
+ get { return base.DefaultCellStyle; }
+ set { base.DefaultCellStyle = value; }
+ }
+
+ public object FalseValue {
+ get {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ return (base.CellTemplate as DataGridViewCheckBoxCell).FalseValue;
+ }
+ set {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ (base.CellTemplate as DataGridViewCheckBoxCell).FalseValue = value;
+ }
+ }
+
+ public FlatStyle FlatStyle {
+ get {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ return (base.CellTemplate as DataGridViewCheckBoxCell).FlatStyle;
+ }
+ set {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ (base.CellTemplate as DataGridViewCheckBoxCell).FlatStyle = value;
+ }
+ }
+
+ public object IndeterminateValue {
+ get {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ return (base.CellTemplate as DataGridViewCheckBoxCell).IndeterminateValue;
+ }
+ set {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ (base.CellTemplate as DataGridViewCheckBoxCell).IndeterminateValue = value;
+ }
+ }
+
+ public bool ThreeState {
+ get {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ return (base.CellTemplate as DataGridViewCheckBoxCell).ThreeState;
+ }
+ set {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ (base.CellTemplate as DataGridViewCheckBoxCell).ThreeState = value;
+ }
+ }
+
+ public object TrueValue {
+ get {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ return (base.CellTemplate as DataGridViewCheckBoxCell).TrueValue;
+ }
+ set {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ (base.CellTemplate as DataGridViewCheckBoxCell).TrueValue = value;
+ }
+ }
+
+ public override string ToString () {
+ throw new NotImplementedException();
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewClipboardCopyMode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewClipboardCopyMode.cs
new file mode 100644
index 00000000000..9eef1304a7f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewClipboardCopyMode.cs
@@ -0,0 +1,40 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public enum DataGridViewClipboardCopyMode {
+ Disable = 0,
+ EnableWithAutoHeaderText = 1,
+ EnableWithoutHeaderText = 2,
+ EnableAlwaysIncludeHeaderText = 3
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumn.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumn.cs
new file mode 100644
index 00000000000..59f4669d6fe
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumn.cs
@@ -0,0 +1,387 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System;
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewColumn : DataGridViewBand, IComponent, IDisposable {
+
+ private DataGridViewAutoSizeColumnMode autoSizeMode;
+ private DataGridViewCell cellTemplate;
+ //private ContextMenuStrip contextMenuStrip;
+ private string dataPropertyName;
+ private int displayIndex;
+ private int dividerWidth;
+ private float fillWeight;
+ private bool frozen;
+ private DataGridViewColumnHeaderCell headerCell;
+ private string headerText = "";
+ private DataGridViewAutoSizeColumnMode inheritedAutoSizeMode;
+ private bool isDataBound;
+ private int minimumWidth = 5;
+ private string name = "";
+ private bool readOnly;
+ private DataGridViewTriState resizable = DataGridViewTriState.True;
+ private ISite site;
+ private DataGridViewColumnSortMode sortMode;
+ private string toolTipText;
+ private Type valueType;
+ private bool visible = true;
+ private int width = 100;
+
+ public DataGridViewColumn () {
+ cellTemplate = null;
+ base.DefaultCellStyle = new DataGridViewCellStyle();
+ readOnly = false;
+ headerCell = new DataGridViewColumnHeaderCell();
+ headerCell.SetColumnIndex(Index);
+ displayIndex = -1;
+ }
+
+ public DataGridViewColumn (DataGridViewCell cellTemplate) : this () {
+ this.cellTemplate = (DataGridViewCell) cellTemplate.Clone();
+ }
+
+ public DataGridViewAutoSizeColumnMode AutoSizeMode {
+ get { return autoSizeMode; }
+ set { autoSizeMode = value; }
+ }
+
+ public virtual DataGridViewCell CellTemplate {
+ get { return cellTemplate; }
+ set {
+ cellTemplate = value;
+ if (DataGridView != null) {
+ cellTemplate.SetDataGridView(DataGridView);
+ }
+ }
+ }
+
+ public Type CellType {
+ get {
+ if (cellTemplate == null) {
+ return null;
+ }
+ return cellTemplate.GetType();
+ }
+ }
+
+ /*
+ public override ContextMenuStrip ContextMenuStrip {
+ get { return contextMenuStrip; }
+ set {
+ if (contextMenuStrip != value) {
+ contextMenuStrip = value;
+ if (DataGridView != null) {
+ DataGridView.OnColumnContextMenuStripChanged(new DataGridViewColumnEventArgs(this));
+ }
+ }
+ }
+ }
+ */
+
+ public string DataPropertyName {
+ get { return dataPropertyName; }
+ set {
+ if (dataPropertyName != value) {
+ dataPropertyName = value;
+ if (DataGridView != null) {
+ DataGridView.OnColumnDataPropertyNameChanged(new DataGridViewColumnEventArgs(this));
+ }
+ }
+ }
+ }
+
+ public override DataGridViewCellStyle DefaultCellStyle {
+ get {
+ return base.DefaultCellStyle;
+ }
+ set {
+ if (DefaultCellStyle != value) {
+ base.DefaultCellStyle = value;
+ if (DataGridView != null) {
+ DataGridView.OnColumnDefaultCellStyleChanged(new DataGridViewColumnEventArgs(this));
+ }
+ }
+ }
+ }
+
+ public int DisplayIndex {
+ get {
+ if (displayIndex < 0) {
+ return Index;
+ }
+ return displayIndex;
+ }
+ set {
+ if (displayIndex != value) {
+ if (value < 0 || value > Int32.MaxValue) {
+ throw new ArgumentOutOfRangeException("DisplayIndex is out of range");
+ }
+ displayIndex = value;
+ if (DataGridView != null) {
+ DataGridView.OnColumnDisplayIndexChanged(new DataGridViewColumnEventArgs(this));
+ }
+ }
+ }
+ }
+
+ public int DividerWidth {
+ get { return dividerWidth; }
+ set {
+ if (dividerWidth != value) {
+ dividerWidth = value;
+ if (DataGridView != null) {
+ DataGridView.OnColumnDividerWidthChanged(new DataGridViewColumnEventArgs(this));
+ }
+ }
+ }
+ }
+
+ public float FillWeight {
+ get { return fillWeight; }
+ set {
+ fillWeight = value;
+ /* When the System.Windows.Forms.DataGridViewColumn.InheritedAutoSizeMode property value is System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill, the column is resized along with other columns in that mode so that all visible columns in the control exactly fill the horizontal width of the available display area. All fill-mode columns in the control divide the available space in proportions determined by their System.Windows.Forms.DataGridViewColumn.FillWeight property values. For more information about column fill mode, see Column Fill Mode in the Windows Forms DataGridView Control.
+
+The maximum sum of System.Windows.Forms.DataGridViewColumn.FillWeight values for all columns in a System.Windows.Forms.DataGridView control is 65535.
+ */
+ }
+ }
+
+ public override bool Frozen {
+ get { return frozen; }
+ set { frozen = value; }
+ }
+ /* When a column is frozen, all the columns to its left (or to its right in right-to-left languages) are frozen as well. The frozen and unfrozen columns form two groups. If column repositioning is enabled by setting the System.Windows.Forms.DataGridView.AllowUserToOrderColumns property to true, the user cannot drag a column from one group to the other.
+Example */
+
+ public DataGridViewColumnHeaderCell HeaderCell {
+ get { return headerCell; }
+ set {
+ if (headerCell != value) {
+ headerCell = value;
+ if (DataGridView != null) {
+ DataGridView.OnColumnHeaderCellChanged(new DataGridViewColumnEventArgs(this));
+ }
+ }
+ }
+ }
+
+ public string HeaderText {
+ get { return headerText; }
+ set { headerText = value; }
+ }
+
+ public DataGridViewAutoSizeColumnMode InheritedAutoSizeMode {
+ get { return inheritedAutoSizeMode; }
+ }
+
+ public override DataGridViewCellStyle InheritedStyle {
+ get {
+ if (DataGridView == null) {
+ return base.DefaultCellStyle;
+ }
+ else {
+ if (base.DefaultCellStyle == null) {
+ return DataGridView.DefaultCellStyle;
+ }
+ else {
+ DataGridViewCellStyle style = (DataGridViewCellStyle) base.DefaultCellStyle.Clone();
+ /////// Combination with dataGridView.DefaultCellStyle
+ return style;
+ }
+ }
+ }
+ }
+
+ public bool IsDataBound {
+ get { return isDataBound; }
+ }
+
+ public int MinimumWidth {
+ get { return minimumWidth; }
+ set {
+ if (minimumWidth != value) {
+ if (value < 2 || value > Int32.MaxValue) {
+ throw new ArgumentOutOfRangeException("MinimumWidth is out of range");
+ }
+ minimumWidth = value;
+ if (DataGridView != null) {
+ DataGridView.OnColumnMinimumWidthChanged(new DataGridViewColumnEventArgs(this));
+ }
+ }
+ }
+ }
+
+ public string Name {
+ get { return name; }
+ set {
+ if (name != value) {
+ name = value;
+ headerCell.Value = value;
+ if (DataGridView != null) {
+ DataGridView.OnColumnNameChanged(new DataGridViewColumnEventArgs(this));
+ }
+ }
+ }
+ }
+
+ public override bool ReadOnly {
+ get { return readOnly; }
+ set { readOnly = value; }
+ }
+
+ public override DataGridViewTriState Resizable {
+ get { return resizable; }
+ set { resizable = value; }
+ }
+
+ public virtual ISite Site {
+ get { return site; }
+ set { site = value; }
+ }
+
+ public DataGridViewColumnSortMode SortMode {
+ get { return sortMode; }
+ set {
+ // System.InvalidOperationException: The value assigned to the property conflicts with System.Windows.Forms.DataGridView.SelectionMode.
+ if (sortMode != value) {
+ sortMode = value;
+ if (DataGridView != null) {
+ DataGridView.OnColumnSortModeChanged(new DataGridViewColumnEventArgs(this));
+ }
+ }
+ }
+ }
+
+ public string ToolTipText {
+ get { return toolTipText; }
+ set {
+ if (toolTipText != value) {
+ toolTipText = value;
+ if (DataGridView != null) {
+ DataGridView.OnColumnToolTipTextChanged(new DataGridViewColumnEventArgs(this));
+ }
+ }
+ }
+ }
+
+ public Type ValueType {
+ get { return valueType; }
+ set { valueType = value; }
+ }
+
+ public override bool Visible {
+ get { return visible; }
+ set { visible = value; }
+ }
+
+ public int Width {
+ get { return width; }
+ set {
+ if (width != value) {
+ if (value < minimumWidth) {
+ throw new ArgumentOutOfRangeException("Width is less than MinimumWidth");
+ }
+ width = value;
+ if (DataGridView != null) {
+ DataGridView.OnColumnWidthChanged(new DataGridViewColumnEventArgs(this));
+ }
+
+ }
+ }
+ }
+
+ //public sealed event EventHandler Disposed;
+ public event EventHandler Disposed;
+
+ public override object Clone () {
+ return this.MemberwiseClone();
+ /*
+ DataGridViewColumn result = new DataGridViewColumn();
+ return result;
+ */
+ }
+
+ //public sealed void Dispose () {
+ //}
+
+ public virtual int GetPreferredWidth (DataGridViewAutoSizeColumnMode autoSizeColumnMode, bool fixedHeight) {
+ switch (autoSizeColumnMode) {
+ case DataGridViewAutoSizeColumnMode.NotSet:
+ case DataGridViewAutoSizeColumnMode.None:
+ case DataGridViewAutoSizeColumnMode.Fill:
+ throw new ArgumentException("AutoSizeColumnMode is invalid");
+ }
+ if (fixedHeight) {
+ return 0;
+ }
+ else {
+ return 0;
+ }
+ }
+
+ public override string ToString () {
+ return Name + ", Index: " + base.Index.ToString() + ".";
+ }
+
+ protected override void Dispose (bool disposing) {
+ if (disposing) {
+ }
+ }
+
+ internal override void SetDataGridView (DataGridView dataGridView) {
+ base.SetDataGridView(dataGridView);
+ if (cellTemplate != null) {
+ cellTemplate.SetDataGridView(dataGridView);
+ }
+ headerCell.SetDataGridView(dataGridView);
+ }
+
+ internal override void SetIndex (int index) {
+ base.SetIndex(index);
+ headerCell.SetColumnIndex(Index);
+ }
+
+ internal override void SetState (DataGridViewElementStates state) {
+ if (State != state) {
+ base.SetState(state);
+ if (DataGridView != null) {
+ DataGridView.OnColumnStateChanged(new DataGridViewColumnStateChangedEventArgs(this, state));
+ }
+ }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnCollection.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnCollection.cs
new file mode 100644
index 00000000000..1904d2d5b0f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnCollection.cs
@@ -0,0 +1,237 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.ComponentModel;
+using System.Collections;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewColumnCollection : BaseCollection, IList, ICollection, IEnumerable {
+
+ private DataGridView dataGridView;
+
+ public DataGridViewColumnCollection (DataGridView dataGridView) {
+ this.dataGridView = dataGridView;
+ }
+
+ public bool IsFixedSize {
+ get { return base.List.IsFixedSize; }
+ }
+
+ object IList.this [int index] {
+ get { return this[index]; }
+ set { throw new NotSupportedException(); }
+ }
+
+ public DataGridViewColumn this [int index] {
+ get { return (DataGridViewColumn) base.List[index]; }
+ }
+
+ public DataGridViewColumn this [string columnName] {
+ get {
+ foreach (DataGridViewColumn col in base.List) {
+ if (col.Name == columnName) {
+ return col;
+ }
+ }
+ return null;
+ }
+ }
+
+ public event CollectionChangeEventHandler CollectionChanged;
+
+ int IList.Add (object o) {
+ return Add(o as DataGridViewColumn);
+ }
+
+ public virtual int Add (DataGridViewColumn dataGridViewColumn) {
+ dataGridViewColumn.SetIndex(base.List.Count);
+ dataGridViewColumn.SetDataGridView(dataGridView);
+ int result = base.List.Add(dataGridViewColumn);
+ OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, dataGridViewColumn));
+ return result;
+ }
+
+ public virtual int Add (string columnName, string headerText) {
+ DataGridViewColumn col = new DataGridViewColumn();
+ col.Name = columnName;
+ col.HeaderText = headerText;
+ return Add(col);
+ }
+
+ public virtual void AddRange (params DataGridViewColumn[] dataGridViewColumns) {
+ foreach (DataGridViewColumn col in dataGridViewColumns) {
+ Add(col);
+ }
+ }
+
+ public virtual void Clear () {
+ base.List.Clear();
+ }
+
+ bool IList.Contains (object o) {
+ return Contains(o as DataGridViewColumn);
+ }
+
+ public virtual bool Contains (DataGridViewColumn dataGridViewColumn) {
+ return base.List.Contains(dataGridViewColumn);
+ }
+
+ public virtual bool Contains (string columnName) {
+ foreach (DataGridViewColumn col in base.List) {
+ if (col.Name == columnName) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void CopyTo (DataGridViewColumn[] array, int index) {
+ base.List.CopyTo(array, index);
+ }
+
+ public int GetColumnCount (DataGridViewElementStates includeFilter) {
+ return 0;
+ }
+
+ public int GetColumnsWidth (DataGridViewElementStates includeFilter) {
+ return 0;
+ }
+
+ public DataGridViewColumn GetFirstColumn (DataGridViewElementStates includeFilter) {
+ return null;
+ }
+
+ public DataGridViewColumn GetFirstColumn (DataGridViewElementStates includeFilter, DataGridViewElementStates excludeFilter) {
+ return null;
+ }
+
+ public DataGridViewColumn GetLastColumn (DataGridViewElementStates includeFilter, DataGridViewElementStates excludeFilter) {
+ return null;
+ }
+
+ public DataGridViewColumn GetNextColumn (DataGridViewColumn dataGridViewColumnStart, DataGridViewElementStates includeFilter, DataGridViewElementStates excludeFilter) {
+ return null;
+ }
+
+ public DataGridViewColumn GetPreviousColumn (DataGridViewColumn dataGridViewColumnStart, DataGridViewElementStates includeFilter, DataGridViewElementStates excludeFilter) {
+ return null;
+ }
+
+ int IList.IndexOf (object o) {
+ return IndexOf(o as DataGridViewColumn);
+ }
+
+ public int IndexOf (DataGridViewColumn dataGridViewColumn) {
+ return base.List.IndexOf(dataGridViewColumn);
+ }
+
+ void IList.Insert (int columnIndex, object o) {
+ Insert(columnIndex, o as DataGridViewColumn);
+ }
+
+ public virtual void Insert (int columnIndex, DataGridViewColumn dataGridViewColumn) {
+ dataGridViewColumn.SetIndex(columnIndex);
+ base.List.Insert(columnIndex, dataGridViewColumn);
+ OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, dataGridViewColumn));
+ }
+
+ void IList.Remove (object o) {
+ Remove(o as DataGridViewColumn);
+ }
+
+ public virtual void Remove (DataGridViewColumn dataGridViewColumn) {
+ base.List.Remove(dataGridViewColumn);
+ OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Remove, dataGridViewColumn));
+ }
+
+ public virtual void Remove (string columnName) {
+ foreach (DataGridViewColumn col in base.List) {
+ if (col.Name == columnName) {
+ Remove(col);
+ return;
+ }
+ }
+ }
+
+ public virtual void RemoveAt (int index) {
+ DataGridViewColumn col = this[index];
+ base.List.RemoveAt(index);
+ OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, col));
+ }
+
+ protected DataGridView DataGridView {
+ get { return dataGridView; }
+ }
+
+ protected virtual void OnCollectionChanged (CollectionChangeEventArgs e) {
+ if (CollectionChanged != null) {
+ CollectionChanged(this, e);
+ }
+ }
+
+ protected override ArrayList List {
+ get { return base.List; }
+ }
+
+ /************************/
+
+ internal ArrayList ColumnDisplayIndexSortedArrayList {
+ get {
+ ArrayList result = (ArrayList) base.List.Clone();
+ result.Sort(new ColumnDisplayIndexComparator());
+ return result;
+ }
+ }
+
+ private class ColumnDisplayIndexComparator : IComparer {
+
+ public int Compare (object o1, object o2) {
+ DataGridViewColumn col1 = (DataGridViewColumn) o1;
+ DataGridViewColumn col2 = (DataGridViewColumn) o2;
+ if (col1.DisplayIndex < col2.DisplayIndex) {
+ return -1;
+ }
+ else if (col1.DisplayIndex > col2.DisplayIndex) {
+ return 1;
+ }
+ else {
+ return 0;
+ }
+ }
+
+ }
+
+ /************************/
+
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnDesignTimeVisibleAttribute.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnDesignTimeVisibleAttribute.cs
new file mode 100644
index 00000000000..e50881d0935
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnDesignTimeVisibleAttribute.cs
@@ -0,0 +1,75 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public sealed class DataGridViewColumnDesignTimeVisibleAttribute : Attribute {
+
+ public static readonly DataGridViewColumnDesignTimeVisibleAttribute Default = new DataGridViewColumnDesignTimeVisibleAttribute(true);
+
+ public static readonly DataGridViewColumnDesignTimeVisibleAttribute No = new DataGridViewColumnDesignTimeVisibleAttribute(false);
+
+ public static readonly DataGridViewColumnDesignTimeVisibleAttribute Yes = new DataGridViewColumnDesignTimeVisibleAttribute(true);
+
+ private bool visible;
+
+ public DataGridViewColumnDesignTimeVisibleAttribute () {
+ }
+
+ public DataGridViewColumnDesignTimeVisibleAttribute (bool visible) {
+ this.visible = visible;
+ }
+
+ public bool Visible {
+ get { return visible; }
+ set { visible = value; }
+ }
+
+ public override bool Equals (object o) {
+ if (!(o is DataGridViewColumnDesignTimeVisibleAttribute)) {
+ return false;
+ }
+ if ((o as DataGridViewColumnDesignTimeVisibleAttribute).visible != this.visible) {
+ return false;
+ }
+ return base.Equals(o);
+ }
+
+ public override int GetHashCode () {
+ throw new NotImplementedException();
+ }
+
+ public override bool IsDefaultAttribute () {
+ return this.Equals(Default);
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnDividerDoubleClickEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnDividerDoubleClickEventArgs.cs
new file mode 100644
index 00000000000..811621bd7f6
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnDividerDoubleClickEventArgs.cs
@@ -0,0 +1,47 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewColumnDividerDoubleClickEventArgs : HandledMouseEventArgs {
+
+ private int columnIndex;
+
+ public DataGridViewColumnDividerDoubleClickEventArgs (int columnIndex, HandledMouseEventArgs e) : base (e.Button, e.Clicks, e.X, e.Y, e.Delta) {
+ this.columnIndex = columnIndex;
+ }
+
+ public int ColumnIndex {
+ get { return columnIndex; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnDividerDoubleClickEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnDividerDoubleClickEventHandler.cs
new file mode 100644
index 00000000000..1bb1292c922
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnDividerDoubleClickEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewColumnDividerDoubleClickEventHandler (object sender, DataGridViewColumnDividerDoubleClickEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnEventArgs.cs
new file mode 100644
index 00000000000..d452db3bd20
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnEventArgs.cs
@@ -0,0 +1,47 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewColumnEventArgs : EventArgs {
+
+ private DataGridViewColumn dataGridViewColumn;
+
+ public DataGridViewColumnEventArgs (DataGridViewColumn dataGridViewColumn) {
+ this.dataGridViewColumn = dataGridViewColumn;
+ }
+
+ public DataGridViewColumn Column {
+ get { return dataGridViewColumn; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnEventHandler.cs
new file mode 100644
index 00000000000..31a00e315c4
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewColumnEventHandler (object sender, DataGridViewColumnEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnHeaderCell.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnHeaderCell.cs
new file mode 100644
index 00000000000..48286259c21
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnHeaderCell.cs
@@ -0,0 +1,144 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewColumnHeaderCell : DataGridViewHeaderCell {
+
+ private SortOrder sortGlyphDirection = SortOrder.None;
+
+ public DataGridViewColumnHeaderCell () {
+ }
+
+ public SortOrder SortGlyphDirection {
+ get { return sortGlyphDirection; }
+ set { sortGlyphDirection = value; }
+ }
+
+ public override object Clone () {
+ return MemberwiseClone();
+ }
+
+ /*
+ public override ContextMenuStrip GetInheritedContextMenuStrip (int rowIndex) {
+ if (rowIndex != -1) {
+ throw new ArgumentOutOfRangeException("RowIndex is not -1");
+ }
+ if (base.ContextMenuStrip != null) {
+ return base.ContextMenuStrip;
+ }
+ return base.GetInheritedContextMenuStrip(rowIndex); //////////////////////////////
+ }
+ */
+
+ public override DataGridViewCellStyle GetInheritedStyle (DataGridViewCellStyle inheritedCellStyle, int rowIndex, bool includeColors) {
+ throw new NotImplementedException();
+ }
+
+ public override string ToString () {
+ return GetType().Name;
+ }
+
+ protected override AccessibleObject CreateAccessibilityInstance () {
+ return new DataGridViewColumnHeaderCellAccessibleObject(this);
+ }
+
+ protected override object GetClipboardContent (int rowIndex, bool firstCell, bool lastCell, bool inFirstRow, bool inLastRow, string format) {
+ throw new NotImplementedException();
+ //////////////////////////////////////////
+ }
+
+ protected override Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
+ return new Rectangle();
+ }
+
+ protected override Size GetPreferredSize (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) {
+ throw new NotImplementedException();
+ }
+
+ protected override object GetValue (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override void Paint (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates dataGridViewElementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
+ graphics.FillRectangle(new SolidBrush(cellStyle.BackColor), cellBounds);
+ graphics.DrawString((string) formattedValue, cellStyle.Font, new SolidBrush(cellStyle.ForeColor), cellBounds, StringFormat.GenericDefault);
+ PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
+ }
+
+ protected override bool SetValue (int rowIndex, object value) {
+ throw new NotImplementedException();
+ }
+
+ protected class DataGridViewColumnHeaderCellAccessibleObject : DataGridViewCellAccessibleObject {
+
+ public DataGridViewColumnHeaderCellAccessibleObject (DataGridViewColumnHeaderCell owner) : base (owner) {
+ }
+
+ public override Rectangle Bounds {
+ get { return base.Bounds; }
+ }
+
+ public override string DefaultAction {
+ get { return base.DefaultAction; }
+ }
+
+ public override string Name {
+ get { return base.Name; }
+ }
+
+ public override AccessibleObject Parent {
+ get { return base.Parent; }
+ }
+
+ public override AccessibleRole Role {
+ get { return base.Role; }
+ }
+
+ public override string Value {
+ get { return base.Value; }
+ }
+
+ public override void DoDefaultAction () {
+ base.DoDefaultAction();
+ }
+
+ public override AccessibleObject Navigate (AccessibleNavigation navigationDirection) {
+ return base.Navigate(navigationDirection);
+ }
+
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnHeadersHeightSizeMode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnHeadersHeightSizeMode.cs
new file mode 100644
index 00000000000..ef5a845ed30
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnHeadersHeightSizeMode.cs
@@ -0,0 +1,39 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public enum DataGridViewColumnHeadersHeightSizeMode {
+ EnableResizing = 0,
+ DisableResizing = 1,
+ AutoSize = 2
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnSortMode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnSortMode.cs
new file mode 100644
index 00000000000..ccf6f73294e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnSortMode.cs
@@ -0,0 +1,39 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public enum DataGridViewColumnSortMode {
+ NotSortable = 0,
+ Automatic = 1,
+ Programmatic = 2
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnStateChangedEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnStateChangedEventArgs.cs
new file mode 100644
index 00000000000..215741f96a1
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnStateChangedEventArgs.cs
@@ -0,0 +1,53 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewColumnStateChangedEventArgs : EventArgs {
+
+ private DataGridViewColumn dataGridViewColumn;
+ private DataGridViewElementStates stateChanged;
+
+ public DataGridViewColumnStateChangedEventArgs (DataGridViewColumn dataGridViewColumn, DataGridViewElementStates stateChanged) {
+ this.dataGridViewColumn = dataGridViewColumn;
+ this.stateChanged = stateChanged;
+ }
+
+ public DataGridViewColumn Column {
+ get { return dataGridViewColumn; }
+ }
+
+ public DataGridViewElementStates StateChanged {
+ get { return stateChanged; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnStateChangedEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnStateChangedEventHandler.cs
new file mode 100644
index 00000000000..ca041f87ce8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnStateChangedEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewColumnStateChangedEventHandler (object sender, DataGridViewColumnStateChangedEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewComboBoxCell.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewComboBoxCell.cs
new file mode 100644
index 00000000000..a68a21dbdcd
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewComboBoxCell.cs
@@ -0,0 +1,330 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewComboBoxCell : DataGridViewCell {
+
+ private bool autoComplete;
+ private object dataSource;
+ private string displayMember;
+ private DataGridViewComboBoxDisplayStyle displayStyle;
+ private bool displayStyleForCurrentCellOnly;
+ private int dropDownWidth;
+ private FlatStyle flatStyle;
+ private ObjectCollection items;
+ private int maxDropDownItems;
+ private bool sorted;
+ private string valueMember;
+
+ public DataGridViewComboBoxCell () : base() {
+ autoComplete = true;
+ dataSource = null;
+ displayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton;
+ displayStyleForCurrentCellOnly = false;
+ dropDownWidth = 1;
+ flatStyle = FlatStyle.Standard;
+ items = new ObjectCollection(this);
+ maxDropDownItems = 8;
+ sorted = false;
+ }
+
+ public virtual bool AutoComplete {
+ get { return autoComplete; }
+ set { autoComplete = value; }
+ }
+
+ public virtual object DataSource {
+ get { return dataSource; }
+ set {
+ if (value is IList || value is IListSource || value == null) {
+ dataSource = value;
+ return;
+ }
+ throw new Exception("Value is no IList, IListSource or null.");
+ }
+ }
+
+ public virtual string DisplayMember {
+ get { return displayMember; }
+ set { displayMember = value; }
+ }
+
+ public DataGridViewComboBoxDisplayStyle DisplayStyle {
+ get { return displayStyle; }
+ set { displayStyle = value; }
+ }
+
+ public bool DisplayStyleForCurrentCellOnly {
+ get { return displayStyleForCurrentCellOnly; }
+ set { displayStyleForCurrentCellOnly = value; }
+ }
+
+ public virtual int DropDownWidth {
+ get { return dropDownWidth; }
+ set {
+ if (value < 1) {
+ throw new ArgumentOutOfRangeException("Value is less than 1.");
+ }
+ dropDownWidth = value;
+ }
+ }
+
+ public override Type EditType {
+ get { return typeof(DataGridViewComboBoxEditingControl); }
+ }
+
+ public FlatStyle FlatStyle {
+ get { return flatStyle; }
+ set {
+ if (!Enum.IsDefined(typeof(FlatStyle), value)) {
+ throw new InvalidEnumArgumentException("Value is not valid FlatStyle.");
+ }
+ flatStyle = value;
+ }
+ }
+
+ public override Type FormattedValueType {
+ get { return typeof(string); }
+ }
+
+ public virtual ObjectCollection Items {
+ get { return items; }
+ }
+
+ public virtual int MaxDropDownItems {
+ get { return maxDropDownItems; }
+ set {
+ if (value < 1 || value > 100) {
+ throw new ArgumentOutOfRangeException("Value is less than 1 or greater than 100.");
+ }
+ maxDropDownItems = value;
+ }
+ }
+
+ public virtual bool Sorted {
+ get { return sorted; }
+ set {
+ /*
+ if () {
+ throw new ArgumentException("Cannot sort a cell attached to a data source.");
+ }
+ */
+ sorted = value;
+ }
+ }
+
+ public virtual string ValueMember {
+ get { return valueMember; }
+ set { valueMember = value; }
+ }
+
+ public override Type ValueType {
+ get { return typeof(string); }
+ }
+
+ public override object Clone () {
+ DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell) base.Clone();
+ cell.autoComplete = this.autoComplete;
+ cell.dataSource = this.dataSource;
+ cell.displayStyle = this.displayStyle;
+ cell.displayStyleForCurrentCellOnly = this.displayStyleForCurrentCellOnly;
+ cell.dropDownWidth = this.dropDownWidth;
+ cell.flatStyle = this.flatStyle;
+ cell.items.AddRange(this.items);
+ cell.maxDropDownItems = this.maxDropDownItems;
+ cell.sorted = this.sorted;
+ return cell;
+ }
+
+ public override void DetachEditingControl () {
+ throw new NotImplementedException();
+ }
+
+ public override void InitializeEditingControl (int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle) {
+ throw new NotImplementedException();
+ }
+
+ public override bool KeyEntersEditMode (KeyEventArgs e) {
+ throw new NotImplementedException();
+ }
+
+ public override object ParseFormattedValue (object formattedValue, DataGridViewCellStyle cellStyle, TypeConverter formattedValueTypeConverter, TypeConverter valueTypeConverter) {
+ throw new NotImplementedException();
+ }
+
+ public override string ToString () {
+ throw new NotImplementedException();
+ }
+
+ protected override Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override Rectangle GetErrorIconBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override object GetFormattedValue (object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context) {
+ throw new NotImplementedException();
+ }
+
+ protected override Size GetPreferredSize (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnDataGridViewChanged () {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnEnter (int rowIndex, bool throughMouseClick) {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnLeave (int rowIndex, bool throughMouseClick) {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnMouseClick (DataGridViewCellMouseEventArgs e) {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnMouseEnter (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnMouseLeave (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnMouseMove (DataGridViewCellMouseEventArgs e) {
+ throw new NotImplementedException();
+ }
+
+ protected override void Paint (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementeState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
+ throw new NotImplementedException();
+ }
+
+ public class ObjectCollection : IList, ICollection, IEnumerable {
+
+ private ArrayList list;
+
+ private DataGridViewComboBoxCell owner;
+
+ public ObjectCollection (DataGridViewComboBoxCell owner) {
+ this.owner = owner;
+ list = new ArrayList();
+ }
+
+ public virtual int Count {
+ get { return list.Count; }
+ }
+
+ public virtual bool IsFixedSize {
+ get { return list.IsFixedSize; }
+ }
+
+ public virtual bool IsReadOnly {
+ get { return list.IsReadOnly; }
+ }
+
+ public virtual bool IsSynchronized {
+ get { return list.IsSynchronized; }
+ }
+
+ public virtual object SyncRoot {
+ get { return list.SyncRoot; }
+ }
+
+ public virtual object this [int index] {
+ get { return list[index]; }
+ set { list[index] = value; }
+ }
+
+ public int Add (object item) {
+ return list.Add(item);
+ }
+
+ public void AddRange (ObjectCollection value) {
+ list.AddRange(value.list);
+ }
+
+ public void AddRange (object[] items) {
+ list.AddRange(items);
+ }
+
+ //public sealed void Clear () {
+ public void Clear () {
+ list.Clear();
+ }
+
+ //public sealed bool Contains (object value) {
+ public bool Contains (object value) {
+ return list.Contains(value);
+ }
+
+ public void CopyTo (Array destination, int arrayIndex) {
+ list.CopyTo(destination, arrayIndex);
+ }
+
+ //public sealed IEnumerator GetEnumerator () {
+ public IEnumerator GetEnumerator () {
+ return list.GetEnumerator();
+ }
+
+ //public sealed int IndexOf (object value) {
+ public int IndexOf (object value) {
+ return list.IndexOf(value);
+ }
+
+ //public sealed void Insert (int index, object item) {
+ public void Insert (int index, object item) {
+ list.Insert(index, item);
+ }
+
+ //public sealed void Remove (object value) {
+ public void Remove (object value) {
+ list.Remove(value);
+ }
+
+ //public sealed void RemoveAt (int index) {
+ public void RemoveAt (int index) {
+ list.RemoveAt(index);
+ }
+
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewComboBoxColumn.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewComboBoxColumn.cs
new file mode 100644
index 00000000000..ab1b4e8fd68
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewComboBoxColumn.cs
@@ -0,0 +1,190 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewComboBoxColumn : DataGridViewColumn {
+
+ private bool autoComplete;
+ private DataGridViewComboBoxDisplayStyle displayStyle;
+ private bool displayStyleForCurrentCellsOnly;
+ private FlatStyle flatStyle;
+
+ public DataGridViewComboBoxColumn () {
+ CellTemplate = new DataGridViewComboBoxCell();
+ SortMode = DataGridViewColumnSortMode.NotSortable;
+ autoComplete = true;
+ displayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton;
+ displayStyleForCurrentCellsOnly = false;
+ }
+
+ public bool AutoComplete {
+ get { return autoComplete; }
+ set { autoComplete = value; }
+ }
+
+ public override DataGridViewCell CellTemplate {
+ get { return base.CellTemplate; }
+ set { base.CellTemplate = value as DataGridViewComboBoxCell; }
+ }
+
+ public object DataSource {
+ get {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ return (base.CellTemplate as DataGridViewComboBoxCell).DataSource; }
+ set {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ (base.CellTemplate as DataGridViewComboBoxCell).DataSource = value;
+ }
+ }
+
+ public string DisplayMember {
+ get {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ return (base.CellTemplate as DataGridViewComboBoxCell).DisplayMember;
+ }
+ set {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ (base.CellTemplate as DataGridViewComboBoxCell).DisplayMember = value;
+ }
+ }
+
+ public DataGridViewComboBoxDisplayStyle DisplayStyle {
+ get { return displayStyle; }
+ set { displayStyle = value; }
+ }
+
+ public bool DisplayStyleForCurrentCellsOnly {
+ get { return displayStyleForCurrentCellsOnly; }
+ set { displayStyleForCurrentCellsOnly = value; }
+ }
+
+ public int DropDownWidth {
+ get {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ return (base.CellTemplate as DataGridViewComboBoxCell).DropDownWidth;
+ }
+ set {
+ if (value < 1) {
+ throw new ArgumentException("Value is less than 1.");
+ }
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ (base.CellTemplate as DataGridViewComboBoxCell).DropDownWidth = value;
+ }
+ }
+
+ public FlatStyle FlatStyle {
+ get { return flatStyle; }
+ set { flatStyle = value; }
+ }
+
+ public DataGridViewComboBoxCell.ObjectCollection Items {
+ get {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ return (base.CellTemplate as DataGridViewComboBoxCell).Items;
+ }
+ }
+
+ public int MaxDropDownItems {
+ get {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ return (base.CellTemplate as DataGridViewComboBoxCell).MaxDropDownItems;
+ }
+ set {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ (base.CellTemplate as DataGridViewComboBoxCell).MaxDropDownItems = value;
+ }
+ }
+
+ public bool Sorted {
+ get {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ return (base.CellTemplate as DataGridViewComboBoxCell).Sorted;
+ }
+ set {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ (base.CellTemplate as DataGridViewComboBoxCell).Sorted = value;
+ }
+ }
+
+ public string ValueMember {
+ get {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ return (base.CellTemplate as DataGridViewComboBoxCell).ValueMember;
+ }
+ set {
+ if (base.CellTemplate == null) {
+ throw new InvalidOperationException("CellTemplate is null.");
+ }
+ (base.CellTemplate as DataGridViewComboBoxCell).ValueMember = value;
+ }
+ }
+
+ public override object Clone () {
+ DataGridViewComboBoxColumn col = (DataGridViewComboBoxColumn) base.Clone();
+ col.autoComplete = this.autoComplete;
+ col.displayStyle = this.displayStyle;
+ col.displayStyleForCurrentCellsOnly = this.displayStyleForCurrentCellsOnly;
+ col.flatStyle = this.flatStyle;
+ col.CellTemplate = (DataGridViewComboBoxCell) this.CellTemplate.Clone();
+ return col;
+ }
+
+ public override string ToString () {
+ return GetType().Name;
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewComboBoxDisplayStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewComboBoxDisplayStyle.cs
new file mode 100644
index 00000000000..6f19fb10706
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewComboBoxDisplayStyle.cs
@@ -0,0 +1,39 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public enum DataGridViewComboBoxDisplayStyle {
+ ComboBox = 0,
+ DropDownButton = 1,
+ Nothing = 2
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewComboBoxEditingControl.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewComboBoxEditingControl.cs
new file mode 100644
index 00000000000..ee9cf5cda8e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewComboBoxEditingControl.cs
@@ -0,0 +1,102 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+
+ [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
+ [ComVisibleAttribute(true)]
+ public class DataGridViewComboBoxEditingControl : ComboBox, IDataGridViewEditingControl {
+
+ //private bool tabStop;
+ private DataGridView editingControlDataGridView;
+ private object editingControlFormattedValue;
+ private int editingControlRowIndex;
+ private bool editingControlValueChanged;
+ private Cursor editingPanelCursor;
+
+ public DataGridViewComboBoxEditingControl () {
+ //tabStop = false;
+ editingControlValueChanged = false;
+ }
+
+ public virtual DataGridView EditingControlDataGridView {
+ get { return editingControlDataGridView; }
+ set { editingControlDataGridView = value; }
+ }
+
+ public virtual object EditingControlFormattedValue {
+ get { return editingControlFormattedValue; }
+ set { editingControlFormattedValue = value; }
+ }
+
+ public virtual int EditingControlRowIndex {
+ get { return editingControlRowIndex; }
+ set { editingControlRowIndex = value; }
+ }
+
+ public virtual bool EditingControlValueChanged {
+ get { return editingControlValueChanged; }
+ set { editingControlValueChanged = value; }
+ }
+
+ public virtual Cursor EditingPanelCursor {
+ get { return editingPanelCursor; }
+ }
+
+ public virtual bool RepositionEditingControlOnValueChange {
+ get { return false; }
+ }
+
+ public virtual void ApplyCellStyleToEditingControl (DataGridViewCellStyle dataGridViewCellStyle) {
+ throw new NotImplementedException();
+ }
+
+ public virtual bool EditingControlWantsInputKey (Keys keyData, bool dataGridViewWantsInputKey) {
+ // true if the specified key is a regular key that should be handled by the editing control; otherwise, false
+ throw new NotImplementedException();
+ }
+
+ public virtual object GetEditingControlFormattedValue (DataGridViewDataErrorContexts context) {
+ throw new NotImplementedException();
+ }
+
+ public virtual void PrepareEditingControlForEdit (bool selectAll) {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnSelectedIndexChanged (EventArgs e) {
+ throw new NotImplementedException();
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewContentAlignment.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewContentAlignment.cs
new file mode 100644
index 00000000000..cb077223a7b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewContentAlignment.cs
@@ -0,0 +1,45 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public enum DataGridViewContentAlignment {
+ NotSet = 0,
+ TopLeft = 1,
+ TopCenter = 2,
+ TopRight = 4,
+ MiddleLeft = 16,
+ MiddleCenter = 32,
+ MiddleRight = 64,
+ BottomLeft = 256,
+ BottomCenter = 512,
+ BottomRight = 1024
+ }
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewDataErrorContexts.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewDataErrorContexts.cs
new file mode 100644
index 00000000000..df316f0d19f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewDataErrorContexts.cs
@@ -0,0 +1,48 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ [FlagsAttribute()]
+ public enum DataGridViewDataErrorContexts {
+ Formatting = 1,
+ Display = 2,
+ PreferredSize = 4,
+ RowDeletion = 8,
+ Parsing = 256,
+ Commit = 512,
+ InitialValueRestoration = 1024,
+ LeaveControl = 2048,
+ CurrentCellChange = 4096,
+ Scroll = 8192,
+ ClipboardContent = 16384
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewDataErrorEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewDataErrorEventArgs.cs
new file mode 100644
index 00000000000..b1c47b60d47
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewDataErrorEventArgs.cs
@@ -0,0 +1,62 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewDataErrorEventArgs : DataGridViewCellCancelEventArgs {
+
+ Exception exception;
+ DataGridViewDataErrorContexts context;
+ bool throwException;
+
+ public DataGridViewDataErrorEventArgs (Exception exception, int columnIndex, int rowIndex, DataGridViewDataErrorContexts context) : base(columnIndex, rowIndex) {
+ this.exception = exception;
+ this.context = context;
+ this.throwException = false;
+ }
+
+ public DataGridViewDataErrorContexts Context {
+ get { return context; }
+ }
+
+ public Exception Exception {
+ get { return exception; }
+ }
+
+ public bool ThrowException {
+ get { return throwException; }
+ set { throwException = value; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewDataErrorEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewDataErrorEventHandler.cs
new file mode 100644
index 00000000000..edf2e482b51
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewDataErrorEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewDataErrorEventHandler (object sender, DataGridViewDataErrorEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewEditMode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewEditMode.cs
new file mode 100644
index 00000000000..0fb63ea4b35
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewEditMode.cs
@@ -0,0 +1,41 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public enum DataGridViewEditMode {
+ EditOnEnter = 0,
+ EditOnKeystroke = 1,
+ EditOnKeystrokeOrF2 = 2,
+ EditOnF2 = 3,
+ EditProgrammatically = 4
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewEditingControlShowingEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewEditingControlShowingEventArgs.cs
new file mode 100644
index 00000000000..bc0563c9646
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewEditingControlShowingEventArgs.cs
@@ -0,0 +1,54 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewEditingControlShowingEventArgs : EventArgs {
+
+ private Control control;
+ private DataGridViewCellStyle cellStyle;
+
+ public DataGridViewEditingControlShowingEventArgs (Control control, DataGridViewCellStyle cellStyle) {
+ this.control = control;
+ this.cellStyle = cellStyle;
+ }
+
+ public DataGridViewCellStyle CellStyle {
+ get { return cellStyle; }
+ set { cellStyle = value; }
+ }
+
+ public Control Control {
+ get { return control; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewEditingControlShowingEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewEditingControlShowingEventHandler.cs
new file mode 100644
index 00000000000..78864d6d21a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewEditingControlShowingEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewEditingControlShowingEventHandler (object sender, DataGridViewEditingControlShowingEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewElement.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewElement.cs
new file mode 100644
index 00000000000..d539fedd4b2
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewElement.cs
@@ -0,0 +1,110 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.Drawing;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewElement {
+
+ private DataGridView dataGridView;
+ private DataGridViewElementStates state;
+
+ public DataGridViewElement () {
+ dataGridView = null;
+ state = DataGridViewElementStates.None;
+ }
+
+ public DataGridView DataGridView {
+ get { return dataGridView; }
+ }
+
+ public virtual DataGridViewElementStates State {
+ get { return state; }
+ }
+
+ protected virtual void OnDataGridViewChanged () {
+ throw new NotImplementedException();
+ }
+
+ protected void RaiseCellClick (DataGridViewCellEventArgs e) {
+ if (dataGridView != null) {
+ dataGridView.InternalOnCellClick(e);
+ }
+ }
+
+ protected void RaiseCellContentClick (DataGridViewCellEventArgs e) {
+ if (dataGridView != null) {
+ dataGridView.InternalOnCellContentClick(e);
+ }
+ }
+
+ protected void RaiseCellContentDoubleClick (DataGridViewCellEventArgs e) {
+ if (dataGridView != null) {
+ dataGridView.InternalOnCellContentDoubleClick(e);
+ }
+ }
+
+ protected void RaiseCellValueChanged (DataGridViewCellEventArgs e) {
+ if (dataGridView != null) {
+ dataGridView.InternalOnCellValueChanged(e);
+ }
+ }
+
+ protected void RaiseDataError (DataGridViewDataErrorEventArgs e) {
+ if (dataGridView != null) {
+ dataGridView.InternalOnDataError(e);
+ }
+ }
+
+ protected void RaiseMouseWheel (MouseEventArgs e) {
+ if (dataGridView != null) {
+ dataGridView.InternalOnMouseWheel(e);
+ }
+ }
+
+ internal virtual void SetDataGridView (DataGridView dataGridView) {
+ if (this.DataGridView == null && dataGridView != null) {
+ this.dataGridView = dataGridView;
+ return;
+ }
+ if (dataGridView != this.DataGridView) {
+ this.dataGridView = dataGridView;
+ OnDataGridViewChanged();
+ }
+ }
+
+ internal virtual void SetState (DataGridViewElementStates state) {
+ this.state = state;
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewElementStates.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewElementStates.cs
new file mode 100644
index 00000000000..f00d4e45dec
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewElementStates.cs
@@ -0,0 +1,49 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+
+ [FlagsAttribute()]
+ [ComVisibleAttribute(true)]
+ public enum DataGridViewElementStates {
+ None = 0,
+ Displayed = 1,
+ Frozen = 2,
+ ReadOnly = 4,
+ Resizable = 8,
+ ResizableSet = 16,
+ Selected = 32,
+ Visible = 64
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewHeaderBorderStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewHeaderBorderStyle.cs
new file mode 100644
index 00000000000..bd3aa5afea6
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewHeaderBorderStyle.cs
@@ -0,0 +1,41 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public enum DataGridViewHeaderBorderStyle {
+ Custom = 0,
+ Single = 1,
+ Raised = 2,
+ Sunken = 3,
+ None = 4
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewHeaderCell.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewHeaderCell.cs
new file mode 100644
index 00000000000..c3ddffa4fe3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewHeaderCell.cs
@@ -0,0 +1,98 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+ public class DataGridViewHeaderCell : DataGridViewCell {
+
+ private ButtonState buttonState;
+
+ public DataGridViewHeaderCell () {
+ }
+
+ public override bool Displayed {
+ get { return base.Displayed; }
+ }
+
+ public override Type FormattedValueType {
+ get { return typeof(string); } //base.FormattedValueType; }
+ }
+
+ public override bool Frozen {
+ get { return base.Frozen; }
+ }
+
+ public override bool ReadOnly {
+ get { return base.ReadOnly; }
+ set { base.ReadOnly = value; }
+ }
+
+ public override bool Resizable {
+ get { return base.Resizable; }
+ }
+
+ public override bool Selected {
+ get { return base.Selected; }
+ set { base.Selected = value; }
+ }
+
+ public override Type ValueType {
+ get { return base.ValueType; }
+ set { base.ValueType = value; }
+ }
+
+ public override bool Visible {
+ get { return base.Visible; }
+ }
+
+ public override object Clone () {
+ DataGridViewHeaderCell result = new DataGridViewHeaderCell();
+ return result;
+ }
+
+ /*
+ public override ContextMenuStrip GetInheritedContextMenuStrip (int rowIndex) {
+ }
+ */
+
+ public override DataGridViewElementStates GetInheritedState (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ public override string ToString () {
+ return "";
+ }
+
+ protected ButtonState ButtonState {
+ get { return buttonState; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewHitTestType.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewHitTestType.cs
new file mode 100644
index 00000000000..28d05f6d845
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewHitTestType.cs
@@ -0,0 +1,43 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public enum DataGridViewHitTestType {
+ None = 0,
+ Cell = 1,
+ ColumnHeader = 2,
+ RowHeader = 3,
+ TopLeftHeader = 4,
+ HorizontalScrollBar = 5,
+ VerticalScrollBar = 6
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewImageCell.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewImageCell.cs
new file mode 100644
index 00000000000..ca350e8ed29
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewImageCell.cs
@@ -0,0 +1,174 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.Drawing;
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewImageCell : DataGridViewCell {
+
+ private object defaultNewRowValue;
+ private string description;
+ private DataGridViewImageCellLayout imageLayout;
+ private bool valueIsIcon;
+
+ public DataGridViewImageCell (bool valueIsIcon) {
+ this.valueIsIcon = valueIsIcon;
+ this.imageLayout = DataGridViewImageCellLayout.NotSet;
+ }
+
+ public DataGridViewImageCell () : this(false) {
+ }
+
+ public override object DefaultNewRowValue {
+ get { return defaultNewRowValue; }
+ }
+
+ public string Description {
+ get { return description; }
+ set { description = value; }
+ }
+
+ public override Type EditType {
+ get { return null; }
+ }
+
+ public override Type FormattedValueType {
+ get { return (valueIsIcon)? typeof(Icon) : typeof(Image); }
+ }
+
+ public DataGridViewImageCellLayout ImageLayout {
+ get { return imageLayout; }
+ set {
+ if (!Enum.IsDefined(typeof(DataGridViewImageCellLayout), value)) {
+ throw new InvalidEnumArgumentException("Value is invalid image cell layout.");
+ }
+ imageLayout = value;
+ }
+ }
+
+ public bool ValueIsIcon {
+ get { return valueIsIcon; }
+ set { valueIsIcon = value; }
+ }
+
+ public override Type ValueType {
+ get {
+ if (base.ValueType != null) {
+ return base.ValueType;
+ }
+ if (OwningColumn != null) {
+ return OwningColumn.ValueType;
+ }
+ if (valueIsIcon) {
+ return typeof(Icon);
+ }
+ else {
+ return typeof(Image);
+ }
+ }
+ set { base.ValueType = value; }
+ }
+
+ public override object Clone () {
+ DataGridViewImageCell cell = (DataGridViewImageCell) base.Clone();
+ cell.defaultNewRowValue = this.defaultNewRowValue;
+ cell.description = this.description;
+ cell.valueIsIcon = this.valueIsIcon;
+ return cell;
+ }
+
+ public override string ToString () {
+ return GetType().Name;
+ }
+
+ protected override AccessibleObject CreateAccessibilityInstance () {
+ return new DataGridViewImageCellAccessibleObject(this);
+ }
+
+ protected override Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override Rectangle GetErrorIconBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override object GetFormattedValue (object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context) {
+ throw new NotImplementedException();
+ }
+
+ protected override Size GetPreferredSize (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) {
+ throw new NotImplementedException();
+ }
+
+ protected override object GetValue (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnMouseEnter (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnMouseLeave (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override void Paint (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementeState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
+ throw new NotImplementedException();
+ }
+
+ protected class DataGridViewImageCellAccessibleObject : DataGridViewCellAccessibleObject {
+
+ public DataGridViewImageCellAccessibleObject (DataGridViewCell owner) : base(owner) {
+ }
+
+ public override string DefaultAction {
+ get { return ""; }
+ }
+
+ public override string Description {
+ get { return (Owner as DataGridViewImageCell).Description; }
+ }
+
+ public override void DoDefaultAction () {
+ // The DataGridViewImageCell has no default action.
+ }
+
+ public override int GetChildCount () {
+ return -1;
+ }
+
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewImageCellLayout.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewImageCellLayout.cs
new file mode 100644
index 00000000000..933e831bad0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewImageCellLayout.cs
@@ -0,0 +1,40 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public enum DataGridViewImageCellLayout {
+ Normal,
+ NotSet,
+ Stretch,
+ Zoom
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewImageColumn.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewImageColumn.cs
new file mode 100644
index 00000000000..4ed6bef247b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewImageColumn.cs
@@ -0,0 +1,94 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.Drawing;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewImageColumn : DataGridViewColumn {
+
+ private Icon icon;
+ private Image image;
+
+ public DataGridViewImageColumn () : this(false) {
+ }
+
+ public DataGridViewImageColumn (bool valuesAreIcons) {
+ //this.valuesAreIcons = valuesAreIcons;
+ base.CellTemplate = new DataGridViewImageCell(valuesAreIcons);
+ (base.CellTemplate as DataGridViewImageCell).ImageLayout = DataGridViewImageCellLayout.Normal;
+ icon = null;
+ image = null;
+ }
+
+ public override DataGridViewCell CellTemplate {
+ get { return base.CellTemplate; }
+ set { base.CellTemplate = value as DataGridViewImageCell; }
+ }
+
+ public override DataGridViewCellStyle DefaultCellStyle {
+ get { return base.DefaultCellStyle; }
+ set { base.DefaultCellStyle = value; }
+ }
+
+ public string Description {
+ get { return (base.CellTemplate as DataGridViewImageCell).Description; }
+ set { (base.CellTemplate as DataGridViewImageCell).Description = value; }
+ }
+
+ public Icon Icon {
+ get { return icon; }
+ set { icon = value; }
+ }
+
+ public Image Image {
+ get { return image; }
+ set { image = value; }
+ }
+
+ public DataGridViewImageCellLayout ImageLayout {
+ get { return (base.CellTemplate as DataGridViewImageCell).ImageLayout; }
+ set { (base.CellTemplate as DataGridViewImageCell).ImageLayout = value; }
+ }
+
+ public override object Clone () {
+ DataGridViewImageColumn col = (DataGridViewImageColumn) base.Clone();
+ col.icon = this.icon;
+ col.image = this.image;
+ return col;
+ }
+
+ public override string ToString () {
+ return GetType().Name;
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewPaintParts.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewPaintParts.cs
new file mode 100644
index 00000000000..f3fb1697684
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewPaintParts.cs
@@ -0,0 +1,46 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ [FlagsAttribute()]
+ public enum DataGridViewPaintParts {
+ None = 0,
+ Background = 1,
+ Border = 2,
+ ContentBackground = 4,
+ ContentForeground = 8,
+ ErrorIcon = 16,
+ Focus = 32,
+ SelectionBackground = 64,
+ All = 127
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRow.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRow.cs
new file mode 100644
index 00000000000..0ca311b69e1
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRow.cs
@@ -0,0 +1,484 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.Drawing;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewRow : DataGridViewBand {
+
+ private AccessibleObject accessibilityObject;
+ private DataGridViewCellCollection cells;
+ //private ContextMenuStrip contextMenuStrip;
+ private object dataBoundItem;
+ private int dividerHeight;
+ private string errorText;
+ private DataGridViewRowHeaderCell headerCell;
+ private int height;
+ private int minimumHeight;
+
+ public DataGridViewRow () {
+ cells = new DataGridViewCellCollection(this);
+ minimumHeight = 3;
+ height = -1;
+ headerCell = new DataGridViewRowHeaderCell();
+ }
+
+ public AccessibleObject AccessibilityObject {
+ get { return accessibilityObject; }
+ }
+
+ public DataGridViewCellCollection Cells {
+ get { return cells; }
+ }
+
+ /*
+ public override ContextMenuStrip ContextMenuStrip {
+ get { return contextMenuStrip; }
+ set {
+ if (contextMenuStrip != value) {
+ contextMenuStrip = value;
+ if (DataGridView != null) {
+ DataGridView.OnRowContextMenuStripChanged(new DataGridViewRowEventArgs(this));
+ }
+ }
+ }
+ }
+ */
+
+ public object DataBoundItem {
+ get { return dataBoundItem; }
+ }
+
+ public override DataGridViewCellStyle DefaultCellStyle {
+ get { return base.DefaultCellStyle; }
+ set {
+ if (DefaultCellStyle != value) {
+ base.DefaultCellStyle = value;
+ if (DataGridView != null) {
+ DataGridView.OnRowDefaultCellStyleChanged(new DataGridViewRowEventArgs(this));
+ }
+ }
+ }
+ }
+
+ public override bool Displayed {
+ get { return base.Displayed; }
+ }
+
+ public int DividerHeight {
+ get { return dividerHeight; }
+ set { dividerHeight = value; }
+ }
+
+ public string ErrorText {
+ get { return errorText; }
+ set {
+ if (errorText != value) {
+ errorText = value;
+ if (DataGridView != null) {
+ DataGridView.OnRowErrorTextChanged(new DataGridViewRowEventArgs(this));
+ }
+ }
+ }
+ }
+
+ public override bool Frozen {
+ get { return base.Frozen; }
+ set { base.Frozen = value; }
+ }
+
+ public DataGridViewRowHeaderCell HeaderCell {
+ get { return headerCell; }
+ set {
+ if (headerCell != value) {
+ headerCell = value;
+ if (DataGridView != null) {
+ DataGridView.OnRowHeaderCellChanged(new DataGridViewRowEventArgs(this));
+ }
+ }
+ }
+ }
+
+ public int Height {
+ get {
+ if (height < 0) {
+ if (DefaultCellStyle != null && DefaultCellStyle.Font != null) {
+ return DefaultCellStyle.Font.Height + 9;
+ }
+ if (InheritedStyle != null && InheritedStyle.Font != null) {
+ return InheritedStyle.Font.Height + 9;
+ }
+ return System.Windows.Forms.Control.DefaultFont.Height + 9;
+ }
+ return height;
+ }
+ set {
+ if (height != value) {
+ if (height < minimumHeight) {
+ throw new ArgumentOutOfRangeException("Height can't be less than MinimumHeight.");
+ }
+ height = value;
+ if (DataGridView != null) {
+ DataGridView.OnRowHeightChanged(new DataGridViewRowEventArgs(this));
+ }
+ }
+ }
+ }
+
+ public override DataGridViewCellStyle InheritedStyle {
+ get {
+ if (DataGridView == null) {
+ return DefaultCellStyle;
+ }
+ else {
+ if (DefaultCellStyle == null) {
+ return DataGridView.DefaultCellStyle;
+ }
+ else {
+ DataGridViewCellStyle style = (DataGridViewCellStyle) DefaultCellStyle.Clone();
+ /////// Combination with dataGridView.DefaultCellStyle
+ return style;
+ }
+ }
+ }
+ }
+
+ public bool IsNewRow {
+ get {
+ if (DataGridView != null && DataGridView.Rows[DataGridView.Rows.Count - 1] == this) {
+ return true;
+ }
+ return false;
+ }
+ }
+
+ public int MinimumHeight {
+ get { return minimumHeight; }
+ set {
+ if (minimumHeight != value) {
+ if (value < 2 || value > Int32.MaxValue) {
+ throw new ArgumentOutOfRangeException("MinimumHeight should be between 2 and Int32.MaxValue.");
+ }
+ minimumHeight = value;
+ if (DataGridView != null) {
+ DataGridView.OnRowMinimumHeightChanged(new DataGridViewRowEventArgs(this));
+ }
+ }
+ }
+ }
+
+ public override bool ReadOnly {
+ get { return base.ReadOnly; }
+ set { base.ReadOnly = value; }
+ }
+
+ public override DataGridViewTriState Resizable {
+ get { return base.Resizable; }
+ set { base.Resizable = value; }
+ }
+
+ public override bool Selected {
+ get {
+ if (Index == -1) {
+ throw new InvalidOperationException("The row is a shared row.");
+ }
+ if (DataGridView == null) {
+ throw new InvalidOperationException("The row has not been added to a DataGridView control.");
+ }
+ return base.Selected;
+ }
+ set {
+ if (Index == -1) {
+ throw new InvalidOperationException("The row is a shared row.");
+ }
+ if (DataGridView == null) {
+ throw new InvalidOperationException("The row has not been added to a DataGridView control.");
+ }
+ base.Selected = value;
+ foreach (DataGridViewCell cell in cells) {
+ cell.Selected = value;
+ }
+ }
+ }
+
+ public override DataGridViewElementStates State {
+ get { return base.State; }
+ }
+
+ public override bool Visible {
+ get { return base.Visible; }
+ set {
+ if (IsNewRow && value == false) {
+ throw new InvalidOperationException("Cant make invisible a new row.");
+ }
+ base.Visible = value;
+ }
+ }
+
+ public virtual DataGridViewAdvancedBorderStyle AdjustRowHeaderBorderStyle (DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput, DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder, bool singleVerticalBorderAdded, bool singleHorizontalBorderAdded, bool isFirstDisplayedRow, bool isLastVisibleRow) {
+ throw new NotImplementedException();
+ }
+
+ public override object Clone () {
+ DataGridViewRow row = (DataGridViewRow) MemberwiseClone();
+ row.cells = new DataGridViewCellCollection(row);
+ foreach (DataGridViewCell cell in cells) {
+ row.cells.Add(cell.Clone() as DataGridViewCell);
+ }
+ return row;
+ }
+
+ public void CreateCells (DataGridView dataGridView) {
+ if (dataGridView == null) {
+ throw new ArgumentNullException("DataGridView is null.");
+ }
+ if (dataGridView.Rows.Contains(this)) {
+ throw new InvalidOperationException("The row already exists in the DataGridView.");
+ }
+ DataGridViewCellCollection newCellCollection = new DataGridViewCellCollection(this);
+ foreach (DataGridViewColumn column in dataGridView.Columns) {
+ if (column.CellTemplate == null) {
+ throw new InvalidOperationException("Cell template not set in column: " + column.Index.ToString() + ".");
+ }
+ newCellCollection.Add((DataGridViewCell) column.CellTemplate.Clone());
+ }
+ cells = newCellCollection;
+ }
+
+ public void CreateCells (DataGridView dataGridView, params object[] values) {
+ if (values == null) {
+ throw new ArgumentNullException("values is null");
+ }
+ CreateCells(dataGridView);
+ for (int i = 0; i < values.Length; i++) {
+ cells[i].Value = values[i];
+ }
+ }
+
+ /*
+ public ContextMenuStrip GetContextMenuStrip (int rowIndex) {
+ if (rowIndex == -1) {
+ throw new InvalidOperationException("rowIndex is -1");
+ }
+ if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count) {
+ throw new ArgumentOutOfRangeException("rowIndex is out of range");
+ }
+ }
+ */
+
+ public string GetErrorText (int rowIndex) {
+ return "";
+ }
+
+ public virtual int GetPreferredHeight (int rowIndex, DataGridViewAutoSizeRowMode autoSizeRowMode, bool fixedWidth) {
+ throw new NotImplementedException();
+ }
+
+ public virtual DataGridViewElementStates GetState (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ public void SetValues (params object[] values) {
+ if (values == null) {
+ throw new ArgumentNullException("vues is null");
+ }
+ if (DataGridView != null && DataGridView.VirtualMode) {
+ throw new InvalidOperationException("DataGridView is operating in virtual mode");
+ }
+ /////// COLUMNAS //////////
+ for (int i = 0; i < values.Length; i++) {
+ DataGridViewCell cell = new DataGridViewTextBoxCell();
+ cell.Value = values[i];
+ cells.Add(cell);
+ }
+ }
+
+ public override string ToString () {
+ return this.GetType().Name + ", Band Index: " + base.Index.ToString();
+ }
+
+ protected virtual AccessibleObject CreateAccessibilityInstance () {
+ return new DataGridViewRowAccessibleObject(this);
+ }
+
+ protected virtual DataGridViewCellCollection CreateCellsInstance () {
+ cells = new DataGridViewCellCollection(this);
+ return cells;
+ }
+
+ protected internal virtual void DrawFocus (Graphics graphics, Rectangle clipBounds, Rectangle bounds, int rowIndex, DataGridViewElementStates rowState, DataGridViewCellStyle cellStyle, bool cellsPaintSelectionBackground) {
+ }
+
+ protected internal virtual void Paint (Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, int rowIndex, DataGridViewElementStates rowState, bool isFirstDisplayedRow, bool isLastVisibleRow) {
+ }
+
+ protected internal virtual void PaintCells (Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, int rowIndex, DataGridViewElementStates rowState, bool isFirstDisplayedRow, bool isLastVisibleRow, DataGridViewPaintParts paintParts) {
+ }
+
+ protected internal virtual void PaintHeader (Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, int rowIndex, DataGridViewElementStates rowState, bool isFirstDisplayedRow, bool isLastVisibleRow, DataGridViewPaintParts paintParts) {
+ }
+
+ internal override void SetDataGridView (DataGridView dataGridView) {
+ base.SetDataGridView(dataGridView);
+ headerCell.SetDataGridView(dataGridView);
+ }
+
+ internal override void SetState (DataGridViewElementStates state) {
+ if (State != state) {
+ base.SetState(state);
+ if (DataGridView != null) {
+ DataGridView.OnRowStateChanged(this.Index, new DataGridViewRowStateChangedEventArgs(this, state));
+ }
+ }
+ }
+
+ [ComVisibleAttribute(true)]
+ protected class DataGridViewRowAccessibleObject : AccessibleObject {
+
+ private DataGridViewRow dataGridViewRow;
+
+ public DataGridViewRowAccessibleObject () {
+ }
+
+ public DataGridViewRowAccessibleObject (DataGridViewRow row) {
+ this.dataGridViewRow = row;
+ }
+
+ public override Rectangle Bounds {
+ get { throw new NotImplementedException(); }
+ }
+
+ public override string DefaultAction {
+ get { return "Edit"; }
+ }
+
+ public override string Name {
+ get { return "Index: " + dataGridViewRow.Index.ToString(); }
+ }
+
+ public DataGridViewRow Owner {
+ get { return dataGridViewRow; }
+ set { dataGridViewRow = value; }
+ }
+
+ public override AccessibleObject Parent {
+ get { return dataGridViewRow.AccessibilityObject; }
+ }
+
+ public override AccessibleRole Role {
+ get { return AccessibleRole.Row; }
+ }
+
+ public override AccessibleStates State {
+ get {
+ if (dataGridViewRow.Selected) {
+ return AccessibleStates.Selected;
+ }
+ else {
+ return AccessibleStates.Focused;
+ }
+ }
+ }
+
+ public override string Value {
+ get {
+ if (dataGridViewRow.Cells.Count == 0) {
+ return "(Create New)";
+ }
+ string result = "";
+ foreach (DataGridViewCell cell in dataGridViewRow.Cells) {
+ result += cell.AccessibilityObject.Value;
+ }
+ return result;
+ }
+ }
+
+ public override AccessibleObject GetChild (int index) {
+ throw new NotImplementedException();
+ }
+
+ public override int GetChildCount () {
+ throw new NotImplementedException();
+ }
+
+ public override AccessibleObject GetFocused () {
+ return null;
+ }
+
+ public override AccessibleObject GetSelected () {
+ return null;
+ }
+
+ public override AccessibleObject Navigate (AccessibleNavigation navigationDirection) {
+ switch (navigationDirection) {
+ case AccessibleNavigation.Right:
+ break;
+ case AccessibleNavigation.Left:
+ break;
+ case AccessibleNavigation.Next:
+ break;
+ case AccessibleNavigation.Previous:
+ break;
+ case AccessibleNavigation.Up:
+ break;
+ case AccessibleNavigation.Down:
+ break;
+ default:
+ return null;
+ }
+ return null;
+ }
+
+ public override void Select (AccessibleSelection flags) {
+ switch (flags) {
+ case AccessibleSelection.TakeFocus:
+ dataGridViewRow.DataGridView.Focus();
+ break;
+ case AccessibleSelection.TakeSelection:
+ //dataGridViewRow.Focus();
+ break;
+ case AccessibleSelection.AddSelection:
+ dataGridViewRow.DataGridView.SelectedRows.InternalAdd(dataGridViewRow);
+ break;
+ case AccessibleSelection.RemoveSelection:
+ dataGridViewRow.DataGridView.SelectedRows.InternalRemove(dataGridViewRow);
+ break;
+ }
+ }
+
+ }
+
+
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowCancelEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowCancelEventArgs.cs
new file mode 100644
index 00000000000..5f8a3e9ce48
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowCancelEventArgs.cs
@@ -0,0 +1,49 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewRowCancelEventArgs : CancelEventArgs {
+
+ DataGridViewRow dataGridViewRow;
+
+ public DataGridViewRowCancelEventArgs (DataGridViewRow dataGridViewRow) {
+ this.dataGridViewRow = dataGridViewRow;
+ }
+
+ public DataGridViewRow Row {
+ get { return dataGridViewRow; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowCancelEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowCancelEventHandler.cs
new file mode 100644
index 00000000000..da05cc6224c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowCancelEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewRowCancelEventHandler (object sender, DataGridViewRowCancelEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowCollection.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowCollection.cs
new file mode 100644
index 00000000000..72d361bc8d1
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowCollection.cs
@@ -0,0 +1,434 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.ComponentModel;
+using System.Collections;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewRowCollection : IList, ICollection, IEnumerable {
+
+ private ArrayList list;
+ private DataGridView dataGridView;
+
+ private bool raiseEvent = true;
+
+ public DataGridViewRowCollection (DataGridView dataGridView) {
+ if (dataGridView == null) {
+ throw new ArgumentException("DataGridView is null.");
+ }
+ this.dataGridView = dataGridView;
+ list = new ArrayList();
+ }
+
+ public int Count {
+ get { return list.Count; }
+ }
+
+ public bool IsFixedSize {
+ get { return list.IsFixedSize; }
+ }
+
+ public bool IsReadOnly {
+ get { return list.IsReadOnly; }
+ }
+
+ public bool IsSynchronized {
+ get { return list.IsSynchronized; }
+ }
+
+ object IList.this [int index] {
+ get {
+ Console.WriteLine("acceso");
+ return this[index];
+ }
+ set { list[index] = value as DataGridViewRow; }
+ }
+
+ public DataGridViewRow this [int index] {
+ get {
+ // Accessing a System.Windows.Forms.DataGridViewRow with this indexer causes the row to become unshared. To keep the row shared, use the System.Windows.Forms.DataGridViewRowCollection.SharedRow method. For more information, see Best Practices for Scaling the Windows Forms DataGridView Control.
+ return (DataGridViewRow) list[index];
+ }
+ }
+
+ public object SyncRoot {
+ get { return list.SyncRoot; }
+ }
+
+ public event CollectionChangeEventHandler CollectionChange;
+
+ public virtual int Add () {
+ return Add(dataGridView.RowTemplate.Clone() as DataGridViewRow);
+ }
+
+ int IList.Add(object o) {
+ return Add(o as DataGridViewRow);
+ }
+
+ public virtual int Add (DataGridViewRow dataGridViewRow) {
+ if (dataGridView.DataSource != null) {
+ throw new InvalidOperationException("DataSource of DataGridView is not null.");
+ }
+ if (dataGridView.Columns.Count == 0) {
+ throw new InvalidOperationException("DataGridView has no columns.");
+ }
+ dataGridViewRow.SetIndex(list.Count);
+ dataGridViewRow.SetDataGridView(dataGridView);
+ int result = list.Add(dataGridViewRow);
+ OnCollectionChange(new CollectionChangeEventArgs(CollectionChangeAction.Add, dataGridViewRow));
+ if (raiseEvent) {
+ DataGridView.OnRowsAdded(new DataGridViewRowsAddedEventArgs(result, 1));
+ }
+ return result;
+ }
+
+ public virtual int Add (int count) {
+ if (count <= 0) {
+ throw new ArgumentOutOfRangeException("Count is less than or equeal to 0.");
+ }
+ if (dataGridView.DataSource != null) {
+ throw new InvalidOperationException("DataSource of DataGridView is not null.");
+ }
+ if (dataGridView.Columns.Count == 0) {
+ throw new InvalidOperationException("DataGridView has no columns.");
+ }
+ raiseEvent = false;
+ int result = 0;
+ for (int i = 0; i < count; i++) {
+ result = Add(dataGridView.RowTemplate.Clone() as DataGridViewRow);
+ }
+ DataGridView.OnRowsAdded(new DataGridViewRowsAddedEventArgs(result - count + 1, count));
+ raiseEvent = true;
+ return result;
+ }
+
+ public virtual int Add (params object[] values) {
+ if (values == null) {
+ throw new ArgumentNullException("values is null.");
+ }
+ if (dataGridView.VirtualMode) {
+ throw new InvalidOperationException("DataGridView is in virtual mode.");
+ }
+ DataGridViewRow row = new DataGridViewRow();
+ int result = Add(row);
+ row.SetValues(values);
+ return result;
+ }
+
+ public virtual int AddCopies (int indexSource, int count) {
+ raiseEvent = false;
+ int lastIndex = 0;
+ for (int i = 0; i < count; i++) {
+ lastIndex = AddCopy(indexSource);
+ }
+ DataGridView.OnRowsAdded(new DataGridViewRowsAddedEventArgs(lastIndex - count + 1, count));
+ raiseEvent = true;
+ return lastIndex;
+ }
+
+ public virtual int AddCopy (int indexSource) {
+ return Add((list[indexSource] as DataGridViewRow).Clone() as DataGridViewRow);
+ }
+
+ public virtual void AddRange (params DataGridViewRow[] dataGridViewRows) {
+ raiseEvent = false;
+ int count = 0;
+ int lastIndex = -1;
+ foreach (DataGridViewRow row in dataGridViewRows) {
+ lastIndex = Add(row);
+ count++;
+ }
+ DataGridView.OnRowsAdded(new DataGridViewRowsAddedEventArgs(lastIndex - count + 1, count));
+ raiseEvent = true;
+ }
+
+ public virtual void Clear () {
+ list.Clear();
+ }
+
+ bool IList.Contains (object o) {
+ return Contains(o as DataGridViewRow);
+ }
+
+ public virtual bool Contains (DataGridViewRow dataGridViewRow) {
+ return list.Contains(dataGridViewRow);
+ }
+
+ public void CopyTo (Array array, int index) {
+ list.CopyTo(array, index);
+ }
+
+ public void CopyTo (DataGridViewRow[] array, int index) {
+ list.CopyTo(array, index);
+ }
+
+ public IEnumerator GetEnumerator () {
+ return list.GetEnumerator();
+ }
+
+ public int GetFirstRow (DataGridViewElementStates includeFilter) {
+ for (int i = 0; i < list.Count; i++) {
+ DataGridViewRow row = (DataGridViewRow) list[i];
+ if ((row.State & includeFilter) != 0) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public int GetFirstRow (DataGridViewElementStates includeFilter, DataGridViewElementStates excludeFilter) {
+ for (int i = 0; i < list.Count; i++) {
+ DataGridViewRow row = (DataGridViewRow) list[i];
+ if (((row.State & includeFilter) != 0) && ((row.State & excludeFilter) == 0)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public int GetLastRow (DataGridViewElementStates includeFilter) {
+ for (int i = list.Count - 1; i >= 0; i--) {
+ DataGridViewRow row = (DataGridViewRow) list[i];
+ if ((row.State & includeFilter) != 0) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public int GetNextRow (int indexStart, DataGridViewElementStates includeFilter) {
+ for (int i = indexStart + 1; i < list.Count; i++) {
+ DataGridViewRow row = (DataGridViewRow) list[i];
+ if ((row.State & includeFilter) != 0) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public int GetNextRow (int indexStart, DataGridViewElementStates includeFilter, DataGridViewElementStates excludeFilter) {
+ for (int i = indexStart + 1; i < list.Count; i++) {
+ DataGridViewRow row = (DataGridViewRow) list[i];
+ if (((row.State & includeFilter) != 0) && ((row.State & excludeFilter) == 0)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public int GetPreviousRow (int indexStart, DataGridViewElementStates includeFilter) {
+ for (int i = indexStart - 1; i >= 0; i--) {
+ DataGridViewRow row = (DataGridViewRow) list[i];
+ if ((row.State & includeFilter) != 0) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public int GetPreviousRow (int indexStart, DataGridViewElementStates includeFilter, DataGridViewElementStates excludeFilter) {
+ for (int i = indexStart - 1; i >= 0; i--) {
+ DataGridViewRow row = (DataGridViewRow) list[i];
+ if (((row.State & includeFilter) != 0) && ((row.State & excludeFilter) == 0)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public int GetRowCount (DataGridViewElementStates includeFilter) {
+ int result = 0;
+ foreach (DataGridViewRow row in list) {
+ if ((row.State & includeFilter) != 0) {
+ result ++;
+ }
+ }
+ return result;
+ }
+
+ public int GetRowsHeight (DataGridViewElementStates includeFilter) {
+ int result = 0;
+ foreach (DataGridViewRow row in list) {
+ if ((row.State & includeFilter) != 0) {
+ result += row.Height;
+ }
+ }
+ return result;
+ }
+
+ public virtual DataGridViewElementStates GetRowState (int rowIndex) {
+ return (list[rowIndex] as DataGridViewRow).State;
+ }
+
+ int IList.IndexOf (object o) {
+ return IndexOf(o as DataGridViewRow);
+ }
+
+ public int IndexOf (DataGridViewRow dataGridViewRow) {
+ return list.IndexOf(dataGridViewRow);
+ }
+
+ void IList.Insert (int rowIndex, object o) {
+ Insert(rowIndex, o as DataGridViewRow);
+ }
+
+ public virtual void Insert (int rowIndex, DataGridViewRow dataGridViewRow) {
+ dataGridViewRow.SetIndex(rowIndex);
+ dataGridViewRow.SetDataGridView(dataGridView);
+ list[rowIndex] = dataGridViewRow;
+ OnCollectionChange(new CollectionChangeEventArgs(CollectionChangeAction.Add, dataGridViewRow));
+ if (raiseEvent) {
+ DataGridView.OnRowsAdded(new DataGridViewRowsAddedEventArgs(rowIndex, 1));
+ }
+ }
+
+ public virtual void Insert (int rowIndex, int count) {
+ int index = rowIndex;
+ raiseEvent = false;
+ for (int i = 0; i < count; i++) {
+ Insert(index++, dataGridView.RowTemplate.Clone());
+ }
+ DataGridView.OnRowsAdded(new DataGridViewRowsAddedEventArgs(rowIndex, count));
+ raiseEvent = true;
+ }
+
+ public virtual void Insert (int rowIndex, params object[] values) {
+ if (values == null) {
+ throw new ArgumentNullException("Values is null.");
+ }
+ if (dataGridView.VirtualMode || dataGridView.DataSource != null) {
+ throw new InvalidOperationException();
+ }
+ DataGridViewRow row = new DataGridViewRow();
+ row.SetValues(values);
+ Insert(rowIndex, row);
+ }
+
+ public virtual void InsertCopies (int indexSource, int indexDestination, int count) {
+ raiseEvent = false;
+ int index = indexDestination;
+ for (int i = 0; i < count; i++) {
+ InsertCopy(indexSource, index++);
+ }
+ DataGridView.OnRowsAdded(new DataGridViewRowsAddedEventArgs(indexDestination, count));
+ raiseEvent = true;
+ }
+
+ public virtual void InsertCopy (int indexSource, int indexDestination) {
+ Insert(indexDestination, (list[indexSource] as DataGridViewRow).Clone());
+ }
+
+ public virtual void InsertRange (int rowIndex, params DataGridViewRow[] dataGridViewRows) {
+ raiseEvent = false;
+ int index = rowIndex;
+ int count = 0;
+ foreach (DataGridViewRow row in dataGridViewRows) {
+ Insert(index++, row);
+ count++;
+ }
+ DataGridView.OnRowsAdded(new DataGridViewRowsAddedEventArgs(rowIndex, count));
+ raiseEvent = true;
+ }
+
+ void IList.Remove (object o) {
+ Remove(o as DataGridViewRow);
+ }
+
+ public virtual void Remove (DataGridViewRow dataGridViewRow) {
+ list.Remove(dataGridViewRow);
+ OnCollectionChange(new CollectionChangeEventArgs(CollectionChangeAction.Remove, dataGridViewRow));
+ DataGridView.OnRowsRemoved(new DataGridViewRowsRemovedEventArgs(dataGridViewRow.Index, 1));
+ }
+
+ public virtual void RemoveAt (int index) {
+ DataGridViewRow row = this[index];
+ list.RemoveAt(index);
+ OnCollectionChange(new CollectionChangeEventArgs(CollectionChangeAction.Remove, row));
+ DataGridView.OnRowsRemoved(new DataGridViewRowsRemovedEventArgs(index, 1));
+ }
+
+ public DataGridViewRow SharedRow (int rowIndex) {
+ return (DataGridViewRow) list[rowIndex];
+ }
+
+ protected DataGridView DataGridView {
+ get { return dataGridView; }
+ }
+
+ protected ArrayList List {
+ get { return list; }
+ }
+
+ protected virtual void OnCollectionChange (CollectionChangeEventArgs e) {
+ if (CollectionChange != null) {
+ CollectionChange(this, e);
+ }
+ }
+
+ /************************/
+
+ internal void InternalAdd (DataGridViewRow dataGridViewRow) {
+ dataGridViewRow.SetIndex(list.Count);
+ dataGridViewRow.SetDataGridView(dataGridView);
+ list.Add(dataGridViewRow);
+ }
+
+ internal ArrayList RowIndexSortedArrayList {
+ get {
+ ArrayList result = (ArrayList) list.Clone();
+ result.Sort(new RowIndexComparator());
+ return result;
+ }
+ }
+
+ private class RowIndexComparator : IComparer {
+
+ public int Compare (object o1, object o2) {
+ DataGridViewRow row1 = (DataGridViewRow) o1;
+ DataGridViewRow row2 = (DataGridViewRow) o2;
+ if (row1.Index < row2.Index) {
+ return -1;
+ }
+ else if (row1.Index > row2.Index) {
+ return 1;
+ }
+ else {
+ return 0;
+ }
+ }
+
+ }
+
+ /************************/
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowContextMenuStripNeededEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowContextMenuStripNeededEventArgs.cs
new file mode 100644
index 00000000000..96f09f2e67f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowContextMenuStripNeededEventArgs.cs
@@ -0,0 +1,55 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewRowContextMenuStripNeededEventArgs : EventArgs {
+
+ private int rowIndex;
+ //private ContextMenuStrip contextMenuStrip;
+
+ public DataGridViewRowContextMenuStripNeededEventArgs (int rowIndex) {
+ this.rowIndex = rowIndex;
+ }
+
+ /*
+ public ContextMenuStrip ContextMenuStrip {
+ get { return contextMenuStrip; }
+ set { contextMenuStrip = value; }
+ }
+ */
+
+ public int RowIndex {
+ get { return rowIndex; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowContextMenuStripNeededEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowContextMenuStripNeededEventHandler.cs
new file mode 100644
index 00000000000..67fae9c98aa
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowContextMenuStripNeededEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewRowContextMenuStripNeededEventHandler (object sender, DataGridViewRowContextMenuStripNeededEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowDividerDoubleClickEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowDividerDoubleClickEventArgs.cs
new file mode 100644
index 00000000000..72ef21a5ec2
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowDividerDoubleClickEventArgs.cs
@@ -0,0 +1,47 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewRowDividerDoubleClickEventArgs : HandledMouseEventArgs {
+
+ private int rowIndex;
+
+ public DataGridViewRowDividerDoubleClickEventArgs (int rowIndex, HandledMouseEventArgs e) : base(e.Button, e.Clicks, e.X, e.Y, e.Delta) {
+ this.rowIndex = rowIndex;
+ }
+
+ public int RowIndex {
+ get { return rowIndex; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowDividerDoubleClickEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowDividerDoubleClickEventHandler.cs
new file mode 100644
index 00000000000..7a4605e2ef4
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowDividerDoubleClickEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewRowDividerDoubleClickEventHandler (object sender, DataGridViewRowDividerDoubleClickEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowErrorTextNeededEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowErrorTextNeededEventArgs.cs
new file mode 100644
index 00000000000..2a5734a1412
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowErrorTextNeededEventArgs.cs
@@ -0,0 +1,54 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewRowErrorTextNeededEventArgs : EventArgs {
+
+ private int rowIndex;
+ private string errorText;
+
+ internal DataGridViewRowErrorTextNeededEventArgs (int rowIndex, string errorText) {
+ this.rowIndex = rowIndex;
+ this.errorText = errorText;
+ }
+
+ public string ErrorText {
+ get { return errorText; }
+ set { errorText = value; }
+ }
+
+ public int RowIndex {
+ get { return rowIndex; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowErrorTextNeededEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowErrorTextNeededEventHandler.cs
new file mode 100644
index 00000000000..052a4cb3319
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowErrorTextNeededEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewRowErrorTextNeededEventHandler (object sender, DataGridViewRowErrorTextNeededEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowEventArgs.cs
new file mode 100644
index 00000000000..18b28444417
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowEventArgs.cs
@@ -0,0 +1,47 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewRowEventArgs : EventArgs {
+
+ private DataGridViewRow dataGridViewRow;
+
+ public DataGridViewRowEventArgs (DataGridViewRow dataGridViewRow) {
+ this.dataGridViewRow = dataGridViewRow;
+ }
+
+ public DataGridViewRow Row {
+ get { return dataGridViewRow; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowEventHandler.cs
new file mode 100644
index 00000000000..a67cd6a3add
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewRowEventHandler (object sender, DataGridViewRowEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeaderCell.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeaderCell.cs
new file mode 100644
index 00000000000..363366e19f5
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeaderCell.cs
@@ -0,0 +1,144 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.Drawing;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewRowHeaderCell : DataGridViewHeaderCell {
+
+ public DataGridViewRowHeaderCell () {
+ }
+
+ public override object Clone () {
+ return MemberwiseClone();
+ }
+
+ /*
+ public override ContextMenuStrip GetInheritedContextMenuStrip (int rowIndex) {
+ }
+ */
+
+ public override DataGridViewCellStyle GetInheritedStyle (DataGridViewCellStyle inheritedCellStyle, int rowIndex, bool includeColors) {
+ throw new NotImplementedException();
+ }
+
+ public override string ToString () {
+ return base.ToString();
+ }
+
+ protected override AccessibleObject CreateAccessibilityInstance () {
+ return new DataGridViewRowHeaderCellAccessibleObject(this);
+ }
+
+ protected override object GetClipboardContent (int rowIndex, bool firstCell, bool lastCell, bool inFirstRow, bool inLastRow, string format) {
+ throw new NotImplementedException();
+ }
+
+ protected override Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override Rectangle GetErrorIconBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected internal override string GetErrorText (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override Size GetPreferredSize (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) {
+ throw new NotImplementedException();
+ }
+
+ protected override object GetValue (int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnMouseEnter (int rowIndex) {
+ }
+
+ protected override void OnMouseLeave (int rowIndex) {
+ }
+
+ protected override void Paint (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
+ graphics.FillRectangle(new SolidBrush(cellStyle.BackColor), cellBounds);
+ if ((cellState & DataGridViewElementStates.Selected) != 0) {
+ graphics.DrawString("*", cellStyle.Font, new SolidBrush(cellStyle.ForeColor), cellBounds, StringFormat.GenericDefault);
+ }
+ PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
+ }
+
+ protected override bool SetValue (int rowIndex, object value) {
+ throw new NotImplementedException();
+ }
+
+ protected class DataGridViewRowHeaderCellAccessibleObject : DataGridViewCellAccessibleObject {
+
+ public DataGridViewRowHeaderCellAccessibleObject (DataGridViewRowHeaderCell owner) : base(owner) {
+ }
+
+ public override Rectangle Bounds {
+ get { return base.Bounds; }
+ }
+
+ public override string DefaultAction {
+ get { return base.DefaultAction; }
+ }
+
+ public override string Name {
+ get { return base.Name; }
+ }
+
+ public override AccessibleObject Parent {
+ get { return base.Parent; }
+ }
+
+ public override AccessibleRole Role {
+ get { return base.Role; }
+ }
+
+ public override string Value {
+ get { return base.Value; }
+ }
+
+ public override void DoDefaultAction () {
+ base.DoDefaultAction();
+ }
+
+ public override AccessibleObject Navigate (AccessibleNavigation navigationDirection) {
+ return base.Navigate(navigationDirection);
+ }
+
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeadersWidthSizeMode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeadersWidthSizeMode.cs
new file mode 100644
index 00000000000..6bf0613ef78
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeadersWidthSizeMode.cs
@@ -0,0 +1,41 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public enum DataGridViewRowHeadersWidthSizeMode {
+ EnableResizing = 0,
+ DisableResizing = 1,
+ AutoSizeToAllHeaders = 2,
+ AutoSizeToDisplayedHeaders = 3,
+ AutoSizeToFirstHeader = 4
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeightInfoNeededEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeightInfoNeededEventArgs.cs
new file mode 100644
index 00000000000..8e120be8447
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeightInfoNeededEventArgs.cs
@@ -0,0 +1,59 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewRowHeightInfoNeededEventArgs : EventArgs {
+
+ private int height;
+ private int minimumHeight;
+ private int rowIndex;
+
+ internal DataGridViewRowHeightInfoNeededEventArgs (int rowIndex, int height, int minimumHeight) {
+ this.rowIndex = rowIndex;
+ this.height = height;
+ this.minimumHeight = minimumHeight;
+ }
+
+ public int Height {
+ get { return height; }
+ }
+
+ public int MinimumHeight {
+ get { return minimumHeight; }
+ }
+
+ public int RowIndex {
+ get { return rowIndex; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeightInfoNeededEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeightInfoNeededEventHandler.cs
new file mode 100644
index 00000000000..c60d955df4e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeightInfoNeededEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewRowHeightInfoNeededEventHandler (object sender, DataGridViewRowHeightInfoNeededEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeightInfoPushedEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeightInfoPushedEventArgs.cs
new file mode 100644
index 00000000000..cd97dffa295
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeightInfoPushedEventArgs.cs
@@ -0,0 +1,61 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewRowHeightInfoPushedEventArgs : HandledEventArgs {
+
+ private int height;
+ private int minimumHeight;
+ private int rowIndex;
+
+ internal DataGridViewRowHeightInfoPushedEventArgs (int rowIndex, int height, int minimumHeight) {
+ this.rowIndex = rowIndex;
+ this.height = height;
+ this.minimumHeight = minimumHeight;
+ }
+
+ public int Height {
+ get { return height; }
+ }
+
+ public int MinimumHeight {
+ get { return minimumHeight; }
+ }
+
+ public int RowIndex {
+ get { return rowIndex; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeightInfoPushedEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeightInfoPushedEventHandler.cs
new file mode 100644
index 00000000000..e0cb9ac0d39
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeightInfoPushedEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewRowHeightInfoPushedEventHandler (object sender, DataGridViewRowHeightInfoPushedEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowPostPaintEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowPostPaintEventArgs.cs
new file mode 100644
index 00000000000..0229bfe8f05
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowPostPaintEventArgs.cs
@@ -0,0 +1,167 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.ComponentModel;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewRowPostPaintEventArgs : HandledEventArgs {
+
+ private DataGridView dataGridView;
+ private Graphics graphics;
+ private Rectangle clipBounds;
+ private Rectangle rowBounds;
+ private int rowIndex;
+ private DataGridViewElementStates rowState;
+ private string errorText;
+ private DataGridViewCellStyle inheritedRowStyle;
+ private bool isFirstDisplayedRow;
+ private bool isLastVisibleRow;
+
+ public DataGridViewRowPostPaintEventArgs (DataGridView dataGridView, Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, int rowIndex, DataGridViewElementStates rowState, string errorText, DataGridViewCellStyle inheritedRowStyle, bool isFirstDisplayedRow, bool isLastVisibleRow) {
+ this.dataGridView = dataGridView;
+ this.graphics = graphics;
+ this.clipBounds = clipBounds;
+ this.rowBounds = rowBounds;
+ this.rowIndex = rowIndex;
+ this.rowState = rowState;
+ this.errorText = errorText;
+ this.inheritedRowStyle = inheritedRowStyle;
+ this.isFirstDisplayedRow = isFirstDisplayedRow;
+ this.isLastVisibleRow = isLastVisibleRow;
+ }
+
+ public Rectangle ClipBounds {
+ get { return clipBounds; }
+ set { clipBounds = value; }
+ }
+
+ public string ErrorText {
+ get { return errorText; }
+ }
+
+ public Graphics Graphics {
+ get { return graphics; }
+ }
+
+ public DataGridViewCellStyle InheritedRowStyle {
+ get { return inheritedRowStyle; }
+ }
+
+ public bool IsFirstDisplayedRow {
+ get { return isFirstDisplayedRow; }
+ }
+
+ public bool IsLastVisibleRow {
+ get { return isLastVisibleRow; }
+ }
+
+ public Rectangle RowBounds {
+ get { return rowBounds; }
+ }
+
+ public int RowIndex {
+ get { return rowIndex; }
+ }
+
+ public DataGridViewElementStates State {
+ get { return rowState; }
+ }
+
+ public void DrawFocus (Rectangle bounds, bool cellsPaintSelectionBackground) {
+ if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count) {
+ throw new InvalidOperationException("Invalid RowIndex.");
+ }
+ Color color;
+ if (cellsPaintSelectionBackground) {
+ color = dataGridView.Rows[rowIndex].InheritedStyle.SelectionBackColor;
+ }
+ else {
+ color = dataGridView.Rows[rowIndex].InheritedStyle.BackColor;
+ }
+ ///////// NOT CHECKED //////////////
+ graphics.FillRectangle(new SolidBrush(color), bounds);
+ }
+
+ public void PaintCells (Rectangle clipBounds, DataGridViewPaintParts paintParts) {
+ if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count) {
+ throw new InvalidOperationException("Invalid RowIndex.");
+ }
+ throw new NotImplementedException();
+ }
+
+ public void PaintCellsBackground (Rectangle clipBounds, bool cellsPaintSelectionBackground) {
+ if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count) {
+ throw new InvalidOperationException("Invalid RowIndex.");
+ }
+ Color color;
+ if (cellsPaintSelectionBackground) {
+ color = dataGridView.Rows[rowIndex].InheritedStyle.SelectionBackColor;
+ }
+ else {
+ color = dataGridView.Rows[rowIndex].InheritedStyle.BackColor;
+ }
+ ///////// NOT CHECKED //////////////
+ graphics.FillRectangle(new SolidBrush(color), clipBounds);
+ }
+
+ public void PaintCellsContent (Rectangle clipBounds) {
+ if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count) {
+ throw new InvalidOperationException("Invalid RowIndex.");
+ }
+ throw new NotImplementedException();
+ }
+
+ public void PaintHeader (bool paintSelectionBackground) {
+ if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count) {
+ throw new InvalidOperationException("Invalid RowIndex.");
+ }
+ Color color;
+ if (paintSelectionBackground) {
+ color = dataGridView.Rows[rowIndex].InheritedStyle.SelectionBackColor;
+ }
+ else {
+ color = dataGridView.RowHeadersDefaultCellStyle.BackColor;
+ }
+ ///////// NOT CHECKED //////////////
+ graphics.FillRectangle(new SolidBrush(color), clipBounds);
+ }
+
+ public void PaintHeader (DataGridViewPaintParts paintParts) {
+ if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count) {
+ throw new InvalidOperationException("Invalid RowIndex.");
+ }
+ throw new NotImplementedException();
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowPostPaintEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowPostPaintEventHandler.cs
new file mode 100644
index 00000000000..8b2d61d5aec
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowPostPaintEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewRowPostPaintEventHandler (object sender, DataGridViewRowPostPaintEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowPrePaintEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowPrePaintEventArgs.cs
new file mode 100644
index 00000000000..7454f08245e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowPrePaintEventArgs.cs
@@ -0,0 +1,173 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.ComponentModel;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewRowPrePaintEventArgs : HandledEventArgs {
+
+ private DataGridView dataGridView;
+ private Graphics graphics;
+ private Rectangle clipBounds;
+ private Rectangle rowBounds;
+ private int rowIndex;
+ private DataGridViewElementStates rowState;
+ private string errorText;
+ private DataGridViewCellStyle inheritedRowStyle;
+ private bool isFirstDisplayedRow;
+ private bool isLastVisibleRow;
+ private DataGridViewPaintParts paintParts;
+
+ public DataGridViewRowPrePaintEventArgs (DataGridView dataGridView, Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, int rowIndex, DataGridViewElementStates rowState, string errorText, DataGridViewCellStyle inheritedRowStyle, bool isFirstDisplayedRow, bool isLastVisibleRow) {
+ this.dataGridView = dataGridView;
+ this.graphics = graphics;
+ this.clipBounds = clipBounds;
+ this.rowBounds = rowBounds;
+ this.rowIndex = rowIndex;
+ this.rowState = rowState;
+ this.errorText = errorText;
+ this.inheritedRowStyle = inheritedRowStyle;
+ this.isFirstDisplayedRow = isFirstDisplayedRow;
+ this.isLastVisibleRow = isLastVisibleRow;
+ }
+
+ public Rectangle ClipBounds {
+ get { return clipBounds; }
+ set { clipBounds = value; }
+ }
+
+ public string ErrorText {
+ get { return errorText; }
+ }
+
+ public Graphics Graphics {
+ get { return graphics; }
+ }
+
+ public DataGridViewCellStyle InheritedRowStyle {
+ get { return inheritedRowStyle; }
+ }
+
+ public bool IsFirstDisplayedRow {
+ get { return isFirstDisplayedRow; }
+ }
+
+ public bool IsLastVisibleRow {
+ get { return isLastVisibleRow; }
+ }
+
+ public DataGridViewPaintParts PaintParts {
+ get { return paintParts; }
+ set { paintParts = value; }
+ }
+
+ public Rectangle RowBounds {
+ get { return rowBounds; }
+ }
+
+ public int RowIndex {
+ get { return rowIndex; }
+ }
+
+ public DataGridViewElementStates State {
+ get { return rowState; }
+ }
+
+ public void DrawFocus (Rectangle bounds, bool cellsPaintSelectionBackground) {
+ if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count) {
+ throw new InvalidOperationException("Invalid RowIndex.");
+ }
+ Color color;
+ if (cellsPaintSelectionBackground) {
+ color = dataGridView.Rows[rowIndex].InheritedStyle.SelectionBackColor;
+ }
+ else {
+ color = dataGridView.Rows[rowIndex].InheritedStyle.BackColor;
+ }
+ ///////// NOT CHECKED //////////////
+ graphics.FillRectangle(new SolidBrush(color), bounds);
+ }
+
+ public void PaintCells (Rectangle clipBounds, DataGridViewPaintParts paintParts) {
+ if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count) {
+ throw new InvalidOperationException("Invalid RowIndex.");
+ }
+ throw new NotImplementedException();
+ }
+
+ public void PaintCellsBackground (Rectangle clipBounds, bool cellsPaintSelectionBackground) {
+ if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count) {
+ throw new InvalidOperationException("Invalid RowIndex.");
+ }
+ Color color;
+ if (cellsPaintSelectionBackground) {
+ color = dataGridView.Rows[rowIndex].InheritedStyle.SelectionBackColor;
+ }
+ else {
+ color = dataGridView.Rows[rowIndex].InheritedStyle.BackColor;
+ }
+ ///////// NOT CHECKED //////////////
+ graphics.FillRectangle(new SolidBrush(color), clipBounds);
+ }
+
+ public void PaintCellsContent (Rectangle clipBounds) {
+ if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count) {
+ throw new InvalidOperationException("Invalid RowIndex.");
+ }
+ throw new NotImplementedException();
+ }
+
+ public void PaintHeader (bool paintSelectionBackground) {
+ if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count) {
+ throw new InvalidOperationException("Invalid RowIndex.");
+ }
+ Color color;
+ if (paintSelectionBackground) {
+ color = dataGridView.Rows[rowIndex].InheritedStyle.SelectionBackColor;
+ }
+ else {
+ color = dataGridView.RowHeadersDefaultCellStyle.BackColor;
+ }
+ ///////// NOT CHECKED //////////////
+ graphics.FillRectangle(new SolidBrush(color), clipBounds);
+ }
+
+ public void PaintHeader (DataGridViewPaintParts paintParts) {
+ if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count) {
+ throw new InvalidOperationException("Invalid RowIndex.");
+ }
+ throw new NotImplementedException();
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowPrePaintEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowPrePaintEventHandler.cs
new file mode 100644
index 00000000000..5b70ad76ebe
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowPrePaintEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewRowPrePaintEventHandler (object sender, DataGridViewRowPrePaintEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowStateChangedEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowStateChangedEventArgs.cs
new file mode 100644
index 00000000000..0c1076112a4
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowStateChangedEventArgs.cs
@@ -0,0 +1,53 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewRowStateChangedEventArgs : EventArgs {
+
+ private DataGridViewRow dataGridViewRow;
+ private DataGridViewElementStates stateChanged;
+
+ public DataGridViewRowStateChangedEventArgs (DataGridViewRow dataGridViewRow, DataGridViewElementStates stateChanged) {
+ this.dataGridViewRow = dataGridViewRow;
+ this.stateChanged = stateChanged;
+ }
+
+ public DataGridViewRow Row {
+ get { return dataGridViewRow; }
+ }
+
+ public DataGridViewElementStates StateChanged {
+ get { return stateChanged; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowStateChangedEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowStateChangedEventHandler.cs
new file mode 100644
index 00000000000..da4b1e46947
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowStateChangedEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewRowStateChangedEventHandler (object sender, DataGridViewRowStateChangedEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsAddedEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsAddedEventArgs.cs
new file mode 100644
index 00000000000..bdc620b9e22
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsAddedEventArgs.cs
@@ -0,0 +1,53 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewRowsAddedEventArgs : EventArgs {
+
+ private int rowIndex;
+ private int rowCount;
+
+ public DataGridViewRowsAddedEventArgs (int rowIndex, int rowCount) {
+ this.rowIndex = rowIndex;
+ this.rowCount = rowCount;
+ }
+
+ public int RowCount {
+ get { return rowCount; }
+ }
+
+ public int RowIndex {
+ get { return rowIndex; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsAddedEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsAddedEventHandler.cs
new file mode 100644
index 00000000000..035ec129d8b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsAddedEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewRowsAddedEventHandler (object sender, DataGridViewRowsAddedEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsDeletedEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsDeletedEventArgs.cs
new file mode 100644
index 00000000000..24aea6e21c5
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsDeletedEventArgs.cs
@@ -0,0 +1,53 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewRowsDeletedEventArgs : EventArgs {
+
+ private int rowCount;
+ private int rowIndex;
+
+ public DataGridViewRowsDeletedEventArgs (int rowIndex, int rowCount) {
+ this.rowIndex = rowIndex;
+ this.rowCount = rowCount;
+ }
+
+ public int RowCount {
+ get { return rowCount; }
+ }
+
+ public int RowIndex {
+ get { return rowIndex; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsRemovedEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsRemovedEventArgs.cs
new file mode 100644
index 00000000000..d0383c07340
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsRemovedEventArgs.cs
@@ -0,0 +1,53 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewRowsRemovedEventArgs : EventArgs {
+
+ private int rowIndex;
+ private int rowCount;
+
+ public DataGridViewRowsRemovedEventArgs (int rowIndex, int rowCount) {
+ this.rowIndex = rowIndex;
+ this.rowCount = rowCount;
+ }
+
+ public int RowCount {
+ get { return rowCount; }
+ }
+
+ public int RowIndex {
+ get { return rowIndex; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsRemovedEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsRemovedEventHandler.cs
new file mode 100644
index 00000000000..8368976ef09
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowsRemovedEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewRowsRemovedEventHandler (object sender, DataGridViewRowsRemovedEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSelectedCellCollection.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSelectedCellCollection.cs
new file mode 100644
index 00000000000..9ad2a8df63f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSelectedCellCollection.cs
@@ -0,0 +1,118 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System;
+using System.Collections;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewSelectedCellCollection : BaseCollection, IList, ICollection, IEnumerable {
+
+ public DataGridViewSelectedCellCollection () {
+ }
+
+ public bool IsFixedSize {
+ get { return base.List.IsFixedSize; }
+ }
+
+ object IList.this [int index] {
+ get { return this[index]; }
+ set { throw new NotSupportedException(); }
+ }
+
+ public DataGridViewCell this [int index] {
+ get { return (DataGridViewCell) base.List[index]; }
+ }
+
+ public int Add (object o) {
+ throw new NotSupportedException();
+ }
+
+ public void Clear () {
+ throw new NotSupportedException("Cannot clear this base.List");
+ }
+
+ public bool Contains (object o) {
+ return Contains(o as DataGridViewCell);
+ }
+
+ public bool Contains (DataGridViewCell dataGridViewCell) {
+ return base.List.Contains(dataGridViewCell);
+ }
+
+ public void CopyTo (DataGridViewCell[] array, int index) {
+ base.List.CopyTo(array, index);
+ /*
+ if (array == null) {
+ throw new ArgumentNullException("array is null");
+ }
+ if (index < 0) {
+ throw new IndexOutOfRangeException("index is out of range");
+ }
+ if (index >= arrayl.Length) {
+ throw new ArgumentException("index is equal or greater than the length of the array");
+ }
+ if ((array.Length - index) < base.List.Count) {
+ throw new ArgumentException("not enought space for the elements from index to the end");
+ }
+ */
+ }
+
+ public int IndexOf (object o) {
+ return base.List.IndexOf(o as DataGridViewCell);
+ }
+
+ public void Insert (int index, object o) {
+ Insert(index, o as DataGridViewCell);
+ }
+
+ public void Insert (int index, DataGridViewCell dataGridViewCell) {
+ throw new NotSupportedException("Can't insert to selected cell base.List");
+ }
+
+ public void Remove (object o) {
+ throw new NotSupportedException("Can't remove elements of selected cell base.List.");
+ }
+
+ public void RemoveAt (int index) {
+ throw new NotSupportedException("Can't remove elements of selected cell base.List.");
+ }
+
+ internal void InternalAdd (DataGridViewCell dataGridViewCell) {
+ base.List.Add(dataGridViewCell);
+ }
+
+ internal void InternalRemove (DataGridViewCell dataGridViewCell) {
+ base.List.Remove(dataGridViewCell);
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSelectedColumnCollection.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSelectedColumnCollection.cs
new file mode 100644
index 00000000000..2260d487388
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSelectedColumnCollection.cs
@@ -0,0 +1,104 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.Collections;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewSelectedColumnCollection : BaseCollection, IList, ICollection, IEnumerable {
+
+ public bool IsFixedSize {
+ get { return base.List.IsFixedSize; }
+ }
+
+ object IList.this [int index] {
+ get { return this[index]; }
+ set { throw new NotSupportedException("Can't insert or modify this collection."); }
+ }
+
+ public DataGridViewColumn this [int index] {
+ get { return (DataGridViewColumn) base.List[index]; }
+ }
+
+ public int Add (object o) {
+ throw new NotSupportedException("Can't add elements to this collection.");
+ }
+
+ public void Clear () {
+ throw new NotSupportedException("This collection cannot be cleared.");
+ }
+
+ public bool Contains (object o) {
+ return Contains(o as DataGridViewColumn);
+ }
+
+ public bool Contains (DataGridViewColumn dataGridViewColumn) {
+ return base.List.Contains(dataGridViewColumn);
+ }
+
+ public void CopyTo (DataGridViewColumn[] array, int index) {
+ base.List.CopyTo(array, index);
+ }
+
+ public int IndexOf (object o) {
+ return base.List.IndexOf(o);
+ }
+
+ public void Insert (int index, object o) {
+ Insert(index, o as DataGridViewColumn);
+ }
+
+ public void Insert (int index, DataGridViewColumn dataGridViewColumn) {
+ throw new NotSupportedException("Insert is not allowed.");
+ }
+
+ public void Remove (object o) {
+ throw new NotSupportedException("Can't remove elements of this collection.");
+ }
+
+ public void RemoveAt (int index) {
+ throw new NotSupportedException("Can't remove elements of this collection.");
+ }
+
+ protected override ArrayList List {
+ get { return base.List; }
+ }
+
+ internal void InternalAdd (DataGridViewColumn dataGridViewColumn) {
+ base.List.Add(dataGridViewColumn);
+ }
+
+ internal void InternalRemove (DataGridViewColumn dataGridViewColumn) {
+ base.List.Remove(dataGridViewColumn);
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSelectedRowCollection.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSelectedRowCollection.cs
new file mode 100644
index 00000000000..2a7b89eb4ee
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSelectedRowCollection.cs
@@ -0,0 +1,104 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.Collections;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewSelectedRowCollection : BaseCollection, IList, ICollection, IEnumerable {
+
+ public bool IsFixedSize {
+ get { return base.List.IsFixedSize; }
+ }
+
+ object IList.this [int index] {
+ get { return this[index]; }
+ set { throw new NotSupportedException("Can't insert or modify this collection."); }
+ }
+
+ public DataGridViewRow this [int index] {
+ get { return (DataGridViewRow) base.List[index]; }
+ }
+
+ public int Add (object o) {
+ throw new NotSupportedException("Can't add elements to this collection.");
+ }
+
+ public void Clear () {
+ throw new NotSupportedException("This collection cannot be cleared.");
+ }
+
+ public bool Contains (object o) {
+ return Contains(o as DataGridViewRow);
+ }
+
+ public bool Contains (DataGridViewRow dataGridViewRow) {
+ return base.List.Contains(dataGridViewRow);
+ }
+
+ public void CopyTo (DataGridViewRow[] array, int index) {
+ base.List.CopyTo(array, index);
+ }
+
+ public int IndexOf (object o) {
+ return base.List.IndexOf(o);
+ }
+
+ public void Insert (int index, object o) {
+ Insert(index, o as DataGridViewRow);
+ }
+
+ public void Insert (int index, DataGridViewRow dataGridViewRow) {
+ throw new NotSupportedException("Insert is not allowed.");
+ }
+
+ public void Remove (object o) {
+ throw new NotSupportedException("Can't remove elements of this collection.");
+ }
+
+ public void RemoveAt (int index) {
+ throw new NotSupportedException("Can't remove elements of this collection.");
+ }
+
+ protected override ArrayList List {
+ get { return base.List; }
+ }
+
+ internal void InternalAdd (DataGridViewRow dataGridViewRow) {
+ base.List.Add(dataGridViewRow);
+ }
+
+ internal void InternalRemove (DataGridViewRow dataGridViewRow) {
+ base.List.Remove(dataGridViewRow);
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSelectionMode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSelectionMode.cs
new file mode 100644
index 00000000000..5016dea816c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSelectionMode.cs
@@ -0,0 +1,41 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public enum DataGridViewSelectionMode {
+ CellSelect = 0,
+ FullRowSelect = 1,
+ FullColumnSelect = 2,
+ RowHeaderSelect = 3,
+ ColumnHeaderSelect = 4
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSortCompareEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSortCompareEventArgs.cs
new file mode 100644
index 00000000000..9b915574335
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSortCompareEventArgs.cs
@@ -0,0 +1,79 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewSortCompareEventArgs : HandledEventArgs {
+
+ private DataGridViewColumn dataGridViewColumn;
+ private object cellValue1;
+ private object cellValue2;
+ private int rowIndex1;
+ private int rowIndex2;
+ private int sortResult = 0;
+
+ public DataGridViewSortCompareEventArgs (DataGridViewColumn dataGridViewColumn, object cellValue1, object cellValue2, int rowIndex1, int rowIndex2) {
+ this.dataGridViewColumn = dataGridViewColumn;
+ this.cellValue1 = cellValue1;
+ this.cellValue2 = cellValue2;
+ this.rowIndex1 = rowIndex1;
+ this.rowIndex2 = rowIndex2;
+ }
+
+ public object CellValue1 {
+ get { return cellValue1; }
+ }
+
+ public object CellValue2 {
+ get { return cellValue2; }
+ }
+
+ public DataGridViewColumn Column {
+ get { return dataGridViewColumn; }
+ }
+
+ public int RowIndex1 {
+ get { return rowIndex1; }
+ }
+
+ public int RowIndex2 {
+ get { return rowIndex2; }
+ }
+
+ public int SortResult {
+ get { return sortResult; }
+ set { sortResult = value; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSortCompareEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSortCompareEventHandler.cs
new file mode 100644
index 00000000000..316a0d6b1ee
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewSortCompareEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void DataGridViewSortCompareEventHandler (object sender, DataGridViewSortCompareEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTextBoxCell.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTextBoxCell.cs
new file mode 100644
index 00000000000..7394d7f18ee
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTextBoxCell.cs
@@ -0,0 +1,176 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewTextBoxCell : DataGridViewCell {
+
+ private int maxInputLength = 32767;
+ private static DataGridViewTextBoxEditingControl editingControl;
+
+ static DataGridViewTextBoxCell () {
+ editingControl = new DataGridViewTextBoxEditingControl();
+ editingControl.Multiline = false;
+ editingControl.BorderStyle = BorderStyle.None;
+ }
+
+ public DataGridViewTextBoxCell () {
+ }
+
+ public override Type FormattedValueType {
+ get { return typeof(string); }
+ }
+
+ public virtual int MaxInputLength {
+ get { return maxInputLength; }
+ set {
+ if (value < 0) {
+ throw new ArgumentOutOfRangeException("MaxInputLength coudn't be less than 0.");
+ }
+ maxInputLength = value;
+ }
+ }
+
+ public override Type ValueType {
+ get { return typeof(string); }
+ }
+
+ public override object Clone () {
+ DataGridViewTextBoxCell result = (DataGridViewTextBoxCell) base.Clone();
+ result.maxInputLength = maxInputLength;
+ return result;
+ }
+
+ public override void DetachEditingControl () {
+ if (DataGridView == null) {
+ throw new InvalidOperationException("There is no associated DataGridView.");
+ }
+ if (DataGridView.Controls.Contains(editingControl)) {
+ DataGridView.Controls.Remove(editingControl);
+ }
+ Console.WriteLine("Detached: ({0}, {1});", RowIndex, ColumnIndex);
+ }
+
+ public override void InitializeEditingControl (int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle) {
+ if (DataGridView == null) {
+ throw new InvalidOperationException("There is no associated DataGridView.");
+ }
+ if (!DataGridView.Controls.Contains(editingControl)) {
+ DataGridView.Controls.Add(editingControl);
+ }
+ editingControl.EditingControlDataGridView = DataGridView;
+ editingControl.MaxLength = maxInputLength;
+ if (initialFormattedValue == null || (string) initialFormattedValue == "") {
+ editingControl.Text = "";
+ }
+ else {
+ editingControl.Text = (string) initialFormattedValue;
+ }
+ editingControl.ApplyCellStyleToEditingControl(dataGridViewCellStyle);
+ editingControl.PrepareEditingControlForEdit(true);
+ }
+
+ public override bool KeyEntersEditMode (KeyEventArgs e) {
+ throw new NotImplementedException();
+ }
+
+ public override void PositionEditingControl (bool setLocation, bool setSize, Rectangle cellBounds, Rectangle cellClip, DataGridViewCellStyle cellStyle, bool singleVerticalBorderAdded, bool singleHorizontalBorderAdded, bool isFirstDisplayedColumn, bool isFirstDisplayedRow) {
+ if (setSize) {
+ editingControl.Size = new Size(cellBounds.Width, cellBounds.Height + 2);
+ }
+ if (setLocation) {
+ editingControl.Location = new Point(cellBounds.X, cellBounds.Y);
+ }
+ editingControl.Invalidate();
+ }
+
+ public override string ToString () {
+ return this.GetType().Name;
+ }
+
+ protected override Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override Rectangle GetErrorIconBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override Size GetPreferredSize (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnEnter (int rowIndex, bool throughMouseClick) {
+ }
+
+ protected override void OnLeave (int rowIndex, bool throughMouseClick) {
+ }
+
+ protected override void OnMouseClick (DataGridViewCellMouseEventArgs e) {
+ }
+
+ protected override void OnMouseEnter (int rowIndex) {
+ }
+
+ protected override void OnMouseLeave (int rowIndex) {
+ }
+
+ protected override void Paint (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
+ //////////////////
+ /*
+ Size size = DataGridViewCell.MeasureTextSize(graphics, (string) formattedValue, cellStyle.Font, TextFormatFlags.Default);
+ switch (cellStyle.Alignment) {
+ case DataGridViewContentAlignment.TopLeft:
+ break;
+ }
+ //cell.SetContentBounds(cellBounds);
+ */
+ //////////////////
+ if ((cellState & DataGridViewElementStates.Selected) != 0) {
+ graphics.FillRectangle(new SolidBrush(cellStyle.SelectionBackColor), cellBounds);
+ graphics.DrawString((string) formattedValue, cellStyle.Font, new SolidBrush(cellStyle.SelectionForeColor), cellBounds, StringFormat.GenericDefault);
+ }
+ else {
+ graphics.FillRectangle(new SolidBrush(cellStyle.BackColor), cellBounds);
+ graphics.DrawString((string) formattedValue, cellStyle.Font, new SolidBrush(cellStyle.ForeColor), cellBounds, StringFormat.GenericDefault);
+ }
+ PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
+ }
+
+ protected override void OnDataGridViewChanged () {
+ editingControl.EditingControlDataGridView = DataGridView;
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTextBoxColumn.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTextBoxColumn.cs
new file mode 100644
index 00000000000..ea72209975d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTextBoxColumn.cs
@@ -0,0 +1,77 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewTextBoxColumn : DataGridViewColumn {
+
+ private int maxInputLength;
+ private DataGridViewColumnSortMode sortMode;
+
+ public DataGridViewTextBoxColumn () {
+ base.CellTemplate = new DataGridViewTextBoxCell();
+ maxInputLength = 32767;
+ sortMode = DataGridViewColumnSortMode.Automatic;
+ }
+
+ public override DataGridViewCell CellTemplate {
+ get { return base.CellTemplate; }
+ set { base.CellTemplate = value as DataGridViewTextBoxCell; }
+ }
+
+ public int MaxInputLength {
+ get { return maxInputLength; }
+ set {
+ if (value < 0) {
+ throw new ArgumentOutOfRangeException("Value is less than 0.");
+ }
+ maxInputLength = value;
+ }
+ }
+
+ public new DataGridViewColumnSortMode SortMode {
+ get { return sortMode; }
+ set {
+ if (DataGridView != null && DataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect && value != DataGridViewColumnSortMode.NotSortable) {
+ throw new InvalidOperationException("Value conflicts with DataGridView.SelectionMode.");
+ }
+ sortMode = value;
+ }
+ }
+
+ public override string ToString () {
+ return GetType().Name;
+ }
+
+
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTextBoxEditingControl.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTextBoxEditingControl.cs
new file mode 100644
index 00000000000..48de9d9cb0d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTextBoxEditingControl.cs
@@ -0,0 +1,117 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+
+ [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
+ [ComVisibleAttribute(true)]
+ public class DataGridViewTextBoxEditingControl : TextBox, IDataGridViewEditingControl {
+
+ private DataGridView editingControlDataGridView;
+ private int rowIndex;
+ private bool editingControlValueChanged;
+ private Cursor editingPanelCursor;
+ private bool repositionEditingControlOnValueChange;
+
+ public DataGridViewTextBoxEditingControl () {
+ }
+
+ public DataGridView EditingControlDataGridView {
+ get { return editingControlDataGridView; }
+ set { editingControlDataGridView = value; }
+ }
+
+ public object EditingControlFormattedValue {
+ get { return base.Text; }
+ set { base.Text = (string) value; }
+ }
+
+ public int EditingControlRowIndex {
+ get { return rowIndex; }
+ set { rowIndex = value; }
+ }
+
+ public bool EditingControlValueChanged {
+ get { return editingControlValueChanged; }
+ set { editingControlValueChanged = value; }
+ }
+
+ public Cursor EditingPanelCursor {
+ get { return editingPanelCursor; }
+ }
+
+ public bool RepositionEditingControlOnValueChange {
+ get { return repositionEditingControlOnValueChange; }
+ }
+
+ public void ApplyCellStyleToEditingControl (DataGridViewCellStyle dataGridViewCellStyle) {
+ Font = dataGridViewCellStyle.Font;
+ BackColor = dataGridViewCellStyle.BackColor;
+ ForeColor = dataGridViewCellStyle.ForeColor;
+ }
+
+ public bool EditingControlWantsInputKey (Keys keyData, bool dataGridViewWantsInputKey) {
+ return true;
+ }
+
+ public object GetEditingControlFormattedValue (DataGridViewDataErrorContexts context) {
+ return EditingControlFormattedValue;
+ }
+
+ public void PrepareEditingControlForEdit (bool selectAll) {
+ Focus();
+ if (selectAll) {
+ SelectAll();
+ }
+ editingControlValueChanged = false;
+ }
+
+ protected override void OnMouseWheel (MouseEventArgs e) {
+ base.OnMouseWheel(e);
+ }
+
+ protected override void OnTextChanged (EventArgs e) {
+ base.OnTextChanged(e);
+ editingControlValueChanged = true;
+ Console.WriteLine("OnTextChanged: {0};", Text);
+ if (editingControlDataGridView != null) {
+ editingControlDataGridView.CurrentCell.Value = Text;
+ }
+ }
+
+ protected override bool ProcessKeyEventArgs (ref Message m) {
+ return base.ProcessKeyEventArgs(ref m);
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTopLeftHeaderCell.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTopLeftHeaderCell.cs
new file mode 100644
index 00000000000..15319056b3a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTopLeftHeaderCell.cs
@@ -0,0 +1,100 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.Drawing;
+
+namespace System.Windows.Forms {
+
+ public class DataGridViewTopLeftHeaderCell : DataGridViewColumnHeaderCell {
+
+ public DataGridViewTopLeftHeaderCell () {
+ }
+
+ public override string ToString () {
+ return GetType().Name;
+ }
+
+ protected override AccessibleObject CreateAccessibilityInstance () {
+ return new DataGridViewTopLeftHeaderCellAccessibleObject(this);
+ }
+
+ protected override Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override Rectangle GetErrorIconBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
+ throw new NotImplementedException();
+ }
+
+ protected override Size GetPreferredSize (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) {
+ throw new NotImplementedException();
+ }
+
+ protected override void Paint (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
+ throw new NotImplementedException();
+ }
+
+ protected override void PaintBorder (Graphics graphics, Rectangle clipBounds, Rectangle bounds, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle) {
+ throw new NotImplementedException();
+ }
+
+ protected class DataGridViewTopLeftHeaderCellAccessibleObject : DataGridViewColumnHeaderCellAccessibleObject {
+
+ public DataGridViewTopLeftHeaderCellAccessibleObject (DataGridViewTopLeftHeaderCell owner) : base (owner) {
+ }
+
+ public override Rectangle Bounds {
+ get { throw new NotImplementedException(); }
+ }
+
+ public override string DefaultAction {
+ get {
+ if (Owner.DataGridView != null && Owner.DataGridView.MultiSelect) {
+ return "Press to Select All";
+ }
+ return "";
+ }
+ }
+
+ public override void DoDefaultAction () {
+ if (Owner.DataGridView != null) {
+ Owner.DataGridView.SelectAll();
+ }
+ }
+
+ public override AccessibleObject Navigate (AccessibleNavigation navigationDirection) {
+ throw new NotImplementedException();
+ }
+
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTriState.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTriState.cs
new file mode 100644
index 00000000000..1513ab03d9e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewTriState.cs
@@ -0,0 +1,39 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public enum DataGridViewTriState {
+ NotSet = 0,
+ True = 1,
+ False = 2
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataObject.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataObject.cs
new file mode 100644
index 00000000000..3a011d6fc3e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataObject.cs
@@ -0,0 +1,288 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+using System;
+using System.Collections;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ClassInterface(ClassInterfaceType.None)]
+ public class DataObject : IDataObject {
+ #region DataObject.Entry Class
+ private class Entry {
+ #region Local Variables
+ private string type;
+ private object data;
+ private bool autoconvert;
+ internal Entry next;
+ #endregion // Local Variables
+
+ #region Constructors
+ internal Entry(string type, object data, bool autoconvert) {
+ this.type = type;
+ this.data = data;
+ this.autoconvert = autoconvert;
+ }
+ #endregion // Constructors
+
+ #region Properties
+ public object Data {
+ get {
+ return data;
+ }
+
+ set {
+ data = value;
+ }
+ }
+ #endregion // Properties
+
+ #region Methods
+ public static int Count(Entry entries) {
+ int result;
+
+ result = 0;
+
+ while (entries != null) {
+ result++;
+ entries = entries.next;
+ }
+
+ return result;
+ }
+
+ public static Entry Find(Entry entries, string type) {
+ while (entries != null) {
+ if (entries.type.Equals(type)) {
+ return entries;
+ }
+ entries = entries.next;
+ }
+
+ return null;
+ }
+
+ public static Entry FindConvertible(Entry entries, string type) {
+ Entry e;
+
+ e = Find(entries, type);
+ if (e != null) {
+ return e;
+ }
+
+ e = entries;
+ while (e != null) {
+ if (type == DataFormats.Text) {
+ if (e.type == DataFormats.UnicodeText) {
+ return e;
+ }
+ } else if (type == DataFormats.UnicodeText) {
+ if (e.type == DataFormats.Text) {
+ return e;
+ }
+ } else if (type == DataFormats.StringFormat) {
+ if (e.type == DataFormats.Text) {
+ return e;
+ } else if (e.type == DataFormats.UnicodeText) {
+ return e;
+ }
+ }
+ e = e.next;
+ }
+
+ return null;
+ }
+
+ public static string[] Entries(Entry entries, bool convertible) {
+ Entry e;
+ ArrayList list;
+ string[] result;
+
+ // Initially store into something that we can grow easily
+ list = new ArrayList(Entry.Count(entries));
+ e = entries;
+
+ while (e != null) {
+ list.Add(e.type);
+ e = e.next;
+ }
+
+ if (convertible) {
+ // Add the convertibles
+ if ((Entry.Find(entries, DataFormats.Text) != null) && (Entry.Find(entries, DataFormats.UnicodeText) == null)) {
+ list.Add(DataFormats.UnicodeText);
+ }
+
+ if ((Entry.Find(entries, DataFormats.Text) == null) && (Entry.Find(entries, DataFormats.UnicodeText) != null)) {
+ list.Add(DataFormats.Text);
+ }
+
+ if (((Entry.Find(entries, DataFormats.Text) != null) || (Entry.Find(entries, DataFormats.UnicodeText) != null)) && (Entry.Find(entries, DataFormats.StringFormat) == null)) {
+ list.Add(DataFormats.StringFormat);
+ }
+ }
+
+ // Copy the results into a string array
+ result = new string[list.Count];
+ for (int i = 0; i < list.Count; i++) {
+ result[i] = (string)list[i];
+ }
+
+ return result;
+ }
+ #endregion // Methods
+ }
+ #endregion // DataObject.Entry class
+
+ #region Local Variables
+ private Entry entries;
+ #endregion // Local Variables
+
+ #region Public Constructors
+ public DataObject() {
+ entries = null;
+ }
+
+ public DataObject(object data) {
+ SetData(data);
+ }
+
+ public DataObject(string format, object data) {
+ SetData(format, data);
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public virtual object GetData(string format) {
+ return GetData(format, true);
+ }
+
+ public virtual object GetData(string format, bool autoConvert) {
+ Entry e;
+ if (autoConvert) {
+ e = Entry.FindConvertible(entries, format);
+ } else {
+ e = Entry.Find(entries, format);
+ }
+ if (e == null)
+ return null;
+ return e.Data;
+ }
+
+ public virtual object GetData(Type format) {
+ return GetData(format.FullName, true);
+ }
+
+ public virtual bool GetDataPresent(string format) {
+ return GetDataPresent(format, true);
+ }
+
+ public virtual bool GetDataPresent(string format, bool autoConvert) {
+ if (autoConvert) {
+ return Entry.FindConvertible(entries, format) != null;
+ } else {
+ return Entry.Find(entries, format) != null;
+ }
+ }
+
+ public virtual bool GetDataPresent(Type format) {
+ return GetDataPresent(format.FullName, true);
+ }
+
+ public virtual string[] GetFormats() {
+ return GetFormats(true);
+ }
+
+ public virtual string[] GetFormats(bool autoConvert) {
+ return Entry.Entries(entries, autoConvert);
+ }
+
+ public virtual void SetData(object data) {
+ SetData(data.GetType(), data);
+ }
+
+ public virtual void SetData(string format, bool autoConvert, object data) {
+ Entry entry;
+ Entry e;
+
+ entry = Entry.Find(entries, format);
+
+ if (entry == null) {
+ entry = new DataObject.Entry(format, data, autoConvert);
+ } else {
+ entry.Data = data;
+ return;
+ }
+
+ lock (this) {
+ if (entries == null) {
+ entries = entry;
+ } else {
+ // Insert into the list of known/defined formats
+ e = entries;
+
+ while (e.next != null) {
+ e = e.next;
+ }
+ e.next = entry;
+ }
+ }
+ }
+
+ public virtual void SetData(string format, object data) {
+ SetData(format, true, data);
+ }
+
+ public virtual void SetData(Type format, object data) {
+ SetData(EnsureFormat(format), true, data);
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ #endregion // Public Instance Methods
+
+ #region Private Methods
+ internal string EnsureFormat(string name) {
+ DataFormats.Format f;
+
+ f = DataFormats.Format.Find(name);
+ if (f == null) {
+ // Register the format
+ f = DataFormats.Format.Add(name);
+ }
+
+ return f.Name;
+ }
+
+ internal string EnsureFormat(Type type) {
+ return EnsureFormat(type.FullName);
+ }
+
+ #endregion // Private Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateBoldEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateBoldEventArgs.cs
new file mode 100644
index 00000000000..755c21340b8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateBoldEventArgs.cs
@@ -0,0 +1,69 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public class DateBoldEventArgs : EventArgs {
+ #region Local Variables
+ private int size;
+ private DateTime start;
+ private int[] days_to_bold;
+ #endregion // Local Variables
+
+ #region Internal Constructor
+ DateBoldEventArgs(DateTime start, int size, int[] daysToBold) {
+ this.start = start;
+ this.size = size;
+ this.days_to_bold = daysToBold;
+ }
+ #endregion
+
+ #region Public Instance Properties
+ public int[] DaysToBold {
+ get {
+ return days_to_bold;
+ }
+
+ set {
+ days_to_bold = value;
+ }
+ }
+
+ public int Size {
+ get {
+ return size;
+ }
+ }
+
+ public DateTime StartDate {
+ get {
+ return start;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateBoldEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateBoldEventHandler.cs
new file mode 100644
index 00000000000..3d1e5d54e59
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateBoldEventHandler.cs
@@ -0,0 +1,31 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void DateBoldEventHandler (object sender, DateBoldEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateRangeEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateRangeEventArgs.cs
new file mode 100644
index 00000000000..066d1dd4f4c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateRangeEventArgs.cs
@@ -0,0 +1,67 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// John BouAntoun jba-mono@optusnet.com.au
+//
+
+using System;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+ public class DateRangeEventArgs : EventArgs {
+ #region local members
+
+ DateTime end;
+ DateTime start;
+
+ #endregion // local members
+
+ #region public constructors
+
+ // constructor that receives two dates, uses the lower of the two as start
+ public DateRangeEventArgs (DateTime start, DateTime end) {
+ this.start = start;
+ this.end = end;
+ }
+
+ #endregion // public constructors
+
+ #region public properties
+
+ // end date of this range
+ public DateTime End {
+ get {
+ return end;
+ }
+ }
+
+ // start date of this range
+ public DateTime Start {
+ get {
+ return start;
+ }
+ }
+
+ #endregion // public properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateRangeEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateRangeEventHandler.cs
new file mode 100644
index 00000000000..b217cd302e7
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateRangeEventHandler.cs
@@ -0,0 +1,31 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// John BouAntoun jba-mono@optusnet.com.au
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ // event handler for when a daterange event is fired (datechanged or dateselected)
+ public delegate void DateRangeEventHandler(object sender, DateRangeEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateTimePicker.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateTimePicker.cs
new file mode 100644
index 00000000000..8cf35bcfb78
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateTimePicker.cs
@@ -0,0 +1,829 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// John BouAntoun jba-mono@optusnet.com.au
+//
+// TODO:
+// - implement custom formatting of the date time value
+// - implement any behaviour associate with UseUpDown (painting, key and mouse)
+// - implement key processing and responding
+// - fix MonthCalendar Popdown on form move
+// - wire in all events from monthcalendar
+
+
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+
+namespace System.Windows.Forms {
+ [DefaultEvent("ValueChanged")]
+ [DefaultProperty("Value")]
+ [Designer("System.Windows.Forms.Design.DateTimePickerDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ public class DateTimePicker : Control {
+
+ #region Public variables
+
+ // this class has to have the specified hour, minute and second, as it says in msdn
+ public static readonly DateTime MaxDateTime = new DateTime (9998, 12, 31, 23, 59, 59);
+ public static readonly DateTime MinDateTime = new DateTime (1753, 1, 1);
+
+ #endregion // Public variables
+
+ #region Local variables
+
+ protected static readonly Color DefaultMonthBackColor = ThemeEngine.Current.ColorWindow;
+ protected static readonly Color DefaultTitleBackColor = ThemeEngine.Current.ColorActiveCaption;
+ protected static readonly Color DefaultTitleForeColor = ThemeEngine.Current.ColorActiveCaptionText;
+ protected static readonly Color DefaultTrailingForeColor = Color.Gray;
+
+ internal MonthCalendar month_calendar;
+ bool is_checked;
+ string custom_format;
+ LeftRightAlignment drop_down_align;
+ DateTimePickerFormat format;
+ DateTime max_date;
+ DateTime min_date;
+ bool show_check_box;
+ bool show_up_down;
+ string text;
+ DateTime date_value;
+
+ // variables used for drawing and such
+ internal int up_down_width;
+ internal bool is_drop_down_visible;
+
+ #endregion // Local variables
+
+ #region DateTimePickerAccessibleObject Subclass
+ [ComVisible(true)]
+ public class DateTimePickerAccessibleObject : ControlAccessibleObject {
+ #region DateTimePickerAccessibleObject Local Variables
+ private DateTimePicker owner;
+ #endregion // DateTimePickerAccessibleObject Local Variables
+
+ #region DateTimePickerAccessibleObject Constructors
+ public DateTimePickerAccessibleObject(DateTimePicker owner) : base(owner) {
+ this.owner = owner;
+ }
+ #endregion // DateTimePickerAccessibleObject Constructors
+
+ #region DateTimePickerAccessibleObject Properties
+ public override AccessibleStates State {
+ get {
+ AccessibleStates retval;
+
+ retval = AccessibleStates.Default;
+
+ if (owner.Checked) {
+ retval |= AccessibleStates.Checked;
+ }
+
+ return retval;
+ }
+ }
+
+ public override string Value {
+ get {
+ return owner.text;
+ }
+ }
+ #endregion // DateTimePickerAccessibleObject Properties
+ }
+ #endregion // DateTimePickerAccessibleObject Sub-class
+
+ #region public constructors
+
+ // only public constructor
+ public DateTimePicker () {
+
+ // initialise the month calendar
+ month_calendar = new MonthCalendar (this);
+ month_calendar.CalendarDimensions = new Size (1, 1);
+ month_calendar.MaxSelectionCount = 1;
+ month_calendar.ForeColor = Control.DefaultForeColor;
+ month_calendar.BackColor = DefaultMonthBackColor;
+ month_calendar.TitleBackColor = DefaultTitleBackColor;
+ month_calendar.TitleForeColor = DefaultTitleForeColor;
+ month_calendar.TrailingForeColor = DefaultTrailingForeColor;
+ month_calendar.Visible = false;
+
+
+ // initialise other variables
+ is_checked = false;
+ custom_format = string.Empty;
+ drop_down_align = LeftRightAlignment.Left;
+ format = DateTimePickerFormat.Long;
+ max_date = MaxDateTime;
+ min_date = MinDateTime;
+ show_check_box = false;
+ show_up_down = false;
+ date_value = DateTime.Now;
+ text = FormatValue ();
+
+ up_down_width = 10;
+ is_drop_down_visible = false;
+
+ month_calendar.DateSelected += new DateRangeEventHandler (MonthCalendarDateSelectedHandler);
+ KeyPress += new KeyPressEventHandler (KeyPressHandler);
+// LostFocus += new EventHandler (LostFocusHandler);
+ MouseDown += new MouseEventHandler (MouseDownHandler);
+ Paint += new PaintEventHandler (PaintHandler);
+
+ SetStyle (ControlStyles.UserPaint | ControlStyles.StandardClick, false);
+ SetStyle (ControlStyles.FixedHeight, true);
+ }
+
+ #endregion
+
+ #region public properties
+
+ // no reason why this is overridden
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Color BackColor {
+ set {
+ base.BackColor = value;
+ }
+ get {
+ return base.BackColor;
+ }
+ }
+
+ // no reason why this is overridden
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Image BackgroundImage {
+ set {
+ base.BackgroundImage = value;
+ }
+ get {
+ return base.BackgroundImage;
+ }
+ }
+
+ [AmbientValue(null)]
+ [Localizable(true)]
+ public Font CalendarFont {
+ set {
+ month_calendar.Font = value;
+ }
+ get {
+ return month_calendar.Font;
+ }
+ }
+
+ public Color CalendarForeColor {
+ set {
+ month_calendar.ForeColor = value;
+ }
+ get {
+ return month_calendar.ForeColor;
+ }
+ }
+
+ public Color CalendarMonthBackground {
+ set {
+ month_calendar.BackColor = value;
+ }
+ get {
+ return month_calendar.BackColor;
+ }
+ }
+
+ public Color CalendarTitleBackColor {
+ set {
+ month_calendar.TitleBackColor = value;
+ }
+ get {
+ return month_calendar.TitleBackColor;
+ }
+ }
+
+ public Color CalendarTitleForeColor {
+ set {
+ month_calendar.TitleForeColor = value;
+ }
+ get {
+ return month_calendar.TitleForeColor;
+ }
+ }
+
+ public Color CalendarTrailingForeColor {
+ set {
+ month_calendar.TrailingForeColor = value;
+ }
+ get {
+ return month_calendar.TrailingForeColor;
+ }
+ }
+
+ // when checked the value is grayed out
+ [Bindable(true)]
+ [DefaultValue(true)]
+ public bool Checked {
+ set {
+ if (is_checked != value) {
+ is_checked = value;
+ // invalidate the value inside this control
+ this.Invalidate (date_area_rect);
+ }
+ }
+ get {
+ return is_checked;
+ }
+ }
+
+ // the custom format string to format this control with
+ [DefaultValue(null)]
+ [RefreshProperties(RefreshProperties.Repaint)]
+ public string CustomFormat {
+ set {
+ if (custom_format != value) {
+ custom_format = value;
+ if (this.Format == DateTimePickerFormat.Custom) {
+ // TODO: change the text value of the dtp
+ }
+ }
+ }
+ get {
+ return custom_format;
+ }
+ }
+
+ // which side the drop down is to be aligned on
+ [DefaultValue(LeftRightAlignment.Left)]
+ [Localizable(true)]
+ public LeftRightAlignment DropDownAlign {
+ set {
+ if (drop_down_align != value) {
+ drop_down_align = value;
+ }
+ }
+ get {
+ return drop_down_align;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Color ForeColor {
+ set {
+ base.ForeColor = value;
+ }
+ get {
+ return base.ForeColor;
+ }
+ }
+
+ // the format of the date time picker text, default is long
+ [RefreshProperties(RefreshProperties.Repaint)]
+ public DateTimePickerFormat Format {
+ set {
+ if (format != value) {
+ format = value;
+ this.OnFormatChanged (EventArgs.Empty);
+ // invalidate the value inside this control
+ this.Invalidate (date_area_rect);
+ }
+ }
+ get {
+ return format;
+ }
+ }
+
+ public DateTime MaxDate {
+ set {
+ if (value < min_date) {
+ throw new ArgumentException ();
+ }
+ if (value > MaxDateTime) {
+ throw new SystemException ();
+ }
+ if (max_date != value) {
+ max_date = value;
+
+ // TODO: verify this is correct behaviour when value > max date
+ if (Value > max_date) {
+ Value = max_date;
+ // invalidate the value inside this control
+ this.Invalidate (date_area_rect);
+ }
+ }
+ }
+ get {
+ return max_date;
+ }
+ }
+
+ public DateTime MinDate {
+ set {
+ if (value < min_date) {
+ throw new ArgumentException ();
+ }
+ if (value < MinDateTime) {
+ throw new SystemException ();
+ }
+ if (min_date != value) {
+ min_date = value;
+
+ // TODO: verify this is correct behaviour when value > max date
+ if (Value < min_date) {
+ Value = min_date;
+ // invalidate the value inside this control
+ this.Invalidate (date_area_rect);
+ }
+ }
+ }
+ get {
+ return min_date;
+ }
+ }
+
+ // the prefered height to draw this control using current font
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int PreferredHeight {
+ get {
+ return this.Font.Height + 7;
+ }
+ }
+
+ // whether or not the check box is shown
+ [DefaultValue(false)]
+ public bool ShowCheckBox {
+ set {
+ if (show_check_box != value) {
+ show_check_box = value;
+ // invalidate the value inside this control
+ this.Invalidate (date_area_rect);
+ }
+ }
+ get {
+ return show_check_box;
+ }
+ }
+
+ // if true show the updown control, else popup the monthcalendar
+ [DefaultValue(false)]
+ public bool ShowUpDown {
+ set {
+ if (show_up_down != value) {
+ show_up_down = value;
+ // need to invalidate the whole control
+ this.Invalidate ();
+ }
+ }
+ get {
+ return show_up_down;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public override string Text {
+ set {
+ // TODO: if the format is a custom format we need to do a custom parse here
+ DateTime parsed_value = DateTime.Parse (value);
+ if (date_value != parsed_value) {
+ Value = parsed_value;
+ }
+ text = FormatValue ();
+ }
+ get {
+ return text;
+ }
+ }
+
+ [Bindable(true)]
+ [RefreshProperties(RefreshProperties.All)]
+ public DateTime Value {
+ set {
+ if (date_value != value) {
+ date_value = value;
+ text = FormatValue ();
+ this.OnValueChanged (EventArgs.Empty);
+ this.Invalidate (date_area_rect);
+ }
+ }
+ get {
+ return date_value;
+ }
+ }
+
+ #endregion // public properties
+
+ #region public methods
+
+ // just return the text value
+ public override string ToString () {
+ return this.Text;
+ }
+
+ #endregion // public methods
+
+ #region public events
+
+ // raised when the monthcalendar is closed
+ public event EventHandler CloseUp;
+
+ // raised when the monthcalendar is opened
+ public event EventHandler DropDown;
+
+ // raised when the format of the value is changed
+ public event EventHandler FormatChanged;
+
+ // raised when the date Value is changed
+ public event EventHandler ValueChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler BackColorChanged {
+ add {
+ base.BackColorChanged += value;
+ }
+
+ remove {
+ base.BackColorChanged -= value;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler BackgroundImageChanged {
+ add {
+ base.BackgroundImageChanged += value;
+ }
+
+ remove {
+ base.BackgroundImageChanged -= value;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler ForeColorChanged {
+ add {
+ base.ForeColorChanged += value;
+ }
+
+ remove {
+ base.ForeColorChanged -= value;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event PaintEventHandler Paint {
+ add {
+ base.Paint += value;
+ }
+
+ remove {
+ base.Paint -= value;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public new event EventHandler TextChanged {
+ add {
+ base.TextChanged += value;
+ }
+
+ remove {
+ base.TextChanged -= value;
+ }
+ }
+ #endregion // public events
+
+ #region protected properties
+
+ // not sure why we're overriding this one
+ protected override CreateParams CreateParams {
+ get {
+ return base.CreateParams;
+ }
+ }
+
+ // specify the default size for this control
+ protected override Size DefaultSize {
+ get {
+ // todo actually measure this properly
+ return new Size (200, PreferredHeight);
+ }
+ }
+
+ #endregion // protected properties
+
+ #region protected methods
+
+ // not sure why we're overriding this one
+ protected override AccessibleObject CreateAccessibilityInstance () {
+ return base.CreateAccessibilityInstance ();
+ }
+
+ // not sure why we're overriding this one
+ protected override void CreateHandle () {
+ base.CreateHandle ();
+ }
+
+ // not sure why we're overriding this one
+ protected override void DestroyHandle () {
+ base.DestroyHandle ();
+ }
+
+ // not sure why we're overriding this one
+ protected override void Dispose (bool disposing) {
+ base.Dispose (disposing);
+ }
+
+ // find out if this key is an input key for us, depends on which date part is focused
+ protected override bool IsInputKey (Keys keyData) {
+ // TODO: fix this implementation of IsInputKey
+ return false;
+ }
+
+ // raises the CloseUp event
+ protected virtual void OnCloseUp (EventArgs eventargs) {
+ if (this.CloseUp != null) {
+ this.CloseUp (this, eventargs);
+ }
+ }
+
+ // raise the drop down event
+ protected virtual void OnDropDown (EventArgs eventargs) {
+ if (this.DropDown != null) {
+ this.DropDown (this, eventargs);
+ }
+ }
+
+ protected override void OnFontChanged(EventArgs e) {
+ // FIXME - do we need to update/invalidate/recalc our stuff?
+ base.OnFontChanged (e);
+ }
+
+ // raises the format changed event
+ protected virtual void OnFormatChanged (EventArgs e) {
+ if (this.FormatChanged != null) {
+ this.FormatChanged (this, e);
+ }
+ }
+
+ // not sure why we're overriding this one
+ protected override void OnSystemColorsChanged (EventArgs e) {
+ base.OnSystemColorsChanged (e);
+ }
+
+ // raise the ValueChanged event
+ protected virtual void OnValueChanged (EventArgs eventargs) {
+ if (this.ValueChanged != null) {
+ this.ValueChanged (this, eventargs);
+ }
+ }
+
+ // overridden to set the bounds of this control properly
+ protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
+ // TODO: ensure I implemented the bounds core setting properly.
+ if ((specified & BoundsSpecified.Height) == BoundsSpecified.Height ||
+ (specified & BoundsSpecified.Size) == BoundsSpecified.Size) {
+ base.SetBoundsCore (x, y, width, DefaultSize.Height, specified);
+ } else {
+ base.SetBoundsCore (x, y, width, height, specified);
+ }
+
+ // need to set the rectangles for all the support internal rects
+ // this is done here as a optimisation since this is an array of rects
+ if ((specified & BoundsSpecified.X) == BoundsSpecified.X ||
+ (specified & BoundsSpecified.Y) == BoundsSpecified.Y) {
+ // TODO set up all the datepart rects
+ }
+ }
+
+ // not sure why we're overriding this
+ protected override void WndProc (ref Message m) {
+ base.WndProc (ref m);
+ }
+
+ #endregion // protected methods
+
+ #region internal / private properties
+
+ // this is the region that the date and the check box is drawn on
+ internal Rectangle date_area_rect {
+ get {
+ Rectangle rect = this.ClientRectangle;
+ if (ShowUpDown) {
+ // set the space to the left of the up/down button
+ if (rect.Width > (up_down_width + 4)) {
+ rect.Width -= (up_down_width + 4);
+ } else {
+ rect.Width = 0;
+ }
+ } else {
+ // set the space to the left of the up/down button
+ // TODO make this use up down button
+ if (rect.Width > (SystemInformation.VerticalScrollBarWidth + 4)) {
+ rect.Width -= SystemInformation.VerticalScrollBarWidth;
+ } else {
+ rect.Width = 0;
+ }
+ }
+
+ rect.Inflate (-2, -2);
+ return rect;
+ }
+ }
+
+ // the rectangle for the drop down arrow
+ internal Rectangle drop_down_arrow_rect {
+ get {
+ Rectangle rect = this.ClientRectangle;
+ rect.X = rect.Right - SystemInformation.VerticalScrollBarWidth - 2;
+ if (rect.Width > (SystemInformation.VerticalScrollBarWidth + 2)) {
+ rect.Width = SystemInformation.VerticalScrollBarWidth;
+ } else {
+ rect.Width = Math.Max (rect.Width - 2, 0);
+ }
+
+ rect.Inflate (0, -2);
+ return rect;
+ }
+ }
+
+ // the part of the date that is currently hilighted
+ internal Rectangle hilight_date_area {
+ get {
+ // TODO: put hilighted part calculation in here
+ return Rectangle.Empty;
+ }
+ }
+
+ #endregion
+
+ #region internal / private methods
+
+ private Point CalculateDropDownLocation (Rectangle parent_control_rect, Size child_size, bool align_left)
+ {
+ // default bottom left
+ Point location = new Point(parent_control_rect.Left + 5, parent_control_rect.Bottom);
+ // now adjust the alignment
+ if (!align_left) {
+ location.X = parent_control_rect.Right - child_size.Width;
+ }
+
+ Point screen_location = PointToScreen (location);
+ Rectangle working_area = Screen.FromControl(this).WorkingArea;
+ // now adjust if off the right side of the screen
+ if (screen_location.X < working_area.X) {
+ screen_location.X = working_area.X;
+ }
+ // now adjust if it should be displayed above control
+ if (screen_location.Y + child_size.Height > working_area.Bottom) {
+ screen_location.Y -= (parent_control_rect.Height + child_size.Height);
+ }
+ return screen_location;
+ }
+
+ // actually draw this control
+ internal void Draw (Rectangle clip_rect, Graphics dc)
+ {
+ ThemeEngine.Current.DrawDateTimePicker (dc, clip_rect, this);
+ }
+
+ // drop the calendar down
+ internal void DropDownMonthCalendar ()
+ {
+ // ensure the right date is set for the month_calendar
+ month_calendar.SetDate (this.date_value);
+ // get a rectangle that has the dimensions of the text area,
+ // but the height of the dtp control.
+ Rectangle align_area = this.date_area_rect;
+ align_area.Y = this.ClientRectangle.Y;
+ align_area.Height = this.ClientRectangle.Height;
+
+ // establish the month calendar's location
+ month_calendar.Location = CalculateDropDownLocation (
+ align_area,
+ month_calendar.Size,
+ (this.DropDownAlign == LeftRightAlignment.Left));
+ month_calendar.Show ();
+ month_calendar.Focus ();
+ month_calendar.Capture = true;
+
+ // fire any registered events
+ if (this.DropDown != null) {
+ this.DropDown (this, EventArgs.Empty);
+ }
+ }
+
+ // hide the month calendar
+ internal void HideMonthCalendar ()
+ {
+ this.is_drop_down_visible = false;
+ Invalidate (drop_down_arrow_rect);
+ month_calendar.Capture = false;
+ if (month_calendar.Visible) {
+ month_calendar.Hide ();
+ }
+ }
+
+ // raised by any key down events
+ private void KeyPressHandler (object sender, KeyPressEventArgs e) {
+ switch (e.KeyChar) {
+ default:
+ break;
+ }
+ e.Handled = true;
+ }
+
+// // if we lose focus and the drop down is up, then close it
+// private void LostFocusHandler (object sender, EventArgs e)
+// {
+// if (is_drop_down_visible && !month_calendar.Focused) {
+// this.HideMonthCalendar ();
+// }
+// }
+
+ // fired when a user clicks on the month calendar to select a date
+ private void MonthCalendarDateSelectedHandler (object sender, DateRangeEventArgs e)
+ {
+ this.Value = e.Start.Date.Add (this.Value.TimeOfDay);
+ this.HideMonthCalendar ();
+ this.Focus ();
+ }
+
+ // to check if the mouse has come down on this control
+ private void MouseDownHandler (object sender, MouseEventArgs e)
+ {
+ /* Click On button*/
+ if (ShowUpDown) {
+ // TODO: Process clicking for UPDown
+ } else {
+ if (is_drop_down_visible == false && drop_down_arrow_rect.Contains (e.X, e.Y)) {
+ is_drop_down_visible = true;
+ Invalidate (drop_down_arrow_rect);
+ DropDownMonthCalendar ();
+ } else {
+ // mouse down on this control anywhere else collapses it
+ if (is_drop_down_visible) {
+ HideMonthCalendar ();
+ }
+ }
+ }
+ }
+
+
+ // paint this control now
+ private void PaintHandler (object sender, PaintEventArgs pe) {
+ if (Width <= 0 || Height <= 0 || Visible == false)
+ return;
+
+ Draw (pe.ClipRectangle, pe.Graphics);
+ }
+
+ private string FormatValue () {
+ string ret_value = string.Empty;
+ switch (format) {
+ case DateTimePickerFormat.Custom:
+ // TODO implement custom text formatting
+ ret_value = date_value.ToString ();
+ break;
+ case DateTimePickerFormat.Short:
+ ret_value = date_value.ToShortDateString ();
+ break;
+ case DateTimePickerFormat.Time:
+ ret_value = date_value.ToLongTimeString ();
+ break;
+ default:
+ ret_value = date_value.ToLongDateString ();
+ break;
+ }
+ return ret_value;
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateTimePickerFormat.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateTimePickerFormat.cs
new file mode 100644
index 00000000000..9b284d7498a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateTimePickerFormat.cs
@@ -0,0 +1,33 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// John BouAntoun jba-mono@optusnet.com.au
+//
+
+namespace System.Windows.Forms {
+ public enum DateTimePickerFormat {
+ Custom = 8,
+ Long = 1,
+ Short = 2,
+ Time = 4
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Day.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Day.cs
new file mode 100644
index 00000000000..baebc9be345
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Day.cs
@@ -0,0 +1,39 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// John BouAntoun jba-mono@optusnet.com.au
+//
+
+namespace System.Windows.Forms {
+ // used mainly by monthcalendar
+ public enum Day {
+ Monday,
+ Tuesday,
+ Wednesday,
+ Thursday,
+ Friday,
+ Saturday,
+ Sunday,
+ Default
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DialogResult.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DialogResult.cs
new file mode 100644
index 00000000000..a956b43b857
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DialogResult.cs
@@ -0,0 +1,46 @@
+//
+// System.Windows.Forms.DialogResult.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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
+//
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+
+ [ComVisible(true)]
+ public enum DialogResult
+ {
+ None = 0,
+ OK = 1,
+ Cancel = 2,
+ Abort = 3,
+ Retry = 4,
+ Ignore = 5,
+ Yes = 6,
+ No = 7
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DockStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DockStyle.cs
new file mode 100644
index 00000000000..2176ceff218
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DockStyle.cs
@@ -0,0 +1,41 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+ [Editor("System.Windows.Forms.Design.DockEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
+ public enum DockStyle {
+ None = 0,
+ Top = 1,
+ Bottom = 2,
+ Left = 3,
+ Right = 4,
+ Fill = 5
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DomainUpDown.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DomainUpDown.cs
new file mode 100644
index 00000000000..06d8c3d61b3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DomainUpDown.cs
@@ -0,0 +1,572 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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.
+//
+// Authors:
+// Jonathan Gilbert <logic@deltaq.org>
+//
+// Integration into MWF:
+// Peter Bartok <pbartok@novell.com>
+//
+
+// COMPLETE
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+
+namespace System.Windows.Forms
+{
+ [DefaultProperty("Items")]
+ [DefaultEvent("SelectedItemChanged")]
+ [MonoTODO("Figure out what to do with the DomainItemAccessibleObject and DomainUpDownAccessibleObject classes")]
+ public class DomainUpDown : UpDownBase {
+ #region Local Variables
+ private DomainUpDownItemCollection items;
+ private int selected_index = -1;
+ private bool sorted;
+ private bool wrap;
+ private int typed_to_index = -1;
+ #endregion // Local Variables
+
+ #region DomainUpDownAccessibleObject sub-class
+ [ComVisible(true)]
+ public class DomainItemAccessibleObject : AccessibleObject {
+ #region DomainItemAccessibleObject Local Variables
+ private AccessibleObject parent;
+ #endregion // DomainItemAccessibleObject Local Variables
+
+ #region DomainItemAccessibleObject Constructors
+ public DomainItemAccessibleObject(string name, AccessibleObject parent) {
+ this.name = name;
+ this.parent = parent;
+ }
+ #endregion // DomainItemAccessibleObject Constructors
+
+ #region DomainItemAccessibleObject Properties
+ public override string Name {
+ get {
+ return base.Name;
+ }
+
+ set {
+ base.Name = value;
+ }
+ }
+
+ public override AccessibleObject Parent {
+ get {
+ return parent;
+ }
+ }
+
+ public override AccessibleRole Role {
+ get {
+ return base.Role;
+ }
+ }
+
+ public override AccessibleStates State {
+ get {
+ return base.State;
+ }
+ }
+
+ public override string Value {
+ get {
+ return base.Value;
+ }
+ }
+ #endregion // DomainItemAccessibleObject Properties
+ }
+ #endregion // DomainItemAccessibleObject sub-class
+
+ #region DomainUpDownAccessibleObject sub-class
+ [ComVisible(true)]
+ public class DomainUpDownAccessibleObject : ControlAccessibleObject {
+ #region DomainUpDownAccessibleObject Local Variables
+ private Control owner;
+ #endregion // DomainUpDownAccessibleObject Local Variables
+
+ #region DomainUpDownAccessibleObject Constructors
+ public DomainUpDownAccessibleObject(Control owner) : base(owner) {
+ this.owner = owner;
+ }
+ #endregion // DomainUpDownAccessibleObject Constructors
+
+ #region DomainUpDownAccessibleObject Properties
+ public override AccessibleRole Role {
+ get {
+ return base.Role;
+ }
+ }
+ #endregion // DomainUpDownAccessibleObject Properties
+
+ #region DomainUpDownAccessibleObject Methods
+ public override AccessibleObject GetChild(int index) {
+ return base.GetChild (index);
+ }
+
+ public override int GetChildCount() {
+ return base.GetChildCount ();
+ }
+ #endregion // DomainUpDownAccessibleObject Methods
+ }
+ #endregion // DomainUpDownAccessibleObject sub-class
+
+ #region DomainUpDownItemCollection sub-class
+ public class DomainUpDownItemCollection : ArrayList {
+ internal ArrayList string_cache = new ArrayList();
+
+ #region Local Variables
+ #endregion // Local Variables
+
+ #region Constructors
+ internal DomainUpDownItemCollection() {}
+ #endregion // Constructors
+
+ #region Public Instance Properties
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public override object this[int index] {
+ get {
+ return base[index];
+ }
+
+ set {
+ if (value == null) {
+ throw new ArgumentNullException("value", "Cannot add null values to a DomainUpDownItemCollection");
+ }
+
+ base[index] = value;
+ string_cache[index] = value.ToString();
+ OnCollectionChanged(index, 0);
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public override int Add(object value) {
+ if (value == null)
+ throw new ArgumentNullException("value", "Cannot add null values to a DomainUpDownItemCollection");
+
+ int ret = base.Add(value);
+ string_cache.Add(value.ToString());
+ OnCollectionChanged(Count - 1, +1);
+ return ret;
+ }
+
+ public override void Insert(int index, object value) {
+ if (value == null)
+ throw new ArgumentNullException("value", "Cannot add null values to a DomainUpDownItemCollection");
+
+ base.Insert(index, value);
+ string_cache.Insert(index, value.ToString());
+ OnCollectionChanged(index, +1);
+ }
+
+ public override void Remove(object obj) {
+ int index = IndexOf(obj);
+
+ if (index >= 0)
+ RemoveAt(index);
+ }
+
+ public override void RemoveAt(int index) {
+ base.RemoveAt(index);
+ string_cache.RemoveAt(index);
+ OnCollectionChanged(index, -1);
+ }
+ #endregion // Public Instance Methods
+
+ #region Internal Methods and Events
+ internal void OnCollectionChanged(int index, int size_delta) {
+ CollectionChangedEventHandler handler = CollectionChanged;
+
+ if (handler != null) {
+ handler(index, size_delta);
+ }
+ }
+
+ internal void PrivSort() {
+ PrivSort(0, Count, Comparer.Default);
+ }
+
+ internal void PrivSort(int index, int count, IComparer comparer) {
+ object[] base_items = null; // this will refer to the base ArrayList private _items member
+ object[] string_cache_items = null; // and this will refer to that of the string_cache
+
+ FieldInfo items_field = null;
+
+ try {
+ items_field = typeof(ArrayList).GetField("_items", BindingFlags.NonPublic | BindingFlags.Instance);
+ }
+ catch {} // security exceptions, perhaps...
+
+ if (items_field != null) {
+ base_items = items_field.GetValue(this) as object[];
+ string_cache_items = items_field.GetValue(string_cache) as object[];
+ }
+
+ if ((base_items == null) || (string_cache_items == null)) {
+ // oh poop =/ guess we have to completely repopulate the string cache
+ base.Sort(index, count, comparer);
+
+ for (int i=0; i < count; i++)
+ string_cache[i + index] = base[i + index].ToString();
+ }
+ else {
+ // yay, this will be much faster than creating a whole bunch more items
+ Array.Sort(string_cache_items, base_items, index, count, comparer);
+
+ OnCollectionChanged(-1, 0);
+ }
+ }
+
+ internal void PrivSort(IComparer comparer) {
+ PrivSort(0, Count, comparer);
+ }
+
+ internal event CollectionChangedEventHandler CollectionChanged;
+ #endregion // Internal Methods and Events
+ }
+ #endregion // DomainUpDownItemCollection sub-class
+
+ #region Private Methods
+ // normally I'd use an EventArgs class, but I don't want to create spurious objects here
+ internal delegate void CollectionChangedEventHandler(int index, int size_delta);
+
+ internal void items_CollectionChanged(int index, int size_delta) {
+ bool new_item = false;
+
+ if ((index == selected_index) && (size_delta <= 0))
+ new_item = true;
+ else if (index <= selected_index)
+ selected_index += size_delta;
+
+ if (sorted && (index >= 0)) // index < 0 means it is already sorting
+ items.PrivSort();
+
+ UpdateEditText();
+
+ if (new_item) {
+ OnSelectedItemChanged(this, EventArgs.Empty);
+ }
+ }
+
+ void go_to_user_input() {
+ UserEdit = false;
+
+ if (typed_to_index >= 0) {
+ selected_index = typed_to_index;
+ OnSelectedItemChanged(this, EventArgs.Empty);
+ }
+ }
+
+ private void TextBoxLostFocus(object source, EventArgs e) {
+ Select(base.txtView.SelectionStart + base.txtView.SelectionLength, 0);
+ }
+
+ private void TextBoxKeyDown(object source, KeyPressEventArgs e) {
+ if (!UserEdit) {
+ base.txtView.SelectionLength = 0;
+ typed_to_index = -1;
+ }
+
+ if (base.txtView.SelectionLength == 0) {
+ base.txtView.SelectionStart = 0;
+ }
+
+ if (base.txtView.SelectionStart != 0) {
+ return;
+ }
+
+ if (e.KeyChar == '\b') { // backspace
+ if (base.txtView.SelectionLength > 0) {
+ string prefix = base.txtView.SelectedText.Substring(0, base.txtView.SelectionLength - 1);
+
+ bool found = false;
+
+ if (typed_to_index < 0) {
+ typed_to_index = 0;
+ }
+
+ if (sorted) {
+ for (int i=typed_to_index; i >= 0; i--) {
+ int difference = string.Compare(prefix, 0, items.string_cache[i].ToString(), 0, prefix.Length, true);
+
+ if (difference == 0) {
+ found = true;
+ typed_to_index = i;
+ }
+
+ if (difference > 0) { // since it is sorted, no strings after this point will match
+ break;
+ }
+ }
+ } else {
+ for (int i=0; i < items.Count; i++) {
+ if (0 == string.Compare(prefix, 0, items.string_cache[i].ToString(), 0, prefix.Length, true)) {
+ found = true;
+ typed_to_index = i;
+ break;
+ }
+ }
+ }
+
+ ChangingText = true;
+
+ if (found)
+ Text = items.string_cache[typed_to_index].ToString();
+ else
+ Text = prefix;
+
+ Select(0, prefix.Length);
+
+ UserEdit = true;
+
+ e.Handled = true;
+ }
+ }
+ else {
+ char key_char = e.KeyChar;
+
+ if (char.IsLetterOrDigit(key_char)
+ || char.IsNumber(key_char)
+ || char.IsPunctuation(key_char)
+ || char.IsSymbol(key_char)
+ || char.IsWhiteSpace(key_char)) {
+ string prefix = base.txtView.SelectedText + key_char;
+
+ bool found = false;
+
+ if (typed_to_index < 0) {
+ typed_to_index = 0;
+ }
+
+ if (sorted) {
+ for (int i=typed_to_index; i < items.Count; i++) {
+ int difference = string.Compare(prefix, 0, items.string_cache[i].ToString(), 0, prefix.Length, true);
+
+ if (difference == 0) {
+ found = true;
+ typed_to_index = i;
+ }
+
+ if (difference <= 0) { // since it is sorted, no strings after this point will match
+ break;
+ }
+ }
+ } else {
+ for (int i=0; i < items.Count; i++) {
+ if (0 == string.Compare(prefix, 0, items.string_cache[i].ToString(), 0, prefix.Length, true)) {
+ found = true;
+ typed_to_index = i;
+ break;
+ }
+ }
+ }
+
+ ChangingText = true;
+
+ if (found) {
+ Text = items.string_cache[typed_to_index].ToString();
+ } else {
+ Text = prefix;
+ }
+
+ Select(0, prefix.Length);
+
+ UserEdit = true;
+
+ e.Handled = true;
+ }
+ }
+ }
+ #endregion // Private Methods
+
+ #region Public Constructors
+ public DomainUpDown() {
+ selected_index = -1;
+ sorted = false;
+ wrap = false;
+ typed_to_index = -1;
+
+ items = new DomainUpDownItemCollection();
+ items.CollectionChanged += new CollectionChangedEventHandler(items_CollectionChanged);
+
+ this.txtView.LostFocus +=new EventHandler(TextBoxLostFocus);
+ this.txtView.KeyPress += new KeyPressEventHandler(TextBoxKeyDown);
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ [Editor("System.Windows.Forms.Design.StringCollectionEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
+ [Localizable(true)]
+ public DomainUpDownItemCollection Items {
+ get {
+ return items;
+ }
+ }
+
+ [Browsable(false)]
+ [DefaultValue(-1)]
+ public int SelectedIndex {
+ get {
+ return selected_index;
+ }
+ set {
+ object before = (selected_index >= 0) ? items[selected_index] : null;
+
+ selected_index = value;
+ UpdateEditText();
+
+ object after = (selected_index >= 0) ? items[selected_index] : null;
+
+ if (!ReferenceEquals(before, after)) {
+ OnSelectedItemChanged(this, EventArgs.Empty);
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public object SelectedItem {
+ get {
+ if (selected_index >= 0) {
+ return items[selected_index];
+ } else {
+ return null;
+ }
+ }
+
+ set {
+ SelectedIndex = items.IndexOf(value);
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool Sorted {
+ get {
+ return sorted;
+ }
+ set {
+ sorted = value;
+
+ if (sorted)
+ items.PrivSort();
+ }
+ }
+
+ [DefaultValue(false)]
+ [Localizable(true)]
+ public bool Wrap {
+ get {
+ return wrap;
+ }
+ set {
+ wrap = value;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public override void DownButton() {
+ if (UserEdit)
+ go_to_user_input();
+
+ int new_index = selected_index + 1;
+
+ if (new_index >= items.Count) {
+ if (!wrap)
+ return;
+
+ new_index = 0;
+ }
+
+ SelectedIndex = new_index;
+ }
+
+ public override string ToString() {
+ return base.ToString() + ", Items.Count: " + items.Count + ", SelectedIndex: " + selected_index;
+ }
+
+ public override void UpButton() {
+ if (UserEdit)
+ go_to_user_input();
+
+ int new_index = selected_index - 1;
+
+ if (new_index < 0) {
+ if (!wrap) {
+ return;
+ }
+
+ new_index = items.Count - 1;
+ }
+
+ SelectedIndex = new_index;
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected override AccessibleObject CreateAccessibilityInstance() {
+ AccessibleObject acc;
+
+ acc = new AccessibleObject(this);
+ acc.role = AccessibleRole.SpinButton;
+
+ return acc;
+ }
+
+ protected override void OnChanged(object source, EventArgs e) {
+ base.OnChanged (source, e);
+ }
+
+ protected void OnSelectedItemChanged(object source, EventArgs e) {
+ EventHandler handler = SelectedItemChanged;
+
+ if (handler != null)
+ handler(source, e);
+ }
+
+ protected override void UpdateEditText() {
+ if ((selected_index >= 0) && (selected_index < items.Count)) {
+ ChangingText = true;
+ Text = items.string_cache[selected_index].ToString();
+ }
+ }
+
+ protected override void OnTextBoxKeyDown(object source, KeyEventArgs e) {
+ base.OnTextBoxKeyDown (source, e);
+ }
+
+ #endregion // Protected Instance Methods
+
+ #region Events
+ public event EventHandler SelectedItemChanged;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DragAction.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DragAction.cs
new file mode 100644
index 00000000000..73313e26f1d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DragAction.cs
@@ -0,0 +1,39 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public enum DragAction {
+ Continue = 0,
+ Drop = 1,
+ Cancel = 2
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DragDropEffects.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DragDropEffects.cs
new file mode 100644
index 00000000000..66cdc6df821
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DragDropEffects.cs
@@ -0,0 +1,41 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+
+ [Flags]
+ public enum DragDropEffects {
+ None = 0x00000000,
+ Copy = 0x00000001,
+ Move = 0x00000002,
+ Link = 0x00000004,
+ Scroll = unchecked((int)0x80000000),
+ All = unchecked((int)0x80000003)
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DragEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DragEventArgs.cs
new file mode 100644
index 00000000000..ea6ccc20222
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DragEventArgs.cs
@@ -0,0 +1,97 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public class DragEventArgs : EventArgs {
+ internal int x;
+ internal int y;
+ internal int keystate;
+ internal DragDropEffects allowed_effect;
+ internal DragDropEffects current_effect;
+ internal IDataObject data_object;
+
+ #region Public Constructors
+ public DragEventArgs(IDataObject data, int keyState, int x, int y, DragDropEffects allowedEffect, DragDropEffects effect) {
+ this.x=x;
+ this.y=y;
+ this.keystate=keyState;
+ this.allowed_effect=allowedEffect;
+ this.current_effect=effect;
+ this.data_object=data;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public DragDropEffects AllowedEffect {
+ get {
+ return this.allowed_effect;
+ }
+ }
+
+ public IDataObject Data {
+ get {
+ return this.data_object;
+ }
+ }
+
+ public DragDropEffects Effect {
+ get {
+ return this.current_effect;
+ }
+
+ set {
+ if ((value & this.allowed_effect)!=0) {
+ this.current_effect=value;
+ }
+ }
+ }
+
+ public int KeyState {
+ get {
+ return this.keystate;
+ }
+ }
+
+ public int X {
+ get {
+ return this.x;
+ }
+ }
+
+ public int Y {
+ get {
+ return this.y;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DragEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DragEventHandler.cs
new file mode 100644
index 00000000000..c2c4d1e0bd0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DragEventHandler.cs
@@ -0,0 +1,31 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void DragEventHandler (object sender, DragEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DrawItemEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DrawItemEventArgs.cs
new file mode 100644
index 00000000000..5ef247df86e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DrawItemEventArgs.cs
@@ -0,0 +1,101 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+using System;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+
+ public class DrawItemEventArgs : EventArgs {
+
+ Graphics graphics;
+ Font font;
+ Rectangle rect;
+ int index;
+ DrawItemState state;
+ Color fore_color;
+ Color back_color;
+
+ public DrawItemEventArgs (Graphics graphics, Font font,
+ Rectangle rect, int index, DrawItemState state) :
+ this (graphics, font, rect, index, state,
+ Control.DefaultForeColor, Control.DefaultBackColor)
+ {
+
+ }
+
+ public DrawItemEventArgs (Graphics graphics, Font font,
+ Rectangle rect, int index, DrawItemState state,
+ Color fore_color, Color back_color)
+ {
+ this.graphics = graphics;
+ this.font = font;
+ this.rect = rect;
+ this.index = index;
+ this.state = state;
+ this.fore_color = fore_color;
+ this.back_color = back_color;
+ }
+
+ public Graphics Graphics {
+ get { return graphics; }
+ }
+
+ public Font Font {
+ get { return font; }
+ }
+
+ public Rectangle Bounds {
+ get { return rect; }
+ }
+
+ public int Index {
+ get { return index; }
+ }
+
+ public DrawItemState State {
+ get { return state; }
+ }
+
+ public Color BackColor {
+ get { return back_color; }
+ }
+
+ public Color ForeColor {
+ get { return fore_color; }
+ }
+
+ public virtual void DrawBackground ()
+ {
+ ThemeEngine.Current.DrawOwnerDrawBackground (this);
+ }
+
+ public virtual void DrawFocusRectangle ()
+ {
+ ThemeEngine.Current.DrawOwnerDrawFocusRectangle (this);
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DrawItemEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DrawItemEventHandler.cs
new file mode 100644
index 00000000000..697783cdce3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DrawItemEventHandler.cs
@@ -0,0 +1,32 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+//
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public delegate void DrawItemEventHandler (object sender, DrawItemEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DrawItemState.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DrawItemState.cs
new file mode 100644
index 00000000000..0b2a8b1c99a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DrawItemState.cs
@@ -0,0 +1,44 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+namespace System.Windows.Forms {
+
+ [Flags]
+ public enum DrawItemState {
+ None = 0,
+ Selected = 1,
+ Grayed = 2,
+ Disabled = 4,
+ Checked = 8,
+ Focus = 16,
+ Default = 32,
+ HotLight = 64,
+ Inactive = 128,
+ NoAccelerator = 256,
+ NoFocusRect = 512,
+ ComboBoxEdit = 4096
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DrawMode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DrawMode.cs
new file mode 100644
index 00000000000..073bca003b7
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DrawMode.cs
@@ -0,0 +1,37 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+//
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public enum DrawMode
+ {
+ Normal = 0,
+ OwnerDrawFixed = 1,
+ OwnerDrawVariable = 2,
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ErrorBlinkStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ErrorBlinkStyle.cs
new file mode 100644
index 00000000000..8115a3d0b42
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ErrorBlinkStyle.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum ErrorBlinkStyle {
+ BlinkIfDifferentError = 0,
+ AlwaysBlink = 1,
+ NeverBlink = 2
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ErrorIconAlignment.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ErrorIconAlignment.cs
new file mode 100644
index 00000000000..0539a3af2e3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ErrorIconAlignment.cs
@@ -0,0 +1,38 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum ErrorIconAlignment {
+ TopLeft = 0,
+ TopRight = 1,
+ MiddleLeft = 2,
+ MiddleRight = 3,
+ BottomLeft = 4,
+ BottomRight = 5
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ErrorProvider.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ErrorProvider.cs
new file mode 100644
index 00000000000..450e975a883
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ErrorProvider.cs
@@ -0,0 +1,440 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+ [ToolboxItemFilter("System.Windows.Forms")]
+ [ProvideProperty("IconAlignment", "System.Windows.Forms.Control, " + Consts.AssemblySystem_Windows_Forms)]
+ [ProvideProperty("IconPadding", "System.Windows.Forms.Control, " + Consts.AssemblySystem_Windows_Forms)]
+ [ProvideProperty("Error", "System.Windows.Forms.Control, " + Consts.AssemblySystem_Windows_Forms)]
+ public class ErrorProvider : Component, IExtenderProvider {
+ #region Private Classes
+ private class ErrorProperty {
+ public ErrorIconAlignment alignment;
+ public int padding;
+ public string text;
+ public Control control;
+ public ErrorProvider ep;
+ private UserControl window;
+ private bool visible;
+ private int blink_count;
+ private EventHandler tick;
+ private System.Windows.Forms.Timer timer;
+
+ public ErrorProperty(ErrorProvider ep, Control control) {
+ this.ep = ep;
+ this.control = control;
+
+ alignment = ErrorIconAlignment.MiddleRight;
+ padding = 0;
+ text = string.Empty;
+ blink_count = 0;
+
+ tick = new EventHandler(window_Tick);
+
+ window = new UserControl();
+ window.Visible = false;
+ window.Width = ep.icon.Width;
+ window.Height = ep.icon.Height;
+
+ if (ep.container != null) {
+ ep.container.Controls.Add(window);
+ ep.container.Controls.SetChildIndex(window, 0);
+ } else {
+ control.parent.Controls.Add(window);
+ control.parent.Controls.SetChildIndex(window, 0);
+ }
+
+ window.Paint += new PaintEventHandler(window_Paint);
+ window.MouseEnter += new EventHandler(window_MouseEnter);
+ window.MouseLeave += new EventHandler(window_MouseLeave);
+ control.SizeChanged += new EventHandler(control_SizeLocationChanged);
+ control.LocationChanged += new EventHandler(control_SizeLocationChanged);
+ // Do we want to block mouse clicks? if so we need a few more events handled
+
+ CalculateAlignment();
+ }
+
+ public string Text {
+ get {
+ return text;
+ }
+
+ set {
+ text = value;
+ if (text != String.Empty) {
+ window.Visible = true;
+ } else {
+ window.Visible = false;
+ }
+
+ if (ep.blinkstyle != ErrorBlinkStyle.NeverBlink) {
+ if (timer == null) {
+ timer = new System.Windows.Forms.Timer();
+ }
+ timer.Interval = ep.blinkrate;
+ timer.Tick += tick;
+ blink_count = 0;
+ timer.Enabled = true;
+ }
+ }
+ }
+
+ public ErrorIconAlignment Alignment {
+ get {
+ return alignment;
+ }
+
+ set {
+ if (alignment != value) {
+ alignment = value;
+ CalculateAlignment();
+ }
+ }
+ }
+
+ public int Padding {
+ get {
+ return padding;
+ }
+
+ set {
+ if (padding != value) {
+ padding = value;
+ CalculateAlignment();
+ }
+ }
+ }
+
+ private void CalculateAlignment() {
+ if (visible) {
+ visible = false;
+ ep.tooltip.Visible = false;
+ }
+
+ switch (alignment) {
+ case ErrorIconAlignment.TopLeft: {
+ window.Left = control.Left - ep.icon.Width - padding;
+ window.Top = control.Top;
+ break;
+ }
+
+ case ErrorIconAlignment.TopRight: {
+ window.Left = control.Left + control.Width + padding;
+ window.Top = control.Top;
+ break;
+ }
+
+ case ErrorIconAlignment.MiddleLeft: {
+ window.Left = control.Left - ep.icon.Width - padding;
+ window.Top = control.Top + (control.Height - ep.icon.Height) / 2;
+ break;
+ }
+
+ case ErrorIconAlignment.MiddleRight: {
+ window.Left = control.Left + control.Width + padding;
+ window.Top = control.Top + (control.Height - ep.icon.Height) / 2;
+ break;
+ }
+
+ case ErrorIconAlignment.BottomLeft: {
+ window.Left = control.Left - ep.icon.Width - padding;
+ window.Top = control.Top + control.Height - ep.icon.Height;
+ break;
+ }
+
+ case ErrorIconAlignment.BottomRight: {
+ window.Left = control.Left + control.Width + padding;
+ window.Top = control.Top + control.Height - ep.icon.Height;
+ break;
+ }
+ }
+ }
+
+ private void window_Paint(object sender, PaintEventArgs e) {
+ if (text != string.Empty) {
+ e.Graphics.DrawIcon(this.ep.icon, 0, 0);
+ }
+ }
+
+ private void window_MouseEnter(object sender, EventArgs e) {
+ if (!visible) {
+ Size size;
+ Point pt;
+
+ visible = true;
+
+ pt = Control.MousePosition;
+
+ size = ThemeEngine.Current.ToolTipSize(ep.tooltip, text);
+ ep.tooltip.Width = size.Width;
+ ep.tooltip.Height = size.Height;
+ ep.tooltip.Text = text;
+
+ if ((pt.X + size.Width) < SystemInformation.WorkingArea.Width) {
+ ep.tooltip.Left = pt.X;
+ } else {
+ ep.tooltip.Left = pt.X - size.Width;
+ }
+
+ if ((pt.Y + size.Height) < (SystemInformation.WorkingArea.Height - 16)) {
+ ep.tooltip.Top = pt.Y + 16;
+ } else {
+ ep.tooltip.Top = pt.Y - size.Height;
+ }
+ ep.tooltip.Visible = true;
+ }
+ }
+
+ private void window_MouseLeave(object sender, EventArgs e) {
+ if (visible) {
+ visible = false;
+ ep.tooltip.Visible = false;
+ }
+ }
+
+ private void control_SizeLocationChanged(object sender, EventArgs e) {
+ if (visible) {
+ visible = false;
+ ep.tooltip.Visible = false;
+ }
+ CalculateAlignment();
+ }
+
+ private void window_Tick(object sender, EventArgs e) {
+ if (timer.Enabled) {
+ Graphics g;
+
+ blink_count++;
+
+ // Dunno why this POS doesn't reliably blink
+ g = window.CreateGraphics();
+ if ((blink_count % 2) == 0) {
+ g.FillRectangle(ThemeEngine.Current.ResPool.GetSolidBrush(window.parent.BackColor), window.ClientRectangle);
+ } else {
+ g.DrawIcon(this.ep.icon, 0, 0);
+ }
+ g.Dispose();
+
+ if ((blink_count > 6) && (ep.blinkstyle == ErrorBlinkStyle.BlinkIfDifferentError)) {
+ timer.Stop();
+ blink_count = 0;
+ }
+ }
+ }
+ }
+ #endregion
+
+ #region Local Variables
+ private int blinkrate;
+ private ErrorBlinkStyle blinkstyle;
+ private string datamember;
+ private object datasource;
+ private ContainerControl container;
+ private Icon icon;
+ private Hashtable controls;
+ private ToolTip.ToolTipWindow tooltip;
+ #endregion // Local Variables
+
+ #region Public Constructors
+ public ErrorProvider() {
+ controls = new Hashtable();
+
+ blinkrate = 250;
+ blinkstyle = ErrorBlinkStyle.BlinkIfDifferentError;
+
+ icon = (Icon)Locale.GetResource("errorProvider.ico");
+ tooltip = new ToolTip.ToolTipWindow(null);
+ }
+
+ public ErrorProvider(ContainerControl parentControl) : this() {
+ container = parentControl;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ [DefaultValue(250)]
+ [RefreshProperties(RefreshProperties.Repaint)]
+ public int BlinkRate {
+ get {
+ return blinkrate;
+ }
+
+ set {
+ blinkrate = value;
+ }
+ }
+
+ [DefaultValue(ErrorBlinkStyle.BlinkIfDifferentError)]
+ public ErrorBlinkStyle BlinkStyle {
+ get {
+ return blinkstyle;
+ }
+
+ set {
+ blinkstyle = value;
+ }
+ }
+
+ [DefaultValue(null)]
+ public ContainerControl ContainerControl {
+ get {
+ return container;
+ }
+
+ set {
+ container = value;
+ }
+ }
+
+ [MonoTODO]
+ [DefaultValue(null)]
+ [Editor ("System.Windows.Forms.Design.DataMemberListEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
+ public string DataMember {
+ get {
+ return datamember;
+ }
+
+ set {
+ datamember = value;
+ // FIXME - add binding magic and also update BindToDataAndErrors with it
+ }
+ }
+
+ [MonoTODO]
+ [DefaultValue(null)]
+ [TypeConverter("System.Windows.Forms.Design.DataSourceConverter, " + Consts.AssemblySystem_Design)]
+ public object DataSource {
+ get {
+ return datasource;
+ }
+
+ set {
+ datasource = value;
+ // FIXME - add binding magic and also update BindToDataAndErrors with it
+ }
+ }
+
+ [Localizable(true)]
+ public Icon Icon {
+ get {
+ return icon;
+ }
+
+ set {
+ icon = value;
+ }
+ }
+
+ public override ISite Site {
+ set {
+ base.Site = value;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ [MonoTODO]
+ public void BindToDataAndErrors(object newDataSource, string newDataMember) {
+ datasource = newDataSource;
+ datamember = newDataMember;
+ // FIXME - finish
+ }
+
+ public bool CanExtend(object extendee) {
+ if (!(extendee is Control)) {
+ return false;
+ }
+
+ if ((extendee is Form) || (extendee is ToolBar)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ [Localizable(true)]
+ [DefaultValue("")]
+ public string GetError(Control control) {
+ return GetErrorProperty(control).Text;
+ }
+
+ [Localizable(true)]
+ [DefaultValue(ErrorIconAlignment.MiddleRight)]
+ public ErrorIconAlignment GetIconAlignment(Control control) {
+ return GetErrorProperty(control).Alignment;
+ }
+
+ [Localizable(true)]
+ [DefaultValue(0)]
+ public int GetIconPadding(Control control) {
+ return GetErrorProperty(control).padding;
+ }
+
+ public void SetError(Control control, string value) {
+ GetErrorProperty(control).Text = value;
+ }
+
+ public void SetIconAlignment(Control control, ErrorIconAlignment value) {
+ GetErrorProperty(control).Alignment = value;
+ }
+
+ public void SetIconPadding(Control control, int padding) {
+ GetErrorProperty(control).Padding = padding;
+ }
+
+ [MonoTODO]
+ public void UpdateBinding() {
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected override void Dispose(bool disposing) {
+ base.Dispose (disposing);
+ }
+ #endregion // Protected Instance Methods
+
+ #region Private Methods
+ private ErrorProperty GetErrorProperty(Control control) {
+ ErrorProperty ep;
+
+ ep = (ErrorProperty)controls[control];
+ if (ep == null) {
+ ep = new ErrorProperty(this, control);
+ controls[control] = ep;
+ }
+
+ return ep;
+ }
+ #endregion // Private Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FeatureSupport.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FeatureSupport.cs
new file mode 100644
index 00000000000..3420d69ef39
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FeatureSupport.cs
@@ -0,0 +1,116 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+using System.Reflection;
+
+namespace System.Windows.Forms {
+ public abstract class FeatureSupport : IFeatureSupport {
+ #region Public Constructors
+ protected FeatureSupport() {
+ }
+ #endregion // Public Constructors
+
+ #region Private and Internal Methods
+ private static IFeatureSupport FeatureObject(string class_name) {
+ Type class_type;
+
+ class_type = Type.GetType(class_name);
+ if ((class_type != null) && (typeof(IFeatureSupport).IsAssignableFrom(class_type))) {
+ ConstructorInfo ctor;
+
+ ctor = class_type.GetConstructor(Type.EmptyTypes);
+ if (ctor != null) {
+ return ((IFeatureSupport)ctor.Invoke(new Object[0]));
+ }
+ }
+
+ return null;
+ }
+ #endregion // Private and Internal Methods
+
+ #region Public Static Methods
+ public static Version GetVersionPresent(string featureClassName, string featureConstName) {
+ IFeatureSupport obj;
+
+ obj = FeatureObject(featureClassName);
+ if (obj != null) {
+ return obj.GetVersionPresent(featureConstName);
+ }
+ return null;
+ }
+
+ public static bool IsPresent(string featureClassName, string featureConstName) {
+ IFeatureSupport obj;
+
+ obj = FeatureObject(featureClassName);
+ if (obj != null) {
+ return obj.IsPresent(featureConstName);
+ }
+
+ return false;
+ }
+
+ public static bool IsPresent(string featureClassName, string featureConstName, Version minimumVersion) {
+ IFeatureSupport obj;
+
+ obj = FeatureObject(featureClassName);
+ if (obj != null) {
+ return obj.IsPresent(featureConstName, minimumVersion);
+ }
+
+ return false;
+ }
+ #endregion // Public Static Methods
+
+ #region Public Instance Methods
+ public abstract Version GetVersionPresent(object feature);
+
+ public virtual bool IsPresent(object feature) {
+ if (GetVersionPresent(feature) != null) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public virtual bool IsPresent(object feature, Version minimumVersion) {
+ Version version;
+ bool retval;
+
+ retval = false;
+ version = GetVersionPresent(feature);
+
+ if ((version != null) && (version >= minimumVersion)) {
+ retval = true;
+ }
+
+ return retval;
+ }
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FileDialog.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FileDialog.cs
new file mode 100644
index 00000000000..ba5a616597b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FileDialog.cs
@@ -0,0 +1,2798 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+//
+// Alexander Olk xenomorph2@onlinehome.de
+//
+
+// NOT COMPLETE - work in progress
+
+using System;
+using System.Drawing;
+using System.ComponentModel;
+using System.Resources;
+using System.IO;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Xml;
+
+namespace System.Windows.Forms {
+ [DefaultProperty ("FileName")]
+ [DefaultEvent ("FileOk")]
+ public abstract class FileDialog : CommonDialog {
+ protected static readonly object EventFileOk = new object ();
+
+ internal enum FileDialogType {
+ OpenFileDialog,
+ SaveFileDialog
+ }
+
+ private bool addExtension = true;
+ private bool checkFileExists = false;
+ private bool checkPathExists = true;
+ private string defaultExt = "";
+ private bool dereferenceLinks = true;
+ private string fileName = "";
+ private string[] fileNames;
+ private string filter;
+ private int filterIndex = 1;
+ private string initialDirectory = "";
+ private bool restoreDirectory = false;
+ private bool showHelp = false;
+ private string title = "";
+ private bool validateNames = true;
+
+ private Button cancelButton;
+ private ToolBarButton upToolBarButton;
+ private PopupButtonPanel popupButtonPanel;
+ private Button openSaveButton;
+ private Button helpButton;
+ private Label fileTypeLabel;
+ private ToolBarButton menueToolBarButton;
+ private ContextMenu menueToolBarButtonContextMenu;
+ private ToolBar smallButtonToolBar;
+ private DirComboBox dirComboBox;
+ private ComboBox fileNameComboBox;
+ private Label fileNameLabel;
+ private MWFFileView mwfFileView;
+ private Label searchSaveLabel;
+ private ToolBarButton newdirToolBarButton;
+ private ToolBarButton backToolBarButton;
+ private ComboBox fileTypeComboBox;
+ private ImageList imageListTopToolbar;
+ private ContextMenu contextMenu;
+ private CheckBox readonlyCheckBox;
+
+ private string currentDirectoryName;
+ private string currentFileName = "";
+ // store current directoryInfo
+ private DirectoryInfo currentDirectoryInfo;
+ // store DirectoryInfo for backButton
+ private Stack directoryStack = new Stack();
+ private MenuItem previousCheckedMenuItem;
+ private bool multiSelect = false;
+
+ private string restoreDirectoryString = "";
+
+ private bool show_special_case = false;
+
+ internal static readonly string recently_string = "[recently/recently]";
+ internal static readonly string network_string = "[network/network]";
+ internal static readonly string mycomputer_string = "[mycomputer/mycomputer]";
+
+ private string current_special_case;
+
+ internal FileDialogType fileDialogType;
+
+ private bool do_not_call_OnSelectedIndexChangedFileTypeComboBox = false;
+
+ private bool showHiddenFiles = false;
+
+ //protected bool readOnlyChecked = false;
+
+ private bool showReadOnly = false;
+ private bool readOnlyChecked = false;
+ internal bool createPrompt = false;
+ internal bool overwritePrompt = true;
+
+ internal FileFilter fileFilter;
+
+ private string last_dir_when_opened_or_saved = "";
+ private string start_dir;
+
+ internal FileDialog ()
+ {
+ fileTypeComboBox = new ComboBox ();
+ backToolBarButton = new ToolBarButton ();
+ newdirToolBarButton = new ToolBarButton ();
+ searchSaveLabel = new Label ();
+ mwfFileView = new MWFFileView ();
+ fileNameLabel = new Label ();
+ fileNameComboBox = new ComboBox ();
+ dirComboBox = new DirComboBox ();
+ smallButtonToolBar = new ToolBar ();
+ menueToolBarButton = new ToolBarButton ();
+ fileTypeLabel = new Label ();
+ openSaveButton = new Button ();
+ form.AcceptButton = openSaveButton;
+ helpButton = new Button ();
+ popupButtonPanel = new PopupButtonPanel (this);
+ upToolBarButton = new ToolBarButton ();
+ cancelButton = new Button ();
+ form.CancelButton = cancelButton;
+ imageListTopToolbar = new ImageList ();
+ menueToolBarButtonContextMenu = new ContextMenu ();
+ contextMenu = new ContextMenu ();
+ readonlyCheckBox = new CheckBox ();
+
+ form.SuspendLayout ();
+
+ //imageListTopToolbar
+ imageListTopToolbar.ColorDepth = ColorDepth.Depth32Bit;
+ imageListTopToolbar.ImageSize = new Size (16, 16); // 16, 16
+ imageListTopToolbar.Images.Add ((Image)Locale.GetResource ("back_arrow"));
+ imageListTopToolbar.Images.Add ((Image)Locale.GetResource ("folder_arrow_up"));
+ imageListTopToolbar.Images.Add ((Image)Locale.GetResource ("folder_star"));
+ imageListTopToolbar.Images.Add ((Image)Locale.GetResource ("window"));
+ imageListTopToolbar.TransparentColor = Color.Transparent;
+
+ // searchLabel
+ searchSaveLabel.FlatStyle = FlatStyle.System;
+ searchSaveLabel.Location = new Point (7, 8);
+ searchSaveLabel.Size = new Size (72, 21);
+ searchSaveLabel.TextAlign = ContentAlignment.MiddleRight;
+
+ // dirComboBox
+ dirComboBox.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right)));
+ dirComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
+ dirComboBox.Location = new Point (99, 8);
+ dirComboBox.Size = new Size (260, 21);
+ dirComboBox.TabIndex = 0;
+
+ // smallButtonToolBar
+ smallButtonToolBar.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right)));
+ smallButtonToolBar.Appearance = ToolBarAppearance.Flat;
+ smallButtonToolBar.AutoSize = false;
+ smallButtonToolBar.Buttons.AddRange (new ToolBarButton [] {
+ backToolBarButton,
+ upToolBarButton,
+ newdirToolBarButton,
+ menueToolBarButton});
+ smallButtonToolBar.ButtonSize = new Size (24, 24); // 21, 16
+ smallButtonToolBar.Divider = false;
+ smallButtonToolBar.Dock = DockStyle.None;
+ smallButtonToolBar.DropDownArrows = true;
+ smallButtonToolBar.ImageList = imageListTopToolbar;
+ smallButtonToolBar.Location = new Point (372, 6);
+ smallButtonToolBar.ShowToolTips = true;
+ smallButtonToolBar.Size = new Size (140, 28);
+ smallButtonToolBar.TabIndex = 1;
+ smallButtonToolBar.TextAlign = ToolBarTextAlign.Right;
+
+ // buttonPanel
+ popupButtonPanel.Dock = DockStyle.None;
+ popupButtonPanel.Location = new Point (7, 37);
+ popupButtonPanel.TabIndex = 2;
+
+ // mwfFileView
+ mwfFileView.Anchor = ((AnchorStyles)((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
+ mwfFileView.Location = new Point (99, 37);
+ mwfFileView.Size = new Size (449, 282);
+ mwfFileView.Columns.Add (" Name", 170, HorizontalAlignment.Left);
+ mwfFileView.Columns.Add ("Size ", 80, HorizontalAlignment.Right);
+ mwfFileView.Columns.Add (" Type", 100, HorizontalAlignment.Left);
+ mwfFileView.Columns.Add (" Last Access", 150, HorizontalAlignment.Left);
+ mwfFileView.AllowColumnReorder = true;
+ mwfFileView.MultiSelect = false;
+ mwfFileView.TabIndex = 3;
+ mwfFileView.FilterIndex = FilterIndex;
+
+ // fileNameLabel
+ fileNameLabel.Anchor = ((AnchorStyles)((AnchorStyles.Bottom | AnchorStyles.Left)));
+ fileNameLabel.FlatStyle = FlatStyle.System;
+ fileNameLabel.Location = new Point (102, 330);
+ fileNameLabel.Size = new Size (70, 21);
+ fileNameLabel.Text = "Filename:";
+ fileNameLabel.TextAlign = ContentAlignment.MiddleLeft;
+
+ // fileNameComboBox
+ fileNameComboBox.Anchor = ((AnchorStyles)(((AnchorStyles.Bottom | AnchorStyles.Left) | AnchorStyles.Right)));
+ fileNameComboBox.Location = new Point (195, 330);
+ fileNameComboBox.Size = new Size (245, 21);
+ fileNameComboBox.TabIndex = 4;
+ fileNameComboBox.Items.Add (" ");
+
+ // fileTypeLabel
+ fileTypeLabel.Anchor = ((AnchorStyles)((AnchorStyles.Bottom | AnchorStyles.Left)));
+ fileTypeLabel.FlatStyle = FlatStyle.System;
+ fileTypeLabel.Location = new Point (102, 356);
+ fileTypeLabel.Size = new Size (70, 21);
+ fileTypeLabel.Text = "Filetype:";
+ fileTypeLabel.TextAlign = ContentAlignment.MiddleLeft;
+
+ // fileTypeComboBox
+ fileTypeComboBox.Anchor = ((AnchorStyles)(((AnchorStyles.Bottom | AnchorStyles.Left) | AnchorStyles.Right)));
+ fileTypeComboBox.Location = new Point (195, 356);
+ fileTypeComboBox.Size = new Size (245, 21);
+ fileTypeComboBox.TabIndex = 5;
+
+ // backToolBarButton
+ backToolBarButton.ImageIndex = 0;
+ backToolBarButton.Enabled = false;
+ backToolBarButton.Style = ToolBarButtonStyle.PushButton;
+
+ // upToolBarButton
+ upToolBarButton.ImageIndex = 1;
+ upToolBarButton.Style = ToolBarButtonStyle.PushButton;
+
+ // newdirToolBarButton
+ newdirToolBarButton.ImageIndex = 2;
+ newdirToolBarButton.Style = ToolBarButtonStyle.PushButton;
+
+ // menueToolBarButton
+ menueToolBarButton.ImageIndex = 3;
+ menueToolBarButton.DropDownMenu = menueToolBarButtonContextMenu;
+ menueToolBarButton.Style = ToolBarButtonStyle.DropDownButton;
+
+ // menueToolBarButtonContextMenu
+ MenuItem mi = new MenuItem ("Small Icon", new EventHandler (OnClickMenuToolBarContextMenu));
+ mi.RadioCheck = true;
+ menueToolBarButtonContextMenu.MenuItems.Add (mi);
+ mi = new MenuItem ("Tiles", new EventHandler (OnClickMenuToolBarContextMenu));
+ mi.RadioCheck = true;
+ menueToolBarButtonContextMenu.MenuItems.Add (mi);
+ mi = new MenuItem ("Large Icon", new EventHandler (OnClickMenuToolBarContextMenu));
+ mi.RadioCheck = true;
+ menueToolBarButtonContextMenu.MenuItems.Add (mi);
+ mi = new MenuItem ("List", new EventHandler (OnClickMenuToolBarContextMenu));
+ mi.RadioCheck = true;
+ mi.Checked = true;
+ previousCheckedMenuItem = mi;
+ menueToolBarButtonContextMenu.MenuItems.Add (mi);
+ mi = new MenuItem ("Details", new EventHandler (OnClickMenuToolBarContextMenu));
+ mi.RadioCheck = true;
+ menueToolBarButtonContextMenu.MenuItems.Add (mi);
+
+ // contextMenu
+ mi = new MenuItem ("Show hidden files", new EventHandler (OnClickContextMenu));
+ mi.Checked = showHiddenFiles;
+ mwfFileView.ShowHiddenFiles = showHiddenFiles;
+ contextMenu.MenuItems.Add (mi);
+
+ // openSaveButton
+ openSaveButton.Anchor = ((AnchorStyles)((AnchorStyles.Bottom | AnchorStyles.Right)));
+ openSaveButton.FlatStyle = FlatStyle.System;
+ openSaveButton.Location = new Point (475, 330);
+ openSaveButton.Size = new Size (72, 21);
+ openSaveButton.TabIndex = 7;
+ openSaveButton.FlatStyle = FlatStyle.System;
+
+ // cancelButton
+ cancelButton.Anchor = ((AnchorStyles)((AnchorStyles.Bottom | AnchorStyles.Right)));
+ cancelButton.FlatStyle = FlatStyle.System;
+ cancelButton.Location = new Point (475, 356);
+ cancelButton.Size = new Size (72, 21);
+ cancelButton.TabIndex = 8;
+ cancelButton.Text = "Cancel";
+ cancelButton.FlatStyle = FlatStyle.System;
+
+ // helpButton
+ helpButton.Anchor = ((AnchorStyles)((AnchorStyles.Bottom | AnchorStyles.Right)));
+ helpButton.FlatStyle = FlatStyle.System;
+ helpButton.Location = new Point (475, 350);
+ helpButton.Size = new Size (72, 21);
+ helpButton.TabIndex = 9;
+ helpButton.Text = "Help";
+ helpButton.FlatStyle = FlatStyle.System;
+
+ // checkBox
+ readonlyCheckBox.Anchor = ((AnchorStyles)(((AnchorStyles.Bottom | AnchorStyles.Left) | AnchorStyles.Right)));
+ readonlyCheckBox.Text = "Open Readonly";
+ readonlyCheckBox.Location = new Point (195, 350);
+ readonlyCheckBox.Size = new Size (245, 21);
+ readonlyCheckBox.TabIndex = 6;
+ readonlyCheckBox.FlatStyle = FlatStyle.System;
+
+ form.ContextMenu = contextMenu;
+
+ form.Size = new Size (554, 405); // 384
+ form.MaximizeBox = true;
+ form.FormBorderStyle = FormBorderStyle.Sizable;
+ form.MinimumSize = new Size (554, 405);
+
+ form.Controls.Add (smallButtonToolBar);
+ form.Controls.Add (cancelButton);
+ form.Controls.Add (openSaveButton);
+ form.Controls.Add (mwfFileView);
+ form.Controls.Add (fileTypeLabel);
+ form.Controls.Add (fileNameLabel);
+ form.Controls.Add (fileTypeComboBox);
+ form.Controls.Add (fileNameComboBox);
+ form.Controls.Add (dirComboBox);
+ form.Controls.Add (searchSaveLabel);
+ form.Controls.Add (popupButtonPanel);
+
+ form.ResumeLayout (false);
+
+ currentDirectoryName = Environment.CurrentDirectory;
+
+ currentDirectoryInfo = new DirectoryInfo (currentDirectoryName);
+
+ if (RestoreDirectory)
+ restoreDirectoryString = currentDirectoryName;
+
+ openSaveButton.Click += new EventHandler (OnClickOpenSaveButton);
+ cancelButton.Click += new EventHandler (OnClickCancelButton);
+ helpButton.Click += new EventHandler (OnClickHelpButton);
+
+ smallButtonToolBar.ButtonClick += new ToolBarButtonClickEventHandler (OnClickSmallButtonToolBar);
+
+ fileTypeComboBox.SelectedIndexChanged += new EventHandler (OnSelectedIndexChangedFileTypeComboBox);
+
+ mwfFileView.SelectedFileChanged += new EventHandler (OnSelectedFileChangedFileView);
+ mwfFileView.DirectoryChanged += new EventHandler (OnDirectoryChangedFileView);
+ mwfFileView.ForceDialogEnd += new EventHandler (OnForceDialogEndFileView);
+ mwfFileView.SelectedFilesChanged += new EventHandler (OnSelectedFilesChangedFileView);
+ mwfFileView.OnDirectoryUp += new EventHandler (OnDirectoryUp);
+
+ dirComboBox.DirectoryChanged += new EventHandler (OnDirectoryChangedDirComboBox);
+
+ readonlyCheckBox.CheckedChanged += new EventHandler (OnCheckCheckChanged);
+
+ start_dir = currentDirectoryName;
+ }
+
+ [DefaultValue(true)]
+ public bool AddExtension {
+ get {
+ return addExtension;
+ }
+
+ set {
+ addExtension = value;
+ }
+ }
+
+ [DefaultValue(false)]
+ public virtual bool CheckFileExists {
+ get {
+ return checkFileExists;
+ }
+
+ set {
+ checkFileExists = value;
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool CheckPathExists {
+ get {
+ return checkPathExists;
+ }
+
+ set {
+ checkPathExists = value;
+ }
+ }
+
+ [DefaultValue("")]
+ public string DefaultExt {
+ get {
+ return defaultExt;
+ }
+
+ set {
+ defaultExt = value;
+
+ // if there is a dot remove it and everything before it
+ if (defaultExt.LastIndexOf ('.') != - 1) {
+ string[] split = defaultExt.Split (new char [] { '.' });
+ defaultExt = split [split.Length - 1];
+ }
+ }
+ }
+
+ // in MS.NET it doesn't make a difference if
+ // DerefenceLinks is true or false
+ // if the selected file is a link FileDialog
+ // always returns the link
+ [DefaultValue(true)]
+ public bool DereferenceLinks {
+ get {
+ return dereferenceLinks;
+ }
+
+ set {
+ dereferenceLinks = value;
+ }
+ }
+
+ [DefaultValue("")]
+ public string FileName {
+ get {
+ return fileName;
+ }
+
+ set {
+ if (value != null) {
+ if (SetFileName (value))
+ fileName = value;
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string[] FileNames {
+ get {
+ if (fileNames == null || fileNames.Length == 0) {
+ string[] null_nada_nothing_filenames = new string [0];
+ return null_nada_nothing_filenames;
+ }
+
+ string[] new_filenames = new string [fileNames.Length];
+ fileNames.CopyTo (new_filenames, 0);
+ return new_filenames;
+ }
+ }
+
+ [DefaultValue("")]
+ [Localizable(true)]
+ public string Filter {
+ get {
+ return filter;
+ }
+
+ set {
+ if (value == null)
+ throw new NullReferenceException ("Filter");
+
+ filter = value;
+
+ fileFilter = new FileFilter (filter);
+
+ UpdateFilters ();
+ }
+ }
+
+ [DefaultValue(1)]
+ public int FilterIndex {
+ get {
+ return filterIndex;
+ }
+
+ set {
+ if (fileFilter != null && fileFilter.FilterArrayList.Count > value)
+ return; // FIXME: throw an exception ?
+
+ filterIndex = value;
+
+ SelectFilter ();
+ }
+ }
+
+ [DefaultValue("")]
+ public string InitialDirectory {
+ get {
+ return initialDirectory;
+ }
+
+ set {
+ if (Directory.Exists (value)) {
+ initialDirectory = value;
+ start_dir = value;
+
+ ChangeDirectory (null, initialDirectory);
+ }
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool RestoreDirectory {
+ get {
+ return restoreDirectory;
+ }
+
+ set {
+ restoreDirectory = value;
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool ShowHelp {
+ get {
+ return showHelp;
+ }
+
+ set {
+ showHelp = value;
+ ResizeAndRelocateForHelpOrReadOnly ();
+ }
+ }
+
+ [DefaultValue("")]
+ [Localizable(true)]
+ public string Title {
+ get {
+ return title;
+ }
+
+ set {
+ title = value;
+
+ form.Text = title;
+ }
+ }
+
+ // this one is a hard one ;)
+ // Win32 filename:
+ // - up to MAX_PATH characters (windef.h) = 260
+ // - no trailing dots or spaces
+ // - case preserving
+ // - etc...
+ // NTFS/Posix filename:
+ // - up to 32,768 Unicode characters
+ // - trailing periods or spaces
+ // - case sensitive
+ // - etc...
+ [DefaultValue(true)]
+ public bool ValidateNames {
+ get {
+ return validateNames;
+ }
+
+ set {
+ validateNames = value;
+ }
+ }
+
+ public override void Reset ()
+ {
+ addExtension = true;
+ checkFileExists = false;
+ checkPathExists = true;
+ defaultExt = "";
+ dereferenceLinks = true;
+ fileName = "";
+ fileNames = null;
+ Filter = "";
+ filterIndex = 1;
+ initialDirectory = "";
+ restoreDirectory = false;
+ ShowHelp = false;
+ Title = "";
+ validateNames = true;
+
+ UpdateFilters ();
+ }
+
+ public override string ToString ()
+ {
+ return base.ToString ();
+ }
+
+ public event CancelEventHandler FileOk {
+ add { Events.AddHandler (EventFileOk, value); }
+ remove { Events.RemoveHandler (EventFileOk, value); }
+ }
+
+ protected virtual IntPtr Instance {
+ get {
+ if (form == null)
+ return IntPtr.Zero;
+ return form.Handle;
+ }
+ }
+
+ // This is just for internal use with MSs version, so it doesn't need to be implemented
+ // as it can't really be accessed anyways
+ protected int Options {
+ get { return -1; }
+ }
+
+ [MonoTODO]
+ protected override IntPtr HookProc (IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected void OnFileOk (CancelEventArgs e)
+ {
+ CancelEventHandler fo = (CancelEventHandler) Events [EventFileOk];
+ if (fo != null)
+ fo (this, e);
+ }
+
+ [MonoTODO]
+ protected override bool RunDialog (IntPtr hWndOwner)
+ {
+ form.Refresh ();
+
+ if (last_dir_when_opened_or_saved != String.Empty)
+ ChangeDirectory (null, last_dir_when_opened_or_saved);
+ else
+ ChangeDirectory (null, start_dir);
+
+ fileNameComboBox.Select ();
+
+ return true;
+ }
+
+ internal virtual bool ShowReadOnly {
+ set {
+ showReadOnly = value;
+ ResizeAndRelocateForHelpOrReadOnly ();
+ }
+
+ get {
+ return showReadOnly;
+ }
+ }
+
+ internal virtual bool ReadOnlyChecked {
+ set {
+ readOnlyChecked = value;
+ readonlyCheckBox.Checked = value;
+ }
+
+ get {
+ return readOnlyChecked;
+ }
+ }
+
+ internal bool BMultiSelect {
+ set {
+ multiSelect = value;
+ mwfFileView.MultiSelect = value;
+ }
+
+ get {
+ return multiSelect;
+ }
+ }
+
+ internal string OpenSaveButtonText {
+ set {
+ openSaveButton.Text = value;
+ }
+ }
+
+ internal string SearchSaveLabel {
+ set {
+ searchSaveLabel.Text = value;
+ }
+ }
+
+ private void SelectFilter ()
+ {
+ do_not_call_OnSelectedIndexChangedFileTypeComboBox = true;
+ fileTypeComboBox.BeginUpdate ();
+ fileTypeComboBox.SelectedIndex = FilterIndex - 1;
+ fileTypeComboBox.EndUpdate ();
+
+ mwfFileView.FilterIndex = FilterIndex;
+
+ mwfFileView.UpdateFileView (currentDirectoryInfo_or_current_special_case);
+ }
+
+ private bool SetFileName (string fname)
+ {
+ bool rooted = Path.IsPathRooted (fname);
+
+ if (!rooted) {
+ if (File.Exists (Path.Combine (currentDirectoryName, fname))) {
+ fileNameComboBox.Text = fname;
+ mwfFileView.SetSelectedIndexTo (fname);
+
+ return true;
+ } else
+ return false;
+ } else {
+ if (File.Exists (fname)) {
+ fileNameComboBox.Text = Path.GetFileName (fname);
+ ChangeDirectory (null, Path.GetDirectoryName (fname));
+ mwfFileView.SetSelectedIndexTo (fname);
+
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ void OnClickContextMenu (object sender, EventArgs e)
+ {
+ MenuItem senderMenuItem = sender as MenuItem;
+
+ if (senderMenuItem.Index == 0) {
+ senderMenuItem.Checked = !senderMenuItem.Checked;
+ showHiddenFiles = senderMenuItem.Checked;
+ mwfFileView.ShowHiddenFiles = showHiddenFiles;
+ mwfFileView.UpdateFileView (currentDirectoryInfo_or_current_special_case);
+ }
+ }
+
+ void OnClickOpenSaveButton (object sender, EventArgs e)
+ {
+ if (mwfFileView.SelectedItems [0] != null) {
+ string path = Path.Combine (currentDirectoryName, mwfFileView.SelectedItems [0].Text);
+ if (Directory.Exists (path)) {
+ ChangeDirectory (null, path);
+ openSaveButton.Select ();
+ return;
+ }
+ }
+
+ if (!multiSelect) {
+ if (!show_special_case) {
+ string fileFromComboBox = fileNameComboBox.Text.Trim ();
+
+ if (fileFromComboBox.Length > 0) {
+ if (!Path.IsPathRooted (fileFromComboBox))
+ fileFromComboBox = Path.Combine (currentDirectoryName, fileFromComboBox);
+
+ FileInfo fileInfo = new FileInfo (fileFromComboBox);
+ if (fileInfo.Exists)
+ currentFileName = fileFromComboBox;
+ else {
+ DirectoryInfo dirInfo = new DirectoryInfo (fileFromComboBox);
+ if (dirInfo.Exists) {
+ ChangeDirectory (null, dirInfo.FullName);
+
+ currentFileName = "";
+
+ fileNameComboBox.Text = " ";
+ return;
+ }
+ }
+ } else
+ return;
+ } else {
+ if (currentFileName == null || currentFileName == String.Empty) {
+ currentFileName = fileNameComboBox.Text.Trim ();
+
+ if (currentFileName.Length > 0) {
+ FileInfo fileInfo = new FileInfo (currentFileName);
+ if (!fileInfo.Exists) {
+ DirectoryInfo dirInfo = new DirectoryInfo (currentFileName);
+ if (dirInfo.Exists) {
+ ChangeDirectory (null, dirInfo.FullName);
+
+ currentFileName = "";
+
+ fileNameComboBox.Text = " ";
+ return;
+ }
+ }
+ } else
+ return;
+ }
+
+ if (currentDirectoryName == String.Empty)
+ currentDirectoryName = Path.GetDirectoryName (currentFileName);
+ }
+
+ if (fileDialogType == FileDialogType.OpenFileDialog) {
+ if (checkFileExists) {
+ if (!File.Exists (currentFileName)) {
+ string message = "\"" + currentFileName + "\" doesn't exist. Please verify that you have entered the correct file name.";
+ MessageBox.Show (message, openSaveButton.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
+
+ currentFileName = "";
+
+ return;
+ }
+ }
+ } else {
+ if (overwritePrompt) {
+ if (File.Exists (currentFileName)) {
+ string message = "\"" + currentFileName + "\" exists. Overwrite ?";
+ DialogResult dr = MessageBox.Show (message, openSaveButton.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
+
+ if (dr == DialogResult.Cancel) {
+ currentFileName = "";
+
+ return;
+ }
+ }
+ }
+
+ if (createPrompt) {
+ if (!File.Exists (currentFileName)) {
+ string message = "\"" + currentFileName + "\" doesn't exist. Create ?";
+ DialogResult dr = MessageBox.Show (message, openSaveButton.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
+
+ if (dr == DialogResult.Cancel) {
+ currentFileName = "";
+
+ return;
+ }
+ }
+ }
+ }
+
+ if (fileDialogType == FileDialogType.SaveFileDialog) {
+ if (addExtension && defaultExt.Length > 0) {
+ if (!currentFileName.EndsWith (defaultExt)) {
+ currentFileName += "." + defaultExt;
+ }
+ }
+ }
+
+ fileNames = new string [1];
+
+ fileNames [0] = currentFileName;
+
+ fileName = currentFileName;
+
+ WriteRecentlyUsed ();
+ } else // multiSelect = true
+ if (fileDialogType != FileDialogType.SaveFileDialog) {
+ if (mwfFileView.SelectedItems.Count > 0) {
+ // first remove all selected directories
+ ArrayList al = new ArrayList ();
+
+ foreach (ListViewItem lvi in mwfFileView.SelectedItems) {
+ FileStruct fileStruct = (FileStruct)mwfFileView.FileHashtable [lvi.Text];
+
+ if (fileStruct.attributes != FileAttributes.Directory) {
+ al.Add (fileStruct);
+ }
+ }
+
+ fileName = ((FileStruct)al [0]).fullname;
+
+ fileNames = new string [al.Count];
+
+ for (int i = 0; i < al.Count; i++) {
+ fileNames [i] = ((FileStruct)al [i]).fullname;
+ }
+ }
+ }
+
+ if (checkPathExists) {
+ if (!Directory.Exists (currentDirectoryName)) {
+ string message = "\"" + currentDirectoryName + "\" doesn't exist. Please verify that you have entered the correct directory name.";
+ MessageBox.Show (message, openSaveButton.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
+
+ if (initialDirectory == String.Empty)
+ currentDirectoryName = Environment.CurrentDirectory;
+ else
+ currentDirectoryName = initialDirectory;
+
+ return;
+ }
+ }
+
+ if (restoreDirectory)
+ currentDirectoryName = restoreDirectoryString;
+
+ if (current_special_case != String.Empty)
+ last_dir_when_opened_or_saved = current_special_case;
+ else
+ last_dir_when_opened_or_saved = currentDirectoryName;
+
+ CancelEventArgs cancelEventArgs = new CancelEventArgs ();
+
+ cancelEventArgs.Cancel = false;
+
+ OnFileOk (cancelEventArgs);
+
+ form.DialogResult = DialogResult.OK;
+ }
+
+ void OnClickCancelButton (object sender, EventArgs e)
+ {
+ if (restoreDirectory)
+ currentDirectoryName = restoreDirectoryString;
+
+ CancelEventArgs cancelEventArgs = new CancelEventArgs ();
+
+ cancelEventArgs.Cancel = true;
+
+ OnFileOk (cancelEventArgs);
+
+ form.DialogResult = DialogResult.Cancel;
+ }
+
+ void OnClickHelpButton (object sender, EventArgs e)
+ {
+ OnHelpRequest (e);
+ }
+
+ void OnClickSmallButtonToolBar (object sender, ToolBarButtonClickEventArgs e)
+ {
+ if (e.Button == upToolBarButton) {
+ if (currentDirectoryInfo != null && currentDirectoryInfo.Parent != null)
+ ChangeDirectory (null, currentDirectoryInfo.Parent.FullName);
+ } else
+ if (e.Button == backToolBarButton) {
+ PopDirectory ();
+ } else
+ if (e.Button == newdirToolBarButton) {
+
+ }
+ }
+
+ void OnClickMenuToolBarContextMenu (object sender, EventArgs e)
+ {
+ MenuItem senderMenuItem = (MenuItem)sender;
+
+ previousCheckedMenuItem.Checked = false;
+ senderMenuItem.Checked = true;
+ previousCheckedMenuItem = senderMenuItem;
+
+ // FIXME...
+
+ switch (senderMenuItem.Index) {
+ case 0:
+ mwfFileView.View = View.SmallIcon;
+ break;
+ case 1:
+ mwfFileView.View = View.LargeIcon;
+ break;
+ case 2:
+ mwfFileView.View = View.LargeIcon;
+ break;
+ case 3:
+ mwfFileView.View = View.List;
+ break;
+ case 4:
+ mwfFileView.View = View.Details;
+ break;
+ default:
+ break;
+ }
+
+
+ mwfFileView.UpdateFileView (currentDirectoryInfo_or_current_special_case);
+ }
+
+ void OnSelectedIndexChangedFileTypeComboBox (object sender, EventArgs e)
+ {
+ if (do_not_call_OnSelectedIndexChangedFileTypeComboBox) {
+ do_not_call_OnSelectedIndexChangedFileTypeComboBox = false;
+ return;
+ }
+
+ filterIndex = fileTypeComboBox.SelectedIndex + 1;
+
+ mwfFileView.FilterIndex = filterIndex;
+
+ mwfFileView.UpdateFileView (currentDirectoryInfo_or_current_special_case);
+ }
+
+ void OnSelectedFileChangedFileView (object sender, EventArgs e)
+ {
+ fileNameComboBox.Text = mwfFileView.FileName;
+ currentFileName = mwfFileView.FullFileName;
+ }
+
+ void OnDirectoryChangedFileView (object sender, EventArgs e)
+ {
+ ChangeDirectory (sender, mwfFileView.FullFileName);
+ }
+
+ void OnForceDialogEndFileView (object sender, EventArgs e)
+ {
+ ForceDialogEnd ();
+ }
+
+ void OnSelectedFilesChangedFileView (object sender, EventArgs e)
+ {
+ fileNameComboBox.Text = mwfFileView.SelectedFilesString;
+ }
+
+ void OnDirectoryChangedDirComboBox (object sender, EventArgs e)
+ {
+ ChangeDirectory (sender, dirComboBox.CurrentPath);
+ }
+
+ void OnCheckCheckChanged (object sender, EventArgs e)
+ {
+ ReadOnlyChecked = readonlyCheckBox.Checked;
+ }
+
+ void OnDirectoryUp (Object sender, EventArgs e)
+ {
+ if (currentDirectoryInfo != null && currentDirectoryInfo.Parent != null)
+ ChangeDirectory (null, currentDirectoryInfo.Parent.FullName);
+
+ // make mwfFileView the active control
+ mwfFileView.Select ();
+ }
+
+ private void UpdateFilters ()
+ {
+ ArrayList filters = fileFilter.FilterArrayList;
+
+ fileTypeComboBox.BeginUpdate ();
+
+ fileTypeComboBox.Items.Clear ();
+
+ foreach (FilterStruct fs in filters) {
+ fileTypeComboBox.Items.Add (fs.filterName);
+ }
+
+ fileTypeComboBox.SelectedIndex = FilterIndex - 1;
+
+ fileTypeComboBox.EndUpdate ();
+
+ mwfFileView.FilterArrayList = filters;
+
+ mwfFileView.FilterIndex = FilterIndex;
+
+ mwfFileView.UpdateFileView (currentDirectoryInfo_or_current_special_case);
+ }
+
+ internal void ChangeDirectory (object sender, string path_or_special_case)
+ {
+ show_special_case = false;
+
+ if (sender != dirComboBox)
+ dirComboBox.CurrentPath = path_or_special_case;
+
+ if (sender != popupButtonPanel)
+ popupButtonPanel.SetPopupButtonStateByPath (path_or_special_case);
+
+ if (currentDirectoryInfo != null)
+ PushDirectory (currentDirectoryInfo);
+ else
+ PushDirectory (current_special_case);
+
+ if (path_or_special_case == recently_string) {
+ currentDirectoryName = String.Empty;
+
+ currentDirectoryInfo = null;
+ show_special_case = true;
+
+ current_special_case = recently_string;
+
+ mwfFileView.UpdateFileView (recently_string);
+
+ } else if (path_or_special_case == mycomputer_string) {
+ currentDirectoryName = String.Empty;
+
+ currentDirectoryInfo = null;
+ show_special_case = true;
+
+ current_special_case = mycomputer_string;
+
+ mwfFileView.UpdateFileView (mycomputer_string);
+
+ } else if (path_or_special_case == network_string) {
+ currentDirectoryName = String.Empty;
+
+ currentDirectoryInfo = null;
+ show_special_case = true;
+
+ current_special_case = network_string;
+
+ mwfFileView.UpdateFileView (network_string);
+
+ } else {
+ currentDirectoryName = path_or_special_case;
+
+ current_special_case = "";
+
+ currentDirectoryInfo = new DirectoryInfo (path_or_special_case);
+
+ mwfFileView.UpdateFileView (currentDirectoryInfo);
+ }
+ }
+
+ private void ForceDialogEnd ()
+ {
+ OnClickOpenSaveButton (this, EventArgs.Empty);
+ }
+
+ private void PushDirectory (object directoryInfo_or_string)
+ {
+ directoryStack.Push (directoryInfo_or_string);
+ backToolBarButton.Enabled = (directoryStack.Count > 1);
+ }
+
+ private void PopDirectory ()
+ {
+ if (directoryStack.Count == 0)
+ return;
+
+ show_special_case = false;
+
+ object directoryInfo_or_string = directoryStack.Pop ();
+
+ if (directoryInfo_or_string is DirectoryInfo) {
+ currentDirectoryInfo = directoryInfo_or_string as DirectoryInfo;
+
+ currentDirectoryName = currentDirectoryInfo.FullName;
+
+ current_special_case = String.Empty;
+ } else
+ if (directoryInfo_or_string is string) {
+ currentDirectoryInfo = null;
+ currentDirectoryName = String.Empty;
+ show_special_case = true;
+ current_special_case = directoryInfo_or_string as string;
+ }
+
+ backToolBarButton.Enabled = (directoryStack.Count > 1);
+
+ dirComboBox.CurrentPath = currentDirectoryName_or_special_case;
+
+ popupButtonPanel.SetPopupButtonStateByPath (currentDirectoryName_or_special_case);
+
+ mwfFileView.UpdateFileView (currentDirectoryInfo_or_current_special_case);
+ }
+
+ private void ResizeAndRelocateForHelpOrReadOnly ()
+ {
+ form.SuspendLayout ();
+ if (ShowHelp || ShowReadOnly) {
+ mwfFileView.Size = new Size (449, 250);
+ fileNameLabel.Location = new Point (102, 298);
+ fileNameComboBox.Location = new Point (195, 298);
+ fileTypeLabel.Location = new Point (102, 324);
+ fileTypeComboBox.Location = new Point (195, 324);
+ openSaveButton.Location = new Point (475, 298);
+ cancelButton.Location = new Point (475, 324);
+ } else {
+ mwfFileView.Size = new Size (449, 282);
+ fileNameLabel.Location = new Point (102, 330);
+ fileNameComboBox.Location = new Point (195, 330);
+ fileTypeLabel.Location = new Point (102, 356);
+ fileTypeComboBox.Location = new Point (195, 356);
+ openSaveButton.Location = new Point (475, 330);
+ cancelButton.Location = new Point (475, 356);
+ }
+
+ if (ShowHelp)
+ form.Controls.Add (helpButton);
+ else
+ form.Controls.Remove (helpButton);
+
+ if (ShowReadOnly)
+ form.Controls.Add (readonlyCheckBox);
+ else
+ form.Controls.Remove (readonlyCheckBox);
+ form.ResumeLayout ();
+ }
+
+ private void WriteRecentlyUsed ()
+ {
+ int platform = (int) Environment.OSVersion.Platform;
+
+ // on a *nix platform we use "$HOME/.recently-used" to store our recently used files (GNOME, libegg like)
+ if ((platform == 4) || (platform == 128)) {
+ string personal_folder = ThemeEngine.Current.Places (UIIcon.PlacesPersonal);
+ string recently_used_path = Path.Combine (personal_folder, ".recently-used");
+
+ if (File.Exists (recently_used_path) && new FileInfo (recently_used_path).Length > 0) {
+ XmlDocument xml_doc = new XmlDocument ();
+ xml_doc.Load (recently_used_path);
+
+ XmlNode grand_parent_node = xml_doc.SelectSingleNode ("RecentFiles");
+
+ if (grand_parent_node != null) {
+ // create a new element
+ XmlElement new_recent_item_node = xml_doc.CreateElement ("RecentItem");
+
+ XmlElement new_child = xml_doc.CreateElement ("URI");
+ UriBuilder ub = new UriBuilder ();
+ ub.Path = currentFileName;
+ ub.Host = null;
+ ub.Scheme = "file";
+ XmlText new_text_child = xml_doc.CreateTextNode (ub.ToString ());
+ new_child.AppendChild (new_text_child);
+
+ new_recent_item_node.AppendChild (new_child);
+
+ new_child = xml_doc.CreateElement ("Mime-Type");
+ new_text_child = xml_doc.CreateTextNode (Mime.GetMimeTypeForFile (currentFileName));
+ new_child.AppendChild (new_text_child);
+
+ new_recent_item_node.AppendChild (new_child);
+
+ new_child = xml_doc.CreateElement ("Timestamp");
+ long seconds = (long)(DateTime.UtcNow - new DateTime (1970, 1, 1)).TotalSeconds;
+ new_text_child = xml_doc.CreateTextNode (seconds.ToString ());
+ new_child.AppendChild (new_text_child);
+
+ new_recent_item_node.AppendChild (new_child);
+
+ new_child = xml_doc.CreateElement ("Groups");
+
+ new_recent_item_node.AppendChild (new_child);
+
+ // now search the nodes in grand_parent_node for another instance of the new uri and if found remove it
+ // so that the new node is the first one
+ foreach (XmlNode n in grand_parent_node.ChildNodes) {
+ XmlNode uri_node = n.SelectSingleNode ("URI");
+ if (uri_node != null) {
+ XmlNode uri_node_child = uri_node.FirstChild;
+ if (uri_node_child is XmlText)
+ if (ub.ToString () == ((XmlText)uri_node_child).Data) {
+ grand_parent_node.RemoveChild (n);
+ break;
+ }
+ }
+ }
+
+ // prepend the new recent item to the grand parent node list
+ grand_parent_node.PrependChild (new_recent_item_node);
+
+ // limit the # of RecentItems to 10
+ if (grand_parent_node.ChildNodes.Count > 10) {
+ while (grand_parent_node.ChildNodes.Count > 10)
+ grand_parent_node.RemoveChild (grand_parent_node.LastChild);
+ }
+
+ try {
+ xml_doc.Save (recently_used_path);
+ } catch ( Exception e ) {
+ }
+ }
+ } else {
+ XmlDocument xml_doc = new XmlDocument ();
+ xml_doc.AppendChild (xml_doc.CreateXmlDeclaration ("1.0", "", ""));
+
+ XmlElement recentFiles_element = xml_doc.CreateElement ("RecentFiles");
+
+ XmlElement new_recent_item_node = xml_doc.CreateElement ("RecentItem");
+
+ XmlElement new_child = xml_doc.CreateElement ("URI");
+ UriBuilder ub = new UriBuilder ();
+ ub.Path = currentFileName;
+ ub.Host = null;
+ ub.Scheme = "file";
+ XmlText new_text_child = xml_doc.CreateTextNode (ub.ToString ());
+ new_child.AppendChild (new_text_child);
+
+ new_recent_item_node.AppendChild (new_child);
+
+ new_child = xml_doc.CreateElement ("Mime-Type");
+ new_text_child = xml_doc.CreateTextNode (Mime.GetMimeTypeForFile (currentFileName));
+ new_child.AppendChild (new_text_child);
+
+ new_recent_item_node.AppendChild (new_child);
+
+ new_child = xml_doc.CreateElement ("Timestamp");
+ long seconds = (long)(DateTime.UtcNow - new DateTime (1970, 1, 1)).TotalSeconds;
+ new_text_child = xml_doc.CreateTextNode (seconds.ToString ());
+ new_child.AppendChild (new_text_child);
+
+ new_recent_item_node.AppendChild (new_child);
+
+ new_child = xml_doc.CreateElement ("Groups");
+
+ new_recent_item_node.AppendChild (new_child);
+
+ recentFiles_element.AppendChild (new_recent_item_node);
+
+ xml_doc.AppendChild (recentFiles_element);
+
+ try {
+ xml_doc.Save (recently_used_path);
+ } catch ( Exception e ) {
+ }
+ }
+ }
+ }
+
+ private object currentDirectoryInfo_or_current_special_case {
+ get {
+ if (currentDirectoryInfo != null)
+ return currentDirectoryInfo;
+ else
+ return current_special_case;
+ }
+ }
+
+ private string currentDirectoryName_or_special_case {
+ get {
+ if (currentDirectoryName != String.Empty)
+ return currentDirectoryName;
+ else
+ return current_special_case;
+ }
+ }
+
+ internal class PopupButtonPanel : Panel {
+ internal class PopupButton : Control {
+ internal enum PopupButtonState { Normal, Down, Up}
+
+ private Image image = null;
+ private PopupButtonState popupButtonState = PopupButtonState.Normal;
+ private StringFormat text_format = new StringFormat();
+
+ public PopupButton ()
+ {
+ text_format.Alignment = StringAlignment.Center;
+ text_format.LineAlignment = StringAlignment.Far;
+
+ SetStyle (ControlStyles.DoubleBuffer, true);
+ SetStyle (ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle (ControlStyles.UserPaint, true);
+ }
+
+ public Image Image {
+ set {
+ image = value;
+ Refresh ();
+ }
+
+ get {
+ return image;
+ }
+ }
+
+ public PopupButtonState ButtonState {
+ set {
+ popupButtonState = value;
+ Refresh ();
+ }
+
+ get {
+ return popupButtonState;
+ }
+ }
+
+ protected override void OnPaint (PaintEventArgs pe)
+ {
+ Draw (pe);
+
+ base.OnPaint (pe);
+ }
+
+ private void Draw (PaintEventArgs pe)
+ {
+ Graphics gr = pe.Graphics;
+
+ gr.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (BackColor), ClientRectangle);
+
+ // draw image
+ if (image != null) {
+ int i_x = (ClientSize.Width - image.Width) / 2;
+ int i_y = 4;
+ gr.DrawImage (image, i_x, i_y);
+ }
+
+ if (Text != String.Empty) {
+ Rectangle text_rect = Rectangle.Inflate (ClientRectangle, -4, 0);
+
+ gr.DrawString (Text, Font, ThemeEngine.Current.ResPool.GetSolidBrush (ForeColor), text_rect, text_format);
+ }
+
+ switch (popupButtonState) {
+ case PopupButtonState.Up:
+ gr.DrawLine (ThemeEngine.Current.ResPool.GetPen (Color.White), 0, 0, ClientSize.Width - 1, 0);
+ gr.DrawLine (ThemeEngine.Current.ResPool.GetPen (Color.White), 0, 0, 0, ClientSize.Height - 1);
+ gr.DrawLine (ThemeEngine.Current.ResPool.GetPen (Color.Black), ClientSize.Width - 1, 0, ClientSize.Width - 1, ClientSize.Height - 1);
+ gr.DrawLine (ThemeEngine.Current.ResPool.GetPen (Color.Black), 0, ClientSize.Height - 1, ClientSize.Width - 1, ClientSize.Height - 1);
+ break;
+
+ case PopupButtonState.Down:
+ gr.DrawLine (ThemeEngine.Current.ResPool.GetPen (Color.Black), 0, 0, ClientSize.Width - 1, 0);
+ gr.DrawLine (ThemeEngine.Current.ResPool.GetPen (Color.Black), 0, 0, 0, ClientSize.Height - 1);
+ gr.DrawLine (ThemeEngine.Current.ResPool.GetPen (Color.White), ClientSize.Width - 1, 0, ClientSize.Width - 1, ClientSize.Height - 1);
+ gr.DrawLine (ThemeEngine.Current.ResPool.GetPen (Color.White), 0, ClientSize.Height - 1, ClientSize.Width - 1, ClientSize.Height - 1);
+ break;
+ }
+ }
+
+ protected override void OnMouseEnter (EventArgs e)
+ {
+ if (popupButtonState != PopupButtonState.Down)
+ popupButtonState = PopupButtonState.Up;
+ Refresh ();
+ base.OnMouseEnter (e);
+ }
+
+ protected override void OnMouseLeave (EventArgs e)
+ {
+ if (popupButtonState != PopupButtonState.Down)
+ popupButtonState = PopupButtonState.Normal;
+ Refresh ();
+ base.OnMouseLeave (e);
+ }
+
+ protected override void OnClick (EventArgs e)
+ {
+ popupButtonState = PopupButtonState.Down;
+ Refresh ();
+ base.OnClick (e);
+ }
+ }
+
+ private FileDialog fileDialog;
+
+ private PopupButton recentlyusedButton;
+ private PopupButton desktopButton;
+ private PopupButton personalButton;
+ private PopupButton mycomputerButton;
+ private PopupButton networkButton;
+
+ private PopupButton lastPopupButton = null;
+
+ private int platform = (int) Environment.OSVersion.Platform;
+
+ public PopupButtonPanel (FileDialog fileDialog)
+ {
+ this.fileDialog = fileDialog;
+
+ SuspendLayout ();
+
+ BorderStyle = BorderStyle.Fixed3D;
+ BackColor = Color.FromArgb (128, 128, 128);
+ Size = new Size (85, 336);
+
+ recentlyusedButton = new PopupButton ();
+ desktopButton = new PopupButton ();
+ personalButton = new PopupButton ();
+ mycomputerButton = new PopupButton ();
+ networkButton = new PopupButton ();
+
+ recentlyusedButton.Size = new Size (82, 64);
+ recentlyusedButton.Image = ThemeEngine.Current.Images (UIIcon.PlacesRecentDocuments, 38);
+ recentlyusedButton.BackColor = BackColor;
+ recentlyusedButton.ForeColor = Color.White;
+ recentlyusedButton.Location = new Point (2, 2);
+ recentlyusedButton.Text = "Recently\nused";
+ recentlyusedButton.Click += new EventHandler (OnClickButton);
+
+ desktopButton.Image = ThemeEngine.Current.Images (UIIcon.PlacesDesktop, 38);
+ desktopButton.BackColor = BackColor;
+ desktopButton.ForeColor = Color.White;
+ desktopButton.Size = new Size (82, 64);
+ desktopButton.Location = new Point (2, 66);
+ desktopButton.Text = "Desktop";
+ desktopButton.Click += new EventHandler (OnClickButton);
+
+ personalButton.Image = ThemeEngine.Current.Images (UIIcon.PlacesPersonal, 38);
+ personalButton.BackColor = BackColor;
+ personalButton.ForeColor = Color.White;
+ personalButton.Size = new Size (82, 64);
+ personalButton.Location = new Point (2, 130);
+ personalButton.Text = "Personal";
+ personalButton.Click += new EventHandler (OnClickButton);
+
+ mycomputerButton.Image = ThemeEngine.Current.Images (UIIcon.PlacesMyComputer, 38);
+ mycomputerButton.BackColor = BackColor;
+ mycomputerButton.ForeColor = Color.White;
+ mycomputerButton.Size = new Size (82, 64);
+ mycomputerButton.Location = new Point (2, 194);
+ mycomputerButton.Text = "My Computer";
+ mycomputerButton.Click += new EventHandler (OnClickButton);
+
+ networkButton.Image = ThemeEngine.Current.Images (UIIcon.PlacesMyNetwork, 38);
+ networkButton.BackColor = BackColor;
+ networkButton.ForeColor = Color.White;
+ networkButton.Size = new Size (82, 64);
+ networkButton.Location = new Point (2, 258);
+ networkButton.Text = "My Network";
+ networkButton.Click += new EventHandler (OnClickButton);
+
+ Controls.Add (recentlyusedButton);
+ Controls.Add (desktopButton);
+ Controls.Add (personalButton);
+ Controls.Add (mycomputerButton);
+ Controls.Add (networkButton);
+
+ ResumeLayout (false);
+ }
+
+ void OnClickButton (object sender, EventArgs e)
+ {
+ if (lastPopupButton != null && (PopupButton)sender != lastPopupButton)
+ lastPopupButton.ButtonState = PopupButton.PopupButtonState.Normal;
+ lastPopupButton = sender as PopupButton;
+
+ if (sender == recentlyusedButton) {
+ if ((platform == 4) || (platform == 128))
+ // do NOT change the following line!
+ // FileDialog uses a special handling for recently used files on *nix
+ // recently used files are not stored as links in a directory but
+ // as a xml file called .recently-used in the users home dir
+ // This matches the Freedesktop.org spec which gnome uses
+ fileDialog.ChangeDirectory (this, FileDialog.recently_string);
+ else
+ fileDialog.ChangeDirectory (this, ThemeEngine.Current.Places (UIIcon.PlacesRecentDocuments));
+ } else
+ if (sender == desktopButton) {
+ fileDialog.ChangeDirectory (this, ThemeEngine.Current.Places (UIIcon.PlacesDesktop));
+ } else
+ if (sender == personalButton) {
+ fileDialog.ChangeDirectory (this, ThemeEngine.Current.Places (UIIcon.PlacesPersonal));
+ } else
+ if (sender == mycomputerButton) {
+ if ((platform == 4) || (platform == 128))
+ // do NOT change the following line!
+ // on *nix we do not have a special folder MyComputer
+ fileDialog.ChangeDirectory (this, FileDialog.mycomputer_string);
+ else
+ fileDialog.ChangeDirectory (this, ThemeEngine.Current.Places (UIIcon.PlacesMyComputer));
+ } else
+ if (sender == networkButton) {
+ if ((platform == 4) || (platform == 128))
+ fileDialog.ChangeDirectory (this, FileDialog.network_string);
+ else
+ fileDialog.ChangeDirectory (this, ThemeEngine.Current.Places (UIIcon.PlacesMyNetwork));
+ }
+ }
+
+ public void SetPopupButtonStateByPath (string path)
+ {
+ if (path == FileDialog.recently_string ||
+ path == ThemeEngine.Current.Places (UIIcon.PlacesRecentDocuments)) {
+ if (lastPopupButton != recentlyusedButton) {
+ if (lastPopupButton != null)
+ lastPopupButton.ButtonState = PopupButton.PopupButtonState.Normal;
+ recentlyusedButton.ButtonState = PopupButton.PopupButtonState.Down;
+ lastPopupButton = recentlyusedButton;
+ }
+ } else
+ if (path == ThemeEngine.Current.Places (UIIcon.PlacesDesktop)) {
+ if (lastPopupButton != desktopButton) {
+ if (lastPopupButton != null)
+ lastPopupButton.ButtonState = PopupButton.PopupButtonState.Normal;
+ desktopButton.ButtonState = PopupButton.PopupButtonState.Down;
+ lastPopupButton = desktopButton;
+ }
+ } else
+ if (path == ThemeEngine.Current.Places (UIIcon.PlacesPersonal)) {
+ if (lastPopupButton != personalButton) {
+ if (lastPopupButton != null)
+ lastPopupButton.ButtonState = PopupButton.PopupButtonState.Normal;
+ personalButton.ButtonState = PopupButton.PopupButtonState.Down;
+ lastPopupButton = personalButton;
+ }
+ } else
+ if (path == FileDialog.mycomputer_string ||
+ path == ThemeEngine.Current.Places (UIIcon.PlacesMyComputer)) {
+ if (lastPopupButton != mycomputerButton) {
+ if (lastPopupButton != null)
+ lastPopupButton.ButtonState = PopupButton.PopupButtonState.Normal;
+ mycomputerButton.ButtonState = PopupButton.PopupButtonState.Down;
+ lastPopupButton = mycomputerButton;
+ }
+ } else
+ if (path == FileDialog.network_string ||
+ path == ThemeEngine.Current.Places (UIIcon.PlacesMyNetwork)) {
+ if (lastPopupButton != networkButton) {
+ if (lastPopupButton != null)
+ lastPopupButton.ButtonState = PopupButton.PopupButtonState.Normal;
+ networkButton.ButtonState = PopupButton.PopupButtonState.Down;
+ lastPopupButton = networkButton;
+ }
+ } else {
+ if (lastPopupButton != null) {
+ lastPopupButton.ButtonState = PopupButton.PopupButtonState.Normal;
+ lastPopupButton = null;
+ }
+ }
+ }
+ }
+ }
+
+ internal struct FilterStruct {
+ public string filterName;
+ public StringCollection filters;
+
+ public FilterStruct (string filterName, string filter)
+ {
+ this.filterName = filterName;
+
+ filters = new StringCollection ();
+
+ SplitFilters (filter);
+ }
+
+ private void SplitFilters (string filter)
+ {
+ string[] split = filter.Split (new char [] {';'});
+
+ filters.AddRange (split);
+ }
+ }
+
+ internal struct FileStruct {
+ public enum FileStructType {
+ File,
+ Directoy,
+ Device,
+ Network
+ }
+
+ public string fullname;
+ public FileAttributes attributes;
+ public long size;
+ public FileStructType type;
+ }
+
+ // MWFFileView
+ internal class MWFFileView : ListView {
+ private ArrayList filterArrayList;
+
+ // store the FileStruct of all files in the current directory
+ private Hashtable fileHashtable = new Hashtable();
+
+ private bool showHiddenFiles = false;
+
+ private EventHandler on_selected_file_changed;
+ private EventHandler on_selected_files_changed;
+ private EventHandler on_directory_changed;
+ private EventHandler on_force_dialog_end;
+ private EventHandler on_one_directory_up;
+
+ private string fileName;
+ private string fullFileName;
+ private string selectedFilesString;
+
+ private int filterIndex;
+
+ private ToolTip toolTip;
+ private int oldItemIndexForToolTip = -1;
+
+ private bool internal_key_up = false;
+
+ private MasterMount masterMount = new MasterMount ();
+
+ public MWFFileView ()
+ {
+ SuspendLayout ();
+
+ toolTip = new ToolTip ();
+ toolTip.InitialDelay = 300;
+ toolTip.ReshowDelay = 0;
+
+ LabelWrap = true;
+
+ SmallImageList = MimeIconEngine.SmallIcons;
+ LargeImageList = MimeIconEngine.LargeIcons;
+
+ View = View.List;
+
+ ResumeLayout (false);
+
+ KeyUp += new KeyEventHandler (MWF_KeyUp);
+ }
+
+ public ArrayList FilterArrayList {
+ set {
+ filterArrayList = value;
+ }
+
+ get {
+ return filterArrayList;
+ }
+ }
+
+ public Hashtable FileHashtable {
+ get {
+ return fileHashtable;
+ }
+ }
+
+ public bool ShowHiddenFiles {
+ set {
+ showHiddenFiles = value;
+ }
+
+ get {
+ return showHiddenFiles;
+ }
+ }
+
+ public string FileName {
+ get {
+ return fileName;
+ }
+ }
+
+ public string FullFileName {
+ get {
+ return fullFileName;
+ }
+ }
+
+ public int FilterIndex {
+ set {
+ filterIndex = value;
+ }
+
+ get {
+ return filterIndex;
+ }
+ }
+
+ public string SelectedFilesString {
+ set {
+ selectedFilesString = value;
+ }
+
+ get {
+ return selectedFilesString;
+ }
+ }
+
+ public void SetSelectedIndexTo (string fname)
+ {
+ foreach (ListViewItem item in Items) {
+ if (item.Text == fname) {
+ BeginUpdate ();
+ SelectedItems.Clear ();
+ item.Selected = true;
+ EndUpdate ();
+ break;
+ }
+ }
+ }
+
+ private ArrayList GetFileInfoArrayList (DirectoryInfo directoryInfo)
+ {
+ ArrayList arrayList = new ArrayList ();
+
+ if (filterArrayList != null && filterArrayList.Count != 0) {
+ FilterStruct fs = (FilterStruct)filterArrayList [filterIndex - 1];
+
+ foreach (string s in fs.filters)
+ arrayList.AddRange (directoryInfo.GetFiles (s));
+ } else
+ arrayList.AddRange (directoryInfo.GetFiles ());
+
+ return arrayList;
+ }
+
+ private ArrayList GetFileInfoArrayListByArrayList (ArrayList al)
+ {
+ ArrayList arrayList = new ArrayList ();
+
+ foreach (string path in al) {
+ if (File.Exists (path)) {
+ FileInfo fi = new FileInfo (path);
+ arrayList.Add (fi);
+ }
+ }
+
+ return arrayList;
+ }
+
+ public void UpdateFileView (object directoryInfo_or_string)
+ {
+ if (directoryInfo_or_string is DirectoryInfo)
+ UpdateFileViewByDirectoryInfo (directoryInfo_or_string as DirectoryInfo);
+ else
+ UpdateFileViewByString (directoryInfo_or_string as string);
+
+ if (Items.Count > 0 && !internal_key_up) {
+ ListViewItem item = Items [0];
+ item.Selected = true;
+ } else
+ internal_key_up = false;
+ }
+
+ private void UpdateFileViewByDirectoryInfo (DirectoryInfo inputDirectoryInfo)
+ {
+ DirectoryInfo directoryInfo = inputDirectoryInfo;
+
+ DirectoryInfo[] directoryInfoArray = directoryInfo.GetDirectories ();
+
+ ArrayList fileInfoArrayList = GetFileInfoArrayList (directoryInfo);
+
+ fileHashtable.Clear ();
+
+ BeginUpdate ();
+
+ Items.Clear ();
+ SelectedItems.Clear ();
+
+ foreach (DirectoryInfo directoryInfoi in directoryInfoArray) {
+ if (!ShowHiddenFiles)
+ if (directoryInfoi.Name.StartsWith (".") || directoryInfoi.Attributes == FileAttributes.Hidden)
+ continue;
+
+ FileStruct fileStruct = new FileStruct ();
+ fileStruct.type = FileStruct.FileStructType.Directoy;
+
+ fileStruct.fullname = directoryInfoi.FullName;
+
+ ListViewItem listViewItem = new ListViewItem (directoryInfoi.Name);
+
+ int index = MimeIconEngine.GetIconIndexForMimeType ("inode/directory");
+
+ listViewItem.ImageIndex = index;
+
+ listViewItem.SubItems.Add ("");
+ listViewItem.SubItems.Add ("Directory");
+ listViewItem.SubItems.Add (directoryInfoi.LastAccessTime.ToShortDateString () + " " + directoryInfoi.LastAccessTime.ToShortTimeString ());
+
+ fileStruct.attributes = FileAttributes.Directory;
+
+ fileHashtable.Add (directoryInfoi.Name, fileStruct);
+
+ Items.Add (listViewItem);
+ }
+
+ foreach (FileInfo fileInfo in fileInfoArrayList) {
+ DoOneFileInfo (fileInfo);
+ }
+
+ EndUpdate ();
+ }
+
+ private void UpdateFileViewByString (string kind)
+ {
+ if (kind == FileDialog.recently_string) {
+ ArrayList fileInfoArrayList = GetFileInfoArrayListByArrayList (GetFreedesktopSpecRecentlyUsed ());
+
+ fileHashtable.Clear ();
+
+ BeginUpdate ();
+
+ Items.Clear ();
+ SelectedItems.Clear ();
+
+ foreach (FileInfo fileInfo in fileInfoArrayList) {
+ DoOneFileInfo (fileInfo);
+ }
+
+ EndUpdate ();
+
+ } else if (kind == FileDialog.mycomputer_string) {
+
+ if (masterMount.ProcMountAvailable) {
+ masterMount.GetMounts ();
+
+ fileHashtable.Clear ();
+
+ BeginUpdate ();
+
+ Items.Clear ();
+ SelectedItems.Clear ();
+
+ foreach (MasterMount.Mount mount in masterMount.Block_devices) {
+ FileStruct fileStruct = new FileStruct ();
+ fileStruct.type = FileStruct.FileStructType.Device;
+
+ fileStruct.fullname = mount.mount_point;
+
+ string item_name = "HDD (" + mount.fsType + ", " + mount.device_short + ")";
+ ListViewItem listViewItem = new ListViewItem (item_name);
+
+ int index = MimeIconEngine.GetIconIndexForMimeType ("harddisk/harddisk");
+
+ listViewItem.ImageIndex = index;
+
+ listViewItem.SubItems.Add ("");
+ listViewItem.SubItems.Add ("Harddisk");
+// listViewItem.SubItems.Add (directoryInfoi.LastAccessTime.ToShortDateString () + " " + directoryInfoi.LastAccessTime.ToShortTimeString ());
+
+ fileStruct.attributes = FileAttributes.Directory;
+
+ fileHashtable.Add (item_name, fileStruct);
+
+ Items.Add (listViewItem);
+ }
+
+ foreach (MasterMount.Mount mount in masterMount.Removable_devices) {
+ FileStruct fileStruct = new FileStruct ();
+ fileStruct.type = FileStruct.FileStructType.Device;
+
+ fileStruct.fullname = mount.mount_point;
+
+ bool is_dvd_cdrom = mount.fsType == MasterMount.FsTypes.usbfs ? false : true;
+ string type_name = is_dvd_cdrom ? "DVD/CD-Rom" : "USB";
+ string mime_type = is_dvd_cdrom ? "cdrom/cdrom" : "removable/removable";
+
+ string item_name = type_name + " (" + mount.device_short + ")";
+
+ ListViewItem listViewItem = new ListViewItem (item_name);
+
+ int index = MimeIconEngine.GetIconIndexForMimeType (mime_type);
+
+ listViewItem.ImageIndex = index;
+
+ listViewItem.SubItems.Add ("");
+ listViewItem.SubItems.Add (type_name);
+// listViewItem.SubItems.Add (directoryInfoi.LastAccessTime.ToShortDateString () + " " + directoryInfoi.LastAccessTime.ToShortTimeString ());
+
+ fileStruct.attributes = FileAttributes.Directory;
+
+ fileHashtable.Add (item_name, fileStruct);
+
+ Items.Add (listViewItem);
+ }
+
+ ListViewItem listViewItem2 = new ListViewItem ("Desktop");
+
+ int index2 = MimeIconEngine.GetIconIndexForMimeType ("desktop/desktop");
+
+ FileStruct fileStruct2 = new FileStruct ();
+ fileStruct2.type = FileStruct.FileStructType.Directoy;
+
+ fileStruct2.fullname = ThemeEngine.Current.Places (UIIcon.PlacesDesktop);
+
+ listViewItem2.ImageIndex = index2;
+
+ listViewItem2.SubItems.Add ("");
+ listViewItem2.SubItems.Add ("Desktop");
+// listViewItem.SubItems.Add (directoryInfoi.LastAccessTime.ToShortDateString () + " " + directoryInfoi.LastAccessTime.ToShortTimeString ());
+
+ fileStruct2.attributes = FileAttributes.Directory;
+
+ fileHashtable.Add ("Desktop", fileStruct2);
+
+ Items.Add (listViewItem2);
+
+
+ listViewItem2 = new ListViewItem ("Personal");
+
+ index2 = MimeIconEngine.GetIconIndexForMimeType ("directory/home");
+
+ fileStruct2 = new FileStruct ();
+ fileStruct2.type = FileStruct.FileStructType.Directoy;
+
+ fileStruct2.fullname = ThemeEngine.Current.Places (UIIcon.PlacesPersonal);
+
+ listViewItem2.ImageIndex = index2;
+
+ listViewItem2.SubItems.Add ("");
+ listViewItem2.SubItems.Add ("Personal");
+// listViewItem.SubItems.Add (directoryInfoi.LastAccessTime.ToShortDateString () + " " + directoryInfoi.LastAccessTime.ToShortTimeString ());
+
+ fileStruct2.attributes = FileAttributes.Directory;
+
+ fileHashtable.Add ("Personal", fileStruct2);
+
+ Items.Add (listViewItem2);
+
+ AddNetwork ();
+
+ EndUpdate ();
+ }
+
+ } else if (kind == FileDialog.network_string) {
+
+ if (masterMount.ProcMountAvailable) {
+ masterMount.GetMounts ();
+
+ fileHashtable.Clear ();
+
+ BeginUpdate ();
+
+ Items.Clear ();
+ SelectedItems.Clear ();
+
+ AddNetwork ();
+
+ EndUpdate ();
+ }
+ }
+ }
+
+ private void AddNetwork ()
+ {
+ foreach (MasterMount.Mount mount in masterMount.Network_devices) {
+ FileStruct fileStruct = new FileStruct ();
+ fileStruct.type = FileStruct.FileStructType.Network;
+
+ fileStruct.fullname = mount.mount_point;
+
+ string item_name = "Network (" + mount.fsType + ", " + mount.device_short + ")";
+
+ ListViewItem listViewItem = new ListViewItem (item_name);
+
+ int index = 0;
+
+ switch (mount.fsType) {
+ case MasterMount.FsTypes.nfs:
+ index = MimeIconEngine.GetIconIndexForMimeType ("nfs/nfs");
+ break;
+ case MasterMount.FsTypes.smbfs:
+ index = MimeIconEngine.GetIconIndexForMimeType ("smb/smb");
+ break;
+ case MasterMount.FsTypes.ncpfs:
+ index = MimeIconEngine.GetIconIndexForMimeType ("network/network");
+ break;
+ default:
+ break;
+ }
+
+ listViewItem.ImageIndex = index;
+
+ listViewItem.SubItems.Add ("");
+ listViewItem.SubItems.Add ("Network");
+// listViewItem.SubItems.Add (directoryInfoi.LastAccessTime.ToShortDateString () + " " + directoryInfoi.LastAccessTime.ToShortTimeString ());
+
+ fileStruct.attributes = FileAttributes.Directory;
+
+ fileHashtable.Add (item_name, fileStruct);
+
+ Items.Add (listViewItem);
+ }
+ }
+
+ private void DoOneFileInfo (FileInfo fileInfo)
+ {
+ if (!ShowHiddenFiles)
+ if (fileInfo.Name.StartsWith (".") || fileInfo.Attributes == FileAttributes.Hidden)
+ return;
+
+ FileStruct fileStruct = new FileStruct ();
+ fileStruct.type = FileStruct.FileStructType.File;
+
+ fileStruct.fullname = fileInfo.FullName;
+
+ string fileName = fileInfo.Name;
+
+ if (fileHashtable.ContainsKey (fileName)) {
+ int i = 1;
+ while (fileHashtable.ContainsKey (fileName + "[" + i + "]")) {
+ i++;
+ }
+ fileName += "[" + i + "]";
+ }
+
+ ListViewItem listViewItem = new ListViewItem (fileName);
+
+ listViewItem.ImageIndex = MimeIconEngine.GetIconIndexForFile (fileStruct.fullname);
+
+ long fileLen = 1;
+ try {
+ if (fileInfo.Length > 1024)
+ fileLen = fileInfo.Length / 1024;
+ } catch ( Exception e ) {
+ fileLen = 1;
+ }
+
+ fileStruct.size = fileLen;
+
+ listViewItem.SubItems.Add (fileLen.ToString () + " KB");
+ listViewItem.SubItems.Add ("File");
+ listViewItem.SubItems.Add (fileInfo.LastAccessTime.ToShortDateString () + " " + fileInfo.LastAccessTime.ToShortTimeString ());
+
+ fileStruct.attributes = FileAttributes.Normal;
+
+ fileHashtable.Add (fileName, fileStruct);
+
+ Items.Add (listViewItem);
+ }
+
+ private ArrayList GetFreedesktopSpecRecentlyUsed ()
+ {
+ // check for GNOME and KDE
+ string personal_folder = ThemeEngine.Current.Places (UIIcon.PlacesPersonal);
+ string recently_used_path = Path.Combine (personal_folder, ".recently-used");
+
+ ArrayList files_al = new ArrayList ();
+
+ // GNOME
+ if (File.Exists (recently_used_path)) {
+ try {
+ XmlTextReader xtr = new XmlTextReader (recently_used_path);
+ while (xtr.Read ()) {
+ if (xtr.NodeType == XmlNodeType.Element && xtr.Name.ToUpper () == "URI") {
+ xtr.Read ();
+ Uri uri = new Uri (xtr.Value);
+ if (!files_al.Contains (uri.LocalPath))
+ files_al.Add (uri.LocalPath);
+ }
+ }
+ xtr.Close ();
+ } catch ( Exception e ) {
+
+ }
+ }
+
+ // KDE
+ string full_kde_recent_document_dir = personal_folder
+ + "/"
+ + ".kde/share/apps/RecentDocuments";
+
+ if (Directory.Exists (full_kde_recent_document_dir)) {
+ string[] files = Directory.GetFiles (full_kde_recent_document_dir, "*.desktop");
+
+ foreach (string file_name in files) {
+ StreamReader sr = new StreamReader (file_name);
+
+ string line = sr.ReadLine ();
+
+ while (line != null) {
+ line = line.Trim ();
+
+ if (line.StartsWith ("URL=")) {
+ line = line.Replace ("URL=", "");
+ line = line.Replace ("$HOME", personal_folder);
+
+ Uri uri = new Uri (line);
+ if (!files_al.Contains (uri.LocalPath))
+ files_al.Add (uri.LocalPath);
+ break;
+ }
+
+ line = sr.ReadLine ();
+ }
+
+ sr.Close ();
+ }
+ }
+
+
+ return files_al;
+ }
+
+ protected override void OnClick (EventArgs e)
+ {
+ if (!MultiSelect) {
+ if (SelectedItems.Count > 0) {
+ ListViewItem listViewItem = SelectedItems [0];
+
+ FileStruct fileStruct = (FileStruct)fileHashtable [listViewItem.Text];
+
+ if (fileStruct.type == FileStruct.FileStructType.File) {
+ fileName = listViewItem.Text;
+ fullFileName = fileStruct.fullname;
+
+ if (on_selected_file_changed != null)
+ on_selected_file_changed (this, EventArgs.Empty);
+ }
+ }
+ }
+
+ base.OnClick (e);
+ }
+
+ protected override void OnDoubleClick (EventArgs e)
+ {
+ if (SelectedItems.Count > 0) {
+ ListViewItem listViewItem = SelectedItems [0];
+
+ FileStruct fileStruct = (FileStruct)fileHashtable [listViewItem.Text];
+
+ if (fileStruct.attributes == FileAttributes.Directory) {
+ fullFileName = fileStruct.fullname;
+
+ if (on_directory_changed != null)
+ on_directory_changed (this, EventArgs.Empty);
+ } else {
+ fileName = listViewItem.Text;
+ fullFileName = fileStruct.fullname;
+
+ if (on_selected_file_changed != null)
+ on_selected_file_changed (this, EventArgs.Empty);
+
+ if (on_force_dialog_end != null)
+ on_force_dialog_end (this, EventArgs.Empty);
+
+ return;
+ }
+ }
+
+ base.OnDoubleClick (e);
+ }
+
+ protected override void OnSelectedIndexChanged (EventArgs e)
+ {
+ if (MultiSelect) {
+ if (SelectedItems.Count > 0) {
+ selectedFilesString = "";
+
+ if (SelectedItems.Count == 1) {
+ FileStruct fileStruct = (FileStruct)fileHashtable [SelectedItems [0].Text];
+
+ if (fileStruct.attributes != FileAttributes.Directory)
+ selectedFilesString = SelectedItems [0].Text;
+ } else {
+ foreach (ListViewItem lvi in SelectedItems) {
+ FileStruct fileStruct = (FileStruct)fileHashtable [lvi.Text];
+
+ if (fileStruct.attributes != FileAttributes.Directory)
+ selectedFilesString += "\"" + lvi.Text + "\" ";
+ }
+ }
+
+ if (on_selected_files_changed != null)
+ on_selected_files_changed (this, EventArgs.Empty);
+ }
+ }
+
+ base.OnSelectedIndexChanged (e);
+ }
+
+ protected override void OnMouseMove (MouseEventArgs e)
+ {
+ ListViewItem item = GetItemAt (e.X, e.Y);
+
+ if (item != null) {
+ int currentItemIndex = item.Index;
+
+ if (currentItemIndex != oldItemIndexForToolTip) {
+ oldItemIndexForToolTip = currentItemIndex;
+
+ if (toolTip != null && toolTip.Active)
+ toolTip.Active = false;
+
+ object fileStructObject = fileHashtable [item.Text];
+
+ if (fileStructObject != null) {
+
+ FileStruct fileStruct = (FileStruct)fileStructObject;
+
+ string output = String.Empty;
+
+ if (fileStruct.type == FileStruct.FileStructType.Directoy)
+ output = String.Format ("Directory: {0}\n", fileStruct.fullname);
+ else if (fileStruct.type == FileStruct.FileStructType.Device)
+ output = String.Format ("Device: {0}", fileStruct.fullname);
+ else if (fileStruct.type == FileStruct.FileStructType.Network)
+ output = String.Format ("Network: {0}", fileStruct.fullname);
+ else
+ output = String.Format ("File: {0}", fileStruct.fullname);
+
+ toolTip.SetToolTip (this, output);
+
+ toolTip.Active = true;
+ }
+ }
+ }
+
+ base.OnMouseMove (e);
+ }
+
+ private void MWF_KeyUp (object sender, KeyEventArgs e)
+ {
+ if (SelectedItems.Count > 0 && e.KeyCode == Keys.Back)
+ if (on_one_directory_up != null) {
+ internal_key_up = true;
+ on_one_directory_up (this, EventArgs.Empty);
+ }
+ }
+
+ public event EventHandler SelectedFileChanged {
+ add { on_selected_file_changed += value; }
+ remove { on_selected_file_changed -= value; }
+ }
+
+ public event EventHandler SelectedFilesChanged {
+ add { on_selected_files_changed += value; }
+ remove { on_selected_files_changed -= value; }
+ }
+
+ public event EventHandler DirectoryChanged {
+ add { on_directory_changed += value; }
+ remove { on_directory_changed -= value; }
+ }
+
+ public event EventHandler ForceDialogEnd {
+ add { on_force_dialog_end += value; }
+ remove { on_force_dialog_end -= value; }
+ }
+
+ public event EventHandler OnDirectoryUp {
+ add { on_one_directory_up += value; }
+ remove { on_one_directory_up -= value; }
+ }
+ }
+
+ internal class FileFilter {
+ private ArrayList filterArrayList = new ArrayList();
+
+ private string filter;
+
+ public FileFilter ()
+ {}
+
+ public FileFilter (string filter)
+ {
+ this.filter = filter;
+
+ SplitFilter ();
+ }
+
+ public ArrayList FilterArrayList {
+ set {
+ filterArrayList = value;
+ }
+
+ get {
+ return filterArrayList;
+ }
+ }
+
+ public string Filter {
+ set {
+ filter = value;
+
+ SplitFilter ();
+ }
+
+ get {
+ return filter;
+ }
+ }
+
+ private void SplitFilter ()
+ {
+ filterArrayList.Clear ();
+
+ if (filter == null)
+ throw new NullReferenceException ("Filter");
+
+ if (filter.Length == 0)
+ return;
+
+ string[] filters = filter.Split (new char [] {'|'});
+
+ if ((filters.Length % 2) != 0)
+ throw new ArgumentException ("Filter");
+
+ for (int i = 0; i < filters.Length; i += 2) {
+ FilterStruct filterStruct = new FilterStruct (filters [i], filters [i + 1]);
+
+ filterArrayList.Add (filterStruct);
+ }
+ }
+ }
+
+ internal class DirComboBox : ComboBox {
+ internal class DirComboBoxItem {
+ private int imageIndex;
+ private string name;
+ private string path;
+ private int xPos;
+
+ public DirComboBoxItem (int imageIndex, string name, string path, int xPos)
+ {
+ this.imageIndex = imageIndex;
+ this.name = name;
+ this.path = path;
+ this.xPos = xPos;
+ }
+
+ public int ImageIndex {
+ set {
+ imageIndex = value;
+ }
+
+ get {
+ return imageIndex;
+ }
+ }
+
+ public string Name {
+ set {
+ name = value;
+ }
+
+ get {
+ return name;
+ }
+ }
+
+ public string Path {
+ set {
+ path = value;
+ }
+
+ get {
+ return path;
+ }
+ }
+
+ public int XPos {
+ set {
+ xPos = value;
+ }
+
+ get {
+ return xPos;
+ }
+ }
+ }
+
+ private ImageList imageList = new ImageList();
+
+ private string currentPath;
+
+ private EventHandler on_directory_changed;
+
+ private bool currentpath_internal_change = false;
+
+ private int platform = (int) Environment.OSVersion.Platform;
+ private string recently_used_tmp;
+ private string my_computer_tmp;
+ private string my_network_tmp;
+ private Stack dirStack = new Stack();
+
+ public DirComboBox ()
+ {
+ SuspendLayout ();
+
+ DrawMode = DrawMode.OwnerDrawFixed;
+
+ imageList.ColorDepth = ColorDepth.Depth32Bit;
+ imageList.ImageSize = new Size (16, 16);
+ imageList.Images.Add (ThemeEngine.Current.Images (UIIcon.PlacesRecentDocuments, 16));
+ imageList.Images.Add (ThemeEngine.Current.Images (UIIcon.PlacesDesktop, 16));
+ imageList.Images.Add (ThemeEngine.Current.Images (UIIcon.PlacesPersonal, 16));
+ imageList.Images.Add (ThemeEngine.Current.Images (UIIcon.PlacesMyComputer, 16));
+ imageList.Images.Add (ThemeEngine.Current.Images (UIIcon.PlacesMyNetwork, 16));
+ imageList.Images.Add (ThemeEngine.Current.Images (UIIcon.NormalFolder, 16));
+ imageList.TransparentColor = Color.Transparent;
+
+ if ((platform == 4) || (platform == 128)) {
+ recently_used_tmp = FileDialog.recently_string;
+ my_computer_tmp = FileDialog.mycomputer_string;
+ my_network_tmp = FileDialog.network_string;
+ } else {
+ recently_used_tmp = ThemeEngine.Current.Places (UIIcon.PlacesRecentDocuments);
+ my_computer_tmp = ThemeEngine.Current.Places (UIIcon.PlacesMyComputer);
+ my_network_tmp = ThemeEngine.Current.Places (UIIcon.PlacesMyNetwork);
+ }
+
+ Items.AddRange (new object [] {
+ new DirComboBoxItem (0, "Recently used", recently_used_tmp, 0),
+ new DirComboBoxItem (1, "Desktop", ThemeEngine.Current.Places (UIIcon.PlacesDesktop), 0),
+ new DirComboBoxItem (2, "Personal folder", ThemeEngine.Current.Places (UIIcon.PlacesPersonal), 0),
+ new DirComboBoxItem (3, "My Computer", my_computer_tmp, 0),
+ new DirComboBoxItem (4, "My Network", my_network_tmp, 0)
+ }
+ );
+
+ ResumeLayout (false);
+ }
+
+ public string CurrentPath {
+ set {
+ currentPath = value;
+
+ currentpath_internal_change = true;
+
+ CreateComboList ();
+ }
+ get {
+ return currentPath;
+ }
+ }
+
+ private void CreateComboList ()
+ {
+ int selection = -1;
+ int child_of = - 1;
+
+ if (currentPath == recently_used_tmp)
+ selection = 0;
+ else
+ if (currentPath == ThemeEngine.Current.Places (UIIcon.PlacesDesktop))
+ selection = 1;
+ else
+ if (currentPath == ThemeEngine.Current.Places (UIIcon.PlacesPersonal))
+ selection = 2;
+ else
+ if (currentPath == my_computer_tmp)
+ selection = 3;
+ else
+ if (currentPath == my_network_tmp)
+ selection = 4;
+
+ child_of = CheckChildOf ();
+
+ BeginUpdate ();
+
+ Items.Clear ();
+
+ Items.Add (new DirComboBoxItem (0, "Recently used", recently_used_tmp, 0));
+
+ Items.Add (new DirComboBoxItem (1, "Desktop", ThemeEngine.Current.Places (UIIcon.PlacesDesktop), 0));
+ if (child_of == 1)
+ selection = AppendToParent ();
+
+ Items.Add (new DirComboBoxItem (2, "Personal folder", ThemeEngine.Current.Places (UIIcon.PlacesPersonal), 0));
+ if (child_of == 2)
+ selection = AppendToParent ();
+
+ Items.Add (new DirComboBoxItem (3, "My Computer", my_computer_tmp, 0));
+
+ Items.Add (new DirComboBoxItem (4, "My Network", my_network_tmp, 0));
+
+ if (selection != -1)
+ SelectedIndex = selection;
+
+ EndUpdate ();
+ }
+
+ private int CheckChildOf ()
+ {
+ dirStack.Clear ();
+
+ if (currentPath == FileDialog.mycomputer_string ||
+ currentPath == FileDialog.network_string ||
+ currentPath == FileDialog.recently_string)
+ return -1;
+
+ DirectoryInfo di = new DirectoryInfo (currentPath);
+
+ dirStack.Push (di);
+
+ while (di.Parent != null) {
+ di = di.Parent;
+ if (di.FullName == ThemeEngine.Current.Places (UIIcon.PlacesDesktop))
+ return 1;
+ else
+ if (di.FullName == ThemeEngine.Current.Places (UIIcon.PlacesPersonal))
+ return 2;
+
+ dirStack.Push (di);
+ }
+
+ return -1;
+ }
+
+ private int AppendToParent ()
+ {
+ int xPos = 0;
+ int selection = -1;
+
+ while (dirStack.Count != 0) {
+ DirectoryInfo dii = dirStack.Pop () as DirectoryInfo;
+ selection = Items.Add (new DirComboBoxItem (5, dii.Name, dii.FullName, xPos + 4));
+ xPos += 4;
+ }
+
+ return selection;
+ }
+
+ protected override void OnDrawItem (DrawItemEventArgs e)
+ {
+ if (e.Index == -1)
+ return;
+
+ Bitmap bmp = new Bitmap (e.Bounds.Width, e.Bounds.Height, e.Graphics);
+ Graphics gr = Graphics.FromImage (bmp);
+
+ DirComboBoxItem dcbi = Items [e.Index] as DirComboBoxItem;
+
+ Color backColor = e.BackColor;
+ Color foreColor = e.ForeColor;
+
+ int xPos = dcbi.XPos;
+
+ if ((e.State & DrawItemState.ComboBoxEdit) != 0)
+ xPos = 0;
+ else
+ if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
+ backColor = ThemeEngine.Current.ColorHighlight;
+ foreColor = ThemeEngine.Current.ColorHighlightText;
+ }
+
+ gr.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (backColor), new Rectangle (0, 0, bmp.Width, bmp.Height));
+
+ gr.DrawString (dcbi.Name, e.Font , ThemeEngine.Current.ResPool.GetSolidBrush (foreColor), new Point (24 + xPos, (bmp.Height - e.Font.Height) / 2));
+ gr.DrawImage (imageList.Images [dcbi.ImageIndex], new Rectangle (new Point (xPos + 2, 0), new Size (16, 16)));
+
+ e.Graphics.DrawImage (bmp, e.Bounds.X, e.Bounds.Y);
+ gr.Dispose ();
+ bmp.Dispose ();
+ }
+
+ protected override void OnSelectedIndexChanged (EventArgs e)
+ {
+ if (Items.Count > 0) {
+ DirComboBoxItem dcbi = Items [SelectedIndex] as DirComboBoxItem;
+
+ currentPath = dcbi.Path;
+
+ // call DirectoryChange event only if the user changes the index with the ComboBox
+ if (!currentpath_internal_change) {
+ if (on_directory_changed != null)
+ on_directory_changed (this, EventArgs.Empty);
+ }
+ }
+
+ currentpath_internal_change = false;
+ }
+
+ public event EventHandler DirectoryChanged {
+ add { on_directory_changed += value; }
+ remove { on_directory_changed -= value; }
+ }
+ }
+
+ // Alexsantas little helper
+ internal class MasterMount {
+ // add more...
+ internal enum FsTypes {
+ ext2,
+ ext3,
+ hpfs,
+ iso9660,
+ jfs,
+ minix,
+ msdos,
+ ntfs,
+ reiserfs,
+ ufs,
+ umsdos,
+ vfat,
+ sysv,
+ xfs,
+ ncpfs,
+ nfs,
+ smbfs,
+ usbfs
+ }
+
+ internal struct Mount {
+ public string device_or_filesystem;
+ public string device_short;
+ public string mount_point;
+ public FsTypes fsType;
+ }
+
+ bool proc_mount_available = false;
+
+ ArrayList block_devices = new ArrayList ();
+ ArrayList network_devices = new ArrayList ();
+ ArrayList removable_devices = new ArrayList ();
+
+ private int platform = (int) Environment.OSVersion.Platform;
+ private MountComparer mountComparer = new MountComparer ();
+
+ public MasterMount ()
+ {
+ // maybe check if the current user can access /proc/mounts
+ if ((platform == 4) || (platform == 128))
+ if (File.Exists ("/proc/mounts"))
+ proc_mount_available = true;
+ }
+
+ public ArrayList Block_devices {
+ get {
+ return block_devices;
+ }
+ }
+
+ public ArrayList Network_devices {
+ get {
+ return network_devices;
+ }
+ }
+
+ public ArrayList Removable_devices {
+ get {
+ return removable_devices;
+ }
+ }
+
+ public bool ProcMountAvailable {
+ get {
+ return proc_mount_available;
+ }
+ }
+
+ public void GetMounts ()
+ {
+ if (!proc_mount_available)
+ return;
+
+ block_devices.Clear ();
+ network_devices.Clear ();
+ removable_devices.Clear ();
+
+ try {
+ StreamReader sr = new StreamReader ("/proc/mounts");
+
+ string line = sr.ReadLine ();
+
+ while (line != null) {
+ ProcessProcMountLine (line);
+ line = sr.ReadLine ();
+ }
+
+ sr.Close ();
+
+ block_devices.Sort (mountComparer);
+ network_devices.Sort (mountComparer);
+ removable_devices.Sort (mountComparer);
+ } catch {
+ // bla
+ }
+ }
+
+ private void ProcessProcMountLine (string line)
+ {
+ string[] split = line.Split (new char [] {' '});
+
+ if (split != null && split.Length > 0) {
+ Mount mount = new Mount ();
+
+ if (split [0].StartsWith ("/dev/"))
+ mount.device_short = split [0].Replace ("/dev/", "");
+ else
+ mount.device_short = split [0];
+
+ mount.device_or_filesystem = split [0];
+ mount.mount_point = split [1];
+
+ // TODO: other removable devices, floppy
+ // ssh
+
+ // network mount
+ if (split [2] == "nfs") {
+ mount.fsType = FsTypes.nfs;
+ network_devices.Add (mount);
+ } else if (split [2] == "smbfs") {
+ mount.fsType = FsTypes.smbfs;
+ network_devices.Add (mount);
+ } else if (split [2] == "ncpfs") {
+ mount.fsType = FsTypes.ncpfs;
+ network_devices.Add (mount);
+
+ } else if (split [2] == "iso9660") { //cdrom
+ mount.fsType = FsTypes.iso9660;
+ removable_devices.Add (mount);
+ } else if (split [2] == "usbfs") { //usb ? not tested
+ mount.fsType = FsTypes.usbfs;
+ removable_devices.Add (mount);
+
+ } else if (split [0].StartsWith ("/")) { //block devices
+ if (split [1].StartsWith ("/dev/")) // root static, do not add
+ return;
+
+ if (split [2] == "ext2")
+ mount.fsType = FsTypes.ext2;
+ else if (split [2] == "ext3")
+ mount.fsType = FsTypes.ext3;
+ else if (split [2] == "reiserfs")
+ mount.fsType = FsTypes.reiserfs;
+ else if (split [2] == "xfs")
+ mount.fsType = FsTypes.xfs;
+ else if (split [2] == "vfat")
+ mount.fsType = FsTypes.vfat;
+ else if (split [2] == "ntfs")
+ mount.fsType = FsTypes.ntfs;
+ else if (split [2] == "msdos")
+ mount.fsType = FsTypes.msdos;
+ else if (split [2] == "umsdos")
+ mount.fsType = FsTypes.umsdos;
+ else if (split [2] == "hpfs")
+ mount.fsType = FsTypes.hpfs;
+ else if (split [2] == "minix")
+ mount.fsType = FsTypes.minix;
+ else if (split [2] == "jfs")
+ mount.fsType = FsTypes.jfs;
+
+ block_devices.Add (mount);
+ }
+ }
+ }
+
+ public class MountComparer : IComparer
+ {
+ public int Compare(object mount1, object mount2)
+ {
+ return String.Compare(((Mount)mount1).device_short, ((Mount)mount2).device_short);
+ }
+ }
+ }
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FixedSizeTextBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FixedSizeTextBox.cs
new file mode 100644
index 00000000000..99da53c54da
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FixedSizeTextBox.cs
@@ -0,0 +1,42 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2006 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+//
+//
+
+// This is an internal class that allows us to use a textbox as a child control
+// for things such as UpDown controls, and the ComboBox that will not have their
+// size altered by scaling
+
+namespace System.Windows.Forms {
+
+ internal class FixedSizeTextBox : TextBox {
+
+ public FixedSizeTextBox ()
+ {
+ SetStyle (ControlStyles.FixedWidth, true);
+ SetStyle (ControlStyles.FixedHeight, true);
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FlatStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FlatStyle.cs
new file mode 100644
index 00000000000..662a2c1f666
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FlatStyle.cs
@@ -0,0 +1,36 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum FlatStyle {
+ Flat = 0,
+ Popup = 1,
+ Standard = 2,
+ System = 3
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FolderBrowserDialog.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FolderBrowserDialog.cs
new file mode 100644
index 00000000000..9ccc5954d4c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FolderBrowserDialog.cs
@@ -0,0 +1,442 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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-2006 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Alexander Olk (xenomorph2@onlinehome.de)
+//
+//
+
+// NOT COMPLETE
+// TODO:
+// - create new folder if NewFolderButton is pressed
+// - better handling of Environment.SpecialFolders
+// - fix: if SelectedPath != "" and it is beyond RootFolder then show it (currently TreeNode.EnsureVisible() is missing...)
+
+using System;
+using System.Drawing;
+using System.ComponentModel;
+using System.Resources;
+using System.IO;
+using System.Collections;
+
+namespace System.Windows.Forms
+{
+ [DefaultEvent("HelpRequest")]
+ [DefaultProperty("SelectedPath")]
+ [Designer("System.Windows.Forms.Design.FolderBrowserDialogDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ public sealed class FolderBrowserDialog : CommonDialog
+ {
+ #region Local Variables
+ private string description = "";
+ private Environment.SpecialFolder rootFolder = Environment.SpecialFolder.Desktop;
+ private string selectedPath = "";
+ private bool showNewFolderButton = true;
+
+ #endregion // Local Variables
+
+ #region Public Constructors
+ public FolderBrowserDialog( )
+ {
+ form = new FolderBrowserDialogForm( this );
+ form.Size = new Size( 322, 288 );
+ form.MinimumSize = new Size( 322, 288 );
+ form.Text = "Search Folder";
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ [Browsable(true)]
+ [DefaultValue("")]
+ [Localizable(true)]
+ public string Description
+ {
+ set
+ {
+ description = value;
+ }
+
+ get
+ {
+ return description;
+ }
+ }
+
+ [Browsable(true)]
+ [DefaultValue(Environment.SpecialFolder.Desktop)]
+ [Localizable(false)]
+ public Environment.SpecialFolder RootFolder
+ {
+ set
+ {
+ rootFolder = value;
+ }
+
+ get
+ {
+ return rootFolder;
+ }
+ }
+
+ [Browsable(true)]
+ [DefaultValue("")]
+ [Editor("System.Windows.Forms.Design.SelectedPathEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
+ [Localizable(true)]
+ public string SelectedPath
+ {
+ set
+ {
+ selectedPath = value;
+ }
+
+ get
+ {
+ return selectedPath;
+ }
+ }
+
+ [Browsable(true)]
+ [DefaultValue(true)]
+ [Localizable(false)]
+ public bool ShowNewFolderButton
+ {
+ set
+ {
+ showNewFolderButton = value;
+ }
+
+ get
+ {
+ return showNewFolderButton;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public override void Reset( )
+ {
+ description = "";
+ rootFolder = Environment.SpecialFolder.Desktop;
+ selectedPath = "";
+ showNewFolderButton = true;
+ }
+
+ protected override bool RunDialog( IntPtr hwndOwner )
+ {
+ FolderBrowserDialogPanel fb = new FolderBrowserDialogPanel (this);
+ form.Controls.Add (fb);
+ return true;
+ }
+ #endregion // Public Instance Methods
+
+ #region Internal Methods
+ internal class FolderBrowserDialogForm : DialogForm
+ {
+ internal FolderBrowserDialogForm( CommonDialog owner )
+ : base( owner )
+ {}
+
+ protected override CreateParams CreateParams
+ {
+ get
+ {
+ CreateParams cp;
+
+ ControlBox = true;
+ MinimizeBox = false;
+ MaximizeBox = false;
+
+ cp = base.CreateParams;
+ cp.Style = (int)( WindowStyles.WS_POPUP | WindowStyles.WS_CAPTION | WindowStyles.WS_SYSMENU | WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_CLIPSIBLINGS );
+ cp.Style |= (int)WindowStyles.WS_OVERLAPPEDWINDOW;
+
+ if (!is_enabled) {
+ cp.Style |= (int)(WindowStyles.WS_DISABLED);
+ }
+
+ return cp;
+ }
+ }
+ }
+
+ internal class FolderBrowserDialogPanel : Panel
+ {
+ private Label descriptionLabel;
+ private Button cancelButton;
+ private Button okButton;
+ private TreeView folderBrowserTreeView;
+ private Button newFolderButton;
+
+ private FolderBrowserDialog folderBrowserDialog;
+ private string selectedPath;
+
+ private ImageList imageList;
+ private TreeNode selectedPathNode = null;
+ private TreeNode root_node;
+
+ public FolderBrowserDialogPanel (FolderBrowserDialog folderBrowserDialog)
+ {
+ this.folderBrowserDialog = folderBrowserDialog;
+
+ newFolderButton = new Button( );
+ folderBrowserTreeView = new TreeView( );
+ okButton = new Button( );
+ cancelButton = new Button( );
+ descriptionLabel = new Label( );
+
+ imageList = new ImageList( );
+
+ folderBrowserDialog.form.AcceptButton = okButton;
+ folderBrowserDialog.form.CancelButton = cancelButton;
+
+ SuspendLayout( );
+
+ // descriptionLabel
+ descriptionLabel.Anchor = ( (AnchorStyles)( ( ( AnchorStyles.Top | AnchorStyles.Left )
+ | AnchorStyles.Right ) ) );
+ descriptionLabel.Location = new Point( 17, 14 );
+ descriptionLabel.Size = new Size( 290, 40 );
+ descriptionLabel.TabIndex = 0;
+ descriptionLabel.Text = folderBrowserDialog.Description;
+
+ // folderBrowserTreeView
+ folderBrowserTreeView.Anchor = ( (AnchorStyles)( ( ( ( AnchorStyles.Top | AnchorStyles.Bottom )
+ | AnchorStyles.Left )
+ | AnchorStyles.Right ) ) );
+ folderBrowserTreeView.ImageIndex = -1;
+ folderBrowserTreeView.Location = new Point( 20, 61 );
+ folderBrowserTreeView.SelectedImageIndex = -1;
+ folderBrowserTreeView.Size = new Size( 278, 153 );
+ folderBrowserTreeView.TabIndex = 1;
+ folderBrowserTreeView.ImageList = imageList;
+ folderBrowserTreeView.ShowLines = false;
+ folderBrowserTreeView.ShowPlusMinus = true;
+ folderBrowserTreeView.HotTracking = true;
+ //folderBrowserTreeView.Indent = 2;
+
+ // newFolderButton
+ newFolderButton.Anchor = ( (AnchorStyles)( ( AnchorStyles.Bottom | AnchorStyles.Left ) ) );
+ newFolderButton.FlatStyle = FlatStyle.System;
+ newFolderButton.Location = new Point( 14, 230 );
+ newFolderButton.Size = new Size( 125, 23 );
+ newFolderButton.TabIndex = 2;
+ newFolderButton.Text = "New Folder";
+ newFolderButton.Enabled = folderBrowserDialog.ShowNewFolderButton;
+
+ // okButton
+ okButton.Anchor = ( (AnchorStyles)( ( AnchorStyles.Bottom | AnchorStyles.Right ) ) );
+ okButton.FlatStyle = FlatStyle.System;
+ okButton.Location = new Point( 142, 230 );
+ okButton.Size = new Size( 80, 23 );
+ okButton.TabIndex = 3;
+ okButton.Text = "OK";
+
+ // cancelButton
+ cancelButton.Anchor = ( (AnchorStyles)( ( AnchorStyles.Bottom | AnchorStyles.Right ) ) );
+ cancelButton.DialogResult = DialogResult.Cancel;
+ cancelButton.FlatStyle = FlatStyle.System;
+ cancelButton.Location = new Point( 226, 230 );
+ cancelButton.Size = new Size( 80, 23 );
+ cancelButton.TabIndex = 4;
+ cancelButton.Text = "Cancel";
+
+ // FolderBrowserDialog
+ ClientSize = new Size( 322, 288 );
+ Dock = DockStyle.Fill;
+
+ Controls.Add( cancelButton );
+ Controls.Add( okButton );
+ Controls.Add( newFolderButton );
+ Controls.Add( folderBrowserTreeView );
+ Controls.Add( descriptionLabel );
+ ResumeLayout( false );
+
+ SetupImageList( );
+
+ okButton.Click += new EventHandler( OnClickOKButton );
+ cancelButton.Click += new EventHandler( OnClickCancelButton );
+
+ string root_path = Environment.GetFolderPath (folderBrowserDialog.RootFolder);
+ root_node = new TreeNode (Path.GetFileName (root_path));
+ root_node.Tag = root_path;
+ root_node.ImageIndex = NodeImageIndex (root_path);
+
+ // If we add the sub nodes before the root is added to the
+ // tree no refreshing will be done whil adding
+ if (folderBrowserDialog.RootFolder == Environment.SpecialFolder.Desktop) {
+
+
+ // Add something similar to 'My Computer'
+ TreeNode mycomp = new TreeNode ("My Computer");
+ if (Path.DirectorySeparatorChar == '/')
+ mycomp.Tag = "/";
+ else
+ mycomp.Tag = Environment.GetFolderPath (Environment.SpecialFolder.MyComputer);
+ mycomp.ImageIndex = NodeImageIndex ((string) mycomp.Tag);
+
+ // A home directory
+ string home_path = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
+ TreeNode home = new TreeNode (Path.GetFileName (home_path));
+ home.Tag = home_path;
+ home.ImageIndex = NodeImageIndex (home_path);
+
+ // This is so we get the expand box
+ mycomp.Nodes.Add (new TreeNode (String.Empty));
+ home.Nodes.Add (new TreeNode (String.Empty));
+
+ root_node.Nodes.Add (mycomp);
+ root_node.Nodes.Add (home);
+ root_node.Expand ();
+ } else {
+ FillNode (root_node);
+ }
+
+ folderBrowserTreeView.Nodes.Add (root_node);
+
+ folderBrowserTreeView.BeforeExpand += new TreeViewCancelEventHandler (OnBeforeExpand);
+ folderBrowserTreeView.AfterSelect += new TreeViewEventHandler( OnAfterSelectFolderBrowserTreeView );
+ }
+
+ public string SelectedPath
+ {
+ set
+ {
+ selectedPath = value;
+ }
+
+ get
+ {
+ return selectedPath;
+ }
+ }
+
+ void OnClickOKButton( object sender, EventArgs e )
+ {
+ folderBrowserDialog.SelectedPath = selectedPath;
+
+ folderBrowserDialog.form.Controls.Remove( this );
+ folderBrowserDialog.form.DialogResult = DialogResult.OK;
+ }
+
+ void OnClickCancelButton( object sender, EventArgs e )
+ {
+ folderBrowserDialog.form.Controls.Remove( this );
+ folderBrowserDialog.form.DialogResult = DialogResult.Cancel;
+ }
+
+ void OnAfterSelectFolderBrowserTreeView( object sender, TreeViewEventArgs e )
+ {
+ if (e.Node == null)
+ return;
+ selectedPath = (string) e.Node.Tag;
+ }
+
+ private void OnBeforeExpand (object sender, TreeViewCancelEventArgs e)
+ {
+ if (e.Node == root_node)
+ return;
+ FillNode (e.Node);
+ }
+
+ private void OnAfterCollapse (object sender, TreeViewCancelEventArgs e)
+ {
+ if (e.Node == root_node)
+ return;
+ e.Node.Nodes.Clear ();
+ }
+
+ private void FillNode (TreeNode node)
+ {
+ Cursor old = folderBrowserTreeView.Cursor;
+ folderBrowserTreeView.Cursor = Cursors.WaitCursor;
+
+ folderBrowserTreeView.BeginUpdate ();
+
+ node.Nodes.Clear ();
+ string path = node.Tag as string;
+ string [] dirs = Directory.GetDirectories (path);
+
+ foreach (string s in dirs) {
+ string name = Path.GetFileName (s);
+ // filter out . directories
+ if (name.StartsWith ("."))
+ continue;
+ TreeNode child = new TreeNode (name);
+ child.Tag = s;
+ child.ImageIndex = NodeImageIndex (s);
+
+ try {
+ // so we get the plus
+ string [] subdirs = Directory.GetDirectories (s);
+ foreach (string subdir in subdirs) {
+ // filter out . directories (le sigh)
+ string subdirname = Path.GetFileName (subdir);
+ if (!subdirname.StartsWith (".")) {
+ child.Nodes.Add (new TreeNode (String.Empty));
+ break;
+ }
+ }
+ } catch {
+ // Probably don't have access
+ }
+
+ node.Nodes.Add (child);
+ }
+
+ folderBrowserTreeView.EndUpdate ();
+ folderBrowserTreeView.Cursor = old;
+ }
+
+ private int NodeImageIndex( string path )
+ {
+ int index = 5;
+
+ if ( path == Environment.GetFolderPath( Environment.SpecialFolder.Desktop ) )
+ index = 1;
+ else
+ if ( path == Environment.GetFolderPath( Environment.SpecialFolder.Personal ) )
+ index = 2;
+
+ return index;
+ }
+
+ private void SetupImageList( )
+ {
+ imageList.ColorDepth = ColorDepth.Depth32Bit;
+ imageList.ImageSize = new Size( 16, 16 );
+ imageList.Images.Add( (Image)Locale.GetResource( "last_open" ) );
+ imageList.Images.Add( (Image)Locale.GetResource( "desktop" ) );
+ imageList.Images.Add( (Image)Locale.GetResource( "folder_with_paper" ) );
+ imageList.Images.Add( (Image)Locale.GetResource( "monitor-computer" ) );
+ imageList.Images.Add( (Image)Locale.GetResource( "monitor-planet" ) );
+ imageList.Images.Add( (Image)Locale.GetResource( "folder" ) );
+ imageList.Images.Add( (Image)Locale.GetResource( "paper" ) );
+ imageList.TransparentColor = Color.Transparent;
+ }
+ }
+ #endregion // Internal Methods
+
+ #region Events
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler HelpRequest;
+ #endregion
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FontDialog.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FontDialog.cs
new file mode 100644
index 00000000000..0562034367b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FontDialog.cs
@@ -0,0 +1,1051 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Alexander Olk xenomorph2@onlinehome.de
+//
+//
+
+// NOT COMPLETE - work in progress
+
+// TODO:
+// - select values for font/style/size via the TextBoxes
+// - etc
+
+using System.ComponentModel;
+using System.Drawing;
+using System.Text.RegularExpressions;
+using System;
+using System.Collections;
+
+namespace System.Windows.Forms
+{
+ [DefaultProperty( "Font" )]
+ [DefaultEvent("Apply")]
+ public class FontDialog : CommonDialog
+ {
+ protected static readonly object EventApply = new object ();
+
+ private Font font;
+ private Color color = Color.Black;
+ private bool allowSimulations = true;
+ private bool allowVectorFonts = true;
+ private bool allowVerticalFonts = true;
+ private bool allowScriptChange = true;
+ private bool fixedPitchOnly = false;
+ private int maxSize = 0;
+ private int minSize = 0;
+ private bool scriptsOnly = false;
+ private bool showApply = false;
+ private bool showColor = false;
+ private bool showEffects = true;
+ private bool showHelp = false;
+
+ private bool fontMustExist = false;
+
+ private Panel examplePanel;
+
+ private Button okButton;
+ private Button cancelButton;
+ private Button applyButton;
+ private Button helpButton;
+
+ private TextBox fontTextBox;
+ private TextBox fontstyleTextBox;
+ private TextBox fontsizeTextBox;
+
+ private ListBox fontListBox;
+ private ListBox fontstyleListBox;
+ private ListBox fontsizeListBox;
+
+ private GroupBox effectsGroupBox;
+ private CheckBox strikethroughCheckBox;
+ private CheckBox underlinedCheckBox;
+ private ComboBox scriptComboBox;
+
+ private Label fontLabel;
+ private Label fontstyleLabel;
+ private Label sizeLabel;
+ private Label scriptLabel;
+
+ private GroupBox exampleGroupBox;
+
+ private ColorComboBox colorComboBox;
+
+ private FontFamily[] fontFamilies;
+
+ private string currentFontName;
+
+ private float currentSize;
+
+ private FontFamily currentFamily;
+
+ private FontStyle currentFontStyle;
+
+ private bool underlined = false;
+ private bool strikethrough = false;
+
+ private Hashtable fontHash = new Hashtable();
+
+ private int[] a_sizes = {
+ 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72
+ };
+
+ private bool internal_change = false;
+
+ #region Public Constructors
+ public FontDialog( )
+ {
+ okButton = new Button( );
+ cancelButton = new Button( );
+ applyButton = new Button( );
+ helpButton = new Button( );
+
+ fontTextBox = new TextBox( );
+ fontstyleTextBox = new TextBox( );
+ fontsizeTextBox = new TextBox( );
+
+ fontListBox = new ListBox( );
+ fontsizeListBox = new ListBox( );
+
+ fontLabel = new Label( );
+ fontstyleLabel = new Label( );
+ sizeLabel = new Label( );
+ scriptLabel = new Label( );
+
+ exampleGroupBox = new GroupBox( );
+ fontstyleListBox = new ListBox( );
+
+ effectsGroupBox = new GroupBox( );
+ underlinedCheckBox = new CheckBox( );
+ strikethroughCheckBox = new CheckBox( );
+ scriptComboBox = new ComboBox( );
+
+ examplePanel = new Panel( );
+
+ colorComboBox = new ColorComboBox( this );
+
+ exampleGroupBox.SuspendLayout( );
+ effectsGroupBox.SuspendLayout( );
+ form.SuspendLayout( );
+
+ // fontsizeListBox
+ fontsizeListBox.Location = new Point( 284, 47 );
+ fontsizeListBox.Size = new Size( 52, 95 );
+ fontsizeListBox.TabIndex = 10;
+ fontListBox.Sorted = true;
+ // fontTextBox
+ fontTextBox.Location = new Point( 16, 26 );
+ fontTextBox.Size = new Size( 140, 21 );
+ fontTextBox.TabIndex = 5;
+ fontTextBox.Text = "";
+ // fontstyleLabel
+ fontstyleLabel.Location = new Point( 164, 10 );
+ fontstyleLabel.Size = new Size( 100, 16 );
+ fontstyleLabel.TabIndex = 1;
+ fontstyleLabel.Text = "Font Style:";
+ // typesizeTextBox
+ fontsizeTextBox.Location = new Point( 284, 26 );
+ fontsizeTextBox.Size = new Size( 52, 21 );
+ fontsizeTextBox.TabIndex = 7;
+ fontsizeTextBox.Text = "";
+ // schriftartListBox
+ fontListBox.Location = new Point( 16, 47 );
+ fontListBox.Size = new Size( 140, 95 );
+ fontListBox.TabIndex = 8;
+ fontListBox.Sorted = true;
+ // exampleGroupBox
+ exampleGroupBox.Controls.Add( examplePanel );
+ exampleGroupBox.FlatStyle = FlatStyle.System;
+ exampleGroupBox.Location = new Point( 164, 158 );
+ exampleGroupBox.Size = new Size( 172, 70 );
+ exampleGroupBox.TabIndex = 12;
+ exampleGroupBox.TabStop = false;
+ exampleGroupBox.Text = "Example";
+ // fontstyleListBox
+ fontstyleListBox.Location = new Point( 164, 47 );
+ fontstyleListBox.Size = new Size( 112, 95 );
+ fontstyleListBox.TabIndex = 9;
+ // schriftartLabel
+ fontLabel.Location = new Point( 16, 10 );
+ fontLabel.Size = new Size( 88, 16 );
+ fontLabel.TabIndex = 0;
+ fontLabel.Text = "Font:";
+ // effectsGroupBox
+ effectsGroupBox.Controls.Add( underlinedCheckBox );
+ effectsGroupBox.Controls.Add( strikethroughCheckBox );
+ effectsGroupBox.Controls.Add( colorComboBox );
+ effectsGroupBox.FlatStyle = FlatStyle.System;
+ effectsGroupBox.Location = new Point( 16, 158 );
+ effectsGroupBox.Size = new Size( 140, 116 );
+ effectsGroupBox.TabIndex = 11;
+ effectsGroupBox.TabStop = false;
+ effectsGroupBox.Text = "Effects";
+ // strikethroughCheckBox
+ strikethroughCheckBox.FlatStyle = FlatStyle.System;
+ strikethroughCheckBox.Location = new Point( 8, 16 );
+ strikethroughCheckBox.TabIndex = 0;
+ strikethroughCheckBox.Text = "Strikethrough";
+ // colorComboBox
+ colorComboBox.Location = new Point( 8, 70 );
+ colorComboBox.Size = new Size( 130, 21 );
+ // sizeLabel
+ sizeLabel.Location = new Point( 284, 10 );
+ sizeLabel.Size = new Size( 100, 16 );
+ sizeLabel.TabIndex = 2;
+ sizeLabel.Text = "Size:";
+ // scriptComboBox
+ scriptComboBox.Location = new Point( 164, 253 );
+ scriptComboBox.Size = new Size( 172, 21 );
+ scriptComboBox.TabIndex = 14;
+ scriptComboBox.Text = "-/-";
+ // okButton
+ okButton.FlatStyle = FlatStyle.System;
+ okButton.Location = new Point( 352, 26 );
+ okButton.Size = new Size( 70, 23 );
+ okButton.TabIndex = 3;
+ okButton.Text = "OK";
+ // cancelButton
+ cancelButton.FlatStyle = FlatStyle.System;
+ cancelButton.Location = new Point( 352, 52 );
+ cancelButton.Size = new Size( 70, 23 );
+ cancelButton.TabIndex = 4;
+ cancelButton.Text = "Cancel";
+ // applyButton
+ applyButton.FlatStyle = FlatStyle.System;
+ applyButton.Location = new Point( 352, 78 );
+ applyButton.Size = new Size( 70, 23 );
+ applyButton.TabIndex = 5;
+ applyButton.Text = "Apply";
+ // helpButton
+ helpButton.FlatStyle = FlatStyle.System;
+ helpButton.Location = new Point( 352, 104 );
+ helpButton.Size = new Size( 70, 23 );
+ helpButton.TabIndex = 6;
+ helpButton.Text = "Help";
+ // underlinedCheckBox
+ underlinedCheckBox.FlatStyle = FlatStyle.System;
+ underlinedCheckBox.Location = new Point( 8, 36 );
+ underlinedCheckBox.TabIndex = 1;
+ underlinedCheckBox.Text = "Underlined";
+ // fontstyleTextBox
+ fontstyleTextBox.Location = new Point( 164, 26 );
+ fontstyleTextBox.Size = new Size( 112, 21 );
+ fontstyleTextBox.TabIndex = 6;
+ fontstyleTextBox.Text = "";
+ // scriptLabel
+ scriptLabel.Location = new Point( 164, 236 );
+ scriptLabel.Size = new Size( 100, 16 );
+ scriptLabel.TabIndex = 13;
+ scriptLabel.Text = "Script:";
+ // examplePanel
+ examplePanel.Location = new Point( 8, 20 );
+ examplePanel.TabIndex = 0;
+ examplePanel.Size = new Size( 156, 40 );
+
+ form.AcceptButton = okButton;
+
+ form.Controls.Add( scriptComboBox );
+ form.Controls.Add( scriptLabel );
+ form.Controls.Add( exampleGroupBox );
+ form.Controls.Add( effectsGroupBox );
+ form.Controls.Add( fontsizeListBox );
+ form.Controls.Add( fontstyleListBox );
+ form.Controls.Add( fontListBox );
+ form.Controls.Add( fontsizeTextBox );
+ form.Controls.Add( fontstyleTextBox );
+ form.Controls.Add( fontTextBox );
+ form.Controls.Add( cancelButton );
+ form.Controls.Add( okButton );
+ form.Controls.Add( sizeLabel );
+ form.Controls.Add( fontstyleLabel );
+ form.Controls.Add( fontLabel );
+ form.Controls.Add( applyButton );
+ form.Controls.Add( helpButton );
+
+ exampleGroupBox.ResumeLayout( false );
+ effectsGroupBox.ResumeLayout( false );
+
+ form.Size = new Size( 430, 318 );
+ form.MinimumSize = new Size( 430, 318 );
+
+ form.FormBorderStyle = FormBorderStyle.FixedDialog;
+ form.MaximizeBox = false;
+
+ form.Text = "Font";
+
+ form.ResumeLayout( false );
+
+ fontFamilies = FontFamily.Families;
+
+ fontListBox.BeginUpdate( );
+ foreach ( FontFamily ff in fontFamilies )
+ {
+ if ( !fontHash.ContainsKey (ff.Name) ) {
+ fontListBox.Items.Add( ff.Name );
+ fontHash.Add( ff.Name, ff );
+ }
+ }
+ fontListBox.EndUpdate( );
+
+ CreateFontSizeListBoxItems ();
+
+ applyButton.Hide( );
+ helpButton.Hide( );
+ colorComboBox.Hide( );
+
+ cancelButton.Click += new EventHandler( OnClickCancelButton );
+ okButton.Click += new EventHandler( OnClickOkButton );
+ applyButton.Click += new EventHandler (OnApplyButton);
+ examplePanel.Paint += new PaintEventHandler( OnPaintExamplePanel );
+ fontListBox.SelectedIndexChanged += new EventHandler( OnSelectedIndexChangedFontListBox );
+ fontsizeListBox.SelectedIndexChanged += new EventHandler( OnSelectedIndexChangedSizeListBox );
+ fontstyleListBox.SelectedIndexChanged += new EventHandler( OnSelectedIndexChangedFontStyleListBox );
+ underlinedCheckBox.CheckedChanged += new EventHandler( OnCheckedChangedUnderlinedCheckBox );
+ strikethroughCheckBox.CheckedChanged += new EventHandler( OnCheckedChangedStrikethroughCheckBox );
+
+ fontTextBox.KeyUp += new KeyEventHandler (OnFontTextBoxKeyUp);
+ fontstyleTextBox.KeyUp += new KeyEventHandler (OnFontStyleTextBoxKeyUp);
+ fontsizeTextBox.KeyUp += new KeyEventHandler (OnFontSizeTextBoxKeyUp);
+
+ Font = form.Font;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public Font Font
+ {
+ get {
+ return font;
+ }
+
+ set {
+ if (value != null) {
+ font = new Font(value, value.Style);
+
+ currentFontStyle = font.Style;
+ currentSize = font.Size;
+ currentFontName = font.Name;
+
+ int index = fontListBox.FindString (currentFontName);
+
+ if (index != -1) {
+ fontListBox.SelectedIndex = index;
+ } else {
+ fontListBox.SelectedIndex = 0;
+ }
+
+ fontListBox.TopIndex = fontListBox.SelectedIndex;
+ }
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool FontMustExist
+ {
+ get {
+ return fontMustExist;
+ }
+
+ set {
+ fontMustExist = value;
+ }
+ }
+
+ public Color Color
+ {
+ set {
+ color = value;
+ examplePanel.Invalidate( );
+ }
+
+ get {
+ return color;
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool AllowSimulations
+ {
+ set {
+ allowSimulations = value;
+ }
+
+ get {
+ return allowSimulations;
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool AllowVectorFonts
+ {
+ set {
+ allowVectorFonts = value;
+ }
+
+ get {
+ return allowVectorFonts;
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool AllowVerticalFonts
+ {
+ set {
+ allowVerticalFonts = value;
+ }
+
+ get {
+ return allowVerticalFonts;
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool AllowScriptChange
+ {
+ set {
+ allowScriptChange = value;
+ }
+
+ get {
+ return allowScriptChange;
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool FixedPitchOnly
+ {
+ set {
+ fixedPitchOnly = value;
+ }
+
+ get {
+ return fixedPitchOnly;
+ }
+ }
+
+ [DefaultValue(0)]
+ public int MaxSize
+ {
+ set {
+ maxSize = value;
+
+ if (maxSize < 0)
+ maxSize = 0;
+
+ if (maxSize < minSize)
+ minSize = maxSize;
+
+ CreateFontSizeListBoxItems ();
+ }
+
+ get {
+ return maxSize;
+ }
+ }
+
+ [DefaultValue(0)]
+ public int MinSize
+ {
+ set {
+ minSize = value;
+
+ if (minSize < 0)
+ minSize = 0;
+
+ if (minSize > maxSize)
+ maxSize = minSize;
+
+ CreateFontSizeListBoxItems ();
+
+ if (minSize > currentSize)
+ if (font != null) {
+ font.Dispose();
+
+ currentSize = minSize;
+
+ font = new Font( currentFamily, currentSize, currentFontStyle );
+
+ UpdateExamplePanel ();
+
+ fontsizeTextBox.Text = currentSize.ToString ();
+ }
+ }
+
+ get {
+ return minSize;
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool ScriptsOnly
+ {
+ set {
+ scriptsOnly = value;
+ }
+
+ get {
+ return scriptsOnly;
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool ShowApply
+ {
+ set {
+ if (value != showApply)
+ {
+ showApply = value;
+ if (showApply)
+ applyButton.Show ();
+ else
+ applyButton.Hide ();
+
+ form.Refresh();
+ }
+
+ }
+
+ get {
+ return showApply;
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool ShowColor
+ {
+ set {
+ if (value != showColor)
+ {
+ showColor = value;
+ if (showColor)
+ colorComboBox.Show ();
+ else
+ colorComboBox.Hide ();
+
+ form.Refresh();
+ }
+ }
+
+ get {
+ return showColor;
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool ShowEffects
+ {
+ set {
+ if (value != showEffects)
+ {
+ showEffects = value;
+ if (showEffects)
+ effectsGroupBox.Show ();
+ else
+ effectsGroupBox.Hide ();
+
+ form.Refresh();
+ }
+ }
+
+ get {
+ return showEffects;
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool ShowHelp
+ {
+ set {
+ if (value != showHelp)
+ {
+ showHelp = value;
+ if (showHelp)
+ helpButton.Show ();
+ else
+ helpButton.Hide ();
+
+ form.Refresh();
+ }
+ }
+
+ get {
+ return showHelp;
+ }
+ }
+
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Properties
+ #endregion // Protected Instance Properties
+
+ #region Public Instance Methods
+ [MonoTODO]
+ public override void Reset( )
+ {
+ color = Color.Black;
+ allowSimulations = true;
+ allowVectorFonts = true;
+ allowVerticalFonts = true;
+ allowScriptChange = true;
+ fixedPitchOnly = false;
+
+ maxSize = 0;
+ minSize = 0;
+ CreateFontSizeListBoxItems ();
+
+ scriptsOnly = false;
+
+ showApply = false;
+ applyButton.Hide ();
+
+ showColor = false;
+ colorComboBox.Hide ();
+
+ showEffects = true;
+ effectsGroupBox.Show ();
+
+ showHelp = false;
+ helpButton.Hide ();
+
+ form.Refresh ();
+ }
+
+ public override string ToString ()
+ {
+ if (font == null)
+ return base.ToString ();
+ return String.Concat (base.ToString (), ", Font: ", font.ToString ());
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ [MonoTODO]
+ protected override bool RunDialog( IntPtr hwndOwner )
+ {
+ form.Refresh();
+
+ return true;
+ }
+
+ internal void OnApplyButton (object sender, EventArgs e)
+ {
+ OnApply (e);
+ }
+
+ protected virtual void OnApply (EventArgs e)
+ {
+ EventHandler apply = (EventHandler) Events [EventApply];
+ if (apply != null)
+ apply (this, e);
+ }
+ #endregion // Protected Instance Methods
+
+ void OnClickCancelButton( object sender, EventArgs e )
+ {
+ form.DialogResult = DialogResult.Cancel;
+ }
+
+ void OnClickOkButton( object sender, EventArgs e )
+ {
+ form.DialogResult = DialogResult.OK;
+ }
+
+ void OnPaintExamplePanel( object sender, PaintEventArgs e )
+ {
+ SolidBrush brush = ThemeEngine.Current.ResPool.GetSolidBrush( color );
+
+ e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( SystemColors.Control ), 0, 0, 156, 40 );
+
+ ControlPaint.DrawBorder3D(e.Graphics, e.ClipRectangle, Border3DStyle.SunkenInner);
+
+ string text = "AaBbYyZz";
+
+ SizeF fontSizeF = e.Graphics.MeasureString( text, font );
+
+ int text_width = (int)fontSizeF.Width;
+ int text_height = (int)fontSizeF.Height;
+
+ int x = ( examplePanel.Width / 2 ) - ( text_width / 2 );
+ if ( x < 0 ) x = 0;
+
+ int y = ( examplePanel.Height / 2 ) - ( text_height / 2 );
+
+ e.Graphics.DrawString( text, font, brush, new Point( x, y ) );
+ }
+
+ void OnSelectedIndexChangedFontListBox( object sender, EventArgs e )
+ {
+ if ( fontListBox.SelectedIndex != -1 )
+ {
+ currentFamily = FindByName( fontListBox.Items[ fontListBox.SelectedIndex ].ToString( ) );
+
+ fontTextBox.Text = currentFamily.Name;
+
+ internal_change = true;
+
+ UpdateFontStyleListBox( );
+
+ UpdateFontSizeListBox ();
+
+ UpdateExamplePanel ();
+
+ form.Select(fontTextBox);
+
+ internal_change = false;
+ }
+ }
+
+ void OnSelectedIndexChangedSizeListBox( object sender, EventArgs e )
+ {
+ if ( fontsizeListBox.SelectedIndex != -1 )
+ {
+ currentSize = (float)System.Convert.ToDouble( fontsizeListBox.Items[ fontsizeListBox.SelectedIndex ] );
+
+ fontsizeTextBox.Text = currentSize.ToString( );
+
+ UpdateExamplePanel( );
+
+ if (!internal_change)
+ form.Select(fontsizeTextBox);
+ }
+ }
+
+ void OnSelectedIndexChangedFontStyleListBox( object sender, EventArgs e )
+ {
+ if ( fontstyleListBox.SelectedIndex != -1 )
+ {
+ switch ( fontstyleListBox.SelectedIndex )
+ {
+ case 0:
+ currentFontStyle = FontStyle.Regular;
+ break;
+ case 1:
+ currentFontStyle = FontStyle.Bold;
+ break;
+ case 2:
+ currentFontStyle = FontStyle.Italic;
+ break;
+ case 3:
+ currentFontStyle = FontStyle.Bold | FontStyle.Italic;
+ break;
+ default:
+ currentFontStyle = FontStyle.Regular;
+ break;
+ }
+
+ if (underlined)
+ currentFontStyle = currentFontStyle | FontStyle.Underline;
+
+ if (strikethrough)
+ currentFontStyle = currentFontStyle | FontStyle.Strikeout;
+
+ fontstyleTextBox.Text = fontstyleListBox.Items[ fontstyleListBox.SelectedIndex ].ToString( );
+
+ if (!internal_change) {
+ UpdateExamplePanel( );
+
+ form.Select(fontstyleTextBox);
+ }
+ }
+ }
+
+ void OnCheckedChangedUnderlinedCheckBox( object sender, EventArgs e )
+ {
+ if ( underlinedCheckBox.Checked ) {
+ currentFontStyle = currentFontStyle | FontStyle.Underline;
+ underlined = true;
+ }
+ else {
+ currentFontStyle = currentFontStyle ^ FontStyle.Underline;
+ underlined = false;
+ }
+
+ UpdateExamplePanel( );
+ }
+
+ void OnCheckedChangedStrikethroughCheckBox( object sender, EventArgs e )
+ {
+ if ( strikethroughCheckBox.Checked ) {
+ currentFontStyle = currentFontStyle | FontStyle.Strikeout;
+ strikethrough = true;
+ }
+ else {
+ currentFontStyle = currentFontStyle ^ FontStyle.Strikeout;
+ strikethrough = false;
+ }
+
+ UpdateExamplePanel( );
+ }
+
+ void OnFontTextBoxKeyUp (object sender, KeyEventArgs e)
+ {
+ for (int i = 0; i < fontListBox.Items.Count; i++) {
+ string name = fontListBox.Items [i] as string;
+
+ if (name.StartsWith(fontTextBox.Text)) {
+ if (name == fontTextBox.Text)
+ fontListBox.SelectedIndex = i;
+ else
+ fontListBox.TopIndex = i;
+
+ break;
+ }
+ }
+ }
+
+ void OnFontStyleTextBoxKeyUp (object sender, KeyEventArgs e)
+ {
+ for (int i = 0; i < fontstyleListBox.Items.Count; i++) {
+ string name = fontstyleListBox.Items [i] as string;
+
+ if (name.StartsWith(fontstyleTextBox.Text)) {
+ if (name == fontstyleTextBox.Text)
+ fontstyleListBox.SelectedIndex = i;
+ else
+ fontstyleListBox.TopIndex = i;
+
+ break;
+ }
+ }
+ }
+
+ void OnFontSizeTextBoxKeyUp (object sender, KeyEventArgs e)
+ {
+ for (int i = 0; i < fontsizeListBox.Items.Count; i++) {
+ string name = fontsizeListBox.Items [i] as string;
+
+ if (name.StartsWith(fontsizeTextBox.Text)) {
+ if (name == fontsizeTextBox.Text)
+ fontsizeListBox.SelectedIndex = i;
+ else
+ fontsizeListBox.TopIndex = i;
+
+ break;
+ }
+ }
+ }
+
+ void UpdateExamplePanel( )
+ {
+ if (font != null)
+ font.Dispose();
+
+ font = new Font( currentFamily, currentSize, currentFontStyle );
+
+ examplePanel.Invalidate( );
+ }
+
+ void UpdateFontSizeListBox ()
+ {
+ int index = fontsizeListBox.FindString(currentSize.ToString());
+
+ if (index != -1)
+ fontsizeListBox.SelectedIndex = index;
+ else
+ fontsizeListBox.SelectedIndex = 0;
+ }
+
+ void UpdateFontStyleListBox( )
+ {
+ // don't know if that works, IsStyleAvailable returns true for all styles under X
+
+ fontstyleListBox.BeginUpdate( );
+
+ fontstyleListBox.Items.Clear( );
+
+ int index = -1;
+ int to_select = 0;
+
+ if ( currentFamily.IsStyleAvailable( FontStyle.Regular ) )
+ {
+ index = fontstyleListBox.Items.Add( "Regular" );
+
+ if ((currentFontStyle & FontStyle.Regular) == FontStyle.Regular)
+ to_select = index;
+ }
+
+ if ( currentFamily.IsStyleAvailable( FontStyle.Bold ) )
+ {
+ index = fontstyleListBox.Items.Add( "Bold" );
+
+ if ((currentFontStyle & FontStyle.Bold) == FontStyle.Bold)
+ to_select = index;
+ }
+
+ if ( currentFamily.IsStyleAvailable( FontStyle.Italic ) )
+ {
+ index = fontstyleListBox.Items.Add( "Italic" );
+
+ if ((currentFontStyle & FontStyle.Italic) == FontStyle.Italic)
+ to_select = index;
+ }
+
+ if ( currentFamily.IsStyleAvailable( FontStyle.Bold ) && currentFamily.IsStyleAvailable( FontStyle.Italic ) )
+ {
+ index = fontstyleListBox.Items.Add( "Bold Italic" );
+
+ if ((currentFontStyle & (FontStyle.Bold | FontStyle.Italic)) == (FontStyle.Bold | FontStyle.Italic))
+ to_select = index;
+ }
+
+ if (fontstyleListBox.Items.Count > 0)
+ fontstyleListBox.SelectedIndex = to_select;
+
+ fontstyleListBox.EndUpdate( );
+ }
+
+ FontFamily FindByName( string name )
+ {
+ return fontHash[ name ] as FontFamily;
+ }
+
+ void CreateFontSizeListBoxItems ()
+ {
+ fontsizeListBox.BeginUpdate ();
+
+ fontsizeListBox.Items. Clear();
+
+ if (minSize == 0 && maxSize == 0)
+ {
+ foreach (int i in a_sizes)
+ fontsizeListBox.Items.Add (i.ToString());
+ } else {
+ foreach (int i in a_sizes) {
+ if (i >= minSize && i <= maxSize)
+ fontsizeListBox.Items.Add (i.ToString());
+ }
+ }
+
+ fontsizeListBox.EndUpdate ();
+ }
+
+ internal class ColorComboBox : ComboBox
+ {
+ internal class ColorComboBoxItem
+ {
+ private Color color;
+ private string name;
+
+ public ColorComboBoxItem( Color color, string name )
+ {
+ this.color = color;
+ this.name = name;
+ }
+
+ public Color Color
+ {
+ set {
+ color = value;
+ }
+
+ get {
+ return color;
+ }
+ }
+
+ public string Name
+ {
+ set {
+ name = value;
+ }
+
+ get {
+ return name;
+ }
+ }
+ }
+
+ private Color selectedColor;
+
+ private FontDialog fontDialog;
+
+ public ColorComboBox( FontDialog fontDialog )
+ {
+ this.fontDialog = fontDialog;
+
+ DropDownStyle = ComboBoxStyle.DropDownList;
+ DrawMode = DrawMode.OwnerDrawFixed;
+
+ Items.AddRange( new object[] {
+ new ColorComboBoxItem( Color.Black, "Black" ),
+ new ColorComboBoxItem( Color.DarkRed, "Dark-Red" ),
+ new ColorComboBoxItem( Color.Green, "Green" ),
+ new ColorComboBoxItem( Color.Olive, "Olive-Green" ), // color not correct
+ new ColorComboBoxItem( Color.Aquamarine, "Aquamarine" ), // color not correct
+ new ColorComboBoxItem( Color.Crimson, "Crimson" ),
+ new ColorComboBoxItem( Color.Cyan, "Cyan" ),
+ new ColorComboBoxItem( Color.Gray, "Gray" ),
+ new ColorComboBoxItem( Color.Silver, "Silver" ),
+ new ColorComboBoxItem( Color.Red, "Red" ),
+ new ColorComboBoxItem( Color.YellowGreen, "Yellow-Green" ),
+ new ColorComboBoxItem( Color.Yellow, "Yellow" ),
+ new ColorComboBoxItem( Color.Blue, "Blue" ),
+ new ColorComboBoxItem( Color.Purple, "Purple" ),
+ new ColorComboBoxItem( Color.Aquamarine, "Aquamarine" ),
+ new ColorComboBoxItem( Color.White, "White" ) }
+ );
+
+ SelectedIndex = 0;
+ }
+
+ protected override void OnDrawItem( DrawItemEventArgs e )
+ {
+ if ( e.Index == -1 )
+ return;
+
+ ColorComboBoxItem ccbi = Items[ e.Index ] as ColorComboBoxItem;
+
+ Rectangle r = e.Bounds;
+ r.X = r.X + 24;
+
+ if ( ( e.State & DrawItemState.Selected ) == DrawItemState.Selected )
+ {
+ e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( Color.Blue ), e.Bounds ); // bot blue
+ e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( ccbi.Color ), e.Bounds.X + 3, e.Bounds.Y + 3, e.Bounds.X + 16, e.Bounds.Bottom - 3 );
+ e.Graphics.DrawRectangle( ThemeEngine.Current.ResPool.GetPen( Color.Black ), e.Bounds.X + 2, e. Bounds.Y + 2, e.Bounds.X + 17, e.Bounds.Bottom - 3 );
+ e.Graphics.DrawString( ccbi.Name, this.Font, ThemeEngine.Current.ResPool.GetSolidBrush( Color.White ), r );
+ }
+ else
+ {
+ e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( Color.White ), e.Bounds );
+ e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( ccbi.Color ), e.Bounds.X + 3, e.Bounds.Y + 3, e.Bounds.X + 16, e.Bounds.Bottom - 3 );
+ e.Graphics.DrawRectangle( ThemeEngine.Current.ResPool.GetPen( Color.Black ), e.Bounds.X + 2, e. Bounds.Y + 2, e.Bounds.X + 17, e.Bounds.Bottom - 3 );
+ e.Graphics.DrawString( ccbi.Name, this.Font, ThemeEngine.Current.ResPool.GetSolidBrush( Color.Black ), r );
+ }
+ }
+
+ protected override void OnSelectedIndexChanged( EventArgs e )
+ {
+ ColorComboBoxItem ccbi = Items[ SelectedIndex ] as ColorComboBoxItem;
+ selectedColor = ccbi.Color;
+
+ fontDialog.Color = selectedColor;
+ }
+ }
+
+ public event EventHandler Apply {
+ add { Events.AddHandler (EventApply, value); }
+ remove { Events.RemoveHandler (EventApply, value); }
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
new file mode 100644
index 00000000000..e53572e54eb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
@@ -0,0 +1,1844 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Drawing;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.ComponentModel.Design.Serialization;
+using System.Collections;
+using System.Runtime.InteropServices;
+using System.Threading;
+
+namespace System.Windows.Forms {
+ [DesignerCategory("Form")]
+ [DesignTimeVisible(false)]
+ [Designer("System.Windows.Forms.Design.FormDocumentDesigner, " + Consts.AssemblySystem_Design, typeof(IRootDesigner))]
+ [DefaultEvent("Load")]
+ [ToolboxItem(false)]
+ public class Form : ContainerControl {
+ #region Local Variables
+ internal static Form active_form;
+ internal bool closing;
+ FormBorderStyle form_border_style;
+ private bool autoscale;
+ private Size clientsize_set;
+ private Size autoscale_base_size;
+ private bool allow_transparency;
+ private static Icon default_icon;
+ internal bool is_modal;
+ internal FormWindowState window_state;
+ private bool control_box;
+ private bool minimize_box;
+ private bool maximize_box;
+ private bool help_button;
+ private bool show_in_taskbar;
+ private bool topmost;
+ private IButtonControl accept_button;
+ private IButtonControl cancel_button;
+ private DialogResult dialog_result;
+ private FormStartPosition start_position;
+ private Form owner;
+ private Form.ControlCollection owned_forms;
+ private MdiClient mdi_container;
+ private InternalWindowManager window_manager;
+ private Form mdi_parent;
+ private bool key_preview;
+ private MainMenu menu;
+ private Icon icon;
+ private Size maximum_size;
+ private Size minimum_size;
+ private SizeGripStyle size_grip_style;
+ private Rectangle maximized_bounds;
+ private Rectangle default_maximized_bounds;
+ private double opacity;
+ internal ApplicationContext context;
+ Color transparency_key;
+ internal MenuTracker active_tracker;
+
+ #endregion // Local Variables
+
+ #region Private & Internal Methods
+ static Form ()
+ {
+ default_icon = (Icon)Locale.GetResource("mono.ico");
+ }
+ #endregion // Private & Internal Methods
+
+ #region Public Classes
+ public new class ControlCollection : Control.ControlCollection {
+ Form form_owner;
+
+ public ControlCollection(Form owner) : base(owner) {
+ this.form_owner = owner;
+ }
+
+ public override void Add(Control value) {
+ if (Contains (value))
+ return;
+ AddToList (value);
+ ((Form)value).owner=(Form)owner;
+ }
+
+ public override void Remove(Control value) {
+ ((Form)value).owner = null;
+ base.Remove (value);
+ }
+ }
+ #endregion // Public Classes
+
+ #region Public Constructor & Destructor
+ public Form ()
+ {
+ SizeF current_scale = GetAutoScaleSize (DeviceContext, Font);
+
+ autoscale = true;
+ autoscale_base_size = new Size ((int)current_scale.Width, (int) current_scale.Height);
+ allow_transparency = false;
+ closing = false;
+ is_modal = false;
+ dialog_result = DialogResult.None;
+ start_position = FormStartPosition.WindowsDefaultLocation;
+ form_border_style = FormBorderStyle.Sizable;
+ window_state = FormWindowState.Normal;
+ key_preview = false;
+ opacity = 1D;
+ menu = null;
+ icon = default_icon;
+ minimum_size = Size.Empty;
+ maximum_size = Size.Empty;
+ clientsize_set = Size.Empty;
+ control_box = true;
+ minimize_box = true;
+ maximize_box = true;
+ help_button = false;
+ show_in_taskbar = true;
+ ime_mode = ImeMode.NoControl;
+ is_visible = false;
+ is_toplevel = true;
+ size_grip_style = SizeGripStyle.Auto;
+ maximized_bounds = Rectangle.Empty;
+ default_maximized_bounds = Rectangle.Empty;
+ owned_forms = new Form.ControlCollection(this);
+ transparency_key = Color.Empty;
+ }
+ #endregion // Public Constructor & Destructor
+
+ #region Public Static Properties
+
+ public static Form ActiveForm {
+ get {
+ Control active;
+
+ active = FromHandle(XplatUI.GetActive());
+
+ if (active != null) {
+ if ( !(active is Form)) {
+ Control parent;
+
+ parent = active.Parent;
+ while (parent != null) {
+ if (parent is Form) {
+ return (Form)parent;
+ }
+ parent = parent.Parent;
+ }
+ } else {
+ return (Form)active;
+ }
+ }
+ return null;
+ }
+ }
+
+ #endregion // Public Static Properties
+
+ #region Public Instance Properties
+ [DefaultValue(null)]
+ public IButtonControl AcceptButton {
+ get {
+ return accept_button;
+ }
+
+ set {
+ accept_button = value;
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool AllowTransparency {
+ get {
+ return allow_transparency;
+ }
+
+ set {
+ if (XplatUI.SupportsTransparency()) {
+ allow_transparency = value;
+
+ if (value) {
+ XplatUI.SetWindowTransparency(Handle, Opacity, TransparencyKey);
+ } else {
+ UpdateStyles(); // Remove the WS_EX_LAYERED style
+ }
+ }
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool AutoScale {
+ get {
+ return autoscale;
+ }
+
+ set {
+ autoscale = value;
+ }
+ }
+
+ [Localizable(true)]
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public virtual Size AutoScaleBaseSize {
+ get {
+ return autoscale_base_size;
+ }
+
+ set {
+ autoscale_base_size = value;
+ }
+ }
+
+ [Localizable(true)]
+ public override bool AutoScroll {
+ get {
+ return base.AutoScroll;
+ }
+ set {
+ base.AutoScroll = value;
+ }
+ }
+
+ public override Color BackColor {
+ get {
+ return base.BackColor;
+ }
+ set {
+ base.BackColor = value;
+ }
+ }
+
+ [DefaultValue(null)]
+ public IButtonControl CancelButton {
+ get {
+ return cancel_button;
+ }
+
+ set {
+ cancel_button = value;
+ }
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
+ [Localizable(true)]
+ public Size ClientSize {
+ get {
+ return base.ClientSize;
+ }
+
+ set {
+ base.ClientSize = value;
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool ControlBox {
+ get {
+ return control_box;
+ }
+
+ set {
+ if (control_box != value) {
+ control_box = value;
+ UpdateStyles();
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Rectangle DesktopBounds {
+ get {
+ return new Rectangle(Location, Size);
+ }
+
+ set {
+ Bounds = value;
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Point DesktopLocation {
+ get {
+ return Location;
+ }
+
+ set {
+ Location = value;
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public DialogResult DialogResult {
+ get {
+ return dialog_result;
+ }
+
+ set {
+ dialog_result = value;
+ if (is_modal) {
+ closing = true;
+ }
+ }
+ }
+
+ [DefaultValue(FormBorderStyle.Sizable)]
+ [DispId(-504)]
+ public FormBorderStyle FormBorderStyle {
+ get {
+ return form_border_style;
+ }
+ set {
+ form_border_style = value;
+
+ if (window_manager == null) {
+ if (IsHandleCreated) {
+ XplatUI.SetBorderStyle(window.Handle, form_border_style);
+ }
+
+ if (value == FormBorderStyle.FixedToolWindow ||
+ value == FormBorderStyle.SizableToolWindow)
+ window_manager = new InternalWindowManager (this);
+ } else {
+ window_manager.UpdateBorderStyle (value);
+ }
+
+ UpdateStyles();
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool HelpButton {
+ get {
+ return help_button;
+ }
+
+ set {
+ if (help_button != value) {
+ help_button = value;
+ UpdateStyles();
+ }
+ }
+ }
+
+ [Localizable(true)]
+ [AmbientValue(null)]
+ public Icon Icon {
+ get {
+ return icon;
+ }
+
+ set {
+ if (icon != value) {
+ icon = value;
+
+ if (IsHandleCreated) {
+ XplatUI.SetIcon(Handle, icon == null ? default_icon : icon);
+ }
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool IsMdiChild {
+ get {
+ return mdi_parent != null;
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool IsMdiContainer {
+ get {
+ return mdi_container != null;
+ }
+
+ set {
+ if (value && mdi_container == null) {
+ mdi_container = new MdiClient();
+ Controls.Add(mdi_container);
+ } else if (!value && mdi_container != null) {
+ Controls.Remove(mdi_container);
+ mdi_container = null;
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Form ActiveMdiChild {
+ get {
+ if (!IsMdiContainer)
+ return null;
+ return (Form) mdi_container.ActiveMdiChild;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public bool IsRestrictedWindow {
+ get {
+ return false;
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool KeyPreview {
+ get {
+ return key_preview;
+ }
+
+ set {
+ key_preview = value;
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool MaximizeBox {
+ get {
+ return maximize_box;
+ }
+ set {
+ if (maximize_box != value) {
+ maximize_box = value;
+ if (IsHandleCreated) {
+ RecreateHandle();
+ }
+ UpdateStyles();
+ }
+ }
+ }
+
+ [DefaultValue("{Width=0, Height=0}")]
+ [Localizable(true)]
+ [RefreshProperties(RefreshProperties.Repaint)]
+ public Size MaximumSize {
+ get {
+ return maximum_size;
+ }
+
+ set {
+ if (maximum_size != value) {
+ maximum_size = value;
+ OnMaximumSizeChanged(EventArgs.Empty);
+ if (IsHandleCreated) {
+ XplatUI.SetWindowMinMax(Handle, maximized_bounds, minimum_size, maximum_size);
+ }
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Form[] MdiChildren {
+ get {
+ if (mdi_container != null) {
+ Form[] form_list;
+
+ form_list = new Form[mdi_container.Controls.Count];
+ for (int i = 0; i < mdi_container.Controls.Count; i++) {
+ form_list[i] = (Form)mdi_container.Controls[i];
+ }
+ return form_list;
+ } else {
+ return new Form[0];
+ }
+ }
+ }
+
+ [MonoTODO("Finish setter")]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Form MdiParent {
+ get {
+ return mdi_parent;
+ }
+
+ set {
+ SuspendLayout ();
+
+ // TopLevel = true;
+
+ if (!value.IsMdiContainer)
+ throw new ArgumentException ();
+
+ if (mdi_parent != null) {
+ mdi_parent.MdiContainer.Controls.Remove (this);
+ }
+
+ mdi_parent = value;
+ if (mdi_parent != null) {
+ window_manager = new MdiWindowManager (this,
+ mdi_parent.MdiContainer);
+ mdi_parent.MdiContainer.Controls.Add (this);
+ UpdateStyles ();
+ }
+
+ ResumeLayout ();
+ }
+ }
+
+ internal MenuTracker ActiveTracker {
+ get { return active_tracker; }
+ set {
+ if (value == active_tracker)
+ return;
+
+ Capture = value != null;
+ active_tracker = value;
+ }
+ }
+
+ internal MdiClient MdiContainer {
+ get { return mdi_container; }
+ }
+
+ internal InternalWindowManager WindowManager {
+ get { return window_manager; }
+ }
+
+ [DefaultValue(null)]
+ public MainMenu Menu {
+ get {
+ return menu;
+ }
+
+ set {
+ if (menu != value) {
+ menu = value;
+
+ if (menu != null && !IsMdiChild) {
+ menu.SetForm (this);
+
+ if (IsHandleCreated) {
+ XplatUI.SetMenu (window.Handle, menu);
+ }
+
+ if (clientsize_set != Size.Empty) {
+ SetClientSizeCore(clientsize_set.Width, clientsize_set.Height);
+ } else {
+ UpdateBounds (bounds.X, bounds.Y, bounds.Width, bounds.Height, ClientSize.Width, ClientSize.Height -
+ ThemeEngine.Current.CalcMenuBarSize (DeviceContext, menu, ClientSize.Width));
+ }
+ } else
+ UpdateBounds ();
+ }
+ }
+ }
+
+ public MainMenu MergedMenu {
+ get {
+ if (!IsMdiChild || window_manager == null)
+ return null;
+ return ((MdiWindowManager) window_manager).MergedMenu;
+ }
+ }
+
+ // This is the menu in display and being used because of merging this can
+ // be different then the menu that is actually assosciated with the form
+ internal MainMenu ActiveMenu {
+ get {
+ if (IsMdiChild)
+ return null;
+
+ if (IsMdiContainer && mdi_container.Controls.Count > 0 &&
+ ((Form) mdi_container.Controls [0]).WindowState == FormWindowState.Maximized) {
+ MdiWindowManager wm = (MdiWindowManager) ((Form) mdi_container.Controls [0]).WindowManager;
+ return wm.MaximizedMenu;
+ }
+
+ Form amc = ActiveMdiChild;
+ if (amc == null || amc.Menu == null)
+ return menu;
+ return amc.MergedMenu;
+ }
+ }
+
+ internal MdiWindowManager ActiveMaximizedMdiChild {
+ get {
+ Form child = ActiveMdiChild;
+ if (child == null)
+ return null;
+ if (child.WindowManager == null || child.window_state != FormWindowState.Maximized)
+ return null;
+ return (MdiWindowManager) child.WindowManager;
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool MinimizeBox {
+ get {
+ return minimize_box;
+ }
+ set {
+ if (minimize_box != value) {
+ minimize_box = value;
+ if (IsHandleCreated) {
+ RecreateHandle();
+ }
+ UpdateStyles();
+ }
+ }
+ }
+
+ [DefaultValue("{Width=0, Height=0}")]
+ [Localizable(true)]
+ [RefreshProperties(RefreshProperties.Repaint)]
+ public Size MinimumSize {
+ get {
+ return minimum_size;
+ }
+
+ set {
+ if (minimum_size != value) {
+ minimum_size = value;
+ OnMinimumSizeChanged(EventArgs.Empty);
+ if (IsHandleCreated) {
+ XplatUI.SetWindowMinMax(Handle, maximized_bounds, minimum_size, maximum_size);
+ }
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool Modal {
+ get {
+ return is_modal;
+ }
+ }
+
+ [DefaultValue(1D)]
+ [TypeConverter(typeof(OpacityConverter))]
+ public double Opacity {
+ get {
+ return opacity;
+ }
+
+ set {
+ opacity = value;
+
+ AllowTransparency = true;
+ UpdateStyles();
+ XplatUI.SetWindowTransparency(Handle, opacity, TransparencyKey);
+ }
+ }
+
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Form[] OwnedForms {
+ get {
+ Form[] form_list;
+
+ form_list = new Form[owned_forms.Count];
+
+ for (int i=0; i<owned_forms.Count; i++) {
+ form_list[i] = (Form)owned_forms[i];
+ }
+
+ return form_list;
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Form Owner {
+ get {
+ return owner;
+ }
+
+ set {
+ if (owner != value) {
+ if (owner != null) {
+ owner.RemoveOwnedForm(this);
+ }
+ owner = value;
+ owner.AddOwnedForm(this);
+ if (IsHandleCreated) {
+ if (owner != null && owner.IsHandleCreated) {
+ XplatUI.SetTopmost(this.window.Handle, owner.window.Handle, true);
+ } else {
+ XplatUI.SetTopmost(this.window.Handle, IntPtr.Zero, false);
+ }
+ }
+ }
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool ShowInTaskbar {
+ get {
+ return show_in_taskbar;
+ }
+ set {
+ if (show_in_taskbar != value) {
+ show_in_taskbar = value;
+ if (IsHandleCreated) {
+ RecreateHandle();
+ }
+ UpdateStyles();
+ }
+ }
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [Localizable(false)]
+ public Size Size {
+ get {
+ return base.Size;
+ }
+
+ set {
+ base.Size = value;
+ }
+ }
+
+ [MonoTODO("Trigger something when GripStyle is set")]
+ [DefaultValue(SizeGripStyle.Auto)]
+ public SizeGripStyle SizeGripStyle {
+ get {
+ return size_grip_style;
+ }
+
+ set {
+ size_grip_style = value;
+ }
+ }
+
+ [DefaultValue(FormStartPosition.WindowsDefaultLocation)]
+ [Localizable(true)]
+ public FormStartPosition StartPosition {
+ get {
+ return start_position;
+ }
+
+ set {
+ if (start_position == FormStartPosition.WindowsDefaultLocation) { // Only do this if it's not set yet
+ start_position = value;
+ if (IsHandleCreated) {
+ switch(start_position) {
+ case FormStartPosition.CenterParent: {
+ CenterToParent();
+ break;
+ }
+
+ case FormStartPosition.CenterScreen: {
+ CenterToScreen();
+ break;
+ }
+
+ default: {
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int TabIndex {
+ get {
+ return base.TabIndex;
+ }
+
+ set {
+ base.TabIndex = value;
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public bool TopLevel {
+ get {
+ return GetTopLevel();
+ }
+
+ set {
+ if (!value && IsMdiContainer)
+ throw new ArgumentException ("MDI Container forms must be top level.");
+ SetTopLevel(value);
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool TopMost {
+ get {
+ return topmost;
+ }
+
+ set {
+ if (topmost != value) {
+ topmost = value;
+ if (IsHandleCreated)
+ XplatUI.SetTopmost(window.Handle, owner != null ? owner.window.Handle : IntPtr.Zero, value);
+ }
+ }
+ }
+
+ public Color TransparencyKey {
+ get {
+ return transparency_key;
+ }
+
+ set {
+ transparency_key = value;
+
+ AllowTransparency = true;
+ UpdateStyles();
+ XplatUI.SetWindowTransparency(Handle, Opacity, transparency_key);
+ }
+ }
+
+ [DefaultValue(FormWindowState.Normal)]
+ public FormWindowState WindowState {
+ get {
+ if (IsHandleCreated) {
+
+ if (window_manager != null)
+ return window_manager.GetWindowState ();
+
+ try {
+ window_state = XplatUI.GetWindowState(Handle);
+ }
+
+ catch(NotSupportedException) {
+ }
+ }
+
+ return window_state;
+ }
+
+ set {
+ window_state = value;
+ if (IsHandleCreated) {
+
+ if (window_manager != null) {
+ window_manager.SetWindowState (window_state);
+ return;
+ }
+
+ try {
+ XplatUI.SetWindowState(Handle, value);
+ }
+
+ catch(NotSupportedException) {
+ }
+ }
+ }
+ }
+
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Properties
+ [MonoTODO("Need to set start position properly")]
+ protected override CreateParams CreateParams {
+ get {
+ CreateParams cp = new CreateParams ();
+
+ cp.Caption = Text;
+ cp.ClassName = XplatUI.DefaultClassName;
+ cp.ClassStyle = 0;
+ cp.Style = 0;
+ cp.ExStyle = 0;
+ cp.Param = 0;
+ cp.Parent = IntPtr.Zero;
+ cp.menu = ActiveMenu;
+
+// if (start_position == FormStartPosition.WindowsDefaultLocation) {
+ cp.X = unchecked((int)0x80000000);
+ cp.Y = unchecked((int)0x80000000);
+// } else {
+// cp.X = Left;
+// cp.Y = Top;
+// }
+ cp.Width = Width;
+ cp.Height = Height;
+
+ cp.Style = (int)(WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_CLIPSIBLINGS);
+
+ if (IsMdiChild) {
+ cp.Style |= (int)(WindowStyles.WS_CHILD | WindowStyles.WS_CAPTION);
+ cp.Parent = Parent.Handle;
+
+ cp.ExStyle |= (int) (WindowExStyles.WS_EX_WINDOWEDGE | WindowExStyles.WS_EX_MDICHILD);
+ switch (FormBorderStyle) {
+ case FormBorderStyle.None:
+ break;
+ case FormBorderStyle.FixedToolWindow:
+ case FormBorderStyle.SizableToolWindow:
+ cp.ExStyle |= (int) WindowExStyles.WS_EX_TOOLWINDOW;
+ goto default;
+ default:
+ cp.Style |= (int) WindowStyles.WS_OVERLAPPEDWINDOW;
+ break;
+ }
+
+ } else {
+ switch (FormBorderStyle) {
+ case FormBorderStyle.Fixed3D: {
+ cp.Style |= (int)(WindowStyles.WS_CAPTION | WindowStyles.WS_BORDER);
+ cp.ExStyle |= (int)WindowExStyles.WS_EX_CLIENTEDGE;
+ break;
+ }
+
+ case FormBorderStyle.FixedDialog: {
+ cp.Style |= (int)(WindowStyles.WS_CAPTION | WindowStyles.WS_BORDER);
+ cp.ExStyle |= (int)(WindowExStyles.WS_EX_DLGMODALFRAME);
+ break;
+ }
+
+ case FormBorderStyle.FixedSingle: {
+ cp.Style |= (int)(WindowStyles.WS_CAPTION | WindowStyles.WS_BORDER);
+ break;
+ }
+
+ case FormBorderStyle.FixedToolWindow: {
+ cp.Style |= (int)(WindowStyles.WS_CAPTION | WindowStyles.WS_BORDER);
+ cp.ExStyle |= (int)(WindowExStyles.WS_EX_TOOLWINDOW);
+ break;
+ }
+
+ case FormBorderStyle.Sizable: {
+ cp.Style |= (int)(WindowStyles.WS_BORDER | WindowStyles.WS_THICKFRAME | WindowStyles.WS_CAPTION);
+ break;
+ }
+
+ case FormBorderStyle.SizableToolWindow: {
+ cp.Style |= (int)(WindowStyles.WS_BORDER | WindowStyles.WS_THICKFRAME | WindowStyles.WS_CAPTION);
+ cp.ExStyle |= (int)(WindowExStyles.WS_EX_TOOLWINDOW);
+ break;
+ }
+
+ case FormBorderStyle.None: {
+ break;
+ }
+ }
+ }
+
+ switch(window_state) {
+ case FormWindowState.Maximized: {
+ cp.Style |= (int)WindowStyles.WS_MAXIMIZE;
+ break;
+ }
+
+ case FormWindowState.Minimized: {
+ cp.Style |= (int)WindowStyles.WS_MINIMIZE;
+ break;
+ }
+ }
+
+ if (TopMost) {
+ cp.ExStyle |= (int) WindowExStyles.WS_EX_TOPMOST;
+ }
+
+ if (ShowInTaskbar) {
+ cp.ExStyle |= (int)WindowExStyles.WS_EX_APPWINDOW;
+ }
+
+ if (MaximizeBox) {
+ cp.Style |= (int)WindowStyles.WS_MAXIMIZEBOX;
+ }
+
+ if (MinimizeBox) {
+ cp.Style |= (int)WindowStyles.WS_MINIMIZEBOX;
+ }
+
+ if (ControlBox) {
+ cp.Style |= (int)WindowStyles.WS_SYSMENU;
+ }
+
+ if (HelpButton && !MaximizeBox && !MinimizeBox) {
+ cp.ExStyle |= (int)WindowExStyles.WS_EX_CONTEXTHELP;
+ }
+
+ if (Visible)
+ cp.Style |= (int)WindowStyles.WS_VISIBLE;
+
+ if (Opacity < 1.0 || TransparencyKey != Color.Empty) {
+ cp.ExStyle |= (int)WindowExStyles.WS_EX_LAYERED;
+ }
+
+ if (!is_enabled && context == null) {
+ cp.Style |= (int)(WindowStyles.WS_DISABLED);
+ }
+
+ return cp;
+ }
+ }
+
+ protected override ImeMode DefaultImeMode {
+ get {
+ return ImeMode.NoControl;
+ }
+ }
+
+ protected override Size DefaultSize {
+ get {
+ return new Size (250, 250);
+ }
+ }
+
+ protected Rectangle MaximizedBounds {
+ get {
+ if (maximized_bounds != Rectangle.Empty) {
+ return maximized_bounds;
+ }
+ return default_maximized_bounds;
+ }
+
+ set {
+ maximized_bounds = value;
+ OnMaximizedBoundsChanged(EventArgs.Empty);
+ if (IsHandleCreated) {
+ XplatUI.SetWindowMinMax(Handle, maximized_bounds, minimum_size, maximum_size);
+ }
+ }
+ }
+ #endregion // Protected Instance Properties
+
+ #region Public Static Methods
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public static SizeF GetAutoScaleSize (Font font)
+ {
+ return XplatUI.GetAutoScaleSize(font);
+ }
+
+ #endregion // Public Static Methods
+
+ #region Public Instance Methods
+ internal SizeF GetAutoScaleSize (Graphics g, Font font)
+ {
+ //
+ // The following constants come from the dotnet mailing list
+ // discussion: http://discuss.develop.com/archives/wa.exe?A2=ind0203A&L=DOTNET&P=R3655
+ //
+ // The magic number is "Its almost the length
+ // of the string with a smattering added in
+ // for compat with earlier code".
+ //
+
+ string magic_string = "The quick brown fox jumped over the lazy dog.";
+ double magic_number = 44.549996948242189;
+ float width = (float) (g.MeasureString (magic_string, font).Width / magic_number);
+
+ return new SizeF (width, font.Height);
+ }
+
+ public void Activate() {
+ Form active;
+
+ // The docs say activate only activates if our app is already active
+ active = ActiveForm;
+ if ((active != null) && (this != active)) {
+ XplatUI.Activate(window.Handle);
+ }
+ }
+
+ public void AddOwnedForm(Form ownedForm) {
+ owned_forms.Add(ownedForm);
+ }
+
+ public void Close () {
+ if (!IsDisposed) {
+ XplatUI.SendMessage(this.Handle, Msg.WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
+ }
+ }
+
+ public void LayoutMdi(MdiLayout value) {
+ if (mdi_container != null) {
+ mdi_container.LayoutMdi(value);
+ }
+ }
+
+ public void RemoveOwnedForm(Form ownedForm) {
+ owned_forms.Remove(ownedForm);
+ }
+
+ public void SetDesktopBounds(int x, int y, int width, int height) {
+ DesktopBounds = new Rectangle(x, y, width, height);
+ }
+
+ public void SetDesktopLocation(int x, int y) {
+ DesktopLocation = new Point(x, y);
+ }
+
+ public DialogResult ShowDialog() {
+ return ShowDialog(null);
+ }
+
+ public DialogResult ShowDialog(IWin32Window ownerWin32) {
+ Form previous;
+
+ if (ownerWin32 != null) {
+ owner = (Form)Control.FromHandle(ownerWin32.Handle);
+ }
+
+ if (owner == this) {
+ throw new InvalidOperationException("The 'ownerWin32' cannot be the form being shown.");
+ }
+
+ if (is_modal) {
+ throw new InvalidOperationException("The form is already displayed as a modal dialog.");
+ }
+
+ if (Visible) {
+ throw new InvalidOperationException("Already visible forms cannot be displayed as a modal dialog. Set the Visible property to 'false' prior to calling Form.ShowDialog.");
+ }
+
+ if (!Enabled) {
+ throw new InvalidOperationException("Cannot display a disabled form as modal dialog.");
+ }
+
+ if (TopLevelControl != this) {
+ throw new InvalidOperationException("Can only display TopLevel forms as modal dialog.");
+ }
+
+ #if broken
+ // Can't do this, will screw us in the modal loop
+ form_parent_window.Parent = this.owner;
+ #endif
+
+ previous = Form.ActiveForm;
+
+ if (!IsHandleCreated) {
+ CreateControl();
+ }
+
+ Application.RunLoop(true, new ApplicationContext(this));
+
+ if (previous != null) {
+ // Cannot use Activate(), it has a check for the current active window...
+ XplatUI.Activate(previous.window.Handle);
+ }
+
+ return DialogResult;
+ }
+
+ public override string ToString() {
+ return GetType().FullName.ToString() + ", Text: " + Text;
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ [MonoTODO("Finish when MDI is more complete")]
+ protected void ActivateMdiChild(Form form) {
+ OnMdiChildActivate(EventArgs.Empty);
+ throw new NotImplementedException();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void AdjustFormScrollbars(bool displayScrollbars) {
+ base.AdjustFormScrollbars (displayScrollbars);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void ApplyAutoScaling()
+ {
+ SizeF current_size_f = GetAutoScaleSize (DeviceContext, Font);
+ Size current_size = new Size ((int) current_size_f.Width, (int) current_size_f.Height);
+
+ if (current_size == autoscale_base_size)
+ return;
+
+ if (Environment.GetEnvironmentVariable ("MONO_MWF_SCALING") == "disable"){
+ Console.WriteLine ("Not scaling");
+ return;
+ }
+
+ //
+ // I tried applying the Fudge height factor from:
+ // http://blogs.msdn.com/mharsh/archive/2004/01/25/62621.aspx
+ // but it makes things larger without looking better.
+ //
+ Scale (current_size_f.Width / AutoScaleBaseSize.Width + 0.08f,
+ current_size_f.Height / AutoScaleBaseSize.Height + 0.08f);
+
+ AutoScaleBaseSize = current_size;
+ }
+
+ protected void CenterToParent() {
+ Control ctl;
+ int w;
+ int h;
+
+ if (Width > 0) {
+ w = Width;
+ } else {
+ w = DefaultSize.Width;
+ }
+
+ if (Height > 0) {
+ h = Height;
+ } else {
+ h = DefaultSize.Height;
+ }
+
+ ctl = null;
+ if (parent != null) {
+ ctl = parent;
+ } else if (owner != null) {
+ ctl = owner;
+ }
+
+ if (owner != null) {
+ this.Location = new Point(ctl.Left + ctl.Width / 2 - w /2, ctl.Top + ctl.Height / 2 - h / 2);
+ }
+ }
+
+ protected void CenterToScreen() {
+ Size DisplaySize;
+ int w;
+ int h;
+
+ if (Width > 0) {
+ w = Width;
+ } else {
+ w = DefaultSize.Width;
+ }
+
+ if (Height > 0) {
+ h = Height;
+ } else {
+ h = DefaultSize.Height;
+ }
+
+ XplatUI.GetDisplaySize(out DisplaySize);
+ this.Location = new Point(DisplaySize.Width / 2 - w / 2, DisplaySize.Height / 2 - h / 2);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override Control.ControlCollection CreateControlsInstance() {
+ return base.CreateControlsInstance ();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void CreateHandle() {
+ base.CreateHandle ();
+
+ XplatUI.SetWindowMinMax(window.Handle, maximized_bounds, minimum_size, maximum_size);
+ if (icon != null) {
+ XplatUI.SetIcon(window.Handle, icon);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void DefWndProc(ref Message m) {
+ base.DefWndProc (ref m);
+ }
+
+ protected override void Dispose(bool disposing) {
+ base.Dispose (disposing);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnActivated(EventArgs e) {
+ if (Activated != null) {
+ Activated(this, e);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnClosed(EventArgs e) {
+ if (Closed != null) {
+ Closed(this, e);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnClosing(System.ComponentModel.CancelEventArgs e) {
+ if (Closing != null) {
+ Closing(this, e);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void OnCreateControl() {
+ base.OnCreateControl ();
+ if (this.ActiveControl == null) {
+ bool visible;
+
+ // This visible hack is to work around CanSelect always being false if one of the parents
+ // is not visible; and we by default create Form invisible...
+ visible = this.is_visible;
+ this.is_visible = true;
+
+ if (SelectNextControl(this, true, true, true, true) == false) {
+ Select(this);
+ }
+
+ this.is_visible = visible;
+ }
+
+ if (menu != null) {
+ XplatUI.SetMenu(window.Handle, menu);
+ }
+
+ OnLoad(EventArgs.Empty);
+
+ // Send initial location
+ OnLocationChanged(EventArgs.Empty);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnDeactivate(EventArgs e) {
+ if (Deactivate != null) {
+ Deactivate(this, e);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void OnFontChanged(EventArgs e) {
+ base.OnFontChanged (e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void OnHandleCreated(EventArgs e) {
+ XplatUI.SetBorderStyle(window.Handle, form_border_style);
+ base.OnHandleCreated (e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void OnHandleDestroyed(EventArgs e) {
+ base.OnHandleDestroyed (e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnInputLanguageChanged(InputLanguageChangedEventArgs e) {
+ if (InputLanguageChanged!=null) {
+ InputLanguageChanged(this, e);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnInputLanguageChanging(InputLanguageChangingEventArgs e) {
+ if (InputLanguageChanging!=null) {
+ InputLanguageChanging(this, e);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnLoad(EventArgs e) {
+ if (Load != null) {
+ Load(this, e);
+ }
+
+ if (AutoScale){
+ ApplyAutoScaling ();
+ AutoScale = false;
+ }
+
+ if (!IsMdiChild) {
+ switch (StartPosition) {
+ case FormStartPosition.CenterScreen:
+ this.CenterToScreen();
+ break;
+ case FormStartPosition.CenterParent:
+ this.CenterToParent ();
+ break;
+ }
+ } else {
+ Left = 25 * MdiParent.MdiContainer.ChildrenCreated + 1;
+ Top = 25 * MdiParent.MdiContainer.ChildrenCreated + 1;
+ MdiParent.MdiContainer.ChildrenCreated++;
+ }
+
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnMaximizedBoundsChanged(EventArgs e) {
+ if (MaximizedBoundsChanged != null) {
+ MaximizedBoundsChanged(this, e);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnMaximumSizeChanged(EventArgs e) {
+ if (MaximumSizeChanged != null) {
+ MaximumSizeChanged(this, e);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnMdiChildActivate(EventArgs e) {
+ if (MdiChildActivate != null) {
+ MdiChildActivate(this, e);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnMenuComplete(EventArgs e) {
+ if (MenuComplete != null) {
+ MenuComplete(this, e);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnMenuStart(EventArgs e) {
+ if (MenuStart != null) {
+ MenuStart(this, e);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnMinimumSizeChanged(EventArgs e) {
+ if (MinimumSizeChanged != null) {
+ MinimumSizeChanged(this, e);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void OnPaint (PaintEventArgs pevent) {
+ base.OnPaint (pevent);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void OnResize(EventArgs e) {
+ base.OnResize(e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void OnStyleChanged(EventArgs e) {
+ base.OnStyleChanged (e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void OnTextChanged(EventArgs e) {
+ base.OnTextChanged (e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void OnVisibleChanged(EventArgs e) {
+ base.OnVisibleChanged (e);
+ }
+
+ protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
+ if (base.ProcessCmdKey (ref msg, keyData)) {
+ return true;
+ }
+
+ // Give our menu a shot
+ if (ActiveMenu != null) {
+ return ActiveMenu.ProcessCmdKey(ref msg, keyData);
+ }
+
+ return false;
+ }
+
+ // LAMESPEC - Not documented that Form overrides ProcessDialogChar; class-status showed
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ protected override bool ProcessDialogChar(char charCode) {
+ return base.ProcessDialogChar (charCode);
+ }
+
+ protected override bool ProcessDialogKey(Keys keyData) {
+ if ((keyData & Keys.Modifiers) == 0) {
+ if (keyData == Keys.Enter && accept_button != null) {
+ accept_button.PerformClick();
+ return true;
+ } else if (keyData == Keys.Escape && cancel_button != null) {
+ cancel_button.PerformClick();
+ return true;
+ }
+ }
+ return base.ProcessDialogKey(keyData);
+ }
+
+ protected override bool ProcessKeyPreview(ref Message msg) {
+ if (key_preview) {
+ if (ProcessKeyEventArgs(ref msg)) {
+ return true;
+ }
+ }
+ return base.ProcessKeyPreview (ref msg);
+ }
+
+ protected override bool ProcessTabKey(bool forward) {
+ return SelectNextControl(ActiveControl, forward, true, true, true);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void ScaleCore(float dx, float dy) {
+ // We can't scale max or min windows
+ if (WindowState == FormWindowState.Normal) {
+ // We cannot call base since base also adjusts X/Y, but
+ // a form is toplevel and doesn't move
+ Size size;
+
+ SuspendLayout();
+
+ size = ClientSize;
+ if (!GetStyle(ControlStyles.FixedWidth)) {
+ size.Width = (int)(size.Width * dx);
+ }
+
+ if (!GetStyle(ControlStyles.FixedHeight)) {
+ size.Height = (int)(size.Height * dy);
+ }
+
+ ClientSize = size;
+
+ /* Now scale our children */
+ Control [] controls = child_controls.GetAllControls ();
+ for (int i=0; i < controls.Length; i++) {
+ controls[i].Scale(dx, dy);
+ }
+
+ ResumeLayout();
+ }
+ }
+
+ protected override void Select(bool directed, bool forward) {
+ Form parent;
+
+ if (directed) {
+ base.SelectNextControl(null, forward, true, true, true);
+ }
+
+ parent = this.ParentForm;
+ if (parent != null) {
+ parent.ActiveControl = this;
+ }
+
+ Activate();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
+ base.SetBoundsCore (x, y, width, height, specified);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void SetClientSizeCore(int x, int y) {
+ if ((minimum_size.Width != 0) && (x < minimum_size.Width)) {
+ x = minimum_size.Width;
+ } else if ((maximum_size.Width != 0) && (x > maximum_size.Width)) {
+ x = maximum_size.Width;
+ }
+
+ if ((minimum_size.Height != 0) && (y < minimum_size.Height)) {
+ y = minimum_size.Height;
+ } else if ((maximum_size.Height != 0) && (y > maximum_size.Height)) {
+ y = maximum_size.Height;
+ }
+
+ Rectangle ClientRect = new Rectangle(0, 0, x, y);
+ Rectangle WindowRect;
+ CreateParams cp = this.CreateParams;
+
+ clientsize_set = new Size(x, y);
+
+ if (XplatUI.CalculateWindowRect(ref ClientRect, cp.Style, cp.ExStyle, cp.menu, out WindowRect)) {
+ SetBoundsCore(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void SetVisibleCore(bool value) {
+ base.SetVisibleCore (value);
+ }
+
+ protected override void UpdateDefaultButton() {
+ base.UpdateDefaultButton ();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void WndProc(ref Message m) {
+
+ if (window_manager != null && window_manager.HandleMessage (ref m)) {
+ return;
+ }
+
+ switch((Msg)m.Msg) {
+ case Msg.WM_DESTROY: {
+ base.WndProc(ref m);
+ if (!is_recreating) {
+ this.closing = true;
+ }
+ return;
+ }
+
+ case Msg.WM_CLOSE_INTERNAL: {
+ DestroyHandle();
+ break;
+ }
+
+ case Msg.WM_CLOSE: {
+ if (!is_modal) {
+ CancelEventArgs args = new CancelEventArgs ();
+
+ OnClosing (args);
+ if (!args.Cancel) {
+ OnClosed (EventArgs.Empty);
+ DestroyHandle();
+ }
+ return;
+ } else {
+ closing = true;
+ }
+ return;
+ }
+
+ case Msg.WM_WINDOWPOSCHANGED: {
+ if (WindowState != FormWindowState.Minimized) {
+ base.WndProc(ref m);
+ }
+ return;
+ }
+
+ case Msg.WM_ACTIVATE: {
+ if (m.WParam != (IntPtr)WindowActiveFlags.WA_INACTIVE) {
+ OnActivated(EventArgs.Empty);
+ } else {
+ OnDeactivate(EventArgs.Empty);
+ }
+ return;
+ }
+
+ case Msg.WM_KILLFOCUS: {
+ base.WndProc(ref m);
+ return;
+ }
+
+ case Msg.WM_SETFOCUS: {
+ if (ActiveControl != null && ActiveControl != this) {
+ ActiveControl.Focus();
+ return; // FIXME - do we need to run base.WndProc, even though we just changed focus?
+ }
+ base.WndProc(ref m);
+ return;
+ }
+
+ // Menu drawing
+ case Msg.WM_NCLBUTTONDOWN: {
+ if (ActiveMenu != null) {
+ ActiveMenu.OnMouseDown(this, new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()), mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()), 0));
+ }
+
+ if (ActiveMaximizedMdiChild != null) {
+ ActiveMaximizedMdiChild.HandleMenuMouseDown (ActiveMenu,
+ LowOrder ((int) m.LParam.ToInt32 ()),
+ HighOrder ((int) m.LParam.ToInt32 ()));
+ }
+ base.WndProc(ref m);
+ return;
+ }
+
+ case Msg.WM_NCMOUSEMOVE: {
+ if (ActiveMenu != null) {
+ ActiveMenu.OnMouseMove(this, new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()), mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()), 0));
+ }
+ base.WndProc(ref m);
+ return;
+ }
+
+ case Msg.WM_NCPAINT: {
+ if (ActiveMenu != null) {
+ PaintEventArgs pe;
+ Point pnt;
+
+ pe = XplatUI.PaintEventStart(Handle, false);
+ pnt = XplatUI.GetMenuOrigin(window.Handle);
+
+ ActiveMenu.Draw (pe, new Rectangle (pnt.X, pnt.Y, ClientSize.Width, 0));
+
+ if (ActiveMaximizedMdiChild != null) {
+ ActiveMaximizedMdiChild.DrawMaximizedButtons (pe, ActiveMenu);
+ }
+
+ XplatUI.PaintEventEnd(Handle, false);
+ }
+
+ base.WndProc(ref m);
+ return;
+ }
+
+ case Msg.WM_NCCALCSIZE: {
+ XplatUIWin32.NCCALCSIZE_PARAMS ncp;
+
+ if ((ActiveMenu != null) && (m.WParam == (IntPtr)1)) {
+ ncp = (XplatUIWin32.NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(XplatUIWin32.NCCALCSIZE_PARAMS));
+
+ // Adjust for menu
+ ncp.rgrc1.top += ThemeEngine.Current.CalcMenuBarSize (DeviceContext, ActiveMenu, ClientSize.Width);
+ Marshal.StructureToPtr(ncp, m.LParam, true);
+ }
+ DefWndProc(ref m);
+ break;
+ }
+
+ case Msg.WM_MOUSEMOVE: {
+ if (active_tracker != null) {
+ MouseEventArgs args;
+
+ args = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
+ mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()), 0);
+ active_tracker.OnMotion(new MouseEventArgs (args.Button, args.Clicks, Control.MousePosition.X, Control.MousePosition.Y, args.Delta));
+ break;
+ }
+ base.WndProc(ref m);
+ break;
+ }
+
+ case Msg.WM_LBUTTONDOWN:
+ case Msg.WM_MBUTTONDOWN:
+ case Msg.WM_RBUTTONDOWN: {
+ if (active_tracker != null) {
+ MouseEventArgs args;
+
+ args = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
+ mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()), 0);
+ active_tracker.OnClick(new MouseEventArgs (args.Button, args.Clicks, Control.MousePosition.X, Control.MousePosition.Y, args.Delta));
+ return;
+ }
+ base.WndProc(ref m);
+ return;
+ }
+
+ case Msg.WM_LBUTTONUP:
+ case Msg.WM_MBUTTONUP:
+ case Msg.WM_RBUTTONUP: {
+ if (active_tracker != null) {
+ MouseEventArgs args;
+
+ args = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
+ mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()), 0);
+ active_tracker.OnMouseUp(new MouseEventArgs (args.Button, args.Clicks, Control.MousePosition.X, Control.MousePosition.Y, args.Delta));
+ mouse_clicks = 1;
+ return;
+ }
+ base.WndProc(ref m);
+ return;
+ }
+
+ case Msg.WM_GETMINMAXINFO: {
+ MINMAXINFO mmi;
+
+ if (m.LParam != IntPtr.Zero) {
+ mmi = (MINMAXINFO)Marshal.PtrToStructure(m.LParam, typeof(MINMAXINFO));
+
+ default_maximized_bounds = new Rectangle(mmi.ptMaxPosition.x, mmi.ptMaxPosition.y, mmi.ptMaxSize.x, mmi.ptMaxSize.y);
+ if (maximized_bounds != Rectangle.Empty) {
+ mmi.ptMaxPosition.x = maximized_bounds.Left;
+ mmi.ptMaxPosition.y = maximized_bounds.Top;
+ mmi.ptMaxSize.x = maximized_bounds.Width;
+ mmi.ptMaxSize.y = maximized_bounds.Height;
+ }
+
+ if (minimum_size != Size.Empty) {
+ mmi.ptMinTrackSize.x = minimum_size.Width;
+ mmi.ptMinTrackSize.y = minimum_size.Height;
+ }
+
+ if (minimum_size != Size.Empty) {
+ mmi.ptMaxTrackSize.x = maximum_size.Width;
+ mmi.ptMaxTrackSize.y = maximum_size.Height;
+ }
+ Marshal.StructureToPtr(mmi, m.LParam, false);
+ }
+ break;
+ }
+
+ default: {
+ base.WndProc (ref m);
+ break;
+ }
+ }
+ }
+ #endregion // Protected Instance Methods
+
+ internal void RemoveWindowManager ()
+ {
+ window_manager = null;
+ }
+
+ internal override void CheckAcceptButton()
+ {
+ if (accept_button != null) {
+ Button a_button = accept_button as Button;
+
+ if (ActiveControl == a_button)
+ return;
+
+ if (ActiveControl is Button) {
+ a_button.paint_as_acceptbutton = false;
+ a_button.Redraw();
+ return;
+ } else {
+ a_button.paint_as_acceptbutton = true;
+ a_button.Redraw();
+ }
+ }
+ }
+
+ #region Events
+ public event EventHandler Activated;
+ public event EventHandler Closed;
+ public event CancelEventHandler Closing;
+ public event EventHandler Deactivate;
+ public event InputLanguageChangedEventHandler InputLanguageChanged;
+ public event InputLanguageChangingEventHandler InputLanguageChanging;
+ public event EventHandler Load;
+ public event EventHandler MaximizedBoundsChanged;
+ public event EventHandler MaximumSizeChanged;
+ public event EventHandler MdiChildActivate;
+ public event EventHandler MenuComplete;
+ public event EventHandler MenuStart;
+ public event EventHandler MinimumSizeChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler TabIndexChanged;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FormBorderStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FormBorderStyle.cs
new file mode 100644
index 00000000000..5429f7468ec
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FormBorderStyle.cs
@@ -0,0 +1,43 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Ravindra (rkumar@novell.com)
+//
+
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+ [ComVisible (true)]
+ [Serializable]
+ public enum FormBorderStyle
+ {
+ None = 0,
+ FixedSingle = 1,
+ Fixed3D = 2,
+ FixedDialog = 3,
+ Sizable = 4,
+ FixedToolWindow = 5,
+ SizableToolWindow = 6
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FormStartPosition.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FormStartPosition.cs
new file mode 100644
index 00000000000..7c98700d80b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FormStartPosition.cs
@@ -0,0 +1,40 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Ravindra (rkumar@novell.com)
+//
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+ [ComVisible (true)]
+ [Serializable]
+ public enum FormStartPosition
+ {
+ Manual = 0,
+ CenterScreen = 1,
+ WindowsDefaultLocation = 2,
+ WindowsDefaultBounds = 3,
+ CenterParent = 4
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FormWindowState.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FormWindowState.cs
new file mode 100644
index 00000000000..84145d246ef
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FormWindowState.cs
@@ -0,0 +1,39 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Ravindra (rkumar@novell.com)
+//
+
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+ [ComVisible (true)]
+ [Serializable]
+ public enum FormWindowState
+ {
+ Normal = 0,
+ Minimized = 1,
+ Maximized = 2
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FrameStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FrameStyle.cs
new file mode 100644
index 00000000000..f80ef0b655f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FrameStyle.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum FrameStyle {
+ Dashed = 0,
+ Thick = 1
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GiveFeedbackEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GiveFeedbackEventArgs.cs
new file mode 100644
index 00000000000..940259e1d10
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GiveFeedbackEventArgs.cs
@@ -0,0 +1,62 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public class GiveFeedbackEventArgs : EventArgs {
+ internal DragDropEffects effect;
+ internal bool use_default_cursors;
+
+ #region Public Constructors
+ public GiveFeedbackEventArgs(DragDropEffects effect, bool useDefaultCursors) {
+ this.effect=effect;
+ this.use_default_cursors=useDefaultCursors;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public DragDropEffects Effect {
+ get {
+ return this.effect;
+ }
+ }
+
+ public bool UseDefaultCursors {
+ get {
+ return this.use_default_cursors;
+ }
+
+ set {
+ this.use_default_cursors=value;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GiveFeedbackEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GiveFeedbackEventHandler.cs
new file mode 100644
index 00000000000..3ffd9e29531
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GiveFeedbackEventHandler.cs
@@ -0,0 +1,32 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void GiveFeedbackEventHandler (object sender, GiveFeedbackEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridColumnStylesCollection.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridColumnStylesCollection.cs
new file mode 100644
index 00000000000..ed3aa7982bf
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridColumnStylesCollection.cs
@@ -0,0 +1,273 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+
+namespace System.Windows.Forms
+{
+ [Editor("System.Windows.Forms.Design.DataGridColumnCollectionEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
+ [ListBindable(false)]
+ public class GridColumnStylesCollection : BaseCollection, IList
+ {
+ private ArrayList items;
+ private DataGridTableStyle owner;
+ private bool fire_event;
+
+ internal GridColumnStylesCollection (DataGridTableStyle tablestyle)
+ {
+ items = new ArrayList ();
+ owner = tablestyle;
+ fire_event = true;
+ }
+
+ #region Public Instance Properties
+ public DataGridColumnStyle this [string columnName] {
+ get {
+ int idx = FromColumnNameToIndex (columnName);
+ return idx == -1 ? null : this [idx];
+ }
+ }
+
+ public DataGridColumnStyle this [int index] {
+ get {
+ return (DataGridColumnStyle) items[index];
+ }
+ }
+
+
+ public DataGridColumnStyle this [PropertyDescriptor propDesc] {
+ get {
+ for (int i = 0; i < items.Count; i++) {
+ DataGridColumnStyle column = (DataGridColumnStyle) items[i];
+ if (column.PropertyDescriptor.Equals (propDesc)) {
+ return column;
+ }
+ }
+
+ return null;
+ }
+ }
+
+ protected override ArrayList List {
+ get { return items; }
+ }
+
+ int ICollection.Count {
+ get { return items.Count;}
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return false; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return this;}
+ }
+
+ bool IList.IsFixedSize {
+ get { return false; }
+ }
+
+ bool IList.IsReadOnly {
+ get { return false;}
+ }
+
+ object IList.this [int index] {
+ get {
+ return items[index];
+ }
+ set {
+ throw new NotSupportedException ();
+ }
+ }
+
+ #endregion Public Instance Properties
+
+ #region Private Instance Properties
+ internal bool FireEvents {
+ get { return fire_event;}
+ set { fire_event = value;}
+ }
+ #endregion Private Instance Properties
+
+ #region Public Instance Methods
+ public virtual int Add (DataGridColumnStyle column)
+ {
+ int cnt = AddInternal (column);
+ return cnt;
+ }
+
+ public void AddRange (DataGridColumnStyle[] columns)
+ {
+ foreach (DataGridColumnStyle mi in columns)
+ AddInternal (mi);
+ }
+
+ public void Clear ()
+ {
+ items.Clear ();
+ OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Refresh , null));
+ }
+
+ public bool Contains (DataGridColumnStyle column)
+ {
+ return (FromColumnNameToIndex (column.MappingName) != -1);
+ }
+
+ public bool Contains (PropertyDescriptor propDesc)
+ {
+ return (this [propDesc] != null);
+ }
+
+ public bool Contains (string name)
+ {
+ return (FromColumnNameToIndex (name) != -1);
+ }
+
+ void ICollection.CopyTo (Array dest, int index)
+ {
+ items.CopyTo (dest, index);
+ }
+
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return items.GetEnumerator ();
+ }
+
+ int IList.Add (object value)
+ {
+ return AddInternal ((DataGridColumnStyle)value);
+ }
+
+ void IList.Clear ()
+ {
+ items.Clear ();
+ OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Refresh , null));
+ }
+
+ bool IList.Contains (object value)
+ {
+ return items.Contains (value);
+ }
+
+ int IList.IndexOf (object value)
+ {
+ return items.IndexOf (value);
+ }
+
+ void IList.Insert (int index, object value)
+ {
+ throw new NotSupportedException ();
+ }
+
+ void IList.Remove (object value)
+ {
+ items.Remove (value);
+ }
+
+ void IList.RemoveAt (int index)
+ {
+ object item = items[index];
+
+ items.RemoveAt (index);
+ OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Remove, item));
+ }
+
+ public int IndexOf (DataGridColumnStyle element)
+ {
+ return items.IndexOf (element);
+ }
+
+ protected void OnCollectionChanged (CollectionChangeEventArgs ccevent)
+ {
+ if (fire_event == true && CollectionChanged != null) {
+ CollectionChanged (this, ccevent);
+ }
+ }
+
+ public void Remove (DataGridColumnStyle column)
+ {
+ items.Remove (column);
+ OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Remove, column));
+ }
+
+ public void RemoveAt (int index)
+ {
+ object item = items[index];
+ items.RemoveAt (index);
+ OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Remove, item));
+ }
+
+ public void ResetPropertyDescriptors ()
+ {
+ for (int i = 0; i < items.Count; i++) {
+ DataGridColumnStyle column = (DataGridColumnStyle) items[i];
+ if (column.PropertyDescriptor != null) {
+ column.PropertyDescriptor = null;
+ }
+ }
+ }
+
+ #endregion Public Instance Methods
+
+ #region Events
+ public event CollectionChangeEventHandler CollectionChanged;
+ #endregion Events
+
+ #region Private Instance Methods
+ private int AddInternal (DataGridColumnStyle column)
+ {
+ // TODO: MS allows duplicate columns. How they diferenciate between them?
+ if (FromColumnNameToIndex (column.MappingName) != -1) {
+ throw new ArgumentException ("The ColumnStyles collection already has a column with this mapping name");
+ }
+
+ column.TableStyle = owner;
+ int cnt = items.Add (column);
+ OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Add, column));
+ return cnt;
+ }
+
+ private int FromColumnNameToIndex (string columnName)
+ {
+ for (int i = 0; i < items.Count; i++) {
+ DataGridColumnStyle column = (DataGridColumnStyle) items[i];
+
+ if (column.MappingName == null || column.MappingName == string.Empty)
+ continue;
+
+ if (String.Compare (column.MappingName, columnName, true) == 0) {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ #endregion Private Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
new file mode 100644
index 00000000000..cc8e38950b4
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
@@ -0,0 +1,167 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jonathan Chambers (jonathan.chambers@ansys.com)
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Drawing;
+
+namespace System.Windows.Forms.PropertyGridInternal
+{
+ internal class GridEntry : GridItem
+ {
+ #region Local Variables
+ private bool expanded = true;
+ private GridItemCollection grid_items;
+ private GridItem parent;
+ private PropertyDescriptor property_descriptor;
+ private object selected_object;
+ private string label;
+ private int top;
+ private Rectangle plus_minus_bounds;
+ private Rectangle bounds;
+ #endregion // Local Variables
+
+ #region Contructors
+ public GridEntry() : base() {
+ plus_minus_bounds = new Rectangle(0,0,0,0);
+ bounds = new Rectangle(0,0,0,0);
+ top = -1;
+ grid_items = new GridItemCollection();
+ }
+
+ public GridEntry(object obj, PropertyDescriptor prop_desc) : this() {
+ selected_object = obj;
+ property_descriptor = prop_desc;
+ }
+ #endregion // Constructors
+
+ #region Public Instance Properties
+ public override bool Expandable
+ {
+ get {
+ return grid_items.Count > 0;
+ }
+ }
+
+ public override bool Expanded
+ {
+ get {
+ return expanded;
+ }
+
+ set {
+ expanded = value;
+ }
+ }
+
+ public override System.Windows.Forms.GridItemCollection GridItems
+ {
+ get {
+ return grid_items;
+ }
+ }
+
+ public override System.Windows.Forms.GridItemType GridItemType
+ {
+ get {
+ return GridItemType.Property;
+ }
+ }
+
+ public override string Label
+ {
+ get {
+ return property_descriptor.Name;
+ }
+ }
+
+ public override System.Windows.Forms.GridItem Parent
+ {
+ get {
+ return parent;
+ }
+ }
+
+ public override System.ComponentModel.PropertyDescriptor PropertyDescriptor
+ {
+ get {
+ return property_descriptor;
+ }
+ }
+
+ public override object Value
+ {
+ get {
+ object return_value = null;
+ if (selected_object != null)
+ return_value = property_descriptor.GetValue(selected_object);
+ return return_value;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ [MonoTODO]
+ public override bool Select () {
+ throw new NotImplementedException();
+ }
+ #endregion // Public Instance Methods
+
+ internal override int Top {
+ get {
+ return top;
+ }
+ set {
+ top = value;
+ }
+ }
+
+ internal override Rectangle PlusMinusBounds {
+ get{
+ return plus_minus_bounds;
+ }
+ set{
+ plus_minus_bounds = value;
+ }
+ }
+
+ internal override Rectangle Bounds
+ {
+ get
+ {
+ return bounds;
+ }
+ set
+ {
+ bounds = value;
+ }
+ }
+
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridItem.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridItem.cs
new file mode 100644
index 00000000000..246ec173cf8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridItem.cs
@@ -0,0 +1,120 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jonathan Chambers (jonathan.chambers@ansys.com)
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Drawing;
+
+namespace System.Windows.Forms
+{
+ public abstract class GridItem
+ {
+
+ #region Fields
+ private bool expanded;
+ #endregion Fields
+
+ #region Constructors
+ protected GridItem()
+ {
+ expanded = false;
+ }
+ #endregion // Constructors
+
+ #region Public Instance Properties
+ public virtual bool Expandable
+ {
+ get {
+ return GridItems.Count > 1;
+ }
+ }
+
+ public virtual bool Expanded
+ {
+ get {
+ return expanded;
+ }
+
+ set {
+ expanded = value;
+ }
+ }
+
+ public abstract new System.Windows.Forms.GridItemCollection GridItems
+ {
+ get;
+ }
+
+ public abstract new System.Windows.Forms.GridItemType GridItemType
+ {
+ get;
+ }
+
+ public abstract new string Label
+ {
+ get;
+ }
+
+
+ public abstract new System.Windows.Forms.GridItem Parent
+ {
+ get;
+ }
+
+
+ public abstract new System.ComponentModel.PropertyDescriptor PropertyDescriptor
+ {
+ get;
+ }
+
+ public abstract new object Value
+ {
+ get;
+ }
+ #endregion
+
+ #region Public Instance Methods
+ public abstract new bool Select ();
+ #endregion // Public Instance Methods
+
+ internal abstract int Top {
+ get;
+ set;
+ }
+
+ internal abstract Rectangle PlusMinusBounds {
+ get;
+ set;
+ }
+
+ internal abstract Rectangle Bounds
+ {
+ get;
+ set;
+ }
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridItemCollection.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridItemCollection.cs
new file mode 100644
index 00000000000..fd222e75b0f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridItemCollection.cs
@@ -0,0 +1,141 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jonathan Chambers (jonathan.chambers@ansys.com)
+//
+
+// COMPLETE
+
+using System;
+using System.Collections;
+
+namespace System.Windows.Forms
+{
+ public class GridItemCollection : IEnumerable, ICollection
+ {
+ #region Local Variables
+ private System.Collections.SortedList list;
+ #endregion // Local Variables
+
+ #region Public Static Fields
+ public static GridItemCollection Empty = new GridItemCollection();
+ #endregion // Public Static Fields
+
+ #region Constructors
+ internal GridItemCollection()
+ {
+ list = new SortedList();
+ }
+ #endregion // Constructors
+
+ #region Internal Properties and Methods
+ internal void Add(string key, GridItem grid_item)
+ {
+ list.Add(key,grid_item);
+ }
+ #endregion // Internal Properties and Methods
+
+ #region Public Instance Properties
+ public int Count
+ {
+ get {
+ return list.Count;
+ }
+ }
+
+ public GridItem this [int index]
+ {
+ get {
+ if (index>=list.Count) {
+ throw new ArgumentOutOfRangeException("index");
+ }
+ return (GridItem)list.GetByIndex(index);
+ }
+ }
+
+ public GridItem this [string key]
+ {
+ get {
+ return (GridItem)list[key];
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region IEnumerable Members
+ public IEnumerator GetEnumerator()
+ {
+ return new GridItemEnumerator(this);
+ }
+ #endregion
+
+ #region Enumerator Class
+ internal class GridItemEnumerator : IEnumerator{
+ int nIndex;
+ GridItemCollection collection;
+ public GridItemEnumerator(GridItemCollection coll) {
+ collection = coll;
+ nIndex = -1;
+ }
+
+ public bool MoveNext() {
+ nIndex++;
+ return(nIndex < collection.Count);
+ }
+
+ public void Reset() {
+ nIndex = -1;
+ }
+
+ object System.Collections.IEnumerator.Current {
+ get {
+ return(collection[nIndex]);
+ }
+ }
+ }
+ #endregion
+
+ #region ICollection Members
+
+ bool ICollection.IsSynchronized
+ {
+ get
+ {
+ return list.IsSynchronized;
+ }
+ }
+
+ void ICollection.CopyTo(Array array, int index)
+ {
+ list.CopyTo(array, index);
+ }
+
+ object ICollection.SyncRoot
+ {
+ get
+ {
+ return list.SyncRoot;
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridItemType.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridItemType.cs
new file mode 100644
index 00000000000..2d9636215fb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridItemType.cs
@@ -0,0 +1,39 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jonathan Chambers (jonathan.chambers@ansys.com)
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public enum GridItemType
+ {
+ Property = 0,
+ Category = 1,
+ ArrayValue = 2,
+ Root = 3
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridTableStylesCollection.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridTableStylesCollection.cs
new file mode 100644
index 00000000000..26c1116a49b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridTableStylesCollection.cs
@@ -0,0 +1,237 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+
+namespace System.Windows.Forms
+{
+ [ListBindable(false)]
+ public class GridTableStylesCollection : BaseCollection, IList
+ {
+ private ArrayList items;
+ private DataGrid owner;
+
+ internal GridTableStylesCollection (DataGrid grid)
+ {
+ items = new ArrayList ();
+ owner = grid;
+ }
+
+ #region Public Instance Properties
+ public DataGridTableStyle this[string tableName] {
+ get {
+ int idx = FromTableNameToIndex (tableName);
+ return idx == -1 ? null : this [idx];
+ }
+ }
+
+ public DataGridTableStyle this[int index] {
+ get {
+ return (DataGridTableStyle) items[index];
+ }
+ }
+
+ protected override ArrayList List {
+ get { return items; }
+ }
+
+ int ICollection.Count {
+ get { return items.Count;}
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return false; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return this;}
+ }
+
+ bool IList.IsFixedSize {
+ get { return false; }
+ }
+
+ bool IList.IsReadOnly {
+ get { return false;}
+ }
+
+ object IList.this [int index] {
+ get {
+ return items[index];
+ }
+ set {
+ throw new NotSupportedException ();
+ }
+ }
+
+ #endregion Public Instance Properties
+
+ #region Public Instance Methods
+ public virtual int Add (DataGridTableStyle table)
+ {
+ int cnt = AddInternal (table);
+ OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Add, table));
+ return cnt;
+ }
+
+ public virtual void AddRange (DataGridTableStyle[] tables)
+ {
+ foreach (DataGridTableStyle mi in tables)
+ AddInternal (mi);
+
+ OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Refresh, null));
+ }
+
+ public void Clear ()
+ {
+ items.Clear ();
+ OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Refresh , null));
+ }
+
+ public bool Contains (DataGridTableStyle table)
+ {
+ return (FromTableNameToIndex (table.MappingName) != -1);
+ }
+
+ public bool Contains (string name)
+ {
+ return (FromTableNameToIndex (name) != -1);
+ }
+
+ void ICollection.CopyTo (Array dest, int index)
+ {
+ items.CopyTo (dest, index);
+ }
+
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return items.GetEnumerator ();
+ }
+
+ int IList.Add (object value)
+ {
+ int cnt = AddInternal ((DataGridTableStyle)value);
+
+ OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Add, null));
+ return cnt;
+ }
+
+ void IList.Clear ()
+ {
+ items.Clear ();
+ OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Refresh , null));
+ }
+
+ bool IList.Contains (object value)
+ {
+ return items.Contains (value);
+ }
+
+ int IList.IndexOf (object value)
+ {
+ return items.IndexOf (value);
+ }
+
+ void IList.Insert (int index, object value)
+ {
+ throw new NotSupportedException ();
+ }
+
+ void IList.Remove (object value)
+ {
+ items.Remove (value);
+ OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Remove, value));
+ }
+
+ void IList.RemoveAt (int index)
+ {
+ object item = items[index];
+ items.RemoveAt (index);
+ OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Remove, item));
+ }
+
+ protected void OnCollectionChanged (CollectionChangeEventArgs ccevent)
+ {
+ if (CollectionChanged != null) {
+ CollectionChanged (this, ccevent);
+ }
+ }
+
+ public void Remove (DataGridTableStyle table)
+ {
+ items.Remove (table);
+ OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Remove, table));
+ }
+
+ public void RemoveAt (int index)
+ {
+ object item = items[index];
+
+ items.RemoveAt (index);
+ OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Remove, item));
+ }
+
+ #endregion Public Instance Methods
+
+ #region Events
+ public event CollectionChangeEventHandler CollectionChanged;
+ #endregion Events
+
+
+ #region Private Instance Methods
+ private int AddInternal (DataGridTableStyle table)
+ {
+ // TODO: MS allows duplicate columns. How they diferenciate between them?
+ if (FromTableNameToIndex (table.MappingName) != -1) {
+ throw new ArgumentException ("The TableStyles collection already has a TableStyle with this mapping name");
+ }
+
+ table.DataGrid = owner;
+ int cnt = items.Add (table);
+ return cnt;
+ }
+
+ private int FromTableNameToIndex (string tableName)
+ {
+ for (int i = 0; i < items.Count; i++) {
+ DataGridTableStyle table = (DataGridTableStyle) items[i];
+
+ if (table.MappingName == null || table.MappingName == string.Empty)
+ continue;
+
+ if (String.Compare (table.MappingName, tableName, true) == 0) {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ #endregion Private Instance Methods
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridTablesFactory.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridTablesFactory.cs
new file mode 100644
index 00000000000..4ecbeab0e75
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridTablesFactory.cs
@@ -0,0 +1,54 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+// NOT COMPLETE
+
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Diagnostics;
+
+namespace System.Windows.Forms
+{
+ public class GridTablesFactory
+ {
+
+ #region Constructors
+ internal GridTablesFactory ()
+ {
+
+ }
+ #endregion
+
+
+ #region Public Instance Properties
+ [MonoTODO]
+ public static DataGridTableStyle[] CreateGridTables (DataGridTableStyle gridTable, object dataSource, string dataMember, BindingContext bindingManager)
+ {
+ throw new NotImplementedException ();
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GroupBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GroupBox.cs
new file mode 100644
index 00000000000..879ecb9545c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GroupBox.cs
@@ -0,0 +1,221 @@
+//
+// System.Windows.Forms.GroupBox.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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
+//
+// TODO:
+//
+// Copyright (C) Novell Inc., 2004-2005
+//
+//
+
+// COMPLETE
+
+using System.Drawing;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+
+namespace System.Windows.Forms
+{
+ [DefaultProperty("Text")]
+ [DefaultEvent("Enter")]
+ [Designer ("System.Windows.Forms.Design.GroupBoxDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ public class GroupBox : Control
+ {
+ private FlatStyle flat_style;
+ private Rectangle display_rectangle = new Rectangle ();
+
+ #region Events
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public new event EventHandler Click;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public new event EventHandler DoubleClick;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public new event KeyEventHandler KeyDown;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public new event KeyPressEventHandler KeyPress;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public new event KeyEventHandler KeyUp;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public new event MouseEventHandler MouseDown;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public new event EventHandler MouseEnter;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public new event EventHandler MouseLeave;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public new event MouseEventHandler MouseMove;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public new event MouseEventHandler MouseUp;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public new event EventHandler TabStopChanged;
+ #endregion Events
+
+ public GroupBox ()
+ {
+ TabStop = false;
+ flat_style = FlatStyle.Standard;
+
+ SetStyle(ControlStyles.ContainerControl | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
+ SetStyle(ControlStyles.Selectable, false);
+ }
+
+ #region Public Properties
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public override bool AllowDrop {
+ get { return base.AllowDrop; }
+ set { base.AllowDrop = value; }
+ }
+
+ protected override CreateParams CreateParams {
+ get { return base.CreateParams; }
+ }
+
+ protected override Size DefaultSize {
+ get { return ThemeEngine.Current.GroupBoxDefaultSize;}
+ }
+
+ public override Rectangle DisplayRectangle {
+ get {
+ display_rectangle.X = 3;
+ display_rectangle.Y = Font.Height + 3;
+ display_rectangle.Width = Width - 6;
+ display_rectangle.Height = Height - Font.Height - 6;
+ return display_rectangle;
+ }
+ }
+
+ [DefaultValue(FlatStyle.Standard)]
+ public FlatStyle FlatStyle {
+ get { return flat_style; }
+ set {
+ if (!Enum.IsDefined (typeof (FlatStyle), value))
+ new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for FlatStyle", value));
+
+ if (flat_style == value)
+ return;
+
+ flat_style = value;
+ Refresh ();
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public new bool TabStop {
+ get { return base.TabStop; }
+ set { base.TabStop = value; }
+ }
+
+ [Localizable(true)]
+ public override string Text {
+ get { return base.Text; }
+ set {
+ if (base.Text == value)
+ return;
+
+ base.Text = value;
+ Refresh ();
+ }
+ }
+
+ #endregion //Public Properties
+
+ #region Public Methods
+ protected override void OnFontChanged (EventArgs e)
+ {
+ base.OnFontChanged (e);
+ Refresh ();
+ }
+
+ protected override void OnPaint (PaintEventArgs pevent)
+ {
+ ThemeEngine.Current.DrawGroupBox (pevent.Graphics, ClientRectangle, this);
+ base.OnPaint(pevent);
+ }
+
+ protected override bool ProcessMnemonic (char charCode)
+ {
+ if (IsMnemonic(charCode, Text) == true) {
+ // Select item next in line in tab order
+ if (this.parent != null) {
+ parent.SelectNextControl(this, true, false, true, false);
+ }
+ return true;
+ }
+
+ return base.ProcessMnemonic (charCode);
+ }
+
+ public override string ToString()
+ {
+ return GetType ().FullName.ToString () + ", Text: " + Text;
+ }
+
+ protected override void WndProc(ref Message m) {
+ switch ((Msg) m.Msg) {
+ case Msg.WM_ERASEBKGND:
+ m.Result = (IntPtr)1;
+ break;
+ default:
+ base.WndProc (ref m);
+ break;
+ }
+ }
+
+ #endregion Public Methods
+#if NET_2_0
+
+ public bool UseCompatibleTextRendering {
+ get {
+ return use_compatible_text_rendering;
+ }
+
+ set {
+ use_compatible_text_rendering = value;
+ }
+ }
+#endif
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HScrollBar.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HScrollBar.cs
new file mode 100644
index 00000000000..b67a95b011c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HScrollBar.cs
@@ -0,0 +1,51 @@
+//
+// System.Windows.Forms.HScrollBar.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004, Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez jordi@ximian.com
+//
+//
+
+
+using System.Drawing;
+
+namespace System.Windows.Forms
+{
+
+ public class HScrollBar : ScrollBar
+ {
+ public HScrollBar()
+ {
+ vert = false;
+ }
+
+ protected override Size DefaultSize {
+ get { return ThemeEngine.Current.HScrollBarDefaultSize;}
+ }
+
+ protected override CreateParams CreateParams {
+ get { return base.CreateParams; }
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HandledMouseEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HandledMouseEventArgs.cs
new file mode 100644
index 00000000000..4ee42e7be38
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HandledMouseEventArgs.cs
@@ -0,0 +1,52 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class HandledMouseEventArgs : MouseEventArgs {
+
+ private bool handled;
+
+ public HandledMouseEventArgs (MouseButtons button, int clicks, int x, int y, int delta) : base (button, clicks, x, y, delta) {
+ handled = false;
+ }
+
+ public HandledMouseEventArgs( MouseButtons button, int clicks, int x, int y, int delta, bool defaultHandledValue) : base (button, clicks, x, y, delta) {
+ this.handled = defaultHandledValue;
+ }
+
+ public bool Handled {
+ get { return handled; }
+ set { handled = value; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Help.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Help.cs
new file mode 100644
index 00000000000..74565dcf216
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Help.cs
@@ -0,0 +1,73 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+ public class Help {
+ #region Constructor
+ private Help() {
+ }
+ #endregion
+
+ #region Public Static Methods
+ public static void ShowHelp(Control parent, string url) {
+ ShowHelp(parent, url, HelpNavigator.TableOfContents, null);
+ }
+
+ public static void ShowHelp(Control parent, string url, HelpNavigator navigator) {
+ ShowHelp(parent, url, navigator, null);
+ }
+
+ [MonoTODO("Create glue code to tie into libCHM")]
+ public static void ShowHelp(Control parent, string url, HelpNavigator command, object param) {
+ MessageBox.Show(parent, (string)Locale.GetText("Help (" + command +
+ (param != null ? "(" + param + ")" : String.Empty) +
+ ") not yet implemented"), (string)Locale.GetText("Popup Help"),
+ MessageBoxButtons.OK, MessageBoxIcon.Stop);
+ }
+
+ public static void ShowHelp(Control parent, string url, string keyword) {
+ if (keyword == null || keyword == String.Empty) {
+ ShowHelp(parent, url, HelpNavigator.TableOfContents, null);
+ }
+ ShowHelp(parent, url, HelpNavigator.Topic, keyword);
+ }
+
+ public static void ShowHelpIndex(Control parent, string url) {
+ ShowHelp(parent, url, HelpNavigator.Index, null);
+ }
+
+ [MonoTODO("Create glue code to tie into libCHM")]
+ public static void ShowPopup(Control parent, string caption, Point location) {
+ MessageBox.Show(parent, (string)Locale.GetText("Popup Help not yet implemented"), (string)Locale.GetText("Popup Help"), MessageBoxButtons.OK, MessageBoxIcon.Stop);
+ }
+ #endregion // Public Static Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HelpEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HelpEventArgs.cs
new file mode 100644
index 00000000000..5c635b0123b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HelpEventArgs.cs
@@ -0,0 +1,64 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+using System.Drawing;
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public class HelpEventArgs : EventArgs {
+ private Point mouse_position;
+ private bool event_handled;
+
+ #region Public Constructors
+ public HelpEventArgs(System.Drawing.Point mousePos) {
+ this.mouse_position=mousePos;
+ this.event_handled=false;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public bool Handled {
+ get {
+ return this.event_handled;
+ }
+
+ set {
+ this.event_handled=value;
+ }
+ }
+
+ public Point MousePos {
+ get {
+ return this.mouse_position;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HelpEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HelpEventHandler.cs
new file mode 100644
index 00000000000..3893dafbe2a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HelpEventHandler.cs
@@ -0,0 +1,30 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void HelpEventHandler (object sender, HelpEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HelpNavigator.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HelpNavigator.cs
new file mode 100644
index 00000000000..201f6de6c03
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HelpNavigator.cs
@@ -0,0 +1,38 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum HelpNavigator {
+ Topic = -2147483647,
+ TableOfContents = -2147483646,
+ Index = -2147483645,
+ Find = -2147483644,
+ AssociateIndex = -2147483643,
+ KeywordIndex = -2147483642
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HelpProvider.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HelpProvider.cs
new file mode 100644
index 00000000000..a73876b703e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HelpProvider.cs
@@ -0,0 +1,279 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// NOT COMPLETE
+// Still missing: Tie-in to HTML help when the user presses F1 on the control
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+ [ToolboxItemFilter("System.Windows.Forms")]
+ [ProvideProperty("ShowHelp", "System.Windows.Forms.Control, " + Consts.AssemblySystem_Windows_Forms)]
+ [ProvideProperty("HelpNavigator", "System.Windows.Forms.Control, " + Consts.AssemblySystem_Windows_Forms)]
+ [ProvideProperty("HelpKeyword", "System.Windows.Forms.Control, " + Consts.AssemblySystem_Windows_Forms)]
+ [ProvideProperty("HelpString", "System.Windows.Forms.Control, " + Consts.AssemblySystem_Windows_Forms)]
+ public class HelpProvider : Component, IExtenderProvider {
+ #region HelpProperty Class
+ private class HelpProperty {
+ internal string keyword;
+ internal HelpNavigator navigator;
+ internal string text;
+ internal bool show;
+ internal Control control;
+ internal HelpProvider hp;
+
+ public HelpProperty(HelpProvider hp, Control control) {
+ this.control = control;
+ this.hp = hp;
+
+ keyword = null;
+ navigator = HelpNavigator.AssociateIndex;
+ text = null;
+ show = false;
+
+ control.HelpRequested += hp.HelpRequestHandler;
+ }
+
+ public string Keyword {
+ get { return keyword; }
+ set { keyword = value; }
+ }
+
+ public HelpNavigator Navigator {
+ get { return navigator; }
+ set { navigator = value; }
+ }
+
+ public string Text {
+ get { return text; }
+ set { text = value; }
+ }
+
+ public bool Show {
+ get { return show; }
+ set { show = value; }
+ }
+ }
+ #endregion // HelpProperty Class
+
+ #region Local Variables
+ private string helpnamespace;
+ private Hashtable controls;
+ private ToolTip.ToolTipWindow tooltip;
+ private EventHandler HideToolTipHandler;
+ private KeyPressEventHandler HideToolTipKeyHandler;
+ private MouseEventHandler HideToolTipMouseHandler;
+ private HelpEventHandler HelpRequestHandler;
+ #endregion // Local Variables
+
+ #region Public Constructors
+ public HelpProvider() {
+ controls = new Hashtable();
+ tooltip = new ToolTip.ToolTipWindow(null);
+
+ HideToolTipHandler = new EventHandler(HideToolTip);
+ HideToolTipKeyHandler = new KeyPressEventHandler(HideToolTipKey);
+ HideToolTipMouseHandler = new MouseEventHandler(HideToolTipMouse);
+ HelpRequestHandler = new HelpEventHandler(HelpRequested);
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ [DefaultValue(null)]
+ [Editor ("System.Windows.Forms.Design.HelpNamespaceEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
+ [Localizable(true)]
+ public virtual string HelpNamespace {
+ get {
+ return helpnamespace;
+ }
+
+ set {
+ helpnamespace = value;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public bool CanExtend(object extendee) {
+ if (!(extendee is Control)) {
+ return false;
+ }
+
+ if ((extendee is Form) || (extendee is ToolBar)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ [DefaultValue(null)]
+ [Localizable(true)]
+ public virtual string GetHelpKeyword(Control ctl) {
+ return GetHelpProperty(ctl).Keyword;
+ }
+
+ [DefaultValue(HelpNavigator.AssociateIndex)]
+ [Localizable(true)]
+ public virtual HelpNavigator GetHelpNavigator(Control ctl) {
+ return GetHelpProperty(ctl).Navigator;
+ }
+
+ [DefaultValue(null)]
+ [Localizable(true)]
+ public virtual string GetHelpString(Control ctl) {
+ return GetHelpProperty(ctl).Text;
+ }
+
+ [Localizable(true)]
+ public virtual bool GetShowHelp(Control ctl) {
+ return GetHelpProperty(ctl).Show;
+ }
+
+ public virtual void ResetShowHelp(Control ctl) {
+ HelpProperty hp;
+
+ hp = GetHelpProperty(ctl);
+
+ if ((hp.Keyword != null) || (hp.Text != null)) {
+ hp.Show = true;
+ } else {
+ hp.Show = false;
+ }
+ }
+
+ public virtual void SetHelpKeyword(Control ctl, string keyword) {
+ GetHelpProperty(ctl).Keyword = keyword;
+ }
+
+ public virtual void SetHelpNavigator(Control ctl, HelpNavigator navigator) {
+ GetHelpProperty(ctl).Navigator = navigator;
+ }
+
+ public virtual void SetHelpString(Control ctl, string helpString) {
+ GetHelpProperty(ctl).Text = helpString;
+ }
+
+ public virtual void SetShowHelp(Control ctl, bool value) {
+ GetHelpProperty(ctl).Show = value;
+ }
+
+ public override string ToString() {
+ return base.ToString() + ", HelpNameSpace: " + helpnamespace;
+ }
+
+ #endregion // Public Instance Methods
+
+ #region Private Methods
+ private HelpProperty GetHelpProperty(Control control) {
+ HelpProperty hp;
+
+ hp = (HelpProperty)controls[control];
+ if (hp == null) {
+ hp = new HelpProperty(this, control);
+ controls[control] = hp;
+ }
+
+ return hp;
+ }
+
+ private void HideToolTip(object Sender, EventArgs e) {
+ Control control;
+
+ control = (Control)Sender;
+ control.LostFocus -= HideToolTipHandler;
+
+ this.tooltip.Visible = false;
+ }
+
+ private void HideToolTipKey(object Sender, KeyPressEventArgs e) {
+ Control control;
+
+ control = (Control)Sender;
+ control.KeyPress -= HideToolTipKeyHandler;
+
+ this.tooltip.Visible = false;
+ }
+
+ private void HideToolTipMouse(object Sender, MouseEventArgs e) {
+ Control control;
+
+ control = (Control)Sender;
+ control.MouseDown -= HideToolTipMouseHandler;
+
+ this.tooltip.Visible = false;
+ }
+
+
+ // This is called when the user does a "what's this" style lookup. It uses the 'text' property
+ private void HelpRequested(object sender, HelpEventArgs e) {
+ Size size;
+ Point pt;
+ Control control;
+
+ control = (Control)sender;
+
+ if (GetHelpProperty(control).Text == null) {
+ return;
+ }
+
+ pt = e.MousePos;
+
+ // Display Tip
+ tooltip.Text = GetHelpProperty(control).Text;
+ size = ThemeEngine.Current.ToolTipSize(tooltip, tooltip.Text);
+ tooltip.Width = size.Width;
+ tooltip.Height = size.Height;
+ pt.X -= size.Width / 2;
+
+ if (pt.X < 0) {
+ pt.X += size.Width / 2;
+ }
+
+ if ((pt.X + size.Width) < SystemInformation.WorkingArea.Width) {
+ tooltip.Left = pt.X;
+ } else {
+ tooltip.Left = pt.X - size.Width;
+ }
+
+ if ((pt.Y + size.Height) < (SystemInformation.WorkingArea.Height - 16)) {
+ tooltip.Top = pt.Y;
+ } else {
+ tooltip.Top = pt.Y - size.Height;
+ }
+
+
+ tooltip.Visible = true;
+ control.KeyPress += HideToolTipKeyHandler;
+ control.MouseDown += HideToolTipMouseHandler;
+ control.LostFocus += HideToolTipHandler;
+ e.Handled = true;
+ }
+ #endregion // Private Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HorizontalAlignment.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HorizontalAlignment.cs
new file mode 100644
index 00000000000..ce577bc0f74
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HorizontalAlignment.cs
@@ -0,0 +1,37 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+//
+
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public enum HorizontalAlignment {
+ Left,
+ Right,
+ Center
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Hwnd.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Hwnd.cs
new file mode 100644
index 00000000000..4a60914dc2c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Hwnd.cs
@@ -0,0 +1,575 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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-2006 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Collections;
+using System.Drawing;
+using System.Runtime.InteropServices;
+
+// NOTE: Possible optimization:
+// Several properties calculate dimensions on the fly; instead; they can
+// be stored in a field and only be recalculated when a style is changed (DefaultClientRect, for example)
+
+namespace System.Windows.Forms {
+ internal class Hwnd : IDisposable {
+ #region Local Variables
+ private static Hashtable windows = new Hashtable(100, 0.5f);
+ //private const int menu_height = 14; // FIXME - Read this value from somewhere
+
+ private IntPtr handle;
+ internal IntPtr client_window;
+ internal IntPtr whole_window;
+ internal Menu menu;
+ internal TitleStyle title_style;
+ internal FormBorderStyle border_style;
+ internal int x;
+ internal int y;
+ internal int width;
+ internal int height;
+ internal bool allow_drop;
+ internal Hwnd parent;
+ internal bool visible;
+ internal uint opacity;
+ internal bool enabled;
+ internal bool zero_sized;
+ internal Rectangle invalid;
+ internal Rectangle nc_invalid;
+ internal bool expose_pending;
+ internal bool nc_expose_pending;
+ internal bool configure_pending;
+ internal bool reparented;
+ internal Graphics client_dc;
+ internal Graphics non_client_dc;
+ internal object user_data;
+ internal Rectangle client_rectangle;
+ internal ArrayList marshal_free_list;
+ internal int caption_height;
+ internal int tool_caption_height;
+ internal bool whacky_wm;
+ internal bool fixed_size;
+ internal static Bitmap bmp = new Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
+ #endregion // Local Variables
+
+ #region Constructors and destructors
+ public Hwnd() {
+ x = 0;
+ y = 0;
+ width = 0;
+ height = 0;
+ visible = false;
+ menu = null;
+ border_style = FormBorderStyle.None;
+ client_window = IntPtr.Zero;
+ whole_window = IntPtr.Zero;
+ handle = IntPtr.Zero;
+ parent = null;
+ invalid = Rectangle.Empty;
+ expose_pending = false;
+ nc_expose_pending = false;
+ enabled = true;
+ reparented = false;
+ client_rectangle = Rectangle.Empty;
+ marshal_free_list = new ArrayList(2);
+ opacity = 0xffffffff;
+ fixed_size = false;
+ }
+
+ public void Dispose() {
+ windows.Remove(client_window);
+ windows.Remove(whole_window);
+ for (int i = 0; i < marshal_free_list.Count; i++) {
+ Marshal.FreeHGlobal((IntPtr)marshal_free_list[i]);
+ }
+ marshal_free_list.Clear();
+ }
+ #endregion
+
+ #region Static Methods
+ public void SetObjectWindow(Hwnd obj, IntPtr window) {
+ windows[window] = obj;
+ }
+
+ public static Hwnd ObjectFromWindow(IntPtr window) {
+ return (Hwnd)windows[window];
+ }
+
+ public static Hwnd ObjectFromHandle(IntPtr handle) {
+ //return (Hwnd)(((GCHandle)handle).Target);
+ return (Hwnd)windows[handle];
+ }
+
+ public static IntPtr HandleFromObject(Hwnd obj) {
+ return obj.handle;
+ }
+
+ public static Hwnd GetObjectFromWindow(IntPtr window) {
+ return (Hwnd)windows[window];
+ }
+
+ public static IntPtr GetHandleFromWindow(IntPtr window) {
+ Hwnd hwnd;
+
+ hwnd = (Hwnd)windows[window];
+ if (hwnd != null) {
+ return hwnd.handle;
+ } else {
+ return IntPtr.Zero;
+ }
+ }
+
+ public static Rectangle GetWindowRectangle(FormBorderStyle border_style,
+ Menu menu, TitleStyle title_style, int caption_height,
+ int tool_caption_height, Rectangle client_rect)
+ {
+ Rectangle rect;
+
+ rect = new Rectangle(client_rect.Location, client_rect.Size);
+
+ if (menu != null) {
+ int menu_height = menu.Rect.Height;
+ if (menu_height == 0) {
+ Graphics g;
+
+ g = Graphics.FromImage(bmp);
+ menu_height = ThemeEngine.Current.CalcMenuBarSize(g, menu, client_rect.Width);
+ g.Dispose();
+ }
+
+ rect.Y -= menu_height;
+ rect.Height += menu_height;
+ }
+
+ if (border_style == FormBorderStyle.Fixed3D) {
+ Size border_3D_size = ThemeEngine.Current.Border3DSize;
+
+ rect.X -= border_3D_size.Width;
+ rect.Y -= border_3D_size.Height;
+ rect.Width += border_3D_size.Width * 2;
+ rect.Height += border_3D_size.Height * 2;
+ } else if (border_style == FormBorderStyle.FixedSingle) {
+ rect.X -= 1;
+ rect.Y -= 1;
+ rect.Width += 2;
+ rect.Height += 2;
+ }
+
+ return rect;
+ }
+
+ public static Rectangle GetClientRectangle(FormBorderStyle border_style, Menu menu, TitleStyle title_style, int caption_height, int tool_caption_height, int width, int height) {
+ Rectangle rect;
+
+ rect = new Rectangle(0, 0, width, height);
+
+ if (menu != null) {
+ int menu_height = menu.Rect.Height;
+ rect.Y += menu_height;
+ rect.Height -= menu_height;
+ }
+
+ if (border_style == FormBorderStyle.Fixed3D) {
+ Size border_3D_size = ThemeEngine.Current.Border3DSize;
+
+ rect.X += border_3D_size.Width;
+ rect.Y += border_3D_size.Height;
+ rect.Width -= border_3D_size.Width * 2;
+ rect.Height -= border_3D_size.Height * 2;
+ } else if (border_style == FormBorderStyle.FixedSingle) {
+ rect.X += 1;
+ rect.Y += 1;
+ rect.Width -= 2;
+ rect.Height -= 2;
+ }
+
+ return rect;
+ }
+ #endregion // Static Methods
+
+ #region Instance Properties
+ public FormBorderStyle BorderStyle {
+ get {
+ return border_style;
+ }
+
+ set {
+ border_style = value;
+ }
+ }
+
+ public Graphics ClientDC {
+ get {
+ return client_dc;
+ }
+
+ set {
+ client_dc = value;
+ }
+ }
+
+ public Graphics NonClientDC {
+ get { return non_client_dc; }
+ set { non_client_dc = value; }
+ }
+
+ public Rectangle ClientRect {
+ get {
+ if (client_rectangle == Rectangle.Empty) {
+ return DefaultClientRect;
+ }
+ return client_rectangle;
+ }
+
+ set {
+ client_rectangle = value;
+ }
+ }
+
+ public IntPtr ClientWindow {
+ get {
+ return client_window;
+ }
+
+ set {
+ client_window = value;
+ handle = value;
+
+ if (windows[client_window] == null) {
+ windows[client_window] = this;
+ }
+ }
+ }
+
+ public Rectangle DefaultClientRect {
+ get {
+ // We pass a Zero for the menu handle so the menu size is
+ // not computed this is done via an WM_NCCALC
+ return GetClientRectangle (border_style, null, title_style,
+ caption_height, tool_caption_height, width, height);
+ }
+ }
+
+ public bool ExposePending {
+ get {
+ return expose_pending;
+ }
+
+ set {
+ expose_pending = value;
+ }
+ }
+
+ public IntPtr Handle {
+ get {
+ if (handle == IntPtr.Zero) {
+ throw new ArgumentNullException("Handle", "Handle is not yet assigned, need a ClientWindow");
+ }
+ return handle;
+ }
+ }
+
+ public int Height {
+ get {
+ return height;
+ }
+
+ set {
+ height = value;
+ }
+ }
+
+ public Menu Menu {
+ get {
+ return menu;
+ }
+
+ set {
+ menu = value;
+ }
+ }
+
+ public bool Reparented {
+ get {
+ return reparented;
+ }
+
+ set {
+ reparented = value;
+ }
+ }
+
+ public uint Opacity {
+ get {
+ return opacity;
+ }
+
+ set {
+ opacity = value;
+ }
+ }
+
+ public bool Enabled {
+ get {
+ if (!enabled) {
+ return false;
+ }
+
+ if (parent != null) {
+ return parent.Enabled;
+ }
+
+ return true;
+ }
+
+ set {
+ enabled = value;
+ }
+ }
+
+ public IntPtr EnabledHwnd {
+ get {
+ if (Enabled || parent == null) {
+ return Handle;
+ }
+
+ return parent.EnabledHwnd;
+ }
+ }
+
+ public Point MenuOrigin {
+ get {
+ Point pt;
+ Size border_3D_size = ThemeEngine.Current.Border3DSize;
+
+ pt = new Point(0, 0);
+
+ if (border_style == FormBorderStyle.Fixed3D) {
+ pt.X += border_3D_size.Width;
+ pt.Y += border_3D_size.Height;
+ } else if (border_style == FormBorderStyle.FixedSingle) {
+ pt.X += 1;
+ pt.Y += 1;
+ }
+
+ if (this.title_style == TitleStyle.Normal) {
+ pt.Y += caption_height;
+ } else if (this.title_style == TitleStyle.Normal) {
+ pt.Y += tool_caption_height;
+ }
+
+ return pt;
+ }
+ }
+
+ public Rectangle Invalid {
+ get {
+ return invalid;
+ }
+
+ set {
+ invalid = value;
+ }
+ }
+
+ public Rectangle NCInvalid {
+ get { return nc_invalid; }
+ set { nc_invalid = value; }
+
+ }
+
+ public bool NCExposePending {
+ get {
+ return nc_expose_pending;
+ }
+
+ set {
+ nc_expose_pending = value;
+ }
+ }
+
+ public Hwnd Parent {
+ get {
+ return parent;
+ }
+
+ set {
+ parent = value;
+ }
+ }
+
+ public int CaptionHeight {
+ get { return caption_height; }
+ set { caption_height = value; }
+ }
+
+ public int ToolCaptionHeight {
+ get { return tool_caption_height; }
+ set { tool_caption_height = value; }
+ }
+
+ public TitleStyle TitleStyle {
+ get {
+ return title_style;
+ }
+
+ set {
+ title_style = value;
+ }
+ }
+
+ public object UserData {
+ get {
+ return user_data;
+ }
+
+ set {
+ user_data = value;
+ }
+ }
+
+ public IntPtr WholeWindow {
+ get {
+ return whole_window;
+ }
+
+ set {
+ whole_window = value;
+
+ if (windows[whole_window] == null) {
+ windows[whole_window] = this;
+ }
+ }
+ }
+
+ public int Width {
+ get {
+ return width;
+ }
+
+ set {
+ width = value;
+ }
+ }
+
+ public bool Visible {
+ get {
+ return visible;
+ }
+
+ set {
+ visible = value;
+ }
+ }
+
+ public int X {
+ get {
+ return x;
+ }
+
+ set {
+ x = value;
+ }
+ }
+
+ public int Y {
+ get {
+ return y;
+ }
+
+ set {
+ y = value;
+ }
+ }
+
+ #endregion // Instance properties
+
+ #region Methods
+ public void AddInvalidArea(int x, int y, int width, int height) {
+ if (invalid == Rectangle.Empty) {
+ invalid = new Rectangle (x, y, width, height);
+ return;
+ }
+
+ int right, bottom;
+ right = Math.Max (invalid.Right, x + width);
+ bottom = Math.Max (invalid.Bottom, y + height);
+ invalid.X = Math.Min (invalid.X, x);
+ invalid.Y = Math.Min (invalid.Y, y);
+
+ invalid.Width = right - invalid.X;
+ invalid.Height = bottom - invalid.Y;
+ }
+
+ public void AddInvalidArea(Rectangle rect) {
+ if (invalid == Rectangle.Empty) {
+ invalid = rect;
+ return;
+ }
+ invalid = Rectangle.Union (invalid, rect);
+ }
+
+ public void ClearInvalidArea() {
+ invalid = Rectangle.Empty;
+ expose_pending = false;
+ }
+
+ public void AddNcInvalidArea(int x, int y, int width, int height) {
+ if (nc_invalid == Rectangle.Empty) {
+ nc_invalid = new Rectangle (x, y, width, height);
+ return;
+ }
+
+ int right, bottom;
+ right = Math.Max (nc_invalid.Right, x + width);
+ bottom = Math.Max (nc_invalid.Bottom, y + height);
+ nc_invalid.X = Math.Min (nc_invalid.X, x);
+ nc_invalid.Y = Math.Min (nc_invalid.Y, y);
+
+ nc_invalid.Width = right - nc_invalid.X;
+ nc_invalid.Height = bottom - nc_invalid.Y;
+ }
+
+ public void AddNcInvalidArea(Rectangle rect) {
+ if (nc_invalid == Rectangle.Empty) {
+ nc_invalid = rect;
+ return;
+ }
+ nc_invalid = Rectangle.Union (nc_invalid, rect);
+ }
+
+ public void ClearNcInvalidArea() {
+ nc_invalid = Rectangle.Empty;
+ nc_expose_pending = false;
+ }
+
+ public override string ToString() {
+ return String.Format("Hwnd, ClientWindow:0x{0:X}, WholeWindow:0x{1:X}, Parent:[{2:X}]", client_window.ToInt32(), whole_window.ToInt32(), parent != null ? parent.ToString() : "<null>");
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IButtonControl.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IButtonControl.cs
new file mode 100644
index 00000000000..9c28ce6b75e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IButtonControl.cs
@@ -0,0 +1,40 @@
+//
+// System.Windows.Forms.IButtonControl.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+
+ public interface IButtonControl
+ {
+ DialogResult DialogResult {get; set;}
+ void NotifyDefault (bool value);
+ void PerformClick ();
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ICommandExecutor.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ICommandExecutor.cs
new file mode 100644
index 00000000000..0a8b7610bcb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ICommandExecutor.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public interface ICommandExecutor {
+ #region Public Instance Methods
+ void Execute();
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IComponentEditorPageSite.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IComponentEditorPageSite.cs
new file mode 100644
index 00000000000..3e1b7b1996d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IComponentEditorPageSite.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com);
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+
+ public interface IComponentEditorPageSite {
+ Control GetControl();
+ void SetDirty();
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IContainerControl.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IContainerControl.cs
new file mode 100644
index 00000000000..4208e3cc757
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IContainerControl.cs
@@ -0,0 +1,39 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public interface IContainerControl {
+ #region Public Instance Properties
+ Control ActiveControl {get; set;}
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ bool ActivateControl(Control active);
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataGridColumnStyleEditingNotificationService.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataGridColumnStyleEditingNotificationService.cs
new file mode 100644
index 00000000000..20a89016ddd
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataGridColumnStyleEditingNotificationService.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public interface IDataGridColumnStyleEditingNotificationService {
+ #region Public Instance Methods
+ void ColumnStartedEditing(Control editingControl);
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataGridEditingService.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataGridEditingService.cs
new file mode 100644
index 00000000000..9f491287838
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataGridEditingService.cs
@@ -0,0 +1,36 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+//
+// Peter Bartok pbartok@novell.com
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public interface IDataGridEditingService {
+ #region Public Instance Methods
+ bool BeginEdit(DataGridColumnStyle gridColumn, int rowNumber);
+ bool EndEdit(DataGridColumnStyle gridColumn, int rowNumber, bool shouldAbort);
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataGridViewEditingCell.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataGridViewEditingCell.cs
new file mode 100644
index 00000000000..aadf51ad3f3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataGridViewEditingCell.cs
@@ -0,0 +1,45 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public interface IDataGridViewEditingCell {
+
+ object EditingCellFormattedValue { get; set; }
+
+ bool EditingCellValueChanged { get; set; }
+
+ object GetEditingCellFormattedValue (DataGridViewDataErrorContexts context);
+
+ void PrepareEditingCellForEdit (bool selectAll);
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataGridViewEditingControl.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataGridViewEditingControl.cs
new file mode 100644
index 00000000000..aa3bf7c175a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataGridViewEditingControl.cs
@@ -0,0 +1,57 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public interface IDataGridViewEditingControl {
+
+ DataGridView EditingControlDataGridView {get; set;}
+
+ object EditingControlFormattedValue {get; set;}
+
+ int EditingControlRowIndex {get; set;}
+
+ bool EditingControlValueChanged {get; set;}
+
+ Cursor EditingPanelCursor {get;}
+
+ bool RepositionEditingControlOnValueChange {get;}
+
+ void ApplyCellStyleToEditingControl (DataGridViewCellStyle dataGridViewCellStyle);
+
+ bool EditingControlWantsInputKey (Keys keyData, bool dataGridViewWantsInputKey);
+
+ object GetEditingControlFormattedValue (DataGridViewDataErrorContexts context);
+
+ void PrepareEditingControlForEdit (bool selectAll);
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataObject.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataObject.cs
new file mode 100644
index 00000000000..4a975a13dc5
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IDataObject.cs
@@ -0,0 +1,53 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public interface IDataObject {
+ #region Public Instance Methods
+ object GetData(string format);
+ object GetData(string format, bool autoConvert);
+ object GetData(Type format);
+
+ bool GetDataPresent(string format);
+ bool GetDataPresent(string format, bool autoConvert);
+ bool GetDataPresent(Type format);
+
+ string[] GetFormats();
+ string[] GetFormats(bool autoConvert);
+
+ void SetData(object data);
+ void SetData(string format, bool autoConvert, object data);
+ void SetData(string format, object data);
+ void SetData(Type format, object data);
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IFeatureSupport.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IFeatureSupport.cs
new file mode 100644
index 00000000000..45717a902a8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IFeatureSupport.cs
@@ -0,0 +1,37 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public interface IFeatureSupport {
+ #region Public Instance Methods
+ Version GetVersionPresent(object feature);
+ bool IsPresent(object feature);
+ bool IsPresent(object feature, Version minimumVersion);
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IFileReaderService.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IFileReaderService.cs
new file mode 100644
index 00000000000..fd276f74ee8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IFileReaderService.cs
@@ -0,0 +1,37 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+using System.IO;
+
+namespace System.Windows.Forms {
+ public interface IFileReaderService {
+ #region Public Instance Methods
+ Stream OpenFileFromSource(string relativePath);
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IMessageFilter.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IMessageFilter.cs
new file mode 100644
index 00000000000..66990357c88
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IMessageFilter.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public interface IMessageFilter {
+ bool PreFilterMessage(ref Message m);
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IRootGridEntry.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IRootGridEntry.cs
new file mode 100755
index 00000000000..1f7cac35ab5
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IRootGridEntry.cs
@@ -0,0 +1,40 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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.
+//
+// Authors:
+// Jonathan Chambers jonathan.chambers@ansys.com
+//
+
+
+// COMPLETE
+
+using System;
+namespace System.Windows.Forms.PropertyGridInternal
+{
+ public interface IRootGridEntry
+ {
+ System.ComponentModel.AttributeCollection BrowsableAttributes { get; set; }
+
+ void ShowCategories ( bool showCategories );
+
+ void ResetBrowsableAttributes ();
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IWin32Window.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IWin32Window.cs
new file mode 100644
index 00000000000..2296f2d7b69
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IWin32Window.cs
@@ -0,0 +1,43 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ [Guid("458AB8A2-A1EA-4d7b-8EBE-DEE5D3D9442C")]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ public interface IWin32Window {
+ #region Public Instance Properties
+ IntPtr Handle {
+ get;
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IWindowTarget.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IWindowTarget.cs
new file mode 100644
index 00000000000..71c70d58ae0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/IWindowTarget.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+namespace System.Windows.Forms {
+ public interface IWindowTarget {
+ #region Public Instance Methods
+ void OnHandleChange(IntPtr newHandle);
+ void OnMessage(ref Message m);
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageIndexConverter.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageIndexConverter.cs
new file mode 100644
index 00000000000..36b8e6522e1
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageIndexConverter.cs
@@ -0,0 +1,98 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Ravindra rkumar@novell.com
+//
+
+
+// COMPLETE
+
+using System.Drawing;
+using System.ComponentModel;
+using System.Collections;
+using System.Diagnostics;
+using System.Globalization;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+ public class ImageIndexConverter : Int32Converter
+ {
+ #region Constructors
+
+ public ImageIndexConverter () { }
+
+ #endregion Constructors
+
+ #region Protected Properties
+
+ protected virtual bool IncludeNoneAsStandardValue {
+ get { return true; }
+ }
+
+ #endregion Protected Properties
+
+ #region Public Methods
+
+ public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ string indexStr;
+ if (value != null && value is string) {
+ indexStr = (string) value;
+ return Int32.Parse (indexStr);
+ }
+ else
+ return base.ConvertFrom (context, culture, value);
+ }
+
+ public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture,
+ object value, Type destinationType)
+ {
+ if (value != null && destinationType == typeof (string)) {
+ if (value is int && (int) value == -1)
+ return "(none)";
+ else
+ return value.ToString ();
+ }
+ else
+ return base.ConvertTo (context, culture, value, destinationType);
+ }
+
+ public override StandardValuesCollection GetStandardValues (ITypeDescriptorContext context)
+ {
+ int [] stdVal = new int [] {-1};
+ return new TypeConverter.StandardValuesCollection (stdVal);
+ }
+
+ public override bool GetStandardValuesExclusive (ITypeDescriptorContext context)
+ {
+ return false;
+ }
+
+ public override bool GetStandardValuesSupported (ITypeDescriptorContext context)
+ {
+ return true;
+ }
+
+ #endregion Public Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageLayout.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageLayout.cs
new file mode 100644
index 00000000000..7b2f4574b45
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageLayout.cs
@@ -0,0 +1,41 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public enum ImageLayout {
+ None = 0,
+ Tile = 1,
+ Center = 2,
+ Stretch = 3,
+ Zoom = 4
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageList.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageList.cs
new file mode 100644
index 00000000000..a4dcd9e548c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageList.cs
@@ -0,0 +1,1159 @@
+//
+// System.Windows.Forms.ImageList.cs
+//
+// Authors:
+// Peter Bartok <pbartok@novell.com>
+// Kornél Pál <http://www.kornelpal.hu/>
+//
+// Copyright (C) 2004-2005 Novell, Inc.
+// 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.
+//
+
+// COMPLETE
+
+//
+// Differences between MS.NET ImageList and this implementation:
+//
+// This is a fully managed image list implementation.
+//
+// Images are stored as Format32bppArgb internally but ColorDepth is applied
+// to the colors of images. Images[index] returns a Format32bppArgb copy of
+// the image so this difference is only internal.
+//
+// MS.NET has no alpha channel support (except for icons in 32-bit mode with
+// comctl32.dll version 6.0) but this implementation has full alpha channel
+// support in 32-bit mode.
+//
+// Handle should be an HIMAGELIST returned by ImageList_Create. This
+// implementation uses (IntPtr)(-1) that is a non-zero but invalid handle.
+//
+// MS.NET destroys handles using the garbage collector this implementation
+// does the same with Image objects stored in an ArrayList.
+//
+// MS.NET 1.x shares the same HIMAGELIST between ImageLists that were
+// initialized from the same ImageListStreamer and doesn't update ImageSize
+// and ColorDepth that are treated as bugs and MS.NET 2.0 behavior is
+// implemented.
+//
+// MS.NET 2.0 initializes TransparentColor to Color.Transparent in
+// constructors but ResetTransparentColor and ShouldSerializeTransparentColor
+// default to Color.LightGray that is treated as a bug.
+//
+// MS.NET 2.0 does not clear keys when handle is destroyed that is treated as
+// a bug.
+//
+
+using System.Collections;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Drawing;
+using System.Drawing.Design;
+using System.Drawing.Imaging;
+using System.Globalization;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+ [DefaultProperty("Images")]
+ [Designer("System.Windows.Forms.Design.ImageListDesigner, " + Consts.AssemblySystem_Design)]
+#if NET_2_0
+ [DesignerSerializer("System.Windows.Forms.Design.ImageListCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
+#endif
+ [ToolboxItemFilter("System.Windows.Forms")]
+ [TypeConverter(typeof(ImageListConverter))]
+ public sealed class ImageList : System.ComponentModel.Component
+ {
+ #region Private Fields
+ private const ColorDepth DefaultColorDepth = ColorDepth.Depth8Bit;
+ private static readonly Size DefaultImageSize = new Size(16, 16);
+ private static readonly Color DefaultTransparentColor = Color.Transparent;
+
+#if NET_2_0
+ private object tag;
+#endif
+ private EventHandler recreateHandle;
+ private readonly ImageCollection images;
+ #endregion // Private Fields
+
+ #region Sub-classes
+ [Editor("System.Windows.Forms.Design.ImageCollectionEditor, " + Consts.AssemblySystem_Design, typeof(UITypeEditor))]
+ public sealed class ImageCollection : IList, ICollection, IEnumerable
+ {
+ private const int AlphaMask = unchecked((int)0xFF000000);
+
+ private
+#if NET_2_0
+ static
+#else
+ sealed
+#endif
+ class IndexedColorDepths
+ {
+#if !NET_2_0
+ private IndexedColorDepths()
+ {
+ }
+#endif
+ internal static readonly ColorPalette Palette4Bit;
+ internal static readonly ColorPalette Palette8Bit;
+ private static readonly int[] squares;
+
+ static IndexedColorDepths()
+ {
+ Bitmap bitmap;
+ int index;
+
+ bitmap = new Bitmap(1, 1, PixelFormat.Format4bppIndexed);
+ Palette4Bit = bitmap.Palette;
+ bitmap.Dispose();
+
+ bitmap = new Bitmap(1, 1, PixelFormat.Format8bppIndexed);
+ Palette8Bit = bitmap.Palette;
+ bitmap.Dispose();
+
+ squares = new int[511];
+ for (index = 0; index < 256; index++)
+ squares[255 + index] = squares[255 - index] = index * index;
+ }
+
+ internal static int GetNearestColor(Color[] palette, int color)
+ {
+ int index;
+ int count;
+ int red;
+ int green;
+ int blue;
+ int nearestColor;
+ int minDistance;
+ int distance;
+
+ count = palette.Length;
+ for (index = 0; index < count; index++)
+ if (palette[index].ToArgb() == color)
+ return color;
+
+ red = unchecked((int)(unchecked((uint)color) >> 16) & 0xFF);
+ green = unchecked((int)(unchecked((uint)color) >> 8) & 0xFF);
+ blue = color & 0xFF;
+ nearestColor = AlphaMask;
+ minDistance = int.MaxValue;
+
+ for (index = 0; index < count; index++)
+ if ((distance = squares[255 + palette[index].R - red] + squares[255 + palette[index].G - green] + squares[255 + palette[index].B - blue]) < minDistance) {
+ nearestColor = palette[index].ToArgb();
+ minDistance = distance;
+ }
+
+ return nearestColor;
+ }
+ }
+
+ [Flags()]
+ private enum ItemFlags
+ {
+ None = 0,
+ UseTransparentColor = 1,
+ ImageStrip = 2
+ }
+
+ private sealed class ImageListItem
+ {
+ internal readonly object Image;
+ internal readonly ItemFlags Flags;
+ internal readonly Color TransparentColor;
+ internal readonly int ImageCount = 1;
+
+ internal ImageListItem(Icon value)
+ {
+ if (value == null)
+ throw new ArgumentNullException("value");
+
+ // Icons are cloned.
+ this.Image = (Icon)value.Clone();
+ }
+
+ internal ImageListItem(Image value)
+ {
+ if (value == null)
+ throw new ArgumentNullException("value");
+
+ if (!(value is Bitmap))
+ throw new ArgumentException("Image must be a Bitmap.");
+
+ // Images are not cloned.
+ this.Image = value;
+ }
+
+ internal ImageListItem(Image value, Color transparentColor) : this(value)
+ {
+ this.Flags = ItemFlags.UseTransparentColor;
+ this.TransparentColor = transparentColor;
+ }
+
+ internal ImageListItem(Image value, int imageCount) : this(value)
+ {
+ this.Flags = ItemFlags.ImageStrip;
+ this.ImageCount = imageCount;
+ }
+ }
+
+ #region ImageCollection Private Fields
+ private ColorDepth colorDepth = DefaultColorDepth;
+ private Size imageSize = DefaultImageSize;
+ private Color transparentColor = DefaultTransparentColor;
+ private ArrayList list = new ArrayList();
+#if NET_2_0
+ private ArrayList keys = new ArrayList();
+#endif
+ private int count;
+ private bool handleCreated;
+#if NET_2_0
+ private int lastKeyIndex = -1;
+#endif
+ private readonly ImageList owner;
+ #endregion // ImageCollection Private Fields
+
+ #region ImageCollection Internal Constructors
+ // For use in ImageList
+ internal ImageCollection(ImageList owner)
+ {
+ this.owner = owner;
+ }
+ #endregion // ImageCollection Internal Constructor
+
+ #region ImageCollection Internal Instance Properties
+ // For use in ImageList
+ internal ColorDepth ColorDepth {
+ get {
+ return this.colorDepth;
+ }
+
+ set {
+ if (!Enum.IsDefined(typeof(ColorDepth), value))
+ throw new InvalidEnumArgumentException("value", (int)value, typeof(ColorDepth));
+
+ if (this.colorDepth != value) {
+ this.colorDepth = value;
+ RecreateHandle();
+ }
+ }
+ }
+
+ // For use in ImageList
+ internal IntPtr Handle {
+ get {
+ CreateHandle();
+ return (IntPtr)(-1);
+ }
+ }
+
+ // For use in ImageList
+ internal bool HandleCreated {
+ get {
+ return this.handleCreated;
+ }
+ }
+
+ // For use in ImageList
+ internal Size ImageSize {
+ get {
+ return this.imageSize;
+ }
+
+ set {
+ if (value.Width < 1 || value.Width > 256 || value.Height < 1 || value.Height > 256)
+ throw new ArgumentException("ImageSize.Width and Height must be between 1 and 256", "value");
+
+ if (this.imageSize != value) {
+ this.imageSize = value;
+ RecreateHandle();
+ }
+ }
+ }
+
+ // For use in ImageList
+ internal ImageListStreamer ImageStream {
+ get {
+ return this.Empty ? null : new ImageListStreamer(this);
+ }
+
+ set {
+ int index;
+ Image[] streamImages;
+
+ if (value == null) {
+#if NET_2_0
+ if (this.handleCreated)
+ DestroyHandle();
+ else
+ this.Clear();
+#endif
+ }
+ // Only deserialized ImageListStreamers are used.
+ else if ((streamImages = value.Images) != null) {
+ this.list = new ArrayList(streamImages.Length);
+ this.count = 0;
+ this.handleCreated = true;
+#if NET_2_0
+ this.keys = new ArrayList(streamImages.Length);
+#endif
+
+ for (index = 0; index < streamImages.Length; index++) {
+ list.Add((Image)streamImages[index].Clone());
+#if NET_2_0
+ keys.Add(null);
+#endif
+ }
+
+ // Invalid ColorDepth values are ignored.
+ if (Enum.IsDefined(typeof(ColorDepth), value.ColorDepth))
+ this.colorDepth = (ColorDepth)value.ColorDepth;
+ this.imageSize = value.ImageSize;
+
+#if NET_2_0
+ // Event is raised even when handle was not created yet.
+ owner.OnRecreateHandle();
+#endif
+ }
+ }
+ }
+
+ // For use in ImageList
+ internal Color TransparentColor {
+ get {
+ return this.transparentColor;
+ }
+
+ set {
+ this.transparentColor = value;
+ }
+ }
+ #endregion // ImageCollection Internal Instance Properties
+
+ #region ImageCollection Public Instance Properties
+ [Browsable(false)]
+ public int Count {
+ get {
+ return this.handleCreated ? list.Count : this.count;
+ }
+ }
+
+ public bool Empty {
+ get {
+ return this.Count == 0;
+ }
+ }
+
+ public bool IsReadOnly {
+ get {
+ return false;
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Image this[int index] {
+ get {
+ return (Image)GetImage(index).Clone();
+ }
+
+ set {
+ Image image;
+
+ if (index < 0 || index >= this.Count)
+ throw new ArgumentOutOfRangeException("index");
+
+ if (value == null)
+ throw new ArgumentNullException("value");
+
+ if (!(value is Bitmap))
+ throw new ArgumentException("Image must be a Bitmap.");
+
+ image = CreateImage(value, this.transparentColor);
+ CreateHandle();
+ list[index] = image;
+ }
+ }
+
+#if NET_2_0
+ public Image this[string key] {
+ get {
+ int index;
+
+ return (index = IndexOfKey(key)) == -1 ? null : this[index];
+ }
+ }
+
+ public StringCollection Keys {
+ get {
+ int index;
+ string key;
+ StringCollection keyCollection;
+
+ // Returns all keys even when there are more keys than
+ // images. Null keys are returned as empty strings.
+
+ keyCollection = new StringCollection();
+ for (index = 0; index < keys.Count; index++)
+ keyCollection.Add(((key = (string)keys[index]) == null || key.Length == 0) ? string.Empty : key);
+
+ return keyCollection;
+ }
+ }
+#endif
+ #endregion // ImageCollection Public Instance Properties
+
+ #region ImageCollection Private Static Methods
+#if NET_2_0
+ private static bool CompareKeys(string key1, string key2)
+ {
+ // Keys are case-insensitive and keys with different length
+ // are not equal even when string.Compare treats them equal.
+
+ if (key1 == null || key2 == null || key1.Length != key2.Length)
+ return false;
+
+ return string.Compare(key1, key2, true, CultureInfo.InvariantCulture) == 0;
+ }
+#endif
+ #endregion // ImageCollection Private Static Methods
+
+ #region ImageCollection Private Instance Methods
+#if NET_2_0
+ private int AddItem(string key, ImageListItem item)
+#else
+ private int AddItem(ImageListItem item)
+#endif
+ {
+ int itemIndex;
+#if NET_2_0
+ int index;
+#endif
+
+ if (this.handleCreated)
+ itemIndex = AddItemInternal(item);
+ else {
+ // Image strips are counted as a single item in the return
+ // value of Add and AddStrip until handle is created.
+
+ itemIndex = list.Add(item);
+ this.count += item.ImageCount;
+ }
+
+#if NET_2_0
+ if ((item.Flags & ItemFlags.ImageStrip) == 0)
+ keys.Add(key);
+ else
+ for (index = 0; index < item.ImageCount; index++)
+ keys.Add(null);
+#endif
+
+ return itemIndex;
+ }
+
+ private int AddItemInternal(ImageListItem item)
+ {
+ if (item.Image is Icon) {
+ int imageWidth;
+ int imageHeight;
+ Bitmap bitmap;
+ Graphics graphics;
+
+ bitmap = new Bitmap(imageWidth = this.imageSize.Width, imageHeight = this.imageSize.Height, PixelFormat.Format32bppArgb);
+ graphics = Graphics.FromImage(bitmap);
+ graphics.DrawIcon((Icon)item.Image, new Rectangle(0, 0, imageWidth, imageHeight));
+ graphics.Dispose();
+
+ ReduceColorDepth(bitmap);
+ return list.Add(bitmap);
+ }
+ else if ((item.Flags & ItemFlags.ImageStrip) == 0)
+ return list.Add(CreateImage((Image)item.Image, (item.Flags & ItemFlags.UseTransparentColor) == 0 ? this.transparentColor : item.TransparentColor));
+ else {
+ int imageX;
+ int width;
+ int imageWidth;
+ int imageHeight;
+ int index;
+ Image image;
+ Bitmap bitmap;
+ Graphics graphics;
+ Rectangle imageRect;
+ ImageAttributes imageAttributes;
+
+ // When ImageSize was changed after adding image strips
+ // Count will return invalid values based on old ImageSize
+ // but when creating handle either ArgumentException will
+ // be thrown or image strip will be added according to the
+ // new ImageSize. This can result in image count
+ // difference that can result in exceptions in methods
+ // that use Count before creating handle. In addition this
+ // can result in the loss of sync with keys. When doing
+ // the same after handle was created there are no problems
+ // as handle will be recreated after changing ImageSize
+ // that results in the loss of images added previously.
+
+ if ((width = (image = (Image)item.Image).Width) == 0 || (width % (imageWidth = this.imageSize.Width)) != 0)
+ throw new ArgumentException("Width of image strip must be a positive multiple of ImageSize.Width.", "value");
+
+ if (image.Height != (imageHeight = this.imageSize.Height))
+ throw new ArgumentException("Height of image strip must be equal to ImageSize.Height.", "value");
+
+ imageRect = new Rectangle(0, 0, imageWidth, imageHeight);
+ if (this.transparentColor.A == 0)
+ imageAttributes = null;
+ else {
+ imageAttributes = new ImageAttributes();
+ imageAttributes.SetColorKey(this.transparentColor, this.transparentColor);
+ }
+
+ index = list.Count;
+ for (imageX = 0; imageX < width; imageX += imageWidth) {
+ bitmap = new Bitmap(imageWidth, imageHeight, PixelFormat.Format32bppArgb);
+ graphics = Graphics.FromImage(bitmap);
+ graphics.DrawImage(image, imageRect, imageX, 0, imageWidth, imageHeight, GraphicsUnit.Pixel, imageAttributes);
+ graphics.Dispose();
+
+ ReduceColorDepth(bitmap);
+ list.Add(bitmap);
+ }
+
+ if (imageAttributes != null)
+ imageAttributes.Dispose();
+
+ return index;
+ }
+ }
+
+ private void CreateHandle()
+ {
+ int index;
+ ArrayList items;
+
+ if (!this.handleCreated) {
+ items = this.list;
+ this.list = new ArrayList(this.count);
+ this.count = 0;
+ this.handleCreated = true;
+
+ for (index = 0; index < items.Count; index++)
+ AddItemInternal((ImageListItem)items[index]);
+ }
+ }
+
+ private Image CreateImage(Image value, Color transparentColor)
+ {
+ int imageWidth;
+ int imageHeight;
+ Bitmap bitmap;
+ Graphics graphics;
+ ImageAttributes imageAttributes;
+
+ if (transparentColor.A == 0)
+ imageAttributes = null;
+ else {
+ imageAttributes = new ImageAttributes();
+ imageAttributes.SetColorKey(transparentColor, transparentColor);
+ }
+
+ bitmap = new Bitmap(imageWidth = this.imageSize.Width, imageHeight = this.imageSize.Height, PixelFormat.Format32bppArgb);
+ graphics = Graphics.FromImage(bitmap);
+ graphics.DrawImage(value, new Rectangle(0, 0, imageWidth, imageHeight), 0, 0, value.Width, value.Height, GraphicsUnit.Pixel, imageAttributes);
+ graphics.Dispose();
+
+ if (imageAttributes != null)
+ imageAttributes.Dispose();
+
+ ReduceColorDepth(bitmap);
+ return bitmap;
+ }
+
+ private void RecreateHandle()
+ {
+ if (this.handleCreated) {
+ DestroyHandle();
+ this.handleCreated = true;
+ owner.OnRecreateHandle();
+ }
+ }
+
+ private unsafe void ReduceColorDepth(Bitmap bitmap)
+ {
+ byte* pixelPtr;
+ byte* lineEndPtr;
+ byte* linePtr;
+ int line;
+ int pixel;
+ int height;
+ int widthBytes;
+ int stride;
+ BitmapData bitmapData;
+ Color[] palette;
+
+ if (this.colorDepth < ColorDepth.Depth32Bit) {
+ bitmapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
+ try {
+ linePtr = (byte*)bitmapData.Scan0;
+ height = bitmapData.Height;
+ widthBytes = bitmapData.Width << 2;
+ stride = bitmapData.Stride;
+
+ if (this.colorDepth < ColorDepth.Depth16Bit) {
+ palette = (this.colorDepth < ColorDepth.Depth8Bit ? IndexedColorDepths.Palette4Bit : IndexedColorDepths.Palette8Bit).Entries;
+
+ for (line = 0; line < height; line++) {
+ lineEndPtr = linePtr + widthBytes;
+ for (pixelPtr = linePtr; pixelPtr < lineEndPtr; pixelPtr += 4)
+ *(int*)pixelPtr = ((pixel = *(int*)pixelPtr) & AlphaMask) == 0 ? 0x00000000 : IndexedColorDepths.GetNearestColor(palette, pixel | AlphaMask);
+ linePtr += stride;
+ }
+ }
+ else if (this.colorDepth < ColorDepth.Depth24Bit) {
+ for (line = 0; line < height; line++) {
+ lineEndPtr = linePtr + widthBytes;
+ for (pixelPtr = linePtr; pixelPtr < lineEndPtr; pixelPtr += 4)
+ *(int*)pixelPtr = ((pixel = *(int*)pixelPtr) & AlphaMask) == 0 ? 0x00000000 : (pixel & 0x00F8F8F8) | AlphaMask;
+ linePtr += stride;
+ }
+ }
+ else {
+ for (line = 0; line < height; line++) {
+ lineEndPtr = linePtr + widthBytes;
+ for (pixelPtr = linePtr; pixelPtr < lineEndPtr; pixelPtr += 4)
+ *(int*)pixelPtr = ((pixel = *(int*)pixelPtr) & AlphaMask) == 0 ? 0x00000000 : pixel | AlphaMask;
+ linePtr += stride;
+ }
+ }
+ }
+ finally {
+ bitmap.UnlockBits(bitmapData);
+ }
+ }
+ }
+ #endregion // ImageCollection Private Instance Methods
+
+ #region ImageCollection Internal Instance Methods
+ // For use in ImageList
+ internal void DestroyHandle()
+ {
+ if (this.handleCreated) {
+ this.list = new ArrayList();
+ this.count = 0;
+ this.handleCreated = false;
+#if NET_2_0
+ keys = new ArrayList();
+#endif
+ }
+ }
+
+ // For use in ImageList
+ internal Image GetImage(int index)
+ {
+ if (index < 0 || index >= this.Count)
+ throw new ArgumentOutOfRangeException("index");
+
+ CreateHandle();
+ return (Image)list[index];
+ }
+
+ // For use in ImageListStreamer
+ internal Image[] ToArray()
+ {
+ Image[] images;
+
+ // Handle is created even when the list is empty.
+ CreateHandle();
+ images = new Image[list.Count];
+ list.CopyTo(images);
+ return images;
+ }
+ #endregion // ImageCollection Internal Instance Methods
+
+ #region ImageCollection Public Instance Methods
+ public void Add(Icon value)
+ {
+#if NET_2_0
+ Add(null, value);
+#else
+ AddItem(new ImageListItem(value));
+#endif
+ }
+
+ public void Add(Image value)
+ {
+#if NET_2_0
+ Add(null, value);
+#else
+ AddItem(new ImageListItem(value));
+#endif
+ }
+
+ public int Add(Image value, Color transparentColor)
+ {
+#if NET_2_0
+ return AddItem(null, new ImageListItem(value, transparentColor));
+#else
+ return AddItem(new ImageListItem(value, transparentColor));
+#endif
+ }
+
+#if NET_2_0
+ public void Add(string key, Icon icon)
+ {
+ // Argument has name icon but exceptions use name value.
+ AddItem(key, new ImageListItem(icon));
+ }
+
+ public void Add(string key, Image image)
+ {
+ // Argument has name image but exceptions use name value.
+ AddItem(key, new ImageListItem(image));
+ }
+
+ public void AddRange(Image[] images)
+ {
+ int index;
+
+ if (images == null)
+ throw new ArgumentNullException("images");
+
+ for (index = 0; index < images.Length; index++)
+ Add(images[index]);
+ }
+#endif
+
+ public int AddStrip(Image value)
+ {
+ int width;
+ int imageWidth;
+
+ if (value == null)
+ throw new ArgumentNullException("value");
+
+ if ((width = value.Width) == 0 || (width % (imageWidth = this.imageSize.Width)) != 0)
+ throw new ArgumentException("Width of image strip must be a positive multiple of ImageSize.Width.", "value");
+
+ if (value.Height != this.imageSize.Height)
+ throw new ArgumentException("Height of image strip must be equal to ImageSize.Height.", "value");
+
+#if NET_2_0
+ return AddItem(null, new ImageListItem(value, width / imageWidth));
+#else
+ return AddItem(new ImageListItem(value, width / imageWidth));
+#endif
+ }
+
+ public void Clear()
+ {
+ list.Clear();
+ if (this.handleCreated)
+ this.count = 0;
+#if NET_2_0
+ keys.Clear();
+#endif
+ }
+
+#if NET_2_0
+ [EditorBrowsable(EditorBrowsableState.Never)]
+#endif
+ public bool Contains(Image image)
+ {
+ throw new NotSupportedException();
+ }
+
+#if NET_2_0
+ public bool ContainsKey(string key)
+ {
+ return IndexOfKey(key) != -1;
+ }
+#endif
+
+ public IEnumerator GetEnumerator()
+ {
+ Image[] images = new Image[this.Count];
+ int index;
+
+ if (images.Length != 0) {
+ // Handle is created only when there are images.
+ CreateHandle();
+
+ for (index = 0; index < images.Length; index++)
+ images[index] = (Image)((Image)list[index]).Clone();
+ }
+
+ return images.GetEnumerator();
+ }
+
+#if NET_2_0
+ [EditorBrowsable(EditorBrowsableState.Never)]
+#endif
+ public int IndexOf(Image image)
+ {
+ throw new NotSupportedException();
+ }
+
+#if NET_2_0
+ public int IndexOfKey(string key)
+ {
+ int index;
+
+ if (key != null && key.Length != 0) {
+ // When last IndexOfKey was successful and the same key was
+ // assigned to an image with a lower index than the last
+ // result and the key of the last result equals to key
+ // argument the last result is returned.
+
+ if (this.lastKeyIndex >= 0 && this.lastKeyIndex < this.Count && CompareKeys((string)keys[this.lastKeyIndex], key))
+ return this.lastKeyIndex;
+
+ // Duplicate keys are allowed and first match is returned.
+ for (index = 0; index < this.Count; index++)
+ if (CompareKeys((string)keys[index], key))
+ return this.lastKeyIndex = index;
+ }
+
+ return this.lastKeyIndex = -1;
+ }
+#endif
+
+#if NET_2_0
+ [EditorBrowsable(EditorBrowsableState.Never)]
+#endif
+ public void Remove(Image image)
+ {
+ throw new NotSupportedException();
+ }
+
+ public void RemoveAt(int index)
+ {
+ if (index < 0 || index >= this.Count)
+ throw new ArgumentOutOfRangeException("index");
+
+ CreateHandle();
+ list.RemoveAt(index);
+#if NET_2_0
+ keys.RemoveAt(index);
+#endif
+ }
+
+#if NET_2_0
+ public void RemoveByKey(string key)
+ {
+ int index;
+
+ if ((index = IndexOfKey(key)) != -1)
+ RemoveAt(index);
+ }
+
+ public void SetKeyName(int index, string name)
+ {
+ // Only SetKeyName throws IndexOutOfRangeException.
+ if (index < 0 || index >= this.Count)
+ throw new IndexOutOfRangeException();
+
+ keys[index] = name;
+ }
+#endif
+ #endregion // ImageCollection Public Instance Methods
+
+ #region ImageCollection Interface Properties
+ object IList.this[int index] {
+ get {
+ return this[index];
+ }
+
+ set {
+ if (!(value is Image))
+ throw new ArgumentException("value");
+
+ this[index] = (Image)value;
+ }
+ }
+
+ bool IList.IsFixedSize {
+ get {
+ return false;
+ }
+ }
+
+ bool ICollection.IsSynchronized {
+ get {
+ return false;
+ }
+ }
+
+ object ICollection.SyncRoot {
+ get {
+ return this;
+ }
+ }
+ #endregion // ImageCollection Interface Properties
+
+ #region ImageCollection Interface Methods
+ int IList.Add(object value)
+ {
+ int index;
+
+ if (!(value is Image))
+ throw new ArgumentException("value");
+
+ index = this.Count;
+ this.Add((Image)value);
+ return index;
+ }
+
+ bool IList.Contains(object value)
+ {
+ return value is Image ? this.Contains((Image)value) : false;
+ }
+
+ int IList.IndexOf(object value)
+ {
+ return value is Image ? this.IndexOf((Image)value) : -1;
+ }
+
+ void IList.Insert(int index, object value)
+ {
+ throw new NotSupportedException();
+ }
+
+ void IList.Remove(object value)
+ {
+ if (value is Image)
+ this.Remove((Image)value);
+ }
+
+ void ICollection.CopyTo(Array array, int index)
+ {
+ int imageIndex;
+
+ for (imageIndex = 0; imageIndex < this.Count; imageIndex++)
+ array.SetValue(this[index], index++);
+ }
+ #endregion // ImageCollection Interface Methods
+ }
+ #endregion // Sub-classes
+
+ #region Public Constructors
+ public ImageList()
+ {
+ images = new ImageCollection(this);
+ }
+
+ public ImageList(System.ComponentModel.IContainer container) : this()
+ {
+ container.Add(this);
+ }
+ #endregion // Public Constructors
+
+ #region Private Instance Methods
+ private void OnRecreateHandle()
+ {
+ if (this.recreateHandle != null)
+ this.recreateHandle(this, EventArgs.Empty);
+ }
+
+#if NET_2_0
+ // For use in Designers
+ private void ResetColorDepth()
+ {
+ this.ColorDepth = DefaultColorDepth;
+ }
+
+ // For use in Designers
+ private void ResetImageSize()
+ {
+ this.ImageSize = DefaultImageSize;
+ }
+
+ // For use in Designers
+ private void ResetTransparentColor()
+ {
+ this.TransparentColor = DefaultTransparentColor;
+ }
+
+ // For use in Designers
+ private bool ShouldSerializeColorDepth()
+ {
+ // ColorDepth is serialized in ImageStream when non-empty.
+ // It is serialized even if it has its default value when empty.
+ return images.Empty;
+ }
+
+ // For use in Designers
+ private bool ShouldSerializeImageSize()
+ {
+ // ImageSize is serialized in ImageStream when non-empty.
+ // It is serialized even if it has its default value when empty.
+ return images.Empty;
+ }
+
+ // For use in Designers
+ private bool ShouldSerializeTransparentColor()
+ {
+ return this.TransparentColor != DefaultTransparentColor;
+ }
+#endif
+ #endregion // Private Instance Methods
+
+ #region Public Instance Properties
+#if !NET_2_0
+ [DefaultValue(DefaultColorDepth)]
+#endif
+ public ColorDepth ColorDepth {
+ get {
+ return images.ColorDepth;
+ }
+
+ set {
+ images.ColorDepth = value;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public IntPtr Handle {
+ get {
+ return images.Handle;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool HandleCreated {
+ get {
+ return images.HandleCreated;
+ }
+ }
+
+ [DefaultValue(null)]
+ [MergableProperty(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public ImageCollection Images {
+ get {
+ return this.images;
+ }
+ }
+
+ [Localizable(true)]
+ public Size ImageSize {
+ get {
+ return images.ImageSize;
+ }
+
+ set {
+ images.ImageSize = value;
+ }
+ }
+
+ [Browsable(false)]
+ [DefaultValue(null)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public ImageListStreamer ImageStream {
+ get {
+ return images.ImageStream;
+ }
+
+ set {
+ images.ImageStream = value;
+ }
+ }
+
+#if NET_2_0
+ [Bindable(true)]
+ [DefaultValue(null)]
+ [Localizable(false)]
+ [TypeConverter(typeof(StringConverter))]
+ public object Tag {
+ get {
+ return this.tag;
+ }
+
+ set {
+ this.tag = value;
+ }
+ }
+#endif
+
+ public Color TransparentColor {
+ get {
+ return images.TransparentColor;
+ }
+
+ set {
+ images.TransparentColor = value;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public void Draw(Graphics g, Point pt, int index)
+ {
+ this.Draw(g, pt.X, pt.Y, index);
+ }
+
+ public void Draw(Graphics g, int x, int y, int index)
+ {
+ g.DrawImage(images.GetImage(index), x, y);
+ }
+
+ public void Draw(Graphics g, int x, int y, int width, int height, int index)
+ {
+ g.DrawImage(images.GetImage(index), x, y, width, height);
+ }
+
+ public override string ToString()
+ {
+ return base.ToString() + " Images.Count: " + images.Count.ToString() + ", ImageSize: " + this.ImageSize.ToString();
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ images.DestroyHandle();
+
+ base.Dispose(disposing);
+ }
+ #endregion // Protected Instance Methods
+
+ #region Events
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public event EventHandler RecreateHandle {
+ add {
+ this.recreateHandle += value;
+ }
+
+ remove {
+ this.recreateHandle -= value;
+ }
+ }
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageListConverter.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageListConverter.cs
new file mode 100644
index 00000000000..937df964561
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageListConverter.cs
@@ -0,0 +1,44 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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.
+//
+// Authors:
+// Matthias Felgner matthiasf@voelcker.com
+//
+
+// COMPLETE
+
+using System.ComponentModel;
+
+
+namespace System.Windows.Forms {
+ internal class ImageListConverter : ComponentConverter {
+ #region Constructors
+ public ImageListConverter() : base(typeof(ImageList)) {
+ }
+ #endregion Constructors
+
+ #region Public Methods
+ public override bool GetPropertiesSupported(ITypeDescriptorContext context){
+ return true;
+ }
+ #endregion Public Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageListStreamer.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageListStreamer.cs
new file mode 100644
index 00000000000..6f5fae74117
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageListStreamer.cs
@@ -0,0 +1,226 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2002-2005 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+//
+// Based on work done by:
+// Dennis Hayes (dennish@Raytek.com)
+// Aleksey Ryabchuk (ryabchuk@yahoo.com)
+
+using System.IO;
+using System.Drawing;
+using System.Collections;
+using System.Drawing.Imaging;
+using System.Runtime.Serialization;
+using System.Runtime.InteropServices;
+
+
+namespace System.Windows.Forms {
+
+ [Serializable]
+ public sealed class ImageListStreamer : ISerializable {
+
+ private static byte [] signature = new byte [] {77 , 83 , 70 , 116};
+
+ private readonly ImageList.ImageCollection imageCollection;
+ private Image [] images;
+ private Size image_size;
+ private Color back_color;
+
+ internal ImageListStreamer (ImageList.ImageCollection imageCollection) {
+ this.imageCollection = imageCollection;
+ }
+
+ private ImageListStreamer (SerializationInfo info, StreamingContext context) {
+
+ byte [] data = (byte [])info.GetValue ("Data", typeof (byte []));
+ if (data == null || data.Length <= signature.Length)
+ return;
+ // check the signature ( 'MSFt' )
+ if (data [0] != signature [0] || data [1] != signature [1] ||
+ data [2] != signature [2] || data [3] != signature [3])
+ return;
+
+ // calulate size of array needed for decomressed data
+ int i = 0;
+ int real_byte_count = 0;
+ for (i = signature.Length; i < data.Length; i += 2)
+ real_byte_count += data [i];
+
+ if (real_byte_count == 0)
+ return;
+
+ int j = 0;
+ byte [] decompressed = new byte [real_byte_count];
+
+ for (i = signature.Length; i < data.Length; i += 2) {
+ for (int k = 0; k < data [i]; k++)
+ decompressed [j++] = data [i + 1];
+ }
+
+ MemoryStream stream = new MemoryStream (decompressed);
+ BinaryReader reader = new BinaryReader (stream);
+
+ try {
+ // read image list header
+ reader.ReadUInt16 (); // usMagic
+ reader.ReadUInt16 (); // usVersion
+ ushort cCurImage = reader.ReadUInt16 ();
+ reader.ReadUInt16 (); // cMaxImage
+ reader.ReadUInt16 (); // cGrow
+ ushort cx = reader.ReadUInt16 ();
+ ushort cy = reader.ReadUInt16 ();
+ uint bkcolor = reader.ReadUInt32 ();
+ reader.ReadUInt16 (); // flags
+
+ short [] ovls = new short [4];
+ for (i = 0; i < ovls.Length; i++) {
+ ovls[i] = reader.ReadInt16 ();
+ }
+
+ image_size = new Size (cx, cy);
+ back_color = Color.FromArgb ((int) bkcolor);
+
+ MemoryStream start = new MemoryStream (decompressed,
+ (int) stream.Position,
+ (int) stream.Length - (int) stream.Position,
+ false);
+
+ Image image = Image.FromStream (start);
+
+ // Holy calamity. This is what happens on MS
+ // if the background colour is 0xFFFFFFFF (CLR_NONE)
+ // the mask is set to the color at pixel 0, 0
+ Bitmap bmp = image as Bitmap;
+ if (bkcolor == 0xFFFFFFFF && bmp != null)
+ back_color = bmp.GetPixel (0, 0);
+
+ int step = image.Width / cx;
+ images = new Image [cCurImage];
+
+ Rectangle dest_rect = new Rectangle (0, 0, cx, cy);
+ for (int r = 0 ; r < cCurImage ; r++) {
+ Rectangle area = new Rectangle (
+ (r % step) * cx,
+ (r / step) * cy,
+ cx, cy);
+ Bitmap b = new Bitmap (cx, cy);
+ using (Graphics g = Graphics.FromImage (b)) {
+ g.DrawImage (image, dest_rect, area,
+ GraphicsUnit.Pixel);
+ }
+ b.MakeTransparent (back_color);
+ images [r] = b;
+ }
+
+ } catch (Exception e) {
+
+ }
+ }
+
+ [MonoTODO ("RLE is broken")]
+ public void GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ MemoryStream stream = new MemoryStream ();
+ BinaryWriter writer = new BinaryWriter (stream);
+
+ writer.Write (signature);
+ writer.Write (GetStreamData ());
+
+ info.AddValue ("Data", stream.ToArray (), typeof (byte []));
+ }
+
+ [MonoTODO ("Images should be written to the stream")]
+ private byte [] GetStreamData ()
+ {
+ MemoryStream stream = new MemoryStream ();
+ BinaryWriter writer = new BinaryWriter (stream);
+ Image [] images = (imageCollection != null) ? imageCollection.ToArray () : this.images;
+
+ int cols = 4;
+ int rows = images.Length / cols;
+ if (images.Length % cols > 0)
+ ++rows;
+
+ Bitmap main = new Bitmap (cols * ImageSize.Width, rows * ImageSize.Height);
+ using (Graphics g = Graphics.FromImage (main)) {
+ g.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (BackColor), 0, 0, cols * ImageSize.Width, rows * ImageSize.Height);
+ for (int i = 0; i < images.Length; i++) {
+ g.DrawImage (images [i], (i % cols) * ImageSize.Width,
+ (i / cols) * ImageSize.Height);
+ }
+ }
+
+ writer.Write ((ushort) (('L' << 8) | 'I')); // magic
+ writer.Write ((ushort) 0x101); // version
+ writer.Write ((ushort) images.Length);
+ writer.Write ((ushort) images.Length);
+ writer.Write ((ushort) (rows * cols));
+ writer.Write ((ushort) 0x4); // grow....not sure this should be hard coded
+ writer.Write ((ushort) image_size.Width);
+ writer.Write ((ushort) image_size.Height);
+ writer.Write (BackColor.ToArgb ());
+ writer.Write ((ushort) 0x1009); // flags
+
+ for (int i = 0; i < 4; i++)
+ writer.Write ((short) -1); // ovls
+
+ return RLEncodeData (stream.ToArray ());
+ }
+
+ // TODO: This is broken
+ private byte [] RLEncodeData (byte [] data)
+ {
+ MemoryStream stream = new MemoryStream ();
+ BinaryWriter writer = new BinaryWriter (stream);
+
+ for (int i = 0; i < data.Length; i += 2) {
+ int seq = 0;
+ byte item = data [i];
+ while (data [i++] == item && i < data.Length)
+ seq++;
+ writer.Write ((byte) seq);
+ writer.Write (item);
+ }
+
+ return stream.ToArray ();
+
+ }
+
+ internal Image [] Images {
+ get { return images; }
+ }
+
+ internal Size ImageSize {
+ get { return image_size; }
+ }
+
+ internal ColorDepth ColorDepth {
+ get { return ColorDepth.Depth32Bit; }
+ }
+
+ internal Color BackColor {
+ get { return back_color; }
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImeMode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImeMode.cs
new file mode 100644
index 00000000000..5adad1fcbce
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImeMode.cs
@@ -0,0 +1,47 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public enum ImeMode {
+ NoControl = 0,
+ On = 1,
+ Off = 2,
+ Disable = 3,
+ Hiragana = 4,
+ Katakana = 5,
+ KatakanaHalf = 6,
+ AlphaFull = 7,
+ Alpha = 8,
+ HangulFull = 9,
+ Hangul = 10,
+ Inherit = -1
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImplicitHScrollBar.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImplicitHScrollBar.cs
new file mode 100644
index 00000000000..cd3345f914c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImplicitHScrollBar.cs
@@ -0,0 +1,47 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+// Partially based on work by:
+// Aleksey Ryabchuk ryabchuk@yahoo.com
+// Alexandre Pigolkine pigolkine@gmx.de
+// Dennis Hayes dennish@raytek.com
+// Jaak Simm jaaksimm@firm.ee
+// John Sohn jsohn@columbus.rr.com
+//
+
+// COMPLETE
+
+using System;
+
+namespace System.Windows.Forms {
+
+ internal class ImplicitHScrollBar : HScrollBar {
+
+ public ImplicitHScrollBar ()
+ {
+ SetStyle (ControlStyles.Selectable, false);
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImplicitVScrollBar.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImplicitVScrollBar.cs
new file mode 100644
index 00000000000..ca731d3df0f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImplicitVScrollBar.cs
@@ -0,0 +1,47 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+// Partially based on work by:
+// Aleksey Ryabchuk ryabchuk@yahoo.com
+// Alexandre Pigolkine pigolkine@gmx.de
+// Dennis Hayes dennish@raytek.com
+// Jaak Simm jaaksimm@firm.ee
+// John Sohn jsohn@columbus.rr.com
+//
+
+// COMPLETE
+
+using System;
+
+namespace System.Windows.Forms {
+
+ internal class ImplicitVScrollBar : VScrollBar {
+
+ public ImplicitVScrollBar ()
+ {
+ SetStyle (ControlStyles.Selectable, false);
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguage.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguage.cs
new file mode 100644
index 00000000000..7cc4fc85657
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguage.cs
@@ -0,0 +1,137 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// NOT COMPLETE
+
+using System.Globalization;
+
+namespace System.Windows.Forms {
+ public sealed class InputLanguage {
+ internal static InputLanguageCollection all;
+ private IntPtr handle;
+ private CultureInfo culture;
+ private string layout_name;
+ private static InputLanguage current_input;
+ private static InputLanguage default_input;
+
+ #region Private Constructor
+ [MonoTODO("Pull Microsofts InputLanguages and enter them here")]
+ internal InputLanguage() {
+ if (all == null) {
+ all = new InputLanguageCollection();
+
+ all.Add(new InputLanguage(IntPtr.Zero, new CultureInfo(""), "US"));
+ }
+ if (default_input == null) {
+ default_input=InputLanguage.FromCulture(CultureInfo.CurrentUICulture);
+ }
+
+ if (current_input == null) {
+ current_input=InputLanguage.FromCulture(CultureInfo.CurrentUICulture);
+ }
+ }
+
+ internal InputLanguage(IntPtr handle, CultureInfo culture, string layout_name) : this() {
+ this.handle=handle;
+ this.culture=culture;
+ this.layout_name=layout_name;
+ }
+ #endregion // Private Constructor
+
+ #region Public Static Properties
+ public static InputLanguage CurrentInputLanguage {
+ get {
+ return current_input;
+ }
+
+ set {
+ if (all.Contains(value)) {
+ current_input=value;
+ }
+ }
+ }
+
+ public static InputLanguage DefaultInputLanguage {
+ get {
+ return default_input;
+ }
+ }
+
+ public static InputLanguageCollection InstalledInputLanguages {
+ get {
+ return all;
+ }
+ }
+ #endregion // Public Static Properties
+
+ #region Public Instance Properties
+ public CultureInfo Culture {
+ get {
+ return this.culture;
+ }
+ }
+
+ public IntPtr Handle {
+ get {
+ return this.handle;
+ }
+ }
+
+ public string LayoutName {
+ get {
+ return this.layout_name;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Static Methods
+ public static InputLanguage FromCulture(System.Globalization.CultureInfo culture) {
+ foreach (InputLanguage c in all) {
+ if (culture.EnglishName==c.culture.EnglishName) {
+ return new InputLanguage(c.handle, c.culture, c.layout_name);
+ }
+ }
+
+ return new InputLanguage(all[0].handle, all[0].culture, all[0].layout_name);
+ }
+ #endregion // Public Static Methods
+
+ #region Public Instance Methods
+ public override bool Equals(object value) {
+ if (value is InputLanguage) {
+ if ((((InputLanguage)value).culture==this.culture) && (((InputLanguage)value).handle==this.handle) && (((InputLanguage)value).layout_name==this.layout_name)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public override int GetHashCode() {
+ return base.GetHashCode();
+ }
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageChangedEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageChangedEventArgs.cs
new file mode 100644
index 00000000000..ea16f810bbc
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageChangedEventArgs.cs
@@ -0,0 +1,72 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+using System.Globalization;
+
+namespace System.Windows.Forms {
+ public class InputLanguageChangedEventArgs : EventArgs {
+ private CultureInfo culture;
+ private byte charset;
+ private InputLanguage input_language;
+
+ #region Public Constructors
+ public InputLanguageChangedEventArgs(System.Globalization.CultureInfo culture, byte charSet) {
+ this.culture = culture;
+ this.charset = charSet;
+ this.input_language = InputLanguage.FromCulture(culture);
+ }
+
+ public InputLanguageChangedEventArgs(InputLanguage inputLanguage, byte charSet) {
+ this.culture = inputLanguage.Culture;
+ this.charset = charSet;
+ this.input_language = inputLanguage;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public byte CharSet {
+ get {
+ return this.charset;
+ }
+ }
+
+ public CultureInfo Culture {
+ get {
+ return this.culture;
+ }
+ }
+
+ public InputLanguage InputLanguage {
+ get {
+ return this.input_language;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageChangedEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageChangedEventHandler.cs
new file mode 100644
index 00000000000..807dce30b19
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageChangedEventHandler.cs
@@ -0,0 +1,31 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void InputLanguageChangedEventHandler(object sender, InputLanguageChangedEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageChangingEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageChangingEventArgs.cs
new file mode 100644
index 00000000000..643e3394db7
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageChangingEventArgs.cs
@@ -0,0 +1,74 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+using System;
+using System.ComponentModel;
+using System.Globalization;
+
+namespace System.Windows.Forms {
+ public class InputLanguageChangingEventArgs : System.ComponentModel.CancelEventArgs {
+ private CultureInfo culture;
+ private bool system_charset;
+ private InputLanguage input_language;
+
+ #region Public Constructors
+ public InputLanguageChangingEventArgs (System.Globalization.CultureInfo culture, bool sysCharSet) {
+ this.culture = culture;
+ this.system_charset = sysCharSet;
+ this.input_language = InputLanguage.FromCulture(culture);
+ }
+
+ public InputLanguageChangingEventArgs (InputLanguage inputLanguage, bool sysCharSet) {
+ this.culture = inputLanguage.Culture;
+ this.system_charset = sysCharSet;
+ this.input_language = inputLanguage;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public bool SysCharSet {
+ get {
+ return this.system_charset;
+ }
+ }
+
+ public CultureInfo Culture {
+ get {
+ return this.culture;
+ }
+ }
+
+ public InputLanguage InputLanguage {
+ get {
+ return this.input_language;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageChangingEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageChangingEventHandler.cs
new file mode 100644
index 00000000000..10a81b03e88
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageChangingEventHandler.cs
@@ -0,0 +1,31 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void InputLanguageChangingEventHandler(object sender, InputLanguageChangingEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageCollection.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageCollection.cs
new file mode 100644
index 00000000000..a2f990cb366
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InputLanguageCollection.cs
@@ -0,0 +1,84 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+using System.Collections;
+using System.Globalization;
+
+namespace System.Windows.Forms {
+ public class InputLanguageCollection : ReadOnlyCollectionBase {
+ #region Local Variables
+ internal InputLanguage[] list;
+ #endregion // Local Variables
+
+ #region Private Constructor
+ internal InputLanguageCollection() {
+ }
+ #endregion // Private Constructor
+
+ #region Internal Instance Methods
+ internal void Add(InputLanguage value) {
+ list[list.Length]=value;
+ }
+ #endregion
+
+ #region Public Instance Methods
+ public InputLanguage this [int index] {
+ get {
+ if (index>=list.Length) {
+ throw new ArgumentOutOfRangeException("index");
+ }
+ return list[index];
+ }
+ }
+
+ public bool Contains(InputLanguage value) {
+ for (int i=0; i<list.Length; i++) {
+ if ((list[i].Culture==value.Culture) && (list[i].LayoutName==value.LayoutName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void CopyTo(InputLanguage[] dest, int index) {
+ if (list.Length>0) {
+ Array.Copy(list, 0, dest, index, list.Length);
+ }
+ }
+
+ public int IndexOf(InputLanguage value) {
+ for (int i=0; i<list.Length; i++) {
+ if ((list[i].Culture==value.Culture) && (list[i].LayoutName==value.LayoutName)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InternalWindowManager.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InternalWindowManager.cs
new file mode 100644
index 00000000000..b281fb478f2
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InternalWindowManager.cs
@@ -0,0 +1,803 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+//
+//
+
+
+using System;
+using System.Drawing;
+using System.Runtime.InteropServices;
+
+
+namespace System.Windows.Forms {
+
+ internal class InternalWindowManager {
+
+ private static Color titlebar_color;
+
+ internal int BorderWidth = 3;
+ private Size MinTitleBarSize = new Size (115, 25);
+
+ internal Form form;
+
+ private TitleButton close_button;
+ private TitleButton maximize_button;
+ private TitleButton minimize_button;
+
+ private TitleButton [] title_buttons = new TitleButton [3];
+
+ // moving windows
+ internal Point start;
+ private State state;
+ private FormPos sizing_edge;
+ internal Rectangle virtual_position;
+ private Rectangle prev_virtual_position;
+
+ private class TitleButton {
+ public Rectangle Rectangle;
+ public ButtonState State;
+ public CaptionButton Caption;
+ public EventHandler Clicked;
+
+ public TitleButton (CaptionButton caption, EventHandler clicked)
+ {
+ Caption = caption;
+ Clicked = clicked;
+ }
+ }
+
+ private enum State {
+ Idle,
+ Moving,
+ Sizing,
+ }
+
+ [Flags]
+ private enum FormPos {
+ None,
+
+ TitleBar = 1,
+
+ Top = 2,
+ Left = 4,
+ Right = 8,
+ Bottom = 16,
+
+ TopLeft = Top | Left,
+ TopRight = Top | Right,
+
+ BottomLeft = Bottom | Left,
+ BottomRight = Bottom | Right,
+
+ AnyEdge = Top | Left | Right | Bottom,
+ }
+
+ public InternalWindowManager (Form form)
+ {
+ titlebar_color = Color.FromArgb (255, 0, 0, 255);
+ this.form = form;
+
+ CreateButtons ();
+ }
+
+ public Form Form {
+ get { return form; }
+ }
+
+ public int IconWidth {
+ get { return TitleBarHeight - 5; }
+ }
+
+ public bool HandleMessage (ref Message m)
+ {
+ switch ((Msg)m.Msg) {
+
+
+ // The mouse handling messages are actually
+ // not WM_NC* messages except for the first button and NCMOVEs
+ // down because we capture on the form
+
+ case Msg.WM_MOUSEMOVE:
+ return HandleMouseMove (form, ref m);
+
+ case Msg.WM_LBUTTONUP:
+ HandleLButtonUp (ref m);
+ break;
+
+ case Msg.WM_RBUTTONDOWN:
+ case Msg.WM_LBUTTONDOWN:
+ return HandleButtonDown (ref m);
+
+ case Msg.WM_NCHITTEST:
+ int x = Control.LowOrder ((int) m.LParam.ToInt32 ());
+ int y = Control.HighOrder ((int) m.LParam.ToInt32 ());
+
+ form.PointToClient (ref x, ref y);
+ y += TitleBarHeight;
+
+ FormPos pos = FormPosForCoords (x, y);
+
+ if (pos == FormPos.TitleBar) {
+ m.Result = new IntPtr ((int) HitTest.HTCAPTION);
+ return true;
+ }
+
+ if (!IsSizable)
+ return false;
+
+ switch (pos) {
+ case FormPos.Top:
+ m.Result = new IntPtr ((int) HitTest.HTTOP);
+ break;
+ case FormPos.Left:
+ m.Result = new IntPtr ((int) HitTest.HTLEFT);
+ break;
+ case FormPos.Right:
+ m.Result = new IntPtr ((int) HitTest.HTRIGHT);
+ break;
+ case FormPos.Bottom:
+ m.Result = new IntPtr ((int) HitTest.HTBOTTOM);
+ break;
+ case FormPos.TopLeft:
+ m.Result = new IntPtr ((int) HitTest.HTTOPLEFT);
+ break;
+ case FormPos.TopRight:
+ m.Result = new IntPtr ((int) HitTest.HTTOPRIGHT);
+ break;
+ case FormPos.BottomLeft:
+ m.Result = new IntPtr ((int) HitTest.HTBOTTOMLEFT);
+ break;
+ case FormPos.BottomRight:
+ m.Result = new IntPtr ((int) HitTest.HTBOTTOMRIGHT);
+ break;
+ default:
+ // We return false so that DefWndProc handles things
+ return false;
+ }
+ return true;
+
+ case Msg.WM_NCMOUSEMOVE:
+ return HandleNCMouseMove (form, ref m);
+
+ case Msg.WM_NCLBUTTONUP:
+ return HandleNCLButtonUp (ref m);
+
+ case Msg.WM_NCLBUTTONDOWN:
+ return HandleNCLButtonDown (ref m);
+
+ case Msg.WM_MOUSE_LEAVE:
+ FormMouseLeave (ref m);
+ break;
+
+ case Msg.WM_NCCALCSIZE:
+ XplatUIWin32.NCCALCSIZE_PARAMS ncp;
+
+ if (m.WParam == (IntPtr) 1) {
+ ncp = (XplatUIWin32.NCCALCSIZE_PARAMS) Marshal.PtrToStructure (m.LParam,
+ typeof (XplatUIWin32.NCCALCSIZE_PARAMS));
+
+ int bw = BorderWidth;
+
+ if (HasBorders) {
+ ncp.rgrc1.top += TitleBarHeight + bw;
+ ncp.rgrc1.bottom -= bw;
+ ncp.rgrc1.left += bw;
+ ncp.rgrc1.right -= bw;
+ }
+
+ Marshal.StructureToPtr(ncp, m.LParam, true);
+ }
+
+ break;
+
+ case Msg.WM_NCPAINT:
+ PaintEventArgs pe;
+
+ pe = XplatUI.PaintEventStart(m.HWnd, false);
+ PaintWindowDecorations (pe);
+ XplatUI.PaintEventEnd(m.HWnd, false);
+
+ // We don't want the form.WndProc to handle this because it
+ // will call a PaintEventEnd
+
+ return true;
+ }
+ return false;
+ }
+
+ public virtual void UpdateBorderStyle (FormBorderStyle border_style)
+ {
+ XplatUI.SetBorderStyle (form.Handle, border_style);
+
+ if (ShouldRemoveWindowManager (border_style)) {
+ form.RemoveWindowManager ();
+ return;
+ }
+
+ CreateButtons ();
+ }
+
+ public void HandleMenuMouseDown (MainMenu menu, int x, int y)
+ {
+ Point pt = MenuTracker.ScreenToMenu (menu, new Point (x, y));
+
+ foreach (TitleButton button in title_buttons) {
+ if (button != null && button.Rectangle.Contains (pt)) {
+ button.Clicked (this, EventArgs.Empty);
+ button.State = ButtonState.Pushed;
+ return;
+ }
+ }
+ }
+
+ public virtual void SetWindowState (FormWindowState window_state)
+ {
+ form.window_state = window_state;
+ }
+
+ public virtual FormWindowState GetWindowState ()
+ {
+ return form.window_state;
+ }
+
+ public virtual void PointToClient (ref int x, ref int y)
+ {
+ // toolwindows stay in screencoords
+ }
+
+ public virtual void PointToScreen (ref int x, ref int y)
+ {
+ XplatUI.ClientToScreen (form.Handle, ref x, ref y);
+ }
+
+ protected virtual bool ShouldRemoveWindowManager (FormBorderStyle style)
+ {
+ return style != FormBorderStyle.FixedToolWindow && style != FormBorderStyle.SizableToolWindow;
+ }
+
+ protected virtual void Activate ()
+ {
+ // Hack to get a paint
+ NativeWindow.WndProc (form.Handle, Msg.WM_NCPAINT, IntPtr.Zero, IntPtr.Zero);
+ form.Refresh ();
+ }
+
+ protected virtual bool IsActive ()
+ {
+ return true;
+ }
+
+ private void CreateButtons ()
+ {
+ switch (form.FormBorderStyle) {
+ case FormBorderStyle.None:
+ close_button = null;
+ minimize_button = null;
+ maximize_button = null;
+ break;
+ case FormBorderStyle.FixedSingle:
+ case FormBorderStyle.Fixed3D:
+ case FormBorderStyle.FixedDialog:
+ case FormBorderStyle.Sizable:
+ close_button = new TitleButton (CaptionButton.Close, new EventHandler (CloseClicked));
+ minimize_button = new TitleButton (CaptionButton.Minimize, new EventHandler (MinimizeClicked));
+ maximize_button = new TitleButton (CaptionButton.Maximize, new EventHandler (MaximizeClicked));
+ break;
+ case FormBorderStyle.FixedToolWindow:
+ case FormBorderStyle.SizableToolWindow:
+ close_button = new TitleButton (CaptionButton.Close, new EventHandler (CloseClicked));
+ break;
+ }
+
+ title_buttons [0] = close_button;
+ title_buttons [1] = minimize_button;
+ title_buttons [2] = maximize_button;
+ }
+
+ protected virtual bool HandleButtonDown (ref Message m)
+ {
+ Activate ();
+ return false;
+ }
+
+ protected virtual bool HandleNCLButtonDown (ref Message m)
+ {
+ Activate ();
+
+ int x = Control.LowOrder ((int) m.LParam.ToInt32 ());
+ int y = Control.HighOrder ((int) m.LParam.ToInt32 ());
+
+ start = Cursor.Position;
+ virtual_position = form.Bounds;
+
+ form.PointToClient (ref x, ref y);
+ // Need to adjust because we are in NC land
+ y += TitleBarHeight;
+ FormPos pos = FormPosForCoords (x, y);
+
+ if (pos == FormPos.TitleBar) {
+ HandleTitleBarDown (x, y);
+ return true;
+ }
+
+ if (IsSizable) {
+ SetCursorForPos (pos);
+
+ if ((pos & FormPos.AnyEdge) == 0)
+ return false;
+
+ state = State.Sizing;
+ sizing_edge = pos;
+ form.Capture = true;
+ return true;
+ }
+
+ return false;
+ }
+
+ private void HandleTitleBarDown (int x, int y)
+ {
+ foreach (TitleButton button in title_buttons) {
+ if (button != null && button.Rectangle.Contains (x, y)) {
+ button.State = ButtonState.Pushed;
+ return;
+ }
+ }
+
+ if (IsMaximized)
+ return;
+
+ state = State.Moving;
+ form.Capture = true;
+ }
+
+ private bool HandleMouseMove (Form form, ref Message m)
+ {
+ switch (state) {
+ case State.Moving:
+ HandleWindowMove (m);
+ return true;
+ case State.Sizing:
+ HandleSizing (m);
+ return true;
+ }
+
+ /*
+ if (IsSizable) {
+ int x = Control.LowOrder ((int) m.LParam.ToInt32 ());
+ int y = Control.HighOrder ((int) m.LParam.ToInt32 ());
+ FormPos pos = FormPosForCoords (x, y);
+ Console.WriteLine ("position: " + pos);
+ SetCursorForPos (pos);
+
+ ClearVirtualPosition ();
+ state = State.Idle;
+ }
+ */
+
+ return false;
+ }
+
+ private bool HandleNCMouseMove (Form form, ref Message m)
+ {
+ int x = Control.LowOrder ((int) m.LParam.ToInt32 ());
+ int y = Control.HighOrder ((int) m.LParam.ToInt32 ());
+
+ if (IsSizable) {
+ form.PointToClient (ref x, ref y);
+ y += TitleBarHeight;
+ }
+
+ return false;
+ }
+
+ private void FormMouseLeave (ref Message m)
+ {
+ form.ResetCursor ();
+ }
+
+ private void SetCursorForPos (FormPos pos)
+ {
+ switch (pos) {
+ case FormPos.TopLeft:
+ case FormPos.BottomRight:
+ form.Cursor = Cursors.SizeNWSE;
+ break;
+ case FormPos.TopRight:
+ case FormPos.BottomLeft:
+ form.Cursor = Cursors.SizeNESW;
+ break;
+ case FormPos.Top:
+ case FormPos.Bottom:
+ form.Cursor = Cursors.SizeNS;
+ break;
+ case FormPos.Left:
+ case FormPos.Right:
+ form.Cursor = Cursors.SizeWE;
+ break;
+ default:
+ form.ResetCursor ();
+ break;
+ }
+ }
+
+ protected virtual void HandleWindowMove (Message m)
+ {
+ Point move = MouseMove (m);
+
+ UpdateVP (virtual_position.X + move.X, virtual_position.Y + move.Y,
+ virtual_position.Width, virtual_position.Height);
+ }
+
+ private void HandleSizing (Message m)
+ {
+ Point move = MouseMove (m);
+ Rectangle pos = virtual_position;
+ int mw = MinTitleBarSize.Width + (BorderWidth * 2);
+ int mh = MinTitleBarSize.Height + (BorderWidth * 2);
+
+ if ((sizing_edge & FormPos.Top) != 0) {
+ int height = form.Height - move.Y;
+ if (height <= mh) {
+ move.Y += height - mh;
+ height = mh;
+ }
+ pos.Y = form.Top + move.Y;
+ pos.Height = height;
+ } else if ((sizing_edge & FormPos.Bottom) != 0) {
+ int height = form.Height + move.Y;
+ if (height <= mh)
+ move.Y -= height - mh;
+ pos.Height = form.Height + move.Y;
+ }
+
+ if ((sizing_edge & FormPos.Left) != 0) {
+ int width = form.Width - move.X;
+ if (width <= mw) {
+ move.X += width - mw;
+ width = mw;
+ }
+ pos.X = form.Left + move.X;
+ pos.Width = width;
+ } else if ((sizing_edge & FormPos.Right) != 0) {
+ int width = form.Width + move.X;
+ if (width <= mw)
+ move.X -= width - mw;
+ pos.Width = form.Width + move.X;
+ }
+
+ UpdateVP (pos);
+ }
+
+ private bool IsMaximized {
+ get { return GetWindowState () == FormWindowState.Maximized; }
+ }
+
+ private bool IsSizable {
+ get {
+ switch (form.FormBorderStyle) {
+ case FormBorderStyle.Sizable:
+ case FormBorderStyle.SizableToolWindow:
+ return true;
+ default:
+ return false;
+ }
+ }
+ }
+
+ private bool HasBorders {
+ get {
+ return form.FormBorderStyle != FormBorderStyle.None;
+ }
+ }
+
+ private bool IsToolWindow {
+ get {
+ if (form.FormBorderStyle == FormBorderStyle.SizableToolWindow ||
+ form.FormBorderStyle == FormBorderStyle.FixedToolWindow)
+ return true;
+ return false;
+ }
+ }
+
+ public int TitleBarHeight {
+ get {
+ if (IsToolWindow)
+ return SystemInformation.ToolWindowCaptionHeight;
+ if (form.FormBorderStyle == FormBorderStyle.None)
+ return 0;
+ return SystemInformation.CaptionHeight;
+ }
+ }
+
+ private Size ButtonSize {
+ get {
+ int height = TitleBarHeight;
+ if (IsToolWindow)
+ return new Size (SystemInformation.ToolWindowCaptionButtonSize.Width - 2,
+ height - 5);
+ if (form.FormBorderStyle == FormBorderStyle.None)
+ return Size.Empty;
+ return new Size (SystemInformation.CaptionButtonSize.Width - 2,
+ height - 5);
+ }
+ }
+
+ protected void UpdateVP (Rectangle r)
+ {
+ UpdateVP (r.X, r.Y, r.Width, r.Height);
+ }
+
+ protected void UpdateVP (Point loc, int w, int h)
+ {
+ UpdateVP (loc.X, loc.Y, w, h);
+ }
+
+ protected void UpdateVP (int x, int y, int w, int h)
+ {
+ virtual_position.X = x;
+ virtual_position.Y = y;
+ virtual_position.Width = w;
+ virtual_position.Height = h;
+
+ DrawVirtualPosition (virtual_position);
+ }
+
+ private void HandleLButtonUp (ref Message m)
+ {
+ if (state == State.Idle)
+ return;
+
+ ClearVirtualPosition ();
+
+ form.Capture = false;
+ form.Bounds = virtual_position;
+ state = State.Idle;
+
+ OnWindowFinishedMoving ();
+ }
+
+ private bool HandleNCLButtonUp (ref Message m)
+ {
+ int x = Control.LowOrder ((int) m.LParam.ToInt32 ());
+ int y = Control.HighOrder ((int) m.LParam.ToInt32 ());
+
+ form.PointToClient (ref x, ref y);
+
+ // Need to adjust because we are in NC land
+ y += TitleBarHeight;
+
+ foreach (TitleButton button in title_buttons) {
+ if (button != null && button.Rectangle.Contains (x, y)) {
+ button.Clicked (this, EventArgs.Empty);
+ return true;
+ }
+ }
+
+ return true;
+ }
+
+ private void PaintWindowDecorations (PaintEventArgs pe)
+ {
+ Graphics dc = pe.Graphics;
+
+ if (HasBorders) {
+ Rectangle borders = new Rectangle (0, 0, form.Width, form.Height);
+
+ ControlPaint.DrawBorder3D (dc, borders, Border3DStyle.Raised);
+ }
+
+ Color color = ThemeEngine.Current.ColorControlDark;
+
+ if (IsActive () && !IsMaximized)
+ color = titlebar_color;
+
+ Rectangle tb = new Rectangle (BorderWidth, BorderWidth,
+ form.Width - (BorderWidth * 2), TitleBarHeight - 1);
+
+ // HACK: For now always draw the titlebar until we get updates better
+ // Rectangle vis = Rectangle.Intersect (tb, pe.ClipRectangle);
+ //if (vis != Rectangle.Empty)
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (color), tb);
+
+ dc.DrawLine (new Pen (SystemColors.ControlLight, 1), BorderWidth,
+ TitleBarHeight + BorderWidth, form.Width - (BorderWidth * 2),
+ TitleBarHeight + BorderWidth);
+
+ if (!IsToolWindow) {
+ tb.X += 18; // Room for the icon and the buttons
+ tb.Width = (form.Width - 62) - tb.X;
+ }
+
+ if (form.Text != null) {
+ StringFormat format = new StringFormat ();
+ format.FormatFlags = StringFormatFlags.NoWrap;
+ format.Trimming = StringTrimming.EllipsisCharacter;
+ format.LineAlignment = StringAlignment.Center;
+
+ if (tb.IntersectsWith (pe.ClipRectangle))
+ dc.DrawString (form.Text, form.Font,
+ ThemeEngine.Current.ResPool.GetSolidBrush (Color.White),
+ tb, format);
+ }
+
+ if (!IsToolWindow && HasBorders) {
+ if (form.Icon != null) {
+ Rectangle icon = new Rectangle (BorderWidth + 3,
+ BorderWidth + 2, IconWidth, IconWidth);
+ if (icon.IntersectsWith (pe.ClipRectangle))
+ dc.DrawIcon (form.Icon, icon);
+ }
+
+ Size bs = ButtonSize;
+ close_button.Rectangle = new Rectangle (form.Width - BorderWidth - bs.Width - 2,
+ BorderWidth + 2, bs.Width, bs.Height);
+
+ maximize_button.Rectangle = new Rectangle (close_button.Rectangle.Left - 2 - bs.Width,
+ BorderWidth + 2, bs.Width, bs.Height);
+
+ minimize_button.Rectangle = new Rectangle (maximize_button.Rectangle.Left - bs.Width,
+ BorderWidth + 2, bs.Width, bs.Height);
+
+
+
+
+
+ DrawTitleButton (dc, minimize_button, pe.ClipRectangle);
+ DrawTitleButton (dc, maximize_button, pe.ClipRectangle);
+ DrawTitleButton (dc, close_button, pe.ClipRectangle);
+ } else if (IsToolWindow) {
+ Size bs = ButtonSize;
+ close_button.Rectangle = new Rectangle (form.Width - BorderWidth - 2 - bs.Width,
+ BorderWidth + 2, bs.Width, bs.Height);
+ DrawTitleButton (dc, close_button, pe.ClipRectangle);
+ }
+ }
+
+ private void DrawTitleButton (Graphics dc, TitleButton button, Rectangle clip)
+ {
+ if (!button.Rectangle.IntersectsWith (clip))
+ return;
+
+ dc.FillRectangle (SystemBrushes.Control, button.Rectangle);
+
+ ControlPaint.DrawCaptionButton (dc, button.Rectangle,
+ button.Caption, ButtonState.Normal);
+ }
+
+ public void DrawMaximizedButtons (PaintEventArgs pe, MainMenu menu)
+ {
+ Size bs = ButtonSize;
+
+ close_button.Rectangle = new Rectangle (menu.Width - BorderWidth - bs.Width - 2,
+ 2, bs.Width, bs.Height);
+
+ maximize_button.Rectangle = new Rectangle (close_button.Rectangle.Left - 2 - bs.Width,
+ 2, bs.Width, bs.Height);
+
+ minimize_button.Rectangle = new Rectangle (maximize_button.Rectangle.Left - bs.Width,
+ 2, bs.Width, bs.Height);
+
+ DrawTitleButton (pe.Graphics, minimize_button, pe.ClipRectangle);
+ DrawTitleButton (pe.Graphics, maximize_button, pe.ClipRectangle);
+ DrawTitleButton (pe.Graphics, close_button, pe.ClipRectangle);
+ }
+
+ private void CloseClicked (object sender, EventArgs e)
+ {
+ form.Close ();
+ }
+
+ private void MinimizeClicked (object sender, EventArgs e)
+ {
+ if (GetWindowState () != FormWindowState.Minimized) {
+ minimize_button.Caption = CaptionButton.Restore;
+ form.WindowState = FormWindowState.Minimized;
+ } else {
+ minimize_button.Caption = CaptionButton.Minimize;
+ form.WindowState = FormWindowState.Normal;
+ }
+ }
+
+ private void MaximizeClicked (object sender, EventArgs e)
+ {
+ if (GetWindowState () != FormWindowState.Maximized) {
+ maximize_button.Caption = CaptionButton.Restore;
+ form.WindowState = FormWindowState.Maximized;
+ } else {
+ maximize_button.Caption = CaptionButton.Maximize;
+ form.WindowState = FormWindowState.Normal;
+ }
+ }
+
+ protected Point MouseMove (Message m)
+ {
+ Point cp = Cursor.Position;
+ return new Point (cp.X - start.X, cp.Y - start.Y);
+ }
+
+ protected virtual void DrawVirtualPosition (Rectangle virtual_position)
+ {
+ form.Location = virtual_position.Location;
+ start = Cursor.Position;
+ }
+
+ protected virtual void ClearVirtualPosition ()
+ {
+
+ }
+
+ protected virtual void OnWindowFinishedMoving ()
+ {
+ }
+
+ private FormPos FormPosForCoords (int x, int y)
+ {
+ if (y < TitleBarHeight + BorderWidth) {
+ // Console.WriteLine ("A");
+ if (y > BorderWidth && x > BorderWidth &&
+ x < form.Width - BorderWidth)
+ return FormPos.TitleBar;
+
+ if (x < BorderWidth || (x < 20 && y < BorderWidth))
+ return FormPos.TopLeft;
+
+ if (x > form.Width - BorderWidth ||
+ (x > form.Width - 20 && y < BorderWidth))
+ return FormPos.TopRight;
+
+ if (y < BorderWidth)
+ return FormPos.Top;
+
+ } else if (y > form.Height - 20) {
+ // Console.WriteLine ("B");
+ if (x < BorderWidth ||
+ (x < 20 && y > form.Height - BorderWidth))
+ return FormPos.BottomLeft;
+
+ if (x > form.Width - (BorderWidth * 2) ||
+ (x > form.Width - 20 &&
+ y > form.Height - BorderWidth))
+ return FormPos.BottomRight;
+
+ if (y > form.Height - (BorderWidth * 2))
+ return FormPos.Bottom;
+
+
+ } else if (x < BorderWidth) {
+ // Console.WriteLine ("C");
+ return FormPos.Left;
+ } else if (x > form.Width - (BorderWidth * 2)) {
+// Console.WriteLine ("D");
+ return FormPos.Right;
+ } else {
+ // Console.WriteLine ("E {0}", form.Width - BorderWidth);
+ }
+
+ return FormPos.None;
+ }
+ }
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InvalidateEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InvalidateEventArgs.cs
new file mode 100644
index 00000000000..3280911fd78
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InvalidateEventArgs.cs
@@ -0,0 +1,49 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+using System.Drawing;
+
+namespace System.Windows.Forms {
+ public class InvalidateEventArgs : EventArgs {
+ private Rectangle invalidated_rectangle;
+
+ #region Public Constructors
+ public InvalidateEventArgs(System.Drawing.Rectangle invalidRect) {
+ this.invalidated_rectangle=invalidRect;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public Rectangle InvalidRect {
+ get {
+ return this.invalidated_rectangle;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InvalidateEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InvalidateEventHandler.cs
new file mode 100644
index 00000000000..3755a18b370
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InvalidateEventHandler.cs
@@ -0,0 +1,32 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void InvalidateEventHandler (object sender, InvalidateEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemActivation.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemActivation.cs
new file mode 100644
index 00000000000..7eb27a1304b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemActivation.cs
@@ -0,0 +1,40 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Kevin Rector
+//
+// Copyright (c) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Kevin Rector (krector@nazmail.com)
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public enum ItemActivation
+ {
+ OneClick = 1,
+ Standard = 0,
+ TwoClick = 2
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemBoundsPortion.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemBoundsPortion.cs
new file mode 100644
index 00000000000..70cf9daa4da
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemBoundsPortion.cs
@@ -0,0 +1,37 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Ravindra (rkumar@novell.com)
+//
+
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public enum ItemBoundsPortion
+ {
+ Entire = 0,
+ Icon = 1,
+ Label = 2,
+ ItemOnly = 3
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemChangedEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemChangedEventArgs.cs
new file mode 100644
index 00000000000..4c6408870b6
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemChangedEventArgs.cs
@@ -0,0 +1,50 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+// COMPLETE
+
+
+using System;
+
+namespace System.Windows.Forms
+{
+ public class ItemChangedEventArgs : EventArgs
+ {
+ private int index;
+
+ #region Internal Constructors
+ internal ItemChangedEventArgs (int index)
+ {
+ this.index = index;
+ }
+ #endregion // Internal Constructors
+
+ #region Public Instance Properties
+ public int Index {
+ get { return index; }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemChangedEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemChangedEventHandler.cs
new file mode 100644
index 00000000000..fef3ef453c4
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemChangedEventHandler.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+
+// COMPLETE
+
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public delegate void ItemChangedEventHandler (object sender, ItemChangedEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemCheckEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemCheckEventArgs.cs
new file mode 100644
index 00000000000..7ae0369c444
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemCheckEventArgs.cs
@@ -0,0 +1,65 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+// COMPLETE
+
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+ [ComVisible (true)]
+ public class ItemCheckEventArgs : EventArgs
+ {
+ private CheckState currentValue;
+ private int index;
+ private CheckState newValue;
+
+ #region Public Constructors
+ public ItemCheckEventArgs (int index, CheckState newCheckValue, CheckState currentValue)
+ {
+ this.index = index;
+ this.newValue = newCheckValue;
+ this.currentValue = currentValue;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public CheckState CurrentValue {
+ get { return currentValue; }
+ }
+
+ public int Index {
+ get { return index; }
+ }
+
+ public CheckState NewValue {
+ get { return newValue; }
+ set { newValue = value; }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemCheckEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemCheckEventHandler.cs
new file mode 100644
index 00000000000..abd41083e63
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemCheckEventHandler.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+
+// COMPLETE
+
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public delegate void ItemCheckEventHandler (object sender, ItemCheckEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemDragEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemDragEventArgs.cs
new file mode 100644
index 00000000000..ec591761781
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemDragEventArgs.cs
@@ -0,0 +1,63 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+// COMPLETE
+
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+ [ComVisible (true)]
+ public class ItemDragEventArgs : EventArgs
+ {
+ private MouseButtons button;
+ private object item;
+
+ #region Public Constructors
+ public ItemDragEventArgs (MouseButtons button)
+ {
+ this.button = button;
+ }
+
+ public ItemDragEventArgs (MouseButtons button, object item)
+ {
+ this.button = button;
+ this.item = item;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public MouseButtons Button {
+ get { return button; }
+ }
+
+ public object Item {
+ get { return item; }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemDragEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemDragEventHandler.cs
new file mode 100644
index 00000000000..508c3848e39
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ItemDragEventHandler.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+
+// COMPLETE
+
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public delegate void ItemDragEventHandler (object sender, ItemDragEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyEventArgs.cs
new file mode 100644
index 00000000000..acc4fa00588
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyEventArgs.cs
@@ -0,0 +1,111 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public class KeyEventArgs : EventArgs {
+ private Keys key_data;
+ private bool event_handled;
+
+ #region Public Constructors
+ public KeyEventArgs(Keys keyData) {
+ this.key_data=keyData | XplatUI.State.ModifierKeys;
+ this.event_handled=false;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public virtual bool Alt {
+ get {
+ if ((this.key_data & Keys.Alt)==0) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ }
+
+ public bool Control {
+ get {
+ if ((this.key_data & Keys.Control)==0) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ }
+
+ public bool Handled {
+ get {
+ return this.event_handled;
+ }
+
+ set {
+ this.event_handled=value;
+ }
+ }
+
+ public Keys KeyCode {
+ get {
+ return (this.key_data & Keys.KeyCode);
+ }
+ }
+
+ public Keys KeyData {
+ get {
+ return this.key_data;
+ }
+ }
+
+ public int KeyValue {
+ get {
+ return Convert.ToInt32(this.key_data);
+ }
+ }
+
+ public Keys Modifiers {
+ get {
+ return (this.key_data & Keys.Modifiers);
+ }
+ }
+
+ public virtual bool Shift {
+ get {
+ if ((this.key_data & Keys.Shift)==0) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyEventHandler.cs
new file mode 100644
index 00000000000..ff67a7f80ea
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyEventHandler.cs
@@ -0,0 +1,33 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void KeyEventHandler (object sender, KeyEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyPressEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyPressEventArgs.cs
new file mode 100644
index 00000000000..6907480be21
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyPressEventArgs.cs
@@ -0,0 +1,63 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public class KeyPressEventArgs : EventArgs {
+ private char key_char;
+ private bool event_handled;
+
+ #region Public Constructors
+ public KeyPressEventArgs(char keyChar) {
+ this.key_char=keyChar;
+ this.event_handled=false;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public bool Handled {
+ get {
+ return this.event_handled;
+ }
+
+ set {
+ this.event_handled=value;
+ }
+ }
+
+ public char KeyChar {
+ get {
+ return this.key_char;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyPressEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyPressEventHandler.cs
new file mode 100644
index 00000000000..3d259159715
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyPressEventHandler.cs
@@ -0,0 +1,31 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void KeyPressEventHandler (object sender, KeyPressEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyboardLayouts.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyboardLayouts.cs
new file mode 100644
index 00000000000..8a6d0098947
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeyboardLayouts.cs
@@ -0,0 +1,130 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+//
+//
+
+using System;
+using System.Resources;
+
+namespace System.Windows.Forms {
+
+ internal class _KeyboardLayout {
+ public string Comment;
+ public int CodePage;
+ public uint [][] Key;
+ public short [] Scan;
+ public VirtualKeys [] VKey;
+
+ public _KeyboardLayout (string comment, int code_page, uint [][] key, short [] scan, VirtualKeys [] vkey)
+ {
+ Comment = comment;
+ CodePage = code_page;
+ Key = key;
+ Scan = scan;
+ VKey = vkey;
+ }
+ }
+
+ internal class KeyboardLayouts {
+
+ private KeyboardLayout [] keyboard_layouts;
+ public int [][] vkey_table;
+ public short [][] scan_table;
+
+ public KeyboardLayouts ()
+ {
+ LoadLayouts ();
+ }
+
+ public void LoadLayouts ()
+ {
+ ResourceManager rm;
+ rm = new ResourceManager ("keyboards", System.Reflection.Assembly.GetExecutingAssembly());
+ keyboard_layouts = (KeyboardLayout []) rm.GetObject ("keyboard_table");
+
+ vkey_table = (int [][]) rm.GetObject ("vkey_table");
+ scan_table = (short [][]) rm.GetObject ("scan_table");
+ }
+
+ public KeyboardLayout [] Layouts {
+ get { return keyboard_layouts; }
+ }
+ }
+
+
+
+ [Serializable]
+ [CLSCompliant(false)]
+#if GENERATING_RESOURCES
+ public
+#else
+ internal
+#endif
+ class KeyboardLayout {
+
+ public int Lcid;
+ public string Name;
+ public ScanTableIndex ScanIndex;
+ public VKeyTableIndex VKeyIndex;
+ public uint [][] Keys;
+
+ public KeyboardLayout (int lcid, string name, ScanTableIndex scan_index,
+ VKeyTableIndex vkey_index, uint [][] keys)
+ {
+ Lcid = lcid;
+ Name = name;
+ ScanIndex = scan_index;
+ VKeyIndex = vkey_index;
+ Keys = keys;
+ }
+
+ public KeyboardLayout (int lcid, string name, int scan_index,
+ int vkey_index, uint [][] keys) : this (lcid, name, (ScanTableIndex) scan_index,
+ (VKeyTableIndex) vkey_index, keys)
+ {
+ }
+ }
+
+ internal enum VKeyTableIndex {
+ Qwerty,
+ Qwertz,
+ Dvorak,
+ Qwertz105,
+ Azerty,
+ QwertyV2,
+ AbntQwerty,
+ QwertyJp106,
+ Vnc
+ }
+
+ internal enum ScanTableIndex {
+ Qwerty,
+ Dvorak,
+ AbntQwerty,
+ QwertyJp106,
+ Vnc
+ }
+
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Keys.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Keys.cs
new file mode 100644
index 00000000000..2f3278417b8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Keys.cs
@@ -0,0 +1,221 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+// COMPLETE
+
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [Flags]
+ [ComVisible(true)]
+ [TypeConverter(typeof(KeysConverter))]
+ public enum Keys {
+ None = 0x00000000,
+ LButton = 0x00000001,
+ RButton = 0x00000002,
+ Cancel = 0x00000003,
+ MButton = 0x00000004,
+ XButton1 = 0x00000005,
+ XButton2 = 0x00000006,
+ Back = 0x00000008,
+ Tab = 0x00000009,
+ LineFeed = 0x0000000A,
+ Clear = 0x0000000C,
+ Return = 0x0000000D,
+ Enter = 0x0000000D,
+ ShiftKey = 0x00000010,
+ ControlKey = 0x00000011,
+ Menu = 0x00000012,
+ Pause = 0x00000013,
+ CapsLock = 0x00000014,
+ Capital = 0x00000014,
+ KanaMode = 0x00000015,
+ HanguelMode = 0x00000015,
+ HangulMode = 0x00000015,
+ JunjaMode = 0x00000017,
+ FinalMode = 0x00000018,
+ KanjiMode = 0x00000019,
+ HanjaMode = 0x00000019,
+ Escape = 0x0000001B,
+ IMEConvert = 0x0000001C,
+ IMENonconvert = 0x0000001D,
+ IMEAceept = 0x0000001E,
+ IMEModeChange = 0x0000001F,
+ Space = 0x00000020,
+ PageUp = 0x00000021,
+ Prior = 0x00000021,
+ PageDown = 0x00000022,
+ Next = 0x00000022,
+ End = 0x00000023,
+ Home = 0x00000024,
+ Left = 0x00000025,
+ Up = 0x00000026,
+ Right = 0x00000027,
+ Down = 0x00000028,
+ Select = 0x00000029,
+ Print = 0x0000002A,
+ Execute = 0x0000002B,
+ PrintScreen = 0x0000002C,
+ Snapshot = 0x0000002C,
+ Insert = 0x0000002D,
+ Delete = 0x0000002E,
+ Help = 0x0000002F,
+ D0 = 0x00000030,
+ D1 = 0x00000031,
+ D2 = 0x00000032,
+ D3 = 0x00000033,
+ D4 = 0x00000034,
+ D5 = 0x00000035,
+ D6 = 0x00000036,
+ D7 = 0x00000037,
+ D8 = 0x00000038,
+ D9 = 0x00000039,
+ A = 0x00000041,
+ B = 0x00000042,
+ C = 0x00000043,
+ D = 0x00000044,
+ E = 0x00000045,
+ F = 0x00000046,
+ G = 0x00000047,
+ H = 0x00000048,
+ I = 0x00000049,
+ J = 0x0000004A,
+ K = 0x0000004B,
+ L = 0x0000004C,
+ M = 0x0000004D,
+ N = 0x0000004E,
+ O = 0x0000004F,
+ P = 0x00000050,
+ Q = 0x00000051,
+ R = 0x00000052,
+ S = 0x00000053,
+ T = 0x00000054,
+ U = 0x00000055,
+ V = 0x00000056,
+ W = 0x00000057,
+ X = 0x00000058,
+ Y = 0x00000059,
+ Z = 0x0000005A,
+ LWin = 0x0000005B,
+ RWin = 0x0000005C,
+ Apps = 0x0000005D,
+ NumPad0 = 0x00000060,
+ NumPad1 = 0x00000061,
+ NumPad2 = 0x00000062,
+ NumPad3 = 0x00000063,
+ NumPad4 = 0x00000064,
+ NumPad5 = 0x00000065,
+ NumPad6 = 0x00000066,
+ NumPad7 = 0x00000067,
+ NumPad8 = 0x00000068,
+ NumPad9 = 0x00000069,
+ Multiply = 0x0000006A,
+ Add = 0x0000006B,
+ Separator = 0x0000006C,
+ Subtract = 0x0000006D,
+ Decimal = 0x0000006E,
+ Divide = 0x0000006F,
+ F1 = 0x00000070,
+ F2 = 0x00000071,
+ F3 = 0x00000072,
+ F4 = 0x00000073,
+ F5 = 0x00000074,
+ F6 = 0x00000075,
+ F7 = 0x00000076,
+ F8 = 0x00000077,
+ F9 = 0x00000078,
+ F10 = 0x00000079,
+ F11 = 0x0000007A,
+ F12 = 0x0000007B,
+ F13 = 0x0000007C,
+ F14 = 0x0000007D,
+ F15 = 0x0000007E,
+ F16 = 0x0000007F,
+ F17 = 0x00000080,
+ F18 = 0x00000081,
+ F19 = 0x00000082,
+ F20 = 0x00000083,
+ F21 = 0x00000084,
+ F22 = 0x00000085,
+ F23 = 0x00000086,
+ F24 = 0x00000087,
+ NumLock = 0x00000090,
+ Scroll = 0x00000091,
+ LShiftKey = 0x000000A0,
+ RShiftKey = 0x000000A1,
+ LControlKey = 0x000000A2,
+ RControlKey = 0x000000A3,
+ LMenu = 0x000000A4,
+ RMenu = 0x000000A5,
+ BrowserBack = 0x000000A6,
+ BrowserForward = 0x000000A7,
+ BrowserRefresh = 0x000000A8,
+ BrowserStop = 0x000000A9,
+ BrowserSearch = 0x000000AA,
+ BrowserFavorites= 0x000000AB,
+ BrowserHome = 0x000000AC,
+ VolumeMute = 0x000000AD,
+ VolumeDown = 0x000000AE,
+ VolumeUp = 0x000000AF,
+ MediaNextTrack = 0x000000B0,
+ MediaPreviousTrack= 0x000000B1,
+ MediaStop = 0x000000B2,
+ MediaPlayPause = 0x000000B3,
+ LaunchMail = 0x000000B4,
+ SelectMedia = 0x000000B5,
+ LaunchApplication1= 0x000000B6,
+ LaunchApplication2= 0x000000B7,
+ OemSemicolon = 0x000000BA,
+ Oemplus = 0x000000BB,
+ Oemcomma = 0x000000BC,
+ OemMinus = 0x000000BD,
+ OemPeriod = 0x000000BE,
+ OemQuestion = 0x000000BF,
+ Oemtilde = 0x000000C0,
+ OemOpenBrackets = 0x000000DB,
+ OemPipe = 0x000000DC,
+ OemCloseBrackets= 0x000000DD,
+ OemQuotes = 0x000000DE,
+ Oem8 = 0x000000DF,
+ OemBackslash = 0x000000E2,
+ ProcessKey = 0x000000E5,
+ Attn = 0x000000F6,
+ Crsel = 0x000000F7,
+ Exsel = 0x000000F8,
+ EraseEof = 0x000000F9,
+ Play = 0x000000FA,
+ Zoom = 0x000000FB,
+ NoName = 0x000000FC,
+ Pa1 = 0x000000FD,
+ OemClear = 0x000000FE,
+ KeyCode = 0x0000FFFF,
+ Shift = 0x00010000,
+ Control = 0x00020000,
+ Alt = 0x00040000,
+ Modifiers = unchecked((int)0xFFFF0000)
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeysConverter.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeysConverter.cs
new file mode 100644
index 00000000000..ed419607262
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/KeysConverter.cs
@@ -0,0 +1,126 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+using System.Collections;
+using System.ComponentModel;
+using System.Text;
+
+namespace System.Windows.Forms {
+ public class KeysConverter : TypeConverter, IComparer {
+ #region Public Constructors
+ public KeysConverter() {
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Methods
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
+ if (sourceType == typeof(string)) {
+ return true;
+ }
+ return false;
+ }
+
+ public int Compare(object a, object b) {
+ if (a is string && b is string) {
+ return String.Compare((string) a, (string)b);
+ }
+ return String.Compare(a.ToString(), b.ToString());
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+ if (value is string) {
+ string[] keys;
+ Keys key;
+
+ keys = ((string)value).Split(new char[] {'+'});
+ key = Keys.None;
+
+ if (keys.Length > 1) {
+ for (int i = 0; i < keys.Length - 1; i++) {
+ if (keys[i].Equals("Ctrl")) {
+ key |= Keys.Control;
+ } else {
+ key |= (Keys)Enum.Parse(typeof(Keys), keys[i], true);
+ }
+ }
+ }
+ key |= (Keys)Enum.Parse(typeof(Keys), keys[keys.Length - 1], true);
+ return key;
+ }
+ return base.ConvertFrom (context, culture, value);
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) {
+ if (destinationType == typeof(string)) {
+ StringBuilder sb;
+ Keys key;
+
+ sb = new StringBuilder();
+ key = (Keys)value;
+
+ // Modifiers first
+ if ((key & Keys.Control) != 0) {
+ sb.Append("Ctrl+");
+ }
+
+ if ((key & Keys.Alt) != 0) {
+ sb.Append("Alt+");
+ }
+
+ if ((key & Keys.Shift) != 0) {
+ sb.Append("Shift+");
+ }
+
+ // Keycode last
+ sb.Append(Enum.GetName(typeof(Keys), key & Keys.KeyCode));
+
+ return sb.ToString();
+ }
+ return base.ConvertTo (context, culture, value, destinationType);
+ }
+
+ public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) {
+ string [] stdVal = new string [] {
+ "Alt", "Back", "Control", "Delete", "End", "Enter", "F1", "F10", "F11", "F12", "F2",
+ "F3", "F4", "F5", "F6", "F7", "F8", "F9", "Home", "Insert", "Next", "Prior", "Shift"};
+
+ return new TypeConverter.StandardValuesCollection (stdVal);
+ }
+
+ public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) {
+
+ return false;
+ }
+
+ public override bool GetStandardValuesSupported(ITypeDescriptorContext context) {
+ return true;
+ }
+
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Label.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Label.cs
new file mode 100644
index 00000000000..d82870b312c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Label.cs
@@ -0,0 +1,657 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+// Peter Bartok, pbartok@novell.com
+//
+//
+
+// COMPLETE
+
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.Drawing.Text;
+using System.Drawing.Imaging;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+ [DefaultProperty("Text")]
+ [Designer ("System.Windows.Forms.Design.LabelDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ public class Label : Control
+ {
+ private bool autosize;
+ private Image image;
+ private bool render_transparent;
+ private FlatStyle flat_style;
+ private int preferred_height;
+ private int preferred_width;
+ private bool use_mnemonic;
+ private int image_index = -1;
+ private ImageList image_list;
+ internal ContentAlignment image_align;
+ internal StringFormat string_format;
+ internal ContentAlignment text_align;
+ static SizeF req_witdthsize = new SizeF (0,0);
+
+ #region Events
+ public event EventHandler AutoSizeChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler BackgroundImageChanged {
+ add {
+ base.BackgroundImageChanged += value;
+ }
+ remove {
+ base.BackgroundImageChanged -= value;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler ImeModeChanged {
+ add {
+ base.ImeModeChanged += value;
+ }
+ remove {
+ base.ImeModeChanged -= value;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event KeyEventHandler KeyDown {
+ add {
+ base.KeyDown += value;
+ }
+ remove {
+ base.KeyDown -= value;
+ }
+ }
+
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event KeyPressEventHandler KeyPress {
+ add {
+ base.KeyPress += value;
+ }
+ remove {
+ base.KeyPress -= value;
+ }
+ }
+
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event KeyEventHandler KeyUp {
+ add {
+ base.KeyUp += value;
+ }
+ remove {
+ base.KeyUp -= value;
+ }
+ }
+
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler TabStopChanged {
+ add {
+ base.TabStopChanged += value;
+ }
+ remove {
+ base.TabStopChanged -= value;
+ }
+ }
+
+ public event EventHandler TextAlignChanged;
+ #endregion
+
+ public Label ()
+ {
+ // Defaults in the Spec
+ autosize = false;
+ tab_stop = false;
+ string_format = new StringFormat();
+ TextAlign = ContentAlignment.TopLeft;
+ image = null;
+ UseMnemonic = true;
+ image_list = null;
+ image_align = ContentAlignment.MiddleCenter;
+ SetUseMnemonic (UseMnemonic);
+ flat_style = FlatStyle.Standard;
+
+ CalcPreferredHeight ();
+ CalcPreferredWidth ();
+
+ AutoSizeChanged = null;
+ TextAlignChanged = null;
+
+ SetStyle (ControlStyles.Selectable, false);
+ SetStyle (ControlStyles.ResizeRedraw |
+ ControlStyles.UserPaint |
+ ControlStyles.AllPaintingInWmPaint |
+ ControlStyles.SupportsTransparentBackColor |
+ ControlStyles.DoubleBuffer, true);
+
+ HandleCreated += new EventHandler (OnHandleCreatedLB);
+ }
+
+ #region Public Properties
+ [DefaultValue(false)]
+ [Localizable(true)]
+ [RefreshProperties(RefreshProperties.All)]
+ public virtual bool AutoSize {
+ get { return autosize; }
+ set {
+ if (autosize == value)
+ return;
+
+ autosize = value;
+ CalcAutoSize ();
+ Refresh ();
+
+ OnAutoSizeChanged (EventArgs.Empty);
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Image BackgroundImage {
+ get {
+ return base.BackgroundImage;
+ }
+ set {
+ base.BackgroundImage = value;
+ Refresh ();
+ }
+ }
+
+ [DefaultValue(BorderStyle.None)]
+ [DispId(-504)]
+ public virtual BorderStyle BorderStyle {
+ get { return InternalBorderStyle; }
+ set { InternalBorderStyle = value; }
+ }
+
+ protected override CreateParams CreateParams {
+ get { return base.CreateParams;}
+ }
+
+ protected override ImeMode DefaultImeMode {
+ get { return ImeMode.Disable;}
+ }
+
+ protected override Size DefaultSize {
+ get {return ThemeEngine.Current.LabelDefaultSize;}
+ }
+
+ [DefaultValue(FlatStyle.Standard)]
+ public FlatStyle FlatStyle {
+ get {
+ return flat_style;
+ }
+ set {
+ if (!Enum.IsDefined (typeof (FlatStyle), value))
+ throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for FlatStyle", value));
+
+ if (flat_style == value)
+ return;
+
+ flat_style = value;
+ Refresh ();
+ }
+ }
+
+ [Localizable(true)]
+ public Image Image {
+ get {
+ if (image != null) {
+ return image;
+ }
+
+ if (image_list != null && ImageIndex >= 0) {
+ return image_list.Images[ImageIndex];
+ }
+
+ return null;
+ }
+ set {
+ if (image == value)
+ return;
+
+ image = value;
+ Refresh ();
+ }
+ }
+
+ [DefaultValue(ContentAlignment.MiddleCenter)]
+ [Localizable(true)]
+ public ContentAlignment ImageAlign {
+ get {
+ return image_align;
+ }
+ set {
+ if (!Enum.IsDefined (typeof (ContentAlignment), value))
+ throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for ContentAlignment", value));
+
+ if (image_align == value)
+ return;
+
+ image_align = value;
+ Refresh ();
+ }
+ }
+
+ [DefaultValue (-1)]
+ [Editor ("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
+ [Localizable (true)]
+ [TypeConverter (typeof (ImageIndexConverter))]
+ public int ImageIndex {
+ get {
+ if (ImageList == null) {
+ return -1;
+ }
+
+ if (image_index >= image_list.Images.Count) {
+ return image_list.Images.Count - 1;
+ }
+
+ return image_index;
+ }
+ set {
+
+ if (value < -1)
+ throw new ArgumentException ();
+
+ if (image_index == value)
+ return;
+
+ image_index = value;
+
+ if (ImageList != null && image_index !=-1)
+ Image = null;
+
+ Refresh ();
+ }
+ }
+
+ [DefaultValue(null)]
+ public ImageList ImageList {
+ get { return image_list;}
+ set {
+ if (image_list == value)
+ return;
+
+ image_list = value;
+
+ if (image_list != null && image_index !=-1)
+ Image = null;
+
+ Refresh ();
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new ImeMode ImeMode {
+ get { return base.ImeMode; }
+ set { base.ImeMode = value; }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public virtual int PreferredHeight {
+ get { return preferred_height; }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public virtual int PreferredWidth {
+ get {return preferred_width; }
+ }
+
+ protected virtual bool RenderTransparent {
+ get { return render_transparent; }
+ set { render_transparent = value;}
+ }
+
+ [Browsable(false)]
+ [DefaultValue(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new bool TabStop {
+ get { return base.TabStop; }
+ set { base.TabStop = value; }
+ }
+
+ [DefaultValue(ContentAlignment.TopLeft)]
+ [Localizable(true)]
+ public virtual ContentAlignment TextAlign {
+ get { return text_align; }
+
+ set {
+ if (!Enum.IsDefined (typeof (ContentAlignment), value))
+ throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for ContentAlignment", value));
+
+ if (text_align != value) {
+
+ text_align = value;
+
+ switch (value) {
+
+ case ContentAlignment.BottomLeft:
+ string_format.LineAlignment = StringAlignment.Far;
+ string_format.Alignment = StringAlignment.Near;
+ break;
+ case ContentAlignment.BottomCenter:
+ string_format.LineAlignment = StringAlignment.Far;
+ string_format.Alignment = StringAlignment.Center;
+ break;
+ case ContentAlignment.BottomRight:
+ string_format.LineAlignment = StringAlignment.Far;
+ string_format.Alignment = StringAlignment.Far;
+ break;
+ case ContentAlignment.TopLeft:
+ string_format.LineAlignment = StringAlignment.Near;
+ string_format.Alignment = StringAlignment.Near;
+ break;
+ case ContentAlignment.TopCenter:
+ string_format.LineAlignment = StringAlignment.Near;
+ string_format.Alignment = StringAlignment.Center;
+ break;
+ case ContentAlignment.TopRight:
+ string_format.LineAlignment = StringAlignment.Near;
+ string_format.Alignment = StringAlignment.Far;
+ break;
+ case ContentAlignment.MiddleLeft:
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.Alignment = StringAlignment.Near;
+ break;
+ case ContentAlignment.MiddleRight:
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.Alignment = StringAlignment.Far;
+ break;
+ case ContentAlignment.MiddleCenter:
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.Alignment = StringAlignment.Center;
+ break;
+ default:
+ break;
+ }
+
+ OnTextAlignChanged (EventArgs.Empty);
+ Refresh();
+ }
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool UseMnemonic {
+ get { return use_mnemonic; }
+ set {
+ if (use_mnemonic != value) {
+ use_mnemonic = value;
+ SetUseMnemonic (use_mnemonic);
+ Refresh ();
+ }
+ }
+ }
+
+ #endregion
+
+
+ #region Public Methods
+
+ protected Rectangle CalcImageRenderBounds (Image image, Rectangle area, ContentAlignment img_align)
+ {
+ Rectangle rcImageClip = area;
+ rcImageClip.Inflate (-2,-2);
+
+ int X = area.X;
+ int Y = area.Y;
+
+ if (img_align == ContentAlignment.TopCenter ||
+ img_align == ContentAlignment.MiddleCenter ||
+ img_align == ContentAlignment.BottomCenter) {
+ X += (area.Width - image.Width) / 2;
+ }
+ else if (img_align == ContentAlignment.TopRight ||
+ img_align == ContentAlignment.MiddleRight||
+ img_align == ContentAlignment.BottomRight) {
+ X += (area.Width - image.Width);
+ }
+
+ if( img_align == ContentAlignment.BottomCenter ||
+ img_align == ContentAlignment.BottomLeft ||
+ img_align == ContentAlignment.BottomRight) {
+ Y += area.Height - image.Height;
+ }
+ else if(img_align == ContentAlignment.MiddleCenter ||
+ img_align == ContentAlignment.MiddleLeft ||
+ img_align == ContentAlignment.MiddleRight) {
+ Y += (area.Height - image.Height) / 2;
+ }
+
+ rcImageClip.X = X;
+ rcImageClip.Y = Y;
+ rcImageClip.Width = image.Width;
+ rcImageClip.Height = image.Height;
+
+ return rcImageClip;
+ }
+
+
+ protected override AccessibleObject CreateAccessibilityInstance ()
+ {
+ return base.CreateAccessibilityInstance ();
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ base.Dispose (disposing);
+
+ if (disposing)
+ string_format.Dispose ();
+ }
+
+ protected void DrawImage (Graphics g, Image image, Rectangle area, ContentAlignment img_align)
+ {
+ if (image == null || g == null)
+ return;
+
+ Rectangle rcImageClip = CalcImageRenderBounds (image, area, img_align);
+
+ if (Enabled)
+ g.DrawImage (image, rcImageClip.X, rcImageClip.Y, rcImageClip.Width, rcImageClip.Height);
+ else
+ ControlPaint.DrawImageDisabled (g, image, rcImageClip.X, rcImageClip.Y, BackColor);
+ }
+
+ protected virtual void OnAutoSizeChanged (EventArgs e)
+ {
+ if (AutoSizeChanged != null)
+ AutoSizeChanged (this, e);
+ }
+
+ protected override void OnEnabledChanged (EventArgs e)
+ {
+ base.OnEnabledChanged (e);
+ }
+
+ protected override void OnFontChanged (EventArgs e)
+ {
+ base.OnFontChanged (e);
+ if (autosize) {
+ CalcAutoSize();
+ } else {
+ CalcPreferredHeight ();
+ }
+ Refresh ();
+ }
+
+ protected override void OnPaint (PaintEventArgs pevent)
+ {
+ ThemeEngine.Current.DrawLabel (pevent.Graphics, ClientRectangle, this);
+ DrawImage (pevent.Graphics, Image, ClientRectangle, image_align);
+ base.OnPaint(pevent);
+ }
+
+ protected override void OnParentChanged (EventArgs e)
+ {
+ base.OnParentChanged (e);
+ }
+
+ protected virtual void OnTextAlignChanged (EventArgs e)
+ {
+ if (TextAlignChanged != null)
+ TextAlignChanged (this, e);
+ }
+
+ protected override void OnTextChanged (EventArgs e)
+ {
+ base.OnTextChanged (e);
+ if (autosize) {
+ CalcAutoSize ();
+ } else {
+ CalcPreferredWidth ();
+ }
+ Refresh ();
+ }
+
+ protected override void OnVisibleChanged (EventArgs e)
+ {
+ base.OnVisibleChanged (e);
+ }
+
+ protected override bool ProcessMnemonic (char charCode)
+ {
+ if (IsMnemonic(charCode, Text) == true) {
+ // Select item next in line in tab order
+ if (this.parent != null) {
+ parent.SelectNextControl(this, true, false, false, false);
+ }
+ return true;
+ }
+
+ return base.ProcessMnemonic (charCode);
+ }
+
+ protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified)
+ {
+ base.SetBoundsCore (x, y, width, height, specified);
+ }
+
+ public override string ToString()
+ {
+ return base.ToString () + ", Text: " + Text;
+ }
+
+ protected override void WndProc (ref Message m)
+ {
+ switch ((Msg) m.Msg) {
+ case Msg.WM_DRAWITEM: {
+ m.Result = (IntPtr)1;
+ }
+ break;
+ default:
+ base.WndProc (ref m);
+ break;
+ }
+ }
+
+ #endregion Public Methods
+
+ #region Private Methods
+
+ private void CalcAutoSize ()
+ {
+ if (IsHandleCreated == false || AutoSize == false)
+ return;
+
+ CalcPreferredWidth ();
+ CalcPreferredHeight ();
+
+ Width = PreferredWidth;
+ Height = PreferredHeight;
+ }
+
+ private void CalcPreferredHeight ()
+ {
+ preferred_height = Font.Height;
+
+ switch (border_style) {
+ case BorderStyle.None:
+ preferred_height += 3;
+ break;
+ case BorderStyle.FixedSingle:
+ case BorderStyle.Fixed3D:
+ preferred_height += 6;
+ break;
+ default:
+ break;
+ }
+
+ }
+
+ private void CalcPreferredWidth ()
+ {
+ SizeF size;
+ size = DeviceContext.MeasureString (Text, Font, req_witdthsize, string_format);
+ preferred_width = (int) size.Width + 3;
+ }
+
+ private void OnHandleCreatedLB (Object o, EventArgs e)
+ {
+ if (autosize)
+ CalcAutoSize ();
+ }
+
+ private void SetUseMnemonic (bool use)
+ {
+ if (use)
+ string_format.HotkeyPrefix = HotkeyPrefix.Show;
+ else
+ string_format.HotkeyPrefix = HotkeyPrefix.None;
+ }
+
+ #endregion Private Methods
+#if NET_2_0
+
+ public bool UseCompatibleTextRendering {
+ get {
+ return use_compatible_text_rendering;
+ }
+
+ set {
+ use_compatible_text_rendering = value;
+ }
+ }
+#endif
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LabelEditEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LabelEditEventArgs.cs
new file mode 100644
index 00000000000..3a899ec30bc
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LabelEditEventArgs.cs
@@ -0,0 +1,68 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+
+// COMPLETE
+
+
+using System;
+
+namespace System.Windows.Forms
+{
+ public class LabelEditEventArgs : EventArgs
+ {
+ private int item;
+ private string label;
+ private bool cancelEdit = false;
+
+ #region Public Constructors
+ public LabelEditEventArgs (int item)
+ {
+ this.item = item;
+ }
+
+ public LabelEditEventArgs (int item, string label)
+ {
+ this.item = item;
+ this.label = label;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public bool CancelEdit {
+ get { return cancelEdit; }
+ set { cancelEdit = value; }
+ }
+
+ public int Item {
+ get { return item; }
+ }
+
+ public string Label {
+ get { return label; }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LabelEditEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LabelEditEventHandler.cs
new file mode 100644
index 00000000000..756eebe081f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LabelEditEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+
+
+// COMPLETE
+
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public delegate void LabelEditEventHandler (object sender, LabelEditEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEngine.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEngine.cs
new file mode 100644
index 00000000000..8f58577f9b4
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEngine.cs
@@ -0,0 +1,45 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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:
+// Miguel de Icaza (miguel@gnome.org)
+//
+// (C) 2004 Novell, Inc.
+//
+#if NET_2_0
+using System;
+using System.ComponentModel;
+
+namespace System.Windows.Forms.Layout {
+
+ public abstract class LayoutEngine {
+
+ public virtual void InitLayout (object child, BoundsSpecified specified)
+ {
+ }
+
+ public virtual bool Layout (object container, LayoutEventArgs args)
+ {
+ return false;
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEventArgs.cs
new file mode 100644
index 00000000000..7a81edd1e4f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEventArgs.cs
@@ -0,0 +1,56 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public sealed class LayoutEventArgs : EventArgs {
+ private Control affected_control;
+ private string affected_property;
+
+ #region Public Constructors
+ public LayoutEventArgs(Control affectedControl, string affectedProperty) {
+ this.affected_control = affectedControl;
+ this.affected_property = affectedProperty;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public Control AffectedControl {
+ get {
+ return this.affected_control;
+ }
+ }
+
+ public string AffectedProperty {
+ get {
+ return this.affected_property;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEventHandler.cs
new file mode 100644
index 00000000000..208c9d8d132
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEventHandler.cs
@@ -0,0 +1,32 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void LayoutEventHandler (object sender, LayoutEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutSettings.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutSettings.cs
new file mode 100644
index 00000000000..84c96235535
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutSettings.cs
@@ -0,0 +1,41 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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:
+// Miguel de Icaza (miguel@gnome.org)
+//
+// (C) 2004 Novell, Inc.
+//
+#if NET_2_0
+using System;
+using System.ComponentModel;
+using System.Windows.Forms.Layout;
+
+namespace System.Windows.Forms {
+
+ public abstract class LayoutSettings {
+ public virtual LayoutEngine LayoutEngine {
+ get {
+ return null;
+ }
+ }
+ }
+}
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LeftRightAlignment.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LeftRightAlignment.cs
new file mode 100644
index 00000000000..e775a94a9e7
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LeftRightAlignment.cs
@@ -0,0 +1,37 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public enum LeftRightAlignment {
+ Left = 0,
+ Right = 1
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LibSupport.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LibSupport.cs
new file mode 100644
index 00000000000..4445ca5c5cb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LibSupport.cs
@@ -0,0 +1,56 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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.
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+
+using System.Collections;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+ class LibSupport {
+ static ArrayList list = new ArrayList ();
+
+ public static void Register ()
+ {
+ FindWindowExW fw = new FindWindowExW (FindWindow);
+ list.Add (fw);
+ support_register_delegate ("FindWindowExW", fw);
+ }
+
+ static IntPtr FindWindow (IntPtr hWnd)
+ {
+ NativeWindow nw = NativeWindow.FindWindow (hWnd);
+ if (nw == null)
+ return IntPtr.Zero;
+
+ return nw.Handle;
+ }
+
+ delegate IntPtr FindWindowExW (IntPtr hWnd);
+
+ [DllImport ("MonoSupportW")]
+ extern static void support_register_delegate (string fmt, Delegate d);
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkArea.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkArea.cs
new file mode 100644
index 00000000000..16b69546353
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkArea.cs
@@ -0,0 +1,168 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+//
+// Dennis Hayes, dennish@raytek.com
+// Andreas Nahr, ClassDevelopment@A-SoftTech.com
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+
+
+// COMPLETE
+
+using System.ComponentModel;
+using System.Globalization;
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ [TypeConverter(typeof(LinkArea.LinkAreaConverter))]
+ public struct LinkArea
+ {
+ #region LinkAreaConverter Class
+ public class LinkAreaConverter : TypeConverter {
+ public LinkAreaConverter() {
+ }
+
+ 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;
+ }
+ return base.CanConvertTo(context, destinationType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+ string[] parts;
+ int start;
+ int length;
+
+ if ((value == null) || !(value is String)) {
+ return base.ConvertFrom (context, culture, value);
+ }
+
+ if (culture == null) {
+ culture = CultureInfo.CurrentCulture;
+ }
+
+ parts = ((string)value).Split(culture.TextInfo.ListSeparator.ToCharArray());
+ start = int.Parse(parts[0].Trim());
+ length = int.Parse(parts[1].Trim());
+ return new LinkArea(start, length);
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) {
+ LinkArea l;
+
+ if ((value == null) || !(value is LinkArea) || (destinationType != typeof(string))) {
+ return base.ConvertTo (context, culture, value, destinationType);
+ }
+
+ if (culture == null) {
+ culture = CultureInfo.CurrentCulture;
+ }
+
+ l = (LinkArea)value;
+
+
+ return l.Start.ToString() + culture.TextInfo.ListSeparator + l.Length.ToString();
+ }
+
+ public override object CreateInstance(ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) {
+ return new LinkArea((int)propertyValues["Start"], (int)propertyValues["Length"]);
+ }
+
+ public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) {
+ return true;
+ }
+
+ public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) {
+ return TypeDescriptor.GetProperties(typeof(LinkArea), attributes);
+ }
+
+ public override bool GetPropertiesSupported(ITypeDescriptorContext context) {
+ return true;
+ }
+ }
+ #endregion // LinkAreaConverter Class
+
+ private int start;
+ private int length;
+
+ public LinkArea (int start, int length)
+ {
+ this.start = start;
+ this.length = length;
+ }
+
+ #region Public Properties
+
+ public int Start {
+ get { return start; }
+ set { start = value; }
+ }
+
+ public int Length {
+ get { return length; }
+ set { length = value; }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public bool IsEmpty {
+ get {
+ if (start == 0 && length == 0)
+ return true;
+ else
+ return false;
+
+ }
+ }
+
+ #endregion //Public Properties
+
+ #region Methods
+
+ public override bool Equals (object o)
+ {
+ if (!(o is LinkArea))
+ return false;
+
+ LinkArea comp = (LinkArea) o;
+ return (comp.Start == start && comp.Length == length);
+ }
+
+ public override int GetHashCode ()
+ {
+ return start << 4 | length;
+ }
+
+ #endregion //Methods
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkBehavior.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkBehavior.cs
new file mode 100644
index 00000000000..99ab9c69d8d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkBehavior.cs
@@ -0,0 +1,39 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+ public enum LinkBehavior
+ {
+ SystemDefault = 0,
+ AlwaysUnderline = 1,
+ HoverUnderline = 2,
+ NeverUnderline = 3,
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkClickedEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkClickedEventArgs.cs
new file mode 100644
index 00000000000..9a6efb082c8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkClickedEventArgs.cs
@@ -0,0 +1,48 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+ [ComVisible(true)]
+ public class LinkClickedEventArgs : EventArgs
+ {
+ private string link_text;
+
+ public LinkClickedEventArgs (string link_text)
+ {
+ this.link_text = link_text;
+ }
+
+ public string LinkText
+ {
+ get { return link_text; }
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkClickedEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkClickedEventHandler.cs
new file mode 100644
index 00000000000..c303262d657
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkClickedEventHandler.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public delegate void LinkClickedEventHandler (object sender, LinkClickedEventArgs e);
+}
+
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkLabel.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkLabel.cs
new file mode 100644
index 00000000000..33ae9a1001a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkLabel.cs
@@ -0,0 +1,895 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+// Based on work by:
+// Daniel Carrera, dcarrera@math.toronto.edu (stubbed out)
+// Jaak Simm (jaaksimm@firm.ee) (stubbed out)
+//
+
+// COMPLETE
+
+
+using System.ComponentModel;
+using System.Collections;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+namespace System.Windows.Forms
+{
+ [DefaultEvent("LinkClicked")]
+ public class LinkLabel : Label, IButtonControl
+ {
+ /* Encapsulates a piece of text (regular or link)*/
+ internal class Piece
+ {
+ public string text;
+ public int start;
+ public int end;
+ public LinkLabel.Link link; // Empty link indicates regular text
+ public Rectangle rect;
+ public bool clicked;
+ public bool focused;
+
+ public Piece ()
+ {
+ start = end = 0;
+ link = null;
+ clicked = false;
+ focused = false;
+ }
+ }
+
+ private Color active_link;
+ private Color disabled_link;
+ private Color link_color;
+ private Color visited_color;
+ private LinkArea link_area;
+ private LinkBehavior link_behavior;
+ private LinkCollection link_collection;
+ private bool link_visited;
+ private bool link_click;
+ internal Piece[] pieces;
+ internal int num_pieces;
+ internal Font link_font;
+ private Cursor override_cursor;
+ private DialogResult dialog_result;
+
+ #region Events
+ public event LinkLabelLinkClickedEventHandler LinkClicked;
+ #endregion // Events
+
+ public LinkLabel ()
+ {
+ LinkArea = new LinkArea (0, -1);
+ link_behavior = LinkBehavior.SystemDefault;
+ link_visited = false;
+ link_click = false;
+ pieces = null;
+ num_pieces = 0;
+ link_font = null;
+
+ ActiveLinkColor = Color.Red;
+ DisabledLinkColor = ThemeEngine.Current.ColorGrayText;
+ LinkColor = Color.FromArgb (255, 0, 0, 255);
+ VisitedLinkColor = Color.FromArgb (255, 128, 0, 128);
+ SetStyle (ControlStyles.Selectable, false);
+ SetStyle (ControlStyles.Opaque, true);
+ }
+
+ #region Public Properties
+
+ public Color ActiveLinkColor {
+ get { return active_link;}
+ set {
+ if (active_link == value)
+ return;
+
+ active_link = value;
+ Refresh ();
+ }
+ }
+
+ public Color DisabledLinkColor {
+
+ get { return disabled_link;}
+ set {
+ if (disabled_link == value)
+ return;
+
+ disabled_link = value;
+ Refresh ();
+ }
+ }
+
+ public Color LinkColor {
+ get { return link_color;}
+ set {
+ if (link_color == value)
+ return;
+
+ link_color = value;
+ Refresh ();
+ }
+ }
+
+ public Color VisitedLinkColor {
+ get { return visited_color;}
+ set {
+ if (visited_color == value)
+ return;
+
+ visited_color = value;
+ Refresh ();
+ }
+ }
+
+ [Localizable (true)]
+ [Editor ("System.Windows.Forms.Design.LinkAreaEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
+ public LinkArea LinkArea {
+ get { return link_area;}
+ set {
+
+ if (value.Start <0 || value.Length < -1)
+ throw new ArgumentException ();
+
+ if (!value.IsEmpty)
+ Links.Add (value.Start, value.Length);
+
+ link_area = value;
+ Refresh ();
+ }
+ }
+
+ [DefaultValue (LinkBehavior.SystemDefault)]
+ public LinkBehavior LinkBehavior {
+
+ get { return link_behavior;}
+ set {
+ if (link_behavior == value)
+ return;
+
+ link_behavior = value;
+ Refresh ();
+ }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public LinkLabel.LinkCollection Links {
+ get {
+ if (link_collection == null)
+ link_collection = new LinkCollection (this);
+
+ return link_collection;
+ }
+ }
+
+ [DefaultValue (false)]
+ public bool LinkVisited {
+ get { return link_visited;}
+ set {
+ if (link_visited == value)
+ return;
+
+ link_visited = value;
+ Refresh ();
+ }
+ }
+
+ protected Cursor OverrideCursor {
+ get { return override_cursor;}
+ set { override_cursor = value;}
+ }
+
+ [RefreshProperties(RefreshProperties.Repaint)]
+ public override string Text {
+ get { return base.Text; }
+ set {
+ if (base.Text == value)
+ return;
+
+ base.Text = value;
+ CreateLinkPieces ();
+ }
+ }
+
+ #endregion // Public Properties
+
+ DialogResult IButtonControl.DialogResult {
+ get { return dialog_result; }
+ set { dialog_result = value; }
+ }
+
+
+ void IButtonControl.NotifyDefault (bool value)
+ {
+
+ }
+
+ void IButtonControl.PerformClick ()
+ {
+
+ }
+
+ #region Public Methods
+ protected override AccessibleObject CreateAccessibilityInstance ()
+ {
+ return base.CreateAccessibilityInstance();
+ }
+
+ protected override void CreateHandle ()
+ {
+ base.CreateHandle ();
+ CreateLinkFont ();
+ CreateLinkPieces ();
+ }
+
+ protected override void OnEnabledChanged (EventArgs e)
+ {
+ base.OnEnabledChanged (e);
+ Refresh ();
+ }
+
+ protected override void OnFontChanged (EventArgs e)
+ {
+ base.OnFontChanged (e);
+ CreateLinkFont ();
+ CreateLinkPieces ();
+ }
+
+ protected override void OnGotFocus (EventArgs e)
+ {
+ base.OnGotFocus (e);
+
+ // Set focus to the first enabled link piece
+ for (int i = 0; i < num_pieces; i++) {
+ if (pieces[i].link != null && pieces[i].link.Enabled) {
+ pieces[i].focused = true;
+ Invalidate (pieces[i].rect);
+ break;
+ }
+ }
+ }
+
+ protected override void OnKeyDown (KeyEventArgs e)
+ {
+ base.OnKeyDown(e);
+
+ // Set focus to the next link piece
+ if (e.KeyCode == Keys.Tab || e.KeyCode == Keys.Right) {
+ for (int i = 0; i < num_pieces; i++) {
+ if (pieces[i].focused) {
+ pieces[i].focused = false;
+ Invalidate (pieces[i].rect);
+
+ for (int n = i + 1; n < num_pieces; n++) {
+ if (pieces[n].link != null && pieces[n].link.Enabled) {
+ pieces[n].focused = true;
+ e.Handled = true;
+ Invalidate (pieces[n].rect);
+ return;
+ }
+ }
+ }
+ }
+ } else if (e.KeyCode == Keys.Return) {
+ for (int i = 0; i < num_pieces; i++) {
+ if (pieces[i].focused && pieces[i].link != null) {
+ OnLinkClicked (new LinkLabelLinkClickedEventArgs (pieces[i].link));
+ break;
+ }
+ }
+ }
+ }
+
+ protected virtual void OnLinkClicked (LinkLabelLinkClickedEventArgs e)
+ {
+ if (LinkClicked != null)
+ LinkClicked (this, e);
+ }
+
+ protected override void OnLostFocus (EventArgs e)
+ {
+ base.OnLostFocus (e);
+
+ // Clean focus in link pieces
+ for (int i = 0; i < num_pieces; i++) {
+ if (pieces[i].focused) {
+ pieces[i].focused = false;
+ }
+ }
+
+ Refresh ();
+ }
+
+ protected override void OnMouseDown (MouseEventArgs e)
+ {
+ if (!Enabled) return;
+
+ base.OnMouseDown (e);
+ this.Capture = true;
+
+ for (int i = 0; i < num_pieces; i++) {
+ if (pieces[i].rect.Contains (e.X, e.Y)) {
+ if (pieces[i].link!= null) {
+ pieces[i].clicked = true;
+ Invalidate (pieces[i].rect);
+ }
+ break;
+ }
+ }
+ }
+
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ if (!Enabled) return;
+ base.OnMouseLeave (e);
+ UpdateHover(null);
+ }
+
+ private bool UpdateHover(Link link) {
+ bool changed;
+
+ changed = false;
+ if (link == null) {
+ Cursor = Cursors.Default;
+
+ if (link_behavior == LinkBehavior.HoverUnderline) {
+ for (int i = 0; i < Links.Count; i++) {
+ if (Links[i].Hoovered == true) {
+ changed = true;
+ Links[i].Hoovered = false;
+ }
+ }
+ }
+ } else {
+ if (link_behavior == LinkBehavior.HoverUnderline) {
+ Cursor = Cursors.Hand;
+
+ if (link.Hoovered != true) {
+ link.Hoovered = true;
+ changed = true;
+ }
+ }
+ }
+
+ if (changed == true) {
+ Refresh ();
+ }
+
+
+ return changed;
+ }
+
+ protected override void OnMouseMove (MouseEventArgs e)
+ {
+ base.OnMouseMove (e);
+ UpdateHover(PointInLink (e.X, e.Y));
+ }
+
+ protected override void OnMouseUp (MouseEventArgs e)
+ {
+ if (!Enabled) return;
+
+ base.OnMouseUp (e);
+ this.Capture = false;
+
+ for (int i = 0; i < num_pieces; i++) {
+ if (pieces[i].link!= null && pieces[i].clicked == true) {
+ OnLinkClicked (new LinkLabelLinkClickedEventArgs (pieces[i].link));
+ pieces[i].clicked = false;
+ Invalidate (pieces[i].rect);
+ break;
+ }
+ }
+ }
+
+ protected override void OnPaint (PaintEventArgs pevent)
+ {
+ ThemeEngine.Current.DrawLinkLabel (pevent.Graphics, pevent.ClipRectangle, this);
+ DrawImage (pevent.Graphics, Image, ClientRectangle, image_align);
+ // Do not call base.OnPaint since it's the Label class
+ }
+
+ protected override void OnPaintBackground (PaintEventArgs e)
+ {
+ base.OnPaintBackground (e);
+ }
+
+ protected override void OnTextAlignChanged (EventArgs e)
+ {
+ base.OnTextAlignChanged (e);
+ CreateLinkPieces ();
+ }
+
+ protected override void OnTextChanged (EventArgs e)
+ {
+ base.OnTextChanged (e);
+ }
+
+ protected Link PointInLink (int x, int y)
+ {
+ for (int i = 0; i < num_pieces; i++) {
+ if (pieces[i].rect.Contains (x,y) && pieces[i].link != null)
+ return pieces[i].link;
+ }
+
+ return null;
+ }
+
+ protected override bool ProcessDialogKey (Keys keyData)
+ {
+ return base.ProcessDialogKey (keyData);
+ }
+
+ protected override void Select (bool directed, bool forward)
+ {
+ base.Select (directed, forward);
+ }
+
+ protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified)
+ {
+ base.SetBoundsCore (x, y, width, height, specified);
+ }
+
+ protected override void WndProc (ref Message m)
+ {
+ base.WndProc (ref m);
+ }
+
+ #endregion //Public Methods
+
+ #region Private Methods
+
+ internal void CreateLinkPieces ()
+ {
+ if (Links.Count == 0 || IsHandleCreated == false || Text.Length == 0)
+ return;
+
+ int cur_piece = 0;
+ num_pieces = 0;
+
+ if (Links.Count == 1 && Links[0].Start == 0 && Links[0].Length == -1) {
+ Links[0].Length = Text.Length;
+ }
+
+ pieces = new Piece [(Links.Count * 2) + 1];
+ pieces[cur_piece] = new Piece();
+ pieces[cur_piece].start = 0;
+
+ for (int i = 0; i < Text.Length; i++) { /* Every char on the text*/
+ for (int l = 0; l < Links.Count; l++) { /* Every link that we know of*/
+ if (Links[l].Start == i) {
+ if (i > 0) {
+ /*Push prev. regular text*/
+ pieces[cur_piece].end = i;
+ pieces[cur_piece].text = Text.Substring (pieces[cur_piece].start,
+ pieces[cur_piece].end - pieces[cur_piece].start);
+
+ cur_piece++;
+
+ /* New link*/
+ pieces[cur_piece] = new Piece ();
+ }
+
+ int end;
+
+ if (Links[l].Start + Links[l].Length > Text.Length) {
+ end = Text.Length - Links[l].Start;
+ }
+ else {
+ end = Links[l].Length;
+ }
+
+ pieces[cur_piece].start = Links[l].Start;
+ pieces[cur_piece].end = Links[l].Start + end;
+ pieces[cur_piece].link = Links[l];
+
+ pieces[cur_piece].text = Text.Substring (pieces[cur_piece].start, end);
+
+ cur_piece++; /* Push link*/
+ pieces[cur_piece] = new Piece();
+ i+= Links[l].Length;
+ pieces[cur_piece].start = i;
+ }
+ }
+ }
+
+ if (pieces[cur_piece].end == 0 && pieces[cur_piece].start < Text.Length) {
+ pieces[cur_piece].end = Text.Length;
+ pieces[cur_piece].text = Text.Substring (pieces[cur_piece].start, pieces[cur_piece].end - pieces[cur_piece].start);
+ cur_piece++;
+ }
+
+ num_pieces = cur_piece;
+
+ CharacterRange[] charRanges = new CharacterRange [num_pieces];
+
+ for (int i = 0; i < num_pieces; i++)
+ charRanges[i] = new CharacterRange (pieces[i].start, pieces[i].end - pieces[i].start);
+
+ Region[] charRegions = new Region [num_pieces];
+ string_format.SetMeasurableCharacterRanges (charRanges);
+
+ // BUG: This sizes do not match the ones used later when drawing
+ charRegions = DeviceContext.MeasureCharacterRanges (Text, link_font, ClientRectangle, string_format);
+
+ RectangleF rect;
+ for (int i = 0; i < num_pieces; i++) {
+ rect = charRegions[i].GetBounds (DeviceContext);
+ pieces[i].rect = Rectangle.Ceiling (rect);
+ charRegions[i].Dispose ();
+ }
+
+ if (Visible && IsHandleCreated)
+ Refresh ();
+
+ }
+
+ /* Check if the links overlap */
+ internal void CheckLinks ()
+ {
+ for (int i = 0; i < Links.Count; i++) {
+ for (int l = 0; l < Links.Count; l++) {
+ if (i==l) continue;
+
+ if (((Links[i].Start + Links[i].Length) >= Links[l].Start &&
+ Links[i].Start + Links[i].Length <= Links[l].Start + Links[l].Length) ||
+ (Links[i].Start >= Links[l].Start &&
+ Links[i].Start <= Links[l].Start + Links[l].Length))
+ throw new InvalidOperationException ("Overlapping link regions.");
+ }
+ }
+ }
+
+ internal Font GetPieceFont (Piece piece)
+ {
+ switch (link_behavior) {
+ case LinkBehavior.AlwaysUnderline:
+ case LinkBehavior.SystemDefault: // Depends on IE configuration
+ {
+ if (piece.link == null) {
+ return Font;
+ } else {
+ return link_font;
+ }
+ }
+ case LinkBehavior.HoverUnderline:
+ {
+ if (piece.link != null && piece.link.Hoovered) {
+ return link_font;
+ } else {
+ return Font;
+ }
+ }
+
+ case LinkBehavior.NeverUnderline:
+ default:
+ return Font;
+ }
+
+ }
+
+
+ internal Color GetLinkColor (Piece piece, int i)
+ {
+ Color color;
+
+ if (Enabled == false ||
+ (piece.link != null && piece.link.Enabled == false))
+ color = DisabledLinkColor;
+ else
+ if (piece.clicked == true)
+ color = ActiveLinkColor;
+ else
+ if ((LinkVisited == true && i == 0) ||
+ (piece.link != null && piece.link.Visited == true))
+ color = VisitedLinkColor;
+ else
+ color = LinkColor;
+
+ return color;
+ }
+
+ private void CreateLinkFont ()
+ {
+ if (link_font != null)
+ link_font.Dispose ();
+
+ link_font = new Font (Font.FontFamily, Font.Size, Font.Style | FontStyle.Underline,
+ Font.Unit);
+ }
+
+ #endregion // Private Methods
+
+ //
+ // System.Windows.Forms.LinkLabel.Link
+ //
+ public class Link
+ {
+ private bool enabled;
+ internal int length;
+ private object linkData;
+ private int start;
+ private bool visited;
+ private LinkLabel owner;
+ private bool hoovered;
+
+ internal Link ()
+ {
+ enabled = true;
+ visited = false;
+ length = start = 0;
+ linkData = null;
+ owner = null;
+ }
+
+ internal Link (LinkLabel owner)
+ {
+ enabled = true;
+ visited = false;
+ length = start = 0;
+ linkData = null;
+ this.owner = owner;
+ }
+
+ public bool Enabled {
+ get { return enabled; }
+ set {
+ if (enabled == value)
+ return;
+
+ enabled = value;
+
+ if (owner != null)
+ owner.Refresh ();
+ }
+ }
+
+ public int Length {
+ get {
+ if (length == -1) {
+ return owner.Text.Length;
+ }
+
+ return length;
+ }
+ set {
+ if (length == value)
+ return;
+
+ length = value;
+
+ if (owner != null)
+ owner.CreateLinkPieces ();
+ }
+ }
+
+ public object LinkData {
+ get { return linkData; }
+ set { linkData = value; }
+ }
+
+ public int Start {
+ get { return start; }
+ set {
+ if (start == value)
+ return;
+
+ start = value;
+
+ if (owner != null)
+ owner.CreateLinkPieces ();
+ }
+ }
+
+ public bool Visited {
+ get { return visited; }
+ set {
+ if (visited == value)
+ return;
+
+ visited = value;
+
+ if (owner != null)
+ owner.Refresh ();
+ }
+ }
+
+ internal bool Hoovered {
+ get { return hoovered; }
+ set { hoovered = value; }
+ }
+ }
+
+ //
+ // System.Windows.Forms.LinkLabel.Link
+ //
+ public class LinkCollection : IList, ICollection, IEnumerable
+ {
+ private LinkLabel owner;
+ private ArrayList collection = new ArrayList();
+
+ public LinkCollection (LinkLabel owner)
+ {
+ if (owner==null)
+ throw new ArgumentNullException ();
+
+ this.owner = owner;
+ }
+
+ [Browsable (false)]
+ public int Count {
+ get { return collection.Count; }
+ }
+
+ public bool IsReadOnly {
+ get { return false; }
+ }
+
+ public virtual LinkLabel.Link this[int index] {
+ get {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException();
+
+ return (LinkLabel.Link) collection[index];
+ }
+ set {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException();
+
+ collection[index] = value;
+ }
+ }
+
+ public Link Add (int start, int length)
+ {
+ return Add (start, length, null);
+ }
+
+
+ public Link Add (int start, int length, object o)
+ {
+ Link link = new Link (owner);
+ int idx;
+
+ if (Count == 1 && this[0].Start == 0
+ && this[0].length == -1) {
+ Clear ();
+ }
+
+ link.Length = length;
+ link.Start = start;
+ link.LinkData = o;
+ idx = collection.Add (link);
+
+ owner.CheckLinks ();
+ owner.CreateLinkPieces ();
+ return (Link) collection[idx];
+ }
+
+ public virtual void Clear ()
+ {
+ collection.Clear();
+ owner.CreateLinkPieces ();
+ }
+
+ public bool Contains (LinkLabel.Link link)
+ {
+ return collection.Contains (link);
+ }
+
+ public IEnumerator GetEnumerator ()
+ {
+ return collection.GetEnumerator ();
+ }
+
+ public int IndexOf (LinkLabel.Link link)
+ {
+ return collection.IndexOf (link);
+ }
+
+ public void Remove (LinkLabel.Link value)
+ {
+ collection.Remove (value);
+ owner.CreateLinkPieces ();
+ }
+
+ public void RemoveAt (int index)
+ {
+ if (index >= Count)
+ throw new ArgumentOutOfRangeException ("Invalid value for array index");
+
+ collection.Remove (collection[index]);
+ owner.CreateLinkPieces ();
+ }
+
+ bool IList.IsFixedSize {
+ get {return false;}
+ }
+
+ object IList.this[int index] {
+ get { return collection[index]; }
+ set { collection[index] = value; }
+ }
+
+ object ICollection.SyncRoot {
+ get {return this;}
+ }
+
+ bool ICollection.IsSynchronized {
+ get {return false;}
+ }
+
+ void ICollection.CopyTo (Array dest, int index)
+ {
+ collection.CopyTo (dest, index);
+ }
+
+ int IList.Add (object control)
+ {
+ int idx = collection.Add (control);
+ owner.CheckLinks ();
+ owner.CreateLinkPieces ();
+ return idx;
+ }
+
+ bool IList.Contains (object control)
+ {
+ return collection.Contains (control);
+ }
+
+ int IList.IndexOf (object control)
+ {
+ return collection.IndexOf (control);
+ }
+
+ void IList.Insert (int index, object value)
+ {
+ collection.Insert (index, value);
+ owner.CheckLinks ();
+ owner.CreateLinkPieces ();
+ }
+
+ void IList.Remove (object control)
+ {
+ collection.Remove (control);
+ owner.CreateLinkPieces ();
+ }
+ }
+#if NET_2_0
+
+ public bool UseCompatibleTextRendering {
+ get {
+ return use_compatible_text_rendering;
+ }
+
+ set {
+ use_compatible_text_rendering = value;
+ }
+ }
+#endif
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkLabelLinkClickedEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkLabelLinkClickedEventArgs.cs
new file mode 100644
index 00000000000..0dd50fd8f6c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkLabelLinkClickedEventArgs.cs
@@ -0,0 +1,49 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+
+ [ComVisible(true)]
+ public class LinkLabelLinkClickedEventArgs : EventArgs
+ {
+ private LinkLabel.Link link;
+
+ public LinkLabelLinkClickedEventArgs (LinkLabel.Link link)
+ {
+ this.link = link;
+ }
+
+ public LinkLabel.Link Link{
+ get {return link; }
+ }
+
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkLabelLinkClickedEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkLabelLinkClickedEventHandler.cs
new file mode 100644
index 00000000000..4f09d9d5668
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkLabelLinkClickedEventHandler.cs
@@ -0,0 +1,39 @@
+//
+// System.LinkLabelLinkClickEventHandler.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+// Dennis hayes (dennish@raytek.com)
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public delegate void LinkLabelLinkClickedEventHandler (object sender, LinkLabelLinkClickedEventArgs e);
+
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkState.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkState.cs
new file mode 100644
index 00000000000..0c7ac502704
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkState.cs
@@ -0,0 +1,41 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+
+
+// COMPLETE
+
+
+namespace System.Windows.Forms
+{
+ public enum LinkState
+ {
+ Normal = 0,
+ Hover = 1,
+ Active = 2,
+ Visited = 4
+ }
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListBindingConverter.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListBindingConverter.cs
new file mode 100644
index 00000000000..03e380fd70c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListBindingConverter.cs
@@ -0,0 +1,60 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// NOT COMPLETE
+
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+ public class ListBindingConverter : TypeConverter {
+ #region Public Constructors
+ public ListBindingConverter() {
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Methods
+ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) {
+ if (destinationType == typeof(string)) {
+ return true;
+ }
+ return base.CanConvertTo (context, destinationType);
+ }
+
+ [MonoTODO]
+ public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) {
+ return base.ConvertTo (context, culture, value, destinationType);
+ }
+
+ public override object CreateInstance(ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) {
+ return new Binding((string)propertyValues["PropertyName"], (object)propertyValues["DataSource"], (string)propertyValues["DataMember"]);
+ }
+
+ public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) {
+ return true;
+ }
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListBox.cs
new file mode 100644
index 00000000000..19302e4d9f8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListBox.cs
@@ -0,0 +1,2390 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+
+// COMPLETE
+
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.ComponentModel.Design.Serialization;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+ [DefaultProperty("Items")]
+ [DefaultEvent("SelectedIndexChanged")]
+ [Designer ("System.Windows.Forms.Design.ListBoxDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ public class ListBox : ListControl
+ {
+ public const int DefaultItemHeight = 13;
+ public const int NoMatches = -1;
+
+ internal class ListBoxInfo
+ {
+ internal int item_height; /* Item's height */
+ internal int top_item; /* First item that we show the in the current page */
+ internal int last_item; /* Last visible item */
+ internal int page_size; /* Number of listbox items per page. In MultiColumn listbox indicates items per column */
+ internal Rectangle textdrawing_rect; /* Displayable Client Rectangle minus the scrollbars and with IntegralHeight calculated*/
+ internal bool show_verticalsb; /* Is Vertical scrollbar show it? */
+ internal bool show_horizontalsb; /* Is Horizontal scrollbar show it? */
+ internal Rectangle client_rect; /* Client Rectangle. Usually = ClientRectangle except when IntegralHeight has been applied*/
+ internal int max_itemwidth; /* Maxium item width within the listbox */
+
+ public ListBoxInfo ()
+ {
+ last_item = 0;
+ item_height = 0;
+ top_item = 0;
+ page_size = 0;
+ max_itemwidth = 0;
+ show_verticalsb = false;
+ show_horizontalsb = false;
+ }
+ }
+
+ internal class ListBoxItem
+ {
+ internal int Index;
+ internal bool Selected;
+ internal int ItemHeight; /* Only used for OwnerDrawVariable */
+ internal CheckState State;
+
+ public ListBoxItem (int index)
+ {
+ Index = index;
+ Selected = false;
+ ItemHeight = -1;
+ State = CheckState.Unchecked;
+ }
+
+ public void CopyState (ListBoxItem src)
+ {
+ Selected = src.Selected;
+ ItemHeight = src.ItemHeight;
+ State = src.State;
+ }
+ }
+
+ internal enum ItemNavigation
+ {
+ First,
+ Last,
+ Next,
+ Previous,
+ NextPage,
+ PreviousPage,
+ PreviousColumn,
+ NextColumn
+ }
+
+ internal enum UpdateOperation
+ {
+ AddItems,
+ DeleteItems,
+ AllItems
+ }
+
+ private int column_width;
+ private DrawMode draw_mode;
+ private int horizontal_extent;
+ private bool horizontal_scrollbar;
+ private bool integral_height;
+ private bool multicolumn;
+ private bool scroll_always_visible;
+ private int selected_index;
+ private SelectedIndexCollection selected_indices;
+ private SelectedObjectCollection selected_items;
+ private SelectionMode selection_mode;
+ private bool sorted;
+ private bool use_tabstops;
+ private int column_width_internal;
+ private ImplicitVScrollBar vscrollbar_ctrl;
+ private ImplicitHScrollBar hscrollbar_ctrl;
+ private bool suspend_ctrlupdate;
+ private bool ctrl_pressed;
+ private bool shift_pressed;
+ private bool has_focus;
+ private bool use_item_height;
+
+ internal int focused_item;
+ internal ListBoxInfo listbox_info;
+ internal ObjectCollection items;
+
+ public ListBox ()
+ {
+ border_style = BorderStyle.Fixed3D;
+ draw_mode = DrawMode.Normal;
+ horizontal_extent = 0;
+ horizontal_scrollbar = false;
+ integral_height = true;
+ multicolumn = false;
+ scroll_always_visible = false;
+ selected_index = -1;
+ focused_item = -1;
+ selection_mode = SelectionMode.One;
+ sorted = false;
+ use_tabstops = true;
+ BackColor = ThemeEngine.Current.ColorWindow;
+ ColumnWidth = 0;
+ suspend_ctrlupdate = false;
+ ctrl_pressed = false;
+ shift_pressed = false;
+ has_focus = false;
+ use_item_height = false;
+
+ items = new ObjectCollection (this);
+ selected_indices = new SelectedIndexCollection (this);
+ selected_items = new SelectedObjectCollection (this);
+ listbox_info = new ListBoxInfo ();
+ listbox_info.item_height = FontHeight;
+
+ /* Vertical scrollbar */
+ vscrollbar_ctrl = new ImplicitVScrollBar ();
+ vscrollbar_ctrl.Minimum = 0;
+ vscrollbar_ctrl.SmallChange = 1;
+ vscrollbar_ctrl.LargeChange = 1;
+ vscrollbar_ctrl.Maximum = 0;
+ vscrollbar_ctrl.ValueChanged += new EventHandler (VerticalScrollEvent);
+ vscrollbar_ctrl.Visible = false;
+
+ /* Horizontal scrollbar */
+ hscrollbar_ctrl = new ImplicitHScrollBar ();
+ hscrollbar_ctrl.Minimum = 0;
+ hscrollbar_ctrl.SmallChange = 1;
+ hscrollbar_ctrl.LargeChange = 1;
+ hscrollbar_ctrl.Maximum = 0;
+ hscrollbar_ctrl.Visible = false;
+ hscrollbar_ctrl.ValueChanged += new EventHandler (HorizontalScrollEvent);
+
+ /* Events */
+ MouseDown += new MouseEventHandler (OnMouseDownLB);
+ KeyDown += new KeyEventHandler (OnKeyDownLB);
+ KeyUp += new KeyEventHandler (OnKeyUpLB);
+ GotFocus += new EventHandler (OnGotFocus);
+ LostFocus += new EventHandler (OnLostFocus);
+
+ SetStyle (ControlStyles.UserPaint, false);
+ }
+
+ #region Events
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler BackgroundImageChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ public new event EventHandler Click;
+
+ public event DrawItemEventHandler DrawItem;
+ public event MeasureItemEventHandler MeasureItem;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event PaintEventHandler Paint;
+
+ public event EventHandler SelectedIndexChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ public new event EventHandler TextChanged;
+ #endregion // Events
+
+ #region Public Properties
+ public override Color BackColor {
+ get { return base.BackColor; }
+ set {
+ if (base.BackColor == value)
+ return;
+
+ base.BackColor = value;
+ base.Refresh (); // Careful. Calling the base method is not the same that calling
+ } // the overriden one that refresh also all the items
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override Image BackgroundImage {
+ get { return base.BackgroundImage; }
+ set {
+ if (base.BackgroundImage == value)
+ return;
+
+ base.BackgroundImage = value;
+
+ if (BackgroundImageChanged != null)
+ BackgroundImageChanged (this, EventArgs.Empty);
+
+ base.Refresh ();
+ }
+ }
+
+ [DefaultValue (BorderStyle.Fixed3D)]
+ [DispId(-504)]
+ public BorderStyle BorderStyle {
+ get { return InternalBorderStyle; }
+ set { InternalBorderStyle = value; }
+ }
+
+ [DefaultValue (0)]
+ [Localizable (true)]
+ public int ColumnWidth {
+ get { return column_width; }
+ set {
+ if (value < 0)
+ throw new ArgumentException ("A value less than zero is assigned to the property.");
+
+ column_width = value;
+
+ if (value == 0)
+ ColumnWidthInternal = 120;
+ else
+ ColumnWidthInternal = value;
+
+ base.Refresh ();
+ }
+ }
+
+ protected override CreateParams CreateParams {
+ get { return base.CreateParams;}
+ }
+
+ protected override Size DefaultSize {
+ get { return new Size (120, 96); }
+ }
+
+ [RefreshProperties(RefreshProperties.Repaint)]
+ [DefaultValue (DrawMode.Normal)]
+ public virtual DrawMode DrawMode {
+ get { return draw_mode; }
+
+ set {
+ if (!Enum.IsDefined (typeof (DrawMode), value))
+ throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for DrawMode", value));
+
+ if (value == DrawMode.OwnerDrawVariable && multicolumn == true)
+ throw new ArgumentException ("Cannot have variable height and multicolumn");
+
+ if (draw_mode == value)
+ return;
+
+ draw_mode = value;
+ base.Refresh ();
+ }
+ }
+
+ public override Color ForeColor {
+ get { return base.ForeColor; }
+ set {
+
+ if (base.ForeColor == value)
+ return;
+
+ base.ForeColor = value;
+ base.Refresh ();
+ }
+ }
+
+ [DefaultValue (0)]
+ [Localizable (true)]
+ public int HorizontalExtent {
+ get { return horizontal_extent; }
+ set {
+ if (horizontal_extent == value)
+ return;
+
+ horizontal_extent = value;
+ base.Refresh ();
+ }
+ }
+
+ [DefaultValue (false)]
+ [Localizable (true)]
+ public bool HorizontalScrollbar {
+ get { return horizontal_scrollbar; }
+ set {
+ if (horizontal_scrollbar == value)
+ return;
+
+ horizontal_scrollbar = value;
+ UpdateShowHorizontalScrollBar ();
+ base.Refresh ();
+ }
+ }
+
+ [DefaultValue (true)]
+ [Localizable (true)]
+ [RefreshProperties(RefreshProperties.Repaint)]
+ public bool IntegralHeight {
+ get { return integral_height; }
+ set {
+ if (integral_height == value)
+ return;
+
+ integral_height = value;
+ CalcClientArea ();
+ }
+ }
+
+ [DefaultValue (13)]
+ [Localizable (true)]
+ [RefreshProperties(RefreshProperties.Repaint)]
+ public virtual int ItemHeight {
+ get {
+ if (draw_mode == DrawMode.Normal)
+ return FontHeight;
+ return listbox_info.item_height;
+ }
+ set {
+ if (value > 255)
+ throw new ArgumentOutOfRangeException ("The ItemHeight property was set beyond 255 pixels");
+
+ if (listbox_info.item_height == value)
+ return;
+
+ listbox_info.item_height = value;
+ use_item_height = true;
+ CalcClientArea ();
+ }
+ }
+
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
+ [Localizable (true)]
+ [Editor ("System.Windows.Forms.Design.ListControlStringCollectionEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
+ public ObjectCollection Items {
+ get { return items; }
+ }
+
+ [DefaultValue (false)]
+ public bool MultiColumn {
+ get { return multicolumn; }
+ set {
+ if (multicolumn == value)
+ return;
+
+ if (value == true && DrawMode == DrawMode.OwnerDrawVariable)
+ throw new ArgumentException ("A multicolumn ListBox cannot have a variable-sized height.");
+
+ multicolumn = value;
+
+ if (IsHandleCreated) {
+ RellocateScrollBars ();
+ CalcClientArea ();
+ UpdateItemInfo (UpdateOperation.AllItems, 0, 0);
+ }
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ public int PreferredHeight {
+ get {
+ int itemsHeight = 0;
+ if (draw_mode == DrawMode.Normal)
+ itemsHeight = FontHeight * items.Count;
+ else if (draw_mode == DrawMode.OwnerDrawFixed)
+ itemsHeight = ItemHeight * items.Count;
+ else if (draw_mode == DrawMode.OwnerDrawVariable) {
+ for (int i = 0; i < items.Count; i++)
+ itemsHeight += items.GetListBoxItem (i).ItemHeight;
+ }
+
+ return itemsHeight;
+ }
+ }
+
+ public override RightToLeft RightToLeft {
+ get { return base.RightToLeft; }
+ set {
+ base.RightToLeft = value;
+ base.Refresh ();
+ }
+ }
+
+ // Only affects the Vertical ScrollBar
+ [DefaultValue (false)]
+ [Localizable (true)]
+ public bool ScrollAlwaysVisible {
+ get { return scroll_always_visible; }
+ set {
+ if (scroll_always_visible == value)
+ return;
+
+ scroll_always_visible = value;
+ UpdateShowVerticalScrollBar ();
+ UpdateShowHorizontalScrollBar ();
+ }
+ }
+
+ [Bindable(true)]
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public override int SelectedIndex {
+ get { return selected_index;}
+ set {
+ if (value < -1 || value >= Items.Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ if (SelectionMode == SelectionMode.None)
+ throw new ArgumentException ("cannot call this method if SelectionMode is SelectionMode.None");
+
+ if (selected_index == value)
+ return;
+
+ if (SelectionMode == SelectionMode.One)
+ UnSelectItem (selected_index, true);
+
+ SelectItem (value);
+ selected_index = value;
+ focused_item = value;
+ OnSelectedIndexChanged (new EventArgs ());
+ OnSelectedValueChanged (new EventArgs ());
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public SelectedIndexCollection SelectedIndices {
+ get { return selected_indices; }
+ }
+
+ [Bindable(true)]
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public object SelectedItem {
+ get {
+ if (SelectedItems.Count > 0)
+ return SelectedItems[0];
+ else
+ return null;
+ }
+ set {
+
+ int index = Items.IndexOf (value);
+
+ if (index == -1)
+ return;
+
+ if (index != SelectedIndex) {
+ SelectedIndex = index;
+ }
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public SelectedObjectCollection SelectedItems {
+ get {return selected_items;}
+ }
+
+ [DefaultValue (SelectionMode.One)]
+ public virtual SelectionMode SelectionMode {
+ get { return selection_mode; }
+ set {
+ if (!Enum.IsDefined (typeof (SelectionMode), value))
+ throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for SelectionMode", value));
+
+ if (selection_mode == value)
+ return;
+
+ selection_mode = value;
+
+ if (SelectedItems.Count > 0) {
+ switch (selection_mode) {
+ case SelectionMode.None:
+ ClearSelected ();
+ break;
+ case SelectionMode.One: {
+ if (SelectedItems.Count > 1) { // All except one
+ int cnt = selected_indices.Count - 1;
+ for (int i = 0; i < cnt; i++) {
+ UnSelectItem (i, true);
+ }
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ [DefaultValue (false)]
+ public bool Sorted {
+ get { return sorted; }
+
+ set {
+ if (sorted == value)
+ return;
+
+ sorted = value;
+ Sort ();
+ }
+ }
+
+ [Bindable (false)]
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ public override string Text {
+ get {
+ if (SelectionMode != SelectionMode.None && SelectedIndex != -1)
+ return GetItemText (SelectedItem);
+
+ return base.Text;
+ }
+ set {
+
+ base.Text = value;
+
+ if (SelectionMode == SelectionMode.None)
+ return;
+
+ int index;
+
+ index = FindStringExact (value);
+
+ if (index == -1)
+ return;
+
+ SelectedIndex = index;
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public int TopIndex {
+ get { return LBoxInfo.top_item; }
+ set {
+ if (value == LBoxInfo.top_item)
+ return;
+
+ if (value < 0 || value >= Items.Count)
+ return;
+
+ LBoxInfo.top_item = value;
+ UpdatedTopItem ();
+ base.Refresh ();
+ }
+ }
+
+ [DefaultValue (true)]
+ public bool UseTabStops {
+ get { return use_tabstops; }
+
+ set {
+ if (use_tabstops == value)
+ return;
+
+ use_tabstops = value;
+ base.Refresh ();
+ }
+ }
+
+ #endregion Public Properties
+
+ #region Private Properties
+
+ internal ListBoxInfo LBoxInfo {
+ get { return listbox_info; }
+ }
+
+ private int ColumnWidthInternal {
+ get { return column_width_internal; }
+ set { column_width_internal = value; }
+ }
+
+ #endregion Private Properties
+
+ #region Public Methods
+ protected virtual void AddItemsCore (object[] value)
+ {
+ Items.AddRange (value);
+ }
+
+ public void BeginUpdate ()
+ {
+ suspend_ctrlupdate = true;
+ }
+
+ public void ClearSelected ()
+ {
+ foreach (int i in selected_indices) {
+ UnSelectItem (i, false);
+ }
+
+ selected_indices.ClearIndices ();
+ selected_items.ClearObjects ();
+ }
+
+ protected virtual ObjectCollection CreateItemCollection ()
+ {
+ return new ObjectCollection (this);
+ }
+
+ public void EndUpdate ()
+ {
+ suspend_ctrlupdate = false;
+ UpdateItemInfo (UpdateOperation.AllItems, 0, 0);
+ base.Refresh ();
+ }
+
+ public int FindString (String s)
+ {
+ return FindString (s, -1);
+ }
+
+ public int FindString (string s, int startIndex)
+ {
+ if (Items.Count == 0)
+ return -1; // No exception throwing if empty
+
+ if (startIndex < -1 || startIndex >= Items.Count - 1)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ startIndex++;
+ for (int i = startIndex; i < Items.Count; i++) {
+ if ((GetItemText (Items[i])).StartsWith (s))
+ return i;
+ }
+
+ return NoMatches;
+ }
+
+ public int FindStringExact (string s)
+ {
+ return FindStringExact (s, -1);
+ }
+
+ public int FindStringExact (string s, int startIndex)
+ {
+ if (Items.Count == 0)
+ return -1; // No exception throwing if empty
+
+ if (startIndex < -1 || startIndex >= Items.Count - 1)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ startIndex++;
+ for (int i = startIndex; i < Items.Count; i++) {
+ if ((GetItemText (Items[i])).Equals (s))
+ return i;
+ }
+
+ return NoMatches;
+ }
+
+ public int GetItemHeight (int index)
+ {
+ if (index < 0 || index >= Items.Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ if (DrawMode == DrawMode.OwnerDrawVariable && IsHandleCreated == true) {
+
+ if ((Items.GetListBoxItem (index)).ItemHeight != -1) {
+ return (Items.GetListBoxItem (index)).ItemHeight;
+ }
+
+ MeasureItemEventArgs args = new MeasureItemEventArgs (DeviceContext, index, ItemHeight);
+ OnMeasureItem (args);
+ (Items.GetListBoxItem (index)).ItemHeight = args.ItemHeight;
+ return args.ItemHeight;
+ }
+
+ return ItemHeight;
+ }
+
+ public Rectangle GetItemRectangle (int index)
+ {
+ if (index < 0 || index >= Items.Count)
+ throw new ArgumentOutOfRangeException ("GetItemRectangle index out of range.");
+
+ Rectangle rect = new Rectangle ();
+
+ if (MultiColumn == false) {
+
+ rect.X = 0;
+ rect.Height = GetItemHeight (index);
+ rect.Width = listbox_info.textdrawing_rect.Width;
+
+ if (DrawMode == DrawMode.OwnerDrawVariable) {
+ rect.Y = 0;
+ if (index >= listbox_info.top_item) {
+ for (int i = listbox_info.top_item; i < index; i++) {
+ rect.Y += GetItemHeight (i);
+ }
+ } else {
+ for (int i = index; i < listbox_info.top_item; i++) {
+ rect.Y -= GetItemHeight (i);
+ }
+ }
+ } else {
+ rect.Y = ItemHeight * (index - listbox_info.top_item);
+ }
+ }
+ else {
+ int which_page;
+
+ which_page = index / listbox_info.page_size;
+ rect.Y = ((index - listbox_info.top_item) % listbox_info.page_size) * ItemHeight;
+ rect.X = which_page * ColumnWidthInternal;
+ rect.Height = ItemHeight;
+ rect.Width = ColumnWidthInternal;
+ }
+
+ return rect;
+ }
+
+ public bool GetSelected (int index)
+ {
+ if (index < 0 || index >= Items.Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ return (Items.GetListBoxItem (index)).Selected;
+ }
+
+ public int IndexFromPoint (Point p)
+ {
+ return IndexFromPoint (p.X, p.Y);
+ }
+
+ // Only returns visible points
+ public int IndexFromPoint (int x, int y)
+ {
+
+ if (Items.Count == 0) {
+ return -1;
+ }
+
+ for (int i = LBoxInfo.top_item; i <= LBoxInfo.last_item; i++) {
+ if (GetItemRectangle (i).Contains (x,y) == true)
+ return i;
+ }
+
+ return -1;
+ }
+
+ protected override void OnChangeUICues (UICuesEventArgs e)
+ {
+ base.OnChangeUICues (e);
+ }
+
+ protected override void OnDataSourceChanged (EventArgs e)
+ {
+ base.OnDataSourceChanged (e);
+ BindDataItems (items);
+
+ if (DataSource == null || DataManager == null) {
+ SelectedIndex = -1;
+ }
+ else {
+ SelectedIndex = DataManager.Position;
+ }
+ }
+
+ protected override void OnDisplayMemberChanged (EventArgs e)
+ {
+ base.OnDisplayMemberChanged (e);
+
+ if (DataManager == null || !IsHandleCreated)
+ return;
+
+ BindDataItems (items);
+ base.Refresh ();
+ }
+
+ protected virtual void OnDrawItem (DrawItemEventArgs e)
+ {
+
+ if (DrawItem != null && (DrawMode == DrawMode.OwnerDrawFixed || DrawMode == DrawMode.OwnerDrawVariable)) {
+ DrawItem (this, e);
+ return;
+ }
+
+ ThemeEngine.Current.DrawListBoxItem (this, e);
+ }
+
+ protected override void OnFontChanged (EventArgs e)
+ {
+ base.OnFontChanged (e);
+ if (!use_item_height) {
+ listbox_info.item_height = FontHeight;
+ RellocateScrollBars ();
+ CalcClientArea ();
+ UpdateItemInfo (UpdateOperation.AllItems, 0, 0);
+ } else {
+ base.Refresh ();
+ }
+ }
+
+ protected override void OnHandleCreated (EventArgs e)
+ {
+ base.OnHandleCreated (e);
+
+ UpdateInternalClientRect (ClientRectangle);
+ SuspendLayout ();
+ Controls.AddImplicit (vscrollbar_ctrl);
+ Controls.AddImplicit (hscrollbar_ctrl);
+ ResumeLayout ();
+ UpdateItemInfo (UpdateOperation.AllItems, 0, 0);
+ }
+
+ protected override void OnHandleDestroyed (EventArgs e)
+ {
+ base.OnHandleDestroyed (e);
+ }
+
+ protected virtual void OnMeasureItem (MeasureItemEventArgs e)
+ {
+ if (draw_mode != DrawMode.OwnerDrawVariable)
+ return;
+
+ if (MeasureItem != null)
+ MeasureItem (this, e);
+ }
+
+ protected override void OnParentChanged (EventArgs e)
+ {
+ base.OnParentChanged (e);
+ }
+
+ protected override void OnResize (EventArgs e)
+ {
+ base.OnResize (e);
+ UpdateInternalClientRect (ClientRectangle);
+ }
+
+ protected override void OnSelectedIndexChanged (EventArgs e)
+ {
+ base.OnSelectedIndexChanged (e);
+
+ if (SelectedIndexChanged != null)
+ SelectedIndexChanged (this, e);
+ }
+
+ protected override void OnSelectedValueChanged (EventArgs e)
+ {
+ base.OnSelectedValueChanged (e);
+ }
+
+ public override void Refresh ()
+ {
+ if (draw_mode == DrawMode.OwnerDrawVariable) {
+ for (int i = 0; i < Items.Count; i++) {
+ (Items.GetListBoxItem (i)).ItemHeight = -1;
+ }
+ }
+
+ base.Refresh ();
+ }
+
+ protected override void RefreshItem (int index)
+ {
+ if (index < 0 || index >= Items.Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ if (draw_mode == DrawMode.OwnerDrawVariable) {
+ (Items.GetListBoxItem (index)).ItemHeight = -1;
+ }
+ }
+
+ protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified)
+ {
+ base.SetBoundsCore (x, y, width, height, specified);
+ }
+
+ protected override void SetItemCore (int index, object value)
+ {
+ if (index < 0 || index >= Items.Count)
+ return;
+
+ Items[index] = value;
+ }
+
+ protected override void SetItemsCore (IList value)
+ {
+ BeginUpdate ();
+ try {
+ Items.Clear ();
+ Items.AddRange (value);
+ } finally {
+ EndUpdate ();
+ }
+ }
+
+ public void SetSelected (int index, bool value)
+ {
+ if (index < 0 || index >= Items.Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ if (SelectionMode == SelectionMode.None)
+ throw new InvalidOperationException ();
+
+ if (value)
+ SelectItem (index);
+ else
+ UnSelectItem (index, true);
+ }
+
+ protected virtual void Sort ()
+ {
+ if (Items.Count == 0)
+ return;
+
+ Items.Sort ();
+ base.Refresh ();
+ }
+
+ public override string ToString ()
+ {
+ return base.ToString () + ", Items Count: " + Items.Count;
+ }
+
+ protected virtual void WmReflectCommand (ref Message m)
+ {
+
+ }
+
+ protected override void WndProc (ref Message m)
+ {
+ switch ((Msg) m.Msg) {
+
+ case Msg.WM_PAINT: {
+ PaintEventArgs paint_event;
+ paint_event = XplatUI.PaintEventStart (Handle, true);
+ OnPaintLB (paint_event);
+ XplatUI.PaintEventEnd (Handle, true);
+ return;
+ }
+
+ case Msg.WM_ERASEBKGND:
+ m.Result = (IntPtr) 1;
+ return;
+
+ default:
+ break;
+ }
+
+ base.WndProc (ref m);
+ }
+
+ #endregion Public Methods
+
+ #region Private Methods
+
+ internal void CalcClientArea ()
+ {
+ listbox_info.textdrawing_rect = listbox_info.client_rect;
+
+ if (listbox_info.show_verticalsb)
+ listbox_info.textdrawing_rect.Width -= vscrollbar_ctrl.Width;
+
+ if (listbox_info.show_horizontalsb)
+ listbox_info.textdrawing_rect.Height -= hscrollbar_ctrl.Height;
+
+ if (DrawMode == DrawMode.OwnerDrawVariable) {
+ int height = 0;
+
+ listbox_info.page_size = 0;
+ for (int i = 0; i < Items.Count; i++) {
+ height += GetItemHeight (i);
+ if (height > listbox_info.textdrawing_rect.Height)
+ break;
+
+ listbox_info.page_size++;
+ }
+
+ } else {
+ listbox_info.page_size = listbox_info.textdrawing_rect.Height / ItemHeight;
+ }
+
+ if (listbox_info.page_size == 0) {
+ listbox_info.page_size = 1;
+ }
+
+ /* Adjust size to visible the maximum number of displayable items */
+ if (IntegralHeight == true) {
+
+ // From MS Docs: The integral height is based on the height of the ListBox, rather than
+ // the client area height. As a result, when the IntegralHeight property is set true,
+ // items can still be partially shown if scroll bars are displayed.
+
+ int remaining = listbox_info.client_rect.Height % listbox_info.item_height;
+
+ if (remaining > 0) {
+ listbox_info.client_rect.Height -= remaining;
+ CalcClientArea ();
+ RellocateScrollBars ();
+ base.Refresh ();
+ }
+ }
+ }
+
+ internal void Draw (Rectangle clip, Graphics dc)
+ {
+ // IntegralHeight has effect, we also have to paint the unused area
+ if (IntegralHeight) {
+ if (ClientRectangle.Height > listbox_info.client_rect.Height) {
+ Region area = new Region (ClientRectangle);
+ area.Exclude (LBoxInfo.textdrawing_rect);
+
+ if (listbox_info.show_horizontalsb) {
+ area.Exclude (new Rectangle (hscrollbar_ctrl.Location.X, hscrollbar_ctrl.Location.Y,
+ hscrollbar_ctrl.Width, hscrollbar_ctrl.Height));
+ }
+
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (BackColor),
+ area.GetBounds (dc));
+
+ area.Dispose ();
+ }
+ }
+
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (BackColor),
+ LBoxInfo.textdrawing_rect);
+
+ if (Items.Count > 0) {
+ Rectangle item_rect;
+ DrawItemState state = DrawItemState.None;
+
+ for (int i = LBoxInfo.top_item; i <= LBoxInfo.last_item; i++) {
+ item_rect = GetItemDisplayRectangle (i, LBoxInfo.top_item);
+
+ if (clip.IntersectsWith (item_rect) == false)
+ continue;
+
+ /* Draw item */
+ state = DrawItemState.None;
+
+ if ((Items.GetListBoxItem (i)).Selected) {
+ state |= DrawItemState.Selected;
+ }
+
+ if (has_focus == true && focused_item == i)
+ state |= DrawItemState.Focus;
+
+ if (MultiColumn == false && hscrollbar_ctrl != null && hscrollbar_ctrl.Visible) {
+ item_rect.X -= hscrollbar_ctrl.Value;
+ item_rect.Width += hscrollbar_ctrl.Value;
+ }
+
+ OnDrawItem (new DrawItemEventArgs (dc, Font, item_rect,
+ i, state, ForeColor, BackColor));
+ }
+ }
+
+ }
+
+ // Converts a GetItemRectangle to a one that we can display
+ internal Rectangle GetItemDisplayRectangle (int index, int first_displayble)
+ {
+ Rectangle item_rect;
+ Rectangle first_item_rect = GetItemRectangle (first_displayble);
+ item_rect = GetItemRectangle (index);
+ item_rect.X -= first_item_rect.X;
+ item_rect.Y -= first_item_rect.Y;
+
+ return item_rect;
+ }
+
+ // Value Changed
+ private void HorizontalScrollEvent (object sender, EventArgs e)
+ {
+ if (!multicolumn) {
+ base.Refresh ();
+ return;
+ }
+
+ int top_item = LBoxInfo.top_item;
+ int last_item = LBoxInfo.last_item;
+
+ LBoxInfo.top_item = listbox_info.page_size * hscrollbar_ctrl.Value;
+ LBoxInfo.last_item = LastVisibleItem ();
+
+ if (top_item != LBoxInfo.top_item || last_item != LBoxInfo.last_item)
+ base.Refresh ();
+ }
+
+ // Only returns visible points. The diference of with IndexFromPoint is that the rectangle
+ // has screen coordinates
+ internal int IndexFromPointDisplayRectangle (int x, int y)
+ {
+ if (Items.Count == 0)
+ return -1;
+
+ for (int i = LBoxInfo.top_item; i <= LBoxInfo.last_item; i++) {
+ if (GetItemDisplayRectangle (i, LBoxInfo.top_item).Contains (x, y) == true)
+ return i;
+ }
+
+ return -1;
+ }
+
+ private int LastVisibleItem ()
+ {
+ Rectangle item_rect;
+ int top_y = LBoxInfo.textdrawing_rect.Y + LBoxInfo.textdrawing_rect.Height;
+ int i = 0;
+
+ if (LBoxInfo.top_item >= Items.Count)
+ return LBoxInfo.top_item;
+
+ for (i = LBoxInfo.top_item; i < Items.Count; i++) {
+
+ item_rect = GetItemDisplayRectangle (i, LBoxInfo.top_item);
+ if (MultiColumn) {
+
+ if (item_rect.X > LBoxInfo.textdrawing_rect.Width)
+ return i - 1;
+ }
+ else {
+ if (item_rect.Y + item_rect.Height > top_y) {
+ return i;
+ }
+ }
+ }
+ return i - 1;
+ }
+
+ private void UpdatedTopItem ()
+ {
+ if (multicolumn) {
+ int col = LBoxInfo.top_item / LBoxInfo.page_size;
+
+ if (col > hscrollbar_ctrl.Maximum)
+ hscrollbar_ctrl.Value = hscrollbar_ctrl.Maximum;
+ else
+ hscrollbar_ctrl.Value = col;
+ }
+ else {
+ if (LBoxInfo.top_item > vscrollbar_ctrl.Maximum)
+ vscrollbar_ctrl.Value = vscrollbar_ctrl.Maximum;
+ else
+ vscrollbar_ctrl.Value = LBoxInfo.top_item;
+ }
+ }
+
+ // Navigates to the indicated item and returns the new item
+ private int NavigateItemVisually (ItemNavigation navigation)
+ {
+ int page_size, columns, selected_index = -1;
+
+ if (multicolumn) {
+ columns = LBoxInfo.textdrawing_rect.Width / ColumnWidthInternal;
+ page_size = columns * LBoxInfo.page_size;
+ if (page_size == 0) {
+ page_size = LBoxInfo.page_size;
+ }
+ } else {
+ page_size = LBoxInfo.page_size;
+ }
+
+ switch (navigation) {
+
+ case ItemNavigation.PreviousColumn: {
+ if (focused_item - LBoxInfo.page_size < 0) {
+ return -1;
+ }
+
+ if (focused_item - LBoxInfo.page_size < LBoxInfo.top_item) {
+ LBoxInfo.top_item = focused_item - LBoxInfo.page_size;
+ UpdatedTopItem ();
+ }
+
+ selected_index = focused_item - LBoxInfo.page_size;
+ break;
+ }
+
+ case ItemNavigation.NextColumn: {
+ if (focused_item + LBoxInfo.page_size >= Items.Count) {
+ break;
+ }
+
+ if (focused_item + LBoxInfo.page_size > LBoxInfo.last_item) {
+ LBoxInfo.top_item = focused_item;
+ UpdatedTopItem ();
+ }
+
+ selected_index = focused_item + LBoxInfo.page_size;
+ break;
+ }
+
+ case ItemNavigation.First: {
+ LBoxInfo.top_item = 0;
+ selected_index = 0;
+ UpdatedTopItem ();
+ break;
+ }
+
+ case ItemNavigation.Last: {
+
+ if (Items.Count < LBoxInfo.page_size) {
+ LBoxInfo.top_item = 0;
+ selected_index = Items.Count - 1;
+ UpdatedTopItem ();
+ } else {
+ LBoxInfo.top_item = Items.Count - LBoxInfo.page_size;
+ selected_index = Items.Count - 1;
+ UpdatedTopItem ();
+ }
+ break;
+ }
+
+ case ItemNavigation.Next: {
+ if (focused_item + 1 < Items.Count) {
+ int actualHeight = 0;
+ if (draw_mode == DrawMode.OwnerDrawVariable) {
+ for (int i = LBoxInfo.top_item; i <= focused_item + 1; i++)
+ actualHeight += GetItemHeight (i);
+ } else {
+ actualHeight = ((focused_item + 1) - LBoxInfo.top_item + 1) * ItemHeight;
+ }
+ if (actualHeight >= LBoxInfo.textdrawing_rect.Height) {
+ int bal = IntegralHeight ? 0 : (listbox_info.textdrawing_rect.Height == actualHeight ? 0 : 1);
+ if (focused_item + bal >= LBoxInfo.last_item) {
+ LBoxInfo.top_item++;
+ UpdatedTopItem ();
+ }
+ }
+ selected_index = focused_item + 1;
+ }
+ break;
+ }
+
+ case ItemNavigation.Previous: {
+ if (focused_item > 0) {
+ if (focused_item - 1 < LBoxInfo.top_item) {
+ LBoxInfo.top_item--;
+ UpdatedTopItem ();
+ }
+ selected_index = focused_item - 1;
+ }
+ break;
+ }
+
+ case ItemNavigation.NextPage: {
+ if (Items.Count < page_size) {
+ NavigateItemVisually (ItemNavigation.Last);
+ break;
+ }
+
+ if (focused_item + page_size - 1 >= Items.Count) {
+ LBoxInfo.top_item = Items.Count - page_size;
+ UpdatedTopItem ();
+ selected_index = Items.Count - 1;
+ }
+ else {
+ if (focused_item + page_size - 1 > LBoxInfo.last_item) {
+ LBoxInfo.top_item = focused_item;
+ UpdatedTopItem ();
+ }
+
+ selected_index = focused_item + page_size - 1;
+ }
+
+ break;
+ }
+
+ case ItemNavigation.PreviousPage: {
+
+ if (focused_item - (LBoxInfo.page_size - 1) <= 0) {
+
+ LBoxInfo.top_item = 0;
+ UpdatedTopItem ();
+ SelectedIndex = 0;
+ }
+ else {
+ if (focused_item - (LBoxInfo.page_size - 1) < LBoxInfo.top_item) {
+ LBoxInfo.top_item = focused_item - (LBoxInfo.page_size - 1);
+ UpdatedTopItem ();
+ }
+
+ selected_index = focused_item - (LBoxInfo.page_size - 1);
+ }
+
+ break;
+ }
+ default:
+ break;
+ }
+
+ return selected_index;
+ }
+
+
+ private void OnGotFocus (object sender, EventArgs e)
+ {
+ has_focus = true;
+
+ if (focused_item != -1) {
+ Rectangle invalidate = GetItemDisplayRectangle (focused_item, LBoxInfo.top_item);
+ Invalidate (invalidate);
+ }
+ }
+
+ private void OnLostFocus (object sender, EventArgs e)
+ {
+ has_focus = false;
+
+ if (focused_item != -1) {
+ Rectangle invalidate = GetItemDisplayRectangle (focused_item, LBoxInfo.top_item);
+ Invalidate (invalidate);
+ }
+ }
+
+ private void OnKeyDownLB (object sender, KeyEventArgs e)
+ {
+ int new_item = -1;
+
+ if (Items.Count == 0)
+ return;
+
+ switch (e.KeyCode) {
+
+ case Keys.ControlKey:
+ ctrl_pressed = true;
+ break;
+
+ case Keys.ShiftKey:
+ shift_pressed = true;
+ break;
+
+ case Keys.Home:
+ new_item = NavigateItemVisually (ItemNavigation.First);
+ break;
+
+ case Keys.End:
+ new_item = NavigateItemVisually (ItemNavigation.Last);
+ break;
+
+ case Keys.Up:
+ new_item = NavigateItemVisually (ItemNavigation.Previous);
+ break;
+
+ case Keys.Down:
+ new_item = NavigateItemVisually (ItemNavigation.Next);
+ break;
+
+ case Keys.PageUp:
+ new_item = NavigateItemVisually (ItemNavigation.PreviousPage);
+ break;
+
+ case Keys.PageDown:
+ new_item = NavigateItemVisually (ItemNavigation.NextPage);
+ break;
+
+ case Keys.Right:
+ if (multicolumn == true) {
+ new_item = NavigateItemVisually (ItemNavigation.NextColumn);
+ }
+ break;
+
+ case Keys.Left:
+ if (multicolumn == true) {
+ new_item = NavigateItemVisually (ItemNavigation.PreviousColumn);
+ }
+ break;
+
+ case Keys.Space:
+ if (selection_mode == SelectionMode.MultiSimple) {
+ SelectedItemFromNavigation (focused_item);
+ }
+ break;
+
+
+ default:
+ break;
+ }
+
+ if (new_item != -1) {
+ SetFocusedItem (new_item);
+ }
+
+ if (new_item != -1) {
+ if (selection_mode != SelectionMode.MultiSimple && selection_mode != SelectionMode.None) {
+ SelectedItemFromNavigation (new_item);
+ }
+ }
+ }
+
+ private void OnKeyUpLB (object sender, KeyEventArgs e)
+ {
+ switch (e.KeyCode) {
+ case Keys.ControlKey:
+ ctrl_pressed = false;
+ break;
+ case Keys.ShiftKey:
+ shift_pressed = false;
+ break;
+ default:
+ break;
+ }
+ }
+
+ internal virtual void OnMouseDownLB (object sender, MouseEventArgs e)
+ {
+ if (Click != null) {
+ if (e.Button == MouseButtons.Left) {
+ Click (this, e);
+ }
+ }
+
+ int index = IndexFromPointDisplayRectangle (e.X, e.Y);
+
+ if (index != -1) {
+ SelectedItemFromNavigation (index);
+ SetFocusedItem (index);
+ }
+ }
+
+ private void OnPaintLB (PaintEventArgs pevent)
+ {
+ if (Paint != null)
+ Paint (this, pevent);
+
+ if (suspend_ctrlupdate == true)
+ return;
+
+ Draw (pevent.ClipRectangle, pevent.Graphics);
+ }
+
+ internal void RellocateScrollBars ()
+ {
+ if (listbox_info.show_verticalsb) {
+ vscrollbar_ctrl.Size = new Size (vscrollbar_ctrl.Width, ClientRectangle.Height);
+ vscrollbar_ctrl.Location = new Point (ClientRectangle.Width - vscrollbar_ctrl.Width, 0);
+ }
+
+ if (listbox_info.show_horizontalsb) {
+ int width = listbox_info.client_rect.Width;
+
+ if (listbox_info.show_verticalsb)
+ width -= vscrollbar_ctrl.Width;
+
+ hscrollbar_ctrl.Size = new Size (width, hscrollbar_ctrl.Height);
+ hscrollbar_ctrl.Location = new Point (0, ClientRectangle.Height - hscrollbar_ctrl.Height);
+ }
+
+ CalcClientArea ();
+ }
+
+ // Add an item in the Selection array and marks it visually as selected
+ private void SelectItem (int index)
+ {
+ if (index == -1)
+ return;
+
+ Rectangle invalidate = GetItemDisplayRectangle (index, LBoxInfo.top_item);
+ (Items.GetListBoxItem (index)).Selected = true;
+ selected_indices.AddIndex (index);
+ selected_items.AddObject (Items[index]);
+
+ if (ClientRectangle.IntersectsWith (invalidate))
+ Invalidate (invalidate);
+
+ }
+
+ // An item navigation operation (mouse or keyboard) has caused to select a new item
+ internal void SelectedItemFromNavigation (int index)
+ {
+ switch (SelectionMode) {
+ case SelectionMode.None: // Do nothing
+ break;
+ case SelectionMode.One: {
+ SelectedIndex = index;
+ break;
+ }
+ case SelectionMode.MultiSimple: {
+ if (selected_index == -1) {
+ SelectedIndex = index;
+ } else {
+
+ if ((Items.GetListBoxItem (index)).Selected) // BUG: index or selected_index?
+ UnSelectItem (index, true);
+ else {
+ SelectItem (index);
+ OnSelectedIndexChanged (new EventArgs ());
+ OnSelectedValueChanged (new EventArgs ());
+ }
+ }
+ break;
+ }
+
+ case SelectionMode.MultiExtended: {
+ if (selected_index == -1) {
+ SelectedIndex = index;
+ } else {
+
+ if (ctrl_pressed == false && shift_pressed == false) {
+ ClearSelected ();
+ }
+
+ if (shift_pressed == true) {
+ ShiftSelection (index);
+ } else { // ctrl_pressed or single item
+ SelectItem (index);
+ }
+
+ OnSelectedIndexChanged (new EventArgs ());
+ OnSelectedValueChanged (new EventArgs ());
+ }
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+
+ private void ShiftSelection (int index)
+ {
+ int shorter_item = -1, dist = Items.Count + 1, cur_dist;
+
+ foreach (int idx in selected_indices) {
+ if (idx > index) {
+ cur_dist = idx - index;
+ }
+ else {
+ cur_dist = index - idx;
+ }
+
+ if (cur_dist < dist) {
+ dist = cur_dist;
+ shorter_item = idx;
+ }
+ }
+
+ if (shorter_item != -1) {
+ int start, end;
+
+ if (shorter_item > index) {
+ start = index;
+ end = shorter_item;
+ } else {
+ start = shorter_item;
+ end = index;
+ }
+
+ ClearSelected ();
+ for (int idx = start; idx <= end; idx++) {
+ SelectItem (idx);
+ }
+ }
+ }
+
+ internal void SetFocusedItem (int index)
+ {
+ Rectangle invalidate;
+ int prev = focused_item;
+
+ focused_item = index;
+
+ if (has_focus == false)
+ return;
+
+ if (prev != -1) { // Invalidates previous item
+ invalidate = GetItemDisplayRectangle (prev, LBoxInfo.top_item);
+ Invalidate (invalidate);
+ }
+
+ if (index != -1) {
+ invalidate = GetItemDisplayRectangle (index, LBoxInfo.top_item);
+ Invalidate (invalidate);
+ }
+ }
+
+ // Removes an item in the Selection array and marks it visually as unselected
+ private void UnSelectItem (int index, bool remove)
+ {
+ if (index == -1)
+ return;
+
+ Rectangle invalidate = GetItemDisplayRectangle (index, LBoxInfo.top_item);
+ (Items.GetListBoxItem (index)).Selected = false;
+
+ if (remove) {
+ selected_indices.RemoveIndex (index);
+ selected_items.RemoveObject (Items[index]);
+ }
+
+ if (ClientRectangle.IntersectsWith (invalidate))
+ Invalidate (invalidate);
+ }
+
+ internal StringFormat GetFormatString ()
+ {
+ StringFormat string_format = new StringFormat ();
+
+ if (RightToLeft == RightToLeft.Yes)
+ string_format.Alignment = StringAlignment.Far;
+ else
+ string_format.Alignment = StringAlignment.Near;
+
+ if (UseTabStops)
+ string_format.SetTabStops (0, new float [] {(float)(Font.Height * 3.7)});
+
+ return string_format;
+ }
+
+ // Updates the scrollbar's position with the new items and inside area
+ internal virtual void UpdateItemInfo (UpdateOperation operation, int first, int last)
+ {
+ if (!IsHandleCreated || suspend_ctrlupdate == true)
+ return;
+
+ UpdateShowVerticalScrollBar ();
+
+ if (listbox_info.show_verticalsb && Items.Count > listbox_info.page_size)
+ if (vscrollbar_ctrl.Enabled)
+ vscrollbar_ctrl.Maximum = Items.Count - listbox_info.page_size;
+
+ if (listbox_info.show_horizontalsb) {
+ if (MultiColumn) {
+ int fullpage = (listbox_info.page_size * (listbox_info.client_rect.Width / ColumnWidthInternal));
+
+ if (hscrollbar_ctrl.Enabled && listbox_info.page_size > 0)
+ hscrollbar_ctrl.Maximum = Math.Max (0, 1 + ((Items.Count - fullpage) / listbox_info.page_size));
+ }
+ }
+
+ if (MultiColumn == false) {
+ /* Calc the longest items for non multicolumn listboxes */
+ if (operation == UpdateOperation.AllItems || operation == UpdateOperation.DeleteItems) {
+
+ SizeF size;
+ for (int i = 0; i < Items.Count; i++) {
+ size = DeviceContext.MeasureString (GetItemText (Items[i]), Font);
+
+ if ((int) size.Width > listbox_info.max_itemwidth)
+ listbox_info.max_itemwidth = (int) size.Width;
+ }
+ }
+ else {
+ if (operation == UpdateOperation.AddItems) {
+
+ SizeF size;
+ for (int i = first; i < last + 1; i++) {
+ size = DeviceContext.MeasureString (GetItemText (Items[i]), Font);
+
+ if ((int) size.Width > listbox_info.max_itemwidth)
+ listbox_info.max_itemwidth = (int) size.Width;
+ }
+ }
+ }
+ }
+
+ if (sorted)
+ Sort ();
+
+ if (Items.Count == 0) {
+ selected_index = -1;
+ focused_item = -1;
+ }
+
+ SelectedItems.ReCreate ();
+ SelectedIndices.ReCreate ();
+ UpdateShowHorizontalScrollBar ();
+ LBoxInfo.last_item = LastVisibleItem ();
+ base.Refresh ();
+ }
+
+ private void UpdateInternalClientRect (Rectangle client_rectangle)
+ {
+ listbox_info.client_rect = client_rectangle;
+ UpdateShowHorizontalScrollBar ();
+ UpdateShowVerticalScrollBar ();
+ RellocateScrollBars ();
+ UpdateItemInfo (UpdateOperation.AllItems, 0, 0);
+ }
+
+ /* Determines if the horizontal scrollbar has to be displyed */
+ private void UpdateShowHorizontalScrollBar ()
+ {
+ bool show = false;
+ bool enabled = true;
+
+ if (MultiColumn) { /* Horizontal scrollbar is always shown in Multicolum mode */
+
+ /* Is it really need it */
+ int page_size = listbox_info.client_rect.Height / listbox_info.item_height;
+ int fullpage = (page_size * (listbox_info.textdrawing_rect.Height / ColumnWidthInternal));
+
+ if (Items.Count > fullpage) {
+ show = true;
+ }
+ else { /* Acording to MS Documentation ScrollAlwaysVisible only affects Horizontal scrollbars but
+ this is not true for MultiColumn listboxes */
+ if (ScrollAlwaysVisible == true) {
+ enabled = false;
+ show = true;
+ }
+ }
+
+ } else { /* If large item*/
+
+ if (listbox_info.max_itemwidth > listbox_info.client_rect.Width && HorizontalScrollbar) {
+ show = true;
+ hscrollbar_ctrl.Maximum = listbox_info.max_itemwidth;
+ hscrollbar_ctrl.LargeChange = listbox_info.textdrawing_rect.Width;
+ }
+ }
+
+ if (hscrollbar_ctrl.Enabled != enabled)
+ hscrollbar_ctrl.Enabled = enabled;
+
+ if (listbox_info.show_horizontalsb == show)
+ return;
+
+ listbox_info.show_horizontalsb = show;
+ hscrollbar_ctrl.Visible = show;
+
+ if (show == true) {
+ RellocateScrollBars ();
+ }
+
+ CalcClientArea ();
+ }
+
+ /* Determines if the vertical scrollbar has to be displyed */
+ private void UpdateShowVerticalScrollBar ()
+ {
+ bool show = false;
+ bool enabled = true;
+
+ if (!MultiColumn) { /* Vertical scrollbar is never shown in Multicolum mode */
+ if (Items.Count > listbox_info.page_size) {
+ show = true;
+ }
+ else
+ if (ScrollAlwaysVisible) {
+ show = true;
+ enabled = false;
+ }
+ }
+
+ if (vscrollbar_ctrl.Enabled != enabled)
+ vscrollbar_ctrl.Enabled = enabled;
+
+ if (listbox_info.show_verticalsb == show)
+ return;
+
+ listbox_info.show_verticalsb = show;
+ vscrollbar_ctrl.Visible = show;
+
+ if (show == true) {
+ if (vscrollbar_ctrl.Enabled)
+ vscrollbar_ctrl.Maximum = Items.Count - listbox_info.page_size;
+
+ RellocateScrollBars ();
+ } else if (vscrollbar_ctrl.Maximum > 0) {
+ vscrollbar_ctrl.Maximum = 0;
+ }
+
+ CalcClientArea ();
+ }
+
+ // Value Changed
+ private void VerticalScrollEvent (object sender, EventArgs e)
+ {
+ int top_item = LBoxInfo.top_item;
+ int last_item = LBoxInfo.last_item;
+
+ LBoxInfo.top_item = /*listbox_info.page_size + */ vscrollbar_ctrl.Value;
+ LBoxInfo.last_item = LastVisibleItem ();
+
+ if (top_item != LBoxInfo.top_item || last_item != LBoxInfo.last_item)
+ base.Refresh ();
+ }
+
+ #endregion Private Methods
+
+ /*
+ ListBox.ObjectCollection
+ */
+ [ListBindable (false)]
+ public class ObjectCollection : IList, ICollection, IEnumerable
+ {
+ // Compare objects
+ internal class ListObjectComparer : IComparer
+ {
+ private ListBox owner;
+
+ public ListObjectComparer (ListBox owner)
+ {
+ this.owner = owner;
+ }
+
+ public int Compare (object a, object b)
+ {
+ string str1 = a.ToString ();
+ string str2 = b.ToString ();
+ return str1.CompareTo (str2);
+ }
+ }
+
+ // Compare ListItem
+ internal class ListItemComparer : IComparer
+ {
+ private ListBox owner;
+
+ public ListItemComparer (ListBox owner)
+ {
+ this.owner = owner;
+ }
+
+ public int Compare (object a, object b)
+ {
+ int index1 = ((ListBox.ListBoxItem) (a)).Index;
+ int index2 = ((ListBox.ListBoxItem) (b)).Index;
+ string str1 = owner.GetItemText (owner.Items[index1]);
+ string str2 = owner.GetItemText (owner.Items[index2]);
+ return str1.CompareTo (str2);
+ }
+ }
+
+ private ListBox owner;
+ internal ArrayList object_items = new ArrayList ();
+ internal ArrayList listbox_items = new ArrayList ();
+
+ public ObjectCollection (ListBox owner)
+ {
+ this.owner = owner;
+ }
+
+ public ObjectCollection (ListBox owner, object[] obj)
+ {
+ this.owner = owner;
+ AddRange (obj);
+ }
+
+ public ObjectCollection (ListBox owner, ObjectCollection obj)
+ {
+ this.owner = owner;
+ AddRange (obj);
+ }
+
+ #region Public Properties
+ public virtual int Count {
+ get { return object_items.Count; }
+ }
+
+ public virtual bool IsReadOnly {
+ get { return false; }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public virtual object this [int index] {
+ get {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ return object_items[index];
+ }
+ set {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ object_items[index] = value;
+ }
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return false; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return this; }
+ }
+
+ bool IList.IsFixedSize {
+ get { return false; }
+ }
+
+ #endregion Public Properties
+
+ #region Private Properties
+ internal ArrayList ObjectItems {
+ get { return object_items;}
+ set {
+ object_items = value;
+ }
+ }
+
+ internal ArrayList ListBoxItems {
+ get { return listbox_items;}
+ set {
+ listbox_items = value;
+ }
+ }
+ #endregion Private Properties
+
+ #region Public Methods
+ public int Add (object item)
+ {
+ int idx;
+
+ idx = AddItem (item);
+ owner.UpdateItemInfo (UpdateOperation.AddItems, idx, idx);
+ return idx;
+ }
+
+ public void AddRange (object[] items)
+ {
+ int cnt = Count;
+
+ foreach (object mi in items)
+ AddItem (mi);
+
+ owner.UpdateItemInfo (UpdateOperation.AddItems, cnt, Count - 1);
+ }
+
+ public void AddRange (ObjectCollection col)
+ {
+ int cnt = Count;
+
+ foreach (object mi in col)
+ AddItem (mi);
+
+ owner.UpdateItemInfo (UpdateOperation.AddItems, cnt, Count - 1);
+ }
+
+ internal void AddRange (IList list)
+ {
+ int cnt = Count;
+
+ foreach (object mi in list)
+ AddItem (mi);
+
+ owner.UpdateItemInfo (UpdateOperation.AddItems, cnt, Count - 1);
+ }
+
+ public virtual void Clear ()
+ {
+ owner.selected_index = -1;
+ owner.focused_item = -1;
+ object_items.Clear ();
+ listbox_items.Clear ();
+ owner.UpdateItemInfo (UpdateOperation.AllItems, 0, 0);
+ }
+ public virtual bool Contains (object obj)
+ {
+ return object_items.Contains (obj);
+ }
+
+ public void CopyTo (object[] dest, int arrayIndex)
+ {
+ object_items.CopyTo (dest, arrayIndex);
+ }
+
+ void ICollection.CopyTo (Array dest, int index)
+ {
+ object_items.CopyTo (dest, index);
+ }
+
+ public virtual IEnumerator GetEnumerator ()
+ {
+ return object_items.GetEnumerator ();
+ }
+
+ int IList.Add (object item)
+ {
+ return Add (item);
+ }
+
+ public virtual int IndexOf (object value)
+ {
+ return object_items.IndexOf (value);
+ }
+
+ public virtual void Insert (int index, object item)
+ {
+ if (index < 0 || index > Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ int idx;
+ ObjectCollection new_items = new ObjectCollection (owner);
+
+ owner.BeginUpdate ();
+
+ for (int i = 0; i < index; i++) {
+ idx = new_items.AddItem (ObjectItems[i]);
+ (new_items.GetListBoxItem (idx)).CopyState (GetListBoxItem (i));
+ }
+
+ new_items.AddItem (item);
+
+ for (int i = index; i < Count; i++){
+ idx = new_items.AddItem (ObjectItems[i]);
+ (new_items.GetListBoxItem (idx)).CopyState (GetListBoxItem (i));
+ }
+
+ ObjectItems = new_items.ObjectItems;
+ ListBoxItems = new_items.ListBoxItems;
+
+ owner.EndUpdate (); // Calls UpdateItemInfo
+ }
+
+ public virtual void Remove (object value)
+ {
+ RemoveAt (IndexOf (value));
+ }
+
+ public virtual void RemoveAt (int index)
+ {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ object_items.RemoveAt (index);
+ listbox_items.RemoveAt (index);
+ owner.UpdateItemInfo (UpdateOperation.DeleteItems, index, index);
+ }
+ #endregion Public Methods
+
+ #region Private Methods
+ internal int AddItem (object item)
+ {
+ int cnt = object_items.Count;
+ object_items.Add (item);
+ listbox_items.Add (new ListBox.ListBoxItem (cnt));
+ return cnt;
+ }
+
+ internal ListBox.ListBoxItem GetListBoxItem (int index)
+ {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ return (ListBox.ListBoxItem) listbox_items[index];
+ }
+
+ internal void SetListBoxItem (ListBox.ListBoxItem item, int index)
+ {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ listbox_items[index] = item;
+ }
+
+ internal void Sort ()
+ {
+ /* Keep this order */
+ listbox_items.Sort (new ListItemComparer (owner));
+ object_items.Sort (new ListObjectComparer (owner));
+
+ for (int i = 0; i < listbox_items.Count; i++) {
+ ListBox.ListBoxItem item = GetListBoxItem (i);
+ item.Index = i;
+ }
+ }
+
+ #endregion Private Methods
+ }
+
+ /*
+ ListBox.SelectedIndexCollection
+ */
+ public class SelectedIndexCollection : IList, ICollection, IEnumerable
+ {
+ private ListBox owner;
+ private ArrayList indices = new ArrayList ();
+
+ public SelectedIndexCollection (ListBox owner)
+ {
+ this.owner = owner;
+ }
+
+ #region Public Properties
+ [Browsable (false)]
+ public virtual int Count {
+ get { return indices.Count; }
+ }
+
+ public virtual bool IsReadOnly {
+ get { return true; }
+ }
+
+ public int this [int index] {
+ get {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ return (int) indices[index];
+ }
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return true; }
+ }
+
+ bool IList.IsFixedSize{
+ get { return true; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return this; }
+ }
+
+ #endregion Public Properties
+
+ #region Public Methods
+ public bool Contains (int selectedIndex)
+ {
+ return indices.Contains (selectedIndex);
+ }
+
+ public virtual void CopyTo (Array dest, int index)
+ {
+ indices.CopyTo (dest, index);
+ }
+
+ public virtual IEnumerator GetEnumerator ()
+ {
+ return indices.GetEnumerator ();
+ }
+
+ int IList.Add (object obj)
+ {
+ throw new NotSupportedException ();
+ }
+
+ void IList.Clear ()
+ {
+ throw new NotSupportedException ();
+ }
+
+ bool IList.Contains (object selectedIndex)
+ {
+ return Contains ((int)selectedIndex);
+ }
+
+ int IList.IndexOf (object selectedIndex)
+ {
+ return IndexOf ((int) selectedIndex);
+ }
+
+ void IList.Insert (int index, object value)
+ {
+ throw new NotSupportedException ();
+ }
+
+ void IList.Remove (object value)
+ {
+ throw new NotSupportedException ();
+ }
+
+ void IList.RemoveAt (int index)
+ {
+ throw new NotSupportedException ();
+ }
+
+ object IList.this[int index]{
+ get {return indices[index]; }
+ set {throw new NotImplementedException (); }
+ }
+
+ public int IndexOf (int selectedIndex)
+ {
+ return indices.IndexOf (selectedIndex);
+ }
+ #endregion Public Methods
+
+ #region Private Methods
+
+ internal void AddIndex (int index)
+ {
+ indices.Add (index);
+ }
+
+ internal void ClearIndices ()
+ {
+ indices.Clear ();
+ }
+
+ internal void RemoveIndex (int index)
+ {
+ indices.Remove (index);
+ }
+
+ internal void ReCreate ()
+ {
+ indices.Clear ();
+
+ for (int i = 0; i < owner.Items.Count; i++) {
+ ListBox.ListBoxItem item = owner.Items.GetListBoxItem (i);
+
+ if (item.Selected)
+ indices.Add (item.Index);
+ }
+ }
+
+ #endregion Private Methods
+ }
+
+ /*
+ SelectedObjectCollection
+ */
+ public class SelectedObjectCollection : IList, ICollection, IEnumerable
+ {
+ private ListBox owner;
+ private ArrayList object_items = new ArrayList ();
+
+ public SelectedObjectCollection (ListBox owner)
+ {
+ this.owner = owner;
+ }
+
+ #region Public Properties
+ public virtual int Count {
+ get { return object_items.Count; }
+ }
+
+ public virtual bool IsReadOnly {
+ get { return true; }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public virtual object this [int index] {
+ get {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ return object_items[index];
+ }
+ set {throw new NotSupportedException ();}
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return true; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return this; }
+ }
+
+ bool IList.IsFixedSize {
+ get { return true; }
+ }
+
+ object IList.this[int index] {
+ get { return object_items[index]; }
+ set { throw new NotSupportedException (); }
+ }
+
+ #endregion Public Properties
+
+ #region Public Methods
+ public virtual bool Contains (object selectedObject)
+ {
+ return object_items.Contains (selectedObject);
+ }
+
+ public virtual void CopyTo (Array dest, int index)
+ {
+ object_items.CopyTo (dest, index);
+ }
+
+ int IList.Add (object value)
+ {
+ throw new NotSupportedException ();
+ }
+
+ void IList.Clear ()
+ {
+ throw new NotSupportedException ();
+ }
+
+ bool IList.Contains (object selectedIndex)
+ {
+ throw new NotImplementedException ();
+ }
+
+ void IList.Insert (int index, object value)
+ {
+ throw new NotSupportedException ();
+ }
+
+ void IList.Remove (object value)
+ {
+ throw new NotSupportedException ();
+ }
+
+ void IList.RemoveAt (int index)
+ {
+ throw new NotSupportedException ();
+ }
+
+ public int IndexOf (object item)
+ {
+ return object_items.IndexOf (item);
+ }
+
+ public virtual IEnumerator GetEnumerator ()
+ {
+ return object_items.GetEnumerator ();
+ }
+
+ #endregion Public Methods
+
+ #region Private Methods
+ internal void AddObject (object obj)
+ {
+ object_items.Add (obj);
+ }
+
+ internal void ClearObjects ()
+ {
+ object_items.Clear ();
+ }
+
+ internal void ReCreate ()
+ {
+ object_items.Clear ();
+
+ for (int i = 0; i < owner.Items.Count; i++) {
+ ListBox.ListBoxItem item = owner.Items.GetListBoxItem (i);
+
+ if (item.Selected)
+ object_items.Add (owner.Items[item.Index]);
+ }
+ }
+
+ internal void RemoveObject (object obj)
+ {
+ object_items.Remove (obj);
+ }
+
+ #endregion Private Methods
+
+ }
+
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListControl.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListControl.cs
new file mode 100644
index 00000000000..f114f61a3ab
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListControl.cs
@@ -0,0 +1,337 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+//
+
+// COMPLETE
+
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Reflection;
+
+namespace System.Windows.Forms
+{
+ public abstract class ListControl : Control
+ {
+ private object data_source;
+ private BindingMemberInfo value_member;
+ private string display_member;
+ private CurrencyManager data_manager;
+ private bool formatting_enabled;
+
+ protected ListControl ()
+ {
+ data_source = null;
+ value_member = new BindingMemberInfo (string.Empty);
+ display_member = string.Empty;
+ data_manager = null;
+ SetStyle (ControlStyles.StandardClick | ControlStyles.UserPaint, false);
+ }
+
+ #region Events
+ public event EventHandler DataSourceChanged;
+ public event EventHandler DisplayMemberChanged;
+ public event EventHandler SelectedValueChanged;
+ public event EventHandler ValueMemberChanged;
+ #endregion // Events
+
+ #region .NET 2.0 Public Properties
+#if NET_2_0
+ public bool FormattingEnabled {
+ get { return formatting_enabled; }
+ set { formatting_enabled = value; }
+ }
+#endif
+ #endregion
+
+ #region Public Properties
+
+ [DefaultValue(null)]
+ [RefreshProperties(RefreshProperties.Repaint)]
+ [TypeConverter("System.Windows.Forms.Design.DataSourceConverter, " + Consts.AssemblySystem_Design)]
+ public object DataSource {
+ get { return data_source; }
+ set {
+ if (!(value is IList || value is IListSource)) {
+ throw new Exception ("Complex DataBinding accepts as a data source " +
+ "either an IList or an IListSource");
+ }
+
+ if (data_source == value)
+ return;
+
+ data_source = value;
+ ConnectToDataSource ();
+ OnDataSourceChanged (EventArgs.Empty);
+ }
+ }
+
+ [DefaultValue("")]
+ [Editor("System.Windows.Forms.Design.DataMemberFieldEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
+ [TypeConverter("System.Windows.Forms.Design.DataMemberFieldConverter, " + Consts.AssemblySystem_Design)]
+ public string DisplayMember {
+ get {
+ return display_member;
+ }
+ set {
+ if (display_member == value) {
+ return;
+ }
+
+ display_member = value;
+ ConnectToDataSource ();
+ OnDisplayMemberChanged (EventArgs.Empty);
+ }
+ }
+
+ public abstract int SelectedIndex {
+ get;
+ set;
+ }
+
+ [Bindable(BindableSupport.Yes)]
+ [Browsable(false)]
+ [DefaultValue(null)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public object SelectedValue {
+ get {
+ if (data_manager == null) {
+ return null;
+ }
+
+ object item = data_manager.GetItem (SelectedIndex);
+ object fil = FilterItemOnProperty (item, ValueMember);
+ return fil;
+ }
+ set {
+ if (value == null) {
+ throw new InvalidOperationException("ListControl.SelectedValue cannot be set to null");
+ }
+
+ if (value is string) {
+ string valueString = value as string;
+ if (valueString == String.Empty) {
+ throw new InvalidOperationException("ListControl.SelectedValue cannot be set to empty string");
+ }
+ }
+
+ if (data_manager != null) {
+
+ PropertyDescriptorCollection col = data_manager.GetItemProperties ();
+ PropertyDescriptor prop = col.Find (ValueMember, true);
+
+ for (int i = 0; i < data_manager.Count; i++) {
+ if (prop.GetValue (data_manager.GetItem (i)) == value) {
+ SelectedIndex = i;
+ return;
+ }
+ }
+
+ }
+ }
+ }
+
+ [DefaultValue("")]
+ [Editor("System.Windows.Forms.Design.DataMemberFieldEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
+ public string ValueMember {
+ get { return value_member.BindingMember; }
+ set {
+ BindingMemberInfo new_value = new BindingMemberInfo (value);
+
+ if (value_member.Equals (new_value)) {
+ return;
+ }
+
+ value_member = new_value;
+
+ if (display_member == string.Empty) {
+ DisplayMember = value_member.BindingMember;
+ }
+
+ ConnectToDataSource ();
+ OnValueMemberChanged (EventArgs.Empty);
+ }
+ }
+
+ #endregion Public Properties
+
+ #region Public Methods
+
+ protected object FilterItemOnProperty (object item)
+ {
+ return FilterItemOnProperty (item, string.Empty);
+ }
+
+ protected object FilterItemOnProperty (object item, string field)
+ {
+ if (item == null)
+ return null;
+
+ if (field == null || field == string.Empty)
+ return item;
+
+ PropertyDescriptor prop = null;
+
+ if (data_manager != null) {
+ PropertyDescriptorCollection col = data_manager.GetItemProperties ();
+ prop = col.Find (field, true);
+ }
+
+ if (prop == null)
+ return item;
+
+ return prop.GetValue (item);
+ }
+
+ public string GetItemText (object item)
+ {
+ if (data_manager != null) {
+ object fil = FilterItemOnProperty (item, DisplayMember);
+ if (fil != null) {
+ return fil.ToString ();
+ }
+ }
+
+ return item.ToString ();
+ }
+
+ protected CurrencyManager DataManager {
+ get { return data_manager; }
+ }
+
+ // Used only by ListBox to avoid to break Listbox's member signature
+ protected override bool IsInputKey (Keys keyData)
+ {
+ switch (keyData) {
+ case Keys.Up:
+ case Keys.Down:
+ case Keys.PageUp:
+ case Keys.PageDown:
+ case Keys.Right:
+ case Keys.Left:
+ case Keys.End:
+ case Keys.Home:
+ case Keys.ControlKey:
+ case Keys.Space:
+ case Keys.ShiftKey:
+ return true;
+
+ default:
+ return false;
+ }
+ }
+
+ protected override void OnBindingContextChanged (EventArgs e)
+ {
+ base.OnBindingContextChanged (e);
+ ConnectToDataSource ();
+
+ if (DataManager != null) {
+ SetItemsCore (DataManager.List);
+ SelectedIndex = DataManager.Position;
+ }
+ }
+
+ protected virtual void OnDataSourceChanged (EventArgs e)
+ {
+ if (DataSourceChanged != null)
+ DataSourceChanged (this,e);
+ }
+
+ protected virtual void OnDisplayMemberChanged (EventArgs e)
+ {
+ if (DisplayMemberChanged != null)
+ DisplayMemberChanged (this, e);
+ }
+
+ protected virtual void OnSelectedIndexChanged (EventArgs e)
+ {
+ if (data_manager == null)
+ return;
+ if (data_manager.Position == SelectedIndex)
+ return;
+ data_manager.Position = SelectedIndex;
+ }
+
+ protected virtual void OnSelectedValueChanged (EventArgs e)
+ {
+ if (SelectedValueChanged != null)
+ SelectedValueChanged (this, e);
+ }
+
+ protected virtual void OnValueMemberChanged (EventArgs e)
+ {
+ if (ValueMemberChanged != null)
+ ValueMemberChanged (this, e);
+ }
+
+ protected abstract void RefreshItem (int index);
+
+ protected virtual void SetItemCore (int index, object value)
+ {
+
+ }
+
+ protected abstract void SetItemsCore (IList items);
+
+ #endregion Public Methods
+
+ #region Private Methods
+
+ internal void BindDataItems (IList items)
+ {
+ items.Clear ();
+
+ if (data_manager != null) {
+ SetItemsCore (data_manager.List);
+ }
+ }
+
+ private void ConnectToDataSource ()
+ {
+ if (data_source == null) {
+ data_manager = null;
+ return;
+ }
+
+ if (BindingContext == null) {
+ return;
+ }
+
+ data_manager = (CurrencyManager) BindingContext [data_source];
+ data_manager.PositionChanged += new EventHandler (OnPositionChanged);
+ }
+
+ private void OnPositionChanged (object sender, EventArgs e)
+ {
+ SelectedIndex = data_manager.Position;
+ }
+
+ #endregion Private Methods
+ }
+
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs
new file mode 100644
index 00000000000..e8b5627c537
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs
@@ -0,0 +1,2712 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Ravindra Kumar (rkumar@novell.com)
+// Jordi Mas i Hernandez, jordi@ximian.com
+// Mike Kestner (mkestner@novell.com)
+//
+// TODO:
+// - Feedback for item activation, change in cursor types as mouse moves.
+// - HideSelection
+// - LabelEdit
+// - Drag and drop
+
+
+// NOT COMPLETE
+
+
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Globalization;
+
+namespace System.Windows.Forms
+{
+ [DefaultEvent ("SelectedIndexChanged")]
+ [DefaultProperty ("Items")]
+ [Designer ("System.Windows.Forms.Design.ListViewDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ public class ListView : Control
+ {
+ private ItemActivation activation = ItemActivation.Standard;
+ private ListViewAlignment alignment = ListViewAlignment.Top;
+ private bool allow_column_reorder = false;
+ private bool auto_arrange = true;
+ private bool check_boxes = false;
+ private CheckedIndexCollection checked_indices;
+ private CheckedListViewItemCollection checked_items;
+ private ColumnHeaderCollection columns;
+ internal ListViewItem focused_item;
+ private bool full_row_select = false;
+ private bool grid_lines = false;
+ private ColumnHeaderStyle header_style = ColumnHeaderStyle.Clickable;
+ private bool hide_selection = true;
+ private bool hover_selection = false;
+ private IComparer item_sorter;
+ private ListViewItemCollection items;
+ private bool label_edit = false;
+ private bool label_wrap = true;
+ private bool multiselect = true;
+ private bool scrollable = true;
+ private SelectedIndexCollection selected_indices;
+ private SelectedListViewItemCollection selected_items;
+ private SortOrder sort_order = SortOrder.None;
+ private ImageList state_image_list;
+ private bool updating = false;
+ private View view = View.LargeIcon;
+ private int layout_wd; // We might draw more than our client area
+ private int layout_ht; // therefore we need to have these two.
+ //private TextBox editor; // Used for editing an item text
+ HeaderControl header_control;
+ internal ItemControl item_control;
+ internal ScrollBar h_scroll; // used for scrolling horizontally
+ internal ScrollBar v_scroll; // used for scrolling vertically
+ internal int h_marker; // Position markers for scrolling
+ internal int v_marker;
+ private int keysearch_tickcnt;
+ private string keysearch_text;
+ static private readonly int keysearch_keydelay = 1000;
+ private int[] reordered_column_indices;
+
+ // internal variables
+ internal ImageList large_image_list;
+ internal ImageList small_image_list;
+ internal Size text_size = Size.Empty;
+
+ #region Events
+ public event LabelEditEventHandler AfterLabelEdit;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler BackgroundImageChanged {
+ add { base.BackgroundImageChanged += value; }
+ remove { base.BackgroundImageChanged -= value; }
+ }
+
+ public event LabelEditEventHandler BeforeLabelEdit;
+ public event ColumnClickEventHandler ColumnClick;
+ public event EventHandler ItemActivate;
+ public event ItemCheckEventHandler ItemCheck;
+ public event ItemDragEventHandler ItemDrag;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event PaintEventHandler Paint {
+ add { base.Paint += value; }
+ remove { base.Paint -= value; }
+ }
+
+ public event EventHandler SelectedIndexChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler TextChanged {
+ add { base.TextChanged += value; }
+ remove { base.TextChanged -= value; }
+ }
+
+ #endregion // Events
+
+ #region Public Constructors
+ public ListView ()
+ {
+ background_color = ThemeEngine.Current.ColorWindow;
+ checked_indices = new CheckedIndexCollection (this);
+ checked_items = new CheckedListViewItemCollection (this);
+ columns = new ColumnHeaderCollection (this);
+ foreground_color = SystemColors.WindowText;
+ items = new ListViewItemCollection (this);
+ selected_indices = new SelectedIndexCollection (this);
+ selected_items = new SelectedListViewItemCollection (this);
+
+ border_style = BorderStyle.Fixed3D;
+
+ header_control = new HeaderControl (this);
+ header_control.Visible = false;
+ item_control = new ItemControl (this);
+ item_control.Visible = true;
+
+ h_scroll = new HScrollBar ();
+ v_scroll = new VScrollBar ();
+ h_marker = v_marker = 0;
+ keysearch_tickcnt = 0;
+
+ // scroll bars are disabled initially
+ h_scroll.Visible = false;
+ h_scroll.ValueChanged += new EventHandler(HorizontalScroller);
+ v_scroll.Visible = false;
+ v_scroll.ValueChanged += new EventHandler(VerticalScroller);
+
+ // event handlers
+ base.KeyDown += new KeyEventHandler(ListView_KeyDown);
+ base.Paint += new PaintEventHandler (ListView_Paint);
+ SizeChanged += new EventHandler (ListView_SizeChanged);
+
+ this.SetStyle (ControlStyles.UserPaint | ControlStyles.StandardClick, false);
+ }
+ #endregion // Public Constructors
+
+ #region Private Internal Properties
+ internal Size CheckBoxSize {
+ get {
+ if (this.check_boxes) {
+ if (this.state_image_list != null)
+ return this.state_image_list.ImageSize;
+ else
+ return ThemeEngine.Current.ListViewCheckBoxSize;
+ }
+ return Size.Empty;
+ }
+ }
+
+ internal bool CanMultiselect {
+ get {
+ if (multiselect && (XplatUI.State.ModifierKeys & (Keys.Control | Keys.Shift)) != 0)
+ return true;
+ else
+ return false;
+ }
+ }
+
+ #endregion // Private Internal Properties
+
+ #region Protected Properties
+ protected override CreateParams CreateParams {
+ get { return base.CreateParams; }
+ }
+
+ protected override Size DefaultSize {
+ get { return ThemeEngine.Current.ListViewDefaultSize; }
+ }
+ #endregion // Protected Properties
+
+ #region Public Instance Properties
+ [DefaultValue (ItemActivation.Standard)]
+ public ItemActivation Activation {
+ get { return activation; }
+ set {
+ if (value != ItemActivation.Standard && value != ItemActivation.OneClick &&
+ value != ItemActivation.TwoClick) {
+ throw new InvalidEnumArgumentException (string.Format
+ ("Enum argument value '{0}' is not valid for Activation", value));
+ }
+
+ activation = value;
+ }
+ }
+
+ [DefaultValue (ListViewAlignment.Top)]
+ [Localizable (true)]
+ public ListViewAlignment Alignment {
+ get { return alignment; }
+ set {
+ if (value != ListViewAlignment.Default && value != ListViewAlignment.Left &&
+ value != ListViewAlignment.SnapToGrid && value != ListViewAlignment.Top) {
+ throw new InvalidEnumArgumentException (string.Format
+ ("Enum argument value '{0}' is not valid for Alignment", value));
+ }
+
+ if (this.alignment != value) {
+ alignment = value;
+ // alignment does not matter in Details/List views
+ if (this.view == View.LargeIcon ||
+ this.View == View.SmallIcon)
+ this.Redraw (true);
+ }
+ }
+ }
+
+ [DefaultValue (false)]
+ public bool AllowColumnReorder {
+ get { return allow_column_reorder; }
+ set { allow_column_reorder = value; }
+ }
+
+ [DefaultValue (true)]
+ public bool AutoArrange {
+ get { return auto_arrange; }
+ set {
+ if (auto_arrange != value) {
+ auto_arrange = value;
+ // autoarrange does not matter in Details/List views
+ if (this.view == View.LargeIcon || this.View == View.SmallIcon)
+ this.Redraw (true);
+ }
+ }
+ }
+
+ public override Color BackColor {
+ get {
+ if (background_color.IsEmpty)
+ return ThemeEngine.Current.ColorWindow;
+ else
+ return background_color;
+ }
+ set { background_color = value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override Image BackgroundImage {
+ get { return background_image; }
+ set {
+ if (value == background_image)
+ return;
+
+ background_image = value;
+ OnBackgroundImageChanged (EventArgs.Empty);
+ }
+ }
+
+ [DefaultValue (BorderStyle.Fixed3D)]
+ [DispId (-504)]
+ public BorderStyle BorderStyle {
+ get { return InternalBorderStyle; }
+ set { InternalBorderStyle = value; }
+ }
+
+ [DefaultValue (false)]
+ public bool CheckBoxes {
+ get { return check_boxes; }
+ set {
+ if (check_boxes != value) {
+ check_boxes = value;
+ this.Redraw (true);
+ }
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public CheckedIndexCollection CheckedIndices {
+ get { return checked_indices; }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public CheckedListViewItemCollection CheckedItems {
+ get { return checked_items; }
+ }
+
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
+ [Localizable (true)]
+ [MergableProperty (false)]
+ public ColumnHeaderCollection Columns {
+ get { return columns; }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public ListViewItem FocusedItem {
+ get {
+ if (focused_item == null && Focused && items.Count > 0)
+ focused_item = items [0];
+ return focused_item;
+ }
+ }
+
+ public override Color ForeColor {
+ get {
+ if (foreground_color.IsEmpty)
+ return ThemeEngine.Current.ColorWindowText;
+ else
+ return foreground_color;
+ }
+ set { foreground_color = value; }
+ }
+
+ [DefaultValue (false)]
+ public bool FullRowSelect {
+ get { return full_row_select; }
+ set { full_row_select = value; }
+ }
+
+ [DefaultValue (false)]
+ public bool GridLines {
+ get { return grid_lines; }
+ set {
+ if (grid_lines != value) {
+ grid_lines = value;
+ this.Redraw (false);
+ }
+ }
+ }
+
+ [DefaultValue (ColumnHeaderStyle.Clickable)]
+ public ColumnHeaderStyle HeaderStyle {
+ get { return header_style; }
+ set {
+ if (header_style == value)
+ return;
+
+ switch (value) {
+ case ColumnHeaderStyle.Clickable:
+ case ColumnHeaderStyle.Nonclickable:
+ case ColumnHeaderStyle.None:
+ break;
+ default:
+ throw new InvalidEnumArgumentException (string.Format
+ ("Enum argument value '{0}' is not valid for ColumnHeaderStyle", value));
+ }
+
+ header_style = value;
+ if (view == View.Details)
+ Redraw (true);
+ }
+ }
+
+ [DefaultValue (true)]
+ public bool HideSelection {
+ get { return hide_selection; }
+ set {
+ if (hide_selection != value) {
+ hide_selection = value;
+ this.Redraw (false);
+ }
+ }
+ }
+
+ [DefaultValue (false)]
+ public bool HoverSelection {
+ get { return hover_selection; }
+ set { hover_selection = value; }
+ }
+
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
+ [Localizable (true)]
+ [MergableProperty (false)]
+ public ListViewItemCollection Items {
+ get { return items; }
+ }
+
+ [DefaultValue (false)]
+ public bool LabelEdit {
+ get { return label_edit; }
+ set { label_edit = value; }
+ }
+
+ [DefaultValue (true)]
+ [Localizable (true)]
+ public bool LabelWrap {
+ get { return label_wrap; }
+ set {
+ if (label_wrap != value) {
+ label_wrap = value;
+ this.Redraw (true);
+ }
+ }
+ }
+
+ [DefaultValue (null)]
+ public ImageList LargeImageList {
+ get { return large_image_list; }
+ set {
+ large_image_list = value;
+ this.Redraw (true);
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public IComparer ListViewItemSorter {
+ get { return item_sorter; }
+ set { item_sorter = value; }
+ }
+
+ [DefaultValue (true)]
+ public bool MultiSelect {
+ get { return multiselect; }
+ set { multiselect = value; }
+ }
+
+ [DefaultValue (true)]
+ public bool Scrollable {
+ get { return scrollable; }
+ set {
+ if (scrollable != value) {
+ scrollable = value;
+ this.Redraw (true);
+ }
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public SelectedIndexCollection SelectedIndices {
+ get { return selected_indices; }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public SelectedListViewItemCollection SelectedItems {
+ get { return selected_items; }
+ }
+
+ [DefaultValue (null)]
+ public ImageList SmallImageList {
+ get { return small_image_list; }
+ set {
+ small_image_list = value;
+ this.Redraw (true);
+ }
+ }
+
+ [DefaultValue (SortOrder.None)]
+ public SortOrder Sorting {
+ get { return sort_order; }
+ set {
+ if (value != SortOrder.Ascending && value != SortOrder.Descending &&
+ value != SortOrder.None) {
+ throw new InvalidEnumArgumentException (string.Format
+ ("Enum argument value '{0}' is not valid for Sorting", value));
+ }
+
+ if (sort_order != value) {
+ sort_order = value;
+ this.Redraw (false);
+ }
+ }
+ }
+
+ [DefaultValue (null)]
+ public ImageList StateImageList {
+ get { return state_image_list; }
+ set {
+ state_image_list = value;
+ this.Redraw (true);
+ }
+ }
+
+ [Bindable (false)]
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override string Text {
+ get { return text; }
+ set {
+ if (value == text)
+ return;
+
+ text = value;
+ this.Redraw (true);
+
+ OnTextChanged (EventArgs.Empty);
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public ListViewItem TopItem {
+ get {
+ // there is no item
+ if (this.items.Count == 0)
+ return null;
+ // if contents are not scrolled
+ // it is the first item
+ else if (h_marker == 0 && v_marker == 0)
+ return this.items [0];
+ // do a hit test for the scrolled position
+ else {
+ foreach (ListViewItem item in this.items) {
+ if (item.Bounds.X >= 0 && item.Bounds.Y >= 0)
+ return item;
+ }
+ return null;
+ }
+ }
+ }
+
+ [DefaultValue (View.LargeIcon)]
+ public View View {
+ get { return view; }
+ set {
+ if (value != View.Details && value != View.LargeIcon &&
+ value != View.List && value != View.SmallIcon ) {
+ throw new InvalidEnumArgumentException (string.Format
+ ("Enum argument value '{0}' is not valid for View", value));
+ }
+
+ if (view != value) {
+ h_scroll.Value = v_scroll.Value = 0;
+ view = value;
+ Redraw (true);
+ }
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Internal Methods Properties
+
+ internal int FirstVisibleIndex {
+ get {
+ // there is no item
+ if (this.items.Count == 0)
+ return 0;
+
+ if (h_marker == 0 && v_marker == 0)
+ return 0;
+
+ foreach (ListViewItem item in this.items) {
+ if (item.Bounds.Right >= 0 && item.Bounds.Bottom >= 0)
+ return item.Index;
+ }
+ return 0;
+
+ }
+ }
+
+
+ internal int LastVisibleIndex {
+ get {
+ for (int i = FirstVisibleIndex; i < Items.Count; i++) {
+ if (Items[i].Bounds.Y > ClientRectangle.Bottom)
+ return i -1;
+ }
+
+ return Items.Count - 1;
+ }
+ }
+
+ internal int TotalWidth {
+ get { return Math.Max (this.Width, this.layout_wd); }
+ }
+
+ internal int TotalHeight {
+ get { return Math.Max (this.Height, this.layout_ht); }
+ }
+
+ internal void Redraw (bool recalculate)
+ {
+ // Avoid calculations when control is being updated
+ if (this.updating)
+ return;
+
+ if (recalculate)
+ CalculateListView (this.alignment);
+
+ Refresh ();
+ }
+
+ internal Size GetChildColumnSize (int index)
+ {
+ Size ret_size = Size.Empty;
+ ColumnHeader col = this.columns [index];
+
+ if (col.Width == -2) { // autosize = max(items, columnheader)
+ Size size = Size.Ceiling (this.DeviceContext.MeasureString
+ (col.Text, this.Font));
+ ret_size = BiggestItem (index);
+ if (size.Width > ret_size.Width)
+ ret_size = size;
+ }
+ else { // -1 and all the values < -2 are put under one category
+ ret_size = BiggestItem (index);
+ // fall back to empty columns' width if no subitem is available for a column
+ if (ret_size.IsEmpty) {
+ ret_size.Width = ThemeEngine.Current.ListViewEmptyColumnWidth;
+ if (col.Text.Length > 0)
+ ret_size.Height = Size.Ceiling (this.DeviceContext.MeasureString
+ (col.Text, this.Font)).Height;
+ else
+ ret_size.Height = this.Font.Height;
+ }
+ }
+
+ // adjust the size for icon and checkbox for 0th column
+ if (index == 0) {
+ ret_size.Width += (this.CheckBoxSize.Width + 4);
+ if (this.small_image_list != null)
+ ret_size.Width += this.small_image_list.ImageSize.Width;
+ }
+ return ret_size;
+ }
+
+ // Returns the size of biggest item text in a column.
+ private Size BiggestItem (int col)
+ {
+ Size temp = Size.Empty;
+ Size ret_size = Size.Empty;
+
+ // 0th column holds the item text, we check the size of
+ // the various subitems falling in that column and get
+ // the biggest one's size.
+ foreach (ListViewItem item in items) {
+ if (col >= item.SubItems.Count)
+ continue;
+
+ temp = Size.Ceiling (this.DeviceContext.MeasureString
+ (item.SubItems [col].Text, this.Font));
+ if (temp.Width > ret_size.Width)
+ ret_size = temp;
+ }
+
+ // adjustment for space
+ if (!ret_size.IsEmpty)
+ ret_size.Width += 4;
+
+ return ret_size;
+ }
+
+ // Sets the size of the biggest item text as per the view
+ private void CalcTextSize ()
+ {
+ // clear the old value
+ text_size = Size.Empty;
+
+ if (items.Count == 0)
+ return;
+
+ text_size = BiggestItem (0);
+
+ if (view == View.LargeIcon && this.label_wrap) {
+ Size temp = Size.Empty;
+ if (this.check_boxes)
+ temp.Width += 2 * this.CheckBoxSize.Width;
+ if (large_image_list != null)
+ temp.Width += large_image_list.ImageSize.Width;
+ if (temp.Width == 0)
+ temp.Width = 43;
+ // wrapping is done for two lines only
+ if (text_size.Width > temp.Width) {
+ text_size.Width = temp.Width;
+ text_size.Height *= 2;
+ }
+ }
+ else if (view == View.List) {
+ // in list view max text shown in determined by the
+ // control width, even if scolling is enabled.
+ int max_wd = this.Width - (this.CheckBoxSize.Width - 2);
+ if (this.small_image_list != null)
+ max_wd -= this.small_image_list.ImageSize.Width;
+
+ if (text_size.Width > max_wd)
+ text_size.Width = max_wd;
+ }
+
+ // we do the default settings, if we have got 0's
+ if (text_size.Height <= 0)
+ text_size.Height = this.Font.Height;
+ if (text_size.Width <= 0)
+ text_size.Width = this.Width;
+
+ // little adjustment
+ text_size.Width += 4;
+ text_size.Height += 2;
+ }
+
+ private void Scroll (ScrollBar scrollbar, int delta)
+ {
+ if (delta == 0 || !scrollbar.Visible)
+ return;
+
+ int max;
+ if (scrollbar == h_scroll)
+ max = h_scroll.Maximum - item_control.Width;
+ else
+ max = v_scroll.Maximum - item_control.Height;
+
+ int val = scrollbar.Value + delta;
+ if (val > max)
+ val = max;
+ else if (val < scrollbar.Minimum)
+ val = scrollbar.Minimum;
+ scrollbar.Value = val;
+ }
+
+ private void CalculateScrollBars ()
+ {
+ Rectangle client_area = ClientRectangle;
+
+ if (!this.scrollable || this.items.Count <= 0) {
+ h_scroll.Visible = false;
+ v_scroll.Visible = false;
+ return;
+ }
+
+ // making a scroll bar visible might make
+ // other scroll bar visible
+ if (layout_wd > client_area.Right) {
+ h_scroll.Visible = true;
+ if ((layout_ht + h_scroll.Height) > client_area.Bottom)
+ v_scroll.Visible = true;
+ else
+ v_scroll.Visible = false;
+ } else if (layout_ht > client_area.Bottom) {
+ v_scroll.Visible = true;
+ if ((layout_wd + v_scroll.Width) > client_area.Right)
+ h_scroll.Visible = true;
+ else
+ h_scroll.Visible = false;
+ } else {
+ h_scroll.Visible = false;
+ v_scroll.Visible = false;
+ }
+
+ item_control.Height = ClientRectangle.Height - header_control.Height;
+
+ if (h_scroll.Visible) {
+ h_scroll.Location = new Point (client_area.X, client_area.Bottom - h_scroll.Height);
+ h_scroll.Minimum = 0;
+
+ // if v_scroll is visible, adjust the maximum of the
+ // h_scroll to account for the width of v_scroll
+ if (v_scroll.Visible) {
+ h_scroll.Maximum = layout_wd + v_scroll.Width;
+ h_scroll.Width = client_area.Width - v_scroll.Width;
+ }
+ else {
+ h_scroll.Maximum = layout_wd;
+ h_scroll.Width = client_area.Width;
+ }
+
+ h_scroll.LargeChange = client_area.Width;
+ h_scroll.SmallChange = Font.Height;
+ item_control.Height -= h_scroll.Height;
+ }
+
+ if (header_control.Visible)
+ header_control.Width = ClientRectangle.Width;
+ item_control.Width = ClientRectangle.Width;
+
+ if (v_scroll.Visible) {
+ v_scroll.Location = new Point (client_area.Right - v_scroll.Width, client_area.Y);
+ v_scroll.Minimum = 0;
+
+ // if h_scroll is visible, adjust the maximum of the
+ // v_scroll to account for the height of h_scroll
+ if (h_scroll.Visible) {
+ v_scroll.Maximum = layout_ht + h_scroll.Height;
+ v_scroll.Height = client_area.Height; // - h_scroll.Height already done
+ } else {
+ v_scroll.Maximum = layout_ht;
+ v_scroll.Height = client_area.Height;
+ }
+
+ v_scroll.LargeChange = client_area.Height;
+ v_scroll.SmallChange = Font.Height;
+ if (header_control.Visible)
+ header_control.Width -= v_scroll.Width;
+ item_control.Width -= v_scroll.Width;
+ }
+ }
+
+ ColumnHeader GetReorderedColumn (int index)
+ {
+ if (reordered_column_indices == null)
+ return Columns [index];
+ else
+ return Columns [reordered_column_indices [index]];
+ }
+
+ void ReorderColumn (ColumnHeader col, int index)
+ {
+ if (reordered_column_indices == null) {
+ reordered_column_indices = new int [Columns.Count];
+ for (int i = 0; i < Columns.Count; i++)
+ reordered_column_indices [i] = i;
+ }
+
+ if (reordered_column_indices [index] == col.Index)
+ return;
+
+ int[] curr = reordered_column_indices;
+ int[] result = new int [Columns.Count];
+ int curr_idx = 0;
+ for (int i = 0; i < Columns.Count; i++) {
+ if (curr_idx < Columns.Count && curr [curr_idx] == col.Index)
+ curr_idx++;
+
+ if (i == index)
+ result [i] = col.Index;
+ else
+ result [i] = curr [curr_idx++];
+ }
+
+ reordered_column_indices = result;
+ LayoutDetails ();
+ header_control.Invalidate ();
+ item_control.Invalidate ();
+ }
+
+ Size LargeIconItemSize {
+ get {
+ int image_w = LargeImageList == null ? 12 : LargeImageList.ImageSize.Width;
+ int image_h = LargeImageList == null ? 2 : LargeImageList.ImageSize.Height;
+ int w = CheckBoxSize.Width + 2 + Math.Max (text_size.Width, image_w);
+ int h = text_size.Height + 2 + Math.Max (CheckBoxSize.Height, image_h);
+ return new Size (w, h);
+ }
+ }
+
+ Size SmallIconItemSize {
+ get {
+ int image_w = SmallImageList == null ? 0 : SmallImageList.ImageSize.Width;
+ int image_h = SmallImageList == null ? 0 : SmallImageList.ImageSize.Height;
+ int w = text_size.Width + 2 + CheckBoxSize.Width + image_w;
+ int h = Math.Max (text_size.Height, Math.Max (CheckBoxSize.Height, image_h));
+ return new Size (w, h);
+ }
+ }
+
+ int rows;
+ int cols;
+ ListViewItem[,] item_matrix;
+
+ void LayoutIcons (bool large_icons, bool left_aligned, int x_spacing, int y_spacing)
+ {
+ header_control.Visible = false;
+ header_control.Size = Size.Empty;
+ item_control.Location = Point.Empty;
+
+ if (items.Count == 0)
+ return;
+
+ Size sz = large_icons ? LargeIconItemSize : SmallIconItemSize;
+
+ Rectangle area = ClientRectangle;
+
+ if (left_aligned) {
+ rows = (int) Math.Floor ((double)area.Height / (double)(sz.Height + y_spacing));
+ if (rows == 0)
+ rows = 1;
+ cols = (int) Math.Ceiling ((double)items.Count / (double)rows);
+ } else {
+ cols = (int) Math.Floor ((double)area.Width / (double)(sz.Width + x_spacing));
+ if (cols == 0)
+ cols = 1;
+ rows = (int) Math.Ceiling ((double)items.Count / (double)cols);
+ }
+
+ layout_ht = rows * (sz.Height + y_spacing) - y_spacing;
+ layout_wd = cols * (sz.Width + x_spacing) - x_spacing;
+ item_matrix = new ListViewItem [rows, cols];
+ int row = 0;
+ int col = 0;
+ foreach (ListViewItem item in items) {
+ int x = col * (sz.Width + x_spacing);
+ int y = row * (sz.Height + y_spacing);
+ item.Location = new Point (x, y);
+ item.Layout ();
+ item.row = row;
+ item.col = col;
+ item_matrix [row, col] = item;
+ if (left_aligned) {
+ if (++row == rows) {
+ row = 0;
+ col++;
+ }
+ } else {
+ if (++col == cols) {
+ col = 0;
+ row++;
+ }
+ }
+ }
+
+ item_control.Size = new Size (layout_wd, layout_ht);
+ }
+
+ void LayoutHeader ()
+ {
+ if (columns.Count == 0 || header_style == ColumnHeaderStyle.None) {
+ header_control.Visible = false;
+ header_control.Size = Size.Empty;
+ return;
+ }
+
+ int x = 0;
+ for (int i = 0; i < Columns.Count; i++) {
+ ColumnHeader col = GetReorderedColumn (i);
+ col.X = x;
+ col.Y = 0;
+ col.CalcColumnHeader ();
+ x += col.Wd;
+ }
+
+ header_control.Width = x;
+ header_control.Height = columns [0].Ht;
+ header_control.Visible = true;
+ }
+
+ void LayoutDetails ()
+ {
+ LayoutHeader ();
+
+ item_control.Location = new Point (0, header_control.Height);
+
+ int y = 0;
+ if (items.Count > 0) {
+ foreach (ListViewItem item in items) {
+ item.Layout ();
+ item.Location = new Point (0, y);
+ y += item.Bounds.Height + 2;
+ }
+
+ // some space for bottom gridline
+ if (grid_lines)
+ y += 2;
+ }
+
+ layout_wd = Math.Max (header_control.Width, item_control.Width);
+ layout_ht = y + header_control.Height;
+ }
+
+ private void CalculateListView (ListViewAlignment align)
+ {
+ CalcTextSize ();
+
+ switch (view) {
+ case View.Details:
+ LayoutDetails ();
+ break;
+
+ case View.SmallIcon:
+ LayoutIcons (false, alignment == ListViewAlignment.Left, 4, 2);
+ break;
+
+ case View.LargeIcon:
+ LayoutIcons (true, alignment == ListViewAlignment.Left,
+ ThemeEngine.Current.ListViewHorizontalSpacing,
+ ThemeEngine.Current.ListViewVerticalSpacing);
+ break;
+
+ case View.List:
+ LayoutIcons (false, true, 4, 2);
+ break;
+ }
+
+ CalculateScrollBars ();
+ }
+
+ internal void UpdateSelection (ListViewItem item)
+ {
+ if (item.Selected) {
+
+ if (!CanMultiselect && SelectedItems.Count > 0) {
+ SelectedItems.Clear ();
+ SelectedIndices.list.Clear ();
+ }
+
+ if (!SelectedItems.Contains (item)) {
+ SelectedItems.list.Add (item);
+ SelectedIndices.list.Add (item.Index);
+ }
+ } else {
+ SelectedItems.list.Remove (item);
+ SelectedIndices.list.Remove (item.Index);
+ }
+ }
+
+ private bool KeySearchString (KeyEventArgs ke)
+ {
+ int current_tickcnt = Environment.TickCount;
+ if (keysearch_tickcnt > 0 && current_tickcnt - keysearch_tickcnt > keysearch_keydelay) {
+ keysearch_text = string.Empty;
+ }
+
+ keysearch_text += (char) ke.KeyData;
+ keysearch_tickcnt = current_tickcnt;
+
+ int start = FocusedItem == null ? 0 : FocusedItem.Index;
+ int i = start;
+ while (true) {
+ if (CultureInfo.CurrentCulture.CompareInfo.IsPrefix (Items[i].Text, keysearch_text,
+ CompareOptions.IgnoreCase)) {
+ SetFocusedItem (Items [i]);
+ items [i].Selected = true;
+ EnsureVisible (i);
+ break;
+ }
+ i = (i + 1 < Items.Count) ? i+1 : 0;
+
+ if (i == start)
+ break;
+ }
+ return true;
+ }
+
+ int GetAdjustedIndex (Keys key)
+ {
+ int result = -1;
+
+ if (View == View.Details) {
+ if (key == Keys.Up)
+ result = FocusedItem.Index - 1;
+ else if (key == Keys.Down) {
+ result = FocusedItem.Index + 1;
+ if (result == items.Count)
+ result = -1;
+ }
+ return result;
+ }
+
+ int row = FocusedItem.row;
+ int col = FocusedItem.col;
+
+ switch (key) {
+ case Keys.Left:
+ if (col == 0)
+ return -1;
+ return item_matrix [row, col - 1].Index;
+
+ case Keys.Right:
+ if (col == (cols - 1))
+ return -1;
+ while (item_matrix [row, col + 1] == null)
+ row--;
+ return item_matrix [row, col + 1].Index;
+
+ case Keys.Up:
+ if (row == 0)
+ return -1;
+ return item_matrix [row - 1, col].Index;
+
+ case Keys.Down:
+ if (row == (rows - 1))
+ return -1;
+ while (item_matrix [row + 1, col] == null)
+ col--;
+ return item_matrix [row + 1, col].Index;
+
+ default:
+ return -1;
+ }
+ }
+
+ ListViewItem selection_start;
+
+ private void SelectItems (ArrayList sel_items)
+ {
+ SelectedItems.Clear ();
+ SelectedIndices.list.Clear ();
+ foreach (ListViewItem item in sel_items)
+ item.Selected = true;
+ }
+
+ private void UpdateMultiSelection (int index)
+ {
+ bool shift_pressed = (XplatUI.State.ModifierKeys & Keys.Shift) != 0;
+ bool ctrl_pressed = (XplatUI.State.ModifierKeys & Keys.Control) != 0;
+ ListViewItem item = items [index];
+
+ if (shift_pressed && selection_start != null) {
+ ArrayList list = new ArrayList ();
+ int start = Math.Min (selection_start.Index, index);
+ int end = Math.Max (selection_start.Index, index);
+ if (View == View.Details) {
+ for (int i = start; i <= end; i++)
+ list.Add (items [i]);
+ } else {
+ int left = Math.Min (items [start].col, items [end].col);
+ int right = Math.Max (items [start].col, items [end].col);
+ int top = Math.Min (items [start].row, items [end].row);
+ int bottom = Math.Max (items [start].row, items [end].row);
+ foreach (ListViewItem curr in items)
+ if (curr.row >= top && curr.row <= bottom &&
+ curr.col >= left && curr.col <= right)
+ list.Add (curr);
+ }
+ SelectItems (list);
+ } else if (!ctrl_pressed) {
+ SelectedItems.Clear ();
+ SelectedIndices.list.Clear ();
+ item.Selected = true;
+ selection_start = item;
+ }
+ }
+
+ private void ListView_KeyDown (object sender, KeyEventArgs ke)
+ {
+ if (ke.Handled || Items.Count == 0)
+ return;
+
+ int index = -1;
+ ke.Handled = true;
+
+ switch (ke.KeyCode) {
+
+ case Keys.End:
+ index = Items.Count - 1;
+ break;
+
+ case Keys.Home:
+ index = 0;
+ break;
+
+ case Keys.Left:
+ case Keys.Right:
+ case Keys.Up:
+ case Keys.Down:
+ index = GetAdjustedIndex (ke.KeyCode);
+ break;
+
+ default:
+ ke.Handled = KeySearchString (ke);
+ return;
+ }
+
+ if (index == -1)
+ return;
+
+ if (MultiSelect)
+ UpdateMultiSelection (index);
+ else
+ items [index].Selected = true;
+
+ SetFocusedItem (items [index]);
+ EnsureVisible (index);
+ }
+
+
+ internal class ItemControl : Control {
+
+ ListView owner;
+ ListViewItem clicked_item;
+ ListViewItem last_clicked_item;
+ bool hover_processed = false;
+
+ public ItemControl (ListView owner)
+ {
+ this.owner = owner;
+ DoubleClick += new EventHandler(ItemsDoubleClick);
+ KeyDown += new KeyEventHandler (ItemsKeyDown);
+ KeyUp += new KeyEventHandler (ItemsKeyUp);
+ MouseDown += new MouseEventHandler(ItemsMouseDown);
+ MouseMove += new MouseEventHandler(ItemsMouseMove);
+ MouseHover += new EventHandler(ItemsMouseHover);
+ MouseUp += new MouseEventHandler(ItemsMouseUp);
+ MouseWheel += new MouseEventHandler(ItemsMouseWheel);
+ Paint += new PaintEventHandler (ItemsPaint);
+ }
+
+ void ItemsDoubleClick (object sender, EventArgs e)
+ {
+ if (owner.activation == ItemActivation.Standard && owner.ItemActivate != null)
+ owner.ItemActivate (this, e);
+ }
+
+ void ItemsKeyDown (object sender, KeyEventArgs args)
+ {
+ owner.OnKeyDown (args);
+ }
+
+ void ItemsKeyUp (object sender, KeyEventArgs args)
+ {
+ owner.OnKeyUp (args);
+ }
+
+ private void ItemsMouseDown (object sender, MouseEventArgs me)
+ {
+ if (owner.items.Count == 0)
+ return;
+
+ Point pt = new Point (me.X, me.Y);
+ foreach (ListViewItem item in owner.items) {
+ if (item.CheckRectReal.Contains (pt)) {
+ CheckState curr_state = item.Checked ? CheckState.Checked : CheckState.Unchecked;
+ item.Checked = !item.Checked;
+
+ CheckState new_state = item.Checked ? CheckState.Checked : CheckState.Unchecked;
+
+ // Raise the ItemCheck event
+ ItemCheckEventArgs ice = new ItemCheckEventArgs (item.Index, curr_state, new_state);
+ owner.OnItemCheck (ice);
+ break;
+ }
+
+ if (owner.View == View.Details && !owner.FullRowSelect) {
+ if (item.GetBounds (ItemBoundsPortion.Label).Contains (pt)) {
+ clicked_item = item;
+ break;
+ }
+ } else {
+ if (item.Bounds.Contains (pt)) {
+ clicked_item = item;
+ break;
+ }
+ }
+ }
+
+ owner.SetFocusedItem (clicked_item);
+
+ if (clicked_item != null) {
+ bool changed = !clicked_item.Selected;
+ if (owner.MultiSelect && (XplatUI.State.ModifierKeys & Keys.Control) == 0)
+ owner.UpdateMultiSelection (clicked_item.Index);
+ else
+ clicked_item.Selected = true;
+
+ if (changed)
+ owner.OnSelectedIndexChanged (EventArgs.Empty);
+
+ // Raise double click if the item was clicked. On MS the
+ // double click is only raised if you double click an item
+ if (me.Clicks > 1 && clicked_item != null)
+ owner.OnDoubleClick (EventArgs.Empty);
+ else if (me.Clicks == 1 && clicked_item != null)
+ owner.OnClick (EventArgs.Empty);
+ } else if (owner.selected_indices.Count > 0) {
+ // Raise the event if there was at least one item
+ // selected and the user click on a dead area (unselecting all)
+ owner.SelectedItems.Clear ();
+ owner.SelectedIndices.list.Clear ();
+ owner.OnSelectedIndexChanged (EventArgs.Empty);
+ }
+ }
+
+ private void ItemsMouseMove (object sender, MouseEventArgs me)
+ {
+ if (owner.HoverSelection && hover_processed) {
+
+ Point pt = PointToClient (Control.MousePosition);
+ ListViewItem item = owner.GetItemAt (pt.X, pt.Y);
+ if (item == null || item.Selected)
+ return;
+
+ hover_processed = false;
+ XplatUI.ResetMouseHover (Handle);
+ }
+ }
+
+
+ private void ItemsMouseHover (object sender, EventArgs e)
+ {
+ if (Capture || !owner.HoverSelection)
+ return;
+
+ hover_processed = true;
+ Point pt = PointToClient (Control.MousePosition);
+ ListViewItem item = owner.GetItemAt (pt.X, pt.Y);
+
+ if (item == null)
+ return;
+
+ item.Selected = true;
+ owner.OnSelectedIndexChanged (new EventArgs ());
+ }
+
+ private void ItemsMouseUp (object sender, MouseEventArgs me)
+ {
+ Capture = false;
+ if (owner.Items.Count == 0)
+ return;
+
+ Point pt = new Point (me.X, me.Y);
+
+ Rectangle rect = Rectangle.Empty;
+ if (clicked_item != null) {
+ if (owner.view == View.Details && !owner.full_row_select)
+ rect = clicked_item.GetBounds (ItemBoundsPortion.Label);
+ else
+ rect = clicked_item.Bounds;
+
+ if (rect.Contains (pt)) {
+ switch (owner.activation) {
+ case ItemActivation.OneClick:
+ owner.OnItemActivate (EventArgs.Empty);
+ break;
+
+ case ItemActivation.TwoClick:
+ if (last_clicked_item == clicked_item) {
+ owner.OnItemActivate (EventArgs.Empty);
+ last_clicked_item = null;
+ } else
+ last_clicked_item = clicked_item;
+ break;
+ default:
+ // DoubleClick activation is handled in another handler
+ break;
+ }
+ }
+ }
+
+ clicked_item = null;
+ }
+
+ private void ItemsMouseWheel (object sender, MouseEventArgs me)
+ {
+ if (owner.Items.Count == 0)
+ return;
+
+ int lines = me.Delta / 120;
+
+ if (lines == 0)
+ return;
+
+ switch (owner.View) {
+ case View.Details:
+ case View.SmallIcon:
+ owner.Scroll (owner.v_scroll, -owner.Items [0].Bounds.Height * SystemInformation.MouseWheelScrollLines * lines);
+ break;
+ case View.LargeIcon:
+ owner.Scroll (owner.v_scroll, -(owner.Items [0].Bounds.Height + ThemeEngine.Current.ListViewVerticalSpacing) * lines);
+ break;
+ case View.List:
+ owner.Scroll (owner.h_scroll, -owner.Items [0].Bounds.Width * lines);
+ break;
+ }
+ }
+
+ private void ItemsPaint (object sender, PaintEventArgs pe)
+ {
+ ThemeEngine.Current.DrawListViewItems (pe.Graphics, pe.ClipRectangle, owner);
+ }
+ }
+
+ private void ListView_Paint (object sender, PaintEventArgs pe)
+ {
+ if (Width <= 0 || Height <= 0 || !Visible || updating)
+ return;
+
+ CalculateScrollBars ();
+ }
+
+ private void ListView_SizeChanged (object sender, EventArgs e)
+ {
+ CalculateListView (alignment);
+ }
+
+ private void SetFocusedItem (ListViewItem item)
+ {
+ if (focused_item != null)
+ focused_item.Focused = false;
+
+ if (item != null)
+ item.Focused = true;
+
+ focused_item = item;
+ }
+
+ private void HorizontalScroller (object sender, EventArgs e)
+ {
+ // Avoid unnecessary flickering, when button is
+ // kept pressed at the end
+ if (h_marker != h_scroll.Value) {
+
+ int pixels = h_marker - h_scroll.Value;
+
+ h_marker = h_scroll.Value;
+ if (header_control.Visible)
+ XplatUI.ScrollWindow (header_control.Handle, pixels, 0, false);
+
+ XplatUI.ScrollWindow (item_control.Handle, pixels, 0, false);
+ }
+ }
+
+ private void VerticalScroller (object sender, EventArgs e)
+ {
+ // Avoid unnecessary flickering, when button is
+ // kept pressed at the end
+ if (v_marker != v_scroll.Value) {
+ int pixels = v_marker - v_scroll.Value;
+ Rectangle area = item_control.ClientRectangle;
+ v_marker = v_scroll.Value;
+ XplatUI.ScrollWindow (item_control.Handle, area, 0, pixels, false);
+ }
+ }
+ #endregion // Internal Methods Properties
+
+ #region Protected Methods
+ protected override void CreateHandle ()
+ {
+ base.CreateHandle ();
+ }
+
+ protected override void Dispose (bool disposing)
+ {
+ if (disposing) {
+ h_scroll.Dispose ();
+ v_scroll.Dispose ();
+
+ large_image_list = null;
+ small_image_list = null;
+ state_image_list = null;
+ }
+
+ base.Dispose (disposing);
+ }
+
+ protected override bool IsInputKey (Keys keyData)
+ {
+ switch (keyData) {
+ case Keys.Up:
+ case Keys.Down:
+ case Keys.PageUp:
+ case Keys.PageDown:
+ case Keys.Right:
+ case Keys.Left:
+ case Keys.End:
+ case Keys.Home:
+ return true;
+
+ default:
+ break;
+ }
+
+ return base.IsInputKey (keyData);
+ }
+
+ protected virtual void OnAfterLabelEdit (LabelEditEventArgs e)
+ {
+ if (AfterLabelEdit != null)
+ AfterLabelEdit (this, e);
+ }
+
+ protected virtual void OnBeforeLabelEdit (LabelEditEventArgs e)
+ {
+ if (BeforeLabelEdit != null)
+ BeforeLabelEdit (this, e);
+ }
+
+ protected virtual void OnColumnClick (ColumnClickEventArgs e)
+ {
+ if (ColumnClick != null)
+ ColumnClick (this, e);
+ }
+
+ protected override void OnEnabledChanged (EventArgs e)
+ {
+ base.OnEnabledChanged (e);
+ }
+
+ protected override void OnFontChanged (EventArgs e)
+ {
+ base.OnFontChanged (e);
+ Redraw (true);
+ }
+
+ protected override void OnHandleCreated (EventArgs e)
+ {
+ base.OnHandleCreated (e);
+ SuspendLayout ();
+ Controls.AddImplicit (header_control);
+ Controls.AddImplicit (item_control);
+ Controls.AddImplicit (this.v_scroll);
+ Controls.AddImplicit (this.h_scroll);
+ ResumeLayout ();
+ }
+
+ protected override void OnHandleDestroyed (EventArgs e)
+ {
+ base.OnHandleDestroyed (e);
+ }
+
+ protected virtual void OnItemActivate (EventArgs e)
+ {
+ if (ItemActivate != null)
+ ItemActivate (this, e);
+ }
+
+ protected virtual void OnItemCheck (ItemCheckEventArgs ice)
+ {
+ if (ItemCheck != null)
+ ItemCheck (this, ice);
+ }
+
+ protected virtual void OnItemDrag (ItemDragEventArgs e)
+ {
+ if (ItemDrag != null)
+ ItemDrag (this, e);
+ }
+
+ protected virtual void OnSelectedIndexChanged (EventArgs e)
+ {
+ if (SelectedIndexChanged != null)
+ SelectedIndexChanged (this, e);
+ }
+
+ protected override void OnSystemColorsChanged (EventArgs e)
+ {
+ base.OnSystemColorsChanged (e);
+ }
+
+ protected void RealizeProperties ()
+ {
+ // FIXME: TODO
+ }
+
+ protected void UpdateExtendedStyles ()
+ {
+ // FIXME: TODO
+ }
+
+ protected override void WndProc (ref Message m)
+ {
+ base.WndProc (ref m);
+ }
+ #endregion // Protected Methods
+
+ #region Public Instance Methods
+ public void ArrangeIcons ()
+ {
+ ArrangeIcons (this.alignment);
+ }
+
+ public void ArrangeIcons (ListViewAlignment alignment)
+ {
+ // Icons are arranged only if view is set to LargeIcon or SmallIcon
+ if (view == View.LargeIcon || view == View.SmallIcon) {
+ this.CalculateListView (alignment);
+ // we have done the calculations already
+ this.Redraw (false);
+ }
+ }
+
+ public void BeginUpdate ()
+ {
+ // flag to avoid painting
+ updating = true;
+ }
+
+ public void Clear ()
+ {
+ columns.Clear ();
+ items.Clear (); // Redraw (true) called here
+ }
+
+ public void EndUpdate ()
+ {
+ // flag to avoid painting
+ updating = false;
+
+ // probably, now we need a redraw with recalculations
+ this.Redraw (true);
+ }
+
+ public void EnsureVisible (int index)
+ {
+ if (index < 0 || index >= items.Count || scrollable == false)
+ return;
+
+ Rectangle view_rect = item_control.ClientRectangle;
+ Rectangle bounds = items [index].Bounds;
+
+ if (view_rect.Contains (bounds))
+ return;
+
+ if (bounds.Left < 0)
+ h_scroll.Value += bounds.Left;
+ else if (bounds.Right > view_rect.Right)
+ h_scroll.Value += (bounds.Right - view_rect.Right);
+
+ if (bounds.Top < 0)
+ v_scroll.Value += bounds.Top;
+ else if (bounds.Bottom > view_rect.Bottom)
+ v_scroll.Value += (bounds.Bottom - view_rect.Bottom);
+ }
+
+ public ListViewItem GetItemAt (int x, int y)
+ {
+ foreach (ListViewItem item in items) {
+ if (item.Bounds.Contains (x, y))
+ return item;
+ }
+ return null;
+ }
+
+ public Rectangle GetItemRect (int index)
+ {
+ return GetItemRect (index, ItemBoundsPortion.Entire);
+ }
+
+ public Rectangle GetItemRect (int index, ItemBoundsPortion portion)
+ {
+ if (index < 0 || index >= items.Count)
+ throw new IndexOutOfRangeException ("Invalid Index");
+
+ return items [index].GetBounds (portion);
+ }
+
+ public void Sort ()
+ {
+ if (sort_order != SortOrder.None)
+ items.list.Sort (item_sorter);
+
+ if (sort_order == SortOrder.Descending)
+ items.list.Reverse ();
+
+ this.Redraw (true);
+ }
+
+ public override string ToString ()
+ {
+ int count = this.Items.Count;
+
+ if (count == 0)
+ return string.Format ("System.Windows.Forms.ListView, Items.Count: 0");
+ else
+ return string.Format ("System.Windows.Forms.ListView, Items.Count: {0}, Items[0]: {1}", count, this.Items [0].ToString ());
+ }
+ #endregion // Public Instance Methods
+
+
+ #region Subclasses
+
+ class HeaderControl : Control {
+
+ ListView owner;
+ bool column_resize_active = false;
+ ColumnHeader resize_column;
+ ColumnHeader clicked_column;
+ ColumnHeader drag_column;
+ int drag_x;
+ int drag_to_index = -1;
+
+ public HeaderControl (ListView owner)
+ {
+ this.owner = owner;
+ MouseDown += new MouseEventHandler (HeaderMouseDown);
+ MouseMove += new MouseEventHandler (HeaderMouseMove);
+ MouseUp += new MouseEventHandler (HeaderMouseUp);
+ Paint += new PaintEventHandler (HeaderPaint);
+ }
+
+ private ColumnHeader ColumnAtX (int x)
+ {
+ Point pt = new Point (x, 0);
+ ColumnHeader result = null;
+ foreach (ColumnHeader col in owner.Columns) {
+ if (col.Rect.Contains (pt)) {
+ result = col;
+ break;
+ }
+ }
+ return result;
+ }
+
+ private int GetReorderedIndex (ColumnHeader col)
+ {
+ if (owner.reordered_column_indices == null)
+ return col.Index;
+ else
+ for (int i = 0; i < owner.Columns.Count; i++)
+ if (owner.reordered_column_indices [i] == col.Index)
+ return i;
+ throw new Exception ("Column index missing from reordered array");
+ }
+
+ private void HeaderMouseDown (object sender, MouseEventArgs me)
+ {
+ if (resize_column != null) {
+ column_resize_active = true;
+ Capture = true;
+ return;
+ }
+
+ clicked_column = ColumnAtX (me.X + owner.h_marker);
+
+ if (clicked_column != null) {
+ Capture = true;
+ if (owner.AllowColumnReorder) {
+ drag_x = me.X;
+ drag_column = (ColumnHeader) clicked_column.Clone ();
+ drag_column.column_rect = clicked_column.Rect;
+ drag_to_index = GetReorderedIndex (clicked_column);
+ }
+ clicked_column.pressed = true;
+ Rectangle bounds = clicked_column.Rect;
+ bounds.X -= owner.h_marker;
+ Invalidate (bounds);
+ return;
+ }
+ }
+
+ private void HeaderMouseMove (object sender, MouseEventArgs me)
+ {
+ Point pt = new Point (me.X + owner.h_marker, me.Y);
+
+ if (column_resize_active) {
+ resize_column.Width = pt.X - resize_column.X;
+ if (resize_column.Width < 0)
+ resize_column.Width = 0;
+ return;
+ }
+
+ resize_column = null;
+
+ if (clicked_column != null) {
+ if (owner.AllowColumnReorder) {
+ Rectangle r;
+
+ r = drag_column.column_rect;
+ r.X = clicked_column.Rect.X + me.X - drag_x;
+ drag_column.column_rect = r;
+
+ int x = me.X + owner.h_marker;
+ ColumnHeader over = ColumnAtX (x);
+ if (x < over.X + over.Width / 2)
+ drag_to_index = GetReorderedIndex (over);
+ else
+ drag_to_index = GetReorderedIndex (over) + 1;
+ Invalidate ();
+ } else {
+ ColumnHeader over = ColumnAtX (me.X + owner.h_marker);
+ bool pressed = clicked_column.pressed;
+ clicked_column.pressed = over == clicked_column;
+ if (clicked_column.pressed ^ pressed) {
+ Rectangle bounds = clicked_column.Rect;
+ bounds.X -= owner.h_marker;
+ Invalidate (bounds);
+ }
+ }
+ return;
+ }
+
+ for (int i = 0; i < owner.Columns.Count; i++) {
+ Rectangle zone = owner.Columns [i].Rect;
+ zone.X = zone.Right - 5;
+ zone.Width = 10;
+ if (zone.Contains (pt)) {
+ resize_column = owner.Columns [i];
+ break;
+ }
+ }
+
+ if (resize_column == null)
+ Cursor = Cursors.Default;
+ else
+ Cursor = Cursors.VSplit;
+ }
+
+ void HeaderMouseUp (object sender, MouseEventArgs me)
+ {
+ Capture = false;
+
+ if (column_resize_active) {
+ column_resize_active = false;
+ resize_column = null;
+ Cursor = Cursors.Default;
+ return;
+ }
+
+ if (clicked_column != null && clicked_column.pressed) {
+ clicked_column.pressed = false;
+ Rectangle bounds = clicked_column.Rect;
+ bounds.X -= owner.h_marker;
+ Invalidate (bounds);
+ owner.OnColumnClick (new ColumnClickEventArgs (clicked_column.Index));
+ }
+
+ if (drag_column != null && owner.AllowColumnReorder) {
+ drag_column = null;
+ if (drag_to_index > GetReorderedIndex (clicked_column))
+ drag_to_index--;
+ if (owner.GetReorderedColumn (drag_to_index) != clicked_column)
+ owner.ReorderColumn (clicked_column, drag_to_index);
+ drag_to_index = -1;
+ Invalidate ();
+ }
+
+ clicked_column = null;
+ }
+
+ void HeaderPaint (object sender, PaintEventArgs pe)
+ {
+ if (Width <= 0 || Height <= 0 || !Visible || owner.updating)
+ return;
+
+ Theme theme = ThemeEngine.Current;
+ theme.DrawListViewHeader (pe.Graphics, pe.ClipRectangle, this.owner);
+
+ if (drag_column == null)
+ return;
+
+ int target_x;
+ if (drag_to_index == owner.Columns.Count)
+ target_x = owner.GetReorderedColumn (drag_to_index - 1).Rect.Right - owner.h_marker;
+ else
+ target_x = owner.GetReorderedColumn (drag_to_index).Rect.X - owner.h_marker;
+ theme.DrawListViewHeaderDragDetails (pe.Graphics, owner, drag_column, target_x);
+ }
+
+ }
+
+ public class CheckedIndexCollection : IList, ICollection, IEnumerable
+ {
+ internal ArrayList list;
+ private ListView owner;
+
+ #region Public Constructor
+ public CheckedIndexCollection (ListView owner)
+ {
+ list = new ArrayList ();
+ this.owner = owner;
+ }
+ #endregion // Public Constructor
+
+ #region Public Properties
+ [Browsable (false)]
+ public virtual int Count {
+ get { return list.Count; }
+ }
+
+ public virtual bool IsReadOnly {
+ get { return true; }
+ }
+
+ public int this [int index] {
+ get {
+ if (index < 0 || index >= list.Count)
+ throw new ArgumentOutOfRangeException ("Index out of range.");
+ return (int) list [index];
+ }
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return false; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return this; }
+ }
+
+ bool IList.IsFixedSize {
+ get { return true; }
+ }
+
+ object IList.this [int index] {
+ get { return this [index]; }
+ set { throw new NotSupportedException ("SetItem operation is not supported."); }
+ }
+ #endregion // Public Properties
+
+ #region Public Methods
+ public bool Contains (int checkedIndex)
+ {
+ return list.Contains (checkedIndex);
+ }
+
+ public virtual IEnumerator GetEnumerator ()
+ {
+ return list.GetEnumerator ();
+ }
+
+ void ICollection.CopyTo (Array dest, int index)
+ {
+ list.CopyTo (dest, index);
+ }
+
+ int IList.Add (object value)
+ {
+ throw new NotSupportedException ("Add operation is not supported.");
+ }
+
+ void IList.Clear ()
+ {
+ throw new NotSupportedException ("Clear operation is not supported.");
+ }
+
+ bool IList.Contains (object checkedIndex)
+ {
+ return list.Contains (checkedIndex);
+ }
+
+ int IList.IndexOf (object checkedIndex)
+ {
+ return list.IndexOf (checkedIndex);
+ }
+
+ void IList.Insert (int index, object value)
+ {
+ throw new NotSupportedException ("Insert operation is not supported.");
+ }
+
+ void IList.Remove (object value)
+ {
+ throw new NotSupportedException ("Remove operation is not supported.");
+ }
+
+ void IList.RemoveAt (int index)
+ {
+ throw new NotSupportedException ("RemoveAt operation is not supported.");
+ }
+
+ public int IndexOf (int checkedIndex)
+ {
+ return list.IndexOf (checkedIndex);
+ }
+ #endregion // Public Methods
+
+ } // CheckedIndexCollection
+
+ public class CheckedListViewItemCollection : IList, ICollection, IEnumerable
+ {
+ internal ArrayList list;
+ private ListView owner;
+
+ #region Public Constructor
+ public CheckedListViewItemCollection (ListView owner)
+ {
+ list = new ArrayList ();
+ this.owner = owner;
+ }
+ #endregion // Public Constructor
+
+ #region Public Properties
+ [Browsable (false)]
+ public virtual int Count {
+ get { return list.Count; }
+ }
+
+ public virtual bool IsReadOnly {
+ get { return true; }
+ }
+
+ public ListViewItem this [int index] {
+ get {
+ if (index < 0 || index >= list.Count)
+ throw new ArgumentOutOfRangeException ("Index out of range.");
+ return (ListViewItem) list [index];
+ }
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return list.IsSynchronized; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return this; }
+ }
+
+ bool IList.IsFixedSize {
+ get { return true; }
+ }
+
+ object IList.this [int index] {
+ get { return this [index]; }
+ set { throw new NotSupportedException ("SetItem operation is not supported."); }
+ }
+ #endregion // Public Properties
+
+ #region Public Methods
+ public bool Contains (ListViewItem item)
+ {
+ return list.Contains (item);
+ }
+
+ public virtual void CopyTo (Array dest, int index)
+ {
+ list.CopyTo (dest, index);
+ }
+
+ public virtual IEnumerator GetEnumerator ()
+ {
+ return list.GetEnumerator ();
+ }
+
+ int IList.Add (object value)
+ {
+ throw new NotSupportedException ("Add operation is not supported.");
+ }
+
+ void IList.Clear ()
+ {
+ throw new NotSupportedException ("Clear operation is not supported.");
+ }
+
+ bool IList.Contains (object item)
+ {
+ return list.Contains (item);
+ }
+
+ int IList.IndexOf (object item)
+ {
+ return list.IndexOf (item);
+ }
+
+ void IList.Insert (int index, object value)
+ {
+ throw new NotSupportedException ("Insert operation is not supported.");
+ }
+
+ void IList.Remove (object value)
+ {
+ throw new NotSupportedException ("Remove operation is not supported.");
+ }
+
+ void IList.RemoveAt (int index)
+ {
+ throw new NotSupportedException ("RemoveAt operation is not supported.");
+ }
+
+ public int IndexOf (ListViewItem item)
+ {
+ return list.IndexOf (item);
+ }
+ #endregion // Public Methods
+
+ } // CheckedListViewItemCollection
+
+ public class ColumnHeaderCollection : IList, ICollection, IEnumerable
+ {
+ internal ArrayList list;
+ private ListView owner;
+
+ #region Public Constructor
+ public ColumnHeaderCollection (ListView owner)
+ {
+ list = new ArrayList ();
+ this.owner = owner;
+ }
+ #endregion // Public Constructor
+
+ #region Public Properties
+ [Browsable (false)]
+ public virtual int Count {
+ get { return list.Count; }
+ }
+
+ public virtual bool IsReadOnly {
+ get { return false; }
+ }
+
+ public virtual ColumnHeader this [int index] {
+ get {
+ if (index < 0 || index >= list.Count)
+ throw new ArgumentOutOfRangeException ("Index out of range.");
+ return (ColumnHeader) list [index];
+ }
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return true; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return this; }
+ }
+
+ bool IList.IsFixedSize {
+ get { return list.IsFixedSize; }
+ }
+
+ object IList.this [int index] {
+ get { return this [index]; }
+ set { throw new NotSupportedException ("SetItem operation is not supported."); }
+ }
+ #endregion // Public Properties
+
+ #region Public Methods
+ public virtual int Add (ColumnHeader value)
+ {
+ int idx;
+ value.owner = this.owner;
+ idx = list.Add (value);
+ owner.Redraw (true);
+ return idx;
+ }
+
+ public virtual ColumnHeader Add (string str, int width, HorizontalAlignment textAlign)
+ {
+ ColumnHeader colHeader = new ColumnHeader (this.owner, str, textAlign, width);
+ this.Add (colHeader);
+ return colHeader;
+ }
+
+ public virtual void AddRange (ColumnHeader [] values)
+ {
+ foreach (ColumnHeader colHeader in values) {
+ colHeader.owner = this.owner;
+ Add (colHeader);
+ }
+
+ owner.Redraw (true);
+ }
+
+ public virtual void Clear ()
+ {
+ list.Clear ();
+ owner.Redraw (true);
+ }
+
+ public bool Contains (ColumnHeader value)
+ {
+ return list.Contains (value);
+ }
+
+ public virtual IEnumerator GetEnumerator ()
+ {
+ return list.GetEnumerator ();
+ }
+
+ void ICollection.CopyTo (Array dest, int index)
+ {
+ list.CopyTo (dest, index);
+ }
+
+ int IList.Add (object value)
+ {
+ if (! (value is ColumnHeader)) {
+ throw new ArgumentException ("Not of type ColumnHeader", "value");
+ }
+
+ return this.Add ((ColumnHeader) value);
+ }
+
+ bool IList.Contains (object value)
+ {
+ if (! (value is ColumnHeader)) {
+ throw new ArgumentException ("Not of type ColumnHeader", "value");
+ }
+
+ return this.Contains ((ColumnHeader) value);
+ }
+
+ int IList.IndexOf (object value)
+ {
+ if (! (value is ColumnHeader)) {
+ throw new ArgumentException ("Not of type ColumnHeader", "value");
+ }
+
+ return this.IndexOf ((ColumnHeader) value);
+ }
+
+ void IList.Insert (int index, object value)
+ {
+ if (! (value is ColumnHeader)) {
+ throw new ArgumentException ("Not of type ColumnHeader", "value");
+ }
+
+ this.Insert (index, (ColumnHeader) value);
+ }
+
+ void IList.Remove (object value)
+ {
+ if (! (value is ColumnHeader)) {
+ throw new ArgumentException ("Not of type ColumnHeader", "value");
+ }
+
+ this.Remove ((ColumnHeader) value);
+ }
+
+ public int IndexOf (ColumnHeader value)
+ {
+ return list.IndexOf (value);
+ }
+
+ public void Insert (int index, ColumnHeader value)
+ {
+ // LAMESPEC: MSDOCS say greater than or equal to the value of the Count property
+ // but it's really only greater.
+ if (index < 0 || index > list.Count)
+ throw new ArgumentOutOfRangeException ("Index out of range.");
+
+ value.owner = this.owner;
+ list.Insert (index, value);
+ owner.Redraw (true);
+ }
+
+ public void Insert (int index, string str, int width, HorizontalAlignment textAlign)
+ {
+ ColumnHeader colHeader = new ColumnHeader (this.owner, str, textAlign, width);
+ this.Insert (index, colHeader);
+ }
+
+ public virtual void Remove (ColumnHeader column)
+ {
+ // TODO: Update Column internal index ?
+ list.Remove (column);
+ owner.Redraw (true);
+ }
+
+ public virtual void RemoveAt (int index)
+ {
+ if (index < 0 || index >= list.Count)
+ throw new ArgumentOutOfRangeException ("Index out of range.");
+
+ // TODO: Update Column internal index ?
+ list.RemoveAt (index);
+ owner.Redraw (true);
+ }
+ #endregion // Public Methods
+
+
+ } // ColumnHeaderCollection
+
+ public class ListViewItemCollection : IList, ICollection, IEnumerable
+ {
+ internal ArrayList list;
+ private ListView owner;
+
+ #region Public Constructor
+ public ListViewItemCollection (ListView owner)
+ {
+ list = new ArrayList ();
+ this.owner = owner;
+ }
+ #endregion // Public Constructor
+
+ #region Public Properties
+ [Browsable (false)]
+ public virtual int Count {
+ get { return list.Count; }
+ }
+
+ public virtual bool IsReadOnly {
+ get { return false; }
+ }
+
+ public virtual ListViewItem this [int displayIndex] {
+ get {
+ if (displayIndex < 0 || displayIndex >= list.Count)
+ throw new ArgumentOutOfRangeException ("Index out of range.");
+ return (ListViewItem) list [displayIndex];
+ }
+
+ set {
+ if (displayIndex < 0 || displayIndex >= list.Count)
+ throw new ArgumentOutOfRangeException ("Index out of range.");
+
+ if (list.Contains (value))
+ throw new ArgumentException ("An item cannot be added more than once. To add an item again, you need to clone it.", "value");
+
+ value.Owner = owner;
+ list [displayIndex] = value;
+
+ owner.Redraw (true);
+ }
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return true; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return this; }
+ }
+
+ bool IList.IsFixedSize {
+ get { return list.IsFixedSize; }
+ }
+
+ object IList.this [int index] {
+ get { return this [index]; }
+ set {
+ if (value is ListViewItem)
+ this [index] = (ListViewItem) value;
+ else
+ this [index] = new ListViewItem (value.ToString ());
+ }
+ }
+ #endregion // Public Properties
+
+ #region Public Methods
+ public virtual ListViewItem Add (ListViewItem value)
+ {
+ if (list.Contains (value))
+ throw new ArgumentException ("An item cannot be added more than once. To add an item again, you need to clone it.", "value");
+
+ value.Owner = owner;
+ list.Add (value);
+
+ if (owner.Sorting != SortOrder.None)
+ owner.Sort ();
+
+ owner.Redraw (true);
+
+ return value;
+ }
+
+ public virtual ListViewItem Add (string text)
+ {
+ ListViewItem item = new ListViewItem (text);
+ return this.Add (item);
+ }
+
+ public virtual ListViewItem Add (string text, int imageIndex)
+ {
+ ListViewItem item = new ListViewItem (text, imageIndex);
+ return this.Add (item);
+ }
+
+ public void AddRange (ListViewItem [] values)
+ {
+ list.Clear ();
+ owner.SelectedItems.list.Clear ();
+ owner.SelectedIndices.list.Clear ();
+ owner.CheckedItems.list.Clear ();
+ owner.CheckedIndices.list.Clear ();
+
+ foreach (ListViewItem item in values) {
+ item.Owner = owner;
+ list.Add (item);
+ }
+
+ if (owner.Sorting != SortOrder.None)
+ owner.Sort ();
+
+ owner.Redraw (true);
+ }
+
+ public virtual void Clear ()
+ {
+ owner.SetFocusedItem (null);
+ owner.h_scroll.Value = owner.v_scroll.Value = 0;
+ list.Clear ();
+ owner.SelectedItems.list.Clear ();
+ owner.SelectedIndices.list.Clear ();
+ owner.CheckedItems.list.Clear ();
+ owner.CheckedIndices.list.Clear ();
+ owner.Redraw (true);
+ }
+
+ public bool Contains (ListViewItem item)
+ {
+ return list.Contains (item);
+ }
+
+ public virtual void CopyTo (Array dest, int index)
+ {
+ list.CopyTo (dest, index);
+ }
+
+ public virtual IEnumerator GetEnumerator ()
+ {
+ return list.GetEnumerator ();
+ }
+
+ int IList.Add (object item)
+ {
+ int result;
+ ListViewItem li;
+
+ if (item is ListViewItem) {
+ li = (ListViewItem) item;
+ if (list.Contains (li))
+ throw new ArgumentException ("An item cannot be added more than once. To add an item again, you need to clone it.", "item");
+ }
+ else
+ li = new ListViewItem (item.ToString ());
+
+ li.Owner = owner;
+ result = list.Add (li);
+ owner.Redraw (true);
+
+ return result;
+ }
+
+ bool IList.Contains (object item)
+ {
+ return list.Contains (item);
+ }
+
+ int IList.IndexOf (object item)
+ {
+ return list.IndexOf (item);
+ }
+
+ void IList.Insert (int index, object item)
+ {
+ if (item is ListViewItem)
+ this.Insert (index, (ListViewItem) item);
+ else
+ this.Insert (index, item.ToString ());
+ }
+
+ void IList.Remove (object item)
+ {
+ Remove ((ListViewItem) item);
+ }
+
+ public int IndexOf (ListViewItem item)
+ {
+ return list.IndexOf (item);
+ }
+
+ public ListViewItem Insert (int index, ListViewItem item)
+ {
+ // LAMESPEC: MSDOCS say greater than or equal to the value of the Count property
+ // but it's really only greater.
+ if (index < 0 || index > list.Count)
+ throw new ArgumentOutOfRangeException ("Index out of range.");
+
+ if (list.Contains (item))
+ throw new ArgumentException ("An item cannot be added more than once. To add an item again, you need to clone it.", "item");
+
+ item.Owner = owner;
+ list.Insert (index, item);
+ owner.Redraw (true);
+ return item;
+ }
+
+ public ListViewItem Insert (int index, string text)
+ {
+ return this.Insert (index, new ListViewItem (text));
+ }
+
+ public ListViewItem Insert (int index, string text, int imageIndex)
+ {
+ return this.Insert (index, new ListViewItem (text, imageIndex));
+ }
+
+ public virtual void Remove (ListViewItem item)
+ {
+ if (!list.Contains (item))
+ return;
+
+ owner.SelectedItems.list.Remove (item);
+ owner.SelectedIndices.list.Remove (item.Index);
+ owner.CheckedItems.list.Remove (item);
+ owner.CheckedIndices.list.Remove (item.Index);
+ list.Remove (item);
+ owner.Redraw (true);
+ }
+
+ public virtual void RemoveAt (int index)
+ {
+ if (index < 0 || index >= list.Count)
+ throw new ArgumentOutOfRangeException ("Index out of range.");
+
+ list.RemoveAt (index);
+ owner.SelectedItems.list.RemoveAt (index);
+ owner.SelectedIndices.list.RemoveAt (index);
+ owner.CheckedItems.list.RemoveAt (index);
+ owner.CheckedIndices.list.RemoveAt (index);
+ owner.Redraw (false);
+ }
+ #endregion // Public Methods
+
+ } // ListViewItemCollection
+
+ public class SelectedIndexCollection : IList, ICollection, IEnumerable
+ {
+ internal ArrayList list;
+ private ListView owner;
+
+ #region Public Constructor
+ public SelectedIndexCollection (ListView owner)
+ {
+ list = new ArrayList ();
+ this.owner = owner;
+ }
+ #endregion // Public Constructor
+
+ #region Public Properties
+ [Browsable (false)]
+ public virtual int Count {
+ get { return list.Count; }
+ }
+
+ public virtual bool IsReadOnly {
+ get { return true; }
+ }
+
+ public int this [int index] {
+ get {
+ if (index < 0 || index >= list.Count)
+ throw new ArgumentOutOfRangeException ("Index out of range.");
+ return (int) list [index];
+ }
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return list.IsSynchronized; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return this; }
+ }
+
+ bool IList.IsFixedSize {
+ get { return true; }
+ }
+
+ object IList.this [int index] {
+ get { return this [index]; }
+ set { throw new NotSupportedException ("SetItem operation is not supported."); }
+ }
+ #endregion // Public Properties
+
+ #region Public Methods
+ public bool Contains (int selectedIndex)
+ {
+ return list.Contains (selectedIndex);
+ }
+
+ public virtual void CopyTo (Array dest, int index)
+ {
+ list.CopyTo (dest, index);
+ }
+
+ public virtual IEnumerator GetEnumerator ()
+ {
+ return list.GetEnumerator ();
+ }
+
+ int IList.Add (object value)
+ {
+ throw new NotSupportedException ("Add operation is not supported.");
+ }
+
+ void IList.Clear ()
+ {
+ throw new NotSupportedException ("Clear operation is not supported.");
+ }
+
+ bool IList.Contains (object selectedIndex)
+ {
+ return list.Contains (selectedIndex);
+ }
+
+ int IList.IndexOf (object selectedIndex)
+ {
+ return list.IndexOf (selectedIndex);
+ }
+
+ void IList.Insert (int index, object value)
+ {
+ throw new NotSupportedException ("Insert operation is not supported.");
+ }
+
+ void IList.Remove (object value)
+ {
+ throw new NotSupportedException ("Remove operation is not supported.");
+ }
+
+ void IList.RemoveAt (int index)
+ {
+ throw new NotSupportedException ("RemoveAt operation is not supported.");
+ }
+
+ public int IndexOf (int selectedIndex)
+ {
+ return list.IndexOf (selectedIndex);
+ }
+ #endregion // Public Methods
+
+ } // SelectedIndexCollection
+
+ public class SelectedListViewItemCollection : IList, ICollection, IEnumerable
+ {
+ internal ArrayList list;
+ private ListView owner;
+
+ #region Public Constructor
+ public SelectedListViewItemCollection (ListView owner)
+ {
+ list = new ArrayList ();
+ this.owner = owner;
+ }
+ #endregion // Public Constructor
+
+ #region Public Properties
+ [Browsable (false)]
+ public virtual int Count {
+ get { return list.Count; }
+ }
+
+ public virtual bool IsReadOnly {
+ get { return true; }
+ }
+
+ public ListViewItem this [int index] {
+ get {
+ if (index < 0 || index >= list.Count)
+ throw new ArgumentOutOfRangeException ("Index out of range.");
+ return (ListViewItem) list [index];
+ }
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return list.IsSynchronized; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return this; }
+ }
+
+ bool IList.IsFixedSize {
+ get { return true; }
+ }
+
+ object IList.this [int index] {
+ get { return this [index]; }
+ set { throw new NotSupportedException ("SetItem operation is not supported."); }
+ }
+ #endregion // Public Properties
+
+ #region Public Methods
+ public virtual void Clear ()
+ {
+ ArrayList copy = (ArrayList) list.Clone ();
+ for (int i = 0; i < copy.Count; i++)
+ ((ListViewItem) copy [i]).Selected = false;
+
+ list.Clear ();
+ }
+
+ public bool Contains (ListViewItem item)
+ {
+ return list.Contains (item);
+ }
+
+ public virtual void CopyTo (Array dest, int index)
+ {
+ list.CopyTo (dest, index);
+ }
+
+ public virtual IEnumerator GetEnumerator ()
+ {
+ return list.GetEnumerator ();
+ }
+
+ int IList.Add (object value)
+ {
+ throw new NotSupportedException ("Add operation is not supported.");
+ }
+
+ bool IList.Contains (object item)
+ {
+ return list.Contains (item);
+ }
+
+ int IList.IndexOf (object item)
+ {
+ return list.IndexOf (item);
+ }
+
+ void IList.Insert (int index, object value)
+ {
+ throw new NotSupportedException ("Insert operation is not supported.");
+ }
+
+ void IList.Remove (object value)
+ {
+ throw new NotSupportedException ("Remove operation is not supported.");
+ }
+
+ void IList.RemoveAt (int index)
+ {
+ throw new NotSupportedException ("RemoveAt operation is not supported.");
+ }
+
+ public int IndexOf (ListViewItem item)
+ {
+ return list.IndexOf (item);
+ }
+ #endregion // Public Methods
+
+ } // SelectedListViewItemCollection
+
+ #endregion // Subclasses
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewAlignment.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewAlignment.cs
new file mode 100644
index 00000000000..953877b8226
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewAlignment.cs
@@ -0,0 +1,37 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Ravindra (rkumar@novell.com)
+//
+
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public enum ListViewAlignment
+ {
+ Default = 0,
+ Left = 1,
+ Top = 2,
+ SnapToGrid = 5
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs
new file mode 100644
index 00000000000..3672af7c8a1
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs
@@ -0,0 +1,909 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+// Mike Kestner <mkestner@novell.com>
+
+
+
+// NOT COMPLETE
+
+
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.Serialization;
+
+namespace System.Windows.Forms
+{
+ [DefaultProperty ("Text")]
+ [DesignTimeVisible (false)]
+ [Serializable]
+ [ToolboxItem (false)]
+ [TypeConverter (typeof (ListViewItemConverter))]
+ public class ListViewItem : ICloneable, ISerializable
+ {
+ #region Instance Variables
+ private int image_index = -1;
+ private bool is_checked = false;
+ private bool is_focused = false;
+ private int state_image_index = -1;
+ private ListViewSubItemCollection sub_items;
+ private object tag;
+ private bool use_item_style = true;
+
+ Rectangle bounds;
+ Rectangle checkbox_rect; // calculated by CalcListViewItem method
+ Rectangle icon_rect;
+ Rectangle item_rect;
+ Rectangle label_rect;
+ ListView owner;
+ bool selected;
+
+ internal int row;
+ internal int col;
+
+ #endregion Instance Variables
+
+ #region Public Constructors
+ public ListViewItem ()
+ {
+ this.sub_items = new ListViewSubItemCollection (this);
+ this.sub_items.Add ("");
+ }
+
+ public ListViewItem (string text) : this (text, -1)
+ {
+ }
+
+ public ListViewItem (string [] items) : this (items, -1)
+ {
+ }
+
+ public ListViewItem (ListViewItem.ListViewSubItem [] subItems, int imageIndex)
+ {
+ this.sub_items = new ListViewSubItemCollection (this);
+ this.sub_items.AddRange (subItems);
+ this.image_index = imageIndex;
+ }
+
+ public ListViewItem (string text, int imageIndex)
+ {
+ this.image_index = imageIndex;
+ this.sub_items = new ListViewSubItemCollection (this);
+ this.sub_items.Add (text);
+ }
+
+ public ListViewItem (string [] items, int imageIndex)
+ {
+ this.sub_items = new ListViewSubItemCollection (this);
+ this.sub_items.AddRange (items);
+ this.image_index = imageIndex;
+ }
+
+ public ListViewItem (string [] items, int imageIndex, Color foreColor,
+ Color backColor, Font font)
+ {
+ this.sub_items = new ListViewSubItemCollection (this);
+ this.sub_items.AddRange (items);
+ this.image_index = imageIndex;
+ ForeColor = foreColor;
+ BackColor = backColor;
+ Font = font;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public Color BackColor {
+ get {
+ if (sub_items.Count > 0)
+ return sub_items[0].BackColor;
+
+ if (owner != null)
+ return owner.BackColor;
+
+ return ThemeEngine.Current.ColorWindow;
+ }
+
+ set { sub_items[0].BackColor = value; }
+ }
+
+ [Browsable (false)]
+ public Rectangle Bounds {
+ get {
+ return GetBounds (ItemBoundsPortion.Entire);
+ }
+ }
+
+ [DefaultValue (false)]
+ [RefreshProperties (RefreshProperties.Repaint)]
+ public bool Checked {
+ get { return is_checked; }
+ set {
+ if (is_checked == value)
+ return;
+
+ is_checked = value;
+
+ if (owner != null) {
+ if (is_checked) {
+ if (owner.CheckedItems.Contains (this) == false) {
+ owner.CheckedItems.list.Add (this);
+ owner.CheckedIndices.list.Add (this.Index);
+ }
+ }
+ else {
+ owner.CheckedItems.list.Remove (this);
+ owner.CheckedIndices.list.Remove (this.Index);
+ }
+
+ Layout ();
+ }
+ Invalidate ();
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public bool Focused {
+ get { return is_focused; }
+ set {
+ if (is_focused == value)
+ return;
+
+ is_focused = value;
+
+ if (owner != null)
+ Layout ();
+ Invalidate ();
+ }
+ }
+
+ [Localizable (true)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public Font Font {
+ get {
+ if (sub_items.Count > 0)
+ return sub_items[0].Font;
+
+ if (owner != null)
+ return owner.Font;
+
+ return ThemeEngine.Current.DefaultFont;
+ }
+ set {
+ if (sub_items[0].Font == value)
+ return;
+
+ sub_items[0].Font = value;
+
+ if (owner != null)
+ Layout ();
+ Invalidate ();
+ }
+ }
+
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public Color ForeColor {
+ get {
+ if (sub_items.Count > 0)
+ return sub_items[0].ForeColor;
+
+ if (owner != null)
+ return owner.ForeColor;
+
+ return ThemeEngine.Current.ColorWindowText;
+ }
+ set { sub_items[0].ForeColor = value; }
+ }
+
+ [DefaultValue (-1)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [Editor ("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design,
+ typeof (System.Drawing.Design.UITypeEditor))]
+ [Localizable (true)]
+ [TypeConverter (typeof (ImageIndexConverter))]
+ public int ImageIndex {
+ get { return image_index; }
+ set {
+ if (value < -1)
+ throw new ArgumentException ("Invalid ImageIndex. It must be greater than or equal to -1.");
+
+ image_index = value;
+
+ if (owner != null)
+ Layout ();
+ Invalidate ();
+ }
+ }
+
+ [Browsable (false)]
+ public ImageList ImageList {
+ get {
+ if (owner == null)
+ return null;
+ else if (owner.View == View.LargeIcon)
+ return owner.large_image_list;
+ else
+ return owner.small_image_list;
+ }
+ }
+
+ [Browsable (false)]
+ public int Index {
+ get {
+ if (owner == null)
+ return -1;
+ else
+ return owner.Items.IndexOf (this);
+ }
+ }
+
+ [Browsable (false)]
+ public ListView ListView {
+ get { return owner; }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public bool Selected {
+ get { return selected; }
+ set {
+ if (selected == value)
+ return;
+
+ selected = value;
+
+ if (owner != null) {
+ owner.UpdateSelection (this);
+ Layout ();
+ }
+ Invalidate ();
+ }
+ }
+
+ [DefaultValue (-1)]
+ [Editor ("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design,
+ typeof (System.Drawing.Design.UITypeEditor))]
+ [Localizable (true)]
+ [TypeConverter (typeof (ImageIndexConverter))]
+ public int StateImageIndex {
+ get { return state_image_index; }
+ set {
+ if (value < -1 || value > 14)
+ throw new ArgumentOutOfRangeException ("Invalid StateImageIndex. It must be in the range of [-1, 14].");
+
+ state_image_index = value;
+ }
+ }
+
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public ListViewSubItemCollection SubItems {
+ get { return sub_items; }
+ }
+
+ [Bindable (true)]
+ [DefaultValue (null)]
+ [Localizable (false)]
+ [TypeConverter (typeof (StringConverter))]
+ public object Tag {
+ get { return tag; }
+ set { tag = value; }
+ }
+
+ [Localizable (true)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public string Text {
+ get {
+ if (this.sub_items.Count > 0)
+ return this.sub_items [0].Text;
+ else
+ return "";
+ }
+ set {
+ if (sub_items [0].Text == value)
+ return;
+
+ sub_items [0].Text = value;
+
+ if (owner != null)
+ Layout ();
+ Invalidate ();
+ }
+ }
+
+ [DefaultValue (true)]
+ public bool UseItemStyleForSubItems {
+ get { return use_item_style; }
+ set { use_item_style = value; }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public void BeginEdit ()
+ {
+ // FIXME: TODO
+ // if (owner != null && owner.LabelEdit
+ // && owner.Activation == ItemActivation.Standard)
+ // allow editing
+ // else
+ // throw new InvalidOperationException ();
+ }
+
+ public virtual object Clone ()
+ {
+ ListViewItem clone = new ListViewItem ();
+ clone.image_index = this.image_index;
+ clone.is_checked = this.is_checked;
+ clone.is_focused = this.is_focused;
+ clone.selected = this.selected;
+ clone.state_image_index = this.state_image_index;
+ clone.sub_items = new ListViewSubItemCollection (this);
+
+ foreach (ListViewSubItem subItem in this.sub_items)
+ clone.sub_items.Add (subItem.Text, subItem.ForeColor,
+ subItem.BackColor, subItem.Font);
+ clone.tag = this.tag;
+ clone.use_item_style = this.use_item_style;
+ clone.owner = null;
+
+ return clone;
+ }
+
+ public virtual void EnsureVisible ()
+ {
+ if (this.owner != null) {
+ owner.EnsureVisible (owner.Items.IndexOf (this));
+ }
+ }
+
+ public Rectangle GetBounds (ItemBoundsPortion portion)
+ {
+ if (owner == null)
+ return Rectangle.Empty;
+
+ Rectangle rect;
+
+ switch (portion) {
+ case ItemBoundsPortion.Icon:
+ rect = icon_rect;
+ break;
+
+ case ItemBoundsPortion.Label:
+ rect = label_rect;
+ break;
+
+ case ItemBoundsPortion.ItemOnly:
+ rect = item_rect;
+ break;
+
+ case ItemBoundsPortion.Entire:
+ rect = bounds;
+ rect.X -= owner.h_marker;
+ rect.Y -= owner.v_marker;
+ return rect;
+
+ default:
+ throw new ArgumentException ("Invalid value for portion.");
+ }
+
+ rect.X += bounds.X - owner.h_marker;
+ rect.Y += bounds.Y - owner.v_marker;
+ return rect;
+ }
+
+ void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ // FIXME: TODO
+ }
+
+ public virtual void Remove ()
+ {
+ if (owner != null)
+ owner.Items.Remove (this);
+ owner = null;
+ }
+
+ public override string ToString ()
+ {
+ return string.Format ("ListViewItem: {0}", this.Text);
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Methods
+ protected virtual void Deserialize (SerializationInfo info, StreamingContext context)
+ {
+ // FIXME: TODO
+ }
+
+ protected virtual void Serialize (SerializationInfo info, StreamingContext context)
+ {
+ // FIXME: TODO
+ }
+ #endregion // Protected Methods
+
+ #region Private Internal Methods
+ internal Rectangle CheckRectReal {
+ get {
+ Rectangle rect = checkbox_rect;
+ rect.X += bounds.X - owner.h_marker;
+ rect.Y += bounds.Y - owner.v_marker;
+ return rect;
+ }
+ }
+
+ Rectangle CheckRect {
+ get { return this.checkbox_rect; }
+ }
+
+ Rectangle IconRect {
+ get { return this.icon_rect; }
+ }
+
+ Rectangle LabelRect {
+ get { return this.label_rect; }
+ }
+
+ internal Point Location {
+ set {
+ if (bounds.X == value.X && bounds.Y == value.Y)
+ return;
+
+ Rectangle prev = Bounds;
+ bounds.X = value.X;
+ bounds.Y = value.Y;
+ if (owner != null) {
+ if (prev != Rectangle.Empty)
+ owner.item_control.Invalidate (prev);
+ owner.item_control.Invalidate (Bounds);
+ }
+ }
+ }
+
+ internal ListView Owner {
+ set {
+ if (owner == value)
+ return;
+
+ owner = value;
+ if (owner != null)
+ Layout ();
+ Invalidate ();
+ }
+ }
+
+ private void Invalidate ()
+ {
+ if (owner == null || owner.item_control == null)
+ return;
+
+ owner.item_control.Invalidate (Bounds);
+ }
+
+ internal void Layout ()
+ {
+ int item_ht;
+ Rectangle total;
+ Size text_size = owner.text_size;
+
+ checkbox_rect = Rectangle.Empty;
+ if (owner.CheckBoxes)
+ checkbox_rect.Size = owner.CheckBoxSize;
+
+ switch (owner.View) {
+ case View.Details:
+ // LAMESPEC: MSDN says, "In all views except the details
+ // view of the ListView, this value specifies the same
+ // bounding rectangle as the Entire value." Actually, it
+ // returns same bounding rectangles for Item and Entire
+ // values in the case of Details view.
+
+ icon_rect = label_rect = Rectangle.Empty;
+ icon_rect.X = checkbox_rect.Width + 2;
+ item_ht = Math.Max (owner.CheckBoxSize.Height, text_size.Height);
+
+ if (owner.SmallImageList != null) {
+ item_ht = Math.Max (item_ht, owner.SmallImageList.ImageSize.Height);
+ icon_rect.Width = owner.SmallImageList.ImageSize.Width;
+ }
+
+ label_rect.Height = icon_rect.Height = item_ht;
+ checkbox_rect.Y = item_rect.Height - checkbox_rect.Height;
+
+ label_rect.X = icon_rect.Right + 1;
+
+ if (owner.Columns.Count > 0)
+ label_rect.Width = Math.Max (text_size.Width, owner.Columns[0].Wd);
+ else
+ label_rect.Width = text_size.Width;
+
+ item_rect = total = Rectangle.Union
+ (Rectangle.Union (checkbox_rect, icon_rect), label_rect);
+ bounds.Size = total.Size;
+
+ // Take into account the rest of columns. First column
+ // is already taken into account above.
+ for (int i = 1; i < owner.Columns.Count; i++) {
+ item_rect.Width += owner.Columns [i].Wd;
+ bounds.Width += owner.Columns [i].Wd;
+ }
+ break;
+
+ case View.LargeIcon:
+ label_rect = icon_rect = Rectangle.Empty;
+
+ if (owner.LargeImageList == null) {
+ icon_rect.Size = new Size (12, 2);
+ } else {
+ icon_rect.Width = owner.LargeImageList.ImageSize.Width;
+ icon_rect.Height = owner.LargeImageList.ImageSize.Height;
+ }
+
+ if (checkbox_rect.Height > icon_rect.Height)
+ icon_rect.Y = checkbox_rect.Height - icon_rect.Height;
+ else
+ checkbox_rect.Y = icon_rect.Height - checkbox_rect.Height;
+
+
+ if (text_size.Width <= icon_rect.Width) {
+ icon_rect.X = checkbox_rect.Width + 1;
+ label_rect.X = icon_rect.X + (icon_rect.Width - text_size.Width) / 2;
+ label_rect.Y = icon_rect.Bottom + 2;
+ label_rect.Size = text_size;
+ } else {
+ int centerX = text_size.Width / 2;
+ icon_rect.X = checkbox_rect.Width + 1 + centerX - icon_rect.Width / 2;
+ label_rect.X = checkbox_rect.Width + 1;
+ label_rect.Y = icon_rect.Bottom + 2;
+ label_rect.Size = text_size;
+ }
+
+ item_rect = Rectangle.Union (icon_rect, label_rect);
+ total = Rectangle.Union (item_rect, checkbox_rect);
+ bounds.Size = total.Size;
+ break;
+
+ case View.List:
+ case View.SmallIcon:
+ label_rect = icon_rect = Rectangle.Empty;
+ icon_rect.X = checkbox_rect.Width + 1;
+ item_ht = Math.Max (owner.CheckBoxSize.Height, text_size.Height);
+
+ if (owner.SmallImageList != null) {
+ item_ht = Math.Max (item_ht, owner.SmallImageList.ImageSize.Height);
+ icon_rect.Width = owner.SmallImageList.ImageSize.Width;
+ icon_rect.Height = owner.SmallImageList.ImageSize.Height;
+ }
+
+ checkbox_rect.Y = item_ht - checkbox_rect.Height;
+ label_rect.X = icon_rect.Right + 1;
+ label_rect.Width = text_size.Width;
+ label_rect.Height = icon_rect.Height = item_ht;
+
+ item_rect = Rectangle.Union (icon_rect, label_rect);
+ total = Rectangle.Union (item_rect, checkbox_rect);
+ bounds.Size = total.Size;
+ break;
+ }
+
+ }
+ #endregion // Private Internal Methods
+
+ #region Subclasses
+
+ [DefaultProperty ("Text")]
+ [DesignTimeVisible (false)]
+ [Serializable]
+ [ToolboxItem (false)]
+ [TypeConverter (typeof(ListViewSubItemConverter))]
+ public class ListViewSubItem
+ {
+ private Color back_color;
+ private Font font;
+ private Color fore_color;
+ internal ListViewItem owner;
+ private string text;
+
+ #region Public Constructors
+ public ListViewSubItem ()
+ {
+ }
+
+ public ListViewSubItem (ListViewItem owner, string text)
+ : this (owner, text, ThemeEngine.Current.ColorWindowText,
+ ThemeEngine.Current.ColorWindow,
+ ThemeEngine.Current.DefaultFont)
+ {
+ }
+
+ public ListViewSubItem (ListViewItem owner, string text, Color foreColor,
+ Color backColor, Font font)
+ {
+ this.owner = owner;
+ this.text = text;
+ this.fore_color = foreColor;
+ this.back_color = backColor;
+ this.font = font;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public Color BackColor {
+ get { return back_color; }
+ set {
+ back_color = value;
+ Invalidate ();
+ }
+ }
+
+ [Localizable (true)]
+ public Font Font {
+ get {
+ if (font != null)
+ return font;
+ else if (owner != null)
+ return owner.Font;
+ return font;
+ }
+ set {
+ font = value;
+ Invalidate ();
+ }
+ }
+
+ public Color ForeColor {
+ get { return fore_color; }
+ set {
+ fore_color = value;
+ Invalidate ();
+ }
+ }
+
+ [Localizable (true)]
+ public string Text {
+ get { return text; }
+ set {
+ text = value;
+ Invalidate ();
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Methods
+ public void ResetStyle ()
+ {
+ font = ThemeEngine.Current.DefaultFont;
+ back_color = ThemeEngine.Current.DefaultControlBackColor;
+ fore_color = ThemeEngine.Current.DefaultControlForeColor;
+ Invalidate ();
+ }
+
+ public override string ToString ()
+ {
+ return string.Format ("ListViewSubItem {{0}}", text);
+ }
+ #endregion // Public Methods
+
+
+ #region Private Methods
+ private void Invalidate ()
+ {
+ if (owner == null || owner.owner == null)
+ return;
+
+ owner.owner.Invalidate ();
+ }
+ #endregion // Private Methods
+ }
+
+ public class ListViewSubItemCollection : IList, ICollection, IEnumerable
+ {
+ private ArrayList list;
+ internal ListViewItem owner;
+
+ #region Public Constructors
+ public ListViewSubItemCollection (ListViewItem owner)
+ {
+ this.owner = owner;
+ this.list = new ArrayList ();
+ }
+ #endregion // Public Constructors
+
+ #region Public Properties
+ [Browsable (false)]
+ public virtual int Count {
+ get { return list.Count; }
+ }
+
+ public virtual bool IsReadOnly {
+ get { return false; }
+ }
+
+ public ListViewSubItem this [int index] {
+ get { return (ListViewSubItem) list [index]; }
+ set {
+ value.owner = this.owner;
+ list [index] = value;
+ }
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return list.IsSynchronized; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return list.SyncRoot; }
+ }
+
+ bool IList.IsFixedSize {
+ get { return list.IsFixedSize; }
+ }
+
+ object IList.this [int index] {
+ get { return this [index]; }
+ set {
+ if (! (value is ListViewSubItem))
+ throw new ArgumentException ("Not of type ListViewSubItem", "value");
+ this [index] = (ListViewSubItem) value;
+ }
+ }
+ #endregion // Public Properties
+
+ #region Public Methods
+ public ListViewSubItem Add (ListViewSubItem item)
+ {
+ item.owner = this.owner;
+ list.Add (item);
+ return item;
+ }
+
+ public ListViewSubItem Add (string text)
+ {
+ ListViewSubItem item = new ListViewSubItem (this.owner, text);
+ list.Add (item);
+ return item;
+ }
+
+ public ListViewSubItem Add (string text, Color foreColor,
+ Color backColor, Font font)
+ {
+ ListViewSubItem item = new ListViewSubItem (this.owner, text,
+ foreColor, backColor, font);
+ list.Add (item);
+ return item;
+ }
+
+ public void AddRange (ListViewSubItem [] items)
+ {
+ this.Clear ();
+ foreach (ListViewSubItem item in items)
+ this.Add (item);
+ }
+
+ public void AddRange (string [] items)
+ {
+ this.Clear ();
+ foreach (string item in items)
+ this.Add (item);
+ }
+
+ public void AddRange (string [] items, Color foreColor,
+ Color backColor, Font font)
+ {
+ this.Clear ();
+ foreach (string item in items)
+ this.Add (item, foreColor, backColor, font);
+ }
+
+ public virtual void Clear ()
+ {
+ list.Clear ();
+ }
+
+ public bool Contains (ListViewSubItem item)
+ {
+ return list.Contains (item);
+ }
+
+ public virtual IEnumerator GetEnumerator ()
+ {
+ return list.GetEnumerator ();
+ }
+
+ void ICollection.CopyTo (Array dest, int index)
+ {
+ list.CopyTo (dest, index);
+ }
+
+ int IList.Add (object item)
+ {
+ if (! (item is ListViewSubItem)) {
+ throw new ArgumentException ("Not of type ListViewSubItem", "item");
+ }
+
+ ListViewSubItem sub_item = (ListViewSubItem) item;
+ sub_item.owner = this.owner;
+ return list.Add (sub_item);
+ }
+
+ bool IList.Contains (object subItem)
+ {
+ if (! (subItem is ListViewSubItem)) {
+ throw new ArgumentException ("Not of type ListViewSubItem", "subItem");
+ }
+
+ return this.Contains ((ListViewSubItem) subItem);
+ }
+
+ int IList.IndexOf (object subItem)
+ {
+ if (! (subItem is ListViewSubItem)) {
+ throw new ArgumentException ("Not of type ListViewSubItem", "subItem");
+ }
+
+ return this.IndexOf ((ListViewSubItem) subItem);
+ }
+
+ void IList.Insert (int index, object item)
+ {
+ if (! (item is ListViewSubItem)) {
+ throw new ArgumentException ("Not of type ListViewSubItem", "item");
+ }
+
+ this.Insert (index, (ListViewSubItem) item);
+ }
+
+ void IList.Remove (object item)
+ {
+ if (! (item is ListViewSubItem)) {
+ throw new ArgumentException ("Not of type ListViewSubItem", "item");
+ }
+
+ this.Remove ((ListViewSubItem) item);
+ }
+
+ public int IndexOf (ListViewSubItem subItem)
+ {
+ return list.IndexOf (subItem);
+ }
+
+ public void Insert (int index, ListViewSubItem item)
+ {
+ item.owner = this.owner;
+ list.Insert (index, item);
+ }
+
+ public void Remove (ListViewSubItem item)
+ {
+ list.Remove (item);
+ }
+
+ public virtual void RemoveAt (int index)
+ {
+ list.RemoveAt (index);
+ }
+ #endregion // Public Methods
+ }
+ #endregion // Subclasses
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItemConverter.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItemConverter.cs
new file mode 100644
index 00000000000..53975c93fa0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItemConverter.cs
@@ -0,0 +1,97 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Ravindra (rkumar@novell.com)
+
+
+// COMPLETE
+
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Drawing;
+using System.Globalization;
+using System.Reflection;
+
+namespace System.Windows.Forms
+{
+ public class ListViewItemConverter : ExpandableObjectConverter
+ {
+ #region Public Constructors
+ public ListViewItemConverter () { }
+ #endregion // Public Constructors
+
+ #region Public Instance Methods
+ public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType) {
+ if (destinationType == typeof (string)) {
+ return true;
+ }
+
+ return base.CanConvertTo (context, destinationType);
+ }
+
+ public override object ConvertTo (ITypeDescriptorContext context,
+ CultureInfo culture, object value,
+ Type destinationType)
+ {
+ if (destinationType == typeof (string)) {
+ return value.ToString ();
+ } else {
+ return base.ConvertTo (context, culture, value, destinationType);
+ }
+ }
+ #endregion // Public Instance Methods
+ }
+
+ internal class ListViewSubItemConverter : ExpandableObjectConverter {
+ #region Public Instance Methods
+ public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType) {
+ if (destinationType == typeof(InstanceDescriptor)) {
+ return true;
+ } else {
+ return base.CanConvertTo(context, destinationType);
+ }
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
+ if (destinationType == typeof(InstanceDescriptor) && value is ListViewItem.ListViewSubItem) {
+ ConstructorInfo constructor_info;
+ Type[] type;
+ ListViewItem.ListViewSubItem sub_item;
+
+ sub_item = (ListViewItem.ListViewSubItem)value;
+ type = new Type[] { typeof(ListViewItem), typeof(string), typeof(Color), typeof(Color), typeof(Font)};
+
+ constructor_info = typeof(ListViewItem.ListViewSubItem).GetConstructor(type);
+ if (constructor_info != null) {
+ object[] arguments = new object[] {sub_item.Text, sub_item.ForeColor, sub_item.BackColor, sub_item.Font};
+ return new InstanceDescriptor(constructor_info, (ICollection) arguments, true);
+ }
+
+ }
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MWFCategoryAttribute.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MWFCategoryAttribute.cs
new file mode 100644
index 00000000000..56afff3f818
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MWFCategoryAttribute.cs
@@ -0,0 +1,50 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+using System.ComponentModel;
+using System.Windows.Forms;
+
+namespace System {
+ [AttributeUsage (AttributeTargets.All, AllowMultiple=false)]
+ internal sealed class MWFCategoryAttribute : System.ComponentModel.CategoryAttribute {
+ #region Constructors
+ public MWFCategoryAttribute() : base() {
+ }
+
+ public MWFCategoryAttribute(string category) : base(category) {
+ }
+ #endregion // Constructors
+
+ #region Methods
+ protected override string GetLocalizedString(string value) {
+ return Locale.GetText(value);
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MWFDescriptionAttribute.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MWFDescriptionAttribute.cs
new file mode 100644
index 00000000000..c7555332d9f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MWFDescriptionAttribute.cs
@@ -0,0 +1,51 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+using System.ComponentModel;
+using System.Windows.Forms;
+
+namespace System {
+ [AttributeUsage (AttributeTargets.All, AllowMultiple=false)]
+ internal sealed class MWFDescriptionAttribute : System.ComponentModel.DescriptionAttribute {
+ #region Constructors
+ public MWFDescriptionAttribute() : base() {
+ }
+
+ public MWFDescriptionAttribute(string category) : base(category) {
+ }
+ #endregion // Constructors
+
+ #region Properties
+ public override string Description {
+ get {
+ return Locale.GetText(base.Description);
+ }
+ }
+ #endregion // Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MainMenu.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MainMenu.cs
new file mode 100644
index 00000000000..95e500b5e3f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MainMenu.cs
@@ -0,0 +1,150 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+//
+
+// COMPLETE
+
+using System.ComponentModel;
+using System.Drawing;
+
+namespace System.Windows.Forms
+{
+ [ToolboxItemFilter("System.Windows.Forms.MainMenu", ToolboxItemFilterType.Allow)]
+ public class MainMenu : Menu
+ {
+ private RightToLeft right_to_left = RightToLeft.Inherit;
+ private Form form = null;
+
+ public MainMenu () : base (null)
+ {
+
+ }
+
+ public MainMenu (MenuItem[] items) : base (items)
+ {
+
+ }
+
+ #region Public Properties
+ [Localizable(true)]
+ public virtual RightToLeft RightToLeft {
+ get { return right_to_left;}
+ set { right_to_left = value; }
+ }
+
+ #endregion Public Properties
+
+ #region Public Methods
+
+ public virtual MainMenu CloneMenu ()
+ {
+ MainMenu new_menu = new MainMenu ();
+ new_menu.CloneMenu (this);
+ return new_menu;
+ }
+
+ protected override void Dispose (bool disposing)
+ {
+ base.Dispose (disposing);
+ }
+
+ public Form GetForm ()
+ {
+ return form;
+ }
+
+ public override string ToString ()
+ {
+ return base.ToString () + ", GetForm: " + form;
+ }
+
+ #endregion Public Methods
+
+ #region Private Methods
+
+ internal void Draw () {
+ PaintEventArgs pe;
+
+ if (Wnd.IsHandleCreated) {
+ pe = XplatUI.PaintEventStart(Wnd.window.Handle, false);
+ Draw (pe, Rect);
+ XplatUI.PaintEventEnd(Wnd.window.Handle, false);
+ }
+ }
+
+ internal void Draw (PaintEventArgs pe)
+ {
+ Draw (pe, Rect);
+ }
+
+ internal void Draw (PaintEventArgs pe, Rectangle rect)
+ {
+ if (!Wnd.IsHandleCreated)
+ return;
+
+ X = rect.X;
+ Y = rect.Y;
+ Height = Rect.Height;
+
+ ThemeEngine.Current.DrawMenuBar (pe.Graphics, this, rect);
+ }
+
+ internal void SetForm (Form form)
+ {
+ this.form = form;
+ Wnd = form;
+
+ if (tracker == null)
+ tracker = new MenuTracker (this);
+ }
+
+ internal override void OnMenuChanged (EventArgs e)
+ {
+ base.OnMenuChanged (EventArgs.Empty);
+ if (form == null)
+ return;
+
+ Height = 0;
+
+ Draw ();
+ }
+
+ /* Mouse events from the form */
+ internal void OnMouseDown (object window, MouseEventArgs args)
+ {
+ tracker.OnClick (args);
+ }
+
+ internal void OnMouseMove (object window, MouseEventArgs e)
+ {
+ MouseEventArgs args = new MouseEventArgs (e.Button, e.Clicks, Control.MousePosition.X, Control.MousePosition.Y, e.Delta);
+ tracker.OnMotion (args);
+ }
+
+ #endregion Private Methods
+ }
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiChildContext.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiChildContext.cs
new file mode 100644
index 00000000000..2b85991daca
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiChildContext.cs
@@ -0,0 +1,695 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+namespace System.Windows.Forms {
+
+ internal class MdiChildContext {
+
+ private static readonly int MdiBorderStyle = 0xFFFF;
+ private static Color titlebar_color;
+
+
+ private MainMenu merged_menu;
+ private int BorderWidth = 3;
+// private int TitleBarHeight = 26;
+// private int ToolTitleBarHeight = 19;
+ private Size MinTitleBarSize = new Size (115, 25);
+
+ private Form form;
+ private MdiClient mdi_container;
+
+ private TitleButton close_button;
+ private TitleButton maximize_button;
+ private TitleButton minimize_button;
+
+ private TitleButton [] title_buttons = new TitleButton [3];
+
+ // moving windows
+ private Point start;
+ private State state;
+ private FormPos sizing_edge;
+ private Rectangle virtual_position;
+ private Rectangle prev_virtual_position;
+ private Rectangle prev_bounds;
+ private bool maximized;
+
+ private class TitleButton {
+ public Rectangle Rectangle;
+ public ButtonState State;
+ public CaptionButton Caption;
+ public EventHandler Clicked;
+
+ public TitleButton (CaptionButton caption, EventHandler clicked)
+ {
+ Caption = caption;
+ Clicked = clicked;
+ }
+ }
+
+ private enum State {
+ Idle,
+ Moving,
+ Sizing,
+ }
+
+ [Flags]
+ private enum FormPos {
+ None,
+
+ TitleBar = 1,
+
+ Top = 2,
+ Left = 4,
+ Right = 8,
+ Bottom = 16,
+
+ TopLeft = Top | Left,
+ TopRight = Top | Right,
+
+ BottomLeft = Bottom | Left,
+ BottomRight = Bottom | Right,
+
+ AnyEdge = Top | Left | Right | Bottom,
+ }
+
+ public MdiChildContext (Form form, MdiClient mdi_container)
+ {
+ titlebar_color = Color.FromArgb (255, 0, 0, 255);
+ this.form = form;
+ this.mdi_container = mdi_container;
+
+ /*
+ minimize_button = new Button ();
+ minimize_button.Bounds = new Rectangle (form.Width - 62,
+ -26, 18, 22);
+ minimize_button.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ minimize_button.Paint += new PaintEventHandler (PaintButtonHandler);
+ minimize_button.Click += new EventHandler (OnMinimizeHandler);
+
+ maximize_button = new Button ();
+ maximize_button.Bounds = new Rectangle (form.Width - 44,
+ BorderWidth + 2, 18, 22);
+ maximize_button.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ maximize_button.Paint += new PaintEventHandler (PaintButtonHandler);
+ maximize_button.Click += new EventHandler (OnMaximizeHandler);
+
+ close_button = new Button ();
+ close_button.Bounds = new Rectangle (form.Width - 24,
+ BorderWidth + 2, 18, 22);
+ close_button.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ close_button.Paint += new PaintEventHandler (PaintButtonHandler);
+ close_button.Click += new EventHandler (CloseButtonClicked);
+
+
+ form.Controls.AddImplicit (close_button);
+ form.Controls.AddImplicit (maximize_button);
+ form.Controls.AddImplicit (minimize_button);
+ */
+
+ CreateButtons ();
+ }
+
+ public bool Maximized {
+ get { return maximized; }
+ }
+
+ public MainMenu MergedMenu {
+ get {
+ if (merged_menu == null)
+ merged_menu = CreateMergedMenu ();
+ return merged_menu;
+ }
+ }
+
+ private MainMenu CreateMergedMenu ()
+ {
+ Form parent = (Form) mdi_container.Parent;
+ MainMenu clone = (MainMenu) parent.Menu.CloneMenu ();
+ clone.MergeMenu (form.Menu);
+ clone.MenuChanged += new EventHandler (MenuChangedHandler);
+ clone.SetForm (parent);
+ return clone;
+ }
+
+ private void MenuChangedHandler (object sender, EventArgs e)
+ {
+ CreateMergedMenu ();
+ }
+
+ public bool HandleMessage (ref Message m)
+ {
+ switch ((Msg)m.Msg) {
+
+
+ // The mouse handling messages are actually
+ // not WM_NC* messages except for the first button and NCMOVEs
+ // down because we capture on the form
+
+ case Msg.WM_MOUSEMOVE:
+ return HandleMouseMove (form, ref m);
+
+ case Msg.WM_LBUTTONUP:
+ HandleLButtonUp (ref m);
+ break;
+
+ case Msg.WM_RBUTTONDOWN:
+ case Msg.WM_LBUTTONDOWN:
+ return HandleButtonDown (ref m);
+
+ case Msg.WM_NCMOUSEMOVE:
+ return HandleNCMouseMove (form, ref m);
+
+ case Msg.WM_NCLBUTTONUP:
+ return HandleNCLButtonUp (ref m);
+
+ case Msg.WM_NCLBUTTONDOWN:
+ return HandleNCLButtonDown (ref m);
+
+ case Msg.WM_MOUSE_LEAVE:
+ FormMouseLeave (ref m);
+ break;
+
+ case Msg.WM_NCPAINT: {
+ PaintEventArgs pe;
+
+ pe = XplatUI.PaintEventStart(m.HWnd, false);
+// form.UpdateStyles ();
+ PaintWindowDecorations (pe);
+ // g.Clear (Color.Red);
+ XplatUI.PaintEventEnd(m.HWnd, false);
+ break;
+ }
+ }
+ return false;
+ }
+
+ public void UpdateBorderStyle (FormBorderStyle border_style)
+ {
+ if (border_style != FormBorderStyle.None)
+ XplatUI.SetBorderStyle (form.Handle, (FormBorderStyle) MdiBorderStyle);
+ else
+ XplatUI.SetBorderStyle (form.Handle, FormBorderStyle.None);
+
+ CreateButtons ();
+ }
+
+ private void CreateButtons ()
+ {
+ switch (form.FormBorderStyle) {
+ case FormBorderStyle.None:
+ close_button = null;
+ minimize_button = null;
+ maximize_button = null;
+ break;
+ case FormBorderStyle.FixedSingle:
+ case FormBorderStyle.Fixed3D:
+ case FormBorderStyle.FixedDialog:
+ case FormBorderStyle.Sizable:
+ close_button = new TitleButton (CaptionButton.Close, new EventHandler (CloseClicked));
+ minimize_button = new TitleButton (CaptionButton.Minimize, new EventHandler (MinimizeClicked));
+ maximize_button = new TitleButton (CaptionButton.Maximize, new EventHandler (MaximizeClicked));
+ break;
+ case FormBorderStyle.FixedToolWindow:
+ case FormBorderStyle.SizableToolWindow:
+ close_button = new TitleButton (CaptionButton.Close, new EventHandler (CloseClicked));
+ break;
+ }
+
+ title_buttons [0] = close_button;
+ title_buttons [1] = minimize_button;
+ title_buttons [2] = maximize_button;
+
+ }
+
+ private bool HandleButtonDown (ref Message m)
+ {
+ form.BringToFront ();
+ mdi_container.ActiveMdiChild = form;
+ return false;
+ }
+
+ private bool HandleNCLButtonDown (ref Message m)
+ {
+ form.BringToFront ();
+ mdi_container.ActiveMdiChild = form;
+
+ int x = Control.LowOrder ((int) m.LParam.ToInt32 ());
+ int y = Control.HighOrder ((int) m.LParam.ToInt32 ());
+
+ form.PointToClient (ref x, ref y);
+
+ start = new Point (x, y);
+ virtual_position = form.Bounds;
+
+ // Need to adjust because we are in NC land
+ y += TitleBarHeight;
+ FormPos pos = FormPosForCoords (x, y);
+
+ if (pos == FormPos.TitleBar) {
+ HandleTitleBarDown (x, y);
+ return true;
+ }
+
+ if (IsSizable) {
+ SetCursorForPos (pos);
+
+ if ((pos & FormPos.AnyEdge) == 0)
+ return false;
+
+ state = State.Sizing;
+ sizing_edge = pos;
+ form.Capture = true;
+ return true;
+ }
+
+ return false;
+ }
+
+ private void HandleTitleBarDown (int x, int y)
+ {
+ foreach (TitleButton button in title_buttons) {
+ if (button != null && button.Rectangle.Contains (x, y)) {
+ button.State = ButtonState.Pushed;
+ return;
+ }
+ }
+
+ if (maximized)
+ return;
+
+ state = State.Moving;
+ form.Capture = true;
+ }
+
+ private bool HandleMouseMove (Form form, ref Message m)
+ {
+ switch (state) {
+ case State.Moving:
+ HandleWindowMove (m);
+ return true;
+ case State.Sizing:
+ HandleSizing (m);
+ return true;
+ }
+
+ /*
+ if (IsSizable) {
+ int x = Control.LowOrder ((int) m.LParam.ToInt32 ());
+ int y = Control.HighOrder ((int) m.LParam.ToInt32 ());
+ FormPos pos = FormPosForCoords (x, y);
+ Console.WriteLine ("position: " + pos);
+ SetCursorForPos (pos);
+
+ ClearVirtualPosition ();
+ state = State.Idle;
+ }
+ */
+
+ return false;
+ }
+
+ private bool HandleNCMouseMove (Form form, ref Message m)
+ {
+ if (IsSizable) {
+ int x = Control.LowOrder ((int) m.LParam.ToInt32 ());
+ int y = Control.HighOrder ((int) m.LParam.ToInt32 ());
+ FormPos pos = FormPosForCoords (x, y);
+
+ SetCursorForPos (pos);
+
+ ClearVirtualPosition ();
+ state = State.Idle;
+ }
+
+ return false;
+ }
+
+ private void FormMouseLeave (ref Message m)
+ {
+ form.ResetCursor ();
+ }
+
+ private void SetCursorForPos (FormPos pos)
+ {
+ switch (pos) {
+ case FormPos.TopLeft:
+ case FormPos.BottomRight:
+ form.Cursor = Cursors.SizeNWSE;
+ break;
+ case FormPos.TopRight:
+ case FormPos.BottomLeft:
+ form.Cursor = Cursors.SizeNESW;
+ break;
+ case FormPos.Top:
+ case FormPos.Bottom:
+ form.Cursor = Cursors.SizeNS;
+ break;
+ case FormPos.Left:
+ case FormPos.Right:
+ form.Cursor = Cursors.SizeWE;
+ break;
+ default:
+ form.ResetCursor ();
+ break;
+ }
+ }
+
+ private void HandleWindowMove (Message m)
+ {
+ Point move = MouseMove (m);
+
+ virtual_position.X = form.Left + move.X;
+ virtual_position.Y = form.Top + move.Y;
+ virtual_position.Width = form.Width;
+ virtual_position.Height = form.Height;
+
+ //mdi_container.EnsureScrollBars (virtual_position.Right, virtual_position.Bottom);
+
+ DrawVirtualPosition ();
+ }
+
+ private void HandleSizing (Message m)
+ {
+ Point move = MouseMove (m);
+ Rectangle pos = virtual_position;
+ int mw = MinTitleBarSize.Width + (BorderWidth * 2);
+ int mh = MinTitleBarSize.Height + (BorderWidth * 2);
+
+ if ((sizing_edge & FormPos.Top) != 0) {
+ int height = form.Height - move.Y;
+ if (height <= mh) {
+ move.Y += height - mh;
+ height = mh;
+ }
+ pos.Y = form.Top + move.Y;
+ pos.Height = height;
+ } else if ((sizing_edge & FormPos.Bottom) != 0) {
+ int height = form.Height + move.Y;
+ if (height <= mh)
+ move.Y -= height - mh;
+ pos.Height = form.Height + move.Y;
+ }
+
+ if ((sizing_edge & FormPos.Left) != 0) {
+ int width = form.Width - move.X;
+ if (width <= mw) {
+ move.X += width - mw;
+ width = mw;
+ }
+ pos.X = form.Left + move.X;
+ pos.Width = width;
+ } else if ((sizing_edge & FormPos.Right) != 0) {
+ int width = form.Width + move.X;
+ if (width <= mw)
+ move.X -= width - mw;
+ pos.Width = form.Width + move.X;
+ }
+
+ UpdateVP (pos);
+ }
+
+ private bool IsSizable {
+ get {
+ switch (form.FormBorderStyle) {
+ case FormBorderStyle.Sizable:
+ case FormBorderStyle.SizableToolWindow:
+ return true;
+ default:
+ return false;
+ }
+ }
+ }
+
+ private bool HasBorders {
+ get {
+ return form.FormBorderStyle != FormBorderStyle.None;
+ }
+ }
+
+ private bool IsToolWindow {
+ get {
+ if (form.FormBorderStyle == FormBorderStyle.SizableToolWindow ||
+ form.FormBorderStyle == FormBorderStyle.FixedToolWindow)
+ return true;
+ return false;
+ }
+ }
+
+ private int TitleBarHeight {
+ get {
+ if (IsToolWindow)
+ return 19;
+ if (form.FormBorderStyle == FormBorderStyle.None)
+ return 0;
+ return 26;
+ }
+ }
+
+ private void UpdateVP (Rectangle r)
+ {
+ UpdateVP (r.X, r.Y, r.Width, r.Height);
+ }
+
+ private void UpdateVP (Point loc, int w, int h)
+ {
+ UpdateVP (loc.X, loc.Y, w, h);
+ }
+
+ private void UpdateVP (int x, int y, int w, int h)
+ {
+ virtual_position.X = x;
+ virtual_position.Y = y;
+ virtual_position.Width = w;
+ virtual_position.Height = h;
+
+ DrawVirtualPosition ();
+ }
+
+ private void HandleLButtonUp (ref Message m)
+ {
+ if (state == State.Idle)
+ return;
+
+ ClearVirtualPosition ();
+
+ form.Capture = false;
+ form.Bounds = virtual_position;
+ state = State.Idle;
+ }
+
+ private bool HandleNCLButtonUp (ref Message m)
+ {
+ int x = Control.LowOrder ((int) m.LParam.ToInt32 ());
+ int y = Control.HighOrder ((int) m.LParam.ToInt32 ());
+
+ form.PointToClient (ref x, ref y);
+
+ // Need to adjust because we are in NC land
+ y += TitleBarHeight;
+
+ foreach (TitleButton button in title_buttons) {
+ if (button != null && button.Rectangle.Contains (x, y)) {
+ button.Clicked (this, EventArgs.Empty);
+ return true;
+ }
+ }
+
+ return true;
+ }
+
+ private void PaintWindowDecorations (PaintEventArgs pe)
+ {
+ Graphics dc = pe.Graphics;
+
+ if (HasBorders) {
+ Rectangle borders = new Rectangle (0, 0, form.Width, form.Height);
+// dc.FillRectangle (new SolidBrush (Color.Black), borders);
+
+/*
+ dc.DrawRectangle (new Pen (SystemColors.ControlLight, 1), borders);
+ borders.Inflate (-2, -2);
+ dc.DrawRectangle (new Pen (SystemColors.ControlDark, 1), borders);
+ borders.X++;
+ borders.Width -= 2;
+ dc.DrawRectangle (new Pen (SystemColors.ControlLight, 1), borders);
+*/
+
+ ControlPaint.DrawBorder3D (dc, borders, Border3DStyle.Raised);
+
+ if (IsSizable) {
+ borders.Inflate (-1, -1);
+ ControlPaint.DrawFocusRectangle (dc, borders);
+ }
+ }
+
+ Color color = ThemeEngine.Current.ColorControlDark;
+ if (form == mdi_container.ActiveMdiChild && !maximized)
+ color = titlebar_color;
+
+ Rectangle tb = new Rectangle (BorderWidth, BorderWidth,
+ form.Width - (BorderWidth * 2), TitleBarHeight - 1);
+
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (color), tb);
+
+ dc.DrawLine (new Pen (Color.White, 1), BorderWidth,
+ TitleBarHeight + BorderWidth, form.Width - BorderWidth,
+ TitleBarHeight + BorderWidth);
+
+ if (!IsToolWindow) {
+ tb.X += 18; // Room for the icon and the buttons
+ tb.Width = (form.Width - 62) - tb.X;
+ }
+
+ if (form.Text != null) {
+ StringFormat format = new StringFormat ();
+ format.FormatFlags = StringFormatFlags.NoWrap;
+ format.Trimming = StringTrimming.EllipsisCharacter;
+ format.LineAlignment = StringAlignment.Center;
+ dc.DrawString (form.Text, form.Font,
+ ThemeEngine.Current.ResPool.GetSolidBrush (Color.White),
+ tb, format);
+ }
+
+ if (!IsToolWindow && HasBorders) {
+ if (form.Icon != null) {
+ dc.DrawIcon (form.Icon, new Rectangle (BorderWidth + 3,
+ BorderWidth + 3, 16, 16));
+ }
+
+ minimize_button.Rectangle = new Rectangle (form.Width - 62,
+ BorderWidth + 2, 18, 22);
+
+ maximize_button.Rectangle = new Rectangle (form.Width - 44,
+ BorderWidth + 2, 18, 22);
+
+ close_button.Rectangle = new Rectangle (form.Width - 24,
+ BorderWidth + 2, 18, 22);
+
+ DrawTitleButton (dc, minimize_button);
+ DrawTitleButton (dc, maximize_button);
+ DrawTitleButton (dc, close_button);
+ } else {
+ close_button.Rectangle = new Rectangle (form.Width - BorderWidth - 2 - 13,
+ BorderWidth + 2, 13, 13);
+ DrawTitleButton (dc, close_button);
+ }
+ }
+
+ private void DrawTitleButton (Graphics dc, TitleButton button)
+ {
+ dc.FillRectangle (SystemBrushes.Control, button.Rectangle);
+
+ ControlPaint.DrawCaptionButton (dc, button.Rectangle,
+ button.Caption, ButtonState.Normal);
+ }
+
+ private void CloseClicked (object sender, EventArgs e)
+ {
+ form.Close ();
+ // form.Close should set visibility to false somewhere
+ // in it's closing chain but currently does not.
+ form.Visible = false;
+ }
+
+ private void MinimizeClicked (object sender, EventArgs e)
+ {
+ form.SuspendLayout ();
+ form.Width = MinTitleBarSize.Width + (BorderWidth * 2);
+ form.Height = MinTitleBarSize.Height + (BorderWidth * 2);
+ form.ResumeLayout ();
+ }
+
+ private void MaximizeClicked (object sender, EventArgs e)
+ {
+ if (maximized) {
+ form.Bounds = prev_bounds;
+ maximized = false;
+ } else {
+ prev_bounds = form.Bounds;
+ form.Bounds = form.Parent.Bounds;
+ maximized = true;
+ }
+ }
+
+ private Point NewLocation (Message m)
+ {
+ int x = Control.LowOrder ((int) m.LParam.ToInt32 ());
+ int y = Control.HighOrder ((int) m.LParam.ToInt32 ());
+ int x_move = x - start.X;
+ int y_move = y - start.Y;
+
+ return new Point (form.Left + x_move, form.Top + y_move);
+ }
+
+ private Point MouseMove (Message m)
+ {
+ int x = Control.LowOrder ((int) m.LParam.ToInt32 ());
+ int y = Control.HighOrder ((int) m.LParam.ToInt32 ());
+ int x_move = x - start.X;
+ int y_move = y - start.Y;
+
+ return new Point (x_move, y_move);
+ }
+
+ private void DrawVirtualPosition ()
+ {
+ ClearVirtualPosition ();
+
+ XplatUI.DrawReversibleRectangle (mdi_container.Handle, virtual_position, 2);
+ prev_virtual_position = virtual_position;
+ }
+
+ private void ClearVirtualPosition ()
+ {
+ if (prev_virtual_position != Rectangle.Empty)
+ XplatUI.DrawReversibleRectangle (mdi_container.Handle,
+ prev_virtual_position, 2);
+ prev_virtual_position = Rectangle.Empty;
+ }
+
+ private FormPos FormPosForCoords (int x, int y)
+ {
+ if (y < TitleBarHeight + BorderWidth) {
+
+ if (y > BorderWidth && x > BorderWidth &&
+ x < form.Width - BorderWidth)
+ return FormPos.TitleBar;
+
+ if (x < BorderWidth || (x < 20 && y < BorderWidth))
+ return FormPos.TopLeft;
+
+ if (x > form.Width - BorderWidth ||
+ (x > form.Width - 20 && y < BorderWidth))
+ return FormPos.TopRight;
+
+ if (y < BorderWidth)
+ return FormPos.Top;
+
+ } else if (y > form.Height - 20) {
+
+ if (x < BorderWidth ||
+ (x < 20 && y > form.Height - BorderWidth))
+ return FormPos.BottomLeft;
+
+ if (x > form.Width - BorderWidth ||
+ (x > form.Width - 20 &&
+ y > form.Height - BorderWidth))
+ return FormPos.BottomRight;
+
+ if (y > form.Height - BorderWidth)
+ return FormPos.Bottom;
+
+
+ } else if (x < BorderWidth) {
+ return FormPos.Left;
+ } else if (x > form.Width - BorderWidth) {
+ return FormPos.Right;
+ }
+
+ return FormPos.None;
+ }
+ }
+
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs
new file mode 100644
index 00000000000..f036219b53a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs
@@ -0,0 +1,410 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+// NOT COMPLETE
+
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+ [DesignTimeVisible(false)]
+ [ToolboxItem(false)]
+ public sealed class MdiClient : Control {
+ #region Local Variables
+ private int mdi_created;
+ private Form active;
+ private HScrollBar hbar;
+ private VScrollBar vbar;
+ private SizeGrip sizegrip;
+ private int hbar_value;
+ private int vbar_value;
+ private bool lock_sizing;
+
+ #endregion // Local Variables
+
+ #region Public Classes
+ public new class ControlCollection : Control.ControlCollection {
+ MdiClient owner;
+
+ public ControlCollection(MdiClient owner) : base(owner) {
+ this.owner = owner;
+ controls = new ArrayList ();
+ }
+
+ public override void Add(Control value) {
+ if ((value is Form) == false || !(((Form)value).IsMdiChild)) {
+ throw new ArgumentException("Form must be MdiChild");
+ }
+ base.Add (value);
+ SetChildIndex (value, 0); // always insert at front
+ // newest member is the active one
+ owner.ActiveMdiChild = (Form) value;
+
+ value.LocationChanged += new EventHandler (owner.FormLocationChanged);
+ }
+
+ public override void Remove(Control value) {
+ base.Remove (value);
+ }
+ }
+ #endregion // Public Classes
+
+ #region Public Constructors
+ public MdiClient() {
+ BackColor = SystemColors.AppWorkspace;
+ Dock = DockStyle.Fill;
+ SetStyle (ControlStyles.Selectable, false);
+ }
+ #endregion // Public Constructors
+
+ protected override Control.ControlCollection CreateControlsInstance ()
+ {
+ return new MdiClient.ControlCollection (this);
+ }
+
+ protected override void WndProc(ref Message m) {
+ /*
+ switch ((Msg) m.Msg) {
+ case Msg.WM_PAINT: {
+ Console.WriteLine ("ignoring paint");
+ return;
+ }
+ }
+ */
+ base.WndProc (ref m);
+ }
+
+ protected override void OnResize (EventArgs e)
+ {
+ base.OnResize (e);
+
+ // Should probably make this into one loop
+ SizeScrollBars ();
+ SizeMaximized ();
+ }
+
+ protected override void ScaleCore (float dx, float dy)
+ {
+ base.ScaleCore (dx, dy);
+ }
+
+ protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified)
+ {
+ base.SetBoundsCore (x, y, width, height, specified);
+ }
+
+ #region Public Instance Properties
+ [Localizable(true)]
+ public override System.Drawing.Image BackgroundImage {
+ get {
+ return base.BackgroundImage;
+ }
+ set {
+ base.BackgroundImage = value;
+ }
+ }
+
+ public Form[] MdiChildren {
+ get {
+ Form[] children;
+
+ children = new Form[Controls.Count];
+ Controls.CopyTo(children, 0);
+
+ return children;
+ }
+ }
+ #endregion // Public Instance Properties
+
+#region Protected Instance Properties
+ protected override CreateParams CreateParams {
+ get {
+ return base.CreateParams;
+ }
+ }
+ #endregion // Protected Instance Properties
+
+ #region Public Instance Methods
+ public void LayoutMdi(MdiLayout value) {
+ throw new NotImplementedException();
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ #endregion // Protected Instance Methods
+
+ private void SizeScrollBars ()
+ {
+ if (lock_sizing)
+ return;
+
+ if (Controls.Count == 0 || ((Form) Controls [0]).WindowState == FormWindowState.Maximized) {
+ if (hbar != null)
+ hbar.Visible = false;
+ if (vbar != null)
+ vbar.Visible = false;
+ return;
+ }
+
+ bool hbar_required = false;
+ bool vbar_required = false;
+
+ int right = 0;
+ int left = 0;
+ foreach (Form child in Controls) {
+ if (!child.Visible)
+ continue;
+ if (child.Right > right)
+ right = child.Right;
+ if (child.Left < left) {
+ hbar_required = true;
+ left = child.Left;
+ }
+ }
+
+ int top = 0;
+ int bottom = 0;
+ foreach (Form child in Controls) {
+ if (!child.Visible)
+ continue;
+ if (child.Bottom > bottom)
+ bottom = child.Bottom;
+ if (child.Top < 0) {
+ vbar_required = true;
+ top = child.Top;
+ }
+ }
+
+ int right_edge = Right;
+ int bottom_edge = Bottom;
+ int prev_right_edge;
+ int prev_bottom_edge;
+
+ bool need_hbar = false;
+ bool need_vbar = false;
+
+ do {
+ prev_right_edge = right_edge;
+ prev_bottom_edge = bottom_edge;
+
+ if (hbar_required || right > right_edge) {
+ need_hbar = true;
+ bottom_edge = Bottom - SystemInformation.HorizontalScrollBarHeight;
+ } else {
+ need_hbar = false;
+ bottom_edge = Bottom;
+ }
+
+ if (vbar_required || bottom > bottom_edge) {
+ need_vbar = true;
+ right_edge = Right - SystemInformation.VerticalScrollBarWidth;
+ } else {
+ need_vbar = false;
+ right_edge = Right;
+ }
+
+ } while (right_edge != prev_right_edge || bottom_edge != prev_bottom_edge);
+
+ if (need_hbar) {
+ if (hbar == null) {
+ hbar = new HScrollBar ();
+ Controls.AddImplicit (hbar);
+ }
+ hbar.Visible = true;
+ CalcHBar (left, right, right_edge, need_vbar);
+ } else if (hbar != null)
+ hbar.Visible = false;
+
+ if (need_vbar) {
+ if (vbar == null) {
+ vbar = new VScrollBar ();
+ Controls.AddImplicit (vbar);
+ }
+ vbar.Visible = true;
+ CalcVBar (top, bottom, bottom_edge, need_hbar);
+ } else if (vbar != null)
+ vbar.Visible = false;
+
+ if (need_hbar && need_vbar) {
+ if (sizegrip == null) {
+ sizegrip = new SizeGrip ();
+ Controls.AddImplicit (sizegrip);
+ }
+ sizegrip.Location = new Point (hbar.Right, vbar.Bottom);
+ sizegrip.Width = vbar.Width;
+ sizegrip.Height = hbar.Height;
+ sizegrip.Visible = true;
+ } else if (sizegrip != null) {
+ sizegrip.Visible = false;
+ }
+ }
+
+ private void CalcHBar (int left, int right, int right_edge, bool vert_vis)
+ {
+ int virtual_left = Math.Min (left, 0);
+ int virtual_right = Math.Max (right, right_edge);
+ int diff = (virtual_right - virtual_left) - right_edge;
+ hbar.Left = 0;
+ hbar.Top = Height - hbar.Height;
+ hbar.Width = Width - (vert_vis ? SystemInformation.VerticalScrollBarWidth : 0);
+ hbar.LargeChange = 50;
+ hbar.Maximum = diff + 51;
+ hbar.Value = -virtual_left;
+ hbar.ValueChanged += new EventHandler (HBarValueChanged);
+ }
+
+ private void CalcVBar (int top, int bottom, int bottom_edge, bool horz_vis)
+ {
+ int virtual_top = Math.Min (top, 0);
+ int virtual_bottom = Math.Max (bottom, bottom_edge);
+ int diff = (virtual_bottom - virtual_top) - bottom_edge;
+ vbar.Top = 0;
+ vbar.Left = Width - vbar.Width;
+ vbar.Height = Height - (horz_vis ? SystemInformation.HorizontalScrollBarHeight : 0);
+ vbar.LargeChange = 50;
+ vbar.Maximum = diff + 51;
+ vbar.Value = -virtual_top;
+ vbar.ValueChanged += new EventHandler (VBarValueChanged);
+
+ }
+
+ private void HBarValueChanged (object sender, EventArgs e)
+ {
+ if (hbar.Value == hbar_value)
+ return;
+
+ lock_sizing = true;
+
+ try {
+ foreach (Form child in Controls) {
+ child.Left += hbar_value - hbar.Value;
+ }
+ } finally {
+ lock_sizing = false;
+ }
+
+ hbar_value = hbar.Value;
+ lock_sizing = false;
+ }
+
+ private void VBarValueChanged (object sender, EventArgs e)
+ {
+ if (vbar.Value == vbar_value)
+ return;
+
+ lock_sizing = true;
+
+ try {
+ foreach (Form child in Controls) {
+ child.Top += vbar_value - vbar.Value;
+ }
+ } finally {
+ lock_sizing = false;
+ }
+
+ vbar_value = vbar.Value;
+ lock_sizing = false;
+ }
+
+ private void SizeMaximized ()
+ {
+ foreach (Form child in Controls) {
+ if (!child.Visible)
+ continue;
+ MdiWindowManager wm = (MdiWindowManager) child.WindowManager;
+ if (wm.GetWindowState () == FormWindowState.Maximized)
+ wm.SizeMaximized ();
+ }
+ }
+
+ private void FormLocationChanged (object sender, EventArgs e)
+ {
+ SizeScrollBars ();
+ }
+
+ private int iconic_x = -1;
+ private int iconic_y = -1;
+ internal void ArrangeIconicWindows ()
+ {
+ int xspacing = 160;
+ int yspacing = 25;
+
+ if (iconic_x == -1 && iconic_y == -1) {
+ iconic_x = Left;
+ iconic_y = Bottom - yspacing;
+ }
+
+ lock_sizing = true;
+ foreach (Form form in Controls) {
+ if (form.WindowState != FormWindowState.Minimized)
+ continue;
+
+ MdiWindowManager wm = (MdiWindowManager) form.WindowManager;
+
+ if (wm.IconicBounds != Rectangle.Empty) {
+ form.Bounds = wm.IconicBounds;
+ continue;
+ }
+
+ // The extra one pixel is a cheap hack for now until we
+ // handle 0 client sizes properly in the driver
+ int height = wm.TitleBarHeight + (wm.BorderWidth * 2) + 1;
+ Rectangle rect = new Rectangle (iconic_x, iconic_y, xspacing, height);
+ form.Bounds = wm.IconicBounds = rect;
+
+ iconic_x += xspacing;
+ if (iconic_x >= Right) {
+ iconic_x = Left;
+ iconic_y -= height;
+ }
+ }
+ lock_sizing = false;
+ }
+
+ internal void ActivateChild (Form form)
+ {
+ form.BringToFront ();
+ active = form;
+
+ foreach (Form child in Controls) {
+ if (child == form)
+ continue;
+ // TODO: We need to repaint the decorations here
+ }
+ }
+
+ internal int ChildrenCreated {
+ get { return mdi_created; }
+ set { mdi_created = value; }
+ }
+
+ internal Form ActiveMdiChild {
+ get { return active; }
+ set { active = value; }
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiLayout.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiLayout.cs
new file mode 100644
index 00000000000..7adca3b97e0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiLayout.cs
@@ -0,0 +1,36 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum MdiLayout {
+ Cascade = 0,
+ TileHorizontal = 1,
+ TileVertical = 2,
+ ArrangeIcons = 3
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs
new file mode 100644
index 00000000000..1e1a9660633
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs
@@ -0,0 +1,256 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+//
+//
+
+
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+namespace System.Windows.Forms {
+
+ internal class MdiWindowManager : InternalWindowManager {
+
+ private static readonly int MdiBorderStyle = 0xFFFF;
+
+ private MainMenu merged_menu;
+ private MainMenu maximized_menu;
+ private MenuItem icon_menu;
+ private FormWindowState prev_window_state;
+
+ private MdiClient mdi_container;
+ private Rectangle prev_virtual_position;
+
+ private Rectangle prev_bounds;
+ internal Rectangle IconicBounds;
+
+ public MdiWindowManager (Form form, MdiClient mdi_container) : base (form)
+ {
+ this.mdi_container = mdi_container;
+ prev_window_state = form.window_state;
+ form.GotFocus += new EventHandler (FormGotFocus);
+
+ icon_menu = CreateIconMenu ();
+ }
+
+ public MainMenu MergedMenu {
+ get {
+ if (merged_menu == null)
+ merged_menu = CreateMergedMenu ();
+ return merged_menu;
+ }
+ }
+
+ private MainMenu CreateMergedMenu ()
+ {
+ Form parent = (Form) mdi_container.Parent;
+ MainMenu clone = (MainMenu) parent.Menu.CloneMenu ();
+ if (form.WindowState == FormWindowState.Maximized) {
+
+ }
+ clone.MergeMenu (form.Menu);
+ clone.MenuChanged += new EventHandler (MenuChangedHandler);
+ clone.SetForm (parent);
+ return clone;
+ }
+
+ public MainMenu MaximizedMenu {
+ get {
+ if (maximized_menu == null)
+ maximized_menu = CreateMaximizedMenu ();
+ return maximized_menu;
+ }
+ }
+
+ private MainMenu CreateMaximizedMenu ()
+ {
+ Form parent = (Form) mdi_container.Parent;
+ MainMenu res = new MainMenu ();
+
+ res.MenuItems.Add (icon_menu);
+
+ if (parent.Menu != null) {
+ MainMenu clone = (MainMenu) parent.Menu.CloneMenu ();
+ res.MergeMenu (clone);
+ }
+
+ res.MenuItems.Add (new MenuItem ()); // Dummy item to get the menu height correct
+
+ res.SetForm (parent);
+ return res;
+ }
+
+ private MenuItem CreateIconMenu ()
+ {
+ MenuItem res = new MenuItem ();
+
+ res.OwnerDraw = true;
+ res.MeasureItem += new MeasureItemEventHandler (MeasureIconMenuItem);
+ res.DrawItem += new DrawItemEventHandler (DrawIconMenuItem);
+
+ MenuItem restore = new MenuItem ("Restore");;
+ MenuItem move = new MenuItem ("Move");
+ MenuItem size = new MenuItem ("Size");
+ MenuItem minimize = new MenuItem ("Minimize");
+ MenuItem maximize = new MenuItem ("Maximize");
+ MenuItem close = new MenuItem ("Close");
+ MenuItem next = new MenuItem ("Next");
+
+ res.MenuItems.AddRange (new MenuItem [] { restore, move, size, minimize,
+ maximize, close, next });
+
+ return res;
+ }
+
+ private void DrawIconMenuItem (object sender, DrawItemEventArgs de)
+ {
+ de.Graphics.DrawIcon (form.Icon, new Rectangle (2, 2, de.Bounds.Height - 4, de.Bounds.Height - 4));
+ }
+
+ private void MeasureIconMenuItem (object sender, MeasureItemEventArgs me)
+ {
+ int size = SystemInformation.MenuHeight;
+ me.ItemHeight = size;
+ me.ItemWidth = size + 2; // some padding
+ }
+
+ private void MenuChangedHandler (object sender, EventArgs e)
+ {
+ CreateMergedMenu ();
+ }
+
+ public override void PointToClient (ref int x, ref int y)
+ {
+ XplatUI.ScreenToClient (mdi_container.Handle, ref x, ref y);
+ }
+
+ public override void PointToScreen (ref int x, ref int y)
+ {
+ XplatUI.ClientToScreen (mdi_container.Handle, ref x, ref y);
+ }
+
+ public override void SetWindowState (FormWindowState window_state)
+ {
+ switch (window_state) {
+ case FormWindowState.Minimized:
+ prev_bounds = form.Bounds;
+ mdi_container.ArrangeIconicWindows ();
+ break;
+ case FormWindowState.Maximized:
+ prev_bounds = form.Bounds;
+ SizeMaximized ();
+ XplatUI.RequestNCRecalc (mdi_container.Parent.Handle);
+ break;
+ case FormWindowState.Normal:
+ form.Bounds = prev_bounds;
+ break;
+ }
+
+ if (prev_window_state == FormWindowState.Maximized)
+ XplatUI.RequestNCRecalc (mdi_container.Parent.Handle);
+ prev_window_state = window_state;
+ }
+
+ internal void SizeMaximized ()
+ {
+ Rectangle pb = mdi_container.Bounds;
+ form.Bounds = new Rectangle (pb.Left - BorderWidth,
+ pb.Top - TitleBarHeight - BorderWidth,
+ pb.Width + BorderWidth * 2,
+ pb.Height + TitleBarHeight + BorderWidth * 2);
+ }
+
+ /*
+ public override void UpdateBorderStyle (FormBorderStyle border_style)
+ {
+ base.UpdateBorderStyle (border_style);
+
+ Console.WriteLine ("MDI SETTING BORDER STYLE: " + border_style);
+ if (border_style != FormBorderStyle.None)
+ XplatUI.SetBorderStyle (form.Handle, (FormBorderStyle) MdiBorderStyle);
+ else
+ XplatUI.SetBorderStyle (form.Handle, FormBorderStyle.None);
+ }
+ */
+
+ protected override bool ShouldRemoveWindowManager (FormBorderStyle style)
+ {
+ return false;
+ }
+
+ protected override void HandleWindowMove (Message m)
+ {
+ Point move = MouseMove (m);
+
+ int x = virtual_position.X + move.X;
+ int y = virtual_position.Y + move.Y;
+
+ UpdateVP (x, y, form.Width, form.Height);
+ start = Cursor.Position;
+ }
+
+ protected override void DrawVirtualPosition (Rectangle virtual_position)
+ {
+ ClearVirtualPosition ();
+
+ if (form.Parent != null)
+ XplatUI.DrawReversibleRectangle (form.Parent.Handle, virtual_position, 2);
+ prev_virtual_position = virtual_position;
+ }
+
+ protected override void ClearVirtualPosition ()
+ {
+ if (prev_virtual_position != Rectangle.Empty && form.Parent != null)
+ XplatUI.DrawReversibleRectangle (form.Parent.Handle,
+ prev_virtual_position, 2);
+ prev_virtual_position = Rectangle.Empty;
+ }
+
+ protected override void OnWindowFinishedMoving ()
+ {
+ // mdi_container.EnsureScrollBars (form.Right, form.Bottom);
+
+ form.Refresh ();
+ }
+
+ protected override bool IsActive ()
+ {
+ return mdi_container.ActiveMdiChild == form;
+ }
+
+ protected override void Activate ()
+ {
+ mdi_container.ActivateChild (form);
+ base.Activate ();
+ }
+
+ private void FormGotFocus (object sender, EventArgs e)
+ {
+ // Maybe we don't need to do this, maybe we do
+ // mdi_container.ActivateChild (form);
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MeasureItemEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MeasureItemEventArgs.cs
new file mode 100644
index 00000000000..65759a002bb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MeasureItemEventArgs.cs
@@ -0,0 +1,76 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+//
+
+using System.Drawing;
+
+namespace System.Windows.Forms
+{
+ public class MeasureItemEventArgs : EventArgs
+ {
+ private Graphics graphics;
+ private int index;
+ private int itemHeight;
+ private int itemWidth = 0;
+
+ public MeasureItemEventArgs (Graphics graphics, int index)
+ {
+ this.graphics = graphics;
+ this.index = index;
+ this.itemHeight = 0;
+ }
+
+ public MeasureItemEventArgs (Graphics graphics, int index, int itemHeight)
+ {
+ this.graphics = graphics;
+ this.index = index;
+ this.itemHeight = itemHeight;
+ }
+
+ #region Public Properties
+
+ public Graphics Graphics {
+ get { return graphics;}
+ }
+
+ public int Index {
+ get { return index;}
+ }
+
+ public int ItemHeight {
+ get { return itemHeight;}
+ set { itemHeight = value;}
+ }
+
+ public int ItemWidth {
+ get { return itemWidth;}
+ set { itemWidth = value;}
+ }
+
+ #endregion Public Properties
+ }
+
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MeasureItemEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MeasureItemEventHandler.cs
new file mode 100644
index 00000000000..2be15e43ced
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MeasureItemEventHandler.cs
@@ -0,0 +1,31 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+//
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public delegate void MeasureItemEventHandler (object sender, MeasureItemEventArgs e);
+} \ No newline at end of file
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Menu.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Menu.cs
new file mode 100644
index 00000000000..5e86dac8a50
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Menu.cs
@@ -0,0 +1,511 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+// TODO:
+// - MDI integration
+// - ShortCut navigation
+//
+// NOT COMPLETE
+
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+ [Designer ("Microsoft.VisualStudio.Windows.Forms.MenuDesigner, " + Consts.AssemblyMicrosoft_VisualStudio, "System.ComponentModel.Design.IDesigner")]
+ [ToolboxItemFilter("System.Windows.Forms", ToolboxItemFilterType.Allow)]
+ [ListBindable(false)]
+ public abstract class Menu : Component
+ {
+ internal MenuItemCollection menu_items;
+ internal IntPtr menu_handle = IntPtr.Zero;
+ internal Menu parent_menu = null;
+ System.Drawing.Rectangle rect;
+ internal Control Wnd;
+ internal MenuTracker tracker;
+
+ public const int FindHandle = 0;
+ public const int FindShortcut = 1;
+
+ protected Menu (MenuItem[] items)
+ {
+ menu_items = new MenuItemCollection (this);
+
+ if (items != null)
+ menu_items.AddRange (items);
+ }
+
+
+ #region Public Properties
+ [BrowsableAttribute(false)]
+ [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
+ [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
+ public IntPtr Handle {
+ get { return menu_handle; }
+ }
+
+ internal virtual void OnMenuChanged (EventArgs e)
+ {
+ if (MenuChanged != null)
+ MenuChanged (this, e);
+ }
+
+ [BrowsableAttribute(false)]
+ [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
+ public virtual bool IsParent {
+ get {
+ if (menu_items != null && menu_items.Count > 0)
+ return true;
+ else
+ return false;
+ }
+ }
+
+ [BrowsableAttribute(false)]
+ [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
+ public MenuItem MdiListItem {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [BrowsableAttribute(false)]
+ [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)]
+ [MergableProperty(false)]
+ public MenuItemCollection MenuItems {
+ get { return menu_items; }
+ }
+
+ #endregion Public Properties
+
+ #region Private Properties
+
+ internal System.Drawing.Rectangle Rect {
+ get {
+ return rect;
+ }
+ }
+
+ internal MenuItem SelectedItem {
+ get {
+ foreach (MenuItem item in MenuItems)
+ if ((item.Status & DrawItemState.Selected) == DrawItemState.Selected)
+ return item;
+
+ return null;
+ }
+ }
+
+ internal int Height {
+ get { return rect.Height; }
+ set { rect.Height = value; }
+ }
+
+ internal int Width {
+ get { return rect.Width; }
+ set { rect.Width = value; }
+ }
+
+ internal int X {
+ get { return rect.X; }
+ set { rect.X = value; }
+ }
+
+ internal int Y {
+ get { return rect.Y; }
+ set { rect.Y = value; }
+ }
+
+ internal MenuTracker Tracker {
+ get {
+ Menu top = this;
+ while (top.parent_menu != null)
+ top = top.parent_menu;
+
+ return top.tracker;
+ }
+ }
+ #endregion Private Properties
+
+ #region Public Methods
+
+ protected void CloneMenu (Menu menuSrc)
+ {
+ Dispose (true);
+
+ menu_items = new MenuItemCollection (this);
+
+ for (int i = 0; i < menuSrc.MenuItems.Count ; i++)
+ menu_items.Add (menuSrc.MenuItems [i].CloneMenu ());
+ }
+
+ protected override void Dispose (bool disposing)
+ {
+ if (disposing) {
+ if (menu_handle != IntPtr.Zero) {
+ menu_handle = IntPtr.Zero;
+ }
+ }
+ }
+
+ // From Microsoft documentation is impossible to guess that
+ // this method is supossed to do
+ public MenuItem FindMenuItem (int type, IntPtr value)
+ {
+ return null;
+ }
+
+ protected int FindMergePosition (int mergeOrder)
+ {
+ int cnt = MenuItems.Count, cur, pos;
+
+ for (pos = 0; pos < cnt; ) {
+ cur = (pos + cnt) /2;
+ if (MenuItems[cur].MergeOrder > mergeOrder) {
+ cnt = cur;
+ } else {
+ pos = cur +1;
+ }
+ }
+
+ return pos;
+ }
+
+ public ContextMenu GetContextMenu ()
+ {
+ for (Menu item = this; item != null; item = item.parent_menu) {
+ if (item is ContextMenu) {
+ return (ContextMenu) item;
+ }
+ }
+
+ return null;
+ }
+
+ public MainMenu GetMainMenu ()
+ {
+ for (Menu item = this; item != null; item = item.parent_menu) {
+ if (item is MainMenu) {
+ return (MainMenu) item;
+ }
+ }
+
+ return null;
+ }
+
+ public virtual void MergeMenu (Menu menuSrc)
+ {
+ if (menuSrc == this)
+ throw new ArgumentException ("The menu cannot be merged with itself");
+
+ for (int i = 0; i < menuSrc.MenuItems.Count; i++){
+
+ switch (menuSrc.MenuItems[i].MergeType) {
+ case MenuMerge.Remove: // Item not included
+ break;
+
+ case MenuMerge.Add:
+ {
+ int pos = FindMergePosition (menuSrc.MenuItems[i].MergeOrder);
+ MenuItems.Add (pos, menuSrc.MenuItems[i].CloneMenu ());
+ break;
+ }
+
+ case MenuMerge.Replace:
+ case MenuMerge.MergeItems:
+ {
+ int pos = FindMergePosition (menuSrc.MenuItems[i].MergeOrder - 1);
+ MenuItems.Insert (pos, menuSrc.MenuItems[i].CloneMenu ());
+
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+ }
+
+ internal bool ProcessCmdKey (ref Message msg, Keys keyData)
+ {
+ if (tracker == null)
+ return false;
+ return tracker.ProcessKeys (ref msg, keyData);
+ }
+
+ public override string ToString ()
+ {
+ return base.ToString () + ", Items.Count: " + MenuItems.Count;
+ }
+
+ #endregion Public Methods
+
+ internal event EventHandler MenuChanged;
+
+ [ListBindable(false)]
+ public class MenuItemCollection : IList, ICollection, IEnumerable
+ {
+ private Menu owner;
+ private ArrayList items = new ArrayList ();
+
+ public MenuItemCollection (Menu owner)
+ {
+ this.owner = owner;
+ }
+
+ #region Public Properties
+
+ public virtual int Count {
+ get { return items.Count;}
+ }
+
+ public virtual bool IsReadOnly {
+ get { return false;}
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return false;}
+ }
+
+ object ICollection.SyncRoot {
+ get { return this;}
+ }
+
+ bool IList.IsFixedSize {
+ get { return false;}
+ }
+
+ public virtual MenuItem this [int index] {
+ get {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ return (MenuItem) items[index];
+ }
+ }
+
+ object IList.this[int index] {
+ get { return items[index]; }
+ set { throw new NotSupportedException (); }
+ }
+
+ #endregion Public Properties
+
+ #region Public Methods
+
+ public virtual int Add (MenuItem mi)
+ {
+ if (mi.Parent != null)
+ mi.Parent.MenuItems.Remove (mi);
+
+ items.Add (mi);
+ mi.Index = items.Count - 1;
+ UpdateItem (mi);
+
+ owner.OnMenuChanged (EventArgs.Empty);
+ if (owner.parent_menu != null)
+ owner.parent_menu.OnMenuChanged (EventArgs.Empty);
+ return items.Count - 1;
+ }
+
+ internal void AddNoEvents (MenuItem mi)
+ {
+ if (mi.Parent != null)
+ mi.Parent.MenuItems.Remove (mi);
+
+ items.Add (mi);
+ mi.Index = items.Count - 1;
+ mi.parent_menu = owner;
+ }
+
+ public virtual MenuItem Add (string s)
+ {
+ MenuItem item = new MenuItem (s);
+ Add (item);
+ return item;
+ }
+
+ public virtual int Add (int index, MenuItem mi)
+ {
+ if (index < 0 || index > Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ ArrayList new_items = new ArrayList (Count + 1);
+
+ for (int i = 0; i < index; i++)
+ new_items.Add (items[i]);
+
+ new_items.Add (mi);
+
+ for (int i = index; i < Count; i++)
+ new_items.Add (items[i]);
+
+ items = new_items;
+ UpdateItemsIndices ();
+ UpdateItem (mi);
+
+ return index;
+ }
+
+ private void UpdateItem (MenuItem mi)
+ {
+ mi.parent_menu = owner;
+ owner.OnMenuChanged (EventArgs.Empty);
+ if (owner.parent_menu != null)
+ owner.parent_menu.OnMenuChanged (EventArgs.Empty);
+ if (owner.Tracker != null)
+ owner.Tracker.AddShortcuts (mi);
+ }
+
+ internal void Insert (int index, MenuItem mi)
+ {
+ if (index < 0 || index > Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+ UpdateItemsIndices ();
+ UpdateItem (mi);
+ }
+
+ public virtual MenuItem Add (string s, EventHandler e)
+ {
+ MenuItem item = new MenuItem (s, e);
+ Add (item);
+
+ return item;
+ }
+
+ public virtual MenuItem Add (string s, MenuItem[] items)
+ {
+ MenuItem item = new MenuItem (s, items);
+ Add (item);
+
+ return item;
+ }
+
+ public virtual void AddRange (MenuItem[] items)
+ {
+ if (items == null)
+ throw new ArgumentNullException ("items");
+
+ foreach (MenuItem mi in items)
+ Add (mi);
+ }
+
+ public virtual void Clear ()
+ {
+ MenuTracker tracker = owner.Tracker;
+ foreach (MenuItem item in items) {
+ if (tracker != null)
+ tracker.RemoveShortcuts (item);
+ item.parent_menu = null;
+ }
+ items.Clear ();
+ owner.OnMenuChanged (EventArgs.Empty);
+ }
+
+ public bool Contains (MenuItem value)
+ {
+ return items.Contains (value);
+ }
+
+ public virtual void CopyTo (Array dest, int index)
+ {
+ items.CopyTo (dest, index);
+ }
+
+ public virtual IEnumerator GetEnumerator ()
+ {
+ return items.GetEnumerator ();
+ }
+
+ int IList.Add (object value)
+ {
+ return Add ((MenuItem)value);
+ }
+
+ bool IList.Contains (object value)
+ {
+ return Contains ((MenuItem)value);
+ }
+
+ int IList.IndexOf (object value)
+ {
+ return IndexOf ((MenuItem)value);
+ }
+
+ void IList.Insert (int index, object value)
+ {
+ Insert (index, (MenuItem) value);
+ }
+
+ void IList.Remove (object value)
+ {
+ Remove ((MenuItem) value);
+ }
+
+ public int IndexOf (MenuItem value)
+ {
+ return items.IndexOf (value);
+ }
+
+ public virtual void Remove (MenuItem item)
+ {
+ RemoveAt (item.Index);
+ }
+
+ public virtual void RemoveAt (int index)
+ {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("Index of out range");
+
+ MenuItem item = (MenuItem) items [index];
+ MenuTracker tracker = owner.Tracker;
+ if (tracker != null)
+ tracker.RemoveShortcuts (item);
+ item.parent_menu = null;
+
+ items.RemoveAt (index);
+
+ UpdateItemsIndices ();
+ owner.OnMenuChanged (EventArgs.Empty);
+ }
+
+ #endregion Public Methods
+
+ #region Private Methods
+
+ private void UpdateItemsIndices ()
+ {
+ for (int i = 0; i < Count; i++) // Recalculate indeces
+ ((MenuItem)items[i]).Index = i;
+ }
+
+ #endregion Private Methods
+ }
+ }
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuAPI.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuAPI.cs
new file mode 100644
index 00000000000..119525025bb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuAPI.cs
@@ -0,0 +1,728 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+// Mike Kestner <mkestner@novell.com>
+//
+
+// NOT COMPLETE
+
+using System.Collections;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+
+ /*
+ When writing this code the Wine project was of great help to
+ understand the logic behind some Win32 issues. Thanks to them. Jordi,
+ */
+ internal class MenuTracker {
+
+ internal bool active;
+ public Menu CurrentMenu;
+ public Menu TopMenu;
+ Form grab_control;
+
+ public MenuTracker (Menu top_menu)
+ {
+ TopMenu = CurrentMenu = top_menu;
+ foreach (MenuItem item in TopMenu.MenuItems)
+ AddShortcuts (item);
+
+ if (top_menu is ContextMenu) {
+ grab_control = (top_menu as ContextMenu).SourceControl.FindForm ();
+ grab_control.ActiveTracker = this;
+ } else
+ grab_control = top_menu.Wnd.FindForm ();
+ }
+
+ enum KeyNavState {
+ Idle,
+ Startup,
+ NoPopups,
+ Navigating
+ }
+
+ KeyNavState keynav_state = KeyNavState.Idle;
+
+ public bool Navigating {
+ get { return keynav_state != KeyNavState.Idle; }
+ }
+
+ internal static Point ScreenToMenu (Menu menu, Point pnt)
+ {
+ int x = pnt.X;
+ int y = pnt.Y;
+ XplatUI.ScreenToMenu (menu.Wnd.window.Handle, ref x, ref y);
+ return new Point (x, y);
+ }
+
+ void Deactivate ()
+ {
+ active = false;
+ grab_control.ActiveTracker = null;
+ keynav_state = KeyNavState.Idle;
+ if (TopMenu is ContextMenu) {
+ PopUpWindow puw = TopMenu.Wnd as PopUpWindow;
+ puw.HideWindow ();
+ } else {
+ DeselectItem (TopMenu.SelectedItem);
+ (TopMenu as MainMenu).Draw ();
+ }
+ CurrentMenu = TopMenu;
+ }
+
+ MenuItem FindItemByCoords (Menu menu, Point pt)
+ {
+ if (menu is MainMenu)
+ pt = ScreenToMenu (menu, pt);
+ else
+ pt = menu.Wnd.PointToClient (pt);
+ foreach (MenuItem item in menu.MenuItems) {
+ Rectangle rect = item.bounds;
+ if (rect.Contains (pt))
+ return item;
+ }
+
+ return null;
+ }
+
+ MenuItem GetItemAtXY (int x, int y)
+ {
+ Point pnt = new Point (x, y);
+ MenuItem item = FindItemByCoords (TopMenu, pnt);
+ if (item == null && TopMenu.SelectedItem != null)
+ item = FindSubItemByCoord (TopMenu.SelectedItem, Control.MousePosition);
+ return item;
+ }
+
+ public void OnClick (MouseEventArgs args)
+ {
+ MenuItem item = GetItemAtXY (args.X, args.Y);
+
+ if (item == null) {
+ Deactivate ();
+ return;
+ }
+
+ SelectItem (item.Parent, item, item.IsPopup);
+ if (item.IsPopup) {
+ active = true;
+ grab_control.ActiveTracker = this;
+ } else if (item.Parent is MainMenu)
+ active = false;
+ else
+ Deactivate ();
+ item.PerformClick ();
+ }
+
+ public void OnMotion (MouseEventArgs args)
+ {
+ MenuItem item = GetItemAtXY (args.X, args.Y);
+
+ if (CurrentMenu.SelectedItem == item)
+ return;
+
+ grab_control.ActiveTracker = (active || item != null) ? this : null;
+
+ Rectangle top_bounds = new Rectangle(0, 0, TopMenu.Rect.Width, TopMenu.Rect.Height);
+ if (item == null && (!active || top_bounds.Contains (ScreenToMenu (TopMenu, new Point (args.X, args.Y)))))
+ DeselectItem (TopMenu.SelectedItem);
+ else
+ MoveSelection (item);
+ }
+
+ public void OnMouseUp (MouseEventArgs args)
+ {
+ // Doing nothing (yet)
+ }
+
+ void MoveSelection (MenuItem item)
+ {
+ if (item == null) {
+ if (CurrentMenu.SelectedItem.IsPopup)
+ return;
+ MenuItem old_item = CurrentMenu.SelectedItem;
+ if (CurrentMenu != TopMenu)
+ CurrentMenu = CurrentMenu.parent_menu;
+ DeselectItem (old_item);
+ } else {
+ if (item.Parent != CurrentMenu.SelectedItem)
+ DeselectItem (CurrentMenu.SelectedItem);
+ CurrentMenu = item.Parent;
+ SelectItem (CurrentMenu, item, active && item.IsPopup);
+ }
+ }
+
+ static public bool TrackPopupMenu (Menu menu, Point pnt)
+ {
+ if (menu.MenuItems.Count <= 0) // No submenus to track
+ return true;
+
+ menu.Wnd = new PopUpWindow (menu);
+ MenuTracker tracker = new MenuTracker (menu);
+ tracker.active = true;
+
+ menu.Wnd.Location = menu.Wnd.PointToClient (pnt);
+
+ ((PopUpWindow)menu.Wnd).ShowWindow ();
+
+ bool no_quit = true;
+
+ while ((menu.Wnd != null) && menu.Wnd.Visible && no_quit) {
+ MSG msg = new MSG ();
+ no_quit = XplatUI.GetMessage(ref msg, IntPtr.Zero, 0, 0);
+ XplatUI.TranslateMessage(ref msg);
+ XplatUI.DispatchMessage(ref msg);
+ }
+
+ if (!no_quit)
+ XplatUI.PostQuitMessage(0);
+
+ if (menu.Wnd != null) {
+ menu.Wnd.Dispose ();
+ menu.Wnd = null;
+ }
+
+ return true;
+ }
+
+ void DeselectItem (MenuItem item)
+ {
+ if (item == null)
+ return;
+
+ item.Status = item.Status &~ DrawItemState.Selected;
+
+ if (item.IsPopup)
+ HideSubPopups (item);
+
+ Menu menu = item.Parent;
+ if (menu is MainMenu)
+ (menu as MainMenu).Draw ();
+ else if (menu.Wnd != null)
+ menu.Wnd.Invalidate (item.bounds);
+ }
+
+ void SelectItem (Menu menu, MenuItem item, bool execute)
+ {
+ MenuItem prev_item = menu.SelectedItem;
+
+ if (prev_item != item) {
+ DeselectItem (prev_item);
+ if (CurrentMenu != menu)
+ CurrentMenu = menu;
+ item.Status |= DrawItemState.Selected;
+ if (menu is MainMenu)
+ (menu as MainMenu).Draw ();
+ else
+ menu.Wnd.Invalidate (item.bounds);
+ item.PerformSelect ();
+ }
+
+ if (execute)
+ ExecFocusedItem (menu, item);
+ }
+
+
+ // Used when the user executes the action of an item (press enter, shortcut)
+ // or a sub-popup menu has to be shown
+ void ExecFocusedItem (Menu menu, MenuItem item)
+ {
+ if (!item.Enabled)
+ return;
+
+ if (item.IsPopup) {
+ ShowSubPopup (menu, item);
+ } else {
+ Deactivate ();
+ item.PerformClick ();
+ }
+ }
+
+ // Create a popup window and show it or only show it if it is already created
+ void ShowSubPopup (Menu menu, MenuItem item)
+ {
+ if (item.Enabled == false)
+ return;
+
+ if (item.Wnd != null)
+ item.Wnd.Dispose ();
+
+ item.PerformPopup ();
+
+ PopUpWindow puw = new PopUpWindow (item);
+
+ Point pnt;
+ if (menu is MainMenu)
+ pnt = new Point (item.X, 0);
+ else
+ pnt = new Point (item.X + item.Width, item.Y + 1);
+ pnt = menu.Wnd.PointToScreen (pnt);
+ puw.Location = pnt;
+ item.Wnd = puw;
+
+ puw.ShowWindow ();
+ }
+
+ static public void HideSubPopups (Menu menu)
+ {
+ foreach (MenuItem item in menu.MenuItems)
+ if (item.IsPopup)
+ HideSubPopups (item);
+
+ if (menu.Wnd == null)
+ return;
+
+ PopUpWindow puw = menu.Wnd as PopUpWindow;
+ puw.Hide ();
+ }
+
+ MenuItem FindSubItemByCoord (Menu menu, Point pnt)
+ {
+ foreach (MenuItem item in menu.MenuItems) {
+
+ if (item.IsPopup && item.Wnd != null && item.Wnd.Visible && item == menu.SelectedItem) {
+ MenuItem result = FindSubItemByCoord (item, pnt);
+ if (result != null)
+ return result;
+ }
+
+ if (menu.Wnd == null)
+ continue;
+
+ Rectangle rect = item.bounds;
+ Point pnt_client = menu.Wnd.PointToScreen (new Point (item.X, item.Y));
+ rect.X = pnt_client.X;
+ rect.Y = pnt_client.Y;
+
+ if (rect.Contains (pnt) == true)
+ return item;
+ }
+
+ return null;
+ }
+
+ static MenuItem FindItemByKey (Menu menu, IntPtr key)
+ {
+ char key_char = (char ) (key.ToInt32() & 0xff);
+ key_char = Char.ToUpper (key_char);
+
+ foreach (MenuItem item in menu.MenuItems) {
+ if (item.Mnemonic == '\0')
+ continue;
+
+ if (item.Mnemonic == key_char)
+ return item;
+ }
+
+ return null;
+ }
+
+ enum ItemNavigation {
+ First,
+ Last,
+ Next,
+ Previous,
+ }
+
+ static MenuItem GetNextItem (Menu menu, ItemNavigation navigation)
+ {
+ int pos = 0;
+ bool selectable_items = false;
+ MenuItem item;
+
+ // Check if there is at least a selectable item
+ for (int i = 0; i < menu.MenuItems.Count; i++) {
+ item = menu.MenuItems [i];
+ if (item.Separator == false && item.Visible == true) {
+ selectable_items = true;
+ break;
+ }
+ }
+
+ if (selectable_items == false)
+ return null;
+
+ switch (navigation) {
+ case ItemNavigation.First:
+
+ /* First item that is not separator and it is visible*/
+ for (pos = 0; pos < menu.MenuItems.Count; pos++) {
+ item = menu.MenuItems [pos];
+ if (item.Separator == false && item.Visible == true)
+ break;
+ }
+
+ break;
+
+ case ItemNavigation.Last: // Not used
+ break;
+
+ case ItemNavigation.Next:
+
+ if (menu.SelectedItem != null)
+ pos = menu.SelectedItem.Index;
+
+ /* Next item that is not separator and it is visible*/
+ for (pos++; pos < menu.MenuItems.Count; pos++) {
+ item = menu.MenuItems [pos];
+ if (item.Separator == false && item.Visible == true)
+ break;
+ }
+
+ if (pos >= menu.MenuItems.Count) { /* Jump at the start of the menu */
+ pos = 0;
+ /* Next item that is not separator and it is visible*/
+ for (; pos < menu.MenuItems.Count; pos++) {
+ item = menu.MenuItems [pos];
+ if (item.Separator == false && item.Visible == true)
+ break;
+ }
+ }
+ break;
+
+ case ItemNavigation.Previous:
+
+ if (menu.SelectedItem != null)
+ pos = menu.SelectedItem.Index;
+
+ /* Previous item that is not separator and it is visible*/
+ for (pos--; pos >= 0; pos--) {
+ item = menu.MenuItems [pos];
+ if (item.Separator == false && item.Visible == true)
+ break;
+ }
+
+ if (pos < 0 ) { /* Jump at the end of the menu*/
+ pos = menu.MenuItems.Count - 1;
+ /* Previous item that is not separator and it is visible*/
+ for (; pos >= 0; pos--) {
+ item = menu.MenuItems [pos];
+ if (item.Separator == false && item.Visible == true)
+ break;
+ }
+ }
+
+ break;
+
+ default:
+ break;
+ }
+
+ return menu.MenuItems [pos];
+ }
+
+ void ProcessMenuKey (Msg msg_type)
+ {
+ if (TopMenu.MenuItems.Count == 0)
+ return;
+
+ MainMenu main_menu = TopMenu as MainMenu;
+
+ switch (msg_type) {
+ case Msg.WM_SYSKEYDOWN:
+ switch (keynav_state) {
+ case KeyNavState.Idle:
+ keynav_state = KeyNavState.Startup;
+ CurrentMenu = TopMenu;
+ main_menu.Draw ();
+ break;
+ case KeyNavState.Startup:
+ break;
+ default:
+ keynav_state = KeyNavState.Idle;
+ Deactivate ();
+ main_menu.Draw ();
+ break;
+ }
+ break;
+
+ case Msg.WM_SYSKEYUP:
+ switch (keynav_state) {
+ case KeyNavState.Idle:
+ case KeyNavState.Navigating:
+ break;
+ case KeyNavState.Startup:
+ keynav_state = KeyNavState.NoPopups;
+ SelectItem (TopMenu, TopMenu.MenuItems [0], false);
+ break;
+ default:
+ keynav_state = KeyNavState.Idle;
+ Deactivate ();
+ main_menu.Draw ();
+ break;
+ }
+ break;
+
+ default:
+ throw new ArgumentException ("Invalid msg_type " + msg_type);
+ }
+ }
+
+ bool ProcessMnemonic (Message msg, Keys key_data)
+ {
+ keynav_state = KeyNavState.Navigating;
+ MenuItem item = FindItemByKey (CurrentMenu, msg.WParam);
+ if (item == null)
+ return false;
+
+ SelectItem (CurrentMenu, item, true);
+ if (item.IsPopup) {
+ SelectItem (item, item.MenuItems [0], false);
+ CurrentMenu = item;
+ }
+ return true;
+ }
+
+ void ProcessArrowKey (Keys keyData)
+ {
+ MenuItem item;
+ switch (keyData) {
+ case Keys.Up:
+ if (CurrentMenu is MainMenu)
+ return;
+ else if (CurrentMenu.MenuItems.Count == 1 && CurrentMenu.parent_menu == TopMenu) {
+ DeselectItem (CurrentMenu.SelectedItem);
+ CurrentMenu = TopMenu;
+ return;
+ }
+ item = GetNextItem (CurrentMenu, ItemNavigation.Previous);
+ if (item != null)
+ SelectItem (CurrentMenu, item, false);
+ break;
+
+ case Keys.Down:
+ if (CurrentMenu is MainMenu) {
+ if (CurrentMenu.SelectedItem != null && CurrentMenu.SelectedItem.IsPopup) {
+ keynav_state = KeyNavState.Navigating;
+ item = CurrentMenu.SelectedItem;
+ ShowSubPopup (CurrentMenu, item);
+ SelectItem (item, item.MenuItems [0], false);
+ CurrentMenu = item;
+ }
+ return;
+ }
+ item = GetNextItem (CurrentMenu, ItemNavigation.Next);
+ if (item != null)
+ SelectItem (CurrentMenu, item, false);
+ break;
+
+ case Keys.Right:
+ if (CurrentMenu is MainMenu) {
+ item = GetNextItem (CurrentMenu, ItemNavigation.Next);
+ bool popup = item.IsPopup && keynav_state != KeyNavState.NoPopups;
+ SelectItem (CurrentMenu, item, popup);
+ if (popup) {
+ SelectItem (item, item.MenuItems [0], false);
+ CurrentMenu = item;
+ }
+ } else if (CurrentMenu.SelectedItem.IsPopup) {
+ item = CurrentMenu.SelectedItem;
+ ShowSubPopup (CurrentMenu, item);
+ SelectItem (item, item.MenuItems [0], false);
+ CurrentMenu = item;
+ } else if (CurrentMenu.parent_menu is MainMenu) {
+ item = GetNextItem (CurrentMenu.parent_menu, ItemNavigation.Next);
+ SelectItem (CurrentMenu.parent_menu, item, item.IsPopup);
+ if (item.IsPopup) {
+ SelectItem (item, item.MenuItems [0], false);
+ CurrentMenu = item;
+ }
+ }
+ break;
+
+ case Keys.Left:
+ if (CurrentMenu is MainMenu) {
+ item = GetNextItem (CurrentMenu, ItemNavigation.Previous);
+ bool popup = item.IsPopup && keynav_state != KeyNavState.NoPopups;
+ SelectItem (CurrentMenu, item, popup);
+ if (popup) {
+ SelectItem (item, item.MenuItems [0], false);
+ CurrentMenu = item;
+ }
+ } else if (CurrentMenu.parent_menu is MainMenu) {
+ item = GetNextItem (CurrentMenu.parent_menu, ItemNavigation.Previous);
+ SelectItem (CurrentMenu.parent_menu, item, item.IsPopup);
+ if (item.IsPopup) {
+ SelectItem (item, item.MenuItems [0], false);
+ CurrentMenu = item;
+ }
+ } else {
+ HideSubPopups (CurrentMenu);
+ CurrentMenu = CurrentMenu.parent_menu;
+ }
+ break;
+ default:
+ throw new ArgumentException ("Invalid keyData: " + keyData);
+ }
+ }
+
+ Hashtable shortcuts = new Hashtable ();
+
+ public void AddShortcuts (MenuItem item)
+ {
+ foreach (MenuItem child in item.MenuItems) {
+ AddShortcuts (child);
+ if (child.Shortcut != Shortcut.None)
+ shortcuts [(int)child.Shortcut] = child;
+ }
+
+ if (item.Shortcut != Shortcut.None)
+ shortcuts [(int)item.Shortcut] = item;
+ }
+
+ public void RemoveShortcuts (MenuItem item)
+ {
+ foreach (MenuItem child in item.MenuItems) {
+ RemoveShortcuts (child);
+ if (child.Shortcut != Shortcut.None)
+ shortcuts.Remove ((int)child.Shortcut);
+ }
+
+ if (item.Shortcut != Shortcut.None)
+ shortcuts.Remove ((int)item.Shortcut);
+ }
+
+ bool ProcessShortcut (Keys keyData)
+ {
+ MenuItem item = shortcuts [(int)keyData] as MenuItem;
+ if (item == null)
+ return false;
+
+ Deactivate ();
+ item.PerformClick ();
+ return true;
+ }
+
+ public bool ProcessKeys (ref Message msg, Keys keyData)
+ {
+ if ((Msg)msg.Msg != Msg.WM_SYSKEYUP && ProcessShortcut (keyData))
+ return true;
+ else if ((keyData & Keys.KeyCode) == Keys.Menu && TopMenu is MainMenu) {
+ ProcessMenuKey ((Msg) msg.Msg);
+ return true;
+ } else if ((keyData & Keys.Alt) == Keys.Alt)
+ return ProcessMnemonic (msg, keyData);
+ else if ((Msg)msg.Msg == Msg.WM_SYSKEYUP || keynav_state == KeyNavState.Idle)
+ return false;
+ else if (!active)
+ return false;
+
+ switch (keyData) {
+ case Keys.Up:
+ case Keys.Down:
+ case Keys.Right:
+ case Keys.Left:
+ ProcessArrowKey (keyData);
+ break;
+
+ case Keys.Escape:
+ Deactivate ();
+ break;
+
+ case Keys.Return:
+ ExecFocusedItem (CurrentMenu, CurrentMenu.SelectedItem);
+ break;
+
+ default:
+ ProcessMnemonic (msg, keyData);
+ break;
+ }
+
+ return true;
+ }
+ }
+
+ internal class PopUpWindow : Control
+ {
+ private Menu menu;
+
+ public PopUpWindow (Menu menu): base ()
+ {
+ this.menu = menu;
+ Paint += new PaintEventHandler (OnPaintPUW);
+ SetStyle (ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle (ControlStyles.ResizeRedraw | ControlStyles.Opaque, true);
+ is_visible = false;
+ }
+
+ protected override CreateParams CreateParams
+ {
+ get {
+ CreateParams cp = base.CreateParams;
+ cp.Caption = "Menu PopUp";
+ cp.Style = unchecked ((int)(WindowStyles.WS_POPUP));
+ cp.ExStyle |= (int)(WindowExStyles.WS_EX_TOOLWINDOW | WindowExStyles.WS_EX_TOPMOST);
+ return cp;
+ }
+ }
+
+ public void ShowWindow ()
+ {
+ Show ();
+ RefreshItems ();
+ Refresh ();
+ }
+
+ private void OnPaintPUW (Object o, PaintEventArgs args)
+ {
+ ThemeEngine.Current.DrawPopupMenu (args.Graphics, menu, args.ClipRectangle, ClientRectangle);
+ }
+
+ public void HideWindow ()
+ {
+ MenuTracker.HideSubPopups (menu);
+ Hide ();
+ }
+
+#if false
+ protected override bool ProcessCmdKey (ref Message msg, Keys keyData)
+ {
+ return MenuTracker.ProcessKeys (menu, ref msg, keyData, tracker);
+ }
+#endif
+
+ protected override void CreateHandle ()
+ {
+ base.CreateHandle ();
+ RefreshItems ();
+ }
+
+ // Called when the number of items has changed
+ internal void RefreshItems ()
+ {
+ ThemeEngine.Current.CalcPopupMenuSize (DeviceContext, menu);
+
+ if ((Location.X + menu.Rect.Width) > SystemInformation.WorkingArea.Width) {
+ Location = new Point (Location.X - menu.Rect.Width, Location.Y);
+ }
+ if ((Location.Y + menu.Rect.Height) > SystemInformation.WorkingArea.Height) {
+ Location = new Point (Location.X, Location.Y - menu.Rect.Height);
+ }
+
+ Width = menu.Rect.Width;
+ Height = menu.Rect.Height;
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuGlyph.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuGlyph.cs
new file mode 100644
index 00000000000..459337ae4ba
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuGlyph.cs
@@ -0,0 +1,36 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum MenuGlyph {
+ Arrow = 0,
+ Min = 0,
+ Checkmark = 1,
+ Bullet = 2,
+ Max = 2
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuItem.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuItem.cs
new file mode 100644
index 00000000000..89b75fd08da
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuItem.cs
@@ -0,0 +1,678 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+//
+
+// NOT COMPLETE
+
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.Drawing.Text;
+
+namespace System.Windows.Forms
+{
+ [DefaultProperty("Text")]
+ [DefaultEvent("Click")]
+ [DesignTimeVisible(false)]
+ [ToolboxItem(false)]
+ public class MenuItem : Menu
+ {
+ internal bool separator;
+ internal bool break_;
+ internal bool bar_break;
+ private Shortcut shortcut;
+ private string text;
+ private bool checked_;
+ private bool radiocheck;
+ private bool enabled;
+ private char mnemonic;
+ private bool showshortcut;
+ private int index;
+ private bool mdilist;
+ private Hashtable mdilist_items;
+ private MdiClient mdicontainer;
+ private bool defaut_item;
+ private bool visible;
+ private bool ownerdraw;
+ private int menuid;
+ private int mergeorder;
+ private int xtab;
+ private int menuheight;
+ private bool menubar;
+ private DrawItemState status;
+ private MenuMerge mergetype;
+ internal Rectangle bounds;
+
+ public MenuItem (): base (null)
+ {
+ CommonConstructor (string.Empty);
+ shortcut = Shortcut.None;
+ }
+
+ public MenuItem (string text) : base (null)
+ {
+ CommonConstructor (text);
+ shortcut = Shortcut.None;
+ }
+
+ public MenuItem (string text, EventHandler onClick) : base (null)
+ {
+ CommonConstructor (text);
+ shortcut = Shortcut.None;
+ Click += onClick;
+ }
+
+ public MenuItem (string text, MenuItem[] items) : base (items)
+ {
+ CommonConstructor (text);
+ shortcut = Shortcut.None;
+ }
+
+ public MenuItem (string text, EventHandler onClick, Shortcut shortcut) : base (null)
+ {
+ CommonConstructor (text);
+ Click += onClick;
+ this.shortcut = shortcut;
+ }
+
+ public MenuItem (MenuMerge mergeType, int mergeOrder, Shortcut shortcut, string text,
+ EventHandler onClick, EventHandler onPopup, EventHandler onSelect, MenuItem[] items)
+ : base (items)
+ {
+ CommonConstructor (text);
+ this.shortcut = shortcut;
+ mergeorder = mergeOrder;
+ mergetype = mergeType;
+
+ Click += onClick;
+ Popup += onPopup;
+ Select += onSelect;
+ }
+
+ private void CommonConstructor (string text)
+ {
+ defaut_item = false;
+ separator = false;
+ break_ = false;
+ bar_break = false;
+ checked_ = false;
+ radiocheck = false;
+ enabled = true;
+ showshortcut = true;
+ visible = true;
+ ownerdraw = false;
+ status = DrawItemState.None;
+ menubar = false;
+ menuheight = 0;
+ xtab = 0;
+ index = -1;
+ mnemonic = '\0';
+ menuid = -1;
+ mergeorder = 0;
+ mergetype = MenuMerge.Add;
+ Text = text; // Text can change separator status
+ }
+
+ #region Events
+ public event EventHandler Click;
+ public event DrawItemEventHandler DrawItem;
+ public event MeasureItemEventHandler MeasureItem;
+ public event EventHandler Popup;
+ public event EventHandler Select;
+ #endregion // Events
+
+ #region Public Properties
+
+ [Browsable(false)]
+ [DefaultValue(false)]
+ public bool BarBreak {
+ get { return break_; }
+ set { break_ = value; }
+ }
+
+ [Browsable(false)]
+ [DefaultValue(false)]
+ public bool Break {
+ get { return bar_break; }
+ set { bar_break = value; }
+ }
+
+ [DefaultValue(false)]
+ public bool Checked {
+ get { return checked_; }
+ set { checked_ = value; }
+ }
+
+ [DefaultValue(false)]
+ public bool DefaultItem {
+ get { return defaut_item; }
+ set { defaut_item = value; }
+ }
+
+ [DefaultValue(true)]
+ [Localizable(true)]
+ public bool Enabled {
+ get { return enabled; }
+ set { enabled = value; }
+ }
+
+ [Browsable(false)]
+ public int Index {
+ get { return index; }
+ set {
+ if (Parent != null && Parent.MenuItems != null && (value < 0 || value >= Parent.MenuItems.Count))
+ throw new ArgumentException ("'" + value + "' is not a valid value for 'value'");
+ index = value;
+ }
+ }
+
+ [Browsable(false)]
+ public override bool IsParent {
+ get { return IsPopup; }
+ }
+
+ [DefaultValue(false)]
+ public bool MdiList {
+ get { return mdilist; }
+ set {
+ if (mdilist == value)
+ return;
+ mdilist = value;
+
+ if (mdilist || mdilist_items == null)
+ return;
+
+ foreach (MenuItem item in mdilist_items.Keys)
+ MenuItems.Remove (item);
+ mdilist_items.Clear ();
+ mdilist_items = null;
+
+ }
+ }
+
+ protected int MenuID {
+ get { return menuid; }
+ }
+
+ [DefaultValue(0)]
+ public int MergeOrder {
+ get { return mergeorder; }
+ set { mergeorder = value; }
+ }
+
+ [DefaultValue(MenuMerge.Add)]
+ public MenuMerge MergeType {
+ get { return mergetype; }
+ set {
+ if (!Enum.IsDefined (typeof (MenuMerge), value))
+ throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for MenuMerge", value));
+
+ mergetype = value;
+ }
+ }
+
+ [Browsable(false)]
+ public char Mnemonic {
+ get { return mnemonic; }
+ }
+
+ [DefaultValue(false)]
+ public bool OwnerDraw {
+ get { return ownerdraw; }
+ set { ownerdraw = value; }
+ }
+
+ [Browsable(false)]
+ public Menu Parent {
+ get { return parent_menu;}
+ }
+
+ [DefaultValue(false)]
+ public bool RadioCheck {
+ get { return radiocheck; }
+ set { radiocheck = value; }
+ }
+
+ [DefaultValue(Shortcut.None)]
+ [Localizable(true)]
+ public Shortcut Shortcut {
+ get { return shortcut;}
+ set {
+ if (!Enum.IsDefined (typeof (Shortcut), value))
+ throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for Shortcut", value));
+
+ shortcut = value;
+ }
+ }
+
+ [DefaultValue(true)]
+ [Localizable(true)]
+ public bool ShowShortcut {
+ get { return showshortcut;}
+ set { showshortcut = value; }
+ }
+
+ [Localizable(true)]
+ public string Text {
+ get { return text; }
+ set {
+ text = value;
+
+ if (text == "-")
+ separator = true;
+ else
+ separator = false;
+
+ ProcessMnemonic ();
+ }
+ }
+
+ [DefaultValue(true)]
+ [Localizable(true)]
+ public bool Visible {
+ get { return visible;}
+ set {
+ if (value == visible)
+ return;
+
+ visible = value;
+
+ if (menu_items != null) {
+ foreach (MenuItem mi in menu_items)
+ mi.Visible = value;
+ }
+
+ if (parent_menu != null)
+ parent_menu.OnMenuChanged (EventArgs.Empty);
+ }
+ }
+
+ #endregion Public Properties
+
+ #region Private Properties
+
+ internal new int Height {
+ get { return bounds.Height; }
+ set { bounds.Height = value; }
+ }
+
+ internal bool IsPopup {
+ get {
+ if (menu_items.Count > 0)
+ return true;
+ else
+ return false;
+ }
+ }
+
+ internal bool MeasureEventDefined {
+ get {
+ if (ownerdraw == true && MeasureItem != null) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+
+ internal bool MenuBar {
+ get { return menubar; }
+ set { menubar = value; }
+ }
+
+ internal int MenuHeight {
+ get { return menuheight; }
+ set { menuheight = value; }
+ }
+
+ internal bool Separator {
+ get { return separator; }
+ set { separator = value; }
+ }
+
+ internal DrawItemState Status {
+ get { return status; }
+ set { status = value; }
+ }
+
+ internal new int Width {
+ get { return bounds.Width; }
+ set { bounds.Width = value; }
+ }
+
+ internal new int X {
+ get { return bounds.X; }
+ set { bounds.X = value; }
+ }
+
+ internal int XTab {
+ get { return xtab; }
+ set { xtab = value; }
+ }
+
+ internal new int Y {
+ get { return bounds.Y; }
+ set { bounds.Y = value; }
+ }
+
+ #endregion Private Properties
+
+ #region Public Methods
+
+ public virtual MenuItem CloneMenu ()
+ {
+ MenuItem item = new MenuItem ();
+ item.CloneMenu (this);
+ return item;
+ }
+
+ protected void CloneMenu (MenuItem menuitem)
+ {
+ base.CloneMenu (menuitem); // Copy subitems
+
+ // Properties
+ BarBreak = menuitem.BarBreak;
+ Break = menuitem.Break;
+ Checked = menuitem.Checked;
+ DefaultItem = menuitem.DefaultItem;
+ Enabled = menuitem.Enabled;
+ MergeOrder = menuitem.MergeOrder;
+ MergeType = menuitem.MergeType;
+ OwnerDraw = menuitem.OwnerDraw;
+ //Parent = menuitem.Parent;
+ RadioCheck = menuitem.RadioCheck;
+ Shortcut = menuitem.Shortcut;
+ ShowShortcut = menuitem.ShowShortcut;
+ Text = menuitem.Text;
+ Visible = menuitem.Visible;
+
+ // Events
+ Click = menuitem.Click;
+ DrawItem = menuitem.DrawItem;
+ MeasureItem = menuitem.MeasureItem;
+ Popup = menuitem.Popup;
+ Select = menuitem.Select;
+ }
+
+ protected override void Dispose (bool disposing)
+ {
+ base.Dispose (disposing);
+ }
+
+ // This really clones the item
+ public virtual MenuItem MergeMenu ()
+ {
+ MenuItem item = new MenuItem ();
+ item.CloneMenu (this);
+ return item;
+ }
+
+ public void MergeMenu (MenuItem menuitem)
+ {
+ base.MergeMenu (menuitem);
+ }
+
+ protected virtual void OnClick (EventArgs e)
+ {
+ if (Click != null)
+ Click (this, e);
+ }
+
+ protected virtual void OnDrawItem (DrawItemEventArgs e)
+ {
+ if (DrawItem != null) {
+ DrawItem (this, e);
+ return;
+ }
+
+ ThemeEngine.Current.DrawMenuItem (this, e);
+ }
+
+
+ protected virtual void OnInitMenuPopup (EventArgs e)
+ {
+ OnPopup (e);
+ }
+
+ protected virtual void OnMeasureItem (MeasureItemEventArgs e)
+ {
+ if (MeasureItem != null)
+ MeasureItem (this, e);
+ }
+
+ protected virtual void OnPopup (EventArgs e)
+ {
+ if (Popup != null)
+ Popup (this, e);
+ }
+
+ protected virtual void OnSelect (EventArgs e)
+ {
+ if (Select != null)
+ Select (this, e);
+ }
+
+ public void PerformClick ()
+ {
+ OnClick (EventArgs.Empty);
+ }
+
+ public virtual void PerformSelect ()
+ {
+ OnSelect (EventArgs.Empty);
+ }
+
+ public override string ToString ()
+ {
+ return base.ToString () + ", Items.Count: " + MenuItems.Count + ", Text: " + text;
+ }
+
+ #endregion Public Methods
+
+ #region Private Methods
+
+ internal void PerformPopup ()
+ {
+ OnPopup (EventArgs.Empty);
+ }
+
+ internal void PerformDrawItem (DrawItemEventArgs e)
+ {
+ if (mdilist && mdilist_items == null) {
+ do {
+ // Add the mdilist for the first time
+ mdilist_items = new Hashtable ();
+
+ MainMenu main = GetMainMenu ();
+ if (main == null || main.GetForm () == null)
+ break;
+
+ Form form = main.GetForm ();
+ mdicontainer = form.MdiContainer;
+ if (mdicontainer == null)
+ break;
+
+ foreach (Form mdichild in mdicontainer.Controls) {
+ MenuItem item = new MenuItem (mdichild.Text);
+ item.Click += new EventHandler (MdiWindowClickHandler);
+ MenuItems.AddNoEvents (item);
+ mdilist_items.Add (item, form);
+ }
+
+ } while (false);
+ }
+
+ OnDrawItem (e);
+ }
+
+ internal void PerformMeasureItem (MeasureItemEventArgs e)
+ {
+ OnMeasureItem (e);
+ }
+
+ private void ProcessMnemonic ()
+ {
+ if (text.Length < 2) {
+ mnemonic = '\0';
+ return;
+ }
+
+ bool bPrevAmp = false;
+ for (int i = 0; i < text.Length -1 ; i++) {
+ if (text[i] == '&') {
+ if (bPrevAmp == false && (text[i+1] != '&')) {
+ mnemonic = Char.ToUpper (text[i+1]);
+ return;
+ }
+
+ bPrevAmp = true;
+ }
+ else
+ bPrevAmp = false;
+ }
+
+ mnemonic = '\0';
+ }
+
+ private string GetShortCutTextCtrl () { return "Ctrl"; }
+ private string GetShortCutTextAlt () { return "Alt"; }
+ private string GetShortCutTextShift () { return "Shift"; }
+
+ internal string GetShortCutText ()
+ {
+ /* Ctrl+A - Ctrl+Z */
+ if (Shortcut >= Shortcut.CtrlA && Shortcut <= Shortcut.CtrlZ)
+ return GetShortCutTextCtrl () + "+" + (char)((int) 'A' + (int)(Shortcut - Shortcut.CtrlA));
+
+ /* Alt+0 - Alt+9 */
+ if (Shortcut >= Shortcut.Alt0 && Shortcut <= Shortcut.Alt9)
+ return GetShortCutTextAlt () + "+" + (char)((int) '0' + (int)(Shortcut - Shortcut.Alt0));
+
+ /* Alt+F1 - Alt+F2 */
+ if (Shortcut >= Shortcut.AltF1 && Shortcut <= Shortcut.AltF9)
+ return GetShortCutTextAlt () + "+F" + (char)((int) '1' + (int)(Shortcut - Shortcut.AltF1));
+
+ /* Ctrl+0 - Ctrl+9 */
+ if (Shortcut >= Shortcut.Ctrl0 && Shortcut <= Shortcut.Ctrl9)
+ return GetShortCutTextCtrl () + "+" + (char)((int) '0' + (int)(Shortcut - Shortcut.Ctrl0));
+
+ /* Ctrl+F0 - Ctrl+F9 */
+ if (Shortcut >= Shortcut.CtrlF1 && Shortcut <= Shortcut.CtrlF9)
+ return GetShortCutTextCtrl () + "+F" + (char)((int) '1' + (int)(Shortcut - Shortcut.CtrlF1));
+
+ /* Ctrl+Shift+0 - Ctrl+Shift+9 */
+ if (Shortcut >= Shortcut.CtrlShift0 && Shortcut <= Shortcut.CtrlShift9)
+ return GetShortCutTextCtrl () + "+" + GetShortCutTextShift () + "+" + (char)((int) '0' + (int)(Shortcut - Shortcut.CtrlShift0));
+
+ /* Ctrl+Shift+A - Ctrl+Shift+Z */
+ if (Shortcut >= Shortcut.CtrlShiftA && Shortcut <= Shortcut.CtrlShiftZ)
+ return GetShortCutTextCtrl () + "+" + GetShortCutTextShift () + "+" + (char)((int) 'A' + (int)(Shortcut - Shortcut.CtrlShiftA));
+
+ /* Ctrl+Shift+F1 - Ctrl+Shift+F9 */
+ if (Shortcut >= Shortcut.CtrlShiftF1 && Shortcut <= Shortcut.CtrlShiftF9)
+ return GetShortCutTextCtrl () + "+" + GetShortCutTextShift () + "+F" + (char)((int) '1' + (int)(Shortcut - Shortcut.CtrlShiftF1));
+
+ /* F1 - F9 */
+ if (Shortcut >= Shortcut.F1 && Shortcut <= Shortcut.F9)
+ return "F" + (char)((int) '1' + (int)(Shortcut - Shortcut.F1));
+
+ /* Shift+F1 - Shift+F9 */
+ if (Shortcut >= Shortcut.ShiftF1 && Shortcut <= Shortcut.ShiftF9)
+ return GetShortCutTextShift () + "+F" + (char)((int) '1' + (int)(Shortcut - Shortcut.ShiftF1));
+
+ /* Special cases */
+ switch (Shortcut) {
+ case Shortcut.AltBksp:
+ return "AltBksp";
+ case Shortcut.AltF10:
+ return GetShortCutTextAlt () + "+F10";
+ case Shortcut.AltF11:
+ return GetShortCutTextAlt () + "+F11";
+ case Shortcut.AltF12:
+ return GetShortCutTextAlt () + "+F12";
+ case Shortcut.CtrlDel:
+ return GetShortCutTextCtrl () + "+Del";
+ case Shortcut.CtrlF10:
+ return GetShortCutTextCtrl () + "+F10";
+ case Shortcut.CtrlF11:
+ return GetShortCutTextCtrl () + "+F11";
+ case Shortcut.CtrlF12:
+ return GetShortCutTextCtrl () + "+F12";
+ case Shortcut.CtrlIns:
+ return GetShortCutTextCtrl () + "+Ins";
+ case Shortcut.CtrlShiftF10:
+ return GetShortCutTextCtrl () + "+" + GetShortCutTextShift () + "+F10";
+ case Shortcut.CtrlShiftF11:
+ return GetShortCutTextCtrl () + "+" + GetShortCutTextShift () + "+F11";
+ case Shortcut.CtrlShiftF12:
+ return GetShortCutTextCtrl () + "+" + GetShortCutTextShift () + "+F12";
+ case Shortcut.Del:
+ return "Del";
+ case Shortcut.F10:
+ return "F10";
+ case Shortcut.F11:
+ return "F11";
+ case Shortcut.F12:
+ return "F12";
+ case Shortcut.Ins:
+ return "Ins";
+ case Shortcut.None:
+ return "None";
+ case Shortcut.ShiftDel:
+ return GetShortCutTextShift () + "+Del";
+ case Shortcut.ShiftF10:
+ return GetShortCutTextShift () + "+F10";
+ case Shortcut.ShiftF11:
+ return GetShortCutTextShift () + "+F11";
+ case Shortcut.ShiftF12:
+ return GetShortCutTextShift () + "+F12";
+ case Shortcut.ShiftIns:
+ return GetShortCutTextShift () + "+Ins";
+ default:
+ break;
+ }
+
+ return "";
+ }
+
+ private void MdiWindowClickHandler (object sender, EventArgs e)
+ {
+ Form mdichild = (Form) mdilist_items [SelectedItem];
+
+ // people could add weird items to the Window menu
+ // so we can't assume its just us
+ if (mdichild == null)
+ return;
+
+ mdicontainer.ActivateChild (mdichild);
+ }
+
+ #endregion Private Methods
+
+ }
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuMerge.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuMerge.cs
new file mode 100644
index 00000000000..2df9a7b9be1
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuMerge.cs
@@ -0,0 +1,38 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+//
+
+namespace System.Windows.Forms
+{
+ public enum MenuMerge
+ {
+ Add = 0,
+ Replace = 1,
+ MergeItems = 2,
+ Remove = 3,
+ }
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Message.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Message.cs
new file mode 100644
index 00000000000..42649008dee
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Message.cs
@@ -0,0 +1,108 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+
+
+// COMPLETE
+
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Diagnostics;
+
+namespace System.Windows.Forms {
+ public struct Message {
+ private int msg;
+ private IntPtr hwnd;
+ private IntPtr lParam;
+ private IntPtr wParam;
+ private IntPtr result;
+
+ #region Public Instance Properties
+ public IntPtr HWnd {
+ get { return hwnd; }
+ set { hwnd=value; }
+ }
+
+ public IntPtr LParam {
+ get { return lParam; }
+ set { lParam=value; }
+ }
+
+ public int Msg {
+ get { return msg; }
+ set { msg=value; }
+ }
+
+ public IntPtr Result {
+ get { return result; }
+ set { result=value; }
+ }
+
+ public IntPtr WParam {
+ get { return wParam; }
+ set { wParam=value; }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Static Methods
+ public static Message Create(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam) {
+ Message new_message = new Message();
+
+ new_message.msg=msg;
+ new_message.hwnd=hWnd;
+ new_message.wParam=wparam;
+ new_message.lParam=lparam;
+ return new_message;
+ }
+ #endregion // Public Static Methods
+
+ #region Public Instance Methods
+ public override bool Equals(object o) {
+ if (!(o is Message)) {
+ return false;
+ }
+
+ return ((this.msg == ((Message)o).msg) &&
+ (this.hwnd == ((Message)o).hwnd) &&
+ (this.lParam == ((Message)o).lParam) &&
+ (this.wParam == ((Message)o).wParam) &&
+ (this.result == ((Message)o).result));
+ }
+
+ public override int GetHashCode() {
+ return base.GetHashCode();
+ }
+
+ public object GetLParam(Type cls) {
+ object o = Marshal.PtrToStructure(this.lParam, cls);
+
+ return(o);
+ }
+
+ public override string ToString() {
+ return String.Format("[{0} {1} {2} {3}]", msg.ToString(), lParam.ToString(), wParam.ToString(), hwnd.ToString());
+ }
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBox.cs
new file mode 100644
index 00000000000..499e99aee2c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBox.cs
@@ -0,0 +1,516 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez (jordi@ximian.com)
+// Benjamin Dasnois (benjamin.dasnois@gmail.com)
+// Robert Thompson (rmt@corporatism.org)
+// Peter Bartok (pbartok@novell.com)
+//
+// TODO:
+// - Complete the implementation when Form.BorderStyle is available.
+// - Add support for MessageBoxOptions and MessageBoxDefaultButton.
+// - Button size calculations assume fixed height for buttons, that could be bad
+//
+
+
+// NOT COMPLETE
+
+using System;
+using System.Drawing;
+using System.Globalization;
+using System.Resources;
+
+namespace System.Windows.Forms
+{
+ public class MessageBox
+ {
+ #region Private MessageBoxForm class
+ private class MessageBoxForm : Form
+ {
+ #region MessageBoxFrom Local Variables
+ internal static string Yes;
+ internal const int space_border = 10;
+ string msgbox_text;
+ bool size_known = false;
+ const int space_image_text= 10;
+ Image icon_image;
+ Point textleft_up;
+ MessageBoxButtons msgbox_buttons;
+ bool buttons_placed = false;
+ int button_left;
+ #endregion // MessageBoxFrom Local Variables
+
+ #region MessageBoxForm Constructors
+ public MessageBoxForm (IWin32Window owner, string text, string caption,
+ MessageBoxButtons buttons, MessageBoxIcon icon)
+ {
+ switch (icon) {
+ case MessageBoxIcon.None: {
+ icon_image = null;
+ break;
+ }
+
+ case MessageBoxIcon.Error: { // Same as MessageBoxIcon.Hand and MessageBoxIcon.Stop
+ icon_image = ThemeEngine.Current.Images(UIIcon.MessageBoxError);
+ break;
+ }
+
+ case MessageBoxIcon.Question: {
+ icon_image = ThemeEngine.Current.Images(UIIcon.MessageBoxQuestion);
+ break;
+ }
+
+ case MessageBoxIcon.Asterisk: { // Same as MessageBoxIcon.Information
+ icon_image = ThemeEngine.Current.Images(UIIcon.MessageBoxInfo);
+ break;
+ }
+
+ case MessageBoxIcon.Warning: { // Same as MessageBoxIcon.Exclamation:
+ icon_image = ThemeEngine.Current.Images(UIIcon.MessageBoxWarning);
+ break;
+ }
+ }
+
+ msgbox_text = text;
+ msgbox_buttons = buttons;
+ this.Text = caption;
+ this.Paint += new PaintEventHandler (MessageBoxForm_Paint);
+ }
+
+ [MonoTODO]
+ public MessageBoxForm (IWin32Window owner, string text, string caption,
+ MessageBoxButtons buttons, MessageBoxIcon icon,
+ MessageBoxDefaultButton defaultButton, MessageBoxOptions options) : this (owner, text, caption, buttons, icon)
+ {
+ // Still needs to implement defaultButton and options
+
+ }
+ #endregion // MessageBoxForm Constructors
+
+ #region Protected Instance Properties
+ protected override CreateParams CreateParams {
+ get {
+ CreateParams cp;
+
+ ControlBox = true;
+ MinimizeBox = false;
+ MaximizeBox = false;
+
+ cp = base.CreateParams;
+
+ cp.Style = (int)(WindowStyles.WS_DLGFRAME | WindowStyles.WS_POPUP | WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_CLIPSIBLINGS | WindowStyles.WS_CAPTION);
+ if (!is_enabled) {
+ cp.Style |= (int)(WindowStyles.WS_DISABLED);
+ }
+
+ return cp;
+ }
+ }
+ #endregion // Protected Instance Properties
+
+ #region MessageBoxForm Methods
+ public DialogResult RunDialog ()
+ {
+ this.StartPosition = FormStartPosition.CenterScreen;
+
+ if (size_known == false) {
+ InitFormsSize ();
+ }
+
+ this.ShowDialog ();
+
+ return this.DialogResult;
+
+ }
+
+ private void MessageBoxForm_Paint (object sender, PaintEventArgs e)
+ {
+ e.Graphics.DrawString (msgbox_text, this.Font, ThemeEngine.Current.ResPool.GetSolidBrush (Color.Black), textleft_up);
+ if (icon_image != null) {
+ e.Graphics.DrawImage(icon_image, new Point(space_border, space_border));
+ }
+ }
+
+ private void InitFormsSize ()
+ {
+ int tb_width = 0;
+
+ // First we have to know the size of text + image
+ Drawing.SizeF tsize = DeviceContext.MeasureString (msgbox_text, this.Font);
+
+ if (icon_image != null) {
+ tsize.Width += icon_image.Width + 10;
+ if(icon_image.Height > tsize.Height) {
+ // Place text middle-right
+ textleft_up = new Point (icon_image.Width + space_image_text + space_border, (int)((icon_image.Height/2)-(tsize.Height/2)) + space_border);
+ } else {
+ textleft_up = new Point (icon_image.Width + space_image_text + space_border, 2 + space_border);
+ }
+ tsize.Height = icon_image.Height;
+ } else {
+ tsize.Width += space_border * 2;
+ textleft_up = new Point (space_border + 12, space_border + 12);
+ tsize.Height += space_border * 2;
+ }
+
+ // Now we want to know the width of buttons
+
+ switch (msgbox_buttons) {
+ case MessageBoxButtons.OK: {
+ tb_width = 110 * 1;
+ break;
+ }
+
+ case MessageBoxButtons.OKCancel: {
+ tb_width = 110 * 2;
+ break;
+ }
+
+ case MessageBoxButtons.AbortRetryIgnore: {
+ tb_width = 110 * 3;
+ break;
+ }
+
+ case MessageBoxButtons.YesNoCancel: {
+ tb_width = 110 * 3;
+ break;
+ }
+
+ case MessageBoxButtons.YesNo: {
+ tb_width = 110 * 2;
+ break;
+ }
+
+ case MessageBoxButtons.RetryCancel: {
+ tb_width = 110 * 2;
+ break;
+ }
+ }
+
+ // Now we choose the good size for the form
+ if (tsize.ToSize ().Width > tb_width) {
+ //this.Width = tsize.ToSize().Width + 10;
+ this.ClientSize = new Size(tsize.ToSize().Width + 10 + (space_border * 2), Height = tsize.ToSize ().Height + 40 + (space_border * 2));
+ } else {
+ //this.Width = tb_width + 10;
+ this.ClientSize = new Size(tb_width + 10 + (space_border * 2), Height = tsize.ToSize ().Height + 40 + (space_border * 2));
+ }
+
+ // Now we set the left of the buttons
+ button_left = (this.ClientSize.Width / 2) - (tb_width / 2) + 5;
+ AddButtons ();
+ size_known = true;
+ }
+ #endregion // MessageBoxForm Methods
+
+ #region Functions for Adding buttons
+ private void AddButtons()
+ {
+ if (!buttons_placed) {
+ switch (msgbox_buttons) {
+ case MessageBoxButtons.OK: {
+ AddOkButton (0 + button_left);
+ break;
+ }
+
+ case MessageBoxButtons.OKCancel: {
+ AddOkButton (0 + button_left);
+ AddCancelButton (110 + button_left);
+ break;
+ }
+
+ case MessageBoxButtons.AbortRetryIgnore: {
+ AddAbortButton (0 + button_left);
+ AddRetryButton (110 + button_left);
+ AddIgnoreButton (220 + button_left);
+ break;
+ }
+
+ case MessageBoxButtons.YesNoCancel: {
+ AddYesButton (0 + button_left);
+ AddNoButton (110 + button_left);
+ AddCancelButton (220 + button_left);
+ break;
+ }
+
+ case MessageBoxButtons.YesNo: {
+ AddYesButton (0 + button_left);
+ AddNoButton (110 + button_left);
+ break;
+ }
+
+ case MessageBoxButtons.RetryCancel: {
+ AddRetryButton (0 + button_left);
+ AddCancelButton (110 + button_left);
+ break;
+ }
+ }
+ buttons_placed = true;
+ }
+ }
+
+ private void AddOkButton (int left)
+ {
+ Button bok = new Button ();
+ bok.Text = Locale.GetText("OK");
+ bok.Width = 100;
+ bok.Height = 30;
+ bok.Top = this.ClientSize.Height - 35 - space_border;
+ bok.Left = left;
+ bok.Click += new EventHandler (OkClick);
+ AcceptButton = bok;
+ this.Controls.Add (bok);
+ }
+
+ private void AddCancelButton (int left)
+ {
+ Button bcan = new Button ();
+ bcan.Text = Locale.GetText("Cancel");
+ bcan.Width = 100;
+ bcan.Height = 30;
+ bcan.Top = this.ClientSize.Height - 35 - space_border;
+ bcan.Left = left;
+ bcan.Click += new EventHandler (CancelClick);
+ CancelButton = bcan;
+ this.Controls.Add (bcan);
+ }
+
+ private void AddAbortButton (int left)
+ {
+ Button babort = new Button ();
+ babort.Text = Locale.GetText("Abort");
+ babort.Width = 100;
+ babort.Height = 30;
+ babort.Top = this.ClientSize.Height - 35 - space_border;
+ babort.Left = left;
+ babort.Click += new EventHandler (AbortClick);
+ CancelButton = babort;
+ this.Controls.Add (babort);
+ }
+
+ private void AddRetryButton(int left)
+ {
+ Button bretry = new Button ();
+ bretry.Text = Locale.GetText("Retry");
+ bretry.Width = 100;
+ bretry.Height = 30;
+ bretry.Top = this.ClientSize.Height - 35 - space_border;
+ bretry.Left = left;
+ bretry.Click += new EventHandler (RetryClick);
+ AcceptButton = bretry;
+ this.Controls.Add (bretry);
+ }
+
+ private void AddIgnoreButton (int left)
+ {
+ Button bignore = new Button ();
+ bignore.Text = Locale.GetText("Ignore");
+ bignore.Width = 100;
+ bignore.Height = 30;
+ bignore.Top = this.ClientSize.Height - 35 - space_border;
+ bignore.Left = left;
+ bignore.Click += new EventHandler (IgnoreClick);
+ this.Controls.Add (bignore);
+ }
+
+ private void AddYesButton (int left)
+ {
+ Button byes = new Button ();
+ byes.Text = Locale.GetText("Yes");
+ byes.Width = 100;
+ byes.Height = 30;
+ byes.Top = this.ClientSize.Height - 35 - space_border;
+ byes.Left = left;
+ byes.Click += new EventHandler (YesClick);
+ AcceptButton = byes;
+ this.Controls.Add (byes);
+ }
+
+ private void AddNoButton (int left)
+ {
+ Button bno = new Button ();
+ bno.Text = Locale.GetText("No");
+ bno.Width = 100;
+ bno.Height = 30;
+ bno.Top = this.ClientSize.Height - 35 - space_border;
+ bno.Left = left;
+ bno.Click += new EventHandler (NoClick);
+ CancelButton = bno;
+ this.Controls.Add (bno);
+ }
+ #endregion
+
+ #region Button click handlers
+ private void OkClick (object sender, EventArgs e)
+ {
+ this.DialogResult = DialogResult.OK;
+ this.Close ();
+ }
+
+ private void CancelClick (object sender, EventArgs e)
+ {
+ this.DialogResult = DialogResult.Cancel;
+ this.Close ();
+ }
+
+ private void AbortClick (object sender, EventArgs e)
+ {
+ this.DialogResult = DialogResult.Abort;
+ this.Close ();
+ }
+
+ private void RetryClick (object sender, EventArgs e)
+ {
+ this.DialogResult = DialogResult.Retry;
+ this.Close ();
+ }
+
+ private void IgnoreClick (object sender, EventArgs e)
+ {
+ this.DialogResult = DialogResult.Ignore;
+ this.Close ();
+ }
+
+ private void YesClick (object sender, EventArgs e)
+ {
+ this.DialogResult = DialogResult.Yes;
+ this.Close ();
+ }
+
+ private void NoClick (object sender, EventArgs e)
+ {
+ this.DialogResult = DialogResult.No;
+ this.Close ();
+ }
+ #endregion
+ }
+ #endregion // Private MessageBoxForm class
+
+
+ #region Constructors
+ private MessageBox ()
+ {
+ }
+ #endregion // Constructors
+
+ #region Public Static Methods
+ public static DialogResult Show (string text)
+ {
+ MessageBoxForm form = new MessageBoxForm (null, text, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None);
+
+ return form.RunDialog ();
+
+ }
+
+ public static DialogResult Show (IWin32Window owner, string text)
+ {
+ MessageBoxForm form = new MessageBoxForm (owner, text, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None);
+
+ return form.RunDialog ();
+
+ }
+
+ public static DialogResult Show (string text, string caption)
+ {
+ MessageBoxForm form = new MessageBoxForm (null, text, caption, MessageBoxButtons.OK, MessageBoxIcon.None);
+
+ return form.RunDialog ();
+ }
+
+ public static DialogResult Show (string text, string caption, MessageBoxButtons buttons)
+ {
+ MessageBoxForm form = new MessageBoxForm (null, text, caption, buttons, MessageBoxIcon.None);
+
+ return form.RunDialog ();
+ }
+
+ public static DialogResult Show (IWin32Window owner, string text, string caption,
+ MessageBoxButtons buttons)
+ {
+ MessageBoxForm form = new MessageBoxForm (owner, text, caption, buttons, MessageBoxIcon.None);
+
+ return form.RunDialog ();
+ }
+
+ public static DialogResult Show (IWin32Window owner, string text, string caption,
+ MessageBoxButtons buttons, MessageBoxIcon icon)
+ {
+ MessageBoxForm form = new MessageBoxForm (owner, text, caption, buttons, icon);
+
+ return form.RunDialog ();
+ }
+
+
+ public static DialogResult Show (IWin32Window owner, string text, string caption)
+ {
+ MessageBoxForm form = new MessageBoxForm (owner, text, caption, MessageBoxButtons.OK, MessageBoxIcon.None);
+
+ return form.RunDialog ();
+ }
+
+
+ public static DialogResult Show (string text, string caption, MessageBoxButtons buttons,
+ MessageBoxIcon icon)
+ {
+ MessageBoxForm form = new MessageBoxForm (null, text, caption, buttons, icon);
+
+ return form.RunDialog ();
+ }
+
+ public static DialogResult Show (string text, string caption, MessageBoxButtons buttons,
+ MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
+ {
+
+ MessageBoxForm form = new MessageBoxForm (null, text, caption, buttons, icon, defaultButton, MessageBoxOptions.DefaultDesktopOnly);
+
+ return form.RunDialog ();
+
+ }
+
+ public static DialogResult Show (IWin32Window owner, string text, string caption,
+ MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
+ {
+ MessageBoxForm form = new MessageBoxForm (owner, text, caption, buttons, icon, defaultButton, MessageBoxOptions.DefaultDesktopOnly);
+
+ return form.RunDialog ();
+ }
+
+ public static DialogResult Show (string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,
+ MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
+ {
+ MessageBoxForm form = new MessageBoxForm (null, text, caption, buttons, icon, defaultButton, options);
+
+ return form.RunDialog ();
+ }
+
+ public static DialogResult Show (IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,
+ MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
+ {
+ MessageBoxForm form = new MessageBoxForm (owner, text, caption,
+ buttons, icon, defaultButton, options);
+
+ return form.RunDialog ();
+ }
+ #endregion // Public Static Methods
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBoxButtons.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBoxButtons.cs
new file mode 100644
index 00000000000..eea8234d4bc
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBoxButtons.cs
@@ -0,0 +1,43 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+//
+
+
+// COMPLETE
+
+
+namespace System.Windows.Forms
+{
+ public enum MessageBoxButtons
+ {
+ OK = 0,
+ OKCancel = 1,
+ AbortRetryIgnore = 2,
+ YesNoCancel = 3,
+ YesNo = 4,
+ RetryCancel = 5,
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBoxDefaultButton.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBoxDefaultButton.cs
new file mode 100644
index 00000000000..a5a1c4cca37
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBoxDefaultButton.cs
@@ -0,0 +1,40 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+//
+
+
+// COMPLETE
+
+
+namespace System.Windows.Forms
+{
+
+ public enum MessageBoxDefaultButton
+ {
+ Button1 = 0,
+ Button2 = 0x100,
+ Button3 = 0x200,
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBoxIcon.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBoxIcon.cs
new file mode 100644
index 00000000000..a2ec5cd3561
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBoxIcon.cs
@@ -0,0 +1,45 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+//
+
+
+// COMPLETE
+
+
+namespace System.Windows.Forms
+{
+ public enum MessageBoxIcon
+ {
+ None = 0x0000,
+ Error = 0x0010,
+ Hand = 0x0010,
+ Stop = 0x0010,
+ Question = 0x0020,
+ Exclamation = 0x0030,
+ Warning = 0x0030,
+ Asterisk = 0x0040,
+ Information = 0x0040,
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBoxOptions.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBoxOptions.cs
new file mode 100644
index 00000000000..ed505c9a8a9
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBoxOptions.cs
@@ -0,0 +1,41 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+ [Flags]
+ public enum MessageBoxOptions
+ {
+ DefaultDesktopOnly = 0x20000,
+ RightAlign = 0x80000,
+ RtlReading = 0x100000,
+ ServiceNotification = 0x200000,
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MethodInvoker.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MethodInvoker.cs
new file mode 100644
index 00000000000..67d3176a360
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MethodInvoker.cs
@@ -0,0 +1,32 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ [Serializable]
+ public delegate void MethodInvoker();
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Mime.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Mime.cs
new file mode 100644
index 00000000000..4983cd11e2e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Mime.cs
@@ -0,0 +1,1238 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+//
+// Alexander Olk xenomorph2@onlinehome.de
+//
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text.RegularExpressions;
+using System.Text;
+
+// Usage:
+// - for files:
+// string mimeType = Mime.GetMimeTypeForFile( string filename );
+// - for byte array:
+// string mimeType = Mime.GetMimeTypeForData( byte[] data );
+// - for string (maybe an email):
+// string mimeType = Mime.GetMimeTypeForString( string input );
+
+// - get alias for mime type:
+// string alias = Mime.GetMimeAlias( string mimeType );
+// - get subclass for mime type:
+// string subtype = Mime.GetMimeSubClass( string mimeType );
+// - get all available mime types:
+// string[] available = Mime.AvailableMimeTypes;
+
+// TODO:
+// - optimize even more :)
+// - async callback ?!?
+// - freedesktop org file extensions can have regular expressions also, resolve them too
+// - sort match collections by magic priority ( higher = first ) ?
+
+// internal test:
+// looking up the mime types 20 times for 2757 files in /usr/lib without caching (mime_file_cache)
+// old version: Time: 00:00:32.3791220
+// new version: Time: 00:00:16.9991810
+
+namespace System.Windows.Forms
+{
+ internal class Mime
+ {
+ public static Mime Instance = new Mime();
+
+ private string current_file_name;
+ private string global_result = octet_stream;
+
+ private FileStream file_stream;
+
+ private byte[] buffer = null;
+
+ private const string octet_stream = "application/octet-stream";
+ private const string text_plain = "text/plain";
+ private const string zero_file = "application/x-zerosize";
+
+ private StringDictionary mime_file_cache = new StringDictionary();
+
+ private const int mime_file_cache_max_size = 3000;
+
+ private string search_string;
+
+ private static object lock_object = new Object();
+
+// private int platform = (int) Environment.OSVersion.Platform;
+
+ private bool is_zero_file = false;
+
+ private int bytes_read = 0;
+
+ public static NameValueCollection Aliases;
+ public static NameValueCollection SubClasses;
+
+ public static NameValueCollection GlobalPatternsShort;
+ public static NameValueCollection GlobalPatternsLong;
+ public static NameValueCollection GlobalLiterals;
+ public static NameValueCollection GlobalSufPref;
+
+ public static ArrayList Matches80Plus;
+ public static ArrayList MatchesBelow80;
+
+ private Mime( )
+ {
+ Aliases = new NameValueCollection (new CaseInsensitiveHashCodeProvider (), new Comparer (System.Globalization.CultureInfo.CurrentUICulture));
+ SubClasses = new NameValueCollection (new CaseInsensitiveHashCodeProvider (), new Comparer (System.Globalization.CultureInfo.CurrentUICulture));
+ GlobalPatternsShort = new NameValueCollection (new CaseInsensitiveHashCodeProvider (), new Comparer (System.Globalization.CultureInfo.CurrentUICulture));
+ GlobalPatternsLong = new NameValueCollection (new CaseInsensitiveHashCodeProvider (), new Comparer (System.Globalization.CultureInfo.CurrentUICulture));
+ GlobalLiterals = new NameValueCollection (new CaseInsensitiveHashCodeProvider (), new Comparer (System.Globalization.CultureInfo.CurrentUICulture));
+ GlobalSufPref = new NameValueCollection (new CaseInsensitiveHashCodeProvider (), new Comparer (System.Globalization.CultureInfo.CurrentUICulture));
+ Matches80Plus = new ArrayList ();
+ MatchesBelow80 = new ArrayList ();
+
+ FDOMimeConfigReader fmcr = new FDOMimeConfigReader ();
+ int buffer_length = fmcr.Init ();
+
+ if (buffer_length != -1) {
+ buffer = new byte[ buffer_length ];
+ }
+ }
+
+ public static string GetMimeTypeForFile( string filename )
+ {
+ lock ( lock_object )
+ {
+ Instance.StartByFileName( filename );
+ }
+
+ return Instance.global_result;
+ }
+
+ // not tested
+ public static string GetMimeTypeForData( byte[] data )
+ {
+ lock ( lock_object )
+ {
+ Instance.StartDataLookup( data );
+ }
+
+ return Instance.global_result;
+ }
+
+ public static string GetMimeTypeForString( string input )
+ {
+ lock ( lock_object )
+ {
+ Instance.StartStringLookup( input );
+ }
+
+ return Instance.global_result;
+ }
+
+ public static string GetMimeAlias( string mimetype )
+ {
+ return Aliases[ mimetype ];
+ }
+
+ public static string GetMimeSubClass( string mimetype )
+ {
+ return SubClasses[ mimetype ];
+ }
+
+ private void StartByFileName( string filename )
+ {
+ if ( mime_file_cache.ContainsKey( filename ) )
+ {
+ global_result = mime_file_cache[ filename ];
+ return;
+ }
+
+ current_file_name = filename;
+ is_zero_file = false;
+
+// if ( !CheckForInode( ) )
+// {
+ global_result = octet_stream;
+
+ GoByFileName( );
+// }
+
+// if ( !mime_file_cache.ContainsKey( current_file_name ) )
+ mime_file_cache.Add( current_file_name, global_result );
+
+ // not tested
+ if ( mime_file_cache.Count > mime_file_cache_max_size )
+ {
+ IEnumerator enumerator = mime_file_cache.GetEnumerator( );
+
+ for ( int i = 0; i < mime_file_cache_max_size - 1000; i++ )
+ {
+ mime_file_cache.Remove( enumerator.Current.ToString( ) );
+ }
+ }
+ }
+
+ private void StartDataLookup( byte[] data )
+ {
+ global_result = octet_stream;
+
+ System.Array.Clear( buffer, 0, buffer.Length );
+
+ if ( data.Length > buffer.Length )
+ {
+ System.Array.Copy( data, buffer, buffer.Length );
+ }
+ else
+ {
+ System.Array.Copy( data, buffer, data.Length );
+ }
+
+ if ( CheckMatch80Plus( ) )
+ return;
+
+ if ( CheckMatchBelow80( ) )
+ return;
+
+ CheckForBinaryOrText( );
+ }
+
+ private void StartStringLookup( string input )
+ {
+ global_result = text_plain;
+
+ search_string = input;
+
+ if ( CheckForContentTypeString( ) )
+ return;
+ }
+
+// private bool CheckForInode( )
+// {
+// if ( ( platform == 4 ) || ( platform == 128 ) )
+// {
+//#if __MonoCS__
+// try
+// {
+// // *nix platform
+// Mono.Unix.UnixFileInfo ufi = new Mono.Unix.UnixFileInfo( current_file_name );
+//
+// if ( ufi.IsFile )
+// {
+// return false;
+// }
+// else
+// if ( ufi.IsDirectory )
+// {
+// global_result = "inode/directory";
+// return true;
+// }
+// else
+// if ( ufi.IsBlockDevice )
+// {
+// global_result = "inode/blockdevice";
+// return true;
+// }
+// else
+// if ( ufi.IsSocket )
+// {
+// global_result = "inode/socket";
+// return true;
+// }
+// else
+// if ( ufi.IsSymbolicLink )
+// {
+// global_result = "inode/symlink";
+// return true;
+// }
+// else
+// if ( ufi.IsCharacterDevice )
+// {
+// global_result = "inode/chardevice";
+// return true;
+// }
+// else
+// if ( ufi.IsFIFO )
+// {
+// global_result = "inode/fifo";
+// return true;
+// }
+// } catch( Exception e )
+// {
+// return false;
+// }
+//#endif
+// }
+// else
+// {
+// // TODO!!!!
+// // windows platform
+// }
+//
+// return false;
+// }
+
+ private void GoByFileName( )
+ {
+ // check if we can open the file
+ if ( !OpenFile( ) )
+ {
+ // couldn't open the file, check globals only
+ CheckGlobalPatterns( );
+
+ return;
+ }
+
+ if ( !is_zero_file )
+ {
+ // check for matches with a priority >= 80
+ if ( CheckMatch80Plus( ) )
+ return;
+ }
+
+ // check global patterns, aka file extensions...
+ // this should be done for zero size files also,
+ // for example zero size file trash.ccc~ should return
+ // application/x-trash instead of application/x-zerosize
+ if ( CheckGlobalPatterns( ) )
+ return;
+
+ // if file size is zero, no other checks are needed
+ if ( is_zero_file )
+ return;
+
+ // ok, still nothing matches then try matches with a priority < 80
+ if ( CheckMatchBelow80( ) )
+ return;
+
+ // wow, still nothing... return application/octet-stream for binary data, or text/plain for textual data
+ CheckForBinaryOrText( );
+ }
+
+ private bool CheckMatch80Plus( )
+ {
+ foreach ( Match match in Matches80Plus )
+ {
+ if ( TestMatch( match ) )
+ {
+ global_result = match.MimeType;
+
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ // this little helper method gives us a real speed improvement
+ private bool FastEndsWidth(string input, string value)
+ {
+ if (value.Length > input.Length)
+ return false;
+
+ int z = input.Length - 1;
+
+ for (int i = value.Length - 1; i > -1; i--) {
+ if (value[i] != input[z])
+ return false;
+
+ z--;
+ }
+
+ return true;
+ }
+
+ private bool FastStartsWith(string input, string value)
+ {
+ if (value.Length > input.Length)
+ return false;
+
+ for (int i = 0; i < value.Length; i++)
+ if (value[i] != input[i])
+ return false;
+
+ return true;
+ }
+
+ // start always with index = 0
+ private int FastIndexOf(string input, char value)
+ {
+ if (input.Length == 0)
+ return -1;
+
+ for (int i = 0; i < input.Length; i++)
+ if (input[i] == value)
+ return i;
+
+ return -1;
+ }
+
+ private int FastIndexOf(string input, string value)
+ {
+ if (input.Length == 0)
+ return -1;
+
+ for (int i = 0; i < input.Length - value.Length; i++) {
+ if (input[i] == value[0]) {
+ int counter = 0;
+ for (int z = 1; z < value.Length; z++) {
+ if (input[i+z] != value[z])
+ break;
+
+ counter++;
+ }
+ if (counter == value.Length -1) {
+ return i;
+ }
+ }
+ }
+
+ return -1;
+ }
+
+ private void CheckGlobalResult( )
+ {
+ int comma_index = FastIndexOf(global_result, ',');
+
+ if ( comma_index != -1 )
+ {
+ global_result = global_result.Substring( 0, comma_index );
+ }
+ }
+
+ private bool CheckGlobalPatterns( )
+ {
+ string filename = Path.GetFileName( current_file_name );
+
+ // first check for literals
+ for ( int i = 0; i < GlobalLiterals.Count; i++ )
+ {
+ string key = GlobalLiterals.GetKey(i);
+
+ // no regex char
+ if ( FastIndexOf(key, '[' ) == -1 )
+ {
+ if (FastIndexOf(filename, key) != -1)
+ {
+ global_result = GlobalLiterals[i];
+ CheckGlobalResult( );
+ return true;
+ }
+ }
+ else // regex it ;)
+ {
+ if ( Regex.IsMatch( filename, key ) )
+ {
+ global_result = GlobalLiterals[ i ];
+ CheckGlobalResult( );
+ return true;
+ }
+ }
+ }
+
+ if ( FastIndexOf(filename, '.' ) != -1 )
+ {
+ // check for double extension like .tar.gz
+ for ( int i = 0; i < GlobalPatternsLong.Count; i++ )
+ {
+ string key = GlobalPatternsLong.GetKey( i );
+
+ if (FastEndsWidth (filename, key))
+ {
+ global_result = GlobalPatternsLong[ i ];
+ CheckGlobalResult( );
+ return true;
+ }
+ else
+ {
+ if ( FastEndsWidth (filename.ToLower( ), key ) )
+ {
+ global_result = GlobalPatternsLong[ i ];
+ CheckGlobalResult( );
+ return true;
+ }
+ }
+ }
+
+ // check normal extensions...
+ string extension = Path.GetExtension( current_file_name );
+
+ if ( extension.Length != 0 )
+ {
+ global_result = GlobalPatternsShort[ extension ];
+
+ if ( global_result != null )
+ {
+ CheckGlobalResult( );
+ return true;
+ }
+
+ global_result = GlobalPatternsShort[ extension.ToLower( ) ];
+
+ if ( global_result != null )
+ {
+ CheckGlobalResult( );
+ return true;
+ }
+ }
+ }
+
+ // finally check if a prefix or suffix matches
+ for ( int i = 0; i < GlobalSufPref.Count; i++ )
+ {
+ string key = GlobalSufPref.GetKey( i );
+
+ if ( key[0] == '*' )
+ {
+ if (FastEndsWidth(filename, key.Replace( "*", "" )))
+ {
+ global_result = GlobalSufPref[ i ];
+ CheckGlobalResult( );
+ return true;
+ }
+ }
+ else
+ {
+ if ( FastStartsWith(filename, key.Replace( "*", "" ) ) )
+ {
+ global_result = GlobalSufPref[ i ];
+ CheckGlobalResult( );
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private bool CheckMatchBelow80( )
+ {
+ foreach ( Match match in MatchesBelow80 )
+ {
+ if ( TestMatch( match ) )
+ {
+ global_result = match.MimeType;
+
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private void CheckForBinaryOrText( )
+ {
+ // check the first 32 bytes
+
+ for ( int i = 0; i < 32; i++ )
+ {
+ char c = System.Convert.ToChar( buffer[ i ] );
+
+ if ( c != '\t' && c != '\n' && c != '\r' && c != 12 && c < 32 )
+ {
+ global_result = octet_stream;
+ return;
+ }
+ }
+
+ global_result = text_plain;
+ }
+
+ private bool TestMatch (Match match)
+ {
+ foreach (Matchlet matchlet in match.Matchlets)
+ if (TestMatchlet (matchlet))
+ return true;
+
+ return false;
+ }
+
+ private bool TestMatchlet( Matchlet matchlet )
+ {
+ // using a simple brute force search algorithm
+ // compare each (masked) value from the buffer with the (masked) value from the matchlet
+
+ // no need to check if the offset + the bytevalue length exceed the # bytes read
+ if (matchlet.Offset + matchlet.ByteValue.Length > bytes_read)
+ return false;
+
+ for ( int offset_counter = 0; offset_counter < matchlet.OffsetLength; offset_counter++ )
+ {
+ if (matchlet.Offset + offset_counter + matchlet.ByteValue.Length > bytes_read)
+ return false;
+
+ if ( matchlet.Mask == null )
+ {
+ if ( buffer[ matchlet.Offset + offset_counter ] == matchlet.ByteValue[ 0 ] )
+ {
+ if ( matchlet.ByteValue.Length == 1 )
+ {
+ if ( matchlet.Matchlets.Count > 0 )
+ {
+ foreach ( Matchlet sub_matchlet in matchlet.Matchlets )
+ {
+ if ( TestMatchlet( sub_matchlet ) )
+ return true;
+ }
+ }
+ else
+ return true;
+ }
+
+ int minus = 0;
+ // check if the last matchlet byte value is the same as the byte value in the buffer...
+ if (matchlet.ByteValue.Length > 2) {
+ if (buffer[ matchlet.Offset + offset_counter + matchlet.ByteValue.Length - 1 ] != matchlet.ByteValue[ matchlet.ByteValue.Length - 1 ])
+ return false;
+
+ minus = 1;
+ }
+
+ for ( int i = 1; i < matchlet.ByteValue.Length - minus; i++ )
+ {
+ if ( buffer[ matchlet.Offset + offset_counter + i ] != matchlet.ByteValue[ i ] )
+ return false;
+ }
+
+ if ( matchlet.Matchlets.Count > 0 )
+ {
+ foreach ( Matchlet sub_matchlets in matchlet.Matchlets )
+ {
+ if ( TestMatchlet( sub_matchlets ) )
+ return true;
+ }
+ }
+ else
+ return true;
+ }
+ }
+ else // with mask ( it's the same as above, only AND the byte with the corresponding mask byte
+ {
+ if ( ( buffer[ matchlet.Offset + offset_counter ] & matchlet.Mask[ 0 ] ) ==
+ ( matchlet.ByteValue[ 0 ] & matchlet.Mask[ 0 ] ) )
+ {
+ if ( matchlet.ByteValue.Length == 1 )
+ {
+ if ( matchlet.Matchlets.Count > 0 )
+ {
+ foreach ( Matchlet sub_matchlets in matchlet.Matchlets )
+ {
+ if ( TestMatchlet( sub_matchlets ) )
+ return true;
+ }
+ }
+ else
+ return true;
+ }
+
+ int minus = 0;
+ // check if the last matchlet byte value is the same as the byte value in the buffer...
+ if (matchlet.ByteValue.Length > 2) {
+
+ if ((buffer[ matchlet.Offset + offset_counter + matchlet.ByteValue.Length - 1 ] & matchlet.Mask[ matchlet.ByteValue.Length - 1 ])
+ != (matchlet.ByteValue[ matchlet.ByteValue.Length - 1 ] & matchlet.Mask[ matchlet.ByteValue.Length - 1 ]))
+ return false;
+
+ minus = 1;
+ }
+
+ for ( int i = 1; i < matchlet.ByteValue.Length - minus; i++ )
+ {
+ if ( ( buffer[ matchlet.Offset + offset_counter + i ] & matchlet.Mask[ i ] ) !=
+ ( matchlet.ByteValue[ i ] & matchlet.Mask[ i ] ) )
+ return false;
+ }
+
+ if ( matchlet.Matchlets.Count > 0 )
+ {
+ foreach ( Matchlet sub_matchlets in matchlet.Matchlets )
+ {
+ if ( TestMatchlet( sub_matchlets ) )
+ return true;
+ }
+ }
+ else
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private bool OpenFile( )
+ {
+ try
+ {
+ file_stream = new FileStream( current_file_name, FileMode.Open, FileAccess.Read ); // FileShare ??? use BinaryReader ???
+
+ if ( file_stream.Length == 0 )
+ {
+ global_result = zero_file;
+ is_zero_file = true;
+ }
+ else
+ {
+ bytes_read = file_stream.Read( buffer, 0, buffer.Length );
+
+ // do not clear the whole buffer everytime; clear only what's needed
+ if (bytes_read < buffer.Length) {
+ System.Array.Clear( buffer, bytes_read, buffer.Length - bytes_read );
+ }
+ }
+
+ file_stream.Close( );
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ private bool CheckForContentTypeString( )
+ {
+ int index = search_string.IndexOf( "Content-type:" );
+
+ if ( index != -1 )
+ {
+ index += 13; // Length of string "Content-type:"
+
+ global_result = "";
+
+ while ( search_string[ index ] != ';' )
+ {
+ global_result += search_string[ index++ ];
+ }
+
+ global_result.Trim( );
+
+ return true;
+ }
+
+ // convert string to byte array
+ byte[] string_byte = ( new ASCIIEncoding( ) ).GetBytes( search_string );
+
+ System.Array.Clear( buffer, 0, buffer.Length );
+
+ if ( string_byte.Length > buffer.Length )
+ {
+ System.Array.Copy( string_byte, buffer, buffer.Length );
+ }
+ else
+ {
+ System.Array.Copy( string_byte, buffer, string_byte.Length );
+ }
+
+ if ( CheckMatch80Plus( ) )
+ return true;
+
+ if ( CheckMatchBelow80( ) )
+ return true;
+
+ return false;
+ }
+ }
+
+ internal class FDOMimeConfigReader {
+ bool fdo_mime_available = false;
+ StringCollection shared_mime_paths = new StringCollection ();
+ BinaryReader br;
+
+ int max_offset_and_range = 0;
+
+ public int Init ()
+ {
+ CheckFDOMimePaths ();
+
+ if (!fdo_mime_available)
+ return -1;
+
+ ReadMagicData ();
+
+ ReadGlobsData ();
+
+ ReadSubclasses ();
+
+ ReadAliases ();
+
+ shared_mime_paths = null;
+ br = null;
+
+ return max_offset_and_range;
+ }
+
+ private void CheckFDOMimePaths ()
+ {
+ if (Directory.Exists ("/usr/share/mime"))
+ shared_mime_paths.Add ("/usr/share/mime/");
+ else
+ if (Directory.Exists ("/usr/local/share/mime"))
+ shared_mime_paths.Add ("/usr/local/share/mime/");
+
+ if (Directory.Exists (System.Environment.GetFolderPath (Environment.SpecialFolder.Personal) + "/.local/share/mime"))
+ shared_mime_paths.Add (System.Environment.GetFolderPath (Environment.SpecialFolder.Personal) + "/.local/share/mime/");
+
+ if (shared_mime_paths.Count == 0)
+ return;
+
+ fdo_mime_available = true;
+ }
+
+ private void ReadMagicData ()
+ {
+ foreach (string path in shared_mime_paths) {
+ if (!File.Exists (path + "/magic"))
+ continue;
+
+ try {
+ FileStream fs = File.OpenRead (path + "/magic");
+ br = new BinaryReader (fs);
+
+ if (CheckMagicHeader ()) {
+ MakeMatches ();
+ }
+
+ br.Close ();
+ fs.Close ();
+ } catch (Exception ) {
+ }
+ }
+ }
+
+ private void MakeMatches ()
+ {
+ Matchlet[] matchlets = new Matchlet [30];
+
+ while (br.PeekChar () != -1) {
+ int priority = -1;
+ string mime_type = ReadPriorityAndMimeType (ref priority);
+
+ if (mime_type != null) {
+ Match match = new Match ();
+ match.Priority = priority;
+ match.MimeType = mime_type;
+
+ while (true) {
+ int indent = 0;
+ // indent
+ char c;
+ if (br.PeekChar () != '>') {
+ string indent_string = "";
+ while (true) {
+ if (br.PeekChar () == '>')
+ break;
+
+ c = br.ReadChar ();
+ indent_string += c;
+ }
+ indent = Convert.ToInt32 (indent_string);
+ }
+
+ int offset = 0;
+
+ // offset
+ if (br.PeekChar () == '>') {
+ br.ReadChar ();
+ offset = ReadValue ();
+ }
+
+ int value_length = 0;
+ byte[] value = null;
+ // value length and value
+ if (br.PeekChar () == '=') {
+ br.ReadChar ();
+
+ // read 2 bytes value length (always big endian)
+ byte first = br.ReadByte ();
+ byte second = br.ReadByte ();
+
+ value_length = first * 256 + second;
+
+ value = br.ReadBytes (value_length);
+ }
+
+ // mask
+ byte[] mask = null;
+
+ if (br.PeekChar () == '&') {
+ br.ReadChar ();
+
+ mask = br.ReadBytes (value_length);
+ }
+
+ // word_size
+ int word_size = 1;
+ if (br.PeekChar () == '~') {
+ br.ReadChar ();
+
+ c = br.ReadChar ();
+
+ word_size = Convert.ToInt32 (c - 0x30);
+
+ // data is stored in big endian format.
+ if (word_size > 1 && System.BitConverter.IsLittleEndian) {
+ //convert the value and, if available, the mask data to little endian
+ if (word_size == 2) {
+ if (value != null) {
+ for (int i = 0; i < value.Length; i += 2) {
+ byte one = value [i];
+ byte two = value [i + 1];
+ value [i] = two;
+ value [i + 1] = one;
+ }
+ }
+ if (mask != null) {
+ for (int i = 0; i < mask.Length; i += 2) {
+ byte one = mask [i];
+ byte two = mask [i + 1];
+ mask [i] = two;
+ mask [i + 1] = one;
+ }
+ }
+ } else if (word_size == 4) {
+ if (value != null) {
+ for (int i = 0; i < value.Length; i += 4) {
+ byte one = value [i];
+ byte two = value [i + 1];
+ byte three = value [i + 2];
+ byte four = value [i + 3];
+ value [i] = four;
+ value [i + 1] = three;
+ value [i + 2] = two;
+ value [i + 3] = one;
+ }
+ }
+ if (mask != null) {
+ for (int i = 0; i < mask.Length; i += 4) {
+ byte one = mask [i];
+ byte two = mask [i + 1];
+ byte three = mask [i + 2];
+ byte four = mask [i + 3];
+ mask [i] = four;
+ mask [i + 1] = three;
+ mask [i + 2] = two;
+ mask [i + 3] = one;
+
+ }
+ }
+ }
+ }
+ }
+
+ // range length
+ int range_length = 0;
+ if (br.PeekChar () == '+') {
+ br.ReadChar ();
+ range_length = ReadValue ();
+ }
+
+ // read \n
+ br.ReadChar ();
+
+ // create the matchlet
+ matchlets [indent] = new Matchlet ();
+ matchlets [indent].Offset = offset;
+ matchlets [indent].OffsetLength = range_length;
+ matchlets [indent].ByteValue = value;
+ if (mask != null)
+ matchlets [indent].Mask = mask;
+
+ if (indent == 0) {
+ match.Matchlets.Add (matchlets [indent]);
+ } else {
+ matchlets [indent - 1].Matchlets.Add (matchlets [indent]);
+ }
+
+ if (max_offset_and_range < matchlets [indent].Offset + matchlets [indent].OffsetLength + matchlets [indent].ByteValue.Length + 1)
+ max_offset_and_range = matchlets [indent].Offset + matchlets [indent].OffsetLength + matchlets [indent].ByteValue.Length + 1;
+
+ // if '[' move to next mime type
+ if (br.PeekChar () == '[')
+ break;
+ }
+
+ if (priority < 80)
+ Mime.MatchesBelow80.Add (match);
+ else
+ Mime.Matches80Plus.Add (match);
+ }
+ }
+ }
+
+ private void ReadGlobsData ()
+ {
+ foreach (string path in shared_mime_paths) {
+ if (!File.Exists (path + "/globs"))
+ continue;
+
+ try {
+ StreamReader sr = new StreamReader (path + "/globs");
+
+ while (sr.Peek () != -1) {
+ string line = sr.ReadLine ().Trim ();
+
+ if (line.StartsWith ("#"))
+ continue;
+
+ string[] split = line.Split (new char [] {':'});
+
+ if (split [1].IndexOf ('*') > -1 && split [1].IndexOf ('.') == -1) {
+ Mime.GlobalSufPref.Add (split [1], split [0]);
+ } else if (split [1]. IndexOf ('*') == -1) {
+ Mime.GlobalLiterals.Add (split [1], split [0]);
+ } else {
+ string[] split2 = split [1].Split (new char [] {'.'});
+
+ if (split2.Length > 2) {
+ // more than one dot
+ Mime.GlobalPatternsLong.Add (split [1].Remove(0, 1), split [0]);
+ } else {
+ // normal
+ Mime.GlobalPatternsShort.Add (split [1].Remove(0, 1), split [0]);
+ }
+ }
+ }
+
+ sr.Close ();
+ } catch (Exception ) {
+ }
+ }
+ }
+
+ private void ReadSubclasses ()
+ {
+ foreach (string path in shared_mime_paths) {
+ if (!File.Exists (path + "/subclasses"))
+ continue;
+
+ try {
+ StreamReader sr = new StreamReader (path + "/subclasses");
+
+ while (sr.Peek () != -1) {
+ string line = sr.ReadLine ().Trim ();
+
+ if (line.StartsWith ("#"))
+ continue;
+
+ string[] split = line.Split (new char [] {' '});
+
+ Mime.SubClasses.Add (split [0], split [1]);
+ }
+
+ sr.Close ();
+ } catch (Exception ) {
+ }
+ }
+ }
+
+ private void ReadAliases ()
+ {
+ foreach (string path in shared_mime_paths) {
+ if (!File.Exists (path + "/aliases"))
+ continue;
+
+ try {
+ StreamReader sr = new StreamReader (path + "/aliases");
+
+ while (sr.Peek () != -1) {
+ string line = sr.ReadLine ().Trim ();
+
+ if (line.StartsWith ("#"))
+ continue;
+
+ string[] split = line.Split (new char [] {' '});
+
+ Mime.Aliases.Add (split [0], split [1]);
+ }
+
+ sr.Close ();
+ } catch (Exception ) {
+ }
+ }
+ }
+
+ private int ReadValue ()
+ {
+ string result_string = "";
+ int result = 0;
+ char c;
+
+ while (true) {
+ if (br.PeekChar () == '=' || br.PeekChar () == '\n')
+ break;
+
+ c = br.ReadChar ();
+ result_string += c;
+ }
+
+ result = Convert.ToInt32 (result_string);
+
+ return result;
+ }
+
+ private string ReadPriorityAndMimeType (ref int priority)
+ {
+ if (br.ReadChar () == '[') {
+ string priority_string = "";
+ while (true) {
+ char c = br.ReadChar ();
+ if (c == ':')
+ break;
+ priority_string += c;
+ }
+
+ priority = System.Convert.ToInt32 (priority_string);
+
+ string mime_type_result = "";
+ while (true) {
+ char c = br.ReadChar ();
+ if (c == ']')
+ break;
+
+ mime_type_result += c;
+ }
+
+ if (br.ReadChar () == '\n')
+ return mime_type_result;
+ }
+ return null;
+ }
+
+ private bool CheckMagicHeader ()
+ {
+ char[] chars = br.ReadChars (10);
+ string magic_header = new String (chars);
+
+ if (magic_header != "MIME-Magic")
+ return false;
+
+ if (br.ReadByte () != 0)
+ return false;
+ if (br.ReadChar () != '\n')
+ return false;
+
+ return true;
+ }
+ }
+
+ internal class Match {
+ string mimeType;
+ int priority;
+ ArrayList matchlets = new ArrayList();
+
+ public string MimeType {
+ set {
+ mimeType = value;
+ }
+
+ get {
+ return mimeType;
+ }
+ }
+
+ public int Priority {
+ set {
+ priority = value;
+ }
+
+ get {
+ return priority;
+ }
+ }
+
+ public ArrayList Matchlets {
+ get {
+ return matchlets;
+ }
+ }
+ }
+
+ internal class Matchlet {
+ byte[] byteValue;
+ byte[] mask = null;
+
+ int offset;
+ int offsetLength;
+ int wordSize = 1;
+
+ ArrayList matchlets = new ArrayList ();
+
+ public byte[] ByteValue {
+ set {
+ byteValue = value;
+ }
+
+ get {
+ return byteValue;
+ }
+ }
+
+ public byte[] Mask {
+ set {
+ mask = value;
+ }
+
+ get {
+ return mask;
+ }
+ }
+
+ public int Offset {
+ set {
+ offset = value;
+ }
+
+ get {
+ return offset;
+ }
+ }
+
+ public int OffsetLength {
+ set {
+ offsetLength = value;
+ }
+
+ get {
+ return offsetLength;
+ }
+ }
+
+ public int WordSize {
+ set {
+ wordSize = value;
+ }
+
+ get {
+ return wordSize;
+ }
+ }
+
+ public ArrayList Matchlets {
+ get {
+ return matchlets;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MimeIcon.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MimeIcon.cs
new file mode 100644
index 00000000000..b4621c79993
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MimeIcon.cs
@@ -0,0 +1,1114 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+//
+// Alexander Olk xenomorph2@onlinehome.de
+//
+
+// short "how to" if you want to add an other platform handler, etc:
+// - first add mime type names and icon names (best is without extension) to MimeIconEngine, for example:
+// MimeIconEngine.AddMimeTypeAndIconName( "inode/directory", "gnome-fs-directory" );
+// - next add the icon name (the same as used in AddMimeTypeAndIconName) and the full filename, for example:
+// MimeIconEngine.AddIcon( "gnome-fs-directory", "/opt/gnome/share/icons/gnome/48x48/filesystems/gnome-fs-directory.png" );
+// AddIcon adds the icon to the image lists SmallIconList and LargeIconList
+// - provide always a "unknown/unknown" 'mime type' with a default icon for unkown mime types,
+// "desktop/desktop" 'mime type' for the desktop icon, "directory/home" 'mime type for the home dir of the user and so on
+// (look at the default platform handler)
+//
+// use
+// public static int GetIconIndexForFile( string full_filename )
+// public static int GetIconIndexForMimeType( string mime_type )
+// to get the image index in MimeIconEngine.SmallIcons and MimeIconEngine.LargeIcons
+// use
+// public static Image GetIconForMimeTypeAndSize( string mime_type, Size size )
+// to get the image itself for a mime type with a specific size
+
+using System;
+using System.Drawing;
+using System.Collections;
+using System.Collections.Specialized;
+using System.IO;
+using System.Text;
+using System.Runtime.InteropServices;
+using System.Xml;
+
+namespace System.Windows.Forms
+{
+ internal enum MimeExtensionHandlerStatus
+ {
+ OK,
+ NO_KDEGLOBALS,
+ NO_GNOMECONFIG,
+ NO_ICONS,
+ NO_MIMELNK
+ }
+
+ internal enum EPlatformHandler
+ {
+ Default,
+ KDE,
+ GNOME
+ // Win, Mac OSX...
+ }
+
+ internal class MimeIconEngine
+ {
+ public static ImageList SmallIcons = new ImageList();
+ public static ImageList LargeIcons = new ImageList();
+
+ private static EPlatformHandler platform = EPlatformHandler.Default;
+
+ private static IconIndexHash MimeTypeIconIndexHash = new IconIndexHash();
+
+ struct IconPath {
+ public string Fullname;
+ public IconPath (string path)
+ {
+ Fullname = path;
+ }
+ }
+
+ struct SvgIconPath {
+ public string Fullname;
+ public SvgIconPath (string path)
+ {
+ Fullname = path;
+ }
+ }
+
+ private class IconIndexHash {
+
+ Hashtable hash = new Hashtable ();
+
+ private int LoadIcon (IconPath path)
+ {
+ Bitmap bmp = new Bitmap (path.Fullname);
+
+ int index = SmallIcons.Images.Add (bmp, Color.Transparent);
+ LargeIcons.Images.Add (bmp, Color.Transparent);
+ return index;
+ }
+
+ private int LoadSvgIcon (SvgIconPath path)
+ {
+ Image image = SVGUtil.GetSVGasImage (path.Fullname, 48, 48);
+
+ int index = SmallIcons.Images.Add (image, Color.Transparent);
+ LargeIcons.Images.Add (image, Color.Transparent);
+ return index;
+ }
+
+ private int LoadIcon (object path)
+ {
+ if (path is SvgIconPath)
+ return LoadSvgIcon ((SvgIconPath) path);
+ else
+ return LoadIcon ((IconPath) path);
+ }
+
+ public object this [object key] {
+ get {
+ if (hash [key] == null)
+ return null;
+ else if (hash [key] is int)
+ return hash [key];
+
+ hash [key] = LoadIcon (hash [key]);
+ return hash [key];
+ }
+ }
+
+ public void Add (string name, object path)
+ {
+ hash [name] = path;
+ }
+
+ public bool ContainsKey (string s)
+ {
+ return hash.ContainsKey (s);
+ }
+ }
+
+ private static NameValueCollection IconNameMimeTypeNameValueCollection = new NameValueCollection();
+
+ private static StringCollection added_icons = new StringCollection();
+
+ private static object lock_object = new Object();
+
+ static MimeIconEngine( )
+ {
+ // add some more aliases, kde for example uses other mime type names for some mime types...
+ Mime.Aliases.Add( "application/x-compressed-tar", "application/x-tgz" );
+ Mime.Aliases.Add( "application/x-bzip-compressed-tar", "application/x-tbz" );
+ Mime.Aliases.Add( "application/zip", "application/x-zip" );
+ Mime.Aliases.Add( "text/x-patch", "text/x-diff" );
+
+ SmallIcons.ColorDepth = ColorDepth.Depth32Bit;
+ SmallIcons.TransparentColor = Color.Transparent;
+ LargeIcons.ColorDepth = ColorDepth.Depth32Bit;
+ LargeIcons.TransparentColor = Color.Transparent;
+
+ string session = Environment.GetEnvironmentVariable( "DESKTOP_SESSION" );
+
+ if ( session != null )
+ {
+ session = session.ToUpper( );
+
+ if ( session == "DEFAULT" )
+ {
+ string helper = Environment.GetEnvironmentVariable( "KDE_FULL_SESSION" );
+
+ if ( helper != null )
+ session = "KDE";
+ else
+ {
+ helper = Environment.GetEnvironmentVariable( "GNOME_DESKTOP_SESSION_ID" );
+
+ if ( helper != null )
+ session = "GNOME";
+ }
+ }
+ }
+ else
+ session = "";
+
+ //Console.WriteLine( "Desktop session is: " + session );
+
+ PlatformMimeIconHandler platformMimeHandler = null;
+
+ if ( session == "KDE" )
+ {
+ SmallIcons.ImageSize = new Size( 24, 24 );
+ LargeIcons.ImageSize = new Size( 48, 48 );
+
+ platformMimeHandler = new KdeHandler( );
+ if ( platformMimeHandler.Start( ) == MimeExtensionHandlerStatus.OK )
+ {
+ platform = EPlatformHandler.KDE;
+ }
+ else // fallback to default
+ {
+ MimeIconEngine.LargeIcons.Images.Clear( );
+ MimeIconEngine.SmallIcons.Images.Clear( );
+ platformMimeHandler = new PlatformDefaultHandler( );
+ platformMimeHandler.Start( );
+ }
+ }
+ else
+ if ( session == "GNOME" )
+ {
+ SmallIcons.ImageSize = new Size( 24, 24 );
+ LargeIcons.ImageSize = new Size( 48, 48 );
+
+ platformMimeHandler = new GnomeHandler( );
+ if ( platformMimeHandler.Start( ) == MimeExtensionHandlerStatus.OK )
+ {
+ platform = EPlatformHandler.GNOME;
+ }
+ else // fallback to default
+ {
+ MimeIconEngine.LargeIcons.Images.Clear( );
+ MimeIconEngine.SmallIcons.Images.Clear( );
+ platformMimeHandler = new PlatformDefaultHandler( );
+ platformMimeHandler.Start( );
+ }
+ }
+ else
+ {
+ SmallIcons.ImageSize = new Size( 16, 16 );
+ LargeIcons.ImageSize = new Size( 48, 48 );
+
+ platformMimeHandler = new PlatformDefaultHandler( );
+ platformMimeHandler.Start( );
+ }
+
+ IconNameMimeTypeNameValueCollection = null;
+ added_icons = null;
+ }
+
+ public static int GetIconIndexForFile( string full_filename )
+ {
+ lock ( lock_object )
+ {
+ string mime_type = Mime.GetMimeTypeForFile( full_filename );
+
+ if ( platform == EPlatformHandler.Default )
+ {
+ if ( mime_type == "inode/directory" )
+ {
+ return (int)MimeTypeIconIndexHash[ "inode/directory" ];
+ }
+ else
+ {
+ return (int)MimeTypeIconIndexHash[ "unknown/unknown" ];
+ }
+ }
+
+ object oindex = GetIconIndex( mime_type );
+
+ if ( oindex == null )
+ oindex = MimeTypeIconIndexHash[ "unknown/unknown" ];
+
+ return (int)oindex;
+ }
+ }
+
+ public static int GetIconIndexForMimeType( string mime_type )
+ {
+ lock ( lock_object )
+ {
+ if ( platform == EPlatformHandler.Default )
+ {
+ if ( mime_type == "inode/directory" )
+ {
+ return (int)MimeTypeIconIndexHash[ "inode/directory" ];
+ }
+ else
+ {
+ return (int)MimeTypeIconIndexHash[ "unknown/unknown" ];
+ }
+ }
+
+ object oindex = GetIconIndex( mime_type );
+
+ if ( oindex == null )
+ oindex = MimeTypeIconIndexHash[ "unknown/unknown" ];
+
+ return (int)oindex;
+ }
+ }
+
+ public static Image GetIconForMimeTypeAndSize( string mime_type, Size size )
+ {
+ lock ( lock_object )
+ {
+ object oindex = GetIconIndex( mime_type );
+
+ if ( oindex == null )
+ oindex = MimeTypeIconIndexHash[ "unknown/unknown" ];
+
+ Bitmap bmp = new Bitmap( LargeIcons.Images[ (int)oindex ], size );
+
+ return bmp;
+ }
+ }
+
+ internal static void AddIcon( string name, string fullname )
+ {
+ if ( !CheckIfIconIsNeeded( name ) )
+ return;
+
+ if ( added_icons.Contains( name ) )
+ return;
+
+ added_icons.Add( name );
+
+ AddMimeTypeIconIndexHash( name, new IconPath (fullname) );
+ }
+
+ internal static void AddSVGIcon( string name, string fullname )
+ {
+ if ( !CheckIfIconIsNeeded( name ) )
+ return;
+
+ if ( added_icons.Contains( name ) )
+ return;
+
+ added_icons.Add( name );
+
+ AddMimeTypeIconIndexHash( name, new SvgIconPath (fullname) );
+ }
+
+ private static bool CheckIfIconIsNeeded( string name )
+ {
+ string mime_types = IconNameMimeTypeNameValueCollection[ name ];
+
+ if ( mime_types != null )
+ return true;
+
+ return false;
+ }
+
+ internal static void AddMimeTypeIconIndexHash( string name, object path_or_index )
+ {
+ string mime_type = IconNameMimeTypeNameValueCollection[ name ];
+
+ if ( mime_type == null )
+ return;
+
+ string[] split = mime_type.Split( new char[] { ',' } );
+
+ foreach ( string s in split )
+ {
+ if ( MimeTypeIconIndexHash.ContainsKey( s ) )
+ continue;
+
+ MimeTypeIconIndexHash.Add( s, path_or_index );
+ }
+ }
+
+ internal static void AddIconByImage( string name, Image image )
+ {
+ int index = SmallIcons.Images.Add( image, Color.Transparent );
+ LargeIcons.Images.Add( image, Color.Transparent );
+
+ AddMimeTypeIconIndexHash( name, index );
+ }
+
+ internal static void AddMimeTypeAndIconName( string mimetype, string iconname )
+ {
+ if ( iconname.Equals( String.Empty ) )
+ return;
+
+ IconNameMimeTypeNameValueCollection.Add( iconname, mimetype );
+ }
+
+ private static object GetIconIndex( string mime_type )
+ {
+ object oindex = null;
+
+ if ( mime_type != null )
+ {
+ // first check if mime_type is available in the mimetype/icon hashtable
+ oindex = MimeTypeIconIndexHash[ mime_type ];
+
+ if ( oindex == null )
+ {
+ // it is not available, check if an alias exist for mime_type
+ string alias = Mime.GetMimeAlias( mime_type );
+
+ if ( alias != null )
+ {
+ string[] split = alias.Split( new char[] { ',' } );
+
+ foreach ( string s in split )
+ {
+ oindex = MimeTypeIconIndexHash[ s ];
+
+ if ( oindex != null )
+ return oindex;
+ }
+ }
+
+ // if oindex is still null check if mime_type is a sub class of an other mime type
+ string sub_class = Mime.SubClasses[ mime_type ];
+
+ if ( sub_class != null )
+ return MimeTypeIconIndexHash[ sub_class ];
+
+ // last check, see if we find an entry for the main mime type class
+ string mime_class_main = mime_type.Substring( 0, mime_type.IndexOf( '/' ) );
+ return MimeTypeIconIndexHash[ mime_class_main ];
+ }
+ }
+
+ return oindex;
+ }
+ }
+
+ internal abstract class PlatformMimeIconHandler
+ {
+ protected StringCollection mime_paths = new StringCollection();
+
+ protected StringCollection icon_paths = new StringCollection();
+
+ protected string icon_theme = "";
+
+ protected MimeExtensionHandlerStatus mimeExtensionHandlerStatus = MimeExtensionHandlerStatus.OK;
+
+ public MimeExtensionHandlerStatus MimeExtensionHandlerStatus
+ {
+ get {
+ return mimeExtensionHandlerStatus;
+ }
+ }
+
+ public abstract MimeExtensionHandlerStatus Start( );
+
+ // check, if icon, mime, etc., directories exist
+ protected virtual bool CheckPlatformDirectories( )
+ {
+ return true;
+ }
+ }
+
+ internal class PlatformDefaultHandler : PlatformMimeIconHandler
+ {
+ public override MimeExtensionHandlerStatus Start( )
+ {
+ MimeIconEngine.AddMimeTypeAndIconName( "unknown/unknown", "paper" );
+ MimeIconEngine.AddMimeTypeAndIconName( "inode/directory", "folder" );
+ MimeIconEngine.AddMimeTypeAndIconName( "desktop/desktop", "desktop" );
+ MimeIconEngine.AddMimeTypeAndIconName( "directory/home", "folder_with_paper" );
+ MimeIconEngine.AddMimeTypeAndIconName( "network/network", "monitor-planet" );
+ MimeIconEngine.AddMimeTypeAndIconName( "recently/recently", "last_open" );
+ MimeIconEngine.AddMimeTypeAndIconName( "workplace/workplace", "monitor-computer" );
+
+ MimeIconEngine.AddIconByImage( "folder", (Image)Locale.GetResource( "folder" ) );
+ MimeIconEngine.AddIconByImage( "paper", (Image)Locale.GetResource( "paper" ) );
+ MimeIconEngine.AddIconByImage( "desktop", (Image)Locale.GetResource( "desktop" ) );
+ MimeIconEngine.AddIconByImage( "folder_with_paper", (Image)Locale.GetResource( "folder_with_paper" ) );
+ MimeIconEngine.AddIconByImage( "monitor-planet", (Image)Locale.GetResource( "monitor-planet" ) );
+ MimeIconEngine.AddIconByImage( "last_open", (Image)Locale.GetResource( "last_open" ) );
+ MimeIconEngine.AddIconByImage( "monitor-computer", (Image)Locale.GetResource( "monitor-computer" ) );
+
+ return MimeExtensionHandlerStatus.OK; // return always ok
+ }
+ }
+
+ internal class KdeHandler : PlatformMimeIconHandler
+ {
+ string full_kdegloabals_filename = Environment.GetFolderPath( Environment.SpecialFolder.Personal )
+ + "/"
+ + ".kde/share/config/kdeglobals";
+
+ public override MimeExtensionHandlerStatus Start( )
+ {
+ if ( !ReadKdeglobals( ) )
+ return mimeExtensionHandlerStatus;
+
+ if ( !CheckPlatformDirectories( ) )
+ return mimeExtensionHandlerStatus;
+
+ // check if the theme is svg only
+ // if true, use theme "default.kde"
+ // don't know if that is available in every linux distribution
+ if ( SVGOnly( ) )
+ icon_theme = "default.kde";
+ else
+ // check if there is a /48x48 directory
+ if( No48x48( ) )
+ icon_theme = "default.kde";
+
+ ReadMimetypes( );
+
+ ReadIcons( );
+
+ return mimeExtensionHandlerStatus;
+ }
+
+ private bool SVGOnly( )
+ {
+ // check only the first path in icon_paths
+ if ( icon_paths.Count > 0 )
+ {
+ string icon_path = icon_paths[ 0 ] + icon_theme;
+ string[] dirs = Directory.GetDirectories( icon_path );
+
+ if ( dirs.Length == 1 && dirs[ 0 ] == "scalable" )
+ return true;
+ }
+
+ return false;
+ }
+
+ private bool No48x48( )
+ {
+ // check only the first path in icon_paths
+ if ( icon_paths.Count > 0 )
+ {
+ string icon_path = icon_paths[ 0 ] + icon_theme;
+ string[] dirs = Directory.GetDirectories( icon_path );
+
+ foreach( string path in dirs )
+ {
+ if ( path.EndsWith( "48x48" ) )
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ protected override bool CheckPlatformDirectories( )
+ {
+ bool icons_found = false;
+
+ // default icon dirs
+ if ( Directory.Exists( "/opt/kde3/share/icons/default.kde" ) )
+ {
+ icon_paths.Add( "/opt/kde3/share/icons" + "/" );
+ icons_found = true;
+ }
+ else
+ if ( Directory.Exists( "/usr/share/icons/default.kde" ) )
+ {
+ icon_paths.Add( "/usr/share/icons" + "/" );
+ icons_found = true;
+ }
+ else
+ if ( Directory.Exists( "/usr/local/share/icons/default.kde" ) )
+ {
+ icon_paths.Add( "/usr/local/share/icons" + "/" );
+ icons_found = true;
+ }
+ else
+ if ( !icons_found )
+ {
+ mimeExtensionHandlerStatus = MimeExtensionHandlerStatus.NO_ICONS;
+ return false;
+ }
+
+ bool mimelnk_found = false;
+
+ if ( Directory.Exists( "/usr/share/mimelnk" ) )
+ {
+ mime_paths.Add( "/usr/share/mimelnk" + "/" );
+ mimelnk_found = true;
+ }
+
+ if ( Directory.Exists( "/usr/local/share/mimelnk" ) )
+ {
+ mime_paths.Add( "/usr/local/share/mimelnk" + "/" );
+ mimelnk_found = true;
+ }
+
+ if ( Directory.Exists( "/opt/kde3/share/mimelnk" ) )
+ {
+ mime_paths.Add( "/opt/kde3/share/mimelnk" + "/" );
+ mimelnk_found = true;
+ }
+
+ if ( !mimelnk_found )
+ {
+ mimeExtensionHandlerStatus = MimeExtensionHandlerStatus.NO_MIMELNK;
+ return false;
+ }
+
+ return true;
+ }
+
+ private void ReadIcons( )
+ {
+ foreach ( string icon_path_in in icon_paths )
+ {
+ string icon_path = icon_path_in + icon_theme + "/48x48";
+
+ string[] directories = Directory.GetDirectories( icon_path );
+
+ foreach ( string d in directories )
+ {
+ DirectoryInfo di = new DirectoryInfo( d );
+
+ FileInfo[] fileinfo = di.GetFiles( );
+
+ foreach ( FileInfo fi in fileinfo )
+ {
+ string name = Path.GetFileNameWithoutExtension( fi.Name );
+
+ MimeIconEngine.AddIcon( name, fi.FullName );
+ }
+ }
+ }
+ }
+
+ private void ReadMimetypes( )
+ {
+ MimeIconEngine.AddMimeTypeAndIconName( "unknown/unknown", "unknown" );
+ MimeIconEngine.AddMimeTypeAndIconName( "desktop/desktop", "desktop" );
+ MimeIconEngine.AddMimeTypeAndIconName( "directory/home", "folder_home" );
+ MimeIconEngine.AddMimeTypeAndIconName( "network/network", "network" );
+ MimeIconEngine.AddMimeTypeAndIconName( "recently/recently", "folder_man" );
+ MimeIconEngine.AddMimeTypeAndIconName( "workplace/workplace", "system" );
+
+ MimeIconEngine.AddMimeTypeAndIconName( "nfs/nfs", "nfs_mount" );
+ MimeIconEngine.AddMimeTypeAndIconName( "smb/smb", "server" );
+
+ MimeIconEngine.AddMimeTypeAndIconName( "harddisk/harddisk", "hdd_mount" );
+ MimeIconEngine.AddMimeTypeAndIconName( "cdrom/cdrom", "cdrom_mount" );
+ MimeIconEngine.AddMimeTypeAndIconName( "removable/removable", "usbpendrive_mount" );
+
+ foreach ( string mime_path in mime_paths )
+ {
+ string[] directories = Directory.GetDirectories( mime_path );
+
+ foreach ( string d in directories )
+ {
+ string[] files = Directory.GetFiles( d );
+
+ foreach ( string f in files )
+ {
+ try {
+ ReadDotDesktop( f );
+ } catch {
+ // Ignore errors if the file can not be read.
+ }
+ }
+ }
+ }
+ }
+
+ private void ReadDotDesktop( string filename )
+ {
+ StreamReader sr = new StreamReader( filename );
+
+ string line = sr.ReadLine( );
+
+ string icon_name = "";
+
+ string mime_type = "";
+
+ bool have_icon = false;
+ bool have_mimetype = false;
+
+ while ( line != null )
+ {
+ line = line.Trim( );
+
+ if ( line.StartsWith( "Icon" ) )
+ {
+ icon_name = line.Substring( line.IndexOf( '=' ) + 1 );
+ icon_name = icon_name.Trim( );
+ if ( have_mimetype )
+ break;
+ have_icon = true;
+ }
+ else
+ if ( line.StartsWith( "MimeType" ) )
+ {
+ mime_type = line.Substring( line.IndexOf( '=' ) + 1 );
+ mime_type = mime_type.Trim( );
+ if ( have_icon )
+ break;
+ have_mimetype = true;
+ }
+
+ line = sr.ReadLine( );
+ }
+
+ sr.Close( );
+
+ MimeIconEngine.AddMimeTypeAndIconName( mime_type, icon_name );
+ }
+
+ private bool ReadKdeglobals( )
+ {
+ if ( !File.Exists( full_kdegloabals_filename ) )
+ {
+ mimeExtensionHandlerStatus = MimeExtensionHandlerStatus.NO_KDEGLOBALS;
+
+ return false;
+ }
+
+ StreamReader sr = new StreamReader( full_kdegloabals_filename );
+
+ string line = sr.ReadLine( );
+
+ while ( line != null )
+ {
+ if ( line.IndexOf( "[Icons]" ) != -1 )
+ {
+ line = sr.ReadLine( );
+
+ if ( line != null && line.IndexOf( "Theme" ) != -1 )
+ {
+ line = line.Trim( );
+
+ icon_theme = line.Substring( line.IndexOf( '=' ) + 1 );
+
+ icon_theme = icon_theme.Trim( );
+
+ break;
+ }
+ }
+
+ line = sr.ReadLine( );
+ }
+
+ sr.Close( );
+
+ return true;
+ }
+ }
+
+ internal class GnomeHandler : PlatformMimeIconHandler
+ {
+ string full_gnome_gconf_tree = Environment.GetFolderPath( Environment.SpecialFolder.Personal )
+ + "/"
+ + ".gconf/%gconf-tree.xml";
+
+ bool is_svg_icon_theme = false;
+
+ string main_icon_theme_path;
+
+ StringCollection inherits_path_collection = new StringCollection ();
+
+ public override MimeExtensionHandlerStatus Start( )
+ {
+ icon_theme = String.Empty;
+
+ if (!File.Exists (full_gnome_gconf_tree))
+ full_gnome_gconf_tree = Environment.GetFolderPath( Environment.SpecialFolder.Personal )
+ + "/"
+ + ".gconf/desktop/gnome/interface/%gconf.xml";
+
+ GetIconThemeFromGConf ();
+
+ if (!GetIconPaths ())
+ return MimeExtensionHandlerStatus.NO_ICONS;
+
+ if (!GetMainIconThemePath ())
+ return MimeExtensionHandlerStatus.NO_ICONS;
+
+ try {
+ GetIconThemeInherits ();
+
+ CreateUIIcons ();
+
+ CreateMimeTypeIcons( );
+ } catch (Exception e) {
+ Console.Error.WriteLine ("Unable to start GNOME mime engine:");
+ Console.Error.WriteLine (e);
+ return MimeExtensionHandlerStatus.NO_GNOMECONFIG;
+ }
+
+ inherits_path_collection = null;
+ icon_paths = null;
+
+ return MimeExtensionHandlerStatus.OK;
+ }
+
+ private bool GetIconThemeFromGConf ()
+ {
+ if (!File.Exists (full_gnome_gconf_tree))
+ return false;
+
+ try {
+ bool found_icon_theme_in_xml = false;
+
+ XmlTextReader xtr = new XmlTextReader (full_gnome_gconf_tree);
+
+ while (xtr.Read ()) {
+ if (xtr.NodeType == XmlNodeType.Element && xtr.Name.ToUpper () == "ENTRY" && xtr.GetAttribute ("name") == "icon_theme") {
+ found_icon_theme_in_xml = true;
+ } else
+ if (xtr.NodeType == XmlNodeType.Element && xtr.Name.ToUpper () == "STRINGVALUE" && found_icon_theme_in_xml) {
+ xtr.Read ();
+ icon_theme = xtr.Value;
+ break;
+ }
+ }
+ xtr.Close ();
+
+ if (icon_theme != String.Empty)
+ return true;
+ else {
+ icon_theme = "gnome";
+ return false;
+ }
+ } catch ( Exception e ) {
+ return false;
+ }
+ }
+
+ private bool GetIconPaths ()
+ {
+ string global_icon_path = "";
+
+ if (Directory.Exists ("/opt/gnome/share/icons"))
+ global_icon_path = "/opt/gnome/share/icons";
+ else
+ if (Directory.Exists ("/usr/share/icons"))
+ global_icon_path = "/usr/share/icons";
+ else
+ if (Directory.Exists ("/usr/local/share/icons"))
+ global_icon_path = "/usr/local/share/icons";
+
+ if (global_icon_path.Length > 0)
+ icon_paths.Add (global_icon_path);
+
+ if (Directory.Exists (Environment.GetFolderPath (Environment.SpecialFolder.Personal) + "/.icons"))
+ icon_paths.Add (Environment.GetFolderPath (Environment.SpecialFolder.Personal) + "/.icons");
+
+ if (icon_paths.Count == 0)
+ return false;
+
+ return true;
+ }
+
+ private bool GetMainIconThemePath ()
+ {
+ foreach (string path in icon_paths) {
+ if (Directory.Exists (path + "/" + icon_theme)) {
+ main_icon_theme_path = path + "/" + icon_theme;
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private void GetIconThemeInherits ()
+ {
+ inherits_path_collection.Add (main_icon_theme_path);
+ GetIndexThemeInherits (main_icon_theme_path + "/" + "index.theme");
+ }
+
+ private void GetIndexThemeInherits (string filename)
+ {
+ StringCollection tmp_inherits = new StringCollection ();
+
+ try {
+ StreamReader sr = new StreamReader (filename);
+
+ string line = sr.ReadLine ();
+
+ while (line != null) {
+ if (line.IndexOf ("Inherits=") != -1) {
+ line = line.Trim ();
+ line = line.Replace ("Inherits=", "");
+
+ line = line.Trim ();
+
+ string[] split = line.Split (new char [] { ',' });
+
+ tmp_inherits.AddRange (split);
+ break;
+ }
+ line = sr.ReadLine ();
+ }
+
+ sr.Close ();
+ } catch (Exception e) {
+
+ }
+
+ if (tmp_inherits.Count > 0) {
+ foreach (string icon_theme in tmp_inherits) {
+ foreach (string path in icon_paths) {
+ if (Directory.Exists (path + "/" + icon_theme)) {
+ if (!inherits_path_collection.Contains (path + "/" + icon_theme))
+ inherits_path_collection.Add (path + "/" + icon_theme);
+ if (File.Exists (path + "/" + icon_theme + "/" + "index.theme"))
+ GetIndexThemeInherits (path + "/" + icon_theme + "/" + "index.theme");
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ private void CreateUIIcons ()
+ {
+ string resolv_path = ResolvePath (main_icon_theme_path);
+
+ // use default gnome icon theme if there isn't a "/48x48" or "/scalable" dir
+ // for the current theme
+ if (resolv_path == String.Empty)
+ foreach (string path in icon_paths)
+ if (Directory.Exists (path + "/gnome")) {
+ resolv_path = path + "/gnome/48x48/";
+ break;
+ }
+
+ string[] dirs = Directory.GetDirectories (resolv_path);
+
+ Hashtable name_mime_hash = new Hashtable ();
+
+ name_mime_hash ["gnome-fs-directory"] = "inode/directory";
+ name_mime_hash ["gnome-fs-regular"] = "unknown/unknown";
+ name_mime_hash ["gnome-fs-desktop"] = "desktop/desktop";
+ name_mime_hash ["gnome-fs-home"] = "directory/home";
+ name_mime_hash ["gnome-fs-network"] = "network/network";
+ name_mime_hash ["gnome-fs-directory-accept"] = "recently/recently";
+ name_mime_hash ["gnome-fs-client"] = "workplace/workplace";
+
+ name_mime_hash ["gnome-fs-nfs"] = "nfs/nfs";
+ name_mime_hash ["gnome-fs-smb"] = "smb/smb";
+
+ name_mime_hash ["gnome-dev-cdrom"] = "cdrom/cdrom";
+ name_mime_hash ["gnome-dev-harddisk"] = "harddisk/harddisk";
+ name_mime_hash ["gnome-dev-removable"] = "removable/removable";
+
+ if (!CheckAndAddUIIcons (dirs, name_mime_hash)) {
+ //could be a kde icon theme, so we check kde icon names also
+ name_mime_hash.Clear ();
+ name_mime_hash ["folder"] = "inode/directory";
+ name_mime_hash ["unknown"] = "unknown/unknown";
+ name_mime_hash ["desktop"] = "desktop/desktop";
+ name_mime_hash ["folder_home"] = "directory/home";
+ name_mime_hash ["network"] = "network/network";
+ name_mime_hash ["folder_man"] = "recently/recently";
+ name_mime_hash ["system"] = "workplace/workplace";
+
+ name_mime_hash ["nfs_mount"] = "nfs/nfs";
+ name_mime_hash ["server"] = "smb/smb";
+
+ name_mime_hash ["cdrom_mount"] = "cdrom/cdrom";
+ name_mime_hash ["hdd_mount"] = "harddisk/harddisk";
+ name_mime_hash ["usbpendrive_mount"] = "removable/removable";
+
+ CheckAndAddUIIcons (dirs, name_mime_hash);
+ }
+ }
+
+ private bool CheckAndAddUIIcons (string[] dirs, Hashtable name_mime_hash)
+ {
+ string extension = is_svg_icon_theme ? "svg" : "png";
+ int counter = 0;
+
+ foreach (string place in dirs) {
+ foreach (DictionaryEntry entry in name_mime_hash) {
+ string key = (string)entry.Key;
+ if (File.Exists (place + "/" + key + "." + extension)) {
+ string value = (string)entry.Value;
+ MimeIconEngine.AddMimeTypeAndIconName (value, key);
+ if (!is_svg_icon_theme)
+ MimeIconEngine.AddIcon (key, place + "/" + key + "." + extension);
+ else
+ MimeIconEngine.AddSVGIcon (key, place + "/" + key + "." + extension);
+ counter++;
+ if (counter == name_mime_hash.Count)
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private void CreateMimeTypeIcons ()
+ {
+ foreach (string ip in inherits_path_collection) {
+ string path_to_use = ResolvePath (ip);
+
+ if (path_to_use == String.Empty)
+ continue;
+
+ if (!Directory.Exists (path_to_use + "mimetypes"))
+ continue;
+
+ string[] files = Directory.GetFiles (path_to_use + "mimetypes");
+
+ foreach (string file in files) {
+ string extension = Path.GetExtension (file);
+
+ if (!is_svg_icon_theme) {
+ if (extension != ".png")
+ continue;
+ } else
+ if (extension != ".svg")
+ continue;
+
+ string file_name = Path.GetFileNameWithoutExtension (file);
+
+ if (!file_name.StartsWith ("gnome-mime-"))
+ continue;
+
+ StringBuilder mime_type = new StringBuilder (file_name.Replace ("gnome-mime-", ""));
+
+ for (int i = 0; i < mime_type.Length; i++)
+ if (mime_type [i] == '-') {
+ mime_type [i] = '/';
+ break;
+ }
+
+ MimeIconEngine.AddMimeTypeAndIconName (mime_type.ToString (), file_name);
+
+ if (!is_svg_icon_theme)
+ MimeIconEngine.AddIcon (file_name, file);
+ else
+ MimeIconEngine.AddSVGIcon (file_name, file);
+ }
+ }
+ }
+
+ private string ResolvePath (string path)
+ {
+ if (Directory.Exists (path + "/48x48")) {
+ is_svg_icon_theme = false;
+ return path + "/48x48/";
+ }
+
+ if (Directory.Exists (path + "/scalable")) {
+ is_svg_icon_theme = true;
+ return path + "/scalable/";
+ }
+
+ return String.Empty;
+ }
+ }
+
+ internal class SVGUtil {
+ [DllImport("librsvg-2.so")]
+ static extern IntPtr rsvg_pixbuf_from_file_at_size (string file_name, int width, int height, out IntPtr error);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern bool gdk_pixbuf_save_to_buffer (IntPtr pixbuf, out IntPtr buffer, out UIntPtr buffer_size, string type, out IntPtr error, IntPtr option_dummy);
+
+ [DllImport("libglib-2.0.so")]
+ static extern void g_free (IntPtr mem);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern bool gdk_init_check(out int argc, string argv);
+
+ [DllImport("libgobject-2.0.so")]
+ static extern void g_object_unref (IntPtr nativeObject);
+
+ static bool inited = false;
+
+ static void Init () {
+ int argc = 0;
+ string argv = "";
+
+ gdk_init_check (out argc, argv);
+
+ inited = true;
+ }
+
+ public static Image GetSVGasImage (string filename, int width, int height) {
+ if (!inited)
+ Init ();
+
+ if (!File.Exists (filename))
+ return null;
+ IntPtr error = IntPtr.Zero;
+ IntPtr pixbuf = rsvg_pixbuf_from_file_at_size (filename, width, height, out error);
+
+ if (error != IntPtr.Zero)
+ return null;
+
+ error = IntPtr.Zero;
+ IntPtr buffer;
+ UIntPtr buffer_size_as_ptr;
+ string type = "png";
+
+ bool saved = gdk_pixbuf_save_to_buffer (pixbuf, out buffer, out buffer_size_as_ptr, type, out error, IntPtr.Zero);
+
+ if (!saved)
+ return null;
+
+ int buffer_size = (int) (uint) buffer_size_as_ptr;
+ byte[] result = new byte [buffer_size];
+ Marshal.Copy (buffer, result, 0, (int) buffer_size);
+ g_free (buffer);
+ g_object_unref (pixbuf);
+
+ Image image = null;
+ using (MemoryStream s = new MemoryStream (result))
+ image = Image.FromStream (s);
+
+ return image;
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MonthCalendar.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MonthCalendar.cs
new file mode 100644
index 00000000000..9860253acbd
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MonthCalendar.cs
@@ -0,0 +1,2030 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc.
+//
+// Authors:
+// John BouAntoun jba-mono@optusnet.com.au
+//
+// REMAINING TODO:
+// - get the date_cell_size and title_size to be pixel perfect match of SWF
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace System.Windows.Forms {
+ [DefaultProperty("SelectionRange")]
+ [DefaultEvent("DateChanged")]
+ [Designer ("System.Windows.Forms.Design.MonthCalendarDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ public class MonthCalendar : Control {
+ #region Local variables
+ DateTime [] annually_bolded_dates;
+ Color back_color;
+ DateTime [] bolded_dates;
+ Size calendar_dimensions;
+ Day first_day_of_week;
+ Color fore_color;
+ DateTime max_date;
+ int max_selection_count;
+ DateTime min_date;
+ DateTime [] monthly_bolded_dates;
+ int scroll_change;
+ SelectionRange selection_range;
+ bool show_today;
+ bool show_today_circle;
+ bool show_week_numbers;
+ Color title_back_color;
+ Color title_fore_color;
+ DateTime today_date;
+ bool today_date_set;
+ Color trailing_fore_color;
+ ContextMenu menu;
+ NumericUpDown year_updown;
+ Timer timer;
+
+ // internal variables used
+ internal DateTime current_month; // the month that is being displayed in top left corner of the grid
+ internal DateTimePicker owner; // used if this control is popped up
+ internal int button_x_offset;
+ internal Size button_size;
+ internal Size title_size;
+ internal Size date_cell_size;
+ internal Size calendar_spacing;
+ internal int divider_line_offset;
+ internal DateTime clicked_date;
+ internal Rectangle clicked_rect;
+ internal bool is_date_clicked;
+ internal bool is_previous_clicked;
+ internal bool is_next_clicked;
+ internal bool is_shift_pressed;
+ internal DateTime first_select_start_date;
+ internal int last_clicked_calendar_index;
+ internal Rectangle last_clicked_calendar_rect;
+ private Point month_title_click_location;
+ // this is used to see which item was actually clicked on in the beginning
+ // so that we know which item to fire on timer
+ // 0: date clicked
+ // 1: previous clicked
+ // 2: next clicked
+ private bool[] click_state;
+
+ // arraylists used to store new dates
+ ArrayList added_bolded_dates;
+ ArrayList removed_bolded_dates;
+ ArrayList added_annually_bolded_dates;
+ ArrayList removed_annually_bolded_dates;
+ ArrayList added_monthly_bolded_dates;
+ ArrayList removed_monthly_bolded_dates;
+
+
+ #endregion // Local variables
+
+ #region Public Constructors
+
+ public MonthCalendar () {
+ // set up the control painting
+ SetStyle (ControlStyles.UserPaint | ControlStyles.StandardClick, false);
+
+ // mouse down timer
+ timer = new Timer ();
+ timer.Interval = 500;
+ timer.Enabled = false;
+
+ // initialise default values
+ DateTime now = DateTime.Now.Date;
+ selection_range = new SelectionRange (now, now);
+ today_date = now;
+ current_month = new DateTime (now.Year , now.Month, 1);
+
+ // iniatialise local members
+ annually_bolded_dates = null;
+ back_color = ThemeEngine.Current.ColorWindow;
+ bolded_dates = null;
+ calendar_dimensions = new Size (1,1);
+ first_day_of_week = Day.Default;
+ fore_color = SystemColors.ControlText;
+ max_date = new DateTime (9998, 12, 31);
+ max_selection_count = 7;
+ min_date = new DateTime (1953, 1, 1);
+ monthly_bolded_dates = null;
+ scroll_change = 0;
+ show_today = true;
+ show_today_circle = true;
+ show_week_numbers = false;
+ title_back_color = ThemeEngine.Current.ColorActiveCaption;
+ title_fore_color = ThemeEngine.Current.ColorActiveCaptionText;
+ today_date_set = false;
+ trailing_fore_color = Color.Gray;
+
+ // initialise the arraylest for bolded dates
+ added_bolded_dates = new ArrayList ();
+ removed_bolded_dates = new ArrayList ();
+ added_annually_bolded_dates = new ArrayList ();
+ removed_annually_bolded_dates = new ArrayList ();
+ added_monthly_bolded_dates = new ArrayList ();
+ removed_monthly_bolded_dates = new ArrayList ();
+
+ // intiailise internal variables used
+ button_x_offset = 5;
+ button_size = new Size (22, 17);
+ // default settings based on 8.25 pt San Serif Font
+ // Not sure of algorithm used to establish this
+ date_cell_size = new Size (24, 16); // default size at san-serif 8.25
+ divider_line_offset = 4;
+ calendar_spacing = new Size (4, 5); // horiz and vert spacing between months in a calendar grid
+
+ // set some state info
+ clicked_date = now;
+ is_date_clicked = false;
+ is_previous_clicked = false;
+ is_next_clicked = false;
+ is_shift_pressed = false;
+ click_state = new bool [] {false, false, false};
+ first_select_start_date = now;
+ month_title_click_location = Point.Empty;
+
+ // set up context menu
+ SetUpContextMenu ();
+
+
+ // event handlers
+// LostFocus += new EventHandler (LostFocusHandler);
+ timer.Tick += new EventHandler (TimerHandler);
+ MouseMove += new MouseEventHandler (MouseMoveHandler);
+ MouseDown += new MouseEventHandler (MouseDownHandler);
+ KeyDown += new KeyEventHandler (KeyDownHandler);
+ MouseUp += new MouseEventHandler (MouseUpHandler);
+ KeyUp += new KeyEventHandler (KeyUpHandler);
+
+ // this replaces paint so call the control version
+ base.Paint += new PaintEventHandler (PaintHandler);
+ }
+
+ // called when this control is added to date time picker
+ internal MonthCalendar (DateTimePicker owner) : this () {
+ this.owner = owner;
+ this.is_visible = false;
+ this.Size = this.DefaultSize;
+ }
+
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+
+ // dates to make bold on calendar annually (recurring)
+ [Localizable (true)]
+ public DateTime[] AnnuallyBoldedDates {
+ set {
+ if (annually_bolded_dates == null || annually_bolded_dates != value) {
+ annually_bolded_dates = value;
+ this.UpdateBoldedDates ();
+ this.Invalidate ();
+ }
+ }
+ get {
+ return annually_bolded_dates;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Image BackgroundImage {
+ get {
+ return base.BackgroundImage;
+ }
+ set {
+ base.BackgroundImage = value;
+ }
+ }
+
+
+ // the back color for the main part of the calendar
+ public override Color BackColor {
+ set {
+ if (back_color != value) {
+ back_color = value;
+ this.OnBackColorChanged (EventArgs.Empty);
+ this.Invalidate ();
+ }
+ }
+ get {
+ return back_color;
+ }
+ }
+
+ // specific dates to make bold on calendar (non-recurring)
+ [Localizable (true)]
+ public DateTime[] BoldedDates {
+ set {
+ if (bolded_dates == null || bolded_dates != value) {
+ bolded_dates = value;
+ this.UpdateBoldedDates ();
+ this.Invalidate ();
+ }
+ }
+ get {
+ return bolded_dates;
+ }
+ }
+
+ // the configuration of the monthly grid display - only allowed to display at most,
+ // 1 calendar year at a time, will be trimmed to fit it properly
+ [Localizable (true)]
+ public Size CalendarDimensions {
+ set {
+ if (value.Width < 0 || value.Height < 0) {
+ throw new ArgumentException ();
+ }
+ if (calendar_dimensions != value) {
+ // squeeze the grid into 1 calendar year
+ if (value.Width * value.Height > 12) {
+ // iteratively reduce the largest dimension till our
+ // product is less than 12
+ if (value.Width > 12 && value.Height > 12) {
+ calendar_dimensions = new Size (4, 3);
+ } else if (value.Width > 12) {
+ for (int i = 12; i > 0; i--) {
+ if (i * value.Height <= 12) {
+ calendar_dimensions = new Size (i, value.Height);
+ break;
+ }
+ }
+ } else if (value.Height > 12) {
+ for (int i = 12; i > 0; i--) {
+ if (i * value.Width <= 12) {
+ calendar_dimensions = new Size (value.Width, i);
+ break;
+ }
+ }
+ }
+ } else {
+ calendar_dimensions = value;
+ }
+ this.Invalidate ();
+ }
+ }
+ get {
+ return calendar_dimensions;
+ }
+ }
+
+ // the first day of the week to display
+ [Localizable (true)]
+ [DefaultValue (Day.Default)]
+ public Day FirstDayOfWeek {
+ set {
+ if (first_day_of_week != value) {
+ first_day_of_week = value;
+ this.Invalidate ();
+ }
+ }
+ get {
+ return first_day_of_week;
+ }
+ }
+
+ // the fore color for the main part of the calendar
+ public override Color ForeColor {
+ set {
+ if (fore_color != value) {
+ fore_color = value;
+ this.OnForeColorChanged (EventArgs.Empty);
+ this.Invalidate ();
+ }
+ }
+ get {
+ return fore_color;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ImeMode ImeMode {
+ get {
+ return ime_mode;
+ }
+
+ set {
+ if (ime_mode != value) {
+ ime_mode = value;
+
+ if (ImeModeChanged != null) {
+ ImeModeChanged(this, EventArgs.Empty);
+ }
+ }
+ }
+ }
+
+ // the maximum date allowed to be selected on this month calendar
+ public DateTime MaxDate {
+ set {
+ if (value < MinDate) {
+ throw new ArgumentException();
+ }
+
+ if (max_date != value) {
+ max_date = value;
+ }
+ }
+ get {
+ return max_date;
+ }
+ }
+
+ // the maximum number of selectable days
+ [DefaultValue (7)]
+ public int MaxSelectionCount {
+ set {
+ if (value < 0) {
+ throw new ArgumentException();
+ }
+
+ // can't set selectioncount less than already selected dates
+ if ((SelectionEnd - SelectionStart).Days > value) {
+ throw new ArgumentException();
+ }
+
+ if (max_selection_count != value) {
+ max_selection_count = value;
+ }
+ }
+ get {
+ return max_selection_count;
+ }
+ }
+
+ // the minimum date allowed to be selected on this month calendar
+ public DateTime MinDate {
+ set {
+ if (value < new DateTime (1953, 1, 1)) {
+ throw new ArgumentException();
+ }
+
+ if (value > MaxDate) {
+ throw new ArgumentException();
+ }
+
+ if (max_date != value) {
+ min_date = value;
+ }
+ }
+ get {
+ return min_date;
+ }
+ }
+
+ // dates to make bold on calendar monthly (recurring)
+ [Localizable (true)]
+ public DateTime[] MonthlyBoldedDates {
+ set {
+ if (monthly_bolded_dates == null || monthly_bolded_dates != value) {
+ monthly_bolded_dates = value;
+ this.UpdateBoldedDates ();
+ this.Invalidate ();
+ }
+ }
+ get {
+ return monthly_bolded_dates;
+ }
+ }
+
+ // the ammount by which to scroll this calendar by
+ [DefaultValue (0)]
+ public int ScrollChange {
+ set {
+ if (value < 0 || value > 20000) {
+ throw new ArgumentException();
+ }
+
+ if (scroll_change != value) {
+ scroll_change = value;
+ }
+ }
+ get {
+ // if zero it to the default -> the total number of months currently visible
+ if (scroll_change == 0) {
+ return CalendarDimensions.Width * CalendarDimensions.Height;
+ }
+ return scroll_change;
+ }
+ }
+
+
+ // the last selected date
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public DateTime SelectionEnd {
+ set {
+ if (value < MinDate || value > MaxDate) {
+ throw new ArgumentException();
+ }
+
+ if (SelectionRange.End != value) {
+ DateTime old_end = SelectionRange.End;
+ // make sure the end obeys the max selection range count
+ if (value < SelectionRange.Start) {
+ SelectionRange.Start = value;
+ }
+ if (value.AddDays((MaxSelectionCount-1)*-1) > SelectionRange.Start) {
+ SelectionRange.Start = value.AddDays((MaxSelectionCount-1)*-1);
+ }
+ SelectionRange.End = value;
+ this.InvalidateDateRange (new SelectionRange (old_end, SelectionRange.End));
+ this.OnDateChanged (new DateRangeEventArgs (SelectionStart, SelectionEnd));
+ }
+ }
+ get {
+ return SelectionRange.End;
+ }
+ }
+
+ // the range of selected dates
+ public SelectionRange SelectionRange {
+ set {
+ if (selection_range != value) {
+ SelectionRange old_range = selection_range;
+
+ // make sure the end obeys the max selection range count
+ if (value.End.AddDays((MaxSelectionCount-1)*-1) > value.Start) {
+ selection_range = new SelectionRange (value.End.AddDays((MaxSelectionCount-1)*-1), value.End);
+ } else {
+ selection_range = value;
+ }
+ SelectionRange visible_range = this.GetDisplayRange(true);
+ if(visible_range.Start > selection_range.End) {
+ this.current_month = new DateTime (selection_range.Start.Year, selection_range.Start.Month, 1);
+ this.Invalidate ();
+ } else if (visible_range.End < selection_range.Start) {
+ int year_diff = selection_range.End.Year - visible_range.End.Year;
+ int month_diff = selection_range.End.Month - visible_range.End.Month;
+ this.current_month = current_month.AddMonths(year_diff * 12 + month_diff);
+ this.Invalidate ();
+ }
+ // invalidate the selected range changes
+ DateTime diff_start = old_range.Start;
+ DateTime diff_end = old_range.End;
+ // now decide which region is greated
+ if (old_range.Start > SelectionRange.Start) {
+ diff_start = SelectionRange.Start;
+ } else if (old_range.Start == SelectionRange.Start) {
+ if (old_range.End < SelectionRange.End) {
+ diff_start = old_range.End;
+ } else {
+ diff_start = SelectionRange.End;
+ }
+ }
+ if (old_range.End < SelectionRange.End) {
+ diff_end = SelectionRange.End;
+ } else if (old_range.End == SelectionRange.End) {
+ if (old_range.Start < SelectionRange.Start) {
+ diff_end = SelectionRange.Start;
+ } else {
+ diff_end = old_range.Start;
+ }
+ }
+
+
+ // invalidate the region required
+ SelectionRange new_range = new SelectionRange (diff_start, diff_end);
+ if (new_range.End != old_range.End || new_range.Start != old_range.Start)
+ this.InvalidateDateRange (new_range);
+ // raise date changed event
+ this.OnDateChanged (new DateRangeEventArgs (SelectionStart, SelectionEnd));
+ }
+ }
+ get {
+ return selection_range;
+ }
+ }
+
+ // the first selected date
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public DateTime SelectionStart {
+ set {
+ if (value < MinDate || value > MaxDate) {
+ throw new ArgumentException();
+ }
+
+ if (SelectionRange.Start != value) {
+ DateTime old_start = SelectionRange.Start;
+ // make sure the end obeys the max selection range count
+ if (value > SelectionRange.End) {
+ SelectionRange.End = value;
+ } else if (value.AddDays(MaxSelectionCount-1) < SelectionRange.End) {
+ SelectionRange.End = value.AddDays(MaxSelectionCount-1);
+ }
+ SelectionRange.Start = value;
+ DateTime new_month = new DateTime(value.Year, value.Month, 1);
+ if (current_month != new_month) {
+ current_month = new_month;
+ this.Invalidate ();
+ } else {
+ this.InvalidateDateRange (new SelectionRange (old_start, SelectionRange.Start));
+ }
+ this.OnDateChanged (new DateRangeEventArgs (SelectionStart, SelectionEnd));
+ }
+ }
+ get {
+ return selection_range.Start;
+ }
+ }
+
+ // whether or not to show todays date
+ [DefaultValue (true)]
+ public bool ShowToday {
+ set {
+ if (show_today != value) {
+ show_today = value;
+ this.Invalidate ();
+ }
+ }
+ get {
+ return show_today;
+ }
+ }
+
+ // whether or not to show a circle around todays date
+ [DefaultValue (true)]
+ public bool ShowTodayCircle {
+ set {
+ if (show_today_circle != value) {
+ show_today_circle = value;
+ this.Invalidate ();
+ }
+ }
+ get {
+ return show_today_circle;
+ }
+ }
+
+ // whether or not to show numbers beside each row of weeks
+ [Localizable (true)]
+ [DefaultValue (false)]
+ public bool ShowWeekNumbers {
+ set {
+ if (show_week_numbers != value) {
+ show_week_numbers = value;
+ this.Invalidate ();
+ }
+ }
+ get {
+ return show_week_numbers;
+ }
+ }
+
+ // the rectangle size required to render one month based on current font
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public Size SingleMonthSize {
+ get {
+ if (this.Font == null) {
+ throw new InvalidOperationException();
+ }
+
+ // multiplier is sucked out from the font size
+ int multiplier = this.Font.Height;
+
+ // establis how many columns and rows we have
+ int column_count = (ShowWeekNumbers) ? 8 : 7;
+ int row_count = 7; // not including the today date
+
+ // set the date_cell_size and the title_size
+ date_cell_size = new Size ((int) Math.Ceiling (2.5 * multiplier), (int) Math.Ceiling (1.5 * multiplier));
+ title_size = new Size ((date_cell_size.Width * column_count), 3 * multiplier);
+
+ return new Size (column_count * date_cell_size.Width, row_count * date_cell_size.Height + title_size.Height);
+ }
+ }
+
+ [Bindable(false)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override string Text {
+ get {
+ return base.Text;
+ }
+ set {
+ base.Text = value;
+ }
+ }
+
+ // the back color for the title of the calendar and the
+ // forecolor for the day of the week text
+ public Color TitleBackColor {
+ set {
+ if (title_back_color != value) {
+ title_back_color = value;
+ this.Invalidate ();
+ }
+ }
+ get {
+ return title_back_color;
+ }
+ }
+
+ // the fore color for the title of the calendar
+ public Color TitleForeColor {
+ set {
+ if (title_fore_color != value) {
+ title_fore_color = value;
+ this.Invalidate ();
+ }
+ }
+ get {
+ return title_fore_color;
+ }
+ }
+
+ // the date this calendar is using to refer to today's date
+ public DateTime TodayDate {
+ set {
+ today_date_set = true;
+ if (today_date != value) {
+ today_date = value;
+ this.Invalidate ();
+ }
+ }
+ get {
+ return today_date;
+ }
+ }
+
+ // tells if user specifically set today_date for this control
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public bool TodayDateSet {
+ get {
+ return today_date_set;
+ }
+ }
+
+ // the color used for trailing dates in the calendar
+ public Color TrailingForeColor {
+ set {
+ if (trailing_fore_color != value) {
+ trailing_fore_color = value;
+ SelectionRange bounds = this.GetDisplayRange (false);
+ SelectionRange visible_bounds = this.GetDisplayRange (true);
+ this.InvalidateDateRange (new SelectionRange (bounds.Start, visible_bounds.Start));
+ this.InvalidateDateRange (new SelectionRange (bounds.End, visible_bounds.End));
+ }
+ }
+ get {
+ return trailing_fore_color;
+ }
+ }
+
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Properties
+
+ // overloaded to allow controll to be windowed for drop down
+ protected override CreateParams CreateParams {
+ get {
+ if (this.owner == null) {
+ return base.CreateParams;
+ } else {
+ CreateParams cp = base.CreateParams;
+ cp.Style ^= (int) WindowStyles.WS_CHILD;
+ cp.Style |= (int) WindowStyles.WS_POPUP;
+ cp.ExStyle |= (int)(WindowExStyles.WS_EX_TOOLWINDOW | WindowExStyles.WS_EX_TOPMOST);
+
+ return cp;
+ }
+ }
+ }
+
+ // not sure what to put in here - just doing a base() call - jba
+ protected override ImeMode DefaultImeMode {
+ get {
+ return base.DefaultImeMode;
+ }
+ }
+
+ protected override Size DefaultSize {
+ get {
+ Size single_month = SingleMonthSize;
+ // get the width
+ int width = calendar_dimensions.Width * single_month.Width;
+ if (calendar_dimensions.Width > 1) {
+ width += (calendar_dimensions.Width - 1) * calendar_spacing.Width;
+ }
+
+ // get the height
+ int height = calendar_dimensions.Height * single_month.Height;
+ if (this.ShowToday) {
+ height += date_cell_size.Height + 2; // add the height of the "Today: " ...
+ }
+ if (calendar_dimensions.Height > 1) {
+ height += (calendar_dimensions.Height - 1) * calendar_spacing.Height;
+ }
+
+ // add the 1 pixel boundary
+ if (width > 0) {
+ width += 2;
+ }
+ if (height > 0) {
+ height +=2;
+ }
+
+ return new Size (width, height);
+ }
+ }
+
+ #endregion // Protected Instance Properties
+
+ #region Public Instance Methods
+
+ // add a date to the anually bolded date arraylist
+ public void AddAnnuallyBoldedDate (DateTime date) {
+ added_annually_bolded_dates.Add (date.Date);
+ }
+
+ // add a date to the normal bolded date arraylist
+ public void AddBoldedDate (DateTime date) {
+ added_bolded_dates.Add (date.Date);
+ }
+
+ // add a date to the anually monthly date arraylist
+ public void AddMonthlyBoldedDate (DateTime date) {
+ added_monthly_bolded_dates.Add (date.Date);
+ }
+
+ // if visible = true, return only the dates of full months, else return all dates visible
+ public SelectionRange GetDisplayRange (bool visible) {
+ DateTime start;
+ DateTime end;
+ start = new DateTime (current_month.Year, current_month.Month, 1);
+ end = start.AddMonths (calendar_dimensions.Width * calendar_dimensions.Height);
+ end = end.AddDays(-1);
+
+ // process all visible dates if needed (including the grayed out dates
+ if (!visible) {
+ start = GetFirstDateInMonthGrid (start);
+ end = GetLastDateInMonthGrid (end);
+ }
+
+ return new SelectionRange (start, end);
+ }
+
+ // HitTest overload that recieve's x and y co-ordinates as separate ints
+ public HitTestInfo HitTest (int x, int y) {
+ return HitTest (new Point (x, y));
+ }
+
+ // returns a HitTestInfo for MonthCalendar element's under the specified point
+ public HitTestInfo HitTest (Point point) {
+ return HitTest (point, out last_clicked_calendar_index, out last_clicked_calendar_rect);
+ }
+
+ // clears all the annually bolded dates
+ public void RemoveAllAnnuallyBoldedDates () {
+ annually_bolded_dates = null;
+ added_annually_bolded_dates.Clear ();
+ removed_annually_bolded_dates.Clear ();
+ }
+
+ // clears all the normal bolded dates
+ public void RemoveAllBoldedDates () {
+ bolded_dates = null;
+ added_bolded_dates.Clear ();
+ removed_bolded_dates.Clear ();
+ }
+
+ // clears all the monthly bolded dates
+ public void RemoveAllMonthlyBoldedDates () {
+ monthly_bolded_dates = null;
+ added_monthly_bolded_dates.Clear ();
+ removed_monthly_bolded_dates.Clear ();
+ }
+
+ // clears the specified annually bolded date (only compares day and month)
+ // only removes the first instance of the match
+ public void RemoveAnnuallyBoldedDate (DateTime date) {
+ if (!removed_annually_bolded_dates.Contains (date.Date)) {
+ removed_annually_bolded_dates.Add (date.Date);
+ }
+ }
+
+ // clears all the normal bolded date
+ // only removes the first instance of the match
+ public void RemoveBoldedDate (DateTime date) {
+ if (!removed_bolded_dates.Contains (date.Date)) {
+ removed_bolded_dates.Add (date.Date);
+ }
+ }
+
+ // clears the specified monthly bolded date (only compares day and month)
+ // only removes the first instance of the match
+ public void RemoveMonthlyBoldedDate (DateTime date) {
+ if (!removed_monthly_bolded_dates.Contains (date.Date)) {
+ removed_monthly_bolded_dates.Add (date.Date);
+ }
+ }
+
+ // sets the calendar_dimensions. If product is > 12, the larger dimension is reduced to make product < 12
+ public void SetCalendarDimensions(int x, int y) {
+ this.CalendarDimensions = new Size(x, y);
+ }
+
+ // sets the currently selected date as date
+ public void SetDate (DateTime date) {
+ this.SetSelectionRange (date.Date, date.Date);
+ }
+
+ // utility method set the SelectionRange property using individual dates
+ public void SetSelectionRange (DateTime date1, DateTime date2) {
+ this.SelectionRange = new SelectionRange(date1, date2);
+ }
+
+ public override string ToString () {
+ return this.GetType().Name + ", " + this.SelectionRange.ToString ();
+ }
+
+ // usually called after an AddBoldedDate method is called
+ // formats monthly and daily bolded dates according to the current calendar year
+ public void UpdateBoldedDates () {
+ UpdateDateArray (ref bolded_dates, added_bolded_dates, removed_bolded_dates);
+ UpdateDateArray (ref monthly_bolded_dates, added_monthly_bolded_dates, removed_monthly_bolded_dates);
+ UpdateDateArray (ref annually_bolded_dates, added_annually_bolded_dates, removed_annually_bolded_dates);
+ }
+
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+
+ // not sure why this needs to be overriden
+ protected override void CreateHandle () {
+ base.CreateHandle ();
+ }
+
+ private void CreateYearUpDown ()
+ {
+ year_updown = new NumericUpDown ();
+ year_updown.Font = this.Font;
+ year_updown.Minimum = MinDate.Year;
+ year_updown.Maximum = MaxDate.Year;
+ year_updown.ReadOnly = true;
+ year_updown.Visible = false;
+ this.Controls.AddImplicit (year_updown);
+ year_updown.ValueChanged += new EventHandler(UpDownYearChangedHandler);
+ }
+
+ // not sure why this needs to be overriden
+ protected override void Dispose (bool disposing) {
+ base.Dispose (disposing);
+ }
+
+ // not sure why this needs to be overriden
+ protected override bool IsInputKey (Keys keyData) {
+ return base.IsInputKey (keyData);
+ }
+
+ // not sure why this needs to be overriden
+ protected override void OnBackColorChanged (EventArgs e) {
+ base.OnBackColorChanged (e);
+ this.Invalidate ();
+ }
+
+ // raises the date changed event
+ protected virtual void OnDateChanged (DateRangeEventArgs drevent) {
+ if (this.DateChanged != null) {
+ this.DateChanged (this, drevent);
+ }
+ }
+
+ // raises the DateSelected event
+ protected virtual void OnDateSelected (DateRangeEventArgs drevent) {
+ if (this.DateSelected != null) {
+ this.DateSelected (this, drevent);
+ }
+ }
+
+ protected override void OnFontChanged (EventArgs e) {
+ base.OnFontChanged (e);
+ }
+
+ protected override void OnForeColorChanged (EventArgs e) {
+ base.OnForeColorChanged (e);
+ }
+
+ protected override void OnHandleCreated (EventArgs e) {
+ base.OnHandleCreated (e);
+ CreateYearUpDown ();
+ }
+
+ // i think this is overriden to not allow the control to be changed to an arbitrary size
+ protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified) {
+ if ((specified & BoundsSpecified.Height) == BoundsSpecified.Height ||
+ (specified & BoundsSpecified.Width) == BoundsSpecified.Width ||
+ (specified & BoundsSpecified.Size) == BoundsSpecified.Size) {
+ // only allow sizes = default size to be set
+ Size min_size = DefaultSize;
+ Size max_size = new Size (
+ DefaultSize.Width + SingleMonthSize.Width + calendar_spacing.Width,
+ DefaultSize.Height + SingleMonthSize.Height + calendar_spacing.Height);
+ int x_mid_point = (max_size.Width + min_size.Width)/2;
+ int y_mid_point = (max_size.Height + min_size.Height)/2;
+ if (width < x_mid_point) {
+ width = min_size.Width;
+ } else {
+ width = max_size.Width;
+ }
+ if (height < y_mid_point) {
+ height = min_size.Height;
+ } else {
+ height = max_size.Height;
+ }
+ base.SetBoundsCore (x, y, width, height, specified);
+ } else {
+ base.SetBoundsCore (x, y, width, height, specified);
+ }
+ }
+
+ protected override void WndProc (ref Message m) {
+ base.WndProc (ref m);
+ }
+
+ #endregion // Protected Instance Methods
+
+ #region public events
+
+ // fired when the date is changed (either explicitely or implicitely)
+ // when navigating the month selector
+ public event DateRangeEventHandler DateChanged;
+
+ // fired when the user explicitely clicks on date to select it
+ public event DateRangeEventHandler DateSelected;
+
+ [Browsable(false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public event EventHandler BackgroundImageChanged;
+
+ // this event is overridden to supress it from being fired
+ [Browsable(false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public event EventHandler Click;
+
+ // this event is overridden to supress it from being fired
+ [Browsable(false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public event EventHandler DoubleClick;
+
+ [Browsable(false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public event EventHandler ImeModeChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event PaintEventHandler Paint;
+
+ [Browsable(false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public event EventHandler TextChanged;
+ #endregion // public events
+
+ #region internal properties
+
+ internal DateTime CurrentMonth {
+ set {
+ // only interested in if the month (not actual date) has changed
+ if (value.Month != current_month.Month ||
+ value.Year != current_month.Year) {
+ this.SelectionRange = new SelectionRange(
+ this.SelectionStart.Add(value.Subtract(current_month)),
+ this.SelectionEnd.Add(value.Subtract(current_month)));
+ current_month = value;
+ UpdateBoldedDates();
+ this.Invalidate();
+ }
+ }
+ get {
+ return current_month;
+ }
+ }
+
+ #endregion // internal properties
+
+ #region internal/private methods
+ internal HitTestInfo HitTest (
+ Point point,
+ out int calendar_index,
+ out Rectangle calendar_rect) {
+ // start by initialising the ref parameters
+ calendar_index = -1;
+ calendar_rect = Rectangle.Empty;
+
+ // before doing all the hard work, see if the today's date wasn't clicked
+ Rectangle today_rect = new Rectangle (
+ ClientRectangle.X,
+ ClientRectangle.Bottom - date_cell_size.Height,
+ 7 * date_cell_size.Width,
+ date_cell_size.Height);
+ if (today_rect.Contains (point) && this.ShowToday) {
+ return new HitTestInfo(HitArea.TodayLink, point, DateTime.Now);
+ }
+
+ Size month_size = SingleMonthSize;
+ // define calendar rect's that this thing can land in
+ Rectangle[] calendars = new Rectangle [CalendarDimensions.Width * CalendarDimensions.Height];
+ for (int i=0; i < CalendarDimensions.Width * CalendarDimensions.Height; i ++) {
+ if (i == 0) {
+ calendars[i] = new Rectangle (
+ new Point (ClientRectangle.X + 1, ClientRectangle.Y + 1),
+ month_size);
+ } else {
+ // calendar on the next row
+ if (i % CalendarDimensions.Width == 0) {
+ calendars[i] = new Rectangle (
+ new Point (calendars[i-CalendarDimensions.Width].X, calendars[i-CalendarDimensions.Width].Bottom + calendar_spacing.Height),
+ month_size);
+ } else {
+ // calendar on the next column
+ calendars[i] = new Rectangle (
+ new Point (calendars[i-1].Right + calendar_spacing.Width, calendars[i-1].Y),
+ month_size);
+ }
+ }
+ }
+
+ // through each trying to find a match
+ for (int i = 0; i < calendars.Length ; i++) {
+ if (calendars[i].Contains (point)) {
+ // check the title section
+ Rectangle title_rect = new Rectangle (
+ calendars[i].Location,
+ title_size);
+ if (title_rect.Contains (point) ) {
+ // make sure it's not a previous button
+ if (i == 0) {
+ Rectangle button_rect = new Rectangle(
+ new Point (calendars[i].X + button_x_offset, (title_size.Height - button_size.Height)/2),
+ button_size);
+ if (button_rect.Contains (point)) {
+ return new HitTestInfo(HitArea.PrevMonthButton, point, DateTime.Now);
+ }
+ }
+ // make sure it's not the next button
+ if (i % CalendarDimensions.Height == 0 && i % CalendarDimensions.Width == calendar_dimensions.Width - 1) {
+ Rectangle button_rect = new Rectangle(
+ new Point (calendars[i].Right - button_x_offset - button_size.Width, (title_size.Height - button_size.Height)/2),
+ button_size);
+ if (button_rect.Contains (point)) {
+ return new HitTestInfo(HitArea.NextMonthButton, point, DateTime.Now);
+ }
+ }
+
+ // indicate which calendar and month it was
+ calendar_index = i;
+ calendar_rect = calendars[i];
+
+ // make sure it's not the month or the year of the calendar
+ if (GetMonthNameRectangle (title_rect, i).Contains (point)) {
+ return new HitTestInfo(HitArea.TitleMonth, point, DateTime.Now);
+ }
+ if (GetYearNameRectangle (title_rect, i).Contains (point)) {
+ return new HitTestInfo(HitArea.TitleYear, point, DateTime.Now);
+ }
+
+ // return the hit test in the title background
+ return new HitTestInfo(HitArea.TitleBackground, point, DateTime.Now);
+ }
+
+ Point date_grid_location = new Point (calendars[i].X, title_rect.Bottom);
+
+ // see if it's in the Week numbers
+ if (ShowWeekNumbers) {
+ Rectangle weeks_rect = new Rectangle (
+ date_grid_location,
+ new Size (date_cell_size.Width,Math.Max (calendars[i].Height - title_rect.Height, 0)));
+ if (weeks_rect.Contains (point)) {
+ return new HitTestInfo(HitArea.WeekNumbers, point, DateTime.Now);
+ }
+
+ // move the location of the grid over
+ date_grid_location.X += date_cell_size.Width;
+ }
+
+ // see if it's in the week names
+ Rectangle day_rect = new Rectangle (
+ date_grid_location,
+ new Size (Math.Max (calendars[i].Right - date_grid_location.X, 0), date_cell_size.Height));
+ if (day_rect.Contains (point)) {
+ return new HitTestInfo(HitArea.DayOfWeek, point, DateTime.Now);
+ }
+
+ // finally see if it was a date that was clicked
+ Rectangle date_grid = new Rectangle (
+ new Point (day_rect.X, day_rect.Bottom),
+ new Size (day_rect.Width, Math.Max(calendars[i].Bottom - day_rect.Bottom, 0)));
+ if (date_grid.Contains (point)) {
+ clicked_rect = date_grid;
+ // okay so it's inside the grid, get the offset
+ Point offset = new Point (point.X - date_grid.X, point.Y - date_grid.Y);
+ int row = offset.Y / date_cell_size.Height;
+ int col = offset.X / date_cell_size.Width;
+ // establish our first day of the month
+ DateTime calendar_month = this.CurrentMonth.AddMonths(i);
+ DateTime first_day = GetFirstDateInMonthGrid (calendar_month);
+ DateTime time = first_day.AddDays ((row * 7) + col);
+ // establish which date was clicked
+ if (time.Year != calendar_month.Year || time.Month != calendar_month.Month) {
+ if (time < calendar_month && i == 0) {
+ return new HitTestInfo(HitArea.PrevMonthDate, point, time);
+ } else if (time > calendar_month && i == CalendarDimensions.Width*CalendarDimensions.Height - 1) {
+ return new HitTestInfo(HitArea.NextMonthDate, point, time);
+ }
+ return new HitTestInfo(HitArea.Nowhere, point, time);
+ }
+ return new HitTestInfo(HitArea.Date, point, time);
+ }
+ }
+ }
+
+ return new HitTestInfo ();
+ }
+
+ // returns the date of the first cell of the specified month grid
+ internal DateTime GetFirstDateInMonthGrid (DateTime month) {
+ // convert the first_day_of_week into a DayOfWeekEnum
+ DayOfWeek first_day = GetDayOfWeek (first_day_of_week);
+ // find the first day of the month
+ DateTime first_date_of_month = new DateTime (month.Year, month.Month, 1);
+ DayOfWeek first_day_of_month = first_date_of_month.DayOfWeek;
+ // adjust for the starting day of the week
+ int offset = first_day_of_month - first_day;
+ if (offset < 0) {
+ offset += 7;
+ }
+ return first_date_of_month.AddDays (-1*offset);
+ }
+
+ // returns the date of the last cell of the specified month grid
+ internal DateTime GetLastDateInMonthGrid (DateTime month)
+ {
+ DateTime start = GetFirstDateInMonthGrid(month);
+ return start.AddDays ((7 * 6)-1);
+ }
+
+ internal bool IsBoldedDate (DateTime date) {
+ // check bolded dates
+ if (bolded_dates != null && bolded_dates.Length > 0) {
+ foreach (DateTime bolded_date in bolded_dates) {
+ if (bolded_date.Date == date.Date) {
+ return true;
+ }
+ }
+ }
+ // check monthly dates
+ if (monthly_bolded_dates != null && monthly_bolded_dates.Length > 0) {
+ foreach (DateTime bolded_date in monthly_bolded_dates) {
+ if (bolded_date.Day == date.Day) {
+ return true;
+ }
+ }
+ }
+ // check yearly dates
+ if (annually_bolded_dates != null && annually_bolded_dates.Length > 0) {
+ foreach (DateTime bolded_date in annually_bolded_dates) {
+ if (bolded_date.Month == date.Month && bolded_date.Day == date.Day) {
+ return true;
+ }
+ }
+ }
+
+ return false; // no match
+ }
+
+ // updates the specified bolded dates array with ones to add and ones to remove
+ private void UpdateDateArray (ref DateTime [] dates, ArrayList to_add, ArrayList to_remove) {
+ ArrayList list = new ArrayList ();
+
+ // update normal bolded dates
+ if (dates != null) {
+ foreach (DateTime date in dates) {
+ list.Add (date.Date);
+ }
+ }
+
+ // add new ones
+ foreach (DateTime date in to_add) {
+ if (!list.Contains (date.Date)) {
+ list.Add (date.Date);
+ }
+ }
+ to_add.Clear ();
+
+ // remove ones to remove
+ foreach (DateTime date in to_remove) {
+ if (list.Contains (date.Date)) {
+ list.Remove (date.Date);
+ }
+ }
+ to_remove.Clear ();
+ // set up the array now
+ if (list.Count > 0) {
+ dates = (DateTime []) list.ToArray (typeof (DateTime));
+ Array.Sort (dates);
+ list.Clear ();
+ } else {
+ dates = null;
+ }
+ }
+
+ // initialise the context menu
+ private void SetUpContextMenu () {
+ menu = new ContextMenu ();
+ for (int i=0; i < 12; i++) {
+ MenuItem menu_item = new MenuItem ( new DateTime (2000, i+1, 1).ToString ("MMMM"));
+ menu_item.Click += new EventHandler (MenuItemClickHandler);
+ menu.MenuItems.Add (menu_item);
+ }
+ }
+
+ // initialises text value and show's year up down in correct position
+ private void PrepareYearUpDown (Point p) {
+ Rectangle old_location = year_updown.Bounds;
+
+ // set position
+ Rectangle title_rect = new Rectangle(
+ last_clicked_calendar_rect.Location,
+ title_size);
+
+ year_updown.Bounds = GetYearNameRectangle(
+ title_rect,
+ last_clicked_calendar_index);
+ year_updown.Top -= 4;
+ year_updown.Width += (int) (this.Font.Size * 4);
+ // set year - only do this if this isn't being called because of a year up down click
+ if(year_updown.Bounds != old_location) {
+ year_updown.Value = current_month.AddMonths(last_clicked_calendar_index).Year;
+ }
+
+ if(!year_updown.Visible) {
+ year_updown.Visible = true;
+ }
+ }
+
+ // returns the first date of the month
+ private DateTime GetFirstDateInMonth (DateTime date) {
+ return new DateTime (date.Year, date.Month, 1);
+ }
+
+ // returns the last date of the month
+ private DateTime GetLastDateInMonth (DateTime date) {
+ return new DateTime (date.Year, date.Month, 1).AddMonths(1).AddDays(-1);
+ }
+
+ // called in response to users seletion with shift key
+ private void AddTimeToSelection (int delta, bool isDays)
+ {
+ DateTime cursor_point;
+ DateTime end_point;
+ // okay we add the period to the date that is not the same as the
+ // start date when shift was first clicked.
+ if (SelectionStart != first_select_start_date) {
+ cursor_point = SelectionStart;
+ } else {
+ cursor_point = SelectionEnd;
+ }
+ // add the days
+ if (isDays) {
+ end_point = cursor_point.AddDays (delta);
+ } else {
+ // delta must be months
+ end_point = cursor_point.AddMonths (delta);
+ }
+ // set the new selection range
+ SelectionRange range = new SelectionRange (first_select_start_date, end_point);
+ if (range.Start.AddDays (MaxSelectionCount-1) < range.End) {
+ // okay the date is beyond what is allowed, lets set the maximum we can
+ if (range.Start != first_select_start_date) {
+ range.Start = range.End.AddDays ((MaxSelectionCount-1)*-1);
+ } else {
+ range.End = range.Start.AddDays (MaxSelectionCount-1);
+ }
+ }
+ this.SelectionRange = range;
+ }
+
+ // attempts to add the date to the selection without throwing exception
+ private void SelectDate (DateTime date) {
+ // try and add the new date to the selction range
+ if (is_shift_pressed || (click_state [0])) {
+ SelectionRange range = new SelectionRange (first_select_start_date, date);
+ if (range.Start.AddDays (MaxSelectionCount-1) < range.End) {
+ // okay the date is beyond what is allowed, lets set the maximum we can
+ if (range.Start != first_select_start_date) {
+ range.Start = range.End.AddDays ((MaxSelectionCount-1)*-1);
+ } else {
+ range.End = range.Start.AddDays (MaxSelectionCount-1);
+ }
+ }
+ SelectionRange = range;
+ } else {
+ SelectionRange = new SelectionRange (date, date);
+ first_select_start_date = date;
+ }
+ }
+
+ // gets the week of the year
+ internal int GetWeekOfYear (DateTime date) {
+ // convert the first_day_of_week into a DayOfWeekEnum
+ DayOfWeek first_day = GetDayOfWeek (first_day_of_week);
+ // find the first day of the year
+ DayOfWeek first_day_of_year = new DateTime (date.Year, 1, 1).DayOfWeek;
+ // adjust for the starting day of the week
+ int offset = first_day_of_year - first_day;
+ int week = ((date.DayOfYear + offset) / 7) + 1;
+ return week;
+ }
+
+ // convert a Day enum into a DayOfWeek enum
+ internal DayOfWeek GetDayOfWeek (Day day) {
+ if (day == Day.Default) {
+ return DayOfWeek.Sunday;
+ } else {
+ return (DayOfWeek) DayOfWeek.Parse (typeof (DayOfWeek), day.ToString ());
+ }
+ }
+
+ // returns the rectangle for themonth name
+ internal Rectangle GetMonthNameRectangle (Rectangle title_rect, int calendar_index) {
+ Graphics g = this.DeviceContext;
+ DateTime this_month = this.current_month.AddMonths (calendar_index);
+ Size title_text_size = g.MeasureString (this_month.ToString ("MMMM yyyy"), this.Font).ToSize ();
+ Size month_size = g.MeasureString (this_month.ToString ("MMMM"), this.Font).ToSize ();
+ // return only the month name part of that
+ return new Rectangle (
+ new Point (
+ title_rect.X + ((title_rect.Width - title_text_size.Width)/2),
+ title_rect.Y + ((title_rect.Height - title_text_size.Height)/2)),
+ month_size);
+ }
+
+ // returns the rectangle for the year in the title
+ internal Rectangle GetYearNameRectangle (Rectangle title_rect, int calendar_index) {
+ Graphics g = this.DeviceContext;
+ DateTime this_month = this.current_month.AddMonths (calendar_index);
+ Size title_text_size = g.MeasureString (this_month.ToString ("MMMM yyyy"), this.Font).ToSize ();
+ Size year_size = g.MeasureString (this_month.ToString ("yyyy"), this.Font).ToSize ();
+ // find out how much space the title took
+ Rectangle text_rect = new Rectangle (
+ new Point (
+ title_rect.X + ((title_rect.Width - title_text_size.Width)/2),
+ title_rect.Y + ((title_rect.Height - title_text_size.Height)/2)),
+ title_text_size);
+ // return only the rect of the year
+ return new Rectangle (
+ new Point (
+ text_rect.Right - year_size.Width,
+ text_rect.Y),
+ year_size);
+ }
+
+ // determine if date is allowed to be drawn in month
+ internal bool IsValidWeekToDraw (DateTime month, DateTime date, int row, int col) {
+ DateTime tocheck = month.AddMonths (-1);
+ if ((month.Year == date.Year && month.Month == date.Month) ||
+ (tocheck.Year == date.Year && tocheck.Month == date.Month)) {
+ return true;
+ }
+
+ // check the railing dates (days in the month after the last month in grid)
+ if (row == CalendarDimensions.Height - 1 && col == CalendarDimensions.Width - 1) {
+ tocheck = month.AddMonths (1);
+ return (tocheck.Year == date.Year && tocheck.Month == date.Month) ;
+ }
+
+ return false;
+ }
+
+ // set one item clicked and all others off
+ private void SetItemClick(HitTestInfo hti)
+ {
+ switch(hti.HitArea) {
+ case HitArea.NextMonthButton:
+ this.is_previous_clicked = false;
+ this.is_next_clicked = true;
+ this.is_date_clicked = false;
+ break;
+ case HitArea.PrevMonthButton:
+ this.is_previous_clicked = true;
+ this.is_next_clicked = false;
+ this.is_date_clicked = false;
+ break;
+ case HitArea.PrevMonthDate:
+ case HitArea.NextMonthDate:
+ case HitArea.Date:
+ this.clicked_date = hti.Time;
+ this.is_previous_clicked = false;
+ this.is_next_clicked = false;
+ this.is_date_clicked = true;
+ break;
+ default :
+ this.is_previous_clicked = false;
+ this.is_next_clicked = false;
+ this.is_date_clicked = false;
+ break;
+ }
+ }
+
+ // called when the year is changed
+ private void UpDownYearChangedHandler (object sender, EventArgs e) {
+ int initial_year_value = this.CurrentMonth.AddMonths(last_clicked_calendar_index).Year;
+ int diff = (int) year_updown.Value - initial_year_value;
+ this.CurrentMonth = this.CurrentMonth.AddYears(diff);
+ }
+
+ // called when context menu is clicked
+ private void MenuItemClickHandler (object sender, EventArgs e) {
+ MenuItem item = sender as MenuItem;
+ if (item != null && month_title_click_location != Point.Empty) {
+ // establish which month we want to move to
+ if (item.Parent == null) {
+ return;
+ }
+ int new_month = item.Parent.MenuItems.IndexOf (item) + 1;
+ if (new_month == 0) {
+ return;
+ }
+ // okay let's establish which calendar was hit
+ Size month_size = this.SingleMonthSize;
+ for (int i=0; i < CalendarDimensions.Height; i++) {
+ for (int j=0; j < CalendarDimensions.Width; j++) {
+ int month_index = (i * CalendarDimensions.Width) + j;
+ Rectangle month_rect = new Rectangle ( new Point (0, 0), month_size);
+ if (j == 0) {
+ month_rect.X = this.ClientRectangle.X + 1;
+ } else {
+ month_rect.X = this.ClientRectangle.X + 1 + ((j)*(month_size.Width+calendar_spacing.Width));
+ }
+ if (i == 0) {
+ month_rect.Y = this.ClientRectangle.Y + 1;
+ } else {
+ month_rect.Y = this.ClientRectangle.Y + 1 + ((i)*(month_size.Height+calendar_spacing.Height));
+ }
+ // see if the point is inside
+ if (month_rect.Contains (month_title_click_location)) {
+ DateTime clicked_month = CurrentMonth.AddMonths (month_index);
+ // get the month that we want to move to
+ int month_offset = new_month - clicked_month.Month;
+
+ // move forward however more months we need to
+ this.CurrentMonth = this.CurrentMonth.AddMonths (month_offset);
+ break;
+ }
+ }
+ }
+
+ // clear the point
+ month_title_click_location = Point.Empty;
+ }
+ }
+
+ // raised on the timer, for mouse hold clicks
+ private void TimerHandler (object sender, EventArgs e) {
+ // now find out which area was click
+ if (this.Capture) {
+ HitTestInfo hti = this.HitTest (this.PointToClient (MousePosition));
+ // see if it was clicked on the prev or next mouse
+ if (click_state [1] || click_state [2]) {
+ // invalidate the area where the mouse was last held
+ DoMouseUp ();
+ // register the click
+ if (hti.HitArea == HitArea.PrevMonthButton ||
+ hti.HitArea == HitArea.NextMonthButton) {
+ DoButtonMouseDown (hti);
+ click_state [1] = (hti.HitArea == HitArea.PrevMonthButton);
+ click_state [2] = !click_state [1];
+ }
+ if (timer.Interval != 300) {
+ timer.Interval = 300;
+ }
+ }
+ } else {
+ timer.Enabled = false;
+ }
+ }
+
+ // selects one of the buttons
+ private void DoButtonMouseDown (HitTestInfo hti) {
+ // show the click then move on
+ SetItemClick(hti);
+ if (hti.HitArea == HitArea.PrevMonthButton) {
+ // invalidate the prev monthbutton
+ this.Invalidate(
+ new Rectangle (
+ this.ClientRectangle.X + 1 + button_x_offset,
+ this.ClientRectangle.Y + 1 + (title_size.Height - button_size.Height)/2,
+ button_size.Width,
+ button_size.Height));
+ this.CurrentMonth = this.CurrentMonth.AddMonths (ScrollChange*-1);
+ } else {
+ // invalidate the next monthbutton
+ this.Invalidate(
+ new Rectangle (
+ this.ClientRectangle.Right - 1 - button_x_offset - button_size.Width,
+ this.ClientRectangle.Y + 1 + (title_size.Height - button_size.Height)/2,
+ button_size.Width,
+ button_size.Height));
+ this.CurrentMonth = this.CurrentMonth.AddMonths (ScrollChange);
+ }
+ }
+
+ // selects the clicked date
+ private void DoDateMouseDown (HitTestInfo hti) {
+ SetItemClick(hti);
+ this.SelectDate (clicked_date);
+ this.OnDateSelected (new DateRangeEventArgs (SelectionStart, SelectionEnd));
+ }
+
+ // event run on the mouse up event
+ private void DoMouseUp () {
+ // invalidate the next monthbutton
+ if (this.is_next_clicked) {
+ this.Invalidate(
+ new Rectangle (
+ this.ClientRectangle.Right - 1 - button_x_offset - button_size.Width,
+ this.ClientRectangle.Y + 1 + (title_size.Height - button_size.Height)/2,
+ button_size.Width,
+ button_size.Height));
+ }
+ // invalidate the prev monthbutton
+ if (this.is_previous_clicked) {
+ this.Invalidate(
+ new Rectangle (
+ this.ClientRectangle.X + 1 + button_x_offset,
+ this.ClientRectangle.Y + 1 + (title_size.Height - button_size.Height)/2,
+ button_size.Width,
+ button_size.Height));
+ }
+ if (this.is_date_clicked) {
+ // invalidate the area under the cursor, to remove focus rect
+ this.InvalidateDateRange (new SelectionRange (clicked_date, clicked_date));
+ }
+ this.is_previous_clicked = false;
+ this.is_next_clicked = false;
+ this.is_date_clicked = false;
+ }
+
+// // need when in windowed mode
+// private void LostFocusHandler (object sender, EventArgs e)
+// {
+// if (this.owner != null) {
+// if (this.Visible) {
+// this.owner.HideMonthCalendar ();
+// }
+// }
+// }
+
+ // occurs when mouse moves around control, used for selection
+ private void MouseMoveHandler (object sender, MouseEventArgs e) {
+ HitTestInfo hti = this.HitTest (e.X, e.Y);
+ // clear the last clicked item
+ if (click_state [0]) {
+ // register the click
+ if (hti.HitArea == HitArea.PrevMonthDate ||
+ hti.HitArea == HitArea.NextMonthDate ||
+ hti.HitArea == HitArea.Date)
+ {
+ Rectangle prev_rect = clicked_rect;
+ DateTime prev_clicked = clicked_date;
+ DoDateMouseDown (hti);
+ if (owner == null) {
+ click_state [0] = true;
+ } else {
+ click_state [0] = false;
+ click_state [1] = false;
+ click_state [2] = false;
+ }
+
+ if (prev_clicked != clicked_date) {
+ Rectangle invalid = Rectangle.Union (prev_rect, clicked_rect);
+ Invalidate (invalid);
+ }
+ }
+
+ }
+ }
+
+ // to check if the mouse has come down on this control
+ private void MouseDownHandler (object sender, MouseEventArgs e)
+ {
+ // clear the click_state variables
+ click_state [0] = false;
+ click_state [1] = false;
+ click_state [2] = false;
+
+ // disable the timer if it was enabled
+ if (timer.Enabled) {
+ timer.Stop ();
+ timer.Enabled = false;
+ }
+
+ Point point = new Point (e.X, e.Y);
+ // figure out if we are in drop down mode and a click happened outside us
+ if (this.owner != null) {
+ if (!this.ClientRectangle.Contains (point)) {
+ this.owner.HideMonthCalendar ();
+ return;
+ }
+ }
+
+ //establish where was hit
+ HitTestInfo hti = this.HitTest(point);
+ // hide the year numeric up down if it was clicked
+ if (year_updown != null && year_updown.Visible && hti.HitArea != HitArea.TitleYear)
+ {
+ year_updown.Visible = false;
+ }
+ switch (hti.HitArea) {
+ case HitArea.PrevMonthButton:
+ case HitArea.NextMonthButton:
+ DoButtonMouseDown (hti);
+ click_state [1] = (hti.HitArea == HitArea.PrevMonthDate);
+ click_state [2] = !click_state [1];
+ timer.Interval = 750;
+ timer.Start ();
+ break;
+ case HitArea.Date:
+ case HitArea.PrevMonthDate:
+ case HitArea.NextMonthDate:
+ DoDateMouseDown (hti);
+ // leave clicked state blank if drop down window
+ if (owner == null) {
+ click_state [0] = true;
+ } else {
+ click_state [0] = false;
+ click_state [1] = false;
+ click_state [2] = false;
+ }
+ break;
+ case HitArea.TitleMonth:
+ month_title_click_location = hti.Point;
+ menu.Show (this, hti.Point);
+ break;
+ case HitArea.TitleYear:
+ // place the numeric up down
+ PrepareYearUpDown(hti.Point);
+ break;
+ case HitArea.TodayLink:
+ this.SetSelectionRange (DateTime.Now.Date, DateTime.Now.Date);
+ this.OnDateSelected (new DateRangeEventArgs (SelectionStart, SelectionEnd));
+ break;
+ default:
+ this.is_previous_clicked = false;
+ this.is_next_clicked = false;
+ this.is_date_clicked = false;
+ break;
+ }
+ }
+
+ // raised by any key down events
+ private void KeyDownHandler (object sender, KeyEventArgs e) {
+ // send keys to the year_updown control, let it handle it
+ if(year_updown.Visible) {
+ switch (e.KeyCode) {
+ case Keys.Enter:
+ year_updown.Visible = false;
+ break;
+ case Keys.Up:
+ year_updown.Value = year_updown.Value + 1;
+ break;
+ case Keys.Down:
+ year_updown.Value = year_updown.Value - 1;
+ break;
+ }
+ } else {
+ if (!is_shift_pressed && e.Shift) {
+ first_select_start_date = SelectionStart;
+ is_shift_pressed = e.Shift;
+ }
+ switch (e.KeyCode) {
+ case Keys.Home:
+ // set the date to the start of the month
+ if (is_shift_pressed) {
+ DateTime date = GetFirstDateInMonth (first_select_start_date);
+ if (date < first_select_start_date.AddDays ((MaxSelectionCount-1)*-1)) {
+ date = first_select_start_date.AddDays ((MaxSelectionCount-1)*-1);
+ }
+ this.SetSelectionRange (date, first_select_start_date);
+ } else {
+ DateTime date = GetFirstDateInMonth (this.SelectionStart);
+ this.SetSelectionRange (date, date);
+ }
+ this.OnDateSelected (new DateRangeEventArgs (SelectionStart, SelectionEnd));
+ break;
+ case Keys.End:
+ // set the date to the last of the month
+ if (is_shift_pressed) {
+ DateTime date = GetLastDateInMonth (first_select_start_date);
+ if (date > first_select_start_date.AddDays (MaxSelectionCount-1)) {
+ date = first_select_start_date.AddDays (MaxSelectionCount-1);
+ }
+ this.SetSelectionRange (date, first_select_start_date);
+ } else {
+ DateTime date = GetLastDateInMonth (this.SelectionStart);
+ this.SetSelectionRange (date, date);
+ }
+ this.OnDateSelected (new DateRangeEventArgs (SelectionStart, SelectionEnd));
+ break;
+ case Keys.PageUp:
+ // set the date to the last of the month
+ if (is_shift_pressed) {
+ this.AddTimeToSelection (-1, false);
+ } else {
+ DateTime date = this.SelectionStart.AddMonths (-1);
+ this.SetSelectionRange (date, date);
+ }
+ this.OnDateSelected (new DateRangeEventArgs (SelectionStart, SelectionEnd));
+ break;
+ case Keys.PageDown:
+ // set the date to the last of the month
+ if (is_shift_pressed) {
+ this.AddTimeToSelection (1, false);
+ } else {
+ DateTime date = this.SelectionStart.AddMonths (1);
+ this.SetSelectionRange (date, date);
+ }
+ this.OnDateSelected (new DateRangeEventArgs (SelectionStart, SelectionEnd));
+ break;
+ case Keys.Up:
+ // set the back 1 week
+ if (is_shift_pressed) {
+ this.AddTimeToSelection (-7, true);
+ } else {
+ DateTime date = this.SelectionStart.AddDays (-7);
+ this.SetSelectionRange (date, date);
+ }
+ this.OnDateSelected (new DateRangeEventArgs (SelectionStart, SelectionEnd));
+ break;
+ case Keys.Down:
+ // set the date forward 1 week
+ if (is_shift_pressed) {
+ this.AddTimeToSelection (7, true);
+ } else {
+ DateTime date = this.SelectionStart.AddDays (7);
+ this.SetSelectionRange (date, date);
+ }
+ this.OnDateSelected (new DateRangeEventArgs (SelectionStart, SelectionEnd));
+ break;
+ case Keys.Left:
+ // move one left
+ if (is_shift_pressed) {
+ this.AddTimeToSelection (-1, true);
+ } else {
+ DateTime date = this.SelectionStart.AddDays (-1);
+ this.SetSelectionRange (date, date);
+ }
+ this.OnDateSelected (new DateRangeEventArgs (SelectionStart, SelectionEnd));
+ break;
+ case Keys.Right:
+ // move one left
+ if (is_shift_pressed) {
+ this.AddTimeToSelection (1, true);
+ } else {
+ DateTime date = this.SelectionStart.AddDays (1);
+ this.SetSelectionRange (date, date);
+ }
+ this.OnDateSelected (new DateRangeEventArgs (SelectionStart, SelectionEnd));
+ break;
+ default:
+ break;
+ }
+ e.Handled = true;
+ }
+ }
+
+ // to check if the mouse has come up on this control
+ private void MouseUpHandler (object sender, MouseEventArgs e)
+ {
+ if (timer.Enabled) {
+ timer.Stop ();
+ }
+ // clear the click state array
+ click_state [0] = false;
+ click_state [1] = false;
+ click_state [2] = false;
+ // do the regulare mouseup stuff
+ this.DoMouseUp ();
+ }
+
+ // raised by any key up events
+ private void KeyUpHandler (object sender, KeyEventArgs e) {
+ is_shift_pressed = e.Shift ;
+ e.Handled = true;
+ }
+
+ // paint this control now
+ private void PaintHandler (object sender, PaintEventArgs pe) {
+ if (Width <= 0 || Height <= 0 || Visible == false)
+ return;
+
+ Draw (pe.ClipRectangle, pe.Graphics);
+
+ // fire the new paint handler
+ if (this.Paint != null)
+ {
+ this.Paint (sender, pe);
+ }
+ }
+
+ // returns the region of the control that needs to be redrawn
+ private void InvalidateDateRange (SelectionRange range) {
+ SelectionRange bounds = this.GetDisplayRange (false);
+
+ if (range.End < bounds.Start || range.Start > bounds.End) {
+ // don't invalidate anything, as the modified date range
+ // is outside the visible bounds of this control
+ return;
+ }
+ // adjust the start and end to be inside the visible range
+ if (range.Start < bounds.Start) {
+ range = new SelectionRange (bounds.Start, range.End);
+ }
+ if (range.End > bounds.End) {
+ range = new SelectionRange (range.Start, bounds.End);
+ }
+ // now invalidate the date rectangles as series of rows
+ DateTime last_month = this.current_month.AddMonths ((CalendarDimensions.Width * CalendarDimensions.Height)).AddDays (-1);
+ DateTime current = range.Start;
+ while (current <= range.End) {
+ DateTime month_end = new DateTime (current.Year, current.Month, 1).AddMonths (1).AddDays (-1);;
+ Rectangle start_rect;
+ Rectangle end_rect;
+ // see if entire selection is in this current month
+ if (range.End <= month_end && current < last_month) {
+ // the end is the last date
+ if (current < this.current_month) {
+ start_rect = GetDateRowRect (current_month, current_month);
+ } else {
+ start_rect = GetDateRowRect (current, current);
+ }
+ end_rect = GetDateRowRect (current, range.End);
+ } else if (current < last_month) {
+ // otherwise it simply means we have a selection spaning
+ // multiple months simply set rectangle inside the current month
+ start_rect = GetDateRowRect (current, current);
+ end_rect = GetDateRowRect (month_end, month_end);
+ } else {
+ // it's outside the visible range
+ start_rect = GetDateRowRect (last_month, last_month.AddDays (1));
+ end_rect = GetDateRowRect (last_month, range.End);
+ }
+ // push to the next month
+ current = month_end.AddDays (1);
+ // invalidate from the start row to the end row for this month
+ this.Invalidate (
+ new Rectangle (
+ start_rect.X,
+ start_rect.Y,
+ start_rect.Width,
+ Math.Max (end_rect.Bottom - start_rect.Y, 0)));
+ }
+ }
+
+ // gets the rect of the row where the specified date appears on the specified month
+ private Rectangle GetDateRowRect (DateTime month, DateTime date) {
+ // first get the general rect of the supplied month
+ Size month_size = SingleMonthSize;
+ Rectangle month_rect = Rectangle.Empty;
+ for (int i=0; i < CalendarDimensions.Width*CalendarDimensions.Height; i++) {
+ DateTime this_month = this.current_month.AddMonths (i);
+ if (month.Year == this_month.Year && month.Month == this_month.Month) {
+ month_rect = new Rectangle (
+ this.ClientRectangle.X + 1 + (month_size.Width * (i%CalendarDimensions.Width)) + (this.calendar_spacing.Width * (i%CalendarDimensions.Width)),
+ this.ClientRectangle.Y + 1 + (month_size.Height * (i/CalendarDimensions.Width)) + (this.calendar_spacing.Height * (i/CalendarDimensions.Width)),
+ month_size.Width,
+ month_size.Height);
+ break;
+ }
+ }
+ // now find out where in the month the supplied date is
+ if (month_rect == Rectangle.Empty) {
+ return Rectangle.Empty;
+ }
+ // find out which row this date is in
+ int row = -1;
+ DateTime first_date = GetFirstDateInMonthGrid (month);
+ DateTime end_date = first_date.AddDays (7);
+ for (int i=0; i < 6; i++) {
+ if (date >= first_date && date < end_date) {
+ row = i;
+ break;
+ }
+ first_date = end_date;
+ end_date = end_date.AddDays (7);
+ }
+ // ensure it's a valid row
+ if (row < 0) {
+ return Rectangle.Empty;
+ }
+ int x_offset = (this.ShowWeekNumbers) ? date_cell_size.Width : 0;
+ int y_offset = title_size.Height + (date_cell_size.Height * (row + 1));
+ return new Rectangle (
+ month_rect.X + x_offset,
+ month_rect.Y + y_offset,
+ date_cell_size.Width * 7,
+ date_cell_size.Height);
+ }
+
+ internal void Draw (Rectangle clip_rect, Graphics dc)
+ {
+ ThemeEngine.Current.DrawMonthCalendar (dc, clip_rect, this);
+ }
+
+ #endregion //internal methods
+
+ #region internal drawing methods
+
+
+ #endregion // internal drawing methods
+
+ #region inner classes and enumerations
+
+ // enumeration about what type of area on the calendar was hit
+ public enum HitArea {
+ Nowhere,
+ TitleBackground,
+ TitleMonth,
+ TitleYear,
+ NextMonthButton,
+ PrevMonthButton,
+ CalendarBackground,
+ Date,
+ NextMonthDate,
+ PrevMonthDate,
+ DayOfWeek,
+ WeekNumbers,
+ TodayLink
+ }
+
+ // info regarding to a hit test on this calendar
+ public sealed class HitTestInfo {
+
+ private HitArea hit_area;
+ private Point point;
+ private DateTime time;
+
+ // default constructor
+ internal HitTestInfo () {
+ hit_area = HitArea.Nowhere;
+ point = new Point (0, 0);
+ time = DateTime.Now;
+ }
+
+ // overload receives all properties
+ internal HitTestInfo (HitArea hit_area, Point point, DateTime time) {
+ this.hit_area = hit_area;
+ this.point = point;
+ this.time = time;
+ }
+
+ // the type of area that was hit
+ public HitArea HitArea {
+ get {
+ return hit_area;
+ }
+ }
+
+ // the point that is being test
+ public Point Point {
+ get {
+ return point;
+ }
+ }
+
+ // the date under the hit test point, only valid if HitArea is Date
+ public DateTime Time {
+ get {
+ return time;
+ }
+ }
+ }
+
+ #endregion // inner classes
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MouseButtons.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MouseButtons.cs
new file mode 100644
index 00000000000..7c73ec3a3d8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MouseButtons.cs
@@ -0,0 +1,42 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [Flags]
+ [ComVisible(true)]
+ public enum MouseButtons {
+ None = 0x00000000,
+ Left = 0x00100000,
+ Right = 0x00200000,
+ Middle = 0x00400000,
+ XButton1 = 0x00800000,
+ XButton2 = 0x01000000
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MouseEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MouseEventArgs.cs
new file mode 100644
index 00000000000..138d64d988e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MouseEventArgs.cs
@@ -0,0 +1,82 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public class MouseEventArgs : EventArgs {
+ private MouseButtons buttons;
+ private int clicks;
+ private int delta;
+ private int x;
+ private int y;
+
+ #region Public Constructors
+ public MouseEventArgs(MouseButtons buttons, int clicks, int x, int y, int delta) {
+ this.buttons=buttons;
+ this.clicks=clicks;
+ this.delta=delta;
+ this.x=x;
+ this.y=y;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public MouseButtons Button {
+ get {
+ return this.buttons;
+ }
+ }
+
+ public int Clicks {
+ get {
+ return this.clicks;
+ }
+ }
+
+ public int Delta {
+ get {
+ return this.delta;
+ }
+ }
+
+ public int X {
+ get {
+ return this.x;
+ }
+ }
+
+ public int Y {
+ get {
+ return this.y;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MouseEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MouseEventHandler.cs
new file mode 100644
index 00000000000..9ba33c20f44
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MouseEventHandler.cs
@@ -0,0 +1,32 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void MouseEventHandler (object sender, MouseEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NativeWindow.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NativeWindow.cs
new file mode 100644
index 00000000000..6811b434778
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NativeWindow.cs
@@ -0,0 +1,167 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc.
+//
+// Authors:
+// Peter Dennis Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+#define ExternalExceptionHandler
+
+using System.Runtime.Remoting;
+using System.Runtime.InteropServices;
+using System.Runtime.CompilerServices;
+using System.Collections;
+using System.Diagnostics;
+
+namespace System.Windows.Forms
+{
+ public class NativeWindow : MarshalByRefObject {
+ internal IntPtr window_handle;
+ static internal Hashtable window_collection = new Hashtable();
+
+ #region Public Constructors
+ public NativeWindow() {
+ window_handle=IntPtr.Zero;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public IntPtr Handle {
+ get {
+ return window_handle;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Static Methods
+ public static NativeWindow FromHandle(IntPtr handle) {
+ NativeWindow window=new NativeWindow();
+
+ window.AssignHandle(handle);
+ return window;
+ }
+ #endregion // Public Static Methods
+
+ #region Private and Internal Methods
+ internal static NativeWindow FindWindow(IntPtr handle) {
+ return (NativeWindow)window_collection[handle];
+ }
+
+ internal void InvalidateHandle() {
+ window_collection.Remove(window_handle);
+ window_handle = IntPtr.Zero;
+ }
+ #endregion
+
+ #region Public Instance Methods
+ public void AssignHandle(IntPtr handle) {
+ if (window_handle != IntPtr.Zero) {
+ window_collection.Remove(window_handle);
+ }
+ window_handle=handle;
+ window_collection.Add(window_handle, this);
+ OnHandleChange();
+ }
+
+ public virtual void CreateHandle(CreateParams create_params) {
+ if (create_params != null) {
+ window_handle=XplatUI.CreateWindow(create_params);
+
+ if (window_handle != IntPtr.Zero) {
+ window_collection.Add(window_handle, this);
+ }
+ }
+ }
+
+ public void DefWndProc(ref Message m) {
+ m.Result=XplatUI.DefWndProc(ref m);
+ }
+
+ public virtual void DestroyHandle() {
+ if (window_handle != IntPtr.Zero) {
+ XplatUI.DestroyWindow(window_handle);
+ }
+ }
+
+ public virtual void ReleaseHandle() {
+ window_collection.Remove(window_handle);
+ window_handle=IntPtr.Zero;
+ OnHandleChange();
+ }
+
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ ~NativeWindow() {
+ }
+
+ protected virtual void OnHandleChange() {
+ }
+
+ protected virtual void OnThreadException(Exception e) {
+ Application.OnThreadException(e);
+ }
+
+ protected virtual void WndProc(ref Message m) {
+ DefWndProc(ref m);
+ }
+
+ internal static IntPtr WndProc(IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) {
+ Message m = new Message();
+ NativeWindow window = null;
+
+ #if !ExternalExceptionHandler
+ try {
+ #endif
+ window = (NativeWindow)window_collection[hWnd];
+ m.HWnd=hWnd;
+ m.Msg=(int)msg;
+ m.WParam=wParam;
+ m.LParam=lParam;
+ m.Result=IntPtr.Zero;
+
+ if (window != null) {
+ window.WndProc(ref m);
+ } else {
+ m.Result=XplatUI.DefWndProc(ref m);
+ }
+ #if !ExternalExceptionHandler
+ }
+
+ catch(System.Exception ex) {
+ if (window != null) {
+ window.OnThreadException(ex);
+ }
+ }
+ #endif
+
+ #if debug
+ Console.WriteLine("NativeWindow.cs: Message {0}, result {1}", msg, m.Result);
+ #endif
+
+ return m.Result;
+ }
+ #endregion // Protected Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NavigateEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NavigateEventArgs.cs
new file mode 100644
index 00000000000..77985888c8e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NavigateEventArgs.cs
@@ -0,0 +1,52 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public class NavigateEventArgs : EventArgs {
+ #region Local Variables
+ private bool forward;
+ #endregion // Local Variables
+
+ #region Public Constructors
+ public NavigateEventArgs(bool isForward) {
+ forward = isForward;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public bool Forward {
+ get {
+ return forward;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NavigateEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NavigateEventHandler.cs
new file mode 100644
index 00000000000..b68bf5f6d2c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NavigateEventHandler.cs
@@ -0,0 +1,32 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void NavigateEventHandler (object sender, NavigateEventArgs ne);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NodeLabelEditEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NodeLabelEditEventArgs.cs
new file mode 100644
index 00000000000..9f2461598d3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NodeLabelEditEventArgs.cs
@@ -0,0 +1,61 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+using System;
+
+namespace System.Windows.Forms {
+
+ public class NodeLabelEditEventArgs : EventArgs {
+
+ private TreeNode node;
+ private string label;
+ private bool cancel;
+
+ public NodeLabelEditEventArgs (TreeNode node)
+ {
+ this.node = node;
+ }
+
+ public NodeLabelEditEventArgs (TreeNode node, string label) : this (node)
+ {
+ this.label = label;
+ }
+
+ public bool CancelEdit {
+ get { return cancel; }
+ set { cancel = value; }
+ }
+
+ public TreeNode Node {
+ get { return node; }
+ }
+
+ public string Label {
+ get { return label; }
+ }
+ }
+
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NodeLabelEditEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NodeLabelEditEventHandler.cs
new file mode 100644
index 00000000000..be4f65b4669
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NodeLabelEditEventHandler.cs
@@ -0,0 +1,33 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+using System;
+
+namespace System.Windows.Forms {
+
+ public delegate void NodeLabelEditEventHandler (object sender, NodeLabelEditEventArgs e);
+
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NotifyIcon.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NotifyIcon.cs
new file mode 100644
index 00000000000..2634b452cc4
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NotifyIcon.cs
@@ -0,0 +1,379 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+// NOT COMPLETE
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+ [DefaultProperty("Text")]
+ [DefaultEvent("MouseDown")]
+ [Designer ("System.Windows.Forms.Design.NotifyIconDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ [ToolboxItemFilter("System.Windows.Forms", ToolboxItemFilterType.Allow)]
+ public sealed class NotifyIcon : System.ComponentModel.Component {
+ #region Local Variables
+ private ContextMenu context_menu;
+ private Icon icon;
+ private Bitmap icon_bitmap;
+ private string text;
+ private bool visible;
+ private NotifyIconWindow window;
+ private bool systray_active;
+ private ToolTip tooltip;
+ #endregion // Local Variables
+
+ #region NotifyIconWindow Class
+ internal class NotifyIconWindow : Control {
+ NotifyIcon owner;
+ Rectangle rect;
+
+ public NotifyIconWindow(NotifyIcon owner) {
+ this.owner = owner;
+ is_visible = false;
+ rect = new Rectangle(0, 0, 1, 1);
+
+ CreateControl();
+
+ Paint += new PaintEventHandler(HandlePaint);
+ SizeChanged += new EventHandler(HandleSizeChanged);
+
+ // Events that need to be sent to our parent
+ Click += new EventHandler(HandleClick);
+ DoubleClick += new EventHandler(HandleDoubleClick);
+ MouseDown +=new MouseEventHandler(HandleMouseDown);
+ MouseUp +=new MouseEventHandler(HandleMouseUp);
+ MouseMove +=new MouseEventHandler(HandleMouseMove);
+ ContextMenu = owner.context_menu;
+ }
+
+ protected override CreateParams CreateParams {
+ get {
+ CreateParams cp;
+
+ cp = base.CreateParams;
+
+ cp.Parent = IntPtr.Zero;
+ cp.Style = (int)WindowStyles.WS_POPUP;
+ cp.Style |= (int)WindowStyles.WS_CLIPSIBLINGS;
+
+ cp.ExStyle = (int)(WindowExStyles.WS_EX_TOOLWINDOW);
+
+ return cp;
+ }
+ }
+
+ protected override void WndProc(ref Message m) {
+ switch((Msg)m.Msg) {
+ case Msg.WM_NCPAINT: {
+ PaintEventArgs paint_event;
+
+ paint_event = XplatUI.PaintEventStart(Handle, false);
+ OnPaint(paint_event);
+ XplatUI.PaintEventEnd(Handle, false);
+ break;
+ }
+
+ case Msg.WM_USER: {
+ switch ((Msg)m.LParam.ToInt32()) {
+ case Msg.WM_LBUTTONDOWN: {
+ HandleMouseDown(this, new MouseEventArgs(MouseButtons.Left, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
+ return;
+ }
+
+ case Msg.WM_LBUTTONUP: {
+ HandleMouseUp(this, new MouseEventArgs(MouseButtons.Left, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
+ HandleClick(this, EventArgs.Empty);
+ return;
+ }
+
+ case Msg.WM_LBUTTONDBLCLK: {
+ HandleDoubleClick(this, EventArgs.Empty);
+ return;
+ }
+
+ case Msg.WM_MOUSEMOVE: {
+ HandleMouseMove(this, new MouseEventArgs(MouseButtons.None, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
+ return;
+ }
+
+ case Msg.WM_RBUTTONDOWN: {
+ HandleMouseDown(this, new MouseEventArgs(MouseButtons.Right, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
+ return;
+ }
+
+ case Msg.WM_RBUTTONUP: {
+ HandleMouseUp(this, new MouseEventArgs(MouseButtons.Right, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
+ HandleClick(this, EventArgs.Empty);
+ return;
+ }
+
+ case Msg.WM_RBUTTONDBLCLK: {
+ HandleDoubleClick(this, EventArgs.Empty);
+ return;
+ }
+ }
+ return;
+ }
+ }
+ base.WndProc (ref m);
+ }
+
+ internal void CalculateIconRect() {
+ if (owner != null && owner.icon != null) {
+ int x;
+ int y;
+ int size;
+
+ // Icons are always square. Try to center them in the window
+ if (ClientRectangle.Width < ClientRectangle.Height) {
+ size = ClientRectangle.Width;
+ } else {
+ size = ClientRectangle.Height;
+ }
+ x = this.ClientRectangle.Width / 2 - size / 2;
+ y = this.ClientRectangle.Height / 2 - size / 2;
+ rect = new Rectangle(x, y, size, size);
+
+ // Force our window to be square
+ if (Width != size) {
+ this.Width = size;
+ }
+
+ if (Height != size) {
+ this.Height = size;
+ }
+ }
+ }
+
+ private void HandlePaint(object sender, PaintEventArgs e) {
+ if (owner.icon != null) {
+ e.Graphics.FillRectangle(ThemeEngine.Current.ResPool.GetSolidBrush(SystemColors.Window), rect);
+ e.Graphics.DrawImage(owner.icon_bitmap, rect);
+
+ }
+ }
+
+ private void HandleSizeChanged(object sender, EventArgs e) {
+ CalculateIconRect();
+ }
+
+ private void HandleClick(object sender, EventArgs e) {
+ if (owner.Click != null) {
+ owner.Click(owner, e);
+ }
+ }
+
+ private void HandleDoubleClick(object sender, EventArgs e) {
+ if (owner.DoubleClick != null) {
+ owner.DoubleClick(owner, e);
+ }
+ }
+
+ private void HandleMouseDown(object sender, MouseEventArgs e) {
+ if (owner.MouseDown != null) {
+ owner.MouseDown(owner, e);
+ }
+ }
+
+ private void HandleMouseUp(object sender, MouseEventArgs e) {
+ if (owner.context_menu != null) {
+ owner.context_menu.Show(this, new Point(e.X, e.Y));
+ }
+
+ if (owner.MouseUp != null) {
+ owner.MouseUp(owner, e);
+ }
+ }
+
+ private void HandleMouseMove(object sender, MouseEventArgs e) {
+ if (owner.MouseMove != null) {
+ owner.MouseMove(owner, e);
+ }
+ }
+ }
+ #endregion // NotifyIconWindow Class
+
+ #region Public Constructors
+ public NotifyIcon() {
+ window = new NotifyIconWindow(this);
+ systray_active = false;
+ }
+
+ public NotifyIcon(System.ComponentModel.IContainer container) : this() {
+ }
+ #endregion // Public Constructors
+
+ #region Private Methods
+ private void ShowSystray(bool property_changed) {
+ if (property_changed) {
+ window.CalculateIconRect();
+ }
+
+ if (systray_active) {
+ if (property_changed) {
+ UpdateSystray();
+ }
+ return;
+ }
+
+ if (icon == null) {
+ return;
+ }
+
+ icon_bitmap = icon.ToBitmap();
+
+ systray_active = true;
+ XplatUI.SystrayAdd(window.Handle, text, icon, out tooltip);
+ }
+
+ private void HideSystray() {
+ if (!systray_active) {
+ return;
+ }
+
+ systray_active = false;
+ XplatUI.SystrayRemove(window.Handle, ref tooltip);
+ }
+
+ private void UpdateSystray() {
+ if (icon_bitmap != null) {
+ icon_bitmap.Dispose();
+ }
+
+ if (icon != null) {
+ icon_bitmap = icon.ToBitmap();
+ }
+
+ XplatUI.SystrayChange(window.Handle, text, icon, ref tooltip);
+ window.Invalidate();
+ }
+ #endregion // Private Methods
+
+ #region Public Instance Properties
+ [DefaultValue(null)]
+ public ContextMenu ContextMenu {
+ get {
+ return context_menu;
+ }
+
+ set {
+ if (context_menu != value) {
+ context_menu = value;
+ window.ContextMenu = value;
+ }
+ }
+ }
+
+ [Localizable(true)]
+ [DefaultValue(null)]
+ public Icon Icon {
+ get {
+ return icon;
+ }
+
+ set {
+ if (icon != value) {
+ icon = value;
+ ShowSystray(true);
+ }
+ }
+ }
+
+ [Localizable(true)]
+ public string Text {
+ get {
+ return text;
+ }
+
+ set {
+ if (text != value) {
+ if (value.Length >= 64) {
+ throw new ArgumentException("ToolTip length must be less than 64 characters long", "Text");
+ }
+ text = value;
+ if (text == string.Empty && icon == null) {
+ HideSystray();
+ } else {
+ ShowSystray(true);
+ }
+ }
+ }
+ }
+
+ [Localizable(true)]
+ [DefaultValue(false)]
+ public bool Visible {
+ get {
+ return visible;
+ }
+
+ set {
+ if (visible != value) {
+ visible = value;
+
+ // Let our control know, too
+ window.is_visible = value;
+
+ if (visible) {
+ ShowSystray(false);
+ } else {
+ HideSystray();
+ }
+ }
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Methods
+ protected override void Dispose(bool disposing) {
+ if (icon_bitmap != null) {
+ icon_bitmap.Dispose();
+ }
+
+ if (disposing)
+ icon = null;
+
+ base.Dispose (disposing);
+ }
+
+ #endregion // Protected Instance Methods
+
+ #region Events
+ [Category("Action")]
+ public event EventHandler Click;
+
+ [Category("Action")]
+ public event EventHandler DoubleClick;
+
+ public event MouseEventHandler MouseDown;
+ public event MouseEventHandler MouseMove;
+ public event MouseEventHandler MouseUp;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NumericUpDown.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NumericUpDown.cs
new file mode 100644
index 00000000000..6af7dfda164
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NumericUpDown.cs
@@ -0,0 +1,463 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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.
+//
+// Authors:
+// Jonathan Gilbert <logic@deltaq.org>
+//
+// Integration into MWF:
+// Peter Bartok <pbartok@novell.com>
+//
+
+// COMPLETE
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Windows.Forms;
+
+namespace System.Windows.Forms {
+ [DefaultEvent("ValueChanged")]
+ [DefaultProperty("Value")]
+ public class NumericUpDown : UpDownBase, ISupportInitialize {
+ #region Local Variables
+ private int suppress_validation;
+ private int decimal_places;
+ private bool hexadecimal;
+ private decimal increment;
+ private decimal maximum;
+ private decimal minimum;
+ private bool thousands_separator;
+ private decimal value;
+ #endregion // Local Variables
+
+ #region Public Constructors
+ public NumericUpDown() {
+ suppress_validation = 0;
+ decimal_places = 0;
+ hexadecimal = false;
+ increment = 1M;
+ maximum = 100.0M;
+ minimum = 0.0M;
+ thousands_separator = false;
+ }
+ #endregion // Public Constructors
+
+ #region Private Methods
+ void wide_number_multiply_by_10(int[] number) {
+ long carry = 0;
+
+ for (int i=0; i < number.Length; i++) {
+ long multiplication = unchecked(carry + 10 * (long)(uint)number[i]);
+
+ carry = multiplication >> 32;
+
+ number[i] = unchecked((int)multiplication);
+ }
+ }
+
+ void wide_number_multiply_by_16(int[] number) {
+ int carry = 0;
+
+ for (int i=0; i < number.Length; i++) {
+ int multiplication = unchecked(carry | (number[i] << 4));
+
+ carry = (number[i] >> 28) & 0x0F;
+
+ number[i] = multiplication;
+ }
+ }
+
+ void wide_number_divide_by_16(int[] number) {
+ int carry = 0;
+
+ for (int i=number.Length - 1; i >= 0; i--) {
+ int division = unchecked(carry | ((number[i] >> 4) & 0x0FFFFFFF));
+
+ carry = (number[i] << 28);
+
+ number[i] = division;
+ }
+ }
+
+ bool wide_number_less_than(int[] left, int[] right) {
+ unchecked {
+ for (int i=left.Length - 1; i >= 0; i--) {
+ uint leftvalue = (uint)left[i];
+ uint rightvalue = (uint)right[i];
+
+ if (leftvalue > rightvalue)
+ return false;
+ if (leftvalue < rightvalue)
+ return true;
+ }
+ }
+
+ // equal
+ return false;
+ }
+
+ void wide_number_subtract(int[] subtrahend, int[] minuend) {
+ long carry = 0;
+
+ unchecked {
+ for (int i=0; i < subtrahend.Length; i++) {
+ long subtrahendvalue = (uint)subtrahend[i];
+ long minuendvalue = (uint)minuend[i];
+
+ long result = subtrahendvalue - minuendvalue + carry;
+
+ if (result < 0) {
+ carry = -1;
+ result -= int.MinValue;
+ result -= int.MinValue;
+ }
+ else
+ carry = 0;
+
+ subtrahend[i] = unchecked((int)result);
+ }
+ }
+ }
+ #endregion // Private Methods
+
+ #region Public Instance Properties
+ [DefaultValue(0)]
+ public int DecimalPlaces {
+ get {
+ return decimal_places;
+ }
+
+ set {
+ decimal_places = value;
+ if (!UserEdit) {
+ UpdateEditText();
+ }
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool Hexadecimal {
+ get {
+ return hexadecimal;
+ }
+
+ set {
+ hexadecimal = value;
+ if (!UserEdit) {
+ UpdateEditText();
+ }
+ }
+ }
+
+ public decimal Increment {
+ get {
+ return increment;
+ }
+
+ set {
+ if (value < 0) {
+ throw new ArgumentOutOfRangeException("value", value, "NumericUpDown increment cannot be negative");
+ }
+
+ increment = value;
+ }
+ }
+
+ [RefreshProperties(RefreshProperties.All)]
+ public decimal Maximum {
+ get {
+ return maximum;
+ }
+
+ set {
+ maximum = value;
+
+ if (minimum > maximum)
+ minimum = maximum;
+
+ if (value > maximum)
+ value = maximum;
+ }
+ }
+
+ [RefreshProperties(RefreshProperties.All)]
+ public decimal Minimum {
+ get {
+ return minimum;
+ }
+
+ set {
+ minimum = value;
+
+ if (maximum < minimum)
+ maximum = minimum;
+
+ if (value < minimum)
+ value = minimum;
+ }
+ }
+
+ [Bindable(false)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override string Text {
+ get {
+ return base.txtView.Text;
+ }
+
+ set {
+ base.txtView.Text = value;
+ }
+ }
+
+ [DefaultValue(false)]
+ [Localizable(true)]
+ public bool ThousandsSeparator {
+ get {
+ return thousands_separator;
+ }
+
+ set {
+ thousands_separator = value;
+
+ if (!UserEdit) {
+ UpdateEditText();
+ }
+ }
+ }
+
+ [Bindable(true)]
+ public decimal Value {
+ get {
+ return value;
+ }
+
+ set {
+ if (suppress_validation <= 0) {
+ if ((value < minimum) || (value > maximum)) {
+ throw new ArgumentException("NumericUpDown.Value must be within the specified Minimum and Maximum values", "value");
+ }
+ }
+
+ this.value = value;
+ OnValueChanged(EventArgs.Empty);
+ UpdateEditText();
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public void BeginInit() {
+ suppress_validation++;
+ }
+
+ public override void DownButton() {
+ if (UserEdit) {
+ ParseEditText();
+ }
+
+ Value = Math.Max(minimum, unchecked(value - increment));
+ }
+
+ public void EndInit() {
+ suppress_validation--;
+ if (suppress_validation == 0)
+ UpdateEditText ();
+ }
+
+ public override string ToString() {
+ return string.Format("{0}: value {1} in range [{2}, {3}]", base.ToString(), value, minimum, maximum);
+ }
+
+ public override void UpButton() {
+ if (UserEdit)
+ ParseEditText();
+
+ Value = Math.Min(maximum, unchecked(value + increment));
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected override AccessibleObject CreateAccessibilityInstance() {
+ AccessibleObject acc;
+
+ acc = new AccessibleObject(this);
+ acc.role = AccessibleRole.SpinButton;
+
+ return acc;
+ }
+
+ protected override void OnTextBoxKeyPress(object source, KeyPressEventArgs e) {
+ if ((ModifierKeys & ~Keys.Shift) != Keys.None) {
+ return;
+ }
+
+ string acceptable = hexadecimal ? "\b-.,0123456789ABCDEF" : "\b-.,0123456789";
+
+ if (acceptable.IndexOf(e.KeyChar) < 0) {
+ // prevent the key from reaching the text box
+ e.Handled = true;
+ }
+
+ base.OnTextBoxKeyPress(source, e);
+ }
+
+ protected virtual void OnValueChanged(EventArgs e) {
+ if (ValueChanged != null) {
+ ValueChanged(this, e);
+ }
+ }
+
+ protected void ParseEditText() {
+ UserEdit = false;
+
+ try {
+ string user_edit_text = Text.Replace(",", "").Trim();
+
+ if (!hexadecimal) {
+ value = decimal.Parse(user_edit_text);
+ } else {
+ value = 0M;
+
+ for (int i=0; i < user_edit_text.Length; i++) {
+ int hex_digit = Convert.ToInt32(user_edit_text.Substring(i, 1), 16);
+
+ value = unchecked(value * 16M + (decimal)hex_digit);
+ }
+ }
+
+ if (value < minimum) {
+ value = minimum;
+ }
+
+ if (value > maximum) {
+ value = maximum;
+ }
+
+ OnValueChanged(EventArgs.Empty);
+ }
+ catch {}
+ }
+
+ protected override void UpdateEditText() {
+ if (suppress_validation > 0)
+ return;
+
+ if (UserEdit)
+ ParseEditText(); // validate user input
+
+ if (!hexadecimal) {
+ // "N" and "F" differ only in that "N" includes commas
+ // every 3 digits to the left of the decimal and "F"
+ // does not.
+
+ string format_string;
+
+ if (thousands_separator) {
+ format_string = "N";
+ } else {
+ format_string = "F";
+ }
+
+ format_string += decimal_places;
+
+ ChangingText = true;
+ Text = value.ToString(format_string);
+ }
+ else {
+ // Decimal.ToString doesn't know the "X" formatter, and
+ // converting it to an int is narrowing, so do it
+ // manually...
+
+ int[] bits = decimal.GetBits(value);
+
+ bool negative = (bits[3] < 0);
+
+ int scale = (bits[3] >> 16) & 0x1F;
+
+ bits[3] = 0;
+
+ int[] radix = new int[4];
+
+ radix[0] = 1;
+
+ for (int i=0; i < scale; i++)
+ wide_number_multiply_by_10(radix);
+
+ int num_chars = 0;
+
+ while (!wide_number_less_than(bits, radix)) {
+ num_chars++;
+ wide_number_multiply_by_16(radix);
+ }
+
+ if (num_chars == 0) {
+ ChangingText = true;
+ Text = "0";
+ return;
+ }
+
+ StringBuilder chars = new StringBuilder();
+
+ if (negative)
+ chars.Append('-');
+
+ for (int i=0; i < num_chars; i++) {
+ int digit = 0;
+
+ wide_number_divide_by_16(radix);
+
+ while (!wide_number_less_than(bits, radix)) { // greater than or equals
+ digit++;
+ wide_number_subtract(bits, radix);
+ }
+
+ if (digit < 10) {
+ chars.Append((char)('0' + digit));
+ } else {
+ chars.Append((char)('A' + digit - 10));
+ }
+ }
+
+ ChangingText = true;
+ Text = chars.ToString();
+ }
+ }
+
+ protected override void ValidateEditText() {
+ ParseEditText();
+ UpdateEditText();
+ }
+ #endregion // Protected Instance Methods
+
+ #region Events
+ public event EventHandler ValueChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler TextChanged;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OSFeature.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OSFeature.cs
new file mode 100644
index 00000000000..3de949aa8a1
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OSFeature.cs
@@ -0,0 +1,63 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public class OSFeature : FeatureSupport {
+ #region Local Variables
+ private static OSFeature feature = new OSFeature();
+ #endregion // Local Variables
+
+ #region Protected Constructors
+ protected OSFeature() {
+
+ }
+ #endregion // Protected Constructors
+
+ #region Public Static Fields
+ public static readonly object LayeredWindows;
+ public static readonly object Themes;
+ #endregion // Public Static Fields
+
+ #region Public Static Properties
+ public static OSFeature Feature {
+ get {
+ return feature;
+ }
+ }
+ #endregion // Public Static Properties
+
+ #region Public Instance Methods
+ public override Version GetVersionPresent(object feature) {
+ if (feature == Themes) {
+ return ThemeEngine.Current.Version;
+ }
+ return null;
+ }
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OSXStructs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OSXStructs.cs
new file mode 100644
index 00000000000..c26542a5efd
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OSXStructs.cs
@@ -0,0 +1,514 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software",, to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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.
+//
+// Authors:
+// Geoff Norton <gnorton@customerdna.com>
+//
+
+
+// NOT COMPLETE
+
+using System;
+using System.ComponentModel;
+using System.Collections;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+
+/// Mac OSX Version
+namespace System.Windows.Forms {
+
+ internal class OSXConstants {
+
+ #region EventClass constants
+ internal const uint kEventClassMouse = 1836021107;
+ internal const uint kEventClassKeyboard = 1801812322;
+ internal const uint kEventClassTextInput = 1952807028;
+ internal const uint kEventClassApplication = 1634758764;
+ internal const uint kEventClassAppleEvent = 1701867619;
+ internal const uint kEventClassMenu = 1835363957;
+ internal const uint kEventClassWindow = 2003398244;
+ internal const uint kEventClassControl = 1668183148;
+ internal const uint kEventClassCommand = 1668113523;
+ internal const uint kEventClassTablet = 1952607348;
+ internal const uint kEventClassVolume = 1987013664;
+ internal const uint kEventClassAppearance = 1634758765;
+ internal const uint kEventClassService = 1936028278;
+ internal const uint kEventClassToolbar = 1952604530;
+ internal const uint kEventClassToolbarItem = 1952606580;
+ internal const uint kEventClassAccessibility = 1633903461;
+ #endregion
+
+ #region kEventClassMouse constants
+ internal const uint kEventMouseDown = 1;
+ internal const uint kEventMouseUp = 2;
+ internal const uint kEventMouseMoved = 5;
+ internal const uint kEventMouseDragged = 6;
+ internal const uint kEventMouseEntered = 8;
+ internal const uint kEventMouseExited = 9;
+ internal const uint kEventMouseWheelMoved = 10;
+ #endregion
+
+ #region kEventClassKeyboard constants
+ internal const uint kEventRawKeyDown = 1;
+ internal const uint kEventRawKeyRepeat = 2;
+ internal const uint kEventRawKeyUp = 3;
+ internal const uint kEventRawKeyModifiersChanged = 4;
+ internal const uint kEventHotKeyPressed = 5;
+ internal const uint kEventHotKeyReleased = 6;
+ #endregion
+
+ #region kEventClassTextInput constants
+ // TODO: We dont use these yet; fill if needed
+ #endregion
+
+ #region kEventClassApplication constants
+ // TODO: We dont use these yet; fill if needed
+ #endregion
+
+ #region kEventClassAppleEvent constants
+ // TODO: We dont use these yet; fill if needed
+ #endregion
+
+ #region kEventClassMenu constants
+ // TODO: We dont use these yet; fill if needed
+ #endregion
+
+ #region kEventClassWindow constants
+ internal const uint kEventWindowUpdate = 1;
+ internal const uint kEventWindowDrawContent = 2;
+ internal const uint kEventWindowActivated = 5;
+ internal const uint kEventWindowDeactivated = 6;
+ internal const uint kEventWindowGetClickActivation = 7;
+ internal const uint kEventWindowShowing = 22;
+ internal const uint kEventWindowHiding = 23;
+ internal const uint kEventWindowShown = 24;
+ internal const uint kEventWindowHidden = 25;
+ internal const uint kEventWindowCollapsing = 86;
+ internal const uint kEventWindowExpanding = 87;
+ internal const uint kEventWindowZoomed = 76;
+ internal const uint kEventWindowBoundsChanging = 26;
+ internal const uint kEventWindowBoundsChanged = 27;
+ internal const uint kEventWindowResizeStarted = 28;
+ internal const uint kEventWindowResizeCompleted = 29;
+ internal const uint kEventWindowDragStarted = 30;
+ internal const uint kEventWindowDragCompleted = 31;
+ internal const uint kEventWindowTransitionStarted = 88;
+ internal const uint kEventWindowTransitionCompleted = 89;
+ internal const uint kEventWindowClickDragRgn = 32;
+ internal const uint kEventWindowClickResizeRgn = 33;
+ internal const uint kEventWindowClickCollapseRgn = 34;
+ internal const uint kEventWindowClickCloseRgn = 35;
+ internal const uint kEventWindowClickZoomRgn = 36;
+ internal const uint kEventWindowClickContentRgn = 37;
+ internal const uint kEventWindowClickProxyIconRgn = 38;
+ internal const uint kEventWindowClickToolbarButtonRgn = 41;
+ internal const uint kEventWindowClickStructureRgn = 42;
+ internal const uint kEventWindowCursorChange = 40;
+ internal const uint kEventWindowCollapse = 66;
+ internal const uint kEventWindowCollapsed = 67;
+ internal const uint kEventWindowCollapseAll = 68;
+ internal const uint kEventWindowExpand = 69;
+ internal const uint kEventWindowExpanded = 70;
+ internal const uint kEventWindowExpandAll = 71;
+ internal const uint kEventWindowClose = 72;
+ internal const uint kEventWindowClosed = 73;
+ internal const uint kEventWindowCloseAll = 74;
+ internal const uint kEventWindowZoom = 75;
+ internal const uint kEventWindowZoomAll = 77;
+ internal const uint kEventWindowContextualMenuSelect = 78;
+ internal const uint kEventWindowPathSelect = 79;
+ internal const uint kEventWindowGetIdealSize = 80;
+ internal const uint kEventWindowGetMinimumSize = 81;
+ internal const uint kEventWindowGetMaximumSize = 82;
+ internal const uint kEventWindowConstrain = 83;
+ internal const uint kEventWindowHandleContentClick = 85;
+ internal const uint kEventWindowGetDockTileMenu = 90;
+ internal const uint kEventWindowHandleActivate = 91;
+ internal const uint kEventWindowHandleDeactivate = 92;
+ internal const uint kEventWindowProxyBeginDrag = 128;
+ internal const uint kEventWindowProxyEndDrag = 129;
+ internal const uint kEventWindowToolbarSwitchMode = 150;
+ internal const uint kEventWindowFocusAcquired = 200;
+ internal const uint kEventWindowFocusRelinquish = 201;
+ internal const uint kEventWindowFocusContent = 202;
+ internal const uint kEventWindowFocusToolbar = 203;
+ internal const uint kEventWindowDrawerOpening = 220;
+ internal const uint kEventWindowDrawerOpened = 221;
+ internal const uint kEventWindowDrawerClosing = 222;
+ internal const uint kEventWindowDrawerClosed = 223;
+ internal const uint kEventWindowDrawFrame = 1000;
+ internal const uint kEventWindowDrawPart = 1001;
+ internal const uint kEventWindowGetRegion = 1002;
+ internal const uint kEventWindowHitTest = 1003;
+ internal const uint kEventWindowInit = 1004;
+ internal const uint kEventWindowDispose = 1005;
+ internal const uint kEventWindowDragHilite = 1006;
+ internal const uint kEventWindowModified = 1007;
+ internal const uint kEventWindowSetupProxyDragImage = 1008;
+ internal const uint kEventWindowStateChanged = 1009;
+ internal const uint kEventWindowMeasureTitle = 1010;
+ internal const uint kEventWindowDrawGrowBox = 1011;
+ internal const uint kEventWindowGetGrowImageRegion = 1012;
+ internal const uint kEventWindowPaint = 1013;
+ #endregion
+
+ #region kEventClassControl constants
+ internal const uint kEventControlInitialize = 1000;
+ internal const uint kEventControlDispose = 1001;
+ internal const uint kEventControlGetOptimalBounds = 1003;
+ internal const uint kEventControlDefInitialize = kEventControlInitialize;
+ internal const uint kEventControlDefDispose = kEventControlDispose;
+ internal const uint kEventControlHit = 1;
+ internal const uint kEventControlSimulateHit = 2;
+ internal const uint kEventControlHitTest = 3;
+ internal const uint kEventControlDraw = 4;
+ internal const uint kEventControlApplyBackground = 5;
+ internal const uint kEventControlApplyTextColor = 6;
+ internal const uint kEventControlSetFocusPart = 7;
+ internal const uint kEventControlGetFocusPart = 8;
+ internal const uint kEventControlActivate = 9;
+ internal const uint kEventControlDeactivate = 10;
+ internal const uint kEventControlSetCursor = 11;
+ internal const uint kEventControlContextualMenuClick = 12;
+ internal const uint kEventControlClick = 13;
+ internal const uint kEventControlGetNextFocusCandidate = 14;
+ internal const uint kEventControlGetAutoToggleValue = 15;
+ internal const uint kEventControlInterceptSubviewClick = 16;
+ internal const uint kEventControlGetClickActivation = 17;
+ internal const uint kEventControlDragEnter = 18;
+ internal const uint kEventControlDragWithin = 19;
+ internal const uint kEventControlDragLeave = 20;
+ internal const uint kEventControlDragReceive = 21;
+ internal const uint kEventControlInvalidateForSizeChange = 22;
+ internal const uint kEventControlTrackingAreaEntered = 23;
+ internal const uint kEventControlTrackingAreaExited = 24;
+ internal const uint kEventControlTrack = 51;
+ internal const uint kEventControlGetScrollToHereStartPoint = 52;
+ internal const uint kEventControlGetIndicatorDragConstraint = 53;
+ internal const uint kEventControlIndicatorMoved = 54;
+ internal const uint kEventControlGhostingFinished = 55;
+ internal const uint kEventControlGetActionProcPart = 56;
+ internal const uint kEventControlGetPartRegion = 101;
+ internal const uint kEventControlGetPartBounds = 102;
+ internal const uint kEventControlSetData = 103;
+ internal const uint kEventControlGetData = 104;
+ internal const uint kEventControlGetSizeConstraints= 105;
+ internal const uint kEventControlGetFrameMetrics = 106;
+ internal const uint kEventControlValueFieldChanged = 151;
+ internal const uint kEventControlAddedSubControl = 152;
+ internal const uint kEventControlRemovingSubControl = 153;
+ internal const uint kEventControlBoundsChanged = 154;
+ internal const uint kEventControlVisibilityChanged = 157;
+ internal const uint kEventControlTitleChanged = 158;
+ internal const uint kEventControlOwningWindowChanged = 159;
+ internal const uint kEventControlHiliteChanged = 160;
+ internal const uint kEventControlEnabledStateChanged = 161;
+ internal const uint kEventControlLayoutInfoChanged = 162;
+ internal const uint kEventControlArbitraryMessage = 201;
+ #endregion
+
+ #region kEventClassCommand constants
+ // TODO: We dont use these yet; fill if needed
+ #endregion
+
+ #region kEventClassTablet constants
+ // TODO: We dont use these yet; fill if needed
+ #endregion
+
+ #region kEventClassVolume constants
+ // TODO: We dont use these yet; fill if needed
+ #endregion
+
+ #region kEventClassAppearance constants
+ // TODO: We dont use these yet; fill if needed
+ #endregion
+
+ #region kEventClassService constants
+ // TODO: We dont use these yet; fill if needed
+ #endregion
+
+ #region kEventClassToolbar constants
+ // TODO: We dont use these yet; fill if needed
+ #endregion
+
+ #region kEventClassToolbarItem constants
+ // TODO: We dont use these yet; fill if needed
+ #endregion
+
+ #region kEventClassAccessibility constants
+ // TODO: We dont use these yet; fill if needed
+ #endregion
+
+ #region kEventParam constants
+
+ internal enum EventParamName : uint {
+ // source: /System/Library/Frameworks/Carbon.framework/Frameworks/HIToolbox.framework/Headers/CarbonEvents.h
+
+ /* Keyboard event parameter and types*/
+ kEventParamKeyMacCharCodes = 1801676914, // 'kchr'
+
+ /* Mouse event parameters and types*/
+ kEventParamMouseLocation = 1835822947, // 'mloc', /* typeHIPoint*/
+ kEventParamMouseButton = 1835168878, // 'mbtn' /* type MouseButton*/
+
+ /* Generic toolbox parameters and types */
+ kEventParamCGContextRef = 1668183160, // 'cntx' /* typeCGContextRef*/
+ kEventParamRgnHandle = 1919381096, // 'rgnh'
+
+ /* Control event parameters and types */
+ kEventParamControlPart = 1668313716, // 'cprt' /* typeControlPartCode*/
+
+ // source: /System/Library/Frameworks/Carbon.framework/Frameworks/HIToolbox.framework/Headers/CarbonEventsCore.h
+ /* Core Event Types */
+ kEventParamDirectObject = 757935405, // '----' /* type varies depending on event*/
+ }
+
+ internal enum EventParamType : uint {
+
+ typeControlPartCode = 1668313716, // 'cprt' /* ControlPartCode*/
+
+ typeQDPoint = 1363439732, // 'QDpt'
+
+ typeControlRef = 1668575852, // 'ctrl'
+
+ typeCGContextRef = 1668183160, // 'cntx' /* CGContextRef*/
+
+ typeMouseButton = 1835168878, // 'mbtn' /* EventMouseButton*/
+
+ typeQDRgnHandle = 1919381096, // 'rgnh'
+
+ typeChar = 1413830740, // 'TEXT'
+ }
+
+ #endregion
+ }
+
+ internal enum WindowClass : uint {
+ kAlertWindowClass = 1,
+ kMovableAlertWindowClass = 2,
+ kModalWindowClass = 3,
+ kMovableModalWindowClass = 4,
+ kFloatingWindowClass = 5,
+ kDocumentWindowClass = 6,
+ kUtilityWindowClass = 8,
+ kHelpWindowClass = 10,
+ kSheetWindowClass = 11,
+ kToolbarWindowClass = 12,
+ kPlainWindowClass = 13,
+ kOverlayWindowClass = 14,
+ kSheetAlertWindowClass = 15,
+ kAltPlainWindowClass = 16,
+ kDrawerWindowClass = 20,
+ kAllWindowClasses = 0xFFFFFFFF
+ }
+
+ internal enum WindowAttributes : uint {
+ kWindowNoAttributes = 0,
+ kWindowCloseBoxAttribute = (1u << 0),
+ kWindowHorizontalZoomAttribute = (1u << 1),
+ kWindowVerticalZoomAttribute = (1u << 2),
+ kWindowFullZoomAttribute = (kWindowVerticalZoomAttribute | kWindowHorizontalZoomAttribute),
+ kWindowCollapseBoxAttribute = (1u << 3),
+ kWindowResizableAttribute = (1u << 4),
+ kWindowSideTitlebarAttribute = (1u << 5),
+ kWindowToolbarButtonAttribute = (1u << 6),
+ kWindowMetalAttribute = (1u << 8),
+ kWindowNoUpdatesAttribute = (1u << 16),
+ kWindowNoActivatesAttribute = (1u << 17),
+ kWindowOpaqueForEventsAttribute = (1u << 18),
+ kWindowCompositingAttribute = (1u << 19),
+ kWindowNoShadowAttribute = (1u << 21),
+ kWindowHideOnSuspendAttribute = (1u << 24),
+ kWindowStandardHandlerAttribute = (1u << 25),
+ kWindowHideOnFullScreenAttribute = (1u << 26),
+ kWindowInWindowMenuAttribute = (1u << 27),
+ kWindowuiveResizeAttribute = (1u << 28),
+ kWindowIgnoreClicksAttribute = (1u << 29),
+ kWindowNoConstrainAttribute = (1u << 31),
+ kWindowStandardDocumentAttributes = (kWindowCloseBoxAttribute | kWindowFullZoomAttribute | kWindowCollapseBoxAttribute | kWindowResizableAttribute),
+ kWindowStandardFloatingAttributes = (kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute)
+ }
+ internal enum ThemeCursor : uint {
+ kThemeArrowCursor = 0,
+ kThemeCopyArrowCursor = 1,
+ kThemeAliasArrowCursor = 2,
+ kThemeContextualMenuArrowCursor = 3,
+ kThemeIBeamCursor = 4,
+ kThemeCrossCursor = 5,
+ kThemePlusCursor = 6,
+ kThemeWatchCursor = 7,
+ kThemeClosedHandCursor = 8,
+ kThemeOpenHandCursor = 9,
+ kThemePointingHandCursor = 10,
+ kThemeCountingUpHandCursor = 11,
+ kThemeCountingDownHandCursor = 12,
+ kThemeCountingUpAndDownHandCursor = 13,
+ kThemeSpinningCursor = 14,
+ kThemeResizeLeftCursor = 15,
+ kThemeResizeRightCursor = 16,
+ kThemeResizeLeftRightCursor = 17,
+ kThemeNotAllowedCursor = 18
+ }
+
+ internal struct CGSize {
+ public float width;
+ public float height;
+
+ public CGSize (int w, int h) {
+ this.width = (float)w;
+ this.height = (float)h;
+ }
+ }
+
+ internal struct QDPoint {
+ public short y;
+ public short x;
+
+ public QDPoint (short x, short y) {
+ this.x = x;
+ this.y = y;
+ }
+ }
+ internal struct CGPoint {
+ public float x;
+ public float y;
+
+ public CGPoint (int x, int y) {
+ this.x = (float)x;
+ this.y = (float)y;
+ }
+ }
+
+ internal struct HIRect {
+ public CGPoint origin;
+ public CGSize size;
+
+ public HIRect (int x, int y, int w, int h) {
+ this.origin = new CGPoint (x, y);
+ this.size = new CGSize (w, h);
+ }
+ }
+
+ internal struct HIViewID {
+ public uint type;
+ public uint id;
+
+ public HIViewID (uint type, uint id) {
+ this.type = type;
+ this.id = id;
+ }
+ }
+
+ internal struct EventTypeSpec
+ {
+ public UInt32 eventClass;
+ public UInt32 eventKind;
+
+ public EventTypeSpec (UInt32 eventClass, UInt32 eventKind)
+ {
+ this.eventClass = eventClass;
+ this.eventKind = eventKind;
+ }
+ }
+
+ internal struct CarbonEvent
+ {
+ public IntPtr hWnd;
+ public IntPtr evt;
+
+ public CarbonEvent (IntPtr hWnd, IntPtr evt)
+ {
+ this.hWnd = hWnd;
+ this.evt = evt;
+ }
+ }
+
+ internal struct RGBColor
+ {
+ public short red;
+ public short green;
+ public short blue;
+ }
+
+ internal struct Rect
+ {
+ public short top;
+ public short left;
+ public short bottom;
+ public short right;
+ }
+
+ internal struct OSXCaret
+ {
+ internal Timer Timer;
+ internal IntPtr Hwnd;
+ internal int X;
+ internal int Y;
+ internal int Width;
+ internal int Height;
+ internal int Visible;
+ internal bool On;
+ internal bool Paused;
+ }
+
+ internal struct OSXHover {
+ internal Timer Timer;
+ internal IntPtr Hwnd;
+ internal int X;
+ internal int Y;
+ internal int Interval;
+ }
+
+ internal struct CGAffineTransform
+ {
+ internal float a;
+ internal float b;
+ internal float c;
+ internal float d;
+ internal float tx;
+ internal float ty;
+ }
+
+ internal enum MouseTrackingResult : ushort
+ {
+ kMouseTrackingMouseDown = 1,
+ kMouseTrackingMouseUp = 2,
+ kMouseTrackingMouseExited = 3,
+ kMouseTrackingMouseEntered = 4,
+ kMouseTrackingMouseDragged = 5,
+ kMouseTrackingKeyModifiersChanged = 6,
+ kMouseTrackingUserCancelled = 7,
+ kMouseTrackingTimedOut = 8,
+ kMouseTrackingMouseMoved = 9
+ }
+
+ internal struct MouseTrackingRegionID
+ {
+ uint signature;
+ uint id;
+
+ public MouseTrackingRegionID (uint signature, uint id) {
+ this.signature = signature;
+ this.id = id;
+ }
+ }
+
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OpacityConverter.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OpacityConverter.cs
new file mode 100644
index 00000000000..b4acde1289c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OpacityConverter.cs
@@ -0,0 +1,74 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Globalization;
+using System.Text;
+
+namespace System.Windows.Forms {
+ public class OpacityConverter : TypeConverter {
+ #region Public Constructors
+ public OpacityConverter() {
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Methods
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
+ if (sourceType == typeof(string)) {
+ return true;
+ }
+ return false;
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+ if (value is string) {
+ string s;
+
+ s = (string)value;
+ if (s.EndsWith("%")) {
+ s = ((string)value).Substring(0, ((string)value).Length - 1);
+ }
+ return Double.Parse(s, NumberStyles.Any, culture) / 100;
+ }
+ return base.ConvertFrom (context, culture, value);
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) {
+ if (destinationType == typeof(string)) {
+ double v;
+
+ v = ((double)value) * 100;
+ return v.ToString() + "%";
+ }
+ return base.ConvertTo (context, culture, value, destinationType);
+ }
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OpenFileDialog.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OpenFileDialog.cs
new file mode 100644
index 00000000000..f2ed9190c78
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OpenFileDialog.cs
@@ -0,0 +1,122 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+//
+// Alexander Olk xenomorph2@onlinehome.de
+//
+
+// NOT COMPLETE - work in progress
+
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.IO;
+
+namespace System.Windows.Forms {
+ [Designer ("System.Windows.Forms.Design.OpenFileDialogDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ public sealed class OpenFileDialog : FileDialog {
+ #region Public Constructors
+ public OpenFileDialog ()
+ {
+ form.SuspendLayout ();
+
+ form.Text = "Open";
+
+ CheckFileExists = true;
+
+ OpenSaveButtonText = "Open";
+ SearchSaveLabel = "Search in:";
+ fileDialogType = FileDialogType.OpenFileDialog;
+
+ form.ResumeLayout (false);
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ [DefaultValue(true)]
+ public override bool CheckFileExists {
+ get {
+ return base.CheckFileExists;
+ }
+
+ set {
+ base.CheckFileExists = value;
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool Multiselect {
+ get {
+ return base.BMultiSelect;
+ }
+
+ set {
+ base.BMultiSelect = value;
+ }
+ }
+
+ [DefaultValue(false)]
+ public new bool ReadOnlyChecked {
+ get {
+ return base.ReadOnlyChecked;
+ }
+
+ set {
+ base.ReadOnlyChecked = value;
+ }
+ }
+
+ [DefaultValue(false)]
+ public new bool ShowReadOnly {
+ get {
+ return base.ShowReadOnly;
+ }
+
+ set {
+ base.ShowReadOnly = value;
+ }
+ }
+
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public Stream OpenFile ()
+ {
+ if (FileName == null)
+ throw new ArgumentNullException ("OpenFile", "FileName is null");
+
+ return new FileStream (FileName, FileMode.Open, FileAccess.Read);
+ }
+ #endregion // Public Instance Methods
+
+ public override void Reset ()
+ {
+ base.Reset ();
+ base.BMultiSelect = false;
+ base.CheckFileExists = true;
+ base.ReadOnlyChecked = false;
+ base.ShowReadOnly = false;
+ }
+ }
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OpenTreeNodeEnumerator.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OpenTreeNodeEnumerator.cs
new file mode 100644
index 00000000000..32a79e93027
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OpenTreeNodeEnumerator.cs
@@ -0,0 +1,113 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+using System;
+using System.Collections;
+
+namespace System.Windows.Forms {
+
+ internal class OpenTreeNodeEnumerator : IEnumerator {
+
+ private TreeNode start;
+ private TreeNode current;
+ private bool started;
+
+ public OpenTreeNodeEnumerator (TreeNode start)
+ {
+ this.start = start;
+ }
+
+ public object Current {
+ get { return current; }
+ }
+
+ public TreeNode CurrentNode {
+ get { return current; }
+ }
+
+ public bool MoveNext ()
+ {
+ if (!started) {
+ started = true;
+ current = start;
+ return (current != null);
+ }
+
+ if (current.IsExpanded && current.Nodes.Count > 0) {
+ current = current.Nodes [0];
+ return true;
+ }
+
+ TreeNode prev = current;
+ TreeNode next = current.NextNode;
+ while (next == null) {
+ // The next node is null so we need to move back up the tree until we hit the top
+ if (prev.parent == null)
+ return false;
+ prev = prev.parent;
+ if (prev.parent != null)
+ next = prev.NextNode;
+ }
+ current = next;
+ return true;
+ }
+
+ public bool MovePrevious ()
+ {
+ if (!started) {
+ started = true;
+ current = start;
+ return (current != null);
+ }
+
+ if (current.PrevNode != null) {
+ // Drill down as far as possible
+ TreeNode prev = current.PrevNode;
+ TreeNode walk = prev;
+ while (walk != null) {
+ prev = walk;
+ if (!walk.IsExpanded)
+ break;
+ walk = walk.LastNode;
+ }
+ current = prev;
+ return true;
+ }
+
+ if (current.parent == null ||
+ current.parent == current.TreeView.root_node)
+ return false;
+
+ current = current.parent;
+ return true;
+ }
+
+ public void Reset ()
+ {
+ started = false;
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Orientation.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Orientation.cs
new file mode 100644
index 00000000000..8213f05264e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Orientation.cs
@@ -0,0 +1,39 @@
+//
+// System.Windows.Forms.Orientation.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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
+//
+// Copyright (C) Novell Inc., 2004
+//
+//
+
+
+namespace System.Windows.Forms
+{
+
+ public enum Orientation
+ {
+ Horizontal = 0,
+ Vertical = 1,
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OwnerDrawPropertyBag.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OwnerDrawPropertyBag.cs
new file mode 100644
index 00000000000..8e17c902728
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OwnerDrawPropertyBag.cs
@@ -0,0 +1,84 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+using System;
+using System.Drawing;
+using System.Runtime.Serialization;
+
+namespace System.Windows.Forms {
+
+ [Serializable]
+ public class OwnerDrawPropertyBag : MarshalByRefObject, ISerializable {
+
+ private Color fore_color;
+ private Color back_color;
+ private Font font;
+
+ internal OwnerDrawPropertyBag ()
+ {
+ fore_color = back_color = Color.Empty;
+ }
+
+ private OwnerDrawPropertyBag (Color fore_color, Color back_color, Font font)
+ {
+ this.fore_color = fore_color;
+ this.back_color = back_color;
+ this.font = font;
+ }
+
+ public Color ForeColor {
+ get { return fore_color; }
+ set { fore_color = value; }
+ }
+
+ public Color BackColor {
+ get { return back_color; }
+ set { back_color = value; }
+ }
+
+ public Font Font {
+ get { return font; }
+ set { font = value; }
+ }
+
+ public virtual bool IsEmpty ()
+ {
+ return (font == null && fore_color.IsEmpty && back_color.IsEmpty);
+ }
+
+ void ISerializable.GetObjectData (SerializationInfo si, StreamingContext context)
+ {
+ si.AddValue ("BackColor", BackColor);
+ si.AddValue ("ForeColor", ForeColor);
+ si.AddValue ("Font", Font);
+ }
+
+ public static OwnerDrawPropertyBag Copy (OwnerDrawPropertyBag value)
+ {
+ return new OwnerDrawPropertyBag (value.ForeColor, value.BackColor, value.Font);
+ }
+ }
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Padding.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Padding.cs
new file mode 100644
index 00000000000..4e94562201c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Padding.cs
@@ -0,0 +1,149 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using System.Drawing;
+
+namespace System.Windows.Forms {
+
+ [Serializable]
+ public struct Padding {
+
+ private int bottom;
+ private int left;
+ private int right;
+ private int top;
+ private bool initialized;
+
+ public Padding (int all) {
+ left = all;
+ right = all;
+ top = all;
+ bottom = all;
+ initialized = true;
+ }
+
+ public Padding (int left, int top, int right, int bottom) {
+ this.left = left;
+ this.right = right;
+ this.top = top;
+ this.bottom = bottom;
+ initialized = true;
+ }
+
+ public static readonly Padding Empty = new Padding();
+
+ public int All {
+ get {
+ if (initialized && left == top && left == right && left == bottom) {
+ return left;
+ }
+ return -1;
+ }
+ set { Left = Top = Right = Bottom = value; }
+ }
+
+ public int Bottom {
+ get { return bottom; }
+ set { bottom = value; initialized = true; }
+ }
+
+ public int Horizontal {
+ get { return left + right; }
+ }
+
+ public int Left {
+ get { return left; }
+ set { left = value; initialized = true; }
+ }
+
+ public int Right {
+ get { return right; }
+ set { right = value; initialized = true; }
+ }
+
+ public Size Size {
+ get { return new Size(left + right, top + bottom); }
+ }
+
+ public int Top {
+ get { return top; }
+ set { top = value; initialized = true; }
+ }
+
+ public int Vertical {
+ get { return top + bottom; }
+ }
+
+ public static Padding Add (Padding p1, Padding p2) {
+ return p1 + p2;
+ }
+
+ public override bool Equals (object other) {
+ if (other is Padding) {
+ Padding other_aux = (Padding) other;
+ return this.left == other_aux.left &&
+ this.top == other_aux.top &&
+ this.right == other_aux.right &&
+ this.bottom == other_aux.bottom;
+ }
+ return false;
+ }
+
+ public override int GetHashCode () {
+ ////////////////////////////// COMPROBAR EN Windows /////////////////////////
+ return top ^ bottom ^ left ^ right;
+ }
+
+ public static Padding operator+ (Padding p1, Padding p2) {
+ return new Padding(p1.Left + p2.Left, p1.Top + p2.Top, p1.Right + p2.Right, p1.Bottom + p2.Bottom);
+ }
+
+ public static bool operator== (Padding p1, Padding p2) {
+ return p1.Equals(p2);
+ }
+
+ public static bool operator!= (Padding p1, Padding p2) {
+ return !(p1.Equals(p2));
+ }
+
+ public static Padding operator- (Padding p1, Padding p2) {
+ return new Padding(p1.Left - p2.Left, p1.Top - p2.Top, p1.Right - p2.Right, p1.Bottom - p2.Bottom);
+ }
+
+ public static Padding Subtract (Padding p1, Padding p2) {
+ return p1 - p2;
+ }
+
+ public override string ToString () {
+ return "{Left=" + Left + ",Top="+ Top + ",Right=" + Right + ",Bottom=" + Bottom + "}";
+ }
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PageSetupDialog.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PageSetupDialog.cs
new file mode 100755
index 00000000000..cf67ca593aa
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PageSetupDialog.cs
@@ -0,0 +1,377 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2006 Novell, Inc.
+//
+// Authors:
+// Jonathan Chambers (jonathan.chambers@ansys.com)
+//
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.ComponentModel.Design.Serialization;
+using System.Collections;
+using System.Diagnostics;
+using System.Drawing;
+using System.Drawing.Printing;
+using System.Reflection;
+
+namespace System.Windows.Forms {
+
+ public sealed class PageSetupDialog : CommonDialog {
+ #region Local variables
+ private PrintDocument document;
+ private PageSettings page_settings;
+ private PrinterSettings printer_settings;
+ private Margins min_margins;
+ private bool allow_margins;
+ private bool allow_orientation;
+ private bool allow_paper;
+ private bool allow_printer;
+ private bool show_help;
+ private bool show_network;
+
+ private GroupBox groupbox_paper;
+ private Label label_source;
+ private Label label_size;
+ private GroupBox groupbox_orientation;
+ private RadioButton radio_landscape;
+ private RadioButton radio_portrait;
+ private GroupBox groupbox_margin;
+ private Label label_left;
+ private Button button_ok;
+ private Button button_cancel;
+ private Button button_printer;
+ private Label label_top;
+ private Label label_right;
+ private Label label_bottom;
+ private TextBox textbox_left;
+ private TextBox textbox_top;
+ private TextBox textbox_right;
+ private TextBox textbox_bottom;
+ private ComboBox combobox_source;
+ private ComboBox combobox_size;
+ #endregion // Local variables
+
+ #region Public Constructors
+ public PageSetupDialog () {
+ InitializeComponent();
+ }
+ #endregion // Public Constructors
+
+
+ #region Public Instance Methods
+ public override void Reset () {
+ }
+ #endregion // Public Instance Methods
+
+ #region Public Instance Properties
+ public bool AllowMargins {
+ get { return allow_margins; }
+ set { allow_margins = value; }
+ }
+
+ public bool AllowOrientation {
+ get { return allow_orientation; }
+ set { allow_orientation = value; }
+ }
+
+ public bool AllowPaper {
+ get { return allow_paper; }
+ set { allow_paper = value; }
+ }
+
+ public bool AllowPrinter {
+ get { return allow_printer; }
+ set { allow_printer = value; }
+ }
+
+ public PrintDocument Document {
+ get { return document; }
+ set { document = value; }
+ }
+
+ public Margins MinMargins {
+ get { return min_margins; }
+ set { min_margins = value; }
+ }
+
+ public PageSettings PageSettings {
+ get { return page_settings; }
+ set { page_settings = value; }
+ }
+
+ public PrinterSettings PrinterSettings {
+ get { return printer_settings; }
+ set { printer_settings = value; }
+ }
+
+ public bool ShowHelp {
+ get { return show_help; }
+ set { show_help = value; }
+ }
+
+ public bool ShowNetwork {
+ get { return show_network; }
+ set { show_network = value; }
+ }
+
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Methods
+ protected override bool RunDialog (IntPtr hwnd) {
+ return true;
+ }
+ #endregion // Protected Instance Methods
+
+ #region Private Helper
+ private void InitializeComponent() {
+ this.groupbox_paper = new System.Windows.Forms.GroupBox();
+ this.combobox_source = new System.Windows.Forms.ComboBox();
+ this.combobox_size = new System.Windows.Forms.ComboBox();
+ this.label_source = new System.Windows.Forms.Label();
+ this.label_size = new System.Windows.Forms.Label();
+ this.groupbox_orientation = new System.Windows.Forms.GroupBox();
+ this.radio_landscape = new System.Windows.Forms.RadioButton();
+ this.radio_portrait = new System.Windows.Forms.RadioButton();
+ this.groupbox_margin = new System.Windows.Forms.GroupBox();
+ this.label_left = new System.Windows.Forms.Label();
+ this.button_ok = new System.Windows.Forms.Button();
+ this.button_cancel = new System.Windows.Forms.Button();
+ this.button_printer = new System.Windows.Forms.Button();
+ this.label_top = new System.Windows.Forms.Label();
+ this.label_right = new System.Windows.Forms.Label();
+ this.label_bottom = new System.Windows.Forms.Label();
+ this.textbox_left = new System.Windows.Forms.TextBox();
+ this.textbox_top = new System.Windows.Forms.TextBox();
+ this.textbox_right = new System.Windows.Forms.TextBox();
+ this.textbox_bottom = new System.Windows.Forms.TextBox();
+ this.groupbox_paper.SuspendLayout();
+ this.groupbox_orientation.SuspendLayout();
+ this.groupbox_margin.SuspendLayout();
+ form.SuspendLayout();
+ //
+ // groupbox_paper
+ //
+ this.groupbox_paper.Controls.Add(this.combobox_source);
+ this.groupbox_paper.Controls.Add(this.combobox_size);
+ this.groupbox_paper.Controls.Add(this.label_source);
+ this.groupbox_paper.Controls.Add(this.label_size);
+ this.groupbox_paper.Location = new System.Drawing.Point(12, 157);
+ this.groupbox_paper.Name = "groupbox_paper";
+ this.groupbox_paper.Size = new System.Drawing.Size(336, 90);
+ this.groupbox_paper.TabIndex = 0;
+ this.groupbox_paper.TabStop = false;
+ this.groupbox_paper.Text = "Paper";
+ //
+ // combobox_source
+ //
+ this.combobox_source.Location = new System.Drawing.Point(84, 54);
+ this.combobox_source.Name = "combobox_source";
+ this.combobox_source.Size = new System.Drawing.Size(240, 21);
+ this.combobox_source.TabIndex = 3;
+ this.combobox_source.Text = "Default";
+ //
+ // combobox_size
+ //
+ this.combobox_size.ItemHeight = 13;
+ this.combobox_size.Location = new System.Drawing.Point(84, 22);
+ this.combobox_size.Name = "combobox_size";
+ this.combobox_size.Size = new System.Drawing.Size(240, 21);
+ this.combobox_size.TabIndex = 2;
+ this.combobox_size.Text = "A4";
+ //
+ // label_source
+ //
+ this.label_source.Location = new System.Drawing.Point(10, 58);
+ this.label_source.Name = "label_source";
+ this.label_source.Size = new System.Drawing.Size(48, 16);
+ this.label_source.TabIndex = 1;
+ this.label_source.Text = "&Source:";
+ //
+ // label_size
+ //
+ this.label_size.Location = new System.Drawing.Point(10, 25);
+ this.label_size.Name = "label_size";
+ this.label_size.Size = new System.Drawing.Size(52, 16);
+ this.label_size.TabIndex = 0;
+ this.label_size.Text = "Si&ze:";
+ //
+ // groupbox_orientation
+ //
+ this.groupbox_orientation.Controls.Add(this.radio_landscape);
+ this.groupbox_orientation.Controls.Add(this.radio_portrait);
+ this.groupbox_orientation.Location = new System.Drawing.Point(12, 255);
+ this.groupbox_orientation.Name = "groupbox_orientation";
+ this.groupbox_orientation.Size = new System.Drawing.Size(96, 90);
+ this.groupbox_orientation.TabIndex = 1;
+ this.groupbox_orientation.TabStop = false;
+ this.groupbox_orientation.Text = "Orientation";
+ //
+ // radio_landscape
+ //
+ this.radio_landscape.Location = new System.Drawing.Point(13, 52);
+ this.radio_landscape.Name = "radio_landscape";
+ this.radio_landscape.Size = new System.Drawing.Size(80, 24);
+ this.radio_landscape.TabIndex = 7;
+ this.radio_landscape.Text = "L&andscape";
+ //
+ // radio_portrait
+ //
+ this.radio_portrait.Location = new System.Drawing.Point(13, 19);
+ this.radio_portrait.Name = "radio_portrait";
+ this.radio_portrait.Size = new System.Drawing.Size(72, 24);
+ this.radio_portrait.TabIndex = 6;
+ this.radio_portrait.Text = "P&ortrait";
+ //
+ // groupbox_margin
+ //
+ this.groupbox_margin.Controls.Add(this.textbox_bottom);
+ this.groupbox_margin.Controls.Add(this.textbox_right);
+ this.groupbox_margin.Controls.Add(this.textbox_top);
+ this.groupbox_margin.Controls.Add(this.textbox_left);
+ this.groupbox_margin.Controls.Add(this.label_bottom);
+ this.groupbox_margin.Controls.Add(this.label_right);
+ this.groupbox_margin.Controls.Add(this.label_top);
+ this.groupbox_margin.Controls.Add(this.label_left);
+ this.groupbox_margin.Location = new System.Drawing.Point(120, 255);
+ this.groupbox_margin.Name = "groupbox_margin";
+ this.groupbox_margin.Size = new System.Drawing.Size(228, 90);
+ this.groupbox_margin.TabIndex = 2;
+ this.groupbox_margin.TabStop = false;
+ this.groupbox_margin.Text = "Margins (inches)";
+ //
+ // label_left
+ //
+ this.label_left.Location = new System.Drawing.Point(10, 25);
+ this.label_left.Name = "label_left";
+ this.label_left.Size = new System.Drawing.Size(40, 23);
+ this.label_left.TabIndex = 0;
+ this.label_left.Text = "&Left:";
+ //
+ // button_ok
+ //
+ this.button_ok.Location = new System.Drawing.Point(120, 358);
+ this.button_ok.Name = "button_ok";
+ this.button_ok.Size = new System.Drawing.Size(72, 23);
+ this.button_ok.TabIndex = 3;
+ this.button_ok.Text = "OK";
+ //
+ // button_cancel
+ //
+ this.button_cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.button_cancel.Location = new System.Drawing.Point(198, 358);
+ this.button_cancel.Name = "button_cancel";
+ this.button_cancel.Size = new System.Drawing.Size(72, 23);
+ this.button_cancel.TabIndex = 4;
+ this.button_cancel.Text = "Cancel";
+ //
+ // button_printer
+ //
+ this.button_printer.Location = new System.Drawing.Point(276, 358);
+ this.button_printer.Name = "button_printer";
+ this.button_printer.Size = new System.Drawing.Size(72, 23);
+ this.button_printer.TabIndex = 5;
+ this.button_printer.Text = "&Printer...";
+ //
+ // label_top
+ //
+ this.label_top.Location = new System.Drawing.Point(10, 57);
+ this.label_top.Name = "label_top";
+ this.label_top.Size = new System.Drawing.Size(40, 23);
+ this.label_top.TabIndex = 1;
+ this.label_top.Text = "&Top:";
+ //
+ // label_right
+ //
+ this.label_right.Location = new System.Drawing.Point(124, 25);
+ this.label_right.Name = "label_right";
+ this.label_right.Size = new System.Drawing.Size(40, 23);
+ this.label_right.TabIndex = 2;
+ this.label_right.Text = "&Right:";
+ //
+ // label_bottom
+ //
+ this.label_bottom.Location = new System.Drawing.Point(124, 57);
+ this.label_bottom.Name = "label_bottom";
+ this.label_bottom.Size = new System.Drawing.Size(40, 23);
+ this.label_bottom.TabIndex = 3;
+ this.label_bottom.Text = "&Bottom:";
+ //
+ // textbox_left
+ //
+ this.textbox_left.Location = new System.Drawing.Point(57, 21);
+ this.textbox_left.Name = "textbox_left";
+ this.textbox_left.Size = new System.Drawing.Size(48, 20);
+ this.textbox_left.TabIndex = 4;
+ this.textbox_left.Text = "1";
+ //
+ // textbox_top
+ //
+ this.textbox_top.Location = new System.Drawing.Point(57, 54);
+ this.textbox_top.Name = "textbox_top";
+ this.textbox_top.Size = new System.Drawing.Size(48, 20);
+ this.textbox_top.TabIndex = 5;
+ this.textbox_top.Text = "1";
+ //
+ // textbox_right
+ //
+ this.textbox_right.Location = new System.Drawing.Point(171, 21);
+ this.textbox_right.Name = "textbox_right";
+ this.textbox_right.Size = new System.Drawing.Size(48, 20);
+ this.textbox_right.TabIndex = 6;
+ this.textbox_right.Text = "1";
+ //
+ // textbox_bottom
+ //
+ this.textbox_bottom.Location = new System.Drawing.Point(171, 54);
+ this.textbox_bottom.Name = "textbox_bottom";
+ this.textbox_bottom.Size = new System.Drawing.Size(48, 20);
+ this.textbox_bottom.TabIndex = 7;
+ this.textbox_bottom.Text = "1";
+ //
+ // Form3
+ //
+ form.AcceptButton = this.button_ok;
+ form.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ form.CancelButton = this.button_cancel;
+ form.ClientSize = new System.Drawing.Size(360, 390);
+ form.Controls.Add(this.button_printer);
+ form.Controls.Add(this.button_cancel);
+ form.Controls.Add(this.button_ok);
+ form.Controls.Add(this.groupbox_margin);
+ form.Controls.Add(this.groupbox_orientation);
+ form.Controls.Add(this.groupbox_paper);
+ form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ form.HelpButton = true;
+ form.MaximizeBox = false;
+ form.MinimizeBox = false;
+ form.Name = "Form3";
+ form.ShowInTaskbar = false;
+ form.Text = "Page Setup";
+ this.groupbox_paper.ResumeLayout(false);
+ this.groupbox_orientation.ResumeLayout(false);
+ this.groupbox_margin.ResumeLayout(false);
+ form.ResumeLayout(false);
+
+ }
+ #endregion // Private Helper
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PaintEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PaintEventArgs.cs
new file mode 100644
index 00000000000..2089a0fc046
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PaintEventArgs.cs
@@ -0,0 +1,86 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+using System.Drawing;
+
+namespace System.Windows.Forms {
+ public class PaintEventArgs : EventArgs, IDisposable {
+ private Graphics graphics;
+ private Rectangle clip_rectangle;
+
+ #region Public Constructors
+ public PaintEventArgs(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipRect) {
+ this.graphics=graphics;
+ this.clip_rectangle=clipRect;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public Rectangle ClipRectangle {
+ get {
+ return this.clip_rectangle;
+ }
+ }
+
+ public Graphics Graphics {
+ get {
+ return this.graphics;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public void Dispose() {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ #endregion // Public Instance Methods
+
+ // Returns the previous graphics
+ internal Graphics SetGraphics (Graphics g)
+ {
+ Graphics res = graphics;
+ graphics = g;
+
+ return res;
+ }
+
+ #region Protected Instance Methods
+ ~PaintEventArgs() {
+ Dispose(false);
+ }
+
+ protected virtual void Dispose(bool disposing) {
+ if (this.graphics!=null) {
+ graphics.Dispose();
+ this.graphics=null;
+ }
+ }
+ #endregion // Protected Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PaintEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PaintEventHandler.cs
new file mode 100644
index 00000000000..bba9a5dc5be
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PaintEventHandler.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public delegate void PaintEventHandler (object sender, PaintEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Panel.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Panel.cs
new file mode 100644
index 00000000000..092470403ac
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Panel.cs
@@ -0,0 +1,125 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+//
+
+// COMPLETE
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [DefaultProperty("BorderStyle")]
+ [DefaultEvent("Paint")]
+ [Designer ("System.Windows.Forms.Design.PanelDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ public class Panel : ScrollableControl {
+ #region Constructors & Destructors
+ public Panel () {
+ base.TabStop = false;
+ SetStyle(ControlStyles.Selectable, false);
+ SetStyle (ControlStyles.SupportsTransparentBackColor, true);
+ }
+ #endregion // Constructors & Destructors
+
+ #region Public Instance Properties
+ [DefaultValue(BorderStyle.None)]
+ [DispId(-504)]
+ public BorderStyle BorderStyle {
+ get { return InternalBorderStyle; }
+ set { InternalBorderStyle = value; }
+ }
+
+ [DefaultValue(false)]
+ public new bool TabStop {
+ get { return base.TabStop; }
+ set {
+ if (value == TabStop)
+ return;
+ base.TabStop = value;
+ }
+ }
+
+ [Bindable(false)]
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override string Text {
+ get { return base.Text; }
+ set {
+ if (value == Text)
+ return;
+ base.Text = value;
+ Refresh ();
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Properties
+ protected override CreateParams CreateParams {
+ get {
+ return base.CreateParams;
+ }
+ }
+
+ protected override Size DefaultSize {
+ get { return ThemeEngine.Current.PanelDefaultSize; }
+ }
+ #endregion // Proteced Instance Properties
+
+ #region Public Instance Methods
+ public override string ToString ()
+ {
+ return base.ToString () + ", BorderStyle: " + BorderStyle;
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected override void OnResize(EventArgs e) {
+ base.OnResize (e);
+ Invalidate(true);
+ }
+
+ #endregion // Protected Instance Methods
+
+ #region Events
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event KeyEventHandler KeyDown;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event KeyPressEventHandler KeyPress;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event KeyEventHandler KeyUp;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler TextChanged;
+ #endregion
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PictureBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PictureBox.cs
new file mode 100644
index 00000000000..b522592b4b8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PictureBox.cs
@@ -0,0 +1,427 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+//
+
+// COMPLETE
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [DefaultProperty("Image")]
+ [Designer("System.Windows.Forms.Design.PictureBoxDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ public class PictureBox : Control
+#if NET_2_0
+ , ISupportInitialize
+#endif
+ {
+ #region Fields
+ private Image image;
+ private PictureBoxSizeMode size_mode;
+ private bool redraw;
+ private bool recalc;
+ private bool allow_drop;
+ private Image initial_image;
+ private int no_update;
+ #endregion // Fields
+
+ private EventHandler frame_handler;
+
+ #region Public Constructor
+ public PictureBox ()
+ {
+ redraw = true;
+ recalc = true;
+ allow_drop = false;
+ SetStyle (ControlStyles.Selectable, false);
+ SetStyle (ControlStyles.SupportsTransparentBackColor, true);
+ }
+ #endregion // Public Constructor
+
+ #region Public Properties
+ [DefaultValue(PictureBoxSizeMode.Normal)]
+ [Localizable(true)]
+ [RefreshProperties(RefreshProperties.Repaint)]
+ public PictureBoxSizeMode SizeMode {
+ get { return size_mode; }
+ set {
+ if (size_mode == value)
+ return;
+ size_mode = value;
+ UpdateSize ();
+ if (no_update == 0) {
+ Redraw (true);
+ Invalidate ();
+ }
+
+ OnSizeModeChanged (EventArgs.Empty);
+ }
+ }
+
+ [DefaultValue(null)]
+ [Localizable(true)]
+ public Image Image {
+ get { return image; }
+ set {
+ StopAnimation ();
+
+ image = value;
+
+ UpdateSize ();
+ if (image != null && ImageAnimator.CanAnimate (image)) {
+ frame_handler = new EventHandler (OnAnimateImage);
+ ImageAnimator.Animate (image, frame_handler);
+ }
+ if (no_update == 0) {
+ Redraw (true);
+ Invalidate ();
+ }
+ }
+ }
+
+ [DefaultValue(BorderStyle.None)]
+ [DispId(-504)]
+ public BorderStyle BorderStyle {
+ get { return InternalBorderStyle; }
+ set { InternalBorderStyle = value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new bool CausesValidation {
+ get { return base.CausesValidation; }
+ set { base.CausesValidation = value; }
+ }
+
+#if NET_2_0
+ [DefaultValue(null)]
+ [Localizable(true)]
+ public Image InitialImage {
+ get { return initial_image; }
+ set { initial_image = value; }
+ }
+#endif
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new ImeMode ImeMode {
+ get { return base.ImeMode; }
+ set { base.ImeMode = value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override RightToLeft RightToLeft {
+ get { return base.RightToLeft; }
+ set { base.RightToLeft = value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new int TabIndex {
+ get { return base.TabIndex; }
+ set { base.TabIndex = value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new bool TabStop {
+ get { return base.TabStop; }
+ set { base.TabStop = value; }
+ }
+
+ [Bindable(false)]
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override string Text {
+ get { return base.Text; }
+ set { base.Text = value; }
+ }
+
+ protected override CreateParams CreateParams {
+ get {
+ return base.CreateParams;
+ }
+ }
+
+ protected override ImeMode DefaultImeMode {
+ get { return base.DefaultImeMode; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Font Font {
+ get { return base.Font; }
+ set { base.Font = value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Color ForeColor {
+ get { return base.ForeColor; }
+ set { base.ForeColor = value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool AllowDrop {
+ get {
+ return allow_drop;
+ }
+ set {
+ if (allow_drop != value) {
+ allow_drop = value;
+ }
+ }
+ }
+ #endregion // Public Properties
+
+ #region Protected Instance Methods
+ protected override Size DefaultSize {
+ get { return ThemeEngine.Current.PictureBoxDefaultSize; }
+ }
+
+ protected override void Dispose (bool disposing)
+ {
+ if (image != null) {
+ StopAnimation ();
+ image = null;
+ }
+ initial_image = null;
+
+ base.Dispose (disposing);
+ }
+
+ protected override void OnPaint (PaintEventArgs pe)
+ {
+ ThemeEngine.Current.DrawPictureBox (pe.Graphics, pe.ClipRectangle, this);
+ base.OnPaint (pe);
+ }
+
+ protected override void OnVisibleChanged (EventArgs e)
+ {
+ base.OnVisibleChanged (e);
+ Redraw (true);
+ }
+
+ protected virtual void OnSizeModeChanged (EventArgs e)
+ {
+ if (SizeModeChanged != null)
+ SizeModeChanged (this, e);
+ }
+
+ protected override void OnEnabledChanged (EventArgs e)
+ {
+ base.OnEnabledChanged (e);
+ }
+
+ protected override void OnParentChanged (EventArgs e)
+ {
+ base.OnParentChanged (e);
+ }
+
+ protected override void OnResize (EventArgs e)
+ {
+ base.OnResize (e);
+ redraw = true;
+
+ if (size_mode == PictureBoxSizeMode.CenterImage || size_mode == PictureBoxSizeMode.StretchImage)
+ Refresh ();
+ }
+
+ protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified)
+ {
+ if (size_mode == PictureBoxSizeMode.AutoSize && image != null) {
+ width = image.Width;
+ height = image.Height;
+ }
+ base.SetBoundsCore (x, y, width, height, specified);
+ }
+ #endregion // Protected Instance Methods
+
+#if NET_2_0
+ #region ISupportInitialize Interface
+ void System.ComponentModel.ISupportInitialize.BeginInit() {
+ no_update++;
+ }
+
+ void System.ComponentModel.ISupportInitialize.EndInit() {
+ if (no_update > 0) {
+ no_update--;
+ }
+ if (no_update == 0) {
+ Redraw (true);
+ Invalidate ();
+ }
+ }
+ #endregion // ISupportInitialize Interface
+#endif
+
+ #region Private Methods
+ private void StopAnimation ()
+ {
+ if (frame_handler == null)
+ return;
+ ImageAnimator.StopAnimate (image, frame_handler);
+ frame_handler = null;
+ }
+
+ private void UpdateSize ()
+ {
+ if (image == null)
+ return;
+ if (size_mode == PictureBoxSizeMode.AutoSize)
+ ClientSize = image.Size;
+ }
+
+ private void Redraw (bool recalc)
+ {
+ redraw = true;
+ this.recalc = recalc;
+ }
+
+ private void OnAnimateImage (object sender, EventArgs e)
+ {
+ // This is called from a worker thread,BeginInvoke is used
+ // so the control is updated from the correct thread
+ BeginInvoke (new EventHandler (UpdateAnimatedImage), new object [] { this, e });
+ }
+
+ private void UpdateAnimatedImage (object sender, EventArgs e)
+ {
+ ImageAnimator.UpdateFrames (image);
+ Redraw (false);
+ Refresh ();
+ }
+
+ #endregion // Private Methods
+
+ #region Public Instance Methods
+ public override string ToString() {
+ return base.ToString ();
+ }
+ #endregion
+
+ #region Events
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler CausesValidationChanged {
+ add { base.CausesValidationChanged += value; }
+ remove { base.CausesValidationChanged -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler Enter {
+ add { base.Enter += value; }
+ remove { base.Enter -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler FontChanged {
+ add { base.FontChanged += value; }
+ remove { base.FontChanged -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler ForeColorChanged {
+ add { base.ForeColorChanged += value; }
+ remove { base.ForeColorChanged -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler ImeModeChanged {
+ add { base.ImeModeChanged += value; }
+ remove { base.ImeModeChanged -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event KeyEventHandler KeyDown {
+ add { base.KeyDown += value; }
+ remove { base.KeyDown -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event KeyPressEventHandler KeyPress {
+ add { base.KeyPress += value; }
+ remove { base.KeyPress -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event KeyEventHandler KeyUp {
+ add { base.KeyUp += value; }
+ remove { base.KeyUp -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler Leave {
+ add { base.Leave += value; }
+ remove { base.Leave -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler RightToLeftChanged {
+ add { base.RightToLeftChanged += value; }
+ remove { base.RightToLeftChanged -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler TabIndexChanged {
+ add { base.TabIndexChanged += value; }
+ remove { base.TabIndexChanged -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler TabStopChanged {
+ add { base.TabStopChanged += value; }
+ remove { base.TabStopChanged -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler TextChanged {
+ add { base.TextChanged += value; }
+ remove { base.TextChanged -= value; }
+ }
+
+ public event EventHandler SizeModeChanged;
+ #endregion // Events
+
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PictureBoxSizeMode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PictureBoxSizeMode.cs
new file mode 100644
index 00000000000..d864f06a9f6
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PictureBoxSizeMode.cs
@@ -0,0 +1,37 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+//
+
+
+namespace System.Windows.Forms {
+
+ public enum PictureBoxSizeMode {
+ Normal,
+ StretchImage,
+ AutoSize,
+ CenterImage
+ }
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintControllerWithStatusDialog.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintControllerWithStatusDialog.cs
new file mode 100755
index 00000000000..d67bc5f358d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintControllerWithStatusDialog.cs
@@ -0,0 +1,129 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2006 Novell, Inc.
+//
+// Authors:
+// Jonathan Chambers (jonathan.chambers@ansys.com)
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Printing;
+
+namespace System.Windows.Forms
+{
+
+ public class PrintControllerWithStatusDialog : PrintController {
+ #region Local variables
+ PrintController underlyingController;
+ string dialogTitle;
+ PrintingDialog dialog;
+ int currentPage;
+ #endregion // Local variables
+
+ #region Public Constructors
+
+ [MonoTODO("Localize Dialog Title")]
+ public PrintControllerWithStatusDialog(PrintController underlyingController) {
+ this.underlyingController = underlyingController;
+ dialog = new PrintingDialog();
+ dialog.Text = "Printing";
+ }
+
+ public PrintControllerWithStatusDialog(PrintController underlyingController, string dialogTitle) : this(underlyingController) {
+ dialog.Text = dialogTitle;
+ }
+ #endregion // Public Constructors
+
+ #region Protected Instance Methods
+ public override void OnEndPage(PrintDocument document, PrintPageEventArgs e) {
+ if (dialog.DialogResult == DialogResult.Cancel) {
+ e.Cancel = true;
+ dialog.Close();
+ }
+ base.OnEndPage (document, e);
+ }
+
+ public override void OnEndPrint(PrintDocument document, PrintEventArgs e) {
+ if (dialog.Visible)
+ dialog.Close();
+ base.OnEndPrint (document, e);
+ }
+
+ public override Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e) {
+ if (dialog.DialogResult == DialogResult.Cancel) {
+ e.Cancel = true;
+ dialog.Close();
+ }
+ dialog.LabelText = string.Format("Page {0} of document", ++currentPage);
+ return base.OnStartPage (document, e);
+ }
+
+ public override void OnStartPrint(PrintDocument document, PrintEventArgs e) {
+ currentPage = 0;
+ dialog.Show();
+ base.OnStartPrint (document, e);
+ }
+
+ #endregion // Protected Instance Methods
+
+ #region Internal Class
+ public class PrintingDialog : Form {
+ private Button buttonCancel;
+ private Label label;
+
+ public PrintingDialog() {
+ buttonCancel = new System.Windows.Forms.Button();
+ label = new System.Windows.Forms.Label();
+ SuspendLayout();
+
+ buttonCancel.Location = new System.Drawing.Point(88, 88);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.TabIndex = 0;
+ buttonCancel.Text = "Cancel";
+
+ label.Location = new System.Drawing.Point(0, 40);
+ label.Name = "label";
+ label.Size = new System.Drawing.Size(257, 23);
+ label.TabIndex = 1;
+ label.Text = "Page 1 of document";
+ label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+
+ AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ CancelButton = buttonCancel;
+ ClientSize = new System.Drawing.Size(258, 124);
+ ControlBox = false;
+ Controls.Add(label);
+ Controls.Add(buttonCancel);
+ FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ Name = "PrintingDialog";
+ ShowInTaskbar = false;
+ Text = "Printing";
+ ResumeLayout(false);
+ }
+
+ public string LabelText {
+ get { return label.Text; }
+ set { label.Text = value; }
+ }
+ }
+ #endregion Internal Class
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintDialog.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintDialog.cs
new file mode 100644
index 00000000000..6b0c62269f5
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintDialog.cs
@@ -0,0 +1,168 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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.
+//
+// Authors:
+// Someone
+// Jonathan Chambers (jonathan.chambers@ansys.com)
+//
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.ComponentModel.Design.Serialization;
+using System.Collections;
+using System.Diagnostics;
+using System.Drawing;
+using System.Drawing.Printing;
+using System.Reflection;
+
+namespace System.Windows.Forms
+{
+ [DefaultProperty("Document")]
+ public sealed class PrintDialog : CommonDialog {
+ PrintDocument document;
+ PrinterSettings printer_settings;
+ bool allow_current_page;
+ bool allow_print_to_file;
+ bool allow_selection;
+ bool allow_some_pages;
+ bool show_help;
+ bool show_network;
+ bool print_to_file;
+
+ public PrintDialog ()
+ {
+ allow_print_to_file = true;
+ show_network = true;
+ }
+
+ public override void Reset ()
+ {
+ }
+
+#if NET_2_0
+ public bool AllowCurrentPage {
+ get {
+ return allow_current_page;
+ }
+
+ set {
+ allow_current_page = value;
+ }
+ }
+#endif
+
+ [DefaultValue(true)]
+ public bool AllowPrintToFile {
+ get {
+ return allow_print_to_file;
+ }
+
+ set {
+ allow_print_to_file = value;
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool AllowSelection {
+ get {
+ return allow_selection;
+ }
+
+ set {
+ allow_selection = value;
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool AllowSomePages {
+ get {
+ return allow_some_pages;
+ }
+
+ set {
+ allow_some_pages = value;
+ }
+ }
+
+ [DefaultValue(null)]
+ public PrintDocument Document {
+ get {
+ return document;
+ }
+
+ set {
+ document = value;
+ }
+ }
+
+ [Browsable(false)]
+ [DefaultValue(null)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public PrinterSettings PrinterSettings {
+ get {
+ return printer_settings;
+ }
+
+ set {
+ printer_settings = value;
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool PrintToFile {
+ get {
+ return print_to_file;
+ }
+
+ set {
+ print_to_file = value;
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool ShowNetwork {
+ get {
+ return show_network;
+ }
+
+ set {
+ show_network = value;
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool ShowHelp {
+ get {
+ return show_help;
+ }
+
+ set {
+ show_help = value;
+ }
+ }
+
+ protected override bool RunDialog (IntPtr hwnd)
+ {
+ return true;
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintPreviewControl.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintPreviewControl.cs
new file mode 100755
index 00000000000..b598daa7b13
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintPreviewControl.cs
@@ -0,0 +1,159 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2006 Novell, Inc.
+//
+// Authors:
+// Jonathan Chambers (jonathan.chambers@ansys.com)
+//
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.ComponentModel.Design.Serialization;
+using System.Collections;
+using System.Diagnostics;
+using System.Drawing;
+using System.Drawing.Printing;
+using System.Reflection;
+
+namespace System.Windows.Forms {
+ [DefaultPropertyAttribute("Document")]
+ public class PrintPreviewControl : Control {
+ #region Local variables
+ private bool autozoom;
+ private int columns;
+ private PrintDocument document;
+ private int rows;
+ private int startPage;
+ private bool useAntiAlias;
+ private double zoom;
+ #endregion // Local variables
+
+ #region Public Constructors
+ public PrintPreviewControl() {
+ autozoom = true;
+ columns = 1;
+ rows = 0;
+ startPage = 0;
+
+ this.BackColor = SystemColors.AppWorkspace;
+ }
+ #endregion // Public Constructors
+
+
+ #region Public Instance Properties
+ [DefaultValue(true)]
+ public bool AutoZoom {
+ get { return autozoom; }
+ set { autozoom = value; }
+ }
+ [DefaultValue(1)]
+ public int Columns {
+ get { return columns; }
+ set { columns = value; }
+ }
+ [DefaultValue(null)]
+ public PrintDocument Document {
+ get { return document; }
+ set { document = value; }
+ }
+ [DefaultValue(0)]
+ public int Rows {
+ get { return rows; }
+ set { rows = value; }
+ }
+ [DefaultValue(0)]
+ public int StartPage {
+ get { return startPage; }
+ set { startPage = value; }
+ }
+
+ public override string Text {
+ get {
+ return base.Text;
+ }
+ set {
+ base.Text = value;
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool UseAntiAlias {
+ get { return useAntiAlias; }
+ set { useAntiAlias = value; }
+ }
+ [DefaultValue(1.0)]
+ public double Zoom {
+ get { return zoom; }
+ set { zoom = value; }
+ }
+ #endregion // Public Instance Properties
+
+
+ #region Public Instance Methods
+ public void InvalidatePreview() {
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void ResetBackColor() {
+ base.ResetBackColor();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void ResetForeColor() {
+ base.ResetForeColor ();
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Properties
+ protected override CreateParams CreateParams {
+ get {
+ return base.CreateParams;
+ }
+ }
+
+ #endregion // Protected Instance Methods
+
+ #region Protected Instance Properties
+
+ protected override void OnPaint(PaintEventArgs e) {
+ base.OnPaint (e);
+ }
+
+ protected override void OnResize(EventArgs e) {
+ base.OnResize (e);
+ }
+
+ protected virtual void OnStartPageChanged(EventArgs e) {
+ if (StartPageChanged != null)
+ StartPageChanged(this, e);
+ }
+
+ protected override void WndProc(ref Message m) {
+ base.WndProc (ref m);
+ }
+
+ #endregion // Protected Instance Methods
+
+ public event EventHandler StartPageChanged;
+
+ public new event EventHandler TextChanged;
+ }
+} \ No newline at end of file
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintPreviewDialog.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintPreviewDialog.cs
new file mode 100755
index 00000000000..36830a92cd3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintPreviewDialog.cs
@@ -0,0 +1,77 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2006 Novell, Inc.
+//
+// Authors:
+// Jonathan Chambers (jonathan.chambers@ansys.com)
+//
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.ComponentModel.Design.Serialization;
+using System.Collections;
+using System.Diagnostics;
+using System.Drawing;
+using System.Drawing.Printing;
+using System.Reflection;
+
+namespace System.Windows.Forms {
+
+ public class PrintPreviewDialog : Form {
+ #region Local variables
+ PrintPreviewControl print_preview;
+ #endregion // Local variables
+
+ #region Public Constructors
+ public PrintPreviewDialog() {
+ print_preview = new PrintPreviewControl();
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public PrintDocument Document {
+ get { return print_preview.Document; }
+ set { print_preview.Document = value; }
+ }
+ public override ISite Site {
+ get {
+ return base.Site;
+ }
+ set {
+ base.Site = value;
+ }
+ }
+ public bool UseAntiAlias {
+ get { return print_preview.UseAntiAlias; }
+ set { print_preview.UseAntiAlias = value; }
+ }
+
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Properties
+ protected override void CreateHandle() {
+ base.CreateHandle ();
+ }
+
+
+ #endregion // Protected Instance Methods
+ }
+} \ No newline at end of file
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ProgressBar.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ProgressBar.cs
new file mode 100644
index 00000000000..0fa380b92eb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ProgressBar.cs
@@ -0,0 +1,414 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez jordi@ximian.com
+//
+//
+
+
+using System.Drawing;
+using System.ComponentModel;
+using System.Drawing.Imaging;
+using System.Drawing.Drawing2D;
+
+namespace System.Windows.Forms
+{
+ [DefaultProperty ("Value")]
+ public sealed class ProgressBar : Control
+ {
+ #region Local Variables
+ private int maximum;
+ private int minimum;
+ internal int step;
+ internal int val;
+ internal Rectangle client_area = new Rectangle ();
+ #endregion // Local Variables
+
+ #region events
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler BackColorChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler BackgroundImageChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler CausesValidationChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler DoubleClick;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler Enter;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler FontChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler ForeColorChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler ImeModeChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event KeyEventHandler KeyDown;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event KeyPressEventHandler KeyPress;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event KeyEventHandler KeyUp;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler Leave;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event PaintEventHandler Paint;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler RightToLeftChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler TabStopChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler TextChanged;
+ #endregion Events
+
+ #region Public Constructors
+ public ProgressBar()
+ {
+ maximum = 100;
+ minimum = 0;
+ step = 10;
+ val = 0;
+
+ base.Paint += new PaintEventHandler (OnPaintPB);
+ base.Resize += new EventHandler (OnResizeTB);
+
+ SetStyle (ControlStyles.UserPaint |
+ ControlStyles.Selectable |
+ ControlStyles.ResizeRedraw |
+ ControlStyles.Opaque, false);
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override bool AllowDrop
+ {
+ get { return base.AllowDrop; }
+ set {
+ base.AllowDrop = value;
+ }
+ }
+
+ // Setting this property in MS .Net 1.1 does not have any visual effect and it
+ // does not fire a BackColorChanged event
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override Color BackColor
+ {
+ get { return base.BackColor; }
+ set { base.BackColor = value; }
+ }
+
+ // Setting this property in MS .Net 1.1 does not have any visual effect and it
+ // does not fire a BackgroundImageChanged event
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override Image BackgroundImage
+ {
+ get { return base.BackgroundImage; }
+ set { base.BackgroundImage = value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new bool CausesValidation
+ {
+ get { return base.CausesValidation; }
+ set {
+ if (base.CausesValidation == value)
+ return;
+
+ base.CausesValidation = value;
+ if (CausesValidationChanged != null)
+ CausesValidationChanged (this, new EventArgs ());
+ }
+ }
+
+ protected override CreateParams CreateParams
+ {
+ get { return base.CreateParams; }
+ }
+
+ protected override ImeMode DefaultImeMode
+ {
+ get { return base.DefaultImeMode; }
+ }
+
+ protected override Size DefaultSize
+ {
+ get { return ThemeEngine.Current.ProgressBarDefaultSize; }
+ }
+
+ // Setting this property in MS .Net 1.1 does not have any visual effect and it
+ // does not fire a FontChanged event
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override Font Font
+ {
+ get { return base.Font; }
+ set { base.Font = value; }
+ }
+
+ // Setting this property in MS .Net 1.1 does not have any visual effect and it
+ // does not fire a FontChanged event
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override Color ForeColor
+ {
+ get { return base.ForeColor; }
+ set { base.ForeColor = value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new ImeMode ImeMode
+ {
+ get { return base.ImeMode; }
+ set
+ {
+ if (value == base.ImeMode)
+ return;
+
+ base.ImeMode = value;
+ if (ImeModeChanged != null)
+ ImeModeChanged (this, EventArgs.Empty);
+ }
+ }
+
+ [RefreshProperties(RefreshProperties.Repaint)]
+ [DefaultValue (100)]
+ public int Maximum
+ {
+ get {
+ return maximum;
+ }
+ set {
+ if (value < 0)
+ throw new ArgumentException(
+ string.Format("Value '{0}' must be greater than or equal to 0.", value ));
+
+ maximum = value;
+ Refresh ();
+ }
+ }
+
+ [RefreshProperties(RefreshProperties.Repaint)]
+ [DefaultValue (0)]
+ public int Minimum {
+ get {
+ return minimum;
+ }
+ set {
+ if (value < 0)
+ throw new ArgumentException(
+ string.Format("Value '{0}' must be greater than or equal to 0.", value ));
+
+ minimum = value;
+ Refresh ();
+ }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override RightToLeft RightToLeft
+ {
+ get { return base.RightToLeft; }
+ set {
+ if (base.RightToLeft == value)
+ return;
+
+ base.RightToLeft = value;
+
+ if (RightToLeftChanged != null)
+ RightToLeftChanged (this, EventArgs.Empty);
+
+ }
+ }
+
+ [DefaultValue (10)]
+ public int Step
+ {
+ get { return step; }
+ set {
+ step = value;
+ Refresh ();
+ }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new bool TabStop
+ {
+ get { return base.TabStop; }
+ set {
+ if (base.TabStop == value)
+ return;
+
+ base.TabStop = value;
+
+ if (TabStopChanged != null)
+ TabStopChanged (this, EventArgs.Empty);
+
+ }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Bindable(false)]
+ public override string Text
+ {
+ get { return base.Text; }
+ set
+ {
+ if (value == base.Text)
+ return;
+
+ if (TextChanged != null)
+ TextChanged (this, EventArgs.Empty);
+
+ Refresh ();
+ }
+ }
+
+ [Bindable(true)]
+ [DefaultValue (0)]
+ public int Value
+ {
+ get {
+ return val;
+ }
+ set {
+ if (value < Minimum || value > Maximum)
+ throw new ArgumentException(
+ string.Format("'{0}' is not a valid value for 'Value'. 'Value' should be between 'Minimum' and 'Maximum'", value));
+
+ val = value;
+ Refresh ();
+ }
+ }
+
+
+ #endregion // Protected Instance Properties
+
+ #region Public Instance Methods
+
+ protected override void CreateHandle ()
+ {
+ base.CreateHandle ();
+ }
+
+ public void Increment (int value)
+ {
+ int newValue = Value + value;
+
+ if (newValue < Minimum)
+ newValue = Minimum;
+
+ if (newValue > Maximum)
+ newValue = Maximum;
+
+ Value = newValue;
+ Refresh ();
+ }
+
+ protected override void OnHandleCreated (EventArgs e)
+ {
+ base.OnHandleCreated (e);
+
+ UpdateAreas ();
+ }
+
+ public void PerformStep ()
+ {
+ if (Value >= Maximum)
+ return;
+
+ Value = Value + Step;
+ Refresh ();
+ }
+
+ public override string ToString()
+ {
+ return string.Format ("{0}, Minimum: {1}, Maximum: {2}, Value: {3}",
+ GetType().FullName.ToString (),
+ Maximum.ToString (),
+ Minimum.ToString (),
+ Value.ToString () );
+ }
+
+ #endregion // Public Instance Methods
+
+ #region Private Instance Methods
+ private void UpdateAreas ()
+ {
+ client_area.X = client_area.Y = 2;
+ client_area.Width = Width - 4;
+ client_area.Height = Height - 4;
+ }
+
+ private void OnResizeTB (Object o, EventArgs e)
+ {
+ if (Width <= 0 || Height <= 0)
+ return;
+
+ UpdateAreas ();
+ }
+
+ private void OnPaintPB (Object o, PaintEventArgs pevent)
+ {
+ ThemeEngine.Current.DrawProgressBar (pevent.Graphics, pevent.ClipRectangle, this);
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ProgressBarStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ProgressBarStyle.cs
new file mode 100644
index 00000000000..83d55e46ac8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ProgressBarStyle.cs
@@ -0,0 +1,37 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2006 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Peter Dennis Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+#if NET_2_0
+namespace System.Windows.Forms {
+ public enum ProgressBarStyle {
+ Blocks = 0,
+ Continuous = 1,
+ Marquee = 2
+ }
+}
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertiesTab.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertiesTab.cs
new file mode 100755
index 00000000000..fe1c4505ae1
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertiesTab.cs
@@ -0,0 +1,77 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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.
+//
+// Authors:
+// Jonathan Chambers jonathan.chambers@ansys.com
+//
+
+
+// NOT COMPLETE
+
+using System;
+
+namespace System.Windows.Forms.PropertyGridInternal
+{
+ /// <summary>
+ /// Summary description for PropertiesTab.
+ /// </summary>
+ public class PropertiesTab : System.Windows.Forms.Design.PropertyTab
+ {
+ public PropertiesTab()
+ {
+ }
+
+ public override System.ComponentModel.PropertyDescriptorCollection GetProperties(object component, Attribute[] attributes)
+ {
+ return base.GetProperties(null, component, attributes);
+ }
+
+ public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object component, Attribute[] attributes)
+ {
+ return base.GetProperties (context, component, attributes);
+ }
+
+ public override System.ComponentModel.PropertyDescriptor GetDefaultProperty (object component)
+ {
+ return base.GetDefaultProperty(component);
+ }
+
+ public override string HelpKeyword
+ {
+ get
+ {
+ return base.HelpKeyword;
+ }
+ }
+
+
+ public override string TabName
+ {
+ get
+ {
+ return string.Empty;
+ }
+ }
+
+
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGrid.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGrid.cs
new file mode 100644
index 00000000000..0bc88346ab8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGrid.cs
@@ -0,0 +1,1068 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jonathan Chambers (jonathan.chambers@ansys.com)
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Drawing;
+using System.Drawing.Design;
+using System.ComponentModel;
+using System.Collections;
+using System.ComponentModel.Design;
+using System.Reflection;
+using System.Windows.Forms.Design;
+using System.Windows.Forms.PropertyGridInternal;
+
+namespace System.Windows.Forms
+{
+ [Designer("System.Windows.Forms.Design.PropertyGridDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ public class PropertyGrid : System.Windows.Forms.ContainerControl, ComponentModel.Com2Interop.IComPropertyBrowser
+ {
+ #region Private Members
+
+
+ private const int GRID_ITEM_HEIGHT = 16;
+ private const int GRID_LEFT_COLUMN_WIDTH = 16;
+ private const int DIVIDER_PADDING = 2;
+
+ private AttributeCollection browsable_attributes = null;
+ private bool can_show_commands = false;
+ private Color commands_back_color;
+ private Color commands_fore_color;
+ private bool commands_visible;
+ private bool commands_visible_if_available;
+ private Point context_menu_default_location;
+ private bool large_buttons;
+ private Color line_color;
+ private PropertySort property_sort;
+ private PropertyTabCollection property_tabs;
+ private GridItem selected_grid_item;
+ internal GridItemCollection grid_items;
+ private object[] selected_objects;
+ private PropertyTab selected_tab;
+
+ private ImageList toolbar_imagelist;
+ private ToolBarButton categorized_toolbarbutton;
+ private ToolBarButton alphabetic_toolbarbutton;
+ private ToolBarButton separator_toolbarbutton;
+ private ToolBarButton propertypages_toolbarbutton;
+
+ internal ToolBar toolbar;
+ internal PropertyGridView property_grid_view;
+ internal Splitter splitter;
+ internal Panel help_panel;
+ internal Label help_title_label;
+ internal Label help_description_label;
+ private ContextMenu context_menu;
+ private MenuItem reset_menuitem;
+ private MenuItem description_menuitem;
+ private object current_property_value;
+
+ #endregion // Private Members
+
+ #region Contructors
+ public PropertyGrid() {
+ selected_objects = new object[1];
+ grid_items = new GridItemCollection();
+ property_tabs = new PropertyTabCollection();
+
+ line_color = SystemColors.ScrollBar;
+ line_color = SystemColors.ScrollBar;
+ browsable_attributes = new AttributeCollection(new Attribute[] {});
+ commands_visible_if_available = false;
+ property_sort = PropertySort.Categorized;
+
+ property_grid_view = new PropertyGridView(this);
+ property_grid_view.Dock = DockStyle.Fill;
+
+ splitter = new Splitter();
+ splitter.Dock = DockStyle.Bottom;
+
+ help_panel = new Panel();
+ help_panel.Dock = DockStyle.Bottom;
+ //help_panel.DockPadding.All = 3;
+ help_panel.Height = 50;
+ help_panel.BackColor = SystemColors.Control;
+
+
+ help_title_label = new Label();
+ help_title_label.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ help_title_label.Name = "help_title_label";
+ help_title_label.Font = new Font(this.Font,FontStyle.Bold);
+ help_title_label.Text = "Title";
+ help_title_label.Location = new Point(2,2);
+ help_title_label.Height = 17;
+ help_title_label.Width = help_panel.Width - 4;
+
+
+ help_description_label = new Label();
+ help_description_label.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ help_description_label.Name = "help_description_label";
+ help_description_label.Font = this.Font;
+ help_description_label.Text = "The long important Description";
+ help_description_label.Location = new Point(2,help_title_label.Top+help_title_label.Height);
+ help_description_label.Width = help_panel.Width - 4;
+ help_description_label.Height = 17;
+
+ help_panel.Controls.Add(help_description_label);
+ help_panel.Controls.Add(help_title_label);
+ help_panel.Paint+=new PaintEventHandler(help_panel_Paint);
+
+ toolbar = new ToolBar();
+ toolbar.Dock = DockStyle.Top;
+ categorized_toolbarbutton = new ToolBarButton();
+ alphabetic_toolbarbutton = new ToolBarButton();
+ separator_toolbarbutton = new ToolBarButton();
+ propertypages_toolbarbutton = new ToolBarButton();
+ context_menu = new ContextMenu();
+
+ toolbar_imagelist = new ImageList();
+ toolbar_imagelist.ColorDepth = ColorDepth.Depth32Bit;
+ toolbar_imagelist.ImageSize = new System.Drawing.Size(16, 16);
+ toolbar_imagelist.TransparentColor = System.Drawing.Color.Transparent;
+ toolbar_imagelist.Images.Add( (Image)Locale.GetResource( "propertygrid_sort_category") );
+ toolbar_imagelist.Images.Add( (Image)Locale.GetResource( "propertygrid_sort_alphabetical") );
+ toolbar_imagelist.Images.Add( (Image)Locale.GetResource( "propertygrid_tab_properties") );
+
+ toolbar.Appearance = ToolBarAppearance.Flat;
+ toolbar.AutoSize = false;
+ toolbar.Buttons.AddRange(new ToolBarButton[] {
+ categorized_toolbarbutton,
+ alphabetic_toolbarbutton,
+ separator_toolbarbutton,
+ propertypages_toolbarbutton});
+
+ toolbar.ButtonSize = new System.Drawing.Size(20, 20);
+ toolbar.ImageList = toolbar_imagelist;
+ toolbar.Location = new System.Drawing.Point(0, 0);
+ toolbar.Name = "toolbar";
+ toolbar.ShowToolTips = true;
+ toolbar.Size = new System.Drawing.Size(256, 27);
+ toolbar.TabIndex = 0;
+ toolbar.ButtonClick += new ToolBarButtonClickEventHandler(toolbar_ButtonClick);
+
+ categorized_toolbarbutton.ImageIndex = 0;
+ categorized_toolbarbutton.Style = ToolBarButtonStyle.ToggleButton;
+ categorized_toolbarbutton.ToolTipText = (string)Locale.GetResource( "Categorized");
+
+ alphabetic_toolbarbutton.ImageIndex = 1;
+ alphabetic_toolbarbutton.Style = ToolBarButtonStyle.ToggleButton;
+ alphabetic_toolbarbutton.ToolTipText = (string)Locale.GetResource( "Alphabetic");
+
+ separator_toolbarbutton.Style = ToolBarButtonStyle.Separator;
+
+ propertypages_toolbarbutton.Enabled = false;
+ propertypages_toolbarbutton.ImageIndex = 2;
+ propertypages_toolbarbutton.Style = ToolBarButtonStyle.ToggleButton;
+ propertypages_toolbarbutton.ToolTipText = "Property Pages";
+
+
+ reset_menuitem = context_menu.MenuItems.Add("Reset");
+ reset_menuitem.Click +=new EventHandler(OnResetPropertyClick);
+ context_menu.MenuItems.Add("-");
+ description_menuitem = context_menu.MenuItems.Add("Description");
+ description_menuitem.Click += new EventHandler(OnDescriptionClick);
+ description_menuitem.Checked = this.HelpVisible;
+ this.ContextMenu = context_menu;
+ toolbar.ContextMenu = context_menu;
+
+ this.Controls.Add(property_grid_view);
+ this.Controls.Add(toolbar);
+ this.Controls.Add(splitter);
+ this.Controls.Add(help_panel);
+ this.Name = "PropertyGrid";
+ this.Size = new System.Drawing.Size(256, 400);
+
+ has_focus = false;
+
+ //TextChanged+=new System.EventHandler(RedrawEvent);
+ //ForeColorChanged+=new EventHandler(RedrawEvent);
+ //BackColorChanged+=new System.EventHandler(RedrawEvent);
+ //FontChanged+=new EventHandler(RedrawEvent);
+ //SizeChanged+=new EventHandler(RedrawEvent);
+
+ UpdateToolBarButtons();
+ }
+ #endregion // Constructors
+
+ #region Public Instance Properties
+
+ [BrowsableAttribute(false)]
+ [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
+ [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
+ public AttributeCollection BrowsableAttributes {
+ get {
+ return browsable_attributes;
+ }
+
+ set {
+ if (browsable_attributes == value) {
+ return;
+ }
+
+ browsable_attributes = value;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool AutoScroll {
+ get {
+ return base.AutoScroll;
+ }
+ set {
+ base.AutoScroll = value;
+ }
+ }
+
+ public override Color BackColor {
+ get {
+ return base.BackColor;
+ }
+
+ set {
+ if (base.BackColor == value) {
+ return;
+ }
+ base.BackColor = value;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Image BackgroundImage {
+ get {
+ return base.BackgroundImage;
+ }
+ set {
+ base.BackgroundImage = value;
+ }
+ }
+
+
+ [BrowsableAttribute(false)]
+ [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
+ public virtual bool CanShowCommands {
+ get {
+ return can_show_commands;
+ }
+ }
+
+ public Color CommandsBackColor {
+ get {
+ return commands_back_color;
+ }
+
+ set {
+ if (commands_back_color == value) {
+ return;
+ }
+ commands_back_color = value;
+ }
+ }
+
+ public Color CommandsForeColor {
+ get {
+ return commands_fore_color;
+ }
+
+ set {
+ if (commands_fore_color == value) {
+ return;
+ }
+ commands_fore_color = value;
+ }
+ }
+
+ [BrowsableAttribute(false)]
+ [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
+ public virtual bool CommandsVisible {
+ get {
+ return commands_visible;
+ }
+ }
+
+ [DefaultValue(false)]
+ public virtual bool CommandsVisibleIfAvailable {
+ get {
+ return commands_visible_if_available;
+ }
+
+ set {
+ if (commands_visible_if_available == value) {
+ return;
+ }
+ commands_visible_if_available = value;
+ }
+ }
+
+ [BrowsableAttribute(false)]
+ [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
+ [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
+ public Point ContextMenuDefaultLocation {
+ get {
+ return context_menu_default_location;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public new Control.ControlCollection Controls {
+ get {
+ return base.Controls;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Color ForeColor
+ {
+ get {
+ return base.ForeColor;
+ }
+ set {
+ base.ForeColor = value;
+ }
+ }
+
+ public Color HelpBackColor {
+ get
+ {
+ return help_panel.BackColor;
+ }
+ set
+ {
+ if (help_panel.BackColor == value) {
+ return;
+ }
+
+ help_panel.BackColor = value;
+ }
+ }
+
+ public Color HelpForeColor {
+ get {
+ return help_panel.ForeColor;
+ }
+
+ set {
+ if (help_panel.ForeColor == value) {
+ return;
+ }
+
+ help_panel.ForeColor = value;
+ }
+ }
+
+ [DefaultValue(true)]
+ [Localizable(true)]
+ public virtual bool HelpVisible {
+ get {
+ return help_panel.Visible;
+ }
+
+ set {
+ if (help_panel.Visible == value) {
+ return;
+ }
+
+ help_panel.Visible = value;
+ }
+ }
+
+ public bool LargeButtons {
+ get {
+ return large_buttons;
+ }
+
+ set {
+ if (large_buttons == value) {
+ return;
+ }
+
+ large_buttons = value;
+ }
+ }
+
+ public Color LineColor {
+ get {
+ return line_color;
+ }
+
+ set {
+ if (line_color == value) {
+ return;
+ }
+
+ line_color = value;
+ }
+ }
+
+ [DefaultValue(PropertySort.CategorizedAlphabetical)]
+ public PropertySort PropertySort {
+ get {
+ return property_sort;
+ }
+
+ set {
+ if (!Enum.IsDefined (typeof (PropertySort), value)) {
+ throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for PropertySort", value));
+ }
+
+ if (property_sort == value) {
+ return;
+ }
+
+ property_sort = value;
+
+ ReflectObjects();
+ Console.WriteLine("PropertySort");
+ property_grid_view.Refresh();
+
+ if (PropertySortChanged != null) {
+ PropertySortChanged(this, EventArgs.Empty);
+ }
+ }
+ }
+
+ [BrowsableAttribute(false)]
+ [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
+ [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
+ public PropertyTabCollection PropertyTabs {
+ get {
+ return property_tabs;
+ }
+ }
+
+ [BrowsableAttribute(false)]
+ [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
+ [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
+ public GridItem SelectedGridItem {
+ get {
+ return selected_grid_item;
+ }
+
+ set {
+ if (selected_grid_item == value) {
+ return;
+ }
+
+ GridItem oldItem = selected_grid_item;
+ selected_grid_item = value;
+ this.help_title_label.Text = selected_grid_item.Label;
+ if (selected_grid_item.PropertyDescriptor != null)
+ this.help_description_label.Text = selected_grid_item.PropertyDescriptor.Description;
+
+ Console.WriteLine("SelectedGridItem");
+ current_property_value = value.Value;
+ if (oldItem != null && oldItem.PropertyDescriptor != null)
+ oldItem.PropertyDescriptor.RemoveValueChanged(SelectedObject, new EventHandler(HandlePropertyValueChanged));
+ if (selected_grid_item.PropertyDescriptor != null)
+ selected_grid_item.PropertyDescriptor.AddValueChanged(SelectedObject, new EventHandler(HandlePropertyValueChanged));
+ OnSelectedGridItemChanged(new SelectedGridItemChangedEventArgs( oldItem, selected_grid_item));
+
+ }
+ }
+
+ private void HandlePropertyValueChanged(object sender, EventArgs e)
+ {
+ OnPropertyValueChanged(new PropertyValueChangedEventArgs( selected_grid_item, current_property_value));
+ }
+
+ [DefaultValue(null)]
+ [TypeConverter("System.Windows.Forms.PropertyGrid+SelectedObjectConverter, " + Consts.AssemblySystem_Windows_Forms)]
+ public object SelectedObject {
+ get {
+ return selected_objects[0];
+ }
+
+ set {
+ selected_objects = new object[] {value};
+ if (this.SelectedObject == null)
+ return;
+ PropertyTabAttribute[] propTabs = (PropertyTabAttribute[])this.SelectedObject.GetType().GetCustomAttributes(typeof(PropertyTabAttribute),true);
+ if (propTabs.Length > 0)
+ {
+ foreach (Type tabType in propTabs[0].TabClasses)
+ {
+ this.PropertyTabs.AddTabType(tabType);
+ }
+ }
+ RefreshTabs(PropertyTabScope.Component);
+ Console.WriteLine("SelectedObject");
+ ReflectObjects();
+ property_grid_view.Refresh();
+ }
+ }
+
+ [BrowsableAttribute(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public object[] SelectedObjects {
+ get {
+ return selected_objects;
+ }
+
+ set {
+ selected_objects = value;
+ ReflectObjects();
+ }
+ }
+
+ [BrowsableAttribute(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public PropertyTab SelectedTab {
+ get {
+ return selected_tab;
+ }
+ }
+
+ public override ISite Site {
+ get {
+ return base.Site;
+ }
+
+ set {
+ base.Site = value;
+ }
+ }
+
+
+ [DefaultValue(true)]
+ public virtual bool ToolbarVisible {
+ get {
+ return toolbar.Visible;
+ }
+
+ set {
+ if (toolbar.Visible == value) {
+ return;
+ }
+
+ toolbar.Visible = value;
+ }
+ }
+
+ public Color ViewBackColor {
+ get {
+ return property_grid_view.BackColor;
+ }
+
+ set {
+ if (property_grid_view.BackColor == value) {
+ return;
+ }
+
+ property_grid_view.BackColor = value;
+ }
+ }
+
+ public Color ViewForeColor {
+ get {
+ return property_grid_view.ForeColor;
+ }
+
+ set {
+ if (property_grid_view.ForeColor == value) {
+ return;
+ }
+
+ property_grid_view.ForeColor = value;
+ }
+ }
+
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Properties
+
+ protected override Size DefaultSize {
+ get {
+ return base.DefaultSize;
+ }
+ }
+
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
+ protected virtual Type DefaultTabType {
+ get {
+ return typeof(PropertiesTab);
+ }
+ }
+
+ protected bool DrawFlatToolbar {
+ get {
+ return (toolbar.Appearance == ToolBarAppearance.Flat);
+ }
+ set {
+ if (value)
+ toolbar.Appearance = ToolBarAppearance.Flat;
+ else
+ toolbar.Appearance = ToolBarAppearance.Normal;
+ }
+ }
+
+ protected override bool ShowFocusCues {
+ get {
+ return base.ShowFocusCues;
+ }
+ }
+
+ #endregion // Protected Instance Properties
+
+ #region Public Instance Methods
+
+ protected override void Dispose(bool val)
+ {
+ base.Dispose(val);
+ }
+
+ public void CollapseAllGridItems ()
+ {
+ foreach (GridItem item in this.grid_items)
+ {
+ item.Expanded = false;
+ }
+ }
+
+ public void ExpandAllGridItems ()
+ {
+ foreach (GridItem item in this.grid_items)
+ {
+ item.Expanded = true;
+ }
+ }
+
+ public override void Refresh ()
+ {
+ base.Refresh ();
+ }
+
+ public void RefreshTabs (PropertyTabScope tabScope)
+ {
+
+ /*button = new ToolBarButton("C");
+ button.ImageIndex = 0;
+ this.toolbar.Buttons.Add(button);
+ button = new ToolBarButton();
+ button.ImageIndex = 0;
+ button.Style = ToolBarButtonStyle.Separator;
+ this.toolbar.Buttons.Add(button);
+ foreach (PropertyTab tab in this.PropertyTabs)
+ {
+
+ int index = toolbar.ImageList.Images.Count;
+ this.toolbar.ImageList.Images.Add(tab.Bitmap);
+ button = new ToolBarButton();
+ button.ImageIndex = index;
+ this.toolbar.Buttons.Add(button);
+ }*/
+
+ }
+
+ public void ResetSelectedProperty()
+ {
+ if (selected_grid_item == null || selected_grid_item.PropertyDescriptor == null)
+ return;
+
+ selected_grid_item.PropertyDescriptor.ResetValue(SelectedObject);
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+
+ protected virtual PropertyTab CreatePropertyTab(Type tabType)
+ {
+ return (PropertyTab)Activator.CreateInstance(tabType);
+ }
+
+ [MonoTODO]
+ protected void OnComComponentNameChanged(ComponentRenameEventArgs e)
+ {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnFontChanged(EventArgs e)
+ {
+ base.OnFontChanged (e);
+ }
+
+ protected override void OnGotFocus(EventArgs e)
+ {
+ has_focus=true;
+ base.OnGotFocus(e);
+ }
+
+ protected override void OnHandleCreated (EventArgs e)
+ {
+ base.OnHandleCreated (e);
+ }
+
+ protected override void OnHandleDestroyed (EventArgs e)
+ {
+ base.OnHandleDestroyed (e);
+ }
+
+ protected override void OnMouseDown (MouseEventArgs e)
+ {
+ base.OnMouseDown (e);
+ }
+
+ protected override void OnMouseMove (MouseEventArgs e)
+ {
+ base.OnMouseMove (e);
+ }
+
+ protected override void OnMouseUp (MouseEventArgs e)
+ {
+ base.OnMouseUp (e);
+ }
+
+ [MonoTODO]
+ protected void OnNotifyPropertyValueUIItemsChanged(object sender, EventArgs e)
+ {
+ }
+
+ protected override void OnPaint (PaintEventArgs pevent)
+ {
+ base.OnPaint (pevent);
+ }
+
+ [MonoTODO]
+ protected virtual void OnPropertyTabChanged (PropertyTabChangedEventArgs e)
+ {
+ throw new NotImplementedException();
+ }
+
+ protected virtual void OnPropertyValueChanged (PropertyValueChangedEventArgs e)
+ {
+ if (PropertyValueChanged != null)
+ {
+ PropertyValueChanged(this, e);
+ current_property_value = selected_grid_item.Value;
+ }
+ }
+
+ protected override void OnResize (EventArgs e)
+ {
+ base.OnResize (e);
+ }
+
+ protected virtual void OnSelectedGridItemChanged (SelectedGridItemChangedEventArgs e)
+ {
+ if (SelectedGridItemChanged != null)
+ {
+ SelectedGridItemChanged(this, e);
+ }
+ }
+
+ protected virtual void OnSelectedObjectsChanged (EventArgs e)
+ {
+ if (SelectedObjectsChanged != null)
+ {
+ SelectedObjectsChanged(this, e);
+ }
+ }
+
+ protected override void OnSystemColorsChanged (EventArgs e)
+ {
+ base.OnSystemColorsChanged (e);
+ }
+
+ protected override void OnVisibleChanged (EventArgs e)
+ {
+ base.OnVisibleChanged (e);
+ }
+
+ protected override bool ProcessDialogKey (Keys keyData)
+ {
+ return base.ProcessDialogKey (keyData);
+ }
+
+ protected override void ScaleCore (float dx, float dy)
+ {
+ base.ScaleCore (dx, dy);
+ }
+
+ [MonoTODO]
+ protected void ShowEventsButton(bool value)
+ {
+ throw new NotImplementedException();
+ }
+
+ protected override void WndProc (ref Message m)
+ {
+ base.WndProc (ref m);
+ }
+ #endregion
+
+ #region Events
+ public event EventHandler PropertySortChanged;
+ public event PropertyTabChangedEventHandler PropertyTabChanged;
+ public event PropertyValueChangedEventHandler PropertyValueChanged;
+ public event SelectedGridItemChangedEventHandler SelectedGridItemChanged;
+ public event EventHandler SelectedObjectsChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler BackgroundImageChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler ForeColorChanged;
+ #endregion
+
+ #region Com2Interop.IComPropertyBrowser Interface
+ [MonoTODO]
+ bool ComponentModel.Com2Interop.IComPropertyBrowser.InPropertySet {
+ get {
+ throw new NotImplementedException();
+ }
+ }
+
+ [MonoTODO]
+ void ComponentModel.Com2Interop.IComPropertyBrowser.DropDownDone() {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ bool ComponentModel.Com2Interop.IComPropertyBrowser.EnsurePendingChangesCommitted() {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ void ComponentModel.Com2Interop.IComPropertyBrowser.HandleF4() {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ void ComponentModel.Com2Interop.IComPropertyBrowser.LoadState(Microsoft.Win32.RegistryKey key) {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ void ComponentModel.Com2Interop.IComPropertyBrowser.SaveState(Microsoft.Win32.RegistryKey key) {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ private event ComponentRenameEventHandler com_component_name_changed;
+ event ComponentRenameEventHandler ComponentModel.Com2Interop.IComPropertyBrowser.ComComponentNameChanged {
+ add { com_component_name_changed += value; }
+ remove { com_component_name_changed -= value; }
+ }
+ #endregion // Com2Interop.IComPropertyBrowser Interface
+
+ #region PropertyTabCollection Class
+ public class PropertyTabCollection : ICollection, IEnumerable
+ {
+ System.Collections.ArrayList list;
+ #region Private Constructors
+ internal PropertyTabCollection() {
+ list = new ArrayList();
+ }
+
+ #endregion // Private Constructors
+
+ public PropertyTab this[int index] {
+ get {
+ return (PropertyTab)list[index];
+ }
+ }
+
+ #region ICollection Members
+ bool ICollection.IsSynchronized
+ {
+ get {
+ return list.IsSynchronized;
+ }
+ }
+
+ void ICollection.CopyTo(Array array, int index)
+ {
+ list.CopyTo(array, index);
+ }
+
+ object ICollection.SyncRoot
+ {
+ get {
+ return list.SyncRoot;
+ }
+ }
+
+ #endregion
+
+ #region IEnumerable Members
+ public IEnumerator GetEnumerator() {
+ return list.GetEnumerator();
+ }
+
+ #endregion
+
+ #region ICollection Members
+ public int Count {
+ get {
+ return list.Count;
+ }
+ }
+
+ #endregion
+
+ #region Public Instance Methods
+ public void AddTabType(System.Type propertyTabType)
+ {
+ list.Add(Activator.CreateInstance(propertyTabType));
+ }
+ [MonoTODO]
+ public void AddTabType(System.Type propertyTabType,
+ System.ComponentModel.PropertyTabScope tabScope)
+ {
+ AddTabType(propertyTabType);
+ }
+ [MonoTODO]
+ public void Clear(System.ComponentModel.PropertyTabScope tabScope)
+ {
+ throw new NotImplementedException();
+ }
+ [MonoTODO]
+ public void RemoveTabType(System.Type propertyTabType)
+ {
+ throw new NotImplementedException();
+ }
+ #endregion
+ }
+ #endregion // PropertyTabCollection Class
+
+ #region Private Helper Methods
+
+ private void toolbar_ButtonClick (object sender, ToolBarButtonClickEventArgs e)
+ {
+ if (e.Button == alphabetic_toolbarbutton) {
+ this.PropertySort = PropertySort.Alphabetical;
+ }
+ else if (e.Button == categorized_toolbarbutton) {
+ this.PropertySort = PropertySort.Categorized;
+ }
+ UpdateToolBarButtons();
+ ReflectObjects();
+ Console.WriteLine("toolbar_ButtonClick");
+ property_grid_view.Refresh();
+ }
+
+ internal void UpdateToolBarButtons ()
+ {
+ if (PropertySort == PropertySort.Alphabetical) {
+ categorized_toolbarbutton.Pushed = false;
+ alphabetic_toolbarbutton.Pushed = true;
+ }
+ else if (PropertySort == PropertySort.Categorized) {
+ categorized_toolbarbutton.Pushed = true;
+ alphabetic_toolbarbutton.Pushed = false;
+ }
+ else {
+ categorized_toolbarbutton.Pushed = false;
+ alphabetic_toolbarbutton.Pushed = false;
+ }
+ }
+
+ private void OnResetPropertyClick (object sender, EventArgs e)
+ {
+ ResetSelectedProperty();
+ }
+
+ private void OnDescriptionClick (object sender, EventArgs e)
+ {
+ this.HelpVisible = !this.HelpVisible;
+ description_menuitem.Checked = this.HelpVisible;
+
+ }
+
+ private void ReflectObjects ()
+ {
+ grid_items = new GridItemCollection();
+ foreach (object obj in selected_objects) {
+ if (obj != null) {
+ PopulateGridItemCollection(obj,grid_items, true);
+ }
+ }
+ }
+
+ private void PopulateGridItemCollection (object obj, GridItemCollection grid_item_coll, bool recurse)
+ {
+ //TypeConverter converter = TypeDescriptor.GetConverter(obj);
+ PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(obj);
+ foreach (PropertyDescriptor property in properties) {
+ if (property.IsBrowsable) {
+ GridEntry grid_entry = new GridEntry(obj, property);
+ if (property_sort == PropertySort.Alphabetical || !recurse)
+ {
+ if (grid_item_coll[property.Name] == null)
+ grid_item_coll.Add(property.Name,grid_entry);
+ }
+ else if (property_sort == PropertySort.Categorized || property_sort == PropertySort.CategorizedAlphabetical)
+ {
+
+ string category = property.Category;
+ GridItem cat_item = grid_item_coll[category];
+ if (cat_item == null)
+ {
+ cat_item = new CategoryGridEntry(category);
+ grid_item_coll.Add(category,cat_item);
+ }
+ cat_item.GridItems.Add(property.Name,grid_entry);
+ }
+ if (recurse)
+ {
+ object propObj = property.GetValue(obj);
+ if (propObj != null)
+ PopulateGridItemCollection(propObj,grid_entry.GridItems, false);
+ }
+ }
+ }
+ }
+
+ #endregion // Private Helper Methods
+
+ private void help_panel_Paint(object sender, PaintEventArgs e)
+ {
+ e.Graphics.FillRectangle(ThemeEngine.Current.ResPool.GetSolidBrush(help_panel.BackColor), help_panel.ClientRectangle );
+ e.Graphics.DrawRectangle(SystemPens.ControlDark, 0,0,help_panel.Width-1,help_panel.Height-1 );
+ }
+#if NET_2_0
+
+ public bool UseCompatibleTextRendering {
+ get {
+ return use_compatible_text_rendering;
+ }
+
+ set {
+ use_compatible_text_rendering = value;
+ }
+ }
+#endif
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridCommands.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridCommands.cs
new file mode 100755
index 00000000000..b92886962ec
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridCommands.cs
@@ -0,0 +1,47 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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.
+//
+// Authors:
+// Jonathan Chambers jonathan.chambers@ansys.com
+//
+
+
+// COMPLETE
+
+using System;
+using System.ComponentModel.Design;
+
+namespace System.Windows.Forms.PropertyGridInternal
+{
+ public class PropertyGridCommands
+ {
+ public PropertyGridCommands()
+ {
+ }
+
+ public static readonly CommandID Commands;
+ public static readonly CommandID Description;
+ public static readonly CommandID Hide;
+ public static readonly CommandID Reset;
+ protected static readonly Guid wfcMenuCommand;
+ protected static readonly Guid wfcMenuGroup;
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridEntry.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridEntry.cs
new file mode 100644
index 00000000000..1e71c636626
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridEntry.cs
@@ -0,0 +1,18 @@
+using System;
+using System.ComponentModel;
+
+namespace System.Windows.Forms.PropertyGridInternal {
+ /// <summary>
+ /// Summary description for PropertyGridEntry.
+ /// </summary>
+ internal class PropertyGridEntry : GridEntry {
+ public PropertyGridEntry() {
+ //
+ // TODO: Add constructor logic here
+ //
+ }
+
+ public PropertyGridEntry(object obj, PropertyDescriptor prop_desc) : base(obj, prop_desc) {
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridTextBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridTextBox.cs
new file mode 100644
index 00000000000..be8110e959e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridTextBox.cs
@@ -0,0 +1,146 @@
+using System;
+
+namespace System.Windows.Forms.PropertyGridInternal {
+ internal class PropertyGridTextBox : System.Windows.Forms.UserControl {
+ private TextBox textbox;
+ private Button dialog_button;
+ private Button dropdown_button;
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.Container components = null;
+
+ public PropertyGridTextBox() {
+ // This call is required by the Windows.Forms Form Designer.
+ InitializeComponent();
+ dropdown_button.Paint+=new PaintEventHandler(dropdown_button_Paint);
+
+ // TODO: Add any initialization after the InitializeComponent call
+
+ }
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ protected override void Dispose( bool disposing ) {
+ if( disposing ) {
+ if(components != null) {
+ components.Dispose();
+ }
+ }
+ base.Dispose( disposing );
+ }
+
+ #region Component Designer generated code
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent() {
+ this.dialog_button = new System.Windows.Forms.Button();
+ this.dropdown_button = new System.Windows.Forms.Button();
+ this.textbox = new System.Windows.Forms.TextBox();
+ this.SuspendLayout();
+ //
+ // dialog_button
+ //
+ this.dialog_button.Dock = System.Windows.Forms.DockStyle.Right;
+ this.dialog_button.Location = new System.Drawing.Point(256, 0);
+ this.dialog_button.Name = "dialog_button";
+ this.dialog_button.Size = new System.Drawing.Size(16, 16);
+ this.dialog_button.TabIndex = 1;
+ this.dialog_button.Text = "D";
+ this.dialog_button.Visible = false;
+ this.dialog_button.Click += new System.EventHandler(this.dialog_button_Click);
+ //
+ // dropdown_button
+ //
+ this.dropdown_button.Dock = System.Windows.Forms.DockStyle.Right;
+ this.dropdown_button.Location = new System.Drawing.Point(240, 0);
+ this.dropdown_button.Name = "dropdown_button";
+ this.dropdown_button.Size = new System.Drawing.Size(16, 16);
+ this.dropdown_button.TabIndex = 2;
+ this.dropdown_button.Visible = false;
+ this.dropdown_button.Click += new System.EventHandler(this.dropdown_button_Click);
+ //
+ // textbox
+ //
+ this.textbox.AutoSize = false;
+ this.textbox.BackColor = System.Drawing.SystemColors.Window;
+ this.textbox.BorderStyle = System.Windows.Forms.BorderStyle.None;
+ this.textbox.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.textbox.Location = new System.Drawing.Point(0, 0);
+ this.textbox.Name = "textbox";
+ this.textbox.Size = new System.Drawing.Size(240, 16);
+ this.textbox.TabIndex = 3;
+ this.textbox.Text = "textbox";
+ //
+ // PropertyGridTextBox
+ //
+ this.Controls.Add(this.textbox);
+ this.Controls.Add(this.dropdown_button);
+ this.Controls.Add(this.dialog_button);
+ this.Name = "PropertyGridTextBox";
+ this.Size = new System.Drawing.Size(272, 16);
+ this.ResumeLayout(false);
+
+ }
+ #endregion
+
+ private void dropdown_button_Click(object sender, System.EventArgs e) {
+ if (DropDownButtonClicked != null)
+ DropDownButtonClicked(this, EventArgs.Empty);
+ }
+
+ private void dialog_button_Click(object sender, System.EventArgs e) {
+ if (DialogButtonClicked != null)
+ DialogButtonClicked(this, EventArgs.Empty);
+ }
+
+
+ public event EventHandler DropDownButtonClicked;
+ public event EventHandler DialogButtonClicked;
+
+ public bool DialogButtonVisible {
+ get{
+ return dialog_button.Visible;
+ }
+ set {
+ dialog_button.Visible = value;
+ dropdown_button.Redraw();
+ }
+ }
+ public bool DropDownButtonVisible {
+ get{
+ return dropdown_button.Visible;
+ }
+ set {
+ dropdown_button.Visible = value;
+ dropdown_button.Redraw();
+ }
+ }
+
+ public bool ReadOnly {
+ get {
+ return textbox.ReadOnly;
+ }
+ set {
+ textbox.ReadOnly = value;
+ }
+ }
+
+ public new string Text {
+ get {
+ return textbox.Text;
+ }
+ set {
+ textbox.Text = value;
+ }
+ }
+
+ private void dropdown_button_Paint(object sender, PaintEventArgs e)
+ {
+ ThemeEngine.Current.CPDrawComboButton(e.Graphics, dropdown_button.ClientRectangle, dropdown_button.ButtonState);
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs
new file mode 100644
index 00000000000..eeb37b33fb8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs
@@ -0,0 +1,758 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Jonathan Chambers (jonathan.chambers@ansys.com)
+//
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Collections;
+using System.Drawing;
+using System.Drawing.Design;
+using System.ComponentModel;
+using System.Windows.Forms.Design;
+
+namespace System.Windows.Forms.PropertyGridInternal
+{
+ internal class PropertyGridView : System.Windows.Forms.ScrollableControl, IWindowsFormsEditorService
+ {
+
+ #region Private Members
+ private const int V_INDENT = 16;
+ private const int ROW_HEIGHT = 16;
+ private const int RESIZE_WIDTH = 3;
+ private const int BUTTON_WIDTH = 25;
+ private PropertyGridTextBox grid_textbox;
+ private PropertyGrid property_grid;
+ private bool resizing_grid;
+ private int splitter_location;
+ private int open_grid_item_count = -1;
+ private int skipped_grid_items;
+ private PropertyGridDropDown dropdown_form;
+ private bool dropdown_form_showing;
+ private Form dialog_form;
+ private VScrollBar vbar;
+ private StringFormat stringFormat;
+ #endregion
+
+ #region Contructors
+ public PropertyGridView (PropertyGrid propertyGrid)
+ {
+ property_grid = propertyGrid;
+
+ property_grid.SelectedGridItemChanged+=new SelectedGridItemChangedEventHandler(HandleSelectedGridItemChanged);
+ property_grid.PropertyValueChanged+=new PropertyValueChangedEventHandler(HandlePropertyValueChanged);
+
+ stringFormat = new StringFormat();
+ stringFormat.FormatFlags = StringFormatFlags.NoWrap;
+ stringFormat.Trimming = StringTrimming.None;
+
+ this.BackColor = Color.Beige;
+ grid_textbox = new PropertyGridTextBox();
+ grid_textbox.DropDownButtonClicked +=new EventHandler(DropDownButtonClicked);
+ grid_textbox.DialogButtonClicked +=new EventHandler(DialogButtonClicked);
+
+
+ dropdown_form = new PropertyGridDropDown();
+ dropdown_form.FormBorderStyle = FormBorderStyle.None;
+ dropdown_form.ShowInTaskbar = false;
+
+ dialog_form = new Form();
+ //dialog_form.FormBorderStyle = FormBorderStyle.None;
+
+
+
+ grid_textbox.Visible = false;
+ grid_textbox.Font = this.Font;//new Font(this.Font,FontStyle.Bold);
+ grid_textbox.BackColor = this.BackColor;
+ // Not working at all, used to??
+ grid_textbox.Validating += new CancelEventHandler(TextBoxValidating);
+ this.Controls.Add(grid_textbox);
+
+ vbar = new VScrollBar();
+ vbar.Visible = false;
+ vbar.Scroll+=new ScrollEventHandler(HandleScroll);
+ vbar.Dock = DockStyle.Right;
+ this.Controls.Add(vbar);
+
+ splitter_location = 65;
+ resizing_grid = false;
+
+ ForeColorChanged+=new EventHandler(RedrawEvent);
+ BackColorChanged+=new System.EventHandler(RedrawEvent);
+ FontChanged+=new EventHandler(RedrawEvent);
+ SizeChanged+=new EventHandler(RedrawEvent);
+
+ SetStyle(ControlStyles.DoubleBuffer, true);
+ SetStyle(ControlStyles.UserPaint, true);
+ SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle(ControlStyles.ResizeRedraw, false);
+ SetStyle(ControlStyles.StandardClick | ControlStyles.StandardDoubleClick, false);
+ }
+
+ #endregion
+
+ #region Protected Instance Methods
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ if (property_grid.SelectedGridItem != null && property_grid.SelectedGridItem.GridItemType == GridItemType.Property)
+ {
+ grid_textbox.Visible = true;
+ if (!grid_textbox.Focused)
+ grid_textbox.Focus();
+ }
+ else
+ {
+ grid_textbox.Visible = false;
+ }
+
+ // Decide if we need a scrollbar
+ open_grid_item_count = 0;
+
+ // draw grid outline
+ //DrawBackground(e);
+
+ e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (BackColor), ClientRectangle);
+
+ // draw grid items
+ // can we use the transform
+ //pevent.Graphics.TranslateTransform(0, -vbar.Value*ROW_HEIGHT);
+ int yLoc = -vbar.Value*ROW_HEIGHT;
+ DrawGridItems(property_grid.grid_items, e, 1, ref yLoc);
+
+ DrawGrid(e, yLoc);
+ e.Graphics.DrawRectangle(SystemPens.ControlDark, 0,0,Width-1,Height-1 );
+
+
+
+
+ UpdateScrollBar();
+
+ base.OnPaint(e);
+ }
+
+ protected override void OnMouseMove (MouseEventArgs e)
+ {
+
+ if (resizing_grid)
+ {
+ splitter_location = Math.Max(e.X,2*V_INDENT);
+ Refresh();
+ }
+ if (e.X > splitter_location - RESIZE_WIDTH && e.X < splitter_location + RESIZE_WIDTH)
+ this.Cursor = Cursors.SizeWE;
+ else
+ this.Cursor = Cursors.Default;
+ base.OnMouseMove (e);
+ }
+
+ private GridItem GetSelectedGridItem (GridItemCollection grid_items, int y, ref int current)
+ {
+ foreach (GridItem child_grid_item in grid_items)
+ {
+ if (y > current && y < current + ROW_HEIGHT)
+ {
+ return child_grid_item;
+ }
+ current += ROW_HEIGHT;
+ if (child_grid_item.Expanded)
+ {
+ GridItem foundItem = GetSelectedGridItem(child_grid_item.GridItems, y, ref current);
+ if (foundItem != null)
+ return foundItem;
+ }
+ }
+ return null;
+ }
+
+ protected override void OnMouseDown (MouseEventArgs e)
+ {
+ if (e.X > splitter_location - RESIZE_WIDTH && e.X < splitter_location + RESIZE_WIDTH)
+ {
+ resizing_grid = true;
+ }
+ else
+ {
+ int offset = -vbar.Value*ROW_HEIGHT;
+ GridItem foundItem = GetSelectedGridItem(property_grid.grid_items, e.Y, ref offset);
+
+ if (foundItem != null)
+ {
+ if (foundItem.Expandable)
+ {
+ if (e.X >=3 && e.X <= 11 && (e.Y % ROW_HEIGHT >= 3 && e.Y % ROW_HEIGHT <= 11))
+ {
+ foundItem.Expanded = !foundItem.Expanded;
+ Invalidate();
+ }
+ }
+ this.property_grid.SelectedGridItem = foundItem;
+ }
+
+ base.OnMouseDown (e);
+ }
+ }
+
+ protected override void OnMouseUp (MouseEventArgs e)
+ {
+ resizing_grid = false;
+ base.OnMouseUp (e);
+ }
+
+ protected override void OnKeyDown (KeyEventArgs e)
+ {
+ base.OnKeyDown (e);
+ }
+
+ #endregion
+
+ #region Private Helper Methods
+
+ private void UpdateScrollBar()
+ {
+ int visible_rows = this.ClientRectangle.Height/ROW_HEIGHT;
+ if (open_grid_item_count > visible_rows)
+ {
+ vbar.Visible = true;
+ vbar.SmallChange = 1;
+ vbar.Minimum = 0;
+ vbar.Maximum = open_grid_item_count-1;
+ vbar.LargeChange = visible_rows;
+ }
+ else
+ {
+ vbar.Visible = false;
+ }
+
+ }
+
+ private GridItem GetGridItemAt (int y)
+ {
+ return null;
+ }
+
+ #region Drawing Code
+
+ private void DrawGrid(PaintEventArgs pevent, int yLoc)
+ {
+ Pen pen = ThemeEngine.Current.ResPool.GetPen(property_grid.LineColor);
+ // vertical divider line
+ pevent.Graphics.DrawLine(pen, splitter_location, 0, splitter_location, yLoc);
+
+ while (yLoc >= 0)
+ {
+ // horizontal lines
+ pevent.Graphics.DrawLine(pen, 0, yLoc, ClientRectangle.Width, yLoc);
+ yLoc -= ROW_HEIGHT;
+ }
+ }
+
+ private void DrawGridItems(GridItemCollection grid_items, PaintEventArgs pevent, int depth, ref int yLoc)
+ {
+ foreach (GridItem grid_item in grid_items)
+ {
+ DrawGridItem (grid_item, pevent, depth, ref yLoc);
+ if (grid_item.Expanded)
+ DrawGridItems(grid_item.GridItems, pevent, (grid_item.GridItemType == GridItemType.Category) ? depth : depth+1, ref yLoc);
+ }
+ }
+
+ private void DrawGridItemLabel(GridItem grid_item, PaintEventArgs pevent, Rectangle rect)
+ {
+ int x = rect.X+1;
+ if (grid_item.Parent != null && grid_item.Parent.GridItemType != GridItemType.Category)
+ x += V_INDENT;
+
+ Font font = this.Font;
+ Brush brush = SystemBrushes.WindowText;
+ if (grid_item.GridItemType == GridItemType.Category)
+ {
+ font = new Font(font, FontStyle.Bold);
+ brush = SystemBrushes.ControlDark;
+ }
+
+ if (grid_item == property_grid.SelectedGridItem && grid_item.GridItemType != GridItemType.Category)
+ {
+ pevent.Graphics.FillRectangle (SystemBrushes.Highlight, rect);
+ // Label
+ brush = SystemBrushes.HighlightText;
+ }
+
+
+ pevent.Graphics.DrawString(grid_item.Label,font,brush,new Rectangle(x, rect.Y + 2,x-rect.X+rect.Width-2,rect.Height-2),stringFormat);
+ }
+
+ private void DrawGridItemValue(GridItem grid_item, PaintEventArgs pevent, Rectangle rect)
+ {
+ // Value
+ if (grid_item.PropertyDescriptor != null)
+ {
+
+ bool paintsValue = false;
+ UITypeEditor editor = null;
+ object temp = grid_item.PropertyDescriptor.GetEditor(typeof(UITypeEditor));
+ editor = (UITypeEditor)temp;//grid_item.PropertyDescriptor.GetEditor(typeof(UITypeEditor));
+ if (editor != null)
+ {
+ paintsValue = editor.GetPaintValueSupported();
+ }
+
+ if (grid_item == property_grid.SelectedGridItem)
+ {
+ grid_textbox.ReadOnly = false;
+ grid_textbox.DropDownButtonVisible = false;
+ grid_textbox.DialogButtonVisible = false;
+ if (editor != null)
+ {
+ UITypeEditorEditStyle style = editor.GetEditStyle();
+
+ switch (style)
+ {
+ case UITypeEditorEditStyle.DropDown:
+ grid_textbox.DropDownButtonVisible = true;
+ break;
+ case UITypeEditorEditStyle.Modal:
+ grid_textbox.DialogButtonVisible = true;
+ break;
+ }
+ }
+ else
+ {
+ try
+ {
+ if (grid_item.PropertyDescriptor.Converter != null)
+ {
+ if (grid_item.PropertyDescriptor.Converter.GetStandardValuesSupported())
+ {
+
+ grid_textbox.DropDownButtonVisible = true;
+ grid_textbox.ReadOnly = true;
+ }
+ }
+ else
+ {
+ System.Console.WriteLine("Converter not available for type {0}",grid_item.PropertyDescriptor.PropertyType);
+ }
+
+ }
+ catch (Exception ex)
+ {
+ }
+ }
+ }
+
+
+
+ int xLoc = splitter_location+1;
+ if (paintsValue)
+ {
+ pevent.Graphics.DrawRectangle(ThemeEngine.Current.ResPool.GetPen(Color.Black), splitter_location+2,rect.Y+2, 20, ROW_HEIGHT-4);
+ try
+ {
+ editor.PaintValue(grid_item.Value, pevent.Graphics, new Rectangle(splitter_location+3,rect.Y+3, 19, ROW_HEIGHT-5));
+ }
+ catch (Exception ex)
+ {
+ System.Console.WriteLine(ex.Message);
+ System.Console.WriteLine("Paint Value failed for type {0}",grid_item.PropertyDescriptor.PropertyType);
+ // design time stuff is not playing nice
+ }
+ xLoc += 27;
+ }
+
+ Font font = this.Font;
+ try
+ {
+ if (grid_item.PropertyDescriptor.Converter != null)
+ {
+ string value = grid_item.PropertyDescriptor.Converter.ConvertToString(grid_item.Value);
+ if (grid_item.PropertyDescriptor.CanResetValue(property_grid.SelectedObject))
+ font = new Font(font, FontStyle.Bold);
+
+ pevent.Graphics.DrawString(value,font,SystemBrushes.WindowText,new RectangleF(xLoc,rect.Y+2, ClientRectangle.Width-(xLoc), ROW_HEIGHT),stringFormat);
+ }
+ else
+ {
+ System.Console.WriteLine("No converter for type {0}",grid_item.PropertyDescriptor.PropertyType);
+ }
+
+ }
+ catch (Exception e)
+ {
+ }
+ if (grid_item == property_grid.SelectedGridItem && grid_item.GridItemType != GridItemType.Category)
+ {
+ grid_textbox.SetBounds(xLoc, rect.Top, ClientRectangle.Width-xLoc - (vbar.Visible ? vbar.Width: 0),ROW_HEIGHT);
+ }
+ }
+ }
+
+ private void DrawGridItem (GridItem grid_item, PaintEventArgs pevent, int depth, ref int yLoc)
+ {
+ if (yLoc > -ROW_HEIGHT && yLoc < ClientRectangle.Height)
+ {
+
+ // left column
+ pevent.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (property_grid.LineColor), 0,yLoc,V_INDENT, ROW_HEIGHT);
+
+ if (grid_item.Expandable)
+ {
+ grid_item.PlusMinusBounds = DrawPlusMinus(pevent, 3, yLoc+3, grid_item.Expanded, grid_item.GridItemType == GridItemType.Category);
+ }
+
+ if (grid_item.GridItemType == GridItemType.Category)
+ {
+ pevent.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (property_grid.LineColor), depth*V_INDENT,yLoc,ClientRectangle.Width-(depth*V_INDENT), ROW_HEIGHT);
+ }
+
+ DrawGridItemLabel(grid_item, pevent, new Rectangle(depth*V_INDENT,yLoc, splitter_location-depth*V_INDENT, ROW_HEIGHT));
+ DrawGridItemValue(grid_item, pevent, new Rectangle(splitter_location+2,yLoc, ClientRectangle.Width-splitter_location-2, ROW_HEIGHT));
+
+
+
+ }
+ grid_item.Top = yLoc;
+ yLoc += ROW_HEIGHT;
+ open_grid_item_count++;
+ }
+
+ private Rectangle DrawPlusMinus (PaintEventArgs pevent, int x, int y, bool expanded, bool category)
+ {
+ Rectangle bounds = new Rectangle(x, y, 8, 8);
+ if (!category) pevent.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush(Color.White), bounds);
+ pevent.Graphics.DrawRectangle (SystemPens.ControlDark, bounds);
+ pevent.Graphics.DrawLine (SystemPens.ControlDark, x+2, y+4, x + 6, y+4);
+ if (!expanded)
+ pevent.Graphics.DrawLine (SystemPens.ControlDark, x+4, y+2, x+4, y+6);
+
+ return bounds;
+ }
+
+ #endregion
+
+ #region Event Handling
+ private void RedrawEvent (object sender, System.EventArgs e)
+ {
+ Refresh();
+ }
+
+ private void TextBoxValidating (object sender, CancelEventArgs e)
+ {
+ if (this.property_grid.SelectedGridItem != null)
+ {
+ PropertyDescriptor desc = property_grid.SelectedGridItem.PropertyDescriptor;
+ if (desc != null)
+ {
+ try
+ {
+ if (desc.Converter != null)
+ {
+ SetPropertyValue(desc.Converter.ConvertFromString(grid_textbox.Text));
+ }
+ else
+ {
+ System.Console.WriteLine("No converter for type {0}",desc.PropertyType);
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("Error converting string");
+ }
+ }
+ }
+ }
+
+ #endregion
+
+
+ #endregion
+
+ private void dropdown_form_Deactivate (object sender, EventArgs e)
+ {
+ dropdown_form_showing = false;
+ dropdown_form.Hide();
+ //dropdown_form = new Form();
+ }
+
+ private void listBox_SelectedIndexChanged (object sender, EventArgs e)
+ {
+ if (this.property_grid.SelectedGridItem != null)
+ {
+ PropertyDescriptor desc = property_grid.SelectedGridItem.PropertyDescriptor;
+ if (desc != null)
+ {
+ SetPropertyValue(((ListBox)sender).SelectedItem);
+ }
+ }
+ dropdown_form.Hide();
+ //dropdown_form = new Form();
+ Refresh();
+ }
+
+ private void SetPropertyValue(object newVal)
+ {
+ if (this.property_grid.SelectedGridItem != null)
+ {
+ PropertyDescriptor desc = property_grid.SelectedGridItem.PropertyDescriptor;
+ if (desc != null)
+ {
+ desc.SetValue(property_grid.SelectedObject, newVal);
+ }
+ }
+ }
+
+ private void DropDownButtonClicked (object sender, EventArgs e)
+ {
+ if (property_grid.SelectedGridItem.PropertyDescriptor.GetEditor(typeof(UITypeEditor)) == null)
+ {
+ //dropdown_form.FormBorderStyle = FormBorderStyle.None;
+ dropdown_form.Deactivate +=new EventHandler(dropdown_form_Deactivate);
+ ListBox listBox = new ListBox();
+ listBox.Dock = DockStyle.Fill;
+ listBox.SelectedIndexChanged +=new EventHandler(listBox_SelectedIndexChanged);
+ foreach (object obj in property_grid.SelectedGridItem.PropertyDescriptor.Converter.GetStandardValues())
+ listBox.Items.Add(obj);
+ dropdown_form.Controls.Clear();
+ dropdown_form.Controls.Add(listBox);
+ dropdown_form.Location = PointToScreen(new Point(grid_textbox.Location.X,grid_textbox.Location.Y+ROW_HEIGHT));
+ dropdown_form.Width = grid_textbox.Width;
+ dropdown_form.Show();
+ }
+ else // use editor
+ {
+ UITypeEditor editor = (UITypeEditor)property_grid.SelectedGridItem.PropertyDescriptor.GetEditor(typeof(UITypeEditor));
+ System.ComponentModel.Design.ServiceContainer service_container = new System.ComponentModel.Design.ServiceContainer();
+ service_container.AddService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService), this);
+ SetPropertyValue(editor.EditValue(new ITypeDescriptorContextImpl(this.property_grid), service_container,property_grid.SelectedGridItem.Value));
+ }
+ }
+
+ private void DialogButtonClicked(object sender, EventArgs e)
+ {
+ //dialog_form.Location = PointToScreen(new Point(grid_textbox.Location.X,grid_textbox.Location.Y+ROW_HEIGHT));
+ //dropdown_form.Width = grid_textbox.Width;
+ dialog_form.Show();
+ }
+
+ private void HandleScroll(object sender, ScrollEventArgs e)
+ {
+ if (e.NewValue <= 0)
+ {
+ e.NewValue = 0;
+ if (e.NewValue == vbar.Value)return;
+ }
+ if (e.NewValue > vbar.Maximum-ClientRectangle.Height/ROW_HEIGHT)
+ {
+ e.NewValue = vbar.Maximum-ClientRectangle.Height/ROW_HEIGHT+1;
+ if (e.NewValue == vbar.Value)return;
+ }
+
+ switch (e.Type)
+ {
+ case ScrollEventType.SmallDecrement:
+ XplatUI.ScrollWindow(Handle, 0, ROW_HEIGHT, false);
+ grid_textbox.Top += ROW_HEIGHT;
+ Invalidate(ClientRectangle);
+ //Invalidate(new Rectangle(0,0,ClientRectangle.Width,ROW_HEIGHT));
+ break;
+ case ScrollEventType.SmallIncrement:
+ XplatUI.ScrollWindow(Handle, 0, -ROW_HEIGHT, false);
+ grid_textbox.Top -= ROW_HEIGHT;
+ Invalidate(ClientRectangle);
+ //Invalidate(new Rectangle(0,ClientRectangle.Bottom-ROW_HEIGHT,ClientRectangle.Width,ROW_HEIGHT));
+ break;
+ case ScrollEventType.LargeDecrement:
+ XplatUI.ScrollWindow(Handle, 0, ROW_HEIGHT, false);
+ Invalidate(ClientRectangle);
+ break;
+ case ScrollEventType.LargeIncrement:
+ XplatUI.ScrollWindow(Handle, 0, -ROW_HEIGHT, false);
+ Invalidate(ClientRectangle);
+ break;
+ case ScrollEventType.ThumbTrack:
+ XplatUI.ScrollWindow(Handle, 0, -(vbar.Value-e.NewValue), false);
+ Invalidate(ClientRectangle);
+ break;
+ case ScrollEventType.ThumbPosition:
+ Invalidate(ClientRectangle);
+ break;
+ }
+ }
+
+
+ private void HandleSelectedGridItemChanged(object sender, SelectedGridItemChangedEventArgs e)
+ {
+ // Region not working correctly
+ //Region clip = new Region();
+ //if (property_grid.SelectedGridItem != null)
+ // clip.Union(new Rectangle(0,property_grid.SelectedGridItem.Top, ClientRectangle.Width, ROW_HEIGHT));
+ // clip.Union(new Rectangle(0,property_grid.SelectedGridItem.Top, ClientRectangle.Width, ROW_HEIGHT));
+
+ if (e.NewSelection.PropertyDescriptor != null)
+ {
+ grid_textbox.Text = e.NewSelection.PropertyDescriptor.Converter.ConvertToString(e.NewSelection.Value);
+ if (e.NewSelection.PropertyDescriptor.CanResetValue(property_grid.SelectedObject))
+ grid_textbox.Font = new Font(this.Font, FontStyle.Bold);
+ else
+ grid_textbox.Font = this.Font;
+ }
+
+ Invalidate(/*clip*/this.ClientRectangle);
+ Update();
+ }
+
+ private void HandlePropertyValueChanged(object s, PropertyValueChangedEventArgs e)
+ {
+ if (e.ChangedItem.PropertyDescriptor != null)
+ {
+ grid_textbox.Text = e.ChangedItem.PropertyDescriptor.Converter.ConvertToString(e.ChangedItem.Value);
+ if (e.ChangedItem.PropertyDescriptor.CanResetValue(property_grid.SelectedObject))
+ grid_textbox.Font = new Font(this.Font, FontStyle.Bold);
+ else
+ grid_textbox.Font = this.Font;
+ }
+ }
+
+ #region IWindowsFormsEditorService Members
+
+ public void CloseDropDown()
+ {
+ dropdown_form_showing = false;
+ dropdown_form.Hide();
+ }
+
+ public void DropDownControl(Control control)
+ {
+ //dropdown_form.FormBorderStyle = FormBorderStyle.None;
+ dropdown_form.Deactivate +=new EventHandler(dropdown_form_Deactivate);
+ dropdown_form.Size = control.Size;
+ control.Dock = DockStyle.Fill;
+ dropdown_form.Controls.Clear();
+ dropdown_form.Controls.Add(control);
+ dropdown_form.Location = PointToScreen(new Point(grid_textbox.Location.X,grid_textbox.Location.Y+ROW_HEIGHT));
+ dropdown_form.Width = grid_textbox.Width;
+
+ dropdown_form_showing = true;
+ dropdown_form.Show();
+ System.Windows.Forms.MSG msg = new MSG();
+ while (XplatUI.GetMessage(ref msg, IntPtr.Zero, 0, 0) && dropdown_form_showing)
+ {
+ XplatUI.TranslateMessage(ref msg);
+ XplatUI.DispatchMessage(ref msg);
+ }
+ }
+
+ public System.Windows.Forms.DialogResult ShowDialog(Form dialog)
+ {
+ return dialog.ShowDialog(this);
+ }
+
+ #endregion
+
+ #region DropDownForm Class
+ #endregion DropDownForm Class
+
+ #region Internal Classes
+ internal class ITypeDescriptorContextImpl : System.ComponentModel.ITypeDescriptorContext
+ {
+ private PropertyGrid property_grid;
+ public ITypeDescriptorContextImpl(PropertyGrid propertyGrid)
+ {
+ property_grid = propertyGrid;
+ }
+ #region ITypeDescriptorContext Members
+
+ public void OnComponentChanged()
+ {
+ // TODO: Add SystemComp.OnComponentChanged implementation
+ }
+
+ public IContainer Container
+ {
+ get
+ {
+ return property_grid as IContainer;
+ }
+ }
+
+ public bool OnComponentChanging()
+ {
+ // TODO: Add SystemComp.OnComponentChanging implementation
+ return false;
+ }
+
+ public object Instance
+ {
+ get
+ {
+ return property_grid.SelectedGridItem.Value;
+ }
+ }
+
+ public PropertyDescriptor PropertyDescriptor
+ {
+ get
+ {
+ return property_grid.SelectedGridItem.PropertyDescriptor;
+ }
+ }
+
+ #endregion
+
+ #region IServiceProvider Members
+
+ public object GetService(Type serviceType)
+ {
+ // TODO: Add SystemComp.GetService implementation
+ return null;
+ }
+
+ #endregion
+
+ }
+
+
+
+ /*
+ class ComboListBox
+ */
+ internal class PropertyGridDropDown : Form
+ {
+ protected override CreateParams CreateParams
+ {
+ get
+ {
+ CreateParams cp = base.CreateParams;
+ cp.Style = unchecked ((int)(WindowStyles.WS_POPUP | WindowStyles.WS_VISIBLE | WindowStyles.WS_CLIPSIBLINGS | WindowStyles.WS_CLIPCHILDREN));
+ cp.ExStyle |= (int)(WindowExStyles.WS_EX_TOOLWINDOW | WindowExStyles.WS_EX_TOPMOST);
+ return cp;
+ }
+ }
+
+ }
+ #endregion
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyManager.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyManager.cs
new file mode 100644
index 00000000000..ea27ef69a07
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyManager.cs
@@ -0,0 +1,141 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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.
+//
+// Authors:
+// Jackson Harper jackson@ximian.com
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+
+ public class PropertyManager : BindingManagerBase {
+
+ private object data_source;
+ private string property_name;
+ private PropertyDescriptor prop_desc;
+ private bool binding_suspended;
+
+ public PropertyManager() {
+ }
+
+ internal PropertyManager (object data_source, string property_name)
+ {
+ this.data_source = data_source;
+ this.property_name = property_name;
+
+ prop_desc = TypeDescriptor.GetProperties (data_source).Find (property_name, true);
+
+ if (prop_desc == null)
+ return;
+
+ prop_desc.AddValueChanged (data_source, new EventHandler (PropertyChangedHandler));
+ }
+
+ public override object Current {
+ get { return data_source; }
+ }
+
+ public override int Position {
+ get { return 0; }
+ set { /* Doesn't do anything on MS" */ }
+ }
+
+ public override int Count {
+ get { return 1; }
+ }
+
+ public override void AddNew ()
+ {
+ throw new NotSupportedException ("AddNew is not supported for property to property binding");
+ }
+
+ public override void CancelCurrentEdit ()
+ {
+ IEditableObject editable = data_source as IEditableObject;
+ if (editable == null)
+ return;
+ editable.CancelEdit ();
+
+ PushData ();
+ }
+
+ public override void EndCurrentEdit ()
+ {
+ PullData ();
+
+ IEditableObject editable = data_source as IEditableObject;
+ if (editable == null)
+ return;
+ editable.EndEdit ();
+ }
+
+ public override PropertyDescriptorCollection GetItemProperties ()
+ {
+ return TypeDescriptor.GetProperties (data_source);
+ }
+
+ public override void RemoveAt (int idx)
+ {
+ throw new NotSupportedException ("RemoveAt is not supported for property to property binding");
+ }
+
+ public override void ResumeBinding ()
+ {
+ binding_suspended = false;
+ }
+
+ public override void SuspendBinding ()
+ {
+ binding_suspended = true;
+ }
+
+ internal override bool IsSuspended {
+ get { return binding_suspended; }
+ }
+
+ protected internal override string GetListName (ArrayList list)
+ {
+ return String.Empty;
+ }
+
+ [MonoTODO]
+ protected override void UpdateIsBinding ()
+ {
+ }
+
+ protected internal override void OnCurrentChanged (EventArgs e)
+ {
+ PullData ();
+
+ if (onCurrentChangedHandler != null) {
+ onCurrentChangedHandler (this, e);
+ }
+ }
+
+ private void PropertyChangedHandler (object sender, EventArgs e)
+ {
+ OnCurrentChanged (EventArgs.Empty);
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertySort.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertySort.cs
new file mode 100644
index 00000000000..701fdab4f96
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertySort.cs
@@ -0,0 +1,41 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jonathan Chambers (jonathan.chambers@ansys.com)
+//
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ [ComVisible(true)]
+ public enum PropertySort
+ {
+ NoSort = 0,
+ Alphabetical = 1,
+ Categorized = 2,
+ CategorizedAlphabetical = 3
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyTabChangedEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyTabChangedEventArgs.cs
new file mode 100644
index 00000000000..90392b514ee
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyTabChangedEventArgs.cs
@@ -0,0 +1,66 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jonathan Chambers (jonathan.chambers@ansys.com)
+//
+
+// COMPLETE
+
+using System;
+using System.Runtime.InteropServices;
+using System.Windows.Forms.Design;
+
+namespace System.Windows.Forms
+{
+ [ComVisible(true)]
+ public class PropertyTabChangedEventArgs : EventArgs
+ {
+ #region Local Variables
+ private PropertyTab old_tab;
+ private PropertyTab new_tab;
+ #endregion // Local Variables
+
+ #region Constructor
+ public PropertyTabChangedEventArgs ( PropertyTab oldTab , PropertyTab newTab )
+ {
+ old_tab = oldTab;
+ new_tab = newTab;
+ }
+ #endregion // Constructor
+
+ #region Public Instance Properties
+ public PropertyTab NewTab
+ {
+ get {
+ return new_tab;
+ }
+ }
+
+ public PropertyTab OldTab
+ {
+ get {
+ return old_tab;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyTabChangedEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyTabChangedEventHandler.cs
new file mode 100644
index 00000000000..aa8e7645bcc
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyTabChangedEventHandler.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jonathan Chambers (jonathan.chambers@ansys.com)
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public delegate void PropertyTabChangedEventHandler(object s, PropertyTabChangedEventArgs e);
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyValueChangedEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyValueChangedEventArgs.cs
new file mode 100644
index 00000000000..a38c5b367b0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyValueChangedEventArgs.cs
@@ -0,0 +1,66 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jonathan Chambers (jonathan.chambers@ansys.com)
+//
+
+// COMPLETE
+
+using System;
+using System.Runtime.InteropServices;
+using System.Windows.Forms.Design;
+
+namespace System.Windows.Forms
+{
+ [ComVisible(true)]
+ public class PropertyValueChangedEventArgs : EventArgs
+ {
+ #region Local Variables
+ private GridItem changed_item;
+ private object old_value;
+ #endregion // Local Variables
+
+ #region Constructors
+ public PropertyValueChangedEventArgs ( GridItem changedItem , object oldValue )
+ {
+ changed_item = changedItem;
+ old_value = oldValue;
+ }
+ #endregion
+
+ #region Public Instance Properties
+ public GridItem ChangedItem
+ {
+ get {
+ return changed_item;
+ }
+ }
+
+ public object OldValue
+ {
+ get {
+ return old_value;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyValueChangedEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyValueChangedEventHandler.cs
new file mode 100644
index 00000000000..b09ee2dfe1b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyValueChangedEventHandler.cs
@@ -0,0 +1,32 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jonathan Chambers (jonathan.chambers@ansys.com)
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public delegate void PropertyValueChangedEventHandler(object s, PropertyValueChangedEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/QueryAccessibilityHelpEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/QueryAccessibilityHelpEventArgs.cs
new file mode 100644
index 00000000000..4d0e9c4fbb1
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/QueryAccessibilityHelpEventArgs.cs
@@ -0,0 +1,84 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public class QueryAccessibilityHelpEventArgs : EventArgs {
+ private string help_namespace;
+ private string help_string;
+ private string help_keyword;
+
+ #region Public Constructors
+ public QueryAccessibilityHelpEventArgs() {
+ this.help_namespace = null;
+ this.help_string = null;
+ this.help_keyword = null;
+ }
+
+ public QueryAccessibilityHelpEventArgs(string helpNamespace, string helpString, string helpKeyword) {
+ this.help_namespace=helpNamespace;
+ this.help_string=helpString;
+ this.help_keyword=helpKeyword;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public string HelpKeyword {
+ get {
+ return this.help_keyword;
+ }
+
+ set {
+ this.help_keyword = value;
+ }
+ }
+
+ public string HelpNamespace {
+ get {
+ return this.help_namespace;
+ }
+
+ set {
+ this.help_namespace = value;
+ }
+ }
+
+ public string HelpString {
+ get {
+ return this.help_string;
+ }
+
+ set {
+ this.help_string = value;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/QueryAccessibilityHelpEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/QueryAccessibilityHelpEventHandler.cs
new file mode 100644
index 00000000000..e6085de5ca0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/QueryAccessibilityHelpEventHandler.cs
@@ -0,0 +1,31 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void QueryAccessibilityHelpEventHandler (object sender, QueryAccessibilityHelpEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/QueryContinueDragEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/QueryContinueDragEventArgs.cs
new file mode 100644
index 00000000000..85e151668b2
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/QueryContinueDragEventArgs.cs
@@ -0,0 +1,71 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public class QueryContinueDragEventArgs : EventArgs {
+ internal int key_state;
+ internal bool escape_pressed;
+ internal DragAction drag_action;
+
+ #region Public Constructors
+ public QueryContinueDragEventArgs(int keyState, bool escapePressed, DragAction action) {
+ this.key_state = keyState;
+ this.escape_pressed = escapePressed;
+ this.drag_action = action;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public DragAction Action {
+ get {
+ return this.drag_action;
+ }
+
+ set {
+ this.drag_action=value;
+ }
+ }
+
+ public bool EscapePressed {
+ get {
+ return this.escape_pressed;
+ }
+ }
+
+ public int KeyState {
+ get {
+ return this.key_state;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/QueryContinueDragEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/QueryContinueDragEventHandler.cs
new file mode 100644
index 00000000000..d250a237ab4
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/QueryContinueDragEventHandler.cs
@@ -0,0 +1,31 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void QueryContinueDragEventHandler (object sender, QueryContinueDragEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/QuestionEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/QuestionEventArgs.cs
new file mode 100644
index 00000000000..afe72db3b0f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/QuestionEventArgs.cs
@@ -0,0 +1,52 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public class QuestionEventArgs : EventArgs {
+
+ private bool response;
+
+ public QuestionEventArgs () {
+ response = false;
+ }
+
+ public QuestionEventArgs (bool response) {
+ this.response = response;
+ }
+
+ public bool Response {
+ get { return response; }
+ set { response = value; }
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/QuestionEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/QuestionEventHandler.cs
new file mode 100644
index 00000000000..261306c0e18
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/QuestionEventHandler.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ public delegate void QuestionEventHandler (object sender, QuestionEventArgs e);
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RadioButton.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RadioButton.cs
new file mode 100644
index 00000000000..ace406fa54e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RadioButton.cs
@@ -0,0 +1,333 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+// COMPLETE
+
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Text;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [DefaultProperty("Checked")]
+ [DefaultEvent("CheckedChanged")]
+ public class RadioButton : ButtonBase {
+ #region Local Variables
+ internal Appearance appearance;
+ internal bool auto_check;
+ internal ContentAlignment radiobutton_alignment;
+ internal CheckState check_state;
+ #endregion // Local Variables
+
+ #region RadioButtonAccessibleObject Subclass
+ [ComVisible(true)]
+ public class RadioButtonAccessibleObject : ControlAccessibleObject {
+ #region RadioButtonAccessibleObject Local Variables
+ private RadioButton owner;
+ #endregion // RadioButtonAccessibleObject Local Variables
+
+ #region RadioButtonAccessibleObject Constructors
+ public RadioButtonAccessibleObject(RadioButton owner) : base(owner) {
+ this.owner = owner;
+ }
+ #endregion // RadioButtonAccessibleObject Constructors
+
+ #region RadioButtonAccessibleObject Properties
+ public override string DefaultAction {
+ get {
+ return "Select";
+ }
+ }
+
+ public override AccessibleRole Role {
+ get {
+ return AccessibleRole.RadioButton;
+ }
+ }
+
+ public override AccessibleStates State {
+ get {
+ AccessibleStates retval;
+
+ retval = AccessibleStates.Default;
+
+ if (owner.check_state == CheckState.Checked) {
+ retval |= AccessibleStates.Checked;
+ }
+
+ if (owner.Focused) {
+ retval |= AccessibleStates.Focused;
+ }
+
+ if (owner.CanFocus) {
+ retval |= AccessibleStates.Focusable;
+ }
+
+ return retval;
+ }
+ }
+ #endregion // RadioButtonAccessibleObject Properties
+
+ #region RadioButtonAccessibleObject Methods
+ public override void DoDefaultAction() {
+ owner.PerformClick();
+ }
+ #endregion // RadioButtonAccessibleObject Methods
+ }
+ #endregion // RadioButtonAccessibleObject Sub-class
+
+ #region Public Constructors
+ public RadioButton() {
+ appearance = Appearance.Normal;
+ auto_check = true;
+ radiobutton_alignment = ContentAlignment.MiddleLeft;
+ text_alignment = ContentAlignment.MiddleLeft;
+ tab_stop = false;
+ GotFocus +=new EventHandler(ReceivedFocus);
+ }
+ #endregion // Public Constructors
+
+ #region Private Methods
+ private void UpdateSiblings() {
+ Control c;
+
+ if (auto_check == false) {
+ return;
+ }
+
+ // Remove tabstop property from and uncheck our radio-button siblings
+ c = this.parent;
+ if (c != null) {
+ for (int i = 0; i < c.child_controls.Count; i++) {
+ if ((this != c.child_controls[i]) && (c.child_controls[i] is RadioButton)) {
+ if (((RadioButton)(c.child_controls[i])).auto_check) {
+ c.child_controls[i].TabStop = false;
+ ((RadioButton)(c.child_controls[i])).Checked = false;
+ }
+ }
+ }
+ }
+
+ this.TabStop = true;
+ }
+
+ internal override void HaveDoubleClick() {
+ if (DoubleClick != null) DoubleClick(this, EventArgs.Empty);
+ }
+
+ internal override void Draw (PaintEventArgs pe) {
+ ThemeEngine.Current.DrawRadioButton (pe.Graphics, this.ClientRectangle, this);
+ }
+
+ private void ReceivedFocus(object sender, EventArgs e) {
+ OnClick(e);
+ }
+ #endregion // Private Methods
+
+ #region Public Instance Properties
+ [DefaultValue(Appearance.Normal)]
+ [Localizable(true)]
+ public Appearance Appearance {
+ get {
+ return appearance;
+ }
+
+ set {
+ if (value != appearance) {
+ appearance = value;
+ if (AppearanceChanged != null) {
+ AppearanceChanged(this, EventArgs.Empty);
+ }
+ Redraw();
+ }
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool AutoCheck {
+ get {
+ return auto_check;
+ }
+
+ set {
+ auto_check = value;
+ }
+ }
+
+ [Bindable(true)]
+ [Localizable(true)]
+ [DefaultValue(ContentAlignment.MiddleLeft)]
+ public ContentAlignment CheckAlign {
+ get {
+ return radiobutton_alignment;
+ }
+
+ set {
+ if (value != radiobutton_alignment) {
+ radiobutton_alignment = value;
+
+ Redraw();
+ }
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool Checked {
+ get {
+ if (check_state != CheckState.Unchecked) {
+ return true;
+ }
+ return false;
+ }
+
+ set {
+ if (value && (check_state != CheckState.Checked)) {
+ UpdateSiblings();
+ check_state = CheckState.Checked;
+ Redraw();
+ OnCheckedChanged(EventArgs.Empty);
+ } else if (!value && (check_state != CheckState.Unchecked)) {
+ check_state = CheckState.Unchecked;
+ Redraw();
+ OnCheckedChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ [DefaultValue(false)]
+ public new bool TabStop {
+ get {
+ return tab_stop;
+ }
+
+ set {
+ tab_stop = value;
+ }
+ }
+
+ [DefaultValue(ContentAlignment.MiddleLeft)]
+ [Localizable(true)]
+ public override ContentAlignment TextAlign {
+ get {
+ return text_alignment;
+ }
+
+ set {
+ if (value != text_alignment) {
+ text_alignment = value;
+ Redraw();
+ }
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Properties
+ protected override CreateParams CreateParams {
+ get {
+ SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle(ControlStyles.UserPaint, true);
+
+ return base.CreateParams;
+ }
+ }
+
+ protected override Size DefaultSize {
+ get {
+ return ThemeEngine.Current.RadioButtonDefaultSize;
+ }
+ }
+ #endregion // Protected Instance Properties
+
+ #region Public Instance Methods
+ public void PerformClick() {
+ OnClick(EventArgs.Empty);
+ }
+
+ public override string ToString() {
+ return base.ToString() + ", Checked: " + this.Checked;
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected override AccessibleObject CreateAccessibilityInstance() {
+ AccessibleObject ao;
+
+ ao = base.CreateAccessibilityInstance ();
+ ao.role = AccessibleRole.RadioButton;
+
+ return ao;
+ }
+
+ protected virtual void OnCheckedChanged(EventArgs e) {
+ if (CheckedChanged != null) {
+ CheckedChanged(this, e);
+ }
+ }
+
+ protected override void OnClick(EventArgs e) {
+ if (auto_check) {
+ if (!Checked) {
+ Checked = true;
+ }
+ } else {
+ Checked = !Checked;
+ }
+
+ base.OnClick (e);
+ }
+
+ protected override void OnEnter(EventArgs e) {
+ base.OnEnter(e);
+ }
+
+ protected override void OnHandleCreated(EventArgs e) {
+ base.OnHandleCreated(e);
+ }
+
+ protected override void OnMouseUp(MouseEventArgs mevent) {
+ base.OnMouseUp(mevent);
+ }
+
+ protected override bool ProcessMnemonic(char charCode) {
+ if (IsMnemonic(charCode, Text) == true) {
+ Select();
+ PerformClick();
+ return true;
+ }
+
+ return base.ProcessMnemonic(charCode);
+ }
+ #endregion // Protected Instance Methods
+
+ #region Events
+ public event EventHandler AppearanceChanged;
+ public event EventHandler CheckedChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public event EventHandler DoubleClick;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
new file mode 100644
index 00000000000..839c73b63d5
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
@@ -0,0 +1,1640 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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-2006 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok <pbartok@novell.com>
+//
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.IO;
+using System.Text;
+using RTF=System.Windows.Forms.RTF;
+
+namespace System.Windows.Forms {
+ public class RichTextBox : TextBoxBase {
+ #region Local Variables
+ internal bool auto_word_select;
+ internal int bullet_indent;
+ internal bool can_redo;
+ internal bool detect_urls;
+ internal string redo_action_name;
+ internal int margin_right;
+ internal string undo_action_name;
+ internal float zoom;
+
+ private RTF.TextMap rtf_text_map;
+ private int rtf_skip_width;
+ private int rtf_skip_count;
+ private StringBuilder rtf_line;
+ private SolidBrush rtf_color;
+ private RTF.Font rtf_rtffont;
+ private int rtf_rtffont_size;
+ private FontStyle rtf_rtfstyle;
+ private HorizontalAlignment rtf_rtfalign;
+ private int rtf_cursor_x;
+ private int rtf_cursor_y;
+ private int rtf_chars;
+ #endregion // Local Variables
+
+ #region Public Constructors
+ public RichTextBox() {
+ accepts_return = true;
+ auto_word_select = false;
+ bullet_indent = 0;
+ can_redo = false;
+ detect_urls = true;
+ max_length = Int32.MaxValue;
+ redo_action_name = string.Empty;
+ margin_right = 0;
+ undo_action_name = string.Empty;
+ zoom = 1;
+ base.Multiline = true;
+ document.CRLFSize = 1;
+
+ scrollbars = RichTextBoxScrollBars.Both;
+ alignment = HorizontalAlignment.Left;
+ LostFocus += new EventHandler(RichTextBox_LostFocus);
+ GotFocus += new EventHandler(RichTextBox_GotFocus);
+ BackColor = ThemeEngine.Current.ColorWindow;
+ ForeColor = ThemeEngine.Current.ColorWindowText;
+ base.HScrolled += new EventHandler(RichTextBox_HScrolled);
+ base.VScrolled += new EventHandler(RichTextBox_VScrolled);
+ }
+ #endregion // Public Constructors
+
+ #region Private & Internal Methods
+ private void RichTextBox_LostFocus(object sender, EventArgs e) {
+ has_focus = false;
+ Invalidate();
+ }
+
+ private void RichTextBox_GotFocus(object sender, EventArgs e) {
+ has_focus = true;
+ Invalidate();
+ }
+ #endregion // Private & Internal Methods
+
+ #region Public Instance Properties
+ public override bool AllowDrop {
+ get {
+ return base.AllowDrop;
+ }
+
+ set {
+ base.AllowDrop = value;
+ }
+ }
+
+ [DefaultValue(false)]
+ [Localizable(true)]
+ public override bool AutoSize {
+ get {
+ return auto_size;
+ }
+
+ set {
+ base.AutoSize = value;
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool AutoWordSelection {
+ get {
+ return auto_word_select;
+ }
+
+ set {
+ auto_word_select = true;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override System.Drawing.Image BackgroundImage {
+ get {
+ return background_image;
+ }
+
+ set {
+ base.BackgroundImage = value;
+ }
+ }
+
+ [DefaultValue(0)]
+ [Localizable(true)]
+ public int BulletIndent {
+ get {
+ return bullet_indent;
+ }
+
+ set {
+ bullet_indent = value;
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool CanRedo {
+ get {
+ return can_redo;
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool DetectUrls {
+ get {
+ return detect_urls;
+ }
+
+ set {
+ detect_urls = true;
+ }
+ }
+
+ public override Font Font {
+ get {
+ return base.Font;
+ }
+
+ set {
+ if (font != value) {
+ Line start;
+ Line end;
+
+ if (auto_size) {
+ if (PreferredHeight != Height) {
+ Height = PreferredHeight;
+ }
+ }
+
+ base.Font = value;
+
+ // Font changes always set the whole doc to that font
+ start = document.GetLine(1);
+ end = document.GetLine(document.Lines);
+ document.FormatText(start, 1, end, end.text.Length + 1, base.Font, new SolidBrush(this.ForeColor));
+ }
+ }
+ }
+
+ public override Color ForeColor {
+ get {
+ return base.ForeColor;
+ }
+
+ set {
+ base.ForeColor = value;
+ }
+ }
+
+ [DefaultValue(Int32.MaxValue)]
+ public override int MaxLength {
+ get {
+ return base.max_length;
+ }
+
+ set {
+ base.max_length = value;
+ }
+ }
+
+ [DefaultValue(true)]
+ public override bool Multiline {
+ get {
+ return multiline;
+ }
+
+ set {
+ base.Multiline = value;
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [MonoTODO]
+ public string RedoActionName {
+ get {
+ return redo_action_name;
+ }
+ }
+
+ [DefaultValue(0)]
+ [Localizable(true)]
+ [MonoTODO("Teach TextControl.RecalculateLine to consider the right margin as well")]
+ public int RightMargin {
+ get {
+ return margin_right;
+ }
+
+ set {
+ margin_right = value;
+ }
+ }
+
+ [Browsable(false)]
+ [DefaultValue("")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string Rtf {
+ get {
+ Line start_line;
+ Line end_line;
+ int current;
+ int total;
+
+ start_line = document.GetLine(1);
+ end_line = document.GetLine(document.Lines);
+ return GenerateRTF(start_line, 0, end_line, end_line.text.Length).ToString();
+ }
+
+ set {
+ MemoryStream data;
+
+ document.Empty();
+ data = new MemoryStream(Encoding.ASCII.GetBytes(value), false);
+
+ InsertRTFFromStream(data, 0, 1);
+
+ data.Close();
+ }
+ }
+
+ [DefaultValue(RichTextBoxScrollBars.Both)]
+ [Localizable(true)]
+ public RichTextBoxScrollBars ScrollBars {
+ get {
+ return scrollbars;
+ }
+
+ set {
+ scrollbars = value;
+ }
+ }
+
+ [Browsable(false)]
+ [DefaultValue("")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string SelectedRtf {
+ get {
+ return GenerateRTF(document.selection_start.line, document.selection_start.pos, document.selection_end.line, document.selection_end.pos).ToString();
+ }
+
+ set {
+ MemoryStream data;
+ int x;
+ int y;
+ int sel_start;
+ int chars;
+ Line line;
+ LineTag tag;
+
+ if (document.selection_visible) {
+ document.ReplaceSelection("");
+ }
+
+ sel_start = document.LineTagToCharIndex(document.selection_start.line, document.selection_start.pos);
+
+ data = new MemoryStream(Encoding.ASCII.GetBytes(value), false);
+ InsertRTFFromStream(data, document.selection_start.pos, document.selection_start.line.line_no, out x, out y, out chars);
+ data.Close();
+
+ document.CharIndexToLineTag(sel_start + chars + (y - document.selection_start.line.line_no) * 2, out line, out tag, out sel_start);
+ document.SetSelection(line, sel_start);
+ document.PositionCaret(line, sel_start);
+ document.DisplayCaret();
+ ScrollToCaret();
+ OnTextChanged(EventArgs.Empty);
+ }
+ }
+
+ [Browsable(false)]
+ [DefaultValue("")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public override string SelectedText {
+ get {
+ return base.SelectedText;
+ }
+
+ set {
+ base.SelectedText = value;
+ }
+ }
+
+ [Browsable(false)]
+ [DefaultValue(HorizontalAlignment.Left)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public HorizontalAlignment SelectionAlignment {
+ get {
+ HorizontalAlignment align;
+ Line start;
+ Line end;
+ Line line;
+
+ start = document.ParagraphStart(document.selection_start.line);
+ align = start.alignment;
+
+ end = document.ParagraphEnd(document.selection_end.line);
+
+ line = start;
+
+ while (true) {
+ if (line.alignment != align) {
+ return HorizontalAlignment.Left;
+ }
+
+ if (line == end) {
+ break;
+ }
+ line = document.GetLine(line.line_no + 1);
+ }
+
+ return align;
+ }
+
+ set {
+ Line start;
+ Line end;
+ Line line;
+
+ start = document.ParagraphStart(document.selection_start.line);
+
+ end = document.ParagraphEnd(document.selection_end.line);
+
+ line = start;
+
+ while (true) {
+ line.alignment = value;
+
+ if (line == end) {
+ break;
+ }
+ line = document.GetLine(line.line_no + 1);
+ }
+ this.CalculateDocument();
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Color SelectionColor {
+ get {
+ Color color;
+ LineTag start;
+ LineTag end;
+ LineTag tag;
+
+ start = document.selection_start.tag;
+ end = document.selection_end.tag;
+ color = ((SolidBrush)document.selection_start.tag.color).Color;
+
+ tag = start;
+ while (true) {
+ if (!color.Equals(((SolidBrush)tag.color).Color)) {
+ return Color.Empty;
+ }
+
+ if (tag == end) {
+ break;
+ }
+
+ tag = document.NextTag(tag);
+
+ if (tag == null) {
+ break;
+ }
+ }
+
+ return color;
+ }
+
+ set {
+ FontDefinition attributes;
+ int sel_start;
+ int sel_end;
+
+ attributes = new FontDefinition();
+ attributes.color = value;
+
+ sel_start = document.LineTagToCharIndex(document.selection_start.line, document.selection_start.pos);
+ sel_end = document.LineTagToCharIndex(document.selection_end.line, document.selection_end.pos);
+
+ document.FormatText(document.selection_start.line, document.selection_start.pos + 1, document.selection_end.line, document.selection_end.pos + 1, attributes);
+
+ document.CharIndexToLineTag(sel_start, out document.selection_start.line, out document.selection_start.tag, out document.selection_start.pos);
+ document.CharIndexToLineTag(sel_end, out document.selection_end.line, out document.selection_end.tag, out document.selection_end.pos);
+
+ document.UpdateView(document.selection_start.line, 0);
+ document.AlignCaret();
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Font SelectionFont {
+ get {
+ Font font;
+ LineTag start;
+ LineTag end;
+ LineTag tag;
+
+ start = document.selection_start.tag;
+ end = document.selection_end.tag;
+ font = document.selection_start.tag.font;
+
+ tag = start;
+ while (true) {
+ if (!font.Equals(tag.font)) {
+ return null;
+ }
+
+ if (tag == end) {
+ break;
+ }
+
+ tag = document.NextTag(tag);
+
+ if (tag == null) {
+ break;
+ }
+ }
+
+ return font;
+ }
+
+ set {
+ FontDefinition attributes;
+ int sel_start;
+ int sel_end;
+
+ attributes = new FontDefinition();
+ attributes.font_obj = value;
+
+ sel_start = document.LineTagToCharIndex(document.selection_start.line, document.selection_start.pos);
+ sel_end = document.LineTagToCharIndex(document.selection_end.line, document.selection_end.pos);
+
+ document.FormatText(document.selection_start.line, document.selection_start.pos + 1, document.selection_end.line, document.selection_end.pos + 1, attributes);
+
+ document.CharIndexToLineTag(sel_start, out document.selection_start.line, out document.selection_start.tag, out document.selection_start.pos);
+ document.CharIndexToLineTag(sel_end, out document.selection_end.line, out document.selection_end.tag, out document.selection_end.pos);
+
+ document.UpdateView(document.selection_start.line, 0);
+ document.AlignCaret();
+
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public override int SelectionLength {
+ get {
+ return base.SelectionLength;
+ }
+
+ set {
+ base.SelectionLength = value;
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public RichTextBoxSelectionTypes SelectionType {
+ get {
+ if (document.selection_start == document.selection_end) {
+ return RichTextBoxSelectionTypes.Empty;
+ }
+
+ // Lazy, but works
+ if (SelectedText.Length > 1) {
+ return RichTextBoxSelectionTypes.MultiChar | RichTextBoxSelectionTypes.Text;
+ }
+
+ return RichTextBoxSelectionTypes.Text;
+ }
+ }
+
+ [Localizable(true)]
+ public override string Text {
+ get {
+ return base.Text;
+ }
+
+ set {
+ base.Text = value;
+ }
+ }
+
+ [Browsable(false)]
+ public override int TextLength {
+ get {
+ return base.TextLength;
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string UndoActionName {
+ get {
+ return document.undo.UndoName;
+ }
+ }
+
+ [Localizable(true)]
+ [DefaultValue(1)]
+ public float ZoomFactor {
+ get {
+ return zoom;
+ }
+
+ set {
+ zoom = value;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Properties
+ protected override CreateParams CreateParams {
+ get {
+ return base.CreateParams;
+ }
+ }
+
+ protected override Size DefaultSize {
+ get {
+ return new Size(100, 96);
+ }
+ }
+ #endregion // Protected Instance Properties
+
+ #region Public Instance Methods
+ public bool CanPaste(DataFormats.Format clipFormat) {
+ if ((clipFormat.Name == DataFormats.Rtf) ||
+ (clipFormat.Name == DataFormats.Text) ||
+ (clipFormat.Name == DataFormats.UnicodeText)) {
+ return true;
+ }
+ return false;
+ }
+
+ public int Find(char[] characterSet) {
+ return Find(characterSet, -1, -1);
+ }
+
+ public int Find(char[] characterSet, int start) {
+ return Find(characterSet, start, -1);
+ }
+
+ public int Find(char[] characterSet, int start, int end) {
+ Document.Marker start_mark;
+ Document.Marker end_mark;
+ Document.Marker result;
+
+ if (start == -1) {
+ document.GetMarker(out start_mark, true);
+ } else {
+ Line line;
+ LineTag tag;
+ int pos;
+
+ start_mark = new Document.Marker();
+
+ document.CharIndexToLineTag(start, out line, out tag, out pos);
+ start_mark.line = line;
+ start_mark.tag = tag;
+ start_mark.pos = pos;
+ }
+
+ if (end == -1) {
+ document.GetMarker(out end_mark, false);
+ } else {
+ Line line;
+ LineTag tag;
+ int pos;
+
+ end_mark = new Document.Marker();
+
+ document.CharIndexToLineTag(end, out line, out tag, out pos);
+ end_mark.line = line;
+ end_mark.tag = tag;
+ end_mark.pos = pos;
+ }
+
+ if (document.FindChars(characterSet, start_mark, end_mark, out result)) {
+ return document.LineTagToCharIndex(result.line, result.pos);
+ }
+
+ return -1;
+ }
+
+ public int Find(string str) {
+ return Find(str, -1, -1, RichTextBoxFinds.None);
+ }
+
+ public int Find(string str, int start, int end, RichTextBoxFinds options) {
+ Document.Marker start_mark;
+ Document.Marker end_mark;
+ Document.Marker result;
+
+ if (start == -1) {
+ document.GetMarker(out start_mark, true);
+ } else {
+ Line line;
+ LineTag tag;
+ int pos;
+
+ start_mark = new Document.Marker();
+
+ document.CharIndexToLineTag(start, out line, out tag, out pos);
+
+ start_mark.line = line;
+ start_mark.tag = tag;
+ start_mark.pos = pos;
+ }
+
+ if (end == -1) {
+ document.GetMarker(out end_mark, false);
+ } else {
+ Line line;
+ LineTag tag;
+ int pos;
+
+ end_mark = new Document.Marker();
+
+ document.CharIndexToLineTag(end, out line, out tag, out pos);
+
+ end_mark.line = line;
+ end_mark.tag = tag;
+ end_mark.pos = pos;
+ }
+
+ if (document.Find(str, start_mark, end_mark, out result, options)) {
+ return document.LineTagToCharIndex(result.line, result.pos);
+ }
+
+ return -1;
+ }
+
+ public int Find(string str, int start, RichTextBoxFinds options) {
+ return Find(str, start, -1, options);
+ }
+
+ public int Find(string str, RichTextBoxFinds options) {
+ return Find(str, -1, -1, options);
+ }
+
+ public char GetCharFromPosition(Point pt) {
+ LineTag tag;
+ int pos;
+
+ PointToTagPos(pt, out tag, out pos);
+
+ if (pos >= tag.line.text.Length) {
+ return '\n';
+ }
+
+ return tag.line.text[pos];
+
+ }
+
+ public int GetCharIndexFromPosition(Point pt) {
+ LineTag tag;
+ int pos;
+
+ PointToTagPos(pt, out tag, out pos);
+
+ return document.LineTagToCharIndex(tag.line, pos);
+ }
+
+ public int GetLineFromCharIndex(int index) {
+ Line line;
+ LineTag tag;
+ int pos;
+
+ document.CharIndexToLineTag(index, out line, out tag, out pos);
+
+ return line.LineNo - 1;
+ }
+
+ public Point GetPositionFromCharIndex(int index) {
+ Line line;
+ LineTag tag;
+ int pos;
+
+ document.CharIndexToLineTag(index, out line, out tag, out pos);
+
+ return new Point((int)line.widths[pos] + 1, line.Y + 1);
+ }
+
+ public void LoadFile(System.IO.Stream data, RichTextBoxStreamType fileType) {
+ RTF.RTF rtf; // Not 'using SWF.RTF' to avoid ambiguities with font and color
+
+ document.Empty();
+
+ // FIXME - ignoring unicode
+ if (fileType == RichTextBoxStreamType.PlainText) {
+ StringBuilder sb;
+ int count;
+ byte[] buffer;
+
+ try {
+ sb = new StringBuilder((int)data.Length);
+ buffer = new byte[1024];
+ }
+
+ catch {
+ throw new IOException("Not enough memory to load document");
+ }
+
+ count = 0;
+ while (count < data.Length) {
+ count += data.Read(buffer, count, 1024);
+ sb.Append(buffer);
+ }
+ base.Text = sb.ToString();
+ return;
+ }
+
+ InsertRTFFromStream(data, 0, 1);
+ }
+
+ [MonoTODO("Make smarter RTF detection?")]
+ public void LoadFile(string path) {
+ if (path.EndsWith(".rtf")) {
+ LoadFile(path, RichTextBoxStreamType.RichText);
+ } else {
+ LoadFile(path, RichTextBoxStreamType.PlainText);
+ }
+ }
+
+ public void LoadFile(string path, RichTextBoxStreamType fileType) {
+ FileStream data;
+
+ data = null;
+
+ try {
+ data = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 1024);
+ LoadFile(data, fileType);
+ }
+
+ catch {
+ throw new IOException("Could not open file " + path);
+ }
+
+ finally {
+ if (data != null) {
+ data.Close();
+ }
+ }
+ }
+
+ public void Paste(DataFormats.Format clipFormat) {
+ base.Paste(clipFormat, false);
+ }
+
+ [MonoTODO()]
+ public void Redo() {
+ }
+
+ public void SaveFile(Stream data, RichTextBoxStreamType fileType) {
+ Encoding encoding;
+ int i;
+ Byte[] bytes;
+
+
+ if (fileType == RichTextBoxStreamType.UnicodePlainText) {
+ encoding = Encoding.Unicode;
+ } else {
+ encoding = Encoding.ASCII;
+ }
+
+ switch(fileType) {
+ case RichTextBoxStreamType.PlainText:
+ case RichTextBoxStreamType.TextTextOleObjs:
+ case RichTextBoxStreamType.UnicodePlainText: {
+ if (!multiline) {
+ bytes = encoding.GetBytes(document.Root.text.ToString());
+ data.Write(bytes, 0, bytes.Length);
+ return;
+ }
+
+ for (i = 1; i < document.Lines; i++) {
+ bytes = encoding.GetBytes(document.GetLine(i).text.ToString() + Environment.NewLine);
+ data.Write(bytes, 0, bytes.Length);
+ }
+ bytes = encoding.GetBytes(document.GetLine(document.Lines).text.ToString());
+ data.Write(bytes, 0, bytes.Length);
+ return;
+ }
+ }
+
+ // If we're here we're saving RTF
+ Line start_line;
+ Line end_line;
+ StringBuilder rtf;
+ int current;
+ int total;
+
+ start_line = document.GetLine(1);
+ end_line = document.GetLine(document.Lines);
+ rtf = GenerateRTF(start_line, 0, end_line, end_line.text.Length);
+ total = rtf.Length;
+ bytes = new Byte[4096];
+
+ // Let's chunk it so we don't use up all memory...
+ for (i = 0; i < total; i += 1024) {
+ if ((i + 1024) < total) {
+ current = encoding.GetBytes(rtf.ToString(i, 1024), 0, 1024, bytes, 0);
+ } else {
+ current = total - i;
+ current = encoding.GetBytes(rtf.ToString(i, current), 0, current, bytes, 0);
+ }
+ data.Write(bytes, 0, current);
+ }
+ }
+
+ public void SaveFile(string path) {
+ if (path.EndsWith(".rtf")) {
+ SaveFile(path, RichTextBoxStreamType.RichText);
+ } else {
+ SaveFile(path, RichTextBoxStreamType.PlainText);
+ }
+ }
+
+ public void SaveFile(string path, RichTextBoxStreamType fileType) {
+ FileStream data;
+
+ data = null;
+
+// try {
+ data = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None, 1024, false);
+ SaveFile(data, fileType);
+// }
+
+// catch {
+// throw new IOException("Could not write document to file " + path);
+// }
+
+// finally {
+ if (data != null) {
+ data.Close();
+ }
+// }
+ }
+
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected virtual object CreateRichEditOleCallback() {
+ throw new NotImplementedException();
+ }
+
+ protected override void OnBackColorChanged(EventArgs e) {
+ base.OnBackColorChanged (e);
+ }
+
+ protected virtual void OnContentsResized(ContentsResizedEventArgs e) {
+ if (ContentsResized != null) {
+ ContentsResized(this, e);
+ }
+ }
+
+ protected override void OnContextMenuChanged(EventArgs e) {
+ base.OnContextMenuChanged (e);
+ }
+
+ protected override void OnHandleCreated(EventArgs e) {
+ base.OnHandleCreated (e);
+ }
+
+ protected override void OnHandleDestroyed(EventArgs e) {
+ base.OnHandleDestroyed (e);
+ }
+
+ protected virtual void OnHScroll(EventArgs e) {
+ if (HScroll != null) {
+ HScroll(this, e);
+ }
+ }
+
+ [MonoTODO("Determine when to call this")]
+ protected virtual void OnImeChange(EventArgs e) {
+ if (ImeChange != null) {
+ ImeChange(this, e);
+ }
+ }
+
+ protected virtual void OnLinkClicked(LinkClickedEventArgs e) {
+ if (LinkClicked != null) {
+ LinkClicked(this, e);
+ }
+ }
+
+ protected virtual void OnProtected(EventArgs e) {
+ if (Protected != null) {
+ Protected(this, e);
+ }
+ }
+
+ protected override void OnRightToLeftChanged(EventArgs e) {
+ base.OnRightToLeftChanged (e);
+ }
+
+ protected virtual void OnSelectionChanged(EventArgs e) {
+ if (SelectionChanged != null) {
+ SelectionChanged(this, e);
+ }
+ }
+
+ protected override void OnSystemColorsChanged(EventArgs e) {
+ base.OnSystemColorsChanged (e);
+ }
+
+ protected override void OnTextChanged(EventArgs e) {
+ base.OnTextChanged (e);
+ }
+
+ protected virtual void OnVScroll(EventArgs e) {
+ if (VScroll != null) {
+ VScroll(this, e);
+ }
+ }
+
+ protected override void WndProc(ref Message m) {
+ base.WndProc (ref m);
+ }
+ #endregion // Protected Instance Methods
+
+ #region Events
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler BackgroundImageChanged;
+
+ public event ContentsResizedEventHandler ContentsResized;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler DoubleClick;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event DragEventHandler DragDrop {
+ add {
+ base.DragDrop += value;
+ }
+
+ remove {
+ base.DragDrop -= value;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event DragEventHandler DragEnter {
+ add {
+ base.DragEnter += value;
+ }
+
+ remove {
+ base.DragEnter -= value;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler DragLeave {
+ add {
+ base.DragLeave += value;
+ }
+
+ remove {
+ base.DragLeave -= value;
+ }
+ }
+
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event DragEventHandler DragOver {
+ add {
+ base.DragOver += value;
+ }
+
+ remove {
+ base.DragOver -= value;
+ }
+ }
+
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event GiveFeedbackEventHandler GiveFeedback;
+
+ public event EventHandler HScroll;
+ public event EventHandler ImeChange;
+ public event LinkClickedEventHandler LinkClicked;
+ public event EventHandler Protected;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event QueryContinueDragEventHandler QueryContinueDrag;
+ public event EventHandler SelectionChanged;
+ public event EventHandler VScroll;
+ #endregion // Events
+
+ #region Private Methods
+ private void HandleControl(RTF.RTF rtf) {
+ switch(rtf.Major) {
+ case RTF.Major.Unicode: {
+ switch(rtf.Minor) {
+ case Minor.UnicodeCharBytes: {
+ rtf_skip_width = rtf.Param;
+ break;
+ }
+
+ case Minor.UnicodeChar: {
+ rtf_skip_count += rtf_skip_width;
+ rtf_line.Append((char)rtf.Param);
+ break;
+ }
+ }
+ break;
+ }
+
+ case RTF.Major.Destination: {
+ Console.Write("[Got Destination control {0}]", rtf.Minor);
+ rtf.SkipGroup();
+ break;
+ }
+
+ case RTF.Major.CharAttr: {
+ switch(rtf.Minor) {
+ case Minor.ForeColor: {
+ System.Windows.Forms.RTF.Color color;
+
+ color = System.Windows.Forms.RTF.Color.GetColor(rtf, rtf.Param);
+ if (color != null) {
+ FlushText(rtf, false);
+ if (color.Red == -1 && color.Green == -1 && color.Blue == -1) {
+ this.rtf_color = new SolidBrush(ForeColor);
+ } else {
+ this.rtf_color = new SolidBrush(Color.FromArgb(color.Red, color.Green, color.Blue));
+ }
+ }
+ break;
+ }
+
+ case Minor.FontSize: {
+ FlushText(rtf, false);
+ this.rtf_rtffont_size = rtf.Param / 2;
+ break;
+ }
+
+ case Minor.FontNum: {
+ System.Windows.Forms.RTF.Font font;
+
+ font = System.Windows.Forms.RTF.Font.GetFont(rtf, rtf.Param);
+ if (font != null) {
+ FlushText(rtf, false);
+ this.rtf_rtffont = font;
+ }
+ break;
+ }
+
+ case Minor.Plain: {
+ FlushText(rtf, false);
+ rtf_rtfstyle = FontStyle.Regular;
+ break;
+ }
+
+ case Minor.Bold: {
+ FlushText(rtf, false);
+ if (rtf.Param == RTF.RTF.NoParam) {
+ rtf_rtfstyle |= FontStyle.Bold;
+ } else {
+ rtf_rtfstyle &= ~FontStyle.Bold;
+ }
+ break;
+ }
+
+ case Minor.Italic: {
+ FlushText(rtf, false);
+ if (rtf.Param == RTF.RTF.NoParam) {
+ rtf_rtfstyle |= FontStyle.Italic;
+ } else {
+ rtf_rtfstyle &= ~FontStyle.Italic;
+ }
+ break;
+ }
+
+ case Minor.StrikeThru: {
+ FlushText(rtf, false);
+ if (rtf.Param == RTF.RTF.NoParam) {
+ rtf_rtfstyle |= FontStyle.Strikeout;
+ } else {
+ rtf_rtfstyle &= ~FontStyle.Strikeout;
+ }
+ break;
+ }
+
+ case Minor.Underline: {
+ FlushText(rtf, false);
+ if (rtf.Param == RTF.RTF.NoParam) {
+ rtf_rtfstyle |= FontStyle.Underline;
+ } else {
+ rtf_rtfstyle = rtf_rtfstyle & ~FontStyle.Underline;
+ }
+ break;
+ }
+
+ case Minor.NoUnderline: {
+ FlushText(rtf, false);
+ rtf_rtfstyle &= ~FontStyle.Underline;
+ break;
+ }
+ }
+ break;
+ }
+
+ case RTF.Major.SpecialChar: {
+ Console.Write("[Got SpecialChar control {0}]", rtf.Minor);
+ SpecialChar(rtf);
+ break;
+ }
+ }
+ }
+
+ private void SpecialChar(RTF.RTF rtf) {
+ switch(rtf.Minor) {
+ case Minor.Page:
+ case Minor.Sect:
+ case Minor.Row:
+ case Minor.Line:
+ case Minor.Par: {
+ FlushText(rtf, true);
+ break;
+ }
+
+ case Minor.Cell: {
+ Console.Write(" ");
+ break;
+ }
+
+ case Minor.NoBrkSpace: {
+ Console.Write(" ");
+ break;
+ }
+
+ case Minor.Tab: {
+ Console.Write("\t");
+ break;
+ }
+
+ case Minor.NoBrkHyphen: {
+ Console.Write("-");
+ break;
+ }
+
+ case Minor.Bullet: {
+ Console.Write("*");
+ break;
+ }
+
+ case Minor.EmDash: {
+ Console.Write("—");
+ break;
+ }
+
+ case Minor.EnDash: {
+ Console.Write("–");
+ break;
+ }
+
+ case Minor.LQuote: {
+ Console.Write("‘");
+ break;
+ }
+
+ case Minor.RQuote: {
+ Console.Write("’");
+ break;
+ }
+
+ case Minor.LDblQuote: {
+ Console.Write("“");
+ break;
+ }
+
+ case Minor.RDblQuote: {
+ Console.Write("”");
+ break;
+ }
+
+ default: {
+ rtf.SkipGroup();
+ break;
+ }
+ }
+ }
+
+ private void HandleText(RTF.RTF rtf) {
+ if (rtf_skip_count > 0) {
+ rtf_skip_count--;
+ return;
+ }
+
+ if ((RTF.StandardCharCode)rtf.Minor != RTF.StandardCharCode.nothing) {
+ rtf_line.Append(rtf_text_map[(RTF.StandardCharCode)rtf.Minor]);
+ } else {
+ if ((int)rtf.Major > 31 && (int)rtf.Major < 128) {
+ rtf_line.Append((char)rtf.Major);
+ } else {
+ //rtf_line.Append((char)rtf.Major);
+ Console.Write("[Literal:0x{0:X2}]", (int)rtf.Major);
+ }
+ }
+ }
+
+ private void FlushText(RTF.RTF rtf, bool newline) {
+ int length;
+ Font font;
+
+ length = rtf_line.Length;
+ if (!newline && (length == 0)) {
+ return;
+ }
+
+ if (rtf_rtffont == null) {
+ // First font in table is default
+ rtf_rtffont = System.Windows.Forms.RTF.Font.GetFont(rtf, 0);
+ }
+
+ font = new Font(rtf_rtffont.Name, rtf_rtffont_size, rtf_rtfstyle);
+
+ if (rtf_color == null) {
+ System.Windows.Forms.RTF.Color color;
+
+ // First color in table is default
+ color = System.Windows.Forms.RTF.Color.GetColor(rtf, 0);
+
+ if ((color == null) || (color.Red == -1 && color.Green == -1 && color.Blue == -1)) {
+ rtf_color = new SolidBrush(ForeColor);
+ } else {
+ rtf_color = new SolidBrush(Color.FromArgb(color.Red, color.Green, color.Blue));
+ }
+ }
+
+ rtf_chars += rtf_line.Length;
+
+ if (rtf_cursor_x == 0) {
+ document.Add(rtf_cursor_y, rtf_line.ToString(), rtf_rtfalign, font, rtf_color);
+ } else {
+ Line line;
+
+ line = document.GetLine(rtf_cursor_y);
+ if (rtf_line.Length > 0) {
+ document.InsertString(line, rtf_cursor_x, rtf_line.ToString());
+ document.FormatText(line, rtf_cursor_x + 1, line, rtf_cursor_x + 1 + length, font, rtf_color); // FormatText is 1-based
+ }
+ if (newline) {
+ document.Split(line, rtf_cursor_x + length);
+ }
+ }
+
+ if (newline) {
+ rtf_cursor_x = 0;
+ rtf_cursor_y++;
+ } else {
+ rtf_cursor_x += length;
+ }
+ rtf_line.Length = 0; // Empty line
+ }
+
+ private void InsertRTFFromStream(Stream data, int cursor_x, int cursor_y) {
+ int x;
+ int y;
+ int chars;
+
+ InsertRTFFromStream(data, cursor_x, cursor_y, out x, out y, out chars);
+ }
+
+ private void InsertRTFFromStream(Stream data, int cursor_x, int cursor_y, out int to_x, out int to_y, out int chars) {
+ RTF.RTF rtf;
+
+ rtf = new RTF.RTF(data);
+
+ // Prepare
+ rtf.ClassCallback[RTF.TokenClass.Text] = new RTF.ClassDelegate(HandleText);
+ rtf.ClassCallback[RTF.TokenClass.Control] = new RTF.ClassDelegate(HandleControl);
+
+ rtf_skip_width = 0;
+ rtf_skip_count = 0;
+ rtf_line = new StringBuilder();
+ rtf_color = null;
+ rtf_rtffont_size = (int)this.Font.Size;
+ rtf_rtfalign = HorizontalAlignment.Left;
+ rtf_rtfstyle = FontStyle.Regular;
+ rtf_rtffont = null;
+ rtf_cursor_x = cursor_x;
+ rtf_cursor_y = cursor_y;
+ rtf_chars = 0;
+ rtf.DefaultFont(this.Font.Name);
+
+ rtf_text_map = new RTF.TextMap();
+ RTF.TextMap.SetupStandardTable(rtf_text_map.Table);
+
+ document.NoRecalc = true;
+
+ try {
+ rtf.Read(); // That's it
+ FlushText(rtf, false);
+ }
+
+ catch (RTF.RTFException) {
+ // Seems to be plain text...
+
+ }
+
+ to_x = rtf_cursor_x;
+ to_y = rtf_cursor_y;
+ chars = rtf_chars;
+
+ document.RecalculateDocument(CreateGraphicsInternal(), cursor_y, document.Lines, false);
+ document.NoRecalc = false;
+
+ document.Invalidate(document.GetLine(cursor_y), 0, document.GetLine(document.Lines), -1);
+ }
+
+ private void RichTextBox_HScrolled(object sender, EventArgs e) {
+ OnHScroll(e);
+ }
+
+ private void RichTextBox_VScrolled(object sender, EventArgs e) {
+ OnVScroll(e);
+ }
+
+ private void PointToTagPos(Point pt, out LineTag tag, out int pos) {
+ Point p;
+
+ p = pt;
+
+ if (p.X >= document.ViewPortWidth) {
+ p.X = document.ViewPortWidth - 1;
+ } else if (p.X < 0) {
+ p.X = 0;
+ }
+
+ if (p.Y >= document.ViewPortHeight) {
+ p.Y = document.ViewPortHeight - 1;
+ } else if (p.Y < 0) {
+ p.Y = 0;
+ }
+
+ tag = document.FindCursor(p.X + document.ViewPortX, p.Y + document.ViewPortY, out pos);
+ }
+
+ private void EmitRTFFontProperties(StringBuilder rtf, int prev_index, int font_index, Font prev_font, Font font) {
+ if (prev_index != font_index) {
+ rtf.Append(String.Format("\\f{0}", font_index)); // Font table entry
+ }
+
+ if ((prev_font == null) || (prev_font.Size != font.Size)) {
+ rtf.Append(String.Format("\\fs{0}", (int)(font.Size * 2))); // Font size
+ }
+
+ if ((prev_font == null) || (font.Bold != prev_font.Bold)) {
+ if (font.Bold) {
+ rtf.Append("\\b");
+ } else {
+ if (prev_font != null) {
+ rtf.Append("\\b0");
+ }
+ }
+ }
+
+ if ((prev_font == null) || (font.Italic != prev_font.Italic)) {
+ if (font.Italic) {
+ rtf.Append("\\i");
+ } else {
+ if (prev_font != null) {
+ rtf.Append("\\i0");
+ }
+ }
+ }
+
+ if ((prev_font == null) || (font.Strikeout != prev_font.Strikeout)) {
+ if (font.Strikeout) {
+ rtf.Append("\\strike");
+ } else {
+ if (prev_font != null) {
+ rtf.Append("\\strike0");
+ }
+ }
+ }
+
+ if ((prev_font == null) || (font.Underline != prev_font.Underline)) {
+ if (font.Underline) {
+ rtf.Append("\\ul");
+ } else {
+ if (prev_font != null) {
+ rtf.Append("\\ul0");
+ }
+ }
+ }
+ }
+
+ [MonoTODO("Emit unicode and other special characters properly")]
+ private void EmitRTFText(StringBuilder rtf, string text) {
+ rtf.Append(text);
+ }
+
+ // start_pos and end_pos are 0-based
+ private StringBuilder GenerateRTF(Line start_line, int start_pos, Line end_line, int end_pos) {
+ StringBuilder sb;
+ ArrayList fonts;
+ ArrayList colors;
+ Color color;
+ Font font;
+ Line line;
+ LineTag tag;
+ int pos;
+ int line_no;
+ int line_len;
+ int i;
+ int length;
+
+ sb = new StringBuilder();
+ fonts = new ArrayList(10);
+ colors = new ArrayList(10);
+
+ // Two runs, first we parse to determine tables;
+ // and unlike most of our processing here we work on tags
+
+ line = start_line;
+ line_no = start_line.line_no;
+ pos = start_pos;
+
+ // Add default font and color; to optimize document content we don't
+ // use this.Font and this.ForeColor but the font/color from the first tag
+ tag = LineTag.FindTag(start_line, pos);
+ font = tag.font;
+ color = ((SolidBrush)tag.color).Color;
+ fonts.Add(font.Name);
+ colors.Add(color);
+
+ while (line_no <= end_line.line_no) {
+ line = document.GetLine(line_no);
+ tag = LineTag.FindTag(line, pos);
+
+ if (line_no != end_line.line_no) {
+ line_len = line.text.Length;
+ } else {
+ line_len = end_pos;
+ }
+
+ while (pos < line_len) {
+ if (tag.font.Name != font.Name) {
+ font = tag.font;
+ if (!fonts.Contains(font.Name)) {
+ fonts.Add(font.Name);
+ }
+ }
+
+ if (((SolidBrush)tag.color).Color != color) {
+ color = ((SolidBrush)tag.color).Color;
+ if (!colors.Contains(color)) {
+ colors.Add(color);
+ }
+ }
+
+ pos = tag.start + tag.length - 1;
+ tag = tag.next;
+ }
+ pos = 0;
+ line_no++;
+ }
+
+ // We have the tables, emit the header
+ sb.Append("{\\rtf1\\ansi");
+ sb.Append("\\ansicpg1252"); // FIXME - is this correct?
+
+ // Default Font
+ sb.Append(String.Format("\\deff{0}", fonts.IndexOf(this.Font.Name)));
+
+ // Default Language
+ sb.Append("\\deflang1033\n"); // FIXME - always 1033?
+
+ // Emit the font table
+ sb.Append("{\\fonttbl");
+ for (i = 0; i < fonts.Count; i++) {
+ sb.Append(String.Format("{{\\f{0}", i)); // {Font
+ sb.Append("\\fnil"); // Family
+ sb.Append("\\fcharset0 "); // Charset ANSI<space>
+ sb.Append((string)fonts[i]); // Font name
+ sb.Append(";}"); // }
+ }
+ sb.Append("}\n");
+
+ // Emit the color table (if needed)
+ if ((colors.Count > 1) || ((((Color)colors[0]).R != this.ForeColor.R) || (((Color)colors[0]).G != this.ForeColor.G) || (((Color)colors[0]).B != this.ForeColor.B))) {
+ sb.Append("{\\colortbl "); // Header and NO! default color
+ for (i = 0; i < colors.Count; i++) {
+ sb.Append(String.Format("\\red{0}", ((Color)colors[i]).R));
+ sb.Append(String.Format("\\green{0}", ((Color)colors[i]).G));
+ sb.Append(String.Format("\\blue{0}", ((Color)colors[i]).B));
+ sb.Append(";");
+ }
+ sb.Append("}\n");
+ }
+
+ sb.Append("{\\*\\generator Mono RichTextBox;}");
+ // Emit initial paragraph settings
+ tag = LineTag.FindTag(start_line, start_pos);
+ sb.Append("\\pard"); // Reset to default paragraph properties
+ EmitRTFFontProperties(sb, -1, fonts.IndexOf(tag.font.Name), null, tag.font); // Font properties
+ sb.Append(" "); // Space separator
+
+ font = tag.font;
+ color = (Color)colors[0];
+ line = start_line;
+ line_no = start_line.line_no;
+ pos = start_pos;
+
+ while (line_no <= end_line.line_no) {
+ line = document.GetLine(line_no);
+ tag = LineTag.FindTag(line, pos);
+
+ if (line_no != end_line.line_no) {
+ line_len = line.text.Length;
+ } else {
+ line_len = end_pos;
+ }
+
+ while (pos < line_len) {
+ length = sb.Length;
+
+ if (tag.font != font) {
+ EmitRTFFontProperties(sb, fonts.IndexOf(font.Name), fonts.IndexOf(tag.font.Name), font, tag.font);
+ font = tag.font;
+ }
+
+ if (((SolidBrush)tag.color).Color != color) {
+ color = ((SolidBrush)tag.color).Color;
+ sb.Append(String.Format("\\cf{0}", colors.IndexOf(color)));
+ }
+ if (length != sb.Length) {
+ sb.Append(" "); // Emit space to separate keywords from text
+ }
+
+ // Emit the string itself
+ if (line_no != end_line.line_no) {
+ EmitRTFText(sb, tag.line.text.ToString(pos, tag.start + tag.length - pos - 1));
+ } else {
+ if (end_pos < (tag.start + tag.length - 1)) {
+ // Emit partial tag only, end_pos is inside this tag
+ EmitRTFText(sb, tag.line.text.ToString(pos, end_pos - pos));
+ } else {
+ EmitRTFText(sb, tag.line.text.ToString(pos, tag.start + tag.length - pos - 1));
+ }
+ }
+
+ pos = tag.start + tag.length - 1;
+ tag = tag.next;
+ }
+ if (pos >= line.text.Length) {
+ if (!line.soft_break) {
+ sb.Append("\\par\n");
+ }
+ }
+ pos = 0;
+ line_no++;
+ }
+
+ sb.Append("}\n");
+
+ return sb;
+ }
+ #endregion // Private Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxFinds.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxFinds.cs
new file mode 100644
index 00000000000..a6a93d0b56a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxFinds.cs
@@ -0,0 +1,38 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok <pbartok@novell.com>
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ [Flags]
+ public enum RichTextBoxFinds {
+ None = 0x00000000,
+ WholeWord = 0x00000002,
+ MatchCase = 0x00000004,
+ NoHighlight = 0x00000008,
+ Reverse = 0x00000010,
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxScrollBars.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxScrollBars.cs
new file mode 100644
index 00000000000..a26e2346540
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxScrollBars.cs
@@ -0,0 +1,39 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok <pbartok@novell.com>
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum RichTextBoxScrollBars {
+ None = 0,
+ Horizontal = 1,
+ Vertical = 2,
+ Both = 3,
+ ForcedHorizontal= 17,
+ ForcedVertical = 18,
+ ForcedBoth = 19
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxSelectionAttribute.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxSelectionAttribute.cs
new file mode 100644
index 00000000000..80d78eeadf0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxSelectionAttribute.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok <pbartok@novell.com>
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum RichTextBoxSelectionAttribute {
+ None = 0,
+ All = 1,
+ Mixed = -1,
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxSelectionTypes.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxSelectionTypes.cs
new file mode 100644
index 00000000000..34d80eb32e4
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxSelectionTypes.cs
@@ -0,0 +1,38 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok <pbartok@novell.com>
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ [Flags]
+ public enum RichTextBoxSelectionTypes {
+ Empty = 0x00000000,
+ Text = 0x00000001,
+ Object = 0x00000002,
+ MultiChar = 0x00000004,
+ MultiObject = 0x00000008
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxStreamType.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxStreamType.cs
new file mode 100644
index 00000000000..2b9a7198bad
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxStreamType.cs
@@ -0,0 +1,37 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok <pbartok@novell.com>
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum RichTextBoxStreamType {
+ RichText = 0,
+ PlainText = 1,
+ RichNoOleObjs = 2,
+ TextTextOleObjs = 3,
+ UnicodePlainText= 4
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxWordPunctuations.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxWordPunctuations.cs
new file mode 100644
index 00000000000..a6a97dadb8d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBoxWordPunctuations.cs
@@ -0,0 +1,36 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok <pbartok@novell.com>
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum RichTextBoxWordPunctuations {
+ Level1 = 128,
+ Level2 = 256,
+ Custom = 512,
+ All = 896
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RightToLeft.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RightToLeft.cs
new file mode 100644
index 00000000000..05afe1bcdee
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RightToLeft.cs
@@ -0,0 +1,36 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum RightToLeft {
+ No = 0,
+ Yes = 1,
+ Inherit = 2
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RowStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RowStyle.cs
new file mode 100644
index 00000000000..c8e4ba1d120
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RowStyle.cs
@@ -0,0 +1,58 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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:
+// Miguel de Icaza (miguel@gnome.org)
+//
+// (C) 2004 Novell, Inc.
+//
+#if NET_2_0
+namespace System.Windows.Forms {
+
+ public class RowStyle : TableLayoutSettings.Style {
+ float height;
+
+ public RowStyle ()
+ {
+ }
+
+ public RowStyle (SizeType st)
+ {
+ size_type = st;
+ }
+
+ public RowStyle (SizeType st, float height)
+ {
+ size_type = st;
+ this.height = height;
+ }
+
+ public float Height {
+ get {
+ return height;
+ }
+
+ set {
+ height = value;
+ }
+ }
+ }
+}
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SWF.csproj.user b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SWF.csproj.user
new file mode 100644
index 00000000000..412fc047288
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SWF.csproj.user
@@ -0,0 +1,48 @@
+<VisualStudioProject>
+ <CSHARP LastOpenVersion = "7.10.3077" >
+ <Build>
+ <Settings ReferencePath = "" >
+ <Config
+ Name = "Debug"
+ EnableASPDebugging = "false"
+ EnableASPXDebugging = "false"
+ EnableUnmanagedDebugging = "false"
+ EnableSQLServerDebugging = "false"
+ RemoteDebugEnabled = "false"
+ RemoteDebugMachine = ""
+ StartAction = "Project"
+ StartArguments = ""
+ StartPage = ""
+ StartProgram = ""
+ StartURL = ""
+ StartWorkingDirectory = ""
+ StartWithIE = "true"
+ />
+ <Config
+ Name = "Release"
+ EnableASPDebugging = "false"
+ EnableASPXDebugging = "false"
+ EnableUnmanagedDebugging = "false"
+ EnableSQLServerDebugging = "false"
+ RemoteDebugEnabled = "false"
+ RemoteDebugMachine = ""
+ StartAction = "Project"
+ StartArguments = ""
+ StartPage = ""
+ StartProgram = ""
+ StartURL = ""
+ StartWorkingDirectory = ""
+ StartWithIE = "false"
+ />
+ </Settings>
+ </Build>
+ <OtherProjectSettings
+ CopyProjectDestinationFolder = ""
+ CopyProjectUncPath = ""
+ CopyProjectOption = "0"
+ ProjectView = "ProjectFiles"
+ ProjectTrust = "0"
+ />
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SaveFileDialog.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SaveFileDialog.cs
new file mode 100644
index 00000000000..aab1835724e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SaveFileDialog.cs
@@ -0,0 +1,102 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+//
+// Alexander Olk xenomorph2@onlinehome.de
+//
+
+// NOT COMPLETE - work in progress
+
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.IO;
+
+namespace System.Windows.Forms {
+ [Designer ("System.Windows.Forms.Design.SaveFileDialogDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ public sealed class SaveFileDialog : FileDialog {
+ #region Public Constructors
+ public SaveFileDialog ()
+ {
+ form.SuspendLayout ();
+
+ form.Text = "Save";
+
+ OpenSaveButtonText = "Save";
+ SearchSaveLabel = "Save in:";
+ fileDialogType = FileDialogType.SaveFileDialog;
+
+ form.ResumeLayout (false);
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ [DefaultValue(false)]
+ public new bool CreatePrompt {
+ set {
+ createPrompt = value;
+ }
+
+ get {
+ return createPrompt;
+ }
+ }
+
+ [DefaultValue(true)]
+ public new bool OverwritePrompt {
+ set {
+ overwritePrompt = value;
+ }
+
+ get {
+ return overwritePrompt;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public Stream OpenFile ()
+ {
+ if (FileName == null)
+ throw new ArgumentNullException ("OpenFile", "FileName is null");
+
+ Stream retValue;
+
+ try {
+ retValue = new FileStream (FileName, FileMode.Create, FileAccess.ReadWrite);
+ } catch (Exception ex) {
+ retValue = null;
+ }
+
+ return retValue;
+ }
+ #endregion // Public Instance Methods
+
+ public override void Reset ()
+ {
+ base.Reset ();
+ overwritePrompt = true;
+ createPrompt = false;
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Screen.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Screen.cs
new file mode 100644
index 00000000000..9e2ccb97f53
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Screen.cs
@@ -0,0 +1,181 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+// NOTE: We made a concious decision to have only a single 'screen'
+// due to the differences in platforms. On Win32 we could gather
+// all information, but not for X11 (and possibly Mac). So for now
+// we'll stick with a single screen, but the functions are still
+// written to support multiple screens, simply beef up the all_screens
+// assignment to get multiples
+// To support multiples, we need to use GetMonitorInfo API on Win32
+
+using System;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+ public class Screen {
+ #region Local Variables
+ private static Screen[] all_screens = { new Screen(true, "Mono MWF Primary Display", SystemInformation.VirtualScreen, SystemInformation.WorkingArea) };
+ private bool primary;
+ private Rectangle bounds;
+ private Rectangle workarea;
+ private string name;
+
+ #endregion // Local Variables
+
+ #region Constructors
+ private Screen() {
+ this.primary = true;
+ this.bounds = SystemInformation.WorkingArea;
+ }
+
+ private Screen(bool primary, string name, Rectangle bounds, Rectangle workarea) {
+ this.primary = primary;
+ this.name = name;
+ this.bounds = bounds;
+ this.workarea = workarea;
+ }
+ #endregion // Constructors
+
+ #region Public Static Properties
+ public static Screen[] AllScreens {
+ get {
+ return all_screens;
+ }
+ }
+
+ public static Screen PrimaryScreen {
+ get {
+ return all_screens[0];
+ }
+ }
+ #endregion // Public Static Properties
+
+ #region Public Instance Properties
+ public Rectangle Bounds {
+ get {
+ return this.bounds;
+ }
+ }
+
+ public string DeviceName {
+ get {
+ return this.name;
+ }
+ }
+
+ public bool Primary {
+ get {
+ return this.primary;
+ }
+ }
+
+ public Rectangle WorkingArea {
+ get {
+ return this.workarea;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Static Methods
+ public static Screen FromControl(Control control) {
+ return Screen.FromPoint(control.Location);
+ }
+
+ public static Screen FromHandle(IntPtr hwnd) {
+ Control control;
+
+ control = Control.FromHandle(hwnd);
+ if (control != null) {
+ return Screen.FromPoint(control.Location);
+ }
+ return Screen.PrimaryScreen;
+ }
+
+ public static Screen FromPoint(Point point) {
+ for (int i = 0; i < all_screens.Length; i++) {
+ if (all_screens[i].Bounds.Contains(point)) {
+ return all_screens[i];
+ }
+ }
+ return Screen.PrimaryScreen;
+ }
+
+ public static Screen FromRectangle(Rectangle rect) {
+ return Screen.FromPoint(new Point(rect.Left, rect.Top));
+ }
+
+ public static Rectangle GetBounds(Control ctl) {
+ return Screen.FromControl(ctl).Bounds;
+ }
+
+ public static Rectangle GetBounds(Point pt) {
+ return Screen.FromPoint(pt).Bounds;
+ }
+
+ public static Rectangle GetBounds(Rectangle rect) {
+ return Screen.FromRectangle(rect).Bounds;
+ }
+
+ public static Rectangle GetWorkingArea(Control ctl) {
+ return Screen.FromControl(ctl).WorkingArea;
+ }
+
+ public static Rectangle GetWorkingArea(Point pt) {
+ return Screen.FromPoint(pt).WorkingArea;
+ }
+
+ public static Rectangle GetWorkingArea(Rectangle rect) {
+ return Screen.FromRectangle(rect).WorkingArea;
+ }
+ #endregion // Public Static Methods
+
+ #region Public Instance Methods
+ public override bool Equals(object obj) {
+ if (obj is Screen) {
+ Screen s = (Screen)obj;
+
+ if (name.Equals(s.name) && (primary == s.primary) && (bounds.Equals(s.Bounds)) && (workarea.Equals(s.workarea))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public override int GetHashCode() {
+ return base.GetHashCode ();
+ }
+
+ public override string ToString() {
+ return "Screen[Bounds={" + this.Bounds + "} WorkingArea={" + this.WorkingArea + "} Primary={" + this.Primary + "} DeviceName=" + this.DeviceName;
+ }
+
+
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollBar.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollBar.cs
new file mode 100644
index 00000000000..0c62db18487
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollBar.cs
@@ -0,0 +1,1229 @@
+//
+// System.Windows.Forms.ScrollBar.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005, Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez jordi@ximian.com
+//
+//
+
+// COMPLETE
+
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Drawing.Drawing2D;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+ [DefaultEvent ("Scroll")]
+ [DefaultProperty ("Value")]
+ public abstract class ScrollBar : Control
+ {
+ #region Local Variables
+ private int position;
+ private int minimum;
+ private int maximum;
+ private int large_change;
+ private int small_change;
+ internal int scrollbutton_height;
+ internal int scrollbutton_width;
+ private ScrollBars type;
+ private Rectangle first_arrow_area = new Rectangle (); // up or left
+ private Rectangle second_arrow_area = new Rectangle (); // down or right
+ private Rectangle thumb_pos = new Rectangle ();
+ private Rectangle thumb_area = new Rectangle ();
+ internal ButtonState firstbutton_state = ButtonState.Normal;
+ internal ButtonState secondbutton_state = ButtonState.Normal;
+ private bool firstbutton_pressed = false;
+ private bool secondbutton_pressed = false;
+ private bool thumb_pressed = false;
+ private float pixel_per_pos = 0;
+ private Timer timer = new Timer ();
+ private TimerType timer_type;
+ private int thumb_pixel_click_move;
+ private int thumb_pixel_click_move_prev;
+ private int thumb_size = 40;
+ private const int thumb_min_size = 8;
+ private const int thumb_notshown_size = 40;
+ internal bool vert;
+ private int lastclick_pos; // Position of the last button-down event
+ private int lastclick_pos_thumb; // Position of the last button-down event relative to the thumb
+ private bool outside_thumbarea_right = false;
+ private bool outside_thumbarea_left = false;
+
+ private Rectangle dirty;
+
+ internal ThumbMoving thumb_moving = ThumbMoving.None;
+ #endregion // Local Variables
+
+ private enum TimerType
+ {
+ HoldButton,
+ RepeatButton,
+ HoldThumbArea,
+ RepeatThumbArea
+ }
+
+ internal enum ThumbMoving
+ {
+ None,
+ Forward,
+ Backwards,
+ }
+
+ #region events
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler BackColorChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler BackgroundImageChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler Click;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler DoubleClick;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler FontChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler ForeColorChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler ImeModeChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event MouseEventHandler MouseDown;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event MouseEventHandler MouseMove;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event MouseEventHandler MouseUp;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event PaintEventHandler Paint;
+
+ public event ScrollEventHandler Scroll;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler TextChanged;
+
+ public event EventHandler ValueChanged;
+ #endregion Events
+
+ public ScrollBar ()
+ {
+ position = 0;
+ minimum = 0;
+ maximum = 100;
+ large_change = 10;
+ small_change = 1;
+
+ timer.Tick += new EventHandler (OnTimer);
+ base.KeyDown += new KeyEventHandler (OnKeyDownSB);
+ base.MouseDown += new MouseEventHandler (OnMouseDownSB);
+ base.MouseUp += new MouseEventHandler (OnMouseUpSB);
+ base.MouseMove += new MouseEventHandler (OnMouseMoveSB);
+ base.Resize += new EventHandler (OnResizeSB);
+ base.TabStop = false;
+ base.cursor = Cursors.Default;
+
+ SetStyle (ControlStyles.UserPaint | ControlStyles.StandardClick, false);
+ }
+
+ #region Internal & Private Properties
+ internal Rectangle FirstArrowArea {
+ get {
+ return this.first_arrow_area;
+ }
+
+ set {
+ this.first_arrow_area = value;
+ }
+ }
+
+ internal Rectangle SecondArrowArea {
+ get {
+ return this.second_arrow_area;
+ }
+
+ set {
+ this.second_arrow_area = value;
+ }
+ }
+
+ internal Rectangle ThumbPos {
+ get {
+ return thumb_pos;
+ }
+
+ set {
+ thumb_pos = value;
+ }
+ }
+ #endregion // Internal & Private Properties
+
+ #region Public Properties
+
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Browsable (false)]
+ public override Color BackColor
+ {
+ get { return base.BackColor; }
+ set {
+ if (base.BackColor == value)
+ return;
+
+ if (BackColorChanged != null)
+ BackColorChanged (this, EventArgs.Empty);
+
+ base.BackColor = value;
+ Refresh ();
+ }
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Browsable (false)]
+ public override Image BackgroundImage
+ {
+ get { return base.BackgroundImage; }
+ set {
+ if (base.BackgroundImage == value)
+ return;
+
+ if (BackgroundImageChanged != null)
+ BackgroundImageChanged (this, EventArgs.Empty);
+
+ base.BackgroundImage = value;
+ }
+ }
+
+ protected override CreateParams CreateParams
+ {
+ get { return base.CreateParams; }
+ }
+
+ protected override ImeMode DefaultImeMode
+ {
+ get { return ImeMode.Disable; }
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Browsable (false)]
+ public override Font Font
+ {
+ get { return base.Font; }
+ set {
+ if (base.Font.Equals (value))
+ return;
+
+ if (FontChanged != null)
+ FontChanged (this, EventArgs.Empty);
+
+ base.Font = value;
+ }
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Browsable (false)]
+ public override Color ForeColor
+ {
+ get { return base.ForeColor; }
+ set {
+ if (base.ForeColor == value)
+ return;
+
+ if (ForeColorChanged != null)
+ ForeColorChanged (this, EventArgs.Empty);
+
+ base.ForeColor = value;
+ Refresh ();
+ }
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Browsable (false)]
+ public new ImeMode ImeMode
+ {
+ get { return base.ImeMode; }
+ set {
+ if (base.ImeMode == value)
+ return;
+
+ if (ImeModeChanged != null)
+ ImeModeChanged (this, EventArgs.Empty);
+
+ base.ImeMode = value;
+ }
+ }
+
+ [DefaultValue (10)]
+ [RefreshProperties(RefreshProperties.Repaint)]
+ [MWFDescription("Scroll amount when clicking in the scroll area"), MWFCategory("Behaviour")]
+ public int LargeChange {
+ get {
+ if (large_change > maximum)
+ return (maximum + 1);
+ else
+ return large_change;
+ }
+ set {
+ if (value < 0)
+ throw new Exception( string.Format("Value '{0}' must be greater than or equal to 0.", value));
+
+ if (large_change != value) {
+ large_change = value;
+
+ // thumb area depends on large change value,
+ // so we need to recalculate it.
+ CalcThumbArea ();
+ UpdatePos (Value, true);
+ Refresh ();
+ }
+ }
+ }
+
+ [DefaultValue (100)]
+ [RefreshProperties(RefreshProperties.Repaint)]
+ [MWFDescription("Highest value for scrollbar"), MWFCategory("Behaviour")]
+ public int Maximum {
+ get { return maximum; }
+ set {
+ if (maximum == value)
+ return;
+
+ maximum = value;
+
+ if (maximum < minimum)
+ minimum = maximum;
+
+ // thumb area depends on maximum value,
+ // so we need to recalculate it.
+ CalcThumbArea ();
+ UpdatePos (Value, true);
+ Refresh ();
+ }
+ }
+
+ [DefaultValue (0)]
+ [RefreshProperties(RefreshProperties.Repaint)]
+ [MWFDescription("Smallest value for scrollbar"), MWFCategory("Behaviour")]
+ public int Minimum {
+ get { return minimum; }
+ set {
+ if (minimum == value)
+ return;
+
+ minimum = value;
+
+ if (minimum > maximum)
+ maximum = minimum;
+
+ // thumb area depends on minimum value,
+ // so we need to recalculate it.
+ CalcThumbArea ();
+ UpdatePos (Value, true);
+ Refresh ();
+ }
+ }
+
+ [DefaultValue (1)]
+ [MWFDescription("Scroll amount when clicking scroll arrows"), MWFCategory("Behaviour")]
+ public int SmallChange {
+ get { return small_change; }
+ set {
+ if ( value < 0 )
+ throw new Exception( string.Format("Value '{0}' must be greater than or equal to 0.", value));
+
+ if (small_change != value) {
+ small_change = value;
+ UpdatePos (Value, true);
+ Refresh ();
+ }
+ }
+ }
+
+ [DefaultValue (false)]
+ public new bool TabStop {
+ get { return base.TabStop; }
+ set { base.TabStop = value; }
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Bindable (false)]
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public override string Text {
+ get { return base.Text; }
+ set { base.Text = value; }
+ }
+
+ [Bindable(true)]
+ [DefaultValue (0)]
+ [MWFDescription("Current value for scrollbar"), MWFCategory("Behaviour")]
+ public int Value {
+ get { return position; }
+ set {
+ if ( value < minimum || value > maximum )
+ throw new ArgumentException(
+ string.Format("'{0}' is not a valid value for 'Value'. 'Value' should be between 'Minimum' and 'Maximum'", value));
+
+ if (position != value){
+ position = value;
+
+ OnValueChanged (EventArgs.Empty);
+
+ ClearDirty ();
+
+ if (IsHandleCreated) {
+ UpdateThumbPos (thumb_area.Y + (int)(((float)(position - minimum)) * pixel_per_pos), false);
+ }
+
+ InvalidateDirty ();
+ }
+ }
+ }
+
+ #endregion //Public Properties
+
+ #region Public Methods
+
+ protected override void OnEnabledChanged (EventArgs e)
+ {
+ base.OnEnabledChanged (e);
+
+ if (Enabled)
+ firstbutton_state = secondbutton_state = ButtonState.Normal;
+ else
+ firstbutton_state = secondbutton_state = ButtonState.Inactive;
+
+ Refresh ();
+ }
+
+ protected override void OnHandleCreated (System.EventArgs e)
+ {
+ base.OnHandleCreated (e);
+
+ CalcButtonSizes ();
+ CalcThumbArea ();
+ UpdateThumbPos (thumb_area.Y + (int)(((float)(position - minimum)) * pixel_per_pos), false);
+ }
+
+ protected virtual void OnScroll (ScrollEventArgs event_args)
+ {
+ if (Scroll == null)
+ return;
+
+ if (event_args.NewValue < Minimum) {
+ event_args.NewValue = Minimum;
+ }
+
+ if (event_args.NewValue > Maximum) {
+ event_args.NewValue = Maximum;
+ }
+
+ Scroll (this, event_args);
+ }
+
+ protected virtual void OnValueChanged (EventArgs e)
+ {
+ if (ValueChanged != null)
+ ValueChanged (this, e);
+ }
+
+ public override string ToString()
+ {
+ return string.Format("{0}, Minimum: {1}, Maximum: {2}, Value: {3}",
+ GetType( ).FullName.ToString( ), minimum, maximum, position);
+ }
+
+ protected void UpdateScrollInfo ()
+ {
+ Refresh ();
+ }
+
+ protected override void WndProc (ref Message m)
+ {
+ switch ((Msg) m.Msg)
+ {
+ case Msg.WM_PAINT:
+ {
+ PaintEventArgs paint_event;
+
+ paint_event = XplatUI.PaintEventStart (Handle, true);
+ OnPaintSB (paint_event);
+ XplatUI.PaintEventEnd (Handle, true);
+ return;
+ }
+
+ case Msg.WM_ERASEBKGND:
+ m.Result = (IntPtr) 1; /// Disable background painting to avoid flickering
+ return;
+
+ default:
+ break;
+ }
+
+ base.WndProc (ref m);
+ }
+
+ #endregion //Public Methods
+
+ #region Private Methods
+
+ private void CalcButtonSizes ()
+ {
+ if (vert) {
+ if (Height < ThemeEngine.Current.ScrollBarButtonSize * 2)
+ scrollbutton_height = Height /2;
+ else
+ scrollbutton_height = ThemeEngine.Current.ScrollBarButtonSize;
+
+ } else {
+ if (Width < ThemeEngine.Current.ScrollBarButtonSize * 2)
+ scrollbutton_width = Width /2;
+ else
+ scrollbutton_width = ThemeEngine.Current.ScrollBarButtonSize;
+ }
+ }
+
+ private void CalcThumbArea ()
+ {
+ // Thumb area
+ if (vert) {
+
+ thumb_area.Height = Height - scrollbutton_height - scrollbutton_height;
+ thumb_area.X = 0;
+ thumb_area.Y = scrollbutton_height;
+ thumb_area.Width = Width;
+
+ if (Height < thumb_notshown_size)
+ thumb_size = 0;
+ else {
+ double per = ((double) this.LargeChange / (double)((1 + maximum - minimum)));
+ thumb_size = 1 + (int) (thumb_area.Height * per);
+
+ if (thumb_size < thumb_min_size)
+ thumb_size = thumb_min_size;
+ }
+
+ pixel_per_pos = ((float)(thumb_area.Height - thumb_size) / (float) ((maximum - minimum - this.LargeChange) + 1));
+
+ } else {
+
+ thumb_area.Y = 0;
+ thumb_area.X = scrollbutton_width;
+ thumb_area.Height = Height;
+ thumb_area.Width = Width - scrollbutton_width - scrollbutton_width;
+
+ if (Width < thumb_notshown_size)
+ thumb_size = 0;
+ else {
+ double per = ((double) this.LargeChange / (double)((1 + maximum - minimum)));
+ thumb_size = 1 + (int) (thumb_area.Width * per);
+
+ if (thumb_size < thumb_min_size)
+ thumb_size = thumb_min_size;
+ }
+
+ pixel_per_pos = ((float)(thumb_area.Width - thumb_size) / (float) ((maximum - minimum - this.LargeChange) + 1));
+ }
+ }
+
+ private void LargeIncrement ()
+ {
+ ScrollEventArgs event_args;
+ int pos = position + large_change;
+
+ event_args = new ScrollEventArgs (ScrollEventType.LargeIncrement, pos);
+ OnScroll (event_args);
+ Value = event_args.NewValue;
+
+ event_args = new ScrollEventArgs (ScrollEventType.EndScroll, Value);
+ OnScroll (event_args);
+ Value = event_args.NewValue;
+ }
+
+ private void LargeDecrement ()
+ {
+ ScrollEventArgs event_args;
+ int pos = position - large_change;
+
+ event_args = new ScrollEventArgs (ScrollEventType.LargeDecrement, pos);
+ OnScroll (event_args);
+ Value = event_args.NewValue;
+
+ event_args = new ScrollEventArgs (ScrollEventType.EndScroll, Value);
+ OnScroll (event_args);
+ Value = event_args.NewValue;
+ }
+
+ private void OnResizeSB (Object o, EventArgs e)
+ {
+ if (Width <= 0 || Height <= 0)
+ return;
+
+ CalcButtonSizes ();
+ CalcThumbArea ();
+ UpdatePos (position, true);
+
+ Refresh ();
+ }
+
+ private void OnPaintSB (PaintEventArgs pevent)
+ {
+ if (Paint != null) {
+ Paint (this, pevent);
+ }
+ ThemeEngine.Current.DrawScrollBar (pevent.Graphics, pevent.ClipRectangle, this);
+ }
+
+ private void OnTimer (Object source, EventArgs e)
+ {
+ ClearDirty ();
+
+ switch (timer_type) {
+
+ case TimerType.HoldButton:
+ SetRepeatButtonTimer ();
+ break;
+
+ case TimerType.RepeatButton:
+ {
+ if ((firstbutton_state & ButtonState.Pushed) == ButtonState.Pushed &&
+ position != Minimum)
+ SmallDecrement();
+
+ if ((secondbutton_state & ButtonState.Pushed) == ButtonState.Pushed &&
+ position != Maximum)
+ SmallIncrement();
+
+ break;
+ }
+
+ case TimerType.HoldThumbArea:
+ SetRepeatThumbAreaTimer ();
+ break;
+
+ case TimerType.RepeatThumbArea:
+ {
+ Point pnt, pnt_screen;
+ Rectangle thumb_area_screen = thumb_area;
+
+ pnt_screen = PointToScreen (new Point (thumb_area.X, thumb_area.Y));
+ thumb_area_screen.X = pnt_screen.X;
+ thumb_area_screen.Y = pnt_screen.Y;
+
+ if (thumb_area_screen.Contains (MousePosition) == false) {
+ timer.Enabled = false;
+ thumb_moving = ThumbMoving.None;
+ DirtyThumbArea ();
+ InvalidateDirty ();
+ }
+
+ pnt = PointToClient (MousePosition);
+
+ if (vert)
+ lastclick_pos = pnt.Y;
+ else
+ lastclick_pos = pnt.X;
+
+ if (thumb_moving == ThumbMoving.Forward) {
+ if ((vert && (thumb_pos.Y + thumb_size > lastclick_pos)) ||
+ (!vert && (thumb_pos.X + thumb_size > lastclick_pos)) ||
+ (thumb_area.Contains (pnt) == false)){
+ timer.Enabled = false;
+ thumb_moving = ThumbMoving.None;
+ Refresh ();
+ return;
+ } else {
+ LargeIncrement ();
+ }
+ }
+ else
+ if ((vert && (thumb_pos.Y < lastclick_pos)) ||
+ (!vert && (thumb_pos.X < lastclick_pos))){
+ timer.Enabled = false;
+ thumb_moving = ThumbMoving.None;
+ Refresh ();
+ } else {
+ LargeDecrement ();
+ }
+
+ break;
+ }
+ default:
+ break;
+ }
+
+ InvalidateDirty ();
+ }
+
+ private void OnMouseMoveSB (object sender, MouseEventArgs e)
+ {
+ if (MouseMove != null) {
+ MouseMove (this, e);
+ }
+
+ if (Enabled == false || thumb_size == 0)
+ return;
+
+ if (firstbutton_pressed) {
+ if (!first_arrow_area.Contains (e.X, e.Y) && ((firstbutton_state & ButtonState.Pushed) == ButtonState.Pushed)) {
+ firstbutton_state = ButtonState.Normal;
+ Invalidate (first_arrow_area);
+ return;
+ } else if (first_arrow_area.Contains (e.X, e.Y) && ((firstbutton_state & ButtonState.Normal) == ButtonState.Normal)) {
+ firstbutton_state = ButtonState.Pushed;
+ Invalidate (first_arrow_area);
+ return;
+ }
+ } else if (secondbutton_pressed) {
+ if (!second_arrow_area.Contains (e.X, e.Y) && ((secondbutton_state & ButtonState.Pushed) == ButtonState.Pushed)) {
+ secondbutton_state = ButtonState.Normal;
+ Invalidate (second_arrow_area);
+ return;
+ } else if (second_arrow_area.Contains (e.X, e.Y) && ((secondbutton_state & ButtonState.Normal) == ButtonState.Normal)) {
+ secondbutton_state = ButtonState.Pushed;
+ Invalidate (second_arrow_area);
+ return;
+ }
+ } else if (thumb_pressed == true) {
+ int pixel_pos;
+
+ if (vert) {
+
+ int mouse_click = e.Y;
+ int outside_curpos = thumb_area.Y + thumb_area.Height - thumb_size + lastclick_pos_thumb;
+
+
+ if (mouse_click > thumb_area.Y + thumb_area.Height) {
+ outside_thumbarea_right = true;
+ mouse_click = thumb_area.Y + thumb_area.Height;
+ }
+
+ if (mouse_click < thumb_area.Y) {
+ outside_thumbarea_left = true;
+ mouse_click = thumb_area.Y;
+ }
+
+ if (outside_thumbarea_right && mouse_click < outside_curpos) {
+ outside_thumbarea_right = false;
+ thumb_pixel_click_move_prev =
+ thumb_pixel_click_move = outside_curpos;
+ }
+
+ if (outside_thumbarea_left && mouse_click > thumb_area.Y + lastclick_pos_thumb) {
+ outside_thumbarea_left = false;
+ thumb_pixel_click_move_prev =
+ thumb_pixel_click_move = thumb_area.Y + lastclick_pos_thumb;
+ }
+
+ if (outside_thumbarea_right == false && outside_thumbarea_left == false) {
+ pixel_pos = thumb_pos.Y + (thumb_pixel_click_move - thumb_pixel_click_move_prev);
+ thumb_pixel_click_move_prev = thumb_pixel_click_move;
+ thumb_pixel_click_move = mouse_click;
+
+ UpdateThumbPos (pixel_pos, true);
+ OnScroll (new ScrollEventArgs (ScrollEventType.ThumbTrack, position));
+ }
+
+ }
+ else {
+ int mouse_click = e.X;
+ int outside_curpos = thumb_area.X + thumb_area.Width - thumb_size + lastclick_pos_thumb;
+
+ if (mouse_click > thumb_area.X + thumb_area.Width) {
+ outside_thumbarea_right = true;
+ mouse_click = thumb_area.X + thumb_area.Width;
+ }
+
+ if (mouse_click < thumb_area.X) {
+ outside_thumbarea_left = true;
+ mouse_click = thumb_area.X;
+ }
+
+ if (outside_thumbarea_right && mouse_click < outside_curpos) {
+ outside_thumbarea_right = false;
+ thumb_pixel_click_move_prev =
+ thumb_pixel_click_move = outside_curpos;
+ }
+
+ if (outside_thumbarea_left && mouse_click > thumb_area.X + lastclick_pos_thumb) {
+ outside_thumbarea_left = false;
+ thumb_pixel_click_move_prev =
+ thumb_pixel_click_move = thumb_area.X + lastclick_pos_thumb;
+ }
+
+ if (outside_thumbarea_right == false && outside_thumbarea_left == false) {
+ pixel_pos = thumb_pos.X + (thumb_pixel_click_move - thumb_pixel_click_move_prev);
+ thumb_pixel_click_move_prev = thumb_pixel_click_move;
+ thumb_pixel_click_move = mouse_click;
+ UpdateThumbPos (pixel_pos, true);
+ OnScroll (new ScrollEventArgs (ScrollEventType.ThumbTrack, position));
+ }
+
+ }
+
+ Refresh ();
+ }
+
+ }
+
+ private void OnMouseDownSB (object sender, MouseEventArgs e)
+ {
+ ClearDirty ();
+
+ if (e.Button == MouseButtons.Right) {
+ if (MouseDown != null) {
+ MouseDown (this, e);
+ }
+ }
+
+ if (Enabled == false)
+ return;
+
+ if (firstbutton_state != ButtonState.Inactive && first_arrow_area.Contains (e.X, e.Y)) {
+ this.Capture = true;
+ firstbutton_state = ButtonState.Pushed;
+ firstbutton_pressed = true;
+ Invalidate (first_arrow_area);
+ if (!timer.Enabled) {
+ SetHoldButtonClickTimer ();
+ timer.Enabled = true;
+ }
+ }
+
+ if (secondbutton_state != ButtonState.Inactive && second_arrow_area.Contains (e.X, e.Y)) {
+ this.Capture = true;
+ secondbutton_state = ButtonState.Pushed;
+ secondbutton_pressed = true;
+ Invalidate (second_arrow_area);
+ if (!timer.Enabled) {
+ SetHoldButtonClickTimer ();
+ timer.Enabled = true;
+ }
+ }
+
+ if (thumb_size > 0 && thumb_pos.Contains (e.X, e.Y)) {
+ thumb_pressed = true;
+ this.Capture = true;
+ if (vert) {
+ lastclick_pos_thumb = e.Y - thumb_pos.Y;
+ lastclick_pos = e.Y;
+ thumb_pixel_click_move_prev = thumb_pixel_click_move = e.Y;
+ }
+ else {
+ lastclick_pos_thumb = e.X - thumb_pos.X;
+ lastclick_pos = e.X;
+ thumb_pixel_click_move_prev = thumb_pixel_click_move = e.X;
+ }
+ } else {
+ if (thumb_size > 0 && thumb_area.Contains (e.X, e.Y)) {
+
+ if (vert) {
+ lastclick_pos_thumb = e.Y - thumb_pos.Y;
+ lastclick_pos = e.Y;
+
+ if (e.Y > thumb_pos.Y + thumb_pos.Height) {
+ LargeIncrement ();
+ thumb_moving = ThumbMoving.Forward;
+ Dirty (new Rectangle (0, thumb_pos.Y + thumb_pos.Height,
+ ClientRectangle.Width,
+ ClientRectangle.Height - (thumb_pos.Y + thumb_pos.Height) -
+ scrollbutton_height));
+ } else {
+ LargeDecrement ();
+ thumb_moving = ThumbMoving.Backwards;
+ Dirty (new Rectangle (0, scrollbutton_height,
+ ClientRectangle.Width,
+ thumb_pos.Y - scrollbutton_height));
+ }
+ } else {
+
+ lastclick_pos_thumb = e.X - thumb_pos.X;
+ lastclick_pos = e.X;
+
+ if (e.X > thumb_pos.X + thumb_pos.Width) {
+ thumb_moving = ThumbMoving.Forward;
+ LargeIncrement ();
+ Dirty (new Rectangle (thumb_pos.X + thumb_pos.Width, 0,
+ ClientRectangle.Width - (thumb_pos.X + thumb_pos.Width) -
+ scrollbutton_width,
+ ClientRectangle.Height));
+ } else {
+ thumb_moving = ThumbMoving.Backwards;
+ LargeDecrement ();
+ Dirty (new Rectangle (scrollbutton_width, 0,
+ thumb_pos.X - scrollbutton_width,
+ ClientRectangle.Height));
+ }
+ }
+
+ SetHoldThumbAreaTimer ();
+ timer.Enabled = true;
+ InvalidateDirty ();
+ }
+ }
+ }
+
+ private void OnMouseUpSB (object sender, MouseEventArgs e)
+ {
+ ClearDirty ();
+
+ if (e.Button == MouseButtons.Right) {
+ if (MouseUp != null) {
+ MouseUp (this, e);
+ }
+ }
+
+ if (Enabled == false)
+ return;
+
+ timer.Enabled = false;
+ if (thumb_moving != ThumbMoving.None) {
+ DirtyThumbArea ();
+ thumb_moving = ThumbMoving.None;
+ }
+ this.Capture = false;
+
+ if (firstbutton_pressed) {
+ firstbutton_state = ButtonState.Normal;
+ if (first_arrow_area.Contains (e.X, e.Y)) {
+ SmallDecrement ();
+ }
+ firstbutton_pressed = false;
+ Dirty (first_arrow_area);
+ } else if (secondbutton_pressed) {
+ secondbutton_state = ButtonState.Normal;
+ if (second_arrow_area.Contains (e.X, e.Y)) {
+ SmallIncrement ();
+ }
+ Dirty (second_arrow_area);
+ secondbutton_pressed = false;
+ } else if (thumb_pressed == true) {
+ OnScroll (new ScrollEventArgs (ScrollEventType.ThumbPosition, position));
+ OnScroll (new ScrollEventArgs (ScrollEventType.EndScroll, position));
+ thumb_pressed = false;
+ Refresh ();
+ return;
+ }
+
+ InvalidateDirty ();
+ }
+
+ private void OnKeyDownSB (Object o, KeyEventArgs key)
+ {
+ if (Enabled == false)
+ return;
+
+ ClearDirty ();
+
+ switch (key.KeyCode){
+ case Keys.Up:
+ {
+ SmallDecrement ();
+ break;
+ }
+ case Keys.Down:
+ {
+ SmallIncrement ();
+ break;
+ }
+ case Keys.PageUp:
+ {
+ LargeDecrement ();
+ break;
+ }
+ case Keys.PageDown:
+ {
+ LargeIncrement ();
+ break;
+ }
+ case Keys.Home:
+ {
+ SetHomePosition ();
+ break;
+ }
+ case Keys.End:
+ {
+ SetEndPosition ();
+ break;
+ }
+ default:
+ break;
+ }
+
+ InvalidateDirty ();
+ }
+
+ private void SetEndPosition ()
+ {
+ ScrollEventArgs event_args;
+ int pos = Maximum;
+
+ event_args = new ScrollEventArgs (ScrollEventType.Last, pos);
+ OnScroll (event_args);
+ pos = event_args.NewValue;
+
+ event_args = new ScrollEventArgs (ScrollEventType.EndScroll, pos);
+ OnScroll (event_args);
+ pos = event_args.NewValue;
+
+ SetValue (pos);
+ }
+
+ private void SetHomePosition ()
+ {
+ ScrollEventArgs event_args;
+ int pos = Minimum;
+
+ event_args = new ScrollEventArgs (ScrollEventType.First, pos);
+ OnScroll (event_args);
+ pos = event_args.NewValue;
+
+ event_args = new ScrollEventArgs (ScrollEventType.EndScroll, pos);
+ OnScroll (event_args);
+ pos = event_args.NewValue;
+
+ SetValue (pos);
+ }
+
+ private void SmallIncrement ()
+ {
+ ScrollEventArgs event_args;
+ int pos = position + small_change;
+
+ event_args = new ScrollEventArgs (ScrollEventType.SmallIncrement, pos);
+ OnScroll (event_args);
+ Value = event_args.NewValue;
+
+ event_args = new ScrollEventArgs (ScrollEventType.EndScroll, Value);
+ OnScroll (event_args);
+ Value = event_args.NewValue;
+ }
+
+ private void SmallDecrement ()
+ {
+ ScrollEventArgs event_args;
+ int pos = position - small_change;
+
+ event_args = new ScrollEventArgs (ScrollEventType.SmallDecrement, pos);
+ OnScroll (event_args);
+ Value = event_args.NewValue;
+
+ event_args = new ScrollEventArgs (ScrollEventType.EndScroll, Value);
+ OnScroll (event_args);
+ Value = event_args.NewValue;
+ }
+
+ private void SetHoldButtonClickTimer ()
+ {
+ timer.Enabled = false;
+ timer.Interval = 200;
+ timer_type = TimerType.HoldButton;
+ timer.Enabled = true;
+ }
+
+ private void SetRepeatButtonTimer ()
+ {
+ timer.Enabled = false;
+ timer.Interval = 50;
+ timer_type = TimerType.RepeatButton;
+ timer.Enabled = true;
+ }
+
+ private void SetHoldThumbAreaTimer ()
+ {
+ timer.Enabled = false;
+ timer.Interval = 200;
+ timer_type = TimerType.HoldThumbArea;
+ timer.Enabled = true;
+ }
+
+ private void SetRepeatThumbAreaTimer ()
+ {
+ timer.Enabled = false;
+ timer.Interval = 50;
+ timer_type = TimerType.RepeatThumbArea;
+ timer.Enabled = true;
+ }
+
+ private void UpdatePos (int newPos, bool update_thumbpos)
+ {
+ int pos;
+
+ if (newPos < minimum)
+ pos = minimum;
+ else
+ if (newPos > maximum + 1 - large_change)
+ pos = maximum + 1 - large_change;
+ else
+ pos = newPos;
+
+ // pos can't be less than minimum
+ if (pos < minimum)
+ pos = minimum;
+
+ if (update_thumbpos) {
+ if (vert)
+ UpdateThumbPos (thumb_area.Y + (int)(((float)(pos - minimum)) * pixel_per_pos), false);
+ else
+ UpdateThumbPos (thumb_area.X + (int)(((float)(pos - minimum)) * pixel_per_pos), false);
+ SetValue (pos);
+ }
+ else {
+ position = pos; // Updates directly the value to avoid thumb pos update
+
+ if (ValueChanged != null)
+ ValueChanged (this, EventArgs.Empty);
+ }
+ }
+
+ private void UpdateThumbPos (int pixel, bool update_value)
+ {
+ float new_pos = 0;
+
+ if (vert) {
+ Dirty (thumb_pos);
+ if (pixel < thumb_area.Y)
+ thumb_pos.Y = thumb_area.Y;
+ else
+ if (pixel > thumb_area.Y + thumb_area.Height - thumb_size)
+ thumb_pos.Y = thumb_area.Y + thumb_area.Height - thumb_size;
+ else
+ thumb_pos.Y = pixel;
+
+ thumb_pos.X = 0;
+ thumb_pos.Width = ThemeEngine.Current.ScrollBarButtonSize;
+ thumb_pos.Height = thumb_size;
+ new_pos = (float) (thumb_pos.Y - thumb_area.Y);
+ new_pos = new_pos / pixel_per_pos;
+
+ Dirty (thumb_pos);
+ } else {
+ Dirty (thumb_pos);
+ if (pixel < thumb_area.X)
+ thumb_pos.X = thumb_area.X;
+ else
+ if (pixel > thumb_area.X + thumb_area.Width - thumb_size)
+ thumb_pos.X = thumb_area.X + thumb_area.Width - thumb_size;
+ else
+ thumb_pos.X = pixel;
+
+ thumb_pos.Y = 0;
+ thumb_pos.Width = thumb_size;
+ thumb_pos.Height = ThemeEngine.Current.ScrollBarButtonSize;
+ new_pos = (float) (thumb_pos.X - thumb_area.X);
+ new_pos = new_pos / pixel_per_pos;
+
+ Dirty (thumb_pos);
+ }
+
+ if (update_value)
+ UpdatePos ((int) new_pos + minimum, false);
+ }
+
+ private void SetValue (int value)
+ {
+ if ( value < minimum || value > maximum )
+ throw new ArgumentException(
+ String.Format("'{0}' is not a valid value for 'Value'. 'Value' should be between 'Minimum' and 'Maximum'", value));
+
+ if (position != value){
+ position = value;
+
+ OnValueChanged (EventArgs.Empty);
+ UpdatePos (value, true);
+ }
+ }
+
+ private void ClearDirty ()
+ {
+ dirty = Rectangle.Empty;
+ }
+
+ private void Dirty (Rectangle r)
+ {
+ if (dirty == Rectangle.Empty) {
+ dirty = r;
+ return;
+ }
+ dirty = Rectangle.Union (dirty, r);
+ }
+
+ private void DirtyThumbArea ()
+ {
+ if (thumb_moving == ThumbMoving.Forward) {
+ if (vert) {
+ Dirty (new Rectangle (0, thumb_pos.Y + thumb_pos.Height,
+ ClientRectangle.Width,
+ ClientRectangle.Height - (thumb_pos.Y + thumb_pos.Height) -
+ scrollbutton_height));
+ } else {
+ Dirty (new Rectangle (thumb_pos.X + thumb_pos.Width, 0,
+ ClientRectangle.Width - (thumb_pos.X + thumb_pos.Width) -
+ scrollbutton_width,
+ ClientRectangle.Height));
+ }
+ } else if (thumb_moving == ThumbMoving.Backwards) {
+ if (vert) {
+ Dirty(new Rectangle (0, scrollbutton_height,
+ ClientRectangle.Width,
+ thumb_pos.Y - scrollbutton_height));
+ } else {
+ Dirty (new Rectangle (scrollbutton_width, 0,
+ thumb_pos.X - scrollbutton_width,
+ ClientRectangle.Height));
+ }
+ }
+ }
+
+ private void InvalidateDirty ()
+ {
+ Invalidate (dirty);
+ dirty = Rectangle.Empty;
+ }
+
+ #endregion //Private Methods
+ }
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollBars.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollBars.cs
new file mode 100644
index 00000000000..0488122b44b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollBars.cs
@@ -0,0 +1,36 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum ScrollBars {
+ None = 0,
+ Horizontal = 1,
+ Vertical = 2,
+ Both = 3
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollButton.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollButton.cs
new file mode 100644
index 00000000000..f58dc9f8e49
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollButton.cs
@@ -0,0 +1,39 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum ScrollButton {
+ Min = 0,
+ Up = 0,
+ Down = 1,
+ Left = 2,
+ Right = 3,
+ Max = 3
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollEventArgs.cs
new file mode 100644
index 00000000000..12ecbafdf78
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollEventArgs.cs
@@ -0,0 +1,64 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public class ScrollEventArgs : EventArgs {
+ #region Local Variables
+ private ScrollEventType type;
+ private int new_value;
+ #endregion
+
+ #region Public Constructors
+ public ScrollEventArgs(ScrollEventType type, int newValue) {
+ this.type = type;
+ this.new_value = newValue;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public int NewValue {
+ get {
+ return new_value;
+ }
+
+ set {
+ new_value = value;
+ }
+ }
+
+ public ScrollEventType Type {
+ get {
+ return type;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollEventHandler.cs
new file mode 100644
index 00000000000..7d9483d512d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollEventHandler.cs
@@ -0,0 +1,31 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void ScrollEventHandler(object sender, ScrollEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollEventType.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollEventType.cs
new file mode 100644
index 00000000000..b3f8c4a222c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollEventType.cs
@@ -0,0 +1,44 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public enum ScrollEventType {
+ SmallDecrement = 0,
+ SmallIncrement = 1,
+ LargeDecrement = 2,
+ LargeIncrement = 3,
+ ThumbPosition = 4,
+ ThumbTrack = 5,
+ First = 6,
+ Last = 7,
+ EndScroll = 8
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollableControl.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollableControl.cs
new file mode 100644
index 00000000000..3351659a61a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollableControl.cs
@@ -0,0 +1,663 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// NOT COMPLETE
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+ [Designer ("System.Windows.Forms.Design.ScrollableControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ public class ScrollableControl : Control {
+ #region Local Variables
+ private bool auto_vscroll;
+ private bool auto_hscroll;
+ private bool hscroll_visible;
+ private bool vscroll_visible;
+ private bool force_hscroll_visible;
+ private bool force_vscroll_visible;
+ private bool auto_scroll;
+ private Size auto_scroll_margin;
+ private Size auto_scroll_min_size;
+ private Point scroll_position;
+ private DockPaddingEdges dock_padding;
+ private SizeGrip sizegrip;
+ private HScrollBar hscrollbar;
+ private VScrollBar vscrollbar;
+ #endregion // Local Variables
+
+ [MonoTODO("Need to use the edge values when performing the layout")]
+ [TypeConverter(typeof(ScrollableControl.DockPaddingEdgesConverter))]
+ #region Subclass DockPaddingEdges
+ public class DockPaddingEdges : ICloneable {
+ #region DockPaddingEdges Local Variables
+ private int all;
+ private int left;
+ private int right;
+ private int top;
+ private int bottom;
+ private Control owner;
+ #endregion // DockPaddingEdges Local Variables
+
+ #region DockPaddingEdges Constructor
+ internal DockPaddingEdges(Control owner) {
+ all = 0;
+ left = 0;
+ right = 0;
+ top = 0;
+ bottom = 0;
+ this.owner = owner;
+ }
+ #endregion // DockPaddingEdges Constructor
+
+ #region DockPaddingEdges Public Instance Properties
+ [RefreshProperties(RefreshProperties.All)]
+ public int All {
+ get {
+ return all;
+ }
+
+ set {
+ all = value;
+ left = value;
+ right = value;
+ top = value;
+ bottom = value;
+
+ owner.PerformLayout();
+ }
+ }
+
+ [RefreshProperties(RefreshProperties.All)]
+ public int Bottom {
+ get {
+ return bottom;
+ }
+
+ set {
+ bottom = value;
+ all = 0;
+
+ owner.PerformLayout();
+ }
+ }
+
+ [RefreshProperties(RefreshProperties.All)]
+ public int Left {
+ get {
+ return left;
+ }
+
+ set {
+ left=value;
+ all = 0;
+
+ owner.PerformLayout();
+ }
+ }
+
+ [RefreshProperties(RefreshProperties.All)]
+ public int Right {
+ get {
+ return right;
+ }
+
+ set {
+ right=value;
+ all = 0;
+
+ owner.PerformLayout();
+ }
+ }
+
+ [RefreshProperties(RefreshProperties.All)]
+ public int Top {
+ get {
+ return top;
+ }
+
+ set {
+ top=value;
+ all = 0;
+
+ owner.PerformLayout();
+ }
+ }
+
+ #endregion // DockPaddingEdges Public Instance Properties
+
+ // Public Instance Methods
+ public override bool Equals(object other) {
+ if (! (other is DockPaddingEdges)) {
+ return false;
+ }
+
+ if ( (this.all == ((DockPaddingEdges)other).all) && (this.left == ((DockPaddingEdges)other).left) &&
+ (this.right == ((DockPaddingEdges)other).right) && (this.top == ((DockPaddingEdges)other).top) &&
+ (this.bottom == ((DockPaddingEdges)other).bottom)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public override int GetHashCode() {
+ return all*top*bottom*right*left;
+ }
+
+ public override string ToString() {
+ return "All = "+all.ToString()+" Top = "+top.ToString()+" Left = "+left.ToString()+" Bottom = "+bottom.ToString()+" Right = "+right.ToString();
+ }
+
+ object ICloneable.Clone() {
+ DockPaddingEdges padding_edge;
+
+ padding_edge=new DockPaddingEdges(owner);
+
+ padding_edge.all=all;
+ padding_edge.left=left;
+ padding_edge.right=right;
+ padding_edge.top=top;
+ padding_edge.bottom=bottom;
+
+ return padding_edge;
+ }
+ }
+ #endregion // Subclass DockPaddingEdges
+
+ #region Subclass DockPaddingEdgesConverter
+ public class DockPaddingEdgesConverter : System.ComponentModel.TypeConverter {
+ // Public Constructors
+ public DockPaddingEdgesConverter() {
+ }
+
+ // Public Instance Methods
+ public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, Attribute[] attributes) {
+ return TypeDescriptor.GetProperties(typeof(DockPaddingEdges), attributes);
+ }
+
+ public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+ return true;
+ }
+ }
+ #endregion // Subclass DockPaddingEdgesConverter
+
+ #region Public Constructors
+ public ScrollableControl() {
+ SetStyle(ControlStyles.ContainerControl, true);
+ SetStyle(ControlStyles.AllPaintingInWmPaint, false);
+ auto_scroll = false;
+ auto_hscroll = false;
+ auto_vscroll = false;
+ hscroll_visible = false;
+ vscroll_visible = false;
+ force_hscroll_visible = false;
+ force_vscroll_visible = false;
+ auto_scroll_margin = new Size(0, 0);
+ auto_scroll_min_size = new Size(0, 0);
+ scroll_position = new Point(0, 0);
+ dock_padding = new DockPaddingEdges(this);
+ SizeChanged +=new EventHandler(Recalculate);
+ VisibleChanged += new EventHandler(Recalculate);
+ }
+ #endregion // Public Constructors
+
+ #region Protected Static Fields
+ protected const int ScrollStateAutoScrolling = 1;
+ protected const int ScrollStateFullDrag = 16;
+ protected const int ScrollStateHScrollVisible = 2;
+ protected const int ScrollStateUserHasScrolled = 8;
+ protected const int ScrollStateVScrollVisible = 4;
+ #endregion // Protected Static Fields
+
+ #region Public Instance Properties
+ [DefaultValue(false)]
+ [Localizable(true)]
+ public virtual bool AutoScroll {
+ get {
+ return auto_scroll;
+ }
+
+ set {
+ if (auto_scroll == value) {
+ return;
+ }
+
+ auto_scroll = value;
+ if (!auto_scroll) {
+ SuspendLayout ();
+
+ Controls.RemoveImplicit (hscrollbar);
+ hscrollbar.Dispose();
+ hscrollbar = null;
+ hscroll_visible = false;
+
+ Controls.RemoveImplicit (vscrollbar);
+ vscrollbar.Dispose();
+ vscrollbar = null;
+ vscroll_visible = false;
+
+ Controls.RemoveImplicit (sizegrip);
+ sizegrip.Dispose();
+ sizegrip = null;
+
+ ResumeLayout ();
+ } else {
+ SuspendLayout ();
+
+ hscrollbar = new HScrollBar();
+ hscrollbar.Visible = false;
+ hscrollbar.ValueChanged += new EventHandler(HandleScrollBar);
+ hscrollbar.Height = SystemInformation.HorizontalScrollBarHeight;
+ this.Controls.AddImplicit (hscrollbar);
+
+ vscrollbar = new VScrollBar();
+ vscrollbar.Visible = false;
+ vscrollbar.ValueChanged += new EventHandler(HandleScrollBar);
+ vscrollbar.Width = SystemInformation.VerticalScrollBarWidth;
+ this.Controls.AddImplicit (vscrollbar);
+
+ sizegrip = new SizeGrip();
+ sizegrip.Visible = false;
+ this.Controls.AddImplicit (sizegrip);
+
+ ResumeLayout ();
+ }
+ }
+ }
+
+ [Localizable(true)]
+ public Size AutoScrollMargin {
+ get {
+ return auto_scroll_margin;
+ }
+
+ set {
+ if (value.Width < 0) {
+ throw new ArgumentException("Width is assigned less than 0", "value.Width");
+ }
+
+ if (value.Height < 0) {
+ throw new ArgumentException("Height is assigned less than 0", "value.Height");
+ }
+
+ auto_scroll_margin = value;
+ }
+ }
+
+ [Localizable(true)]
+ public Size AutoScrollMinSize {
+ get {
+ return auto_scroll_min_size;
+ }
+
+ set {
+ auto_scroll_min_size = value;
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Point AutoScrollPosition {
+ get {
+ return new Point(-scroll_position.X, -scroll_position.Y);
+ }
+
+ set {
+ if ((value.X != scroll_position.X) || (value.Y != scroll_position.Y)) {
+ int shift_x;
+ int shift_y;
+
+ shift_x = 0;
+ shift_y = 0;
+ if (hscroll_visible) {
+ shift_x = value.X - scroll_position.X;
+ }
+
+ if (vscroll_visible) {
+ shift_y = value.Y - scroll_position.Y;
+ }
+
+ ScrollWindow(shift_x, shift_y);
+
+ if (hscroll_visible) {
+ hscrollbar.Value = scroll_position.X;
+ }
+
+ if (vscroll_visible) {
+ vscrollbar.Value = scroll_position.Y;
+ }
+
+ }
+ }
+ }
+
+ public override Rectangle DisplayRectangle {
+ get {
+ Rectangle rect;
+
+ rect = base.DisplayRectangle;
+ if (vscroll_visible) {
+ rect.Width -= vscrollbar.Width;
+ if (rect.Width < 0) {
+ rect.Width = 0;
+ }
+ }
+
+ if (hscroll_visible) {
+ rect.Height -= hscrollbar.Height;
+ if (rect.Height < 0) {
+ rect.Height = 0;
+ }
+ }
+
+ rect.X += dock_padding.Left;
+ rect.Y += dock_padding.Top;
+
+ rect.Width -= dock_padding.Right + dock_padding.Left;
+ rect.Height -= dock_padding.Bottom + dock_padding.Top;
+
+ return rect;
+ //return new Rectangle(-scroll_position.X, -scroll_position.Y, auto_scroll_min_size.Width, auto_scroll_min_size.Height);
+ }
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ [Localizable(true)]
+ public DockPaddingEdges DockPadding {
+ get {
+ return dock_padding;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Methods
+ protected override CreateParams CreateParams {
+ get {
+ return base.CreateParams;
+ }
+ }
+
+ protected bool HScroll {
+ get {
+ return hscroll_visible;
+ }
+
+ set {
+ if (hscroll_visible != value) {
+ force_hscroll_visible = value;
+ Recalculate(this, EventArgs.Empty);
+ }
+ }
+ }
+
+ protected bool VScroll {
+ get {
+ return vscroll_visible;
+ }
+
+ set {
+ if (vscroll_visible != value) {
+ force_vscroll_visible = value;
+ Recalculate(this, EventArgs.Empty);
+ }
+ }
+ }
+ #endregion // Protected Instance Methods
+
+ #region Public Instance Methods
+ public void ScrollControlIntoView(Control activeControl) {
+ }
+
+ public void SetAutoScrollMargin(int x, int y) {
+ if (x < 0) {
+ x = 0;
+ }
+
+ if (y < 0) {
+ y = 0;
+ }
+
+ auto_scroll_margin = new Size(x, y);
+ Recalculate(this, EventArgs.Empty);
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void AdjustFormScrollbars(bool displayScrollbars) {
+ // Internal MS
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected bool GetScrollState(int bit) {
+ return false;
+ // Internal MS
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void OnLayout(LayoutEventArgs levent) {
+ base.OnLayout(levent);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void OnMouseWheel(MouseEventArgs e) {
+ if (vscroll_visible) {
+ if (e.Delta > 0) {
+ if (vscrollbar.Minimum < (vscrollbar.Value - vscrollbar.LargeChange)) {
+ vscrollbar.Value -= vscrollbar.LargeChange;
+ } else {
+ vscrollbar.Value = vscrollbar.Minimum;
+ }
+ } else {
+ if (vscrollbar.Maximum > (vscrollbar.Value + vscrollbar.LargeChange)) {
+ vscrollbar.Value += vscrollbar.LargeChange;
+ } else {
+ vscrollbar.Value = vscrollbar.Maximum;
+ }
+ }
+ }
+ base.OnMouseWheel(e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void OnVisibleChanged(EventArgs e) {
+ base.OnVisibleChanged(e);
+ }
+
+ protected override void ScaleCore(float dx, float dy) {
+ base.ScaleCore(dx, dy);
+ }
+
+ protected void SetDisplayRectLocation(int x, int y) {
+ throw new NotImplementedException();
+ }
+
+ protected void SetScrollState(int bit, bool value) {
+ throw new NotImplementedException();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void WndProc(ref Message m) {
+ base.WndProc(ref m);
+ }
+ #endregion // Protected Instance Methods
+
+ #region Internal & Private Methods
+ private Size Canvas {
+ get {
+ int num_of_children;
+ int width;
+ int height;
+
+ num_of_children = child_controls.Count;
+ width = 0;
+ height = 0;
+
+ for (int i = 0; i < num_of_children; i++) {
+ if ((child_controls[i].Visible == false) || (child_controls[i] == hscrollbar) || (child_controls[i] == vscrollbar) || (child_controls[i] == sizegrip)) {
+ continue;
+ }
+ if (child_controls[i].Right > width) {
+ width = child_controls[i].Right;
+ }
+
+ if (child_controls[i].Bottom > height) {
+ height = child_controls[i].Bottom;
+ }
+ }
+
+ return new Size(width, height);
+ }
+ }
+
+ private void Recalculate (object sender, EventArgs e)
+ {
+ if (!this.auto_scroll && !force_hscroll_visible && !force_vscroll_visible) {
+ return;
+ }
+
+ Size canvas = Canvas;
+ Size client = ClientRectangle.Size;
+
+ canvas.Width += auto_scroll_margin.Width;
+ canvas.Height += auto_scroll_margin.Height;
+
+ int right_edge = client.Width;
+ int bottom_edge = client.Height;
+ int prev_right_edge;
+ int prev_bottom_edge;
+
+ do {
+ prev_right_edge = right_edge;
+ prev_bottom_edge = bottom_edge;
+
+ if ((force_hscroll_visible || canvas.Width > right_edge) && client.Width > 0) {
+ hscroll_visible = true;
+ bottom_edge = client.Height - SystemInformation.HorizontalScrollBarHeight;
+ } else {
+ hscroll_visible = false;
+ bottom_edge = client.Height;
+ }
+
+ if ((force_vscroll_visible || canvas.Height > bottom_edge) && client.Height > 0) {
+ vscroll_visible = true;
+ right_edge = client.Width - SystemInformation.VerticalScrollBarWidth;
+ } else {
+ vscroll_visible = false;
+ right_edge = client.Width;
+ }
+
+ } while (right_edge != prev_right_edge || bottom_edge != prev_bottom_edge);
+
+ if (hscroll_visible) {
+ hscrollbar.Left = 0;
+ hscrollbar.Top = client.Height - SystemInformation.HorizontalScrollBarHeight;
+ hscrollbar.LargeChange = DisplayRectangle.Width;
+ hscrollbar.SmallChange = DisplayRectangle.Width / 10;
+ hscrollbar.Maximum = canvas.Width - 1;
+ } else {
+ scroll_position.X = 0;
+ }
+
+ if (vscroll_visible) {
+ vscrollbar.Left = client.Width - SystemInformation.VerticalScrollBarWidth;
+ vscrollbar.Top = 0;
+
+ vscrollbar.LargeChange = DisplayRectangle.Height;
+ vscrollbar.SmallChange = DisplayRectangle.Height / 10;
+ vscrollbar.Maximum = canvas.Height - 1;
+ } else {
+ scroll_position.Y = 0;
+ }
+
+ if (hscroll_visible && vscroll_visible) {
+ hscrollbar.Width = ClientRectangle.Width - SystemInformation.VerticalScrollBarWidth;
+ vscrollbar.Height = ClientRectangle.Height - SystemInformation.HorizontalScrollBarHeight;
+
+ sizegrip.Left = hscrollbar.Right;
+ sizegrip.Top = vscrollbar.Bottom;
+ sizegrip.Width = SystemInformation.VerticalScrollBarWidth;
+ sizegrip.Height = SystemInformation.HorizontalScrollBarHeight;
+
+ hscrollbar.Visible = true;
+ vscrollbar.Visible = true;
+ sizegrip.Visible = true;
+ } else {
+ sizegrip.Visible = false;
+ if (hscroll_visible) {
+ hscrollbar.Width = ClientRectangle.Width;
+ hscrollbar.Visible = true;
+ } else {
+ hscrollbar.Visible = false;
+ }
+
+ if (vscroll_visible) {
+ vscrollbar.Height = ClientRectangle.Height;
+ vscrollbar.Visible = true;
+ } else {
+ vscrollbar.Visible = false;
+ }
+ }
+ }
+
+ private void HandleScrollBar(object sender, EventArgs e) {
+ if (sender == vscrollbar) {
+ ScrollWindow(0, vscrollbar.Value- scroll_position.Y);
+ } else {
+ ScrollWindow(hscrollbar.Value - scroll_position.X, 0);
+ }
+ }
+
+ private void ScrollWindow(int XOffset, int YOffset) {
+ int num_of_children;
+
+ SuspendLayout();
+
+ num_of_children = child_controls.Count;
+
+ for (int i = 0; i < num_of_children; i++) {
+ if (child_controls[i] == hscrollbar || child_controls[i] == vscrollbar || child_controls[i] == sizegrip) {
+ continue;
+ }
+ child_controls[i].Left -= XOffset;
+ child_controls[i].Top -= YOffset;
+ // Is this faster? child_controls[i].Location -= new Size(XOffset, YOffset);
+ }
+
+ scroll_position.X += XOffset;
+ scroll_position.Y += YOffset;
+
+ // Should we call XplatUI.ScrollWindow???
+ Invalidate();
+ ResumeLayout();
+ }
+ #endregion // Internal & Private Methods
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SecurityIDType.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SecurityIDType.cs
new file mode 100644
index 00000000000..ba8ade5edba
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SecurityIDType.cs
@@ -0,0 +1,41 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public enum SecurityIDType {
+ User = 1,
+ Group = 2,
+ Domain = 3,
+ Alias = 4,
+ WellKnownGroup = 5,
+ DeletedAccount = 6,
+ Invalid = 7,
+ Unknown = 8,
+ Computer = 9
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectedGridItemChangedEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectedGridItemChangedEventArgs.cs
new file mode 100644
index 00000000000..95f632cb55e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectedGridItemChangedEventArgs.cs
@@ -0,0 +1,65 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jonathan Chambers (jonathan.chambers@ansys.com)
+//
+
+// COMPLETE
+
+using System;
+using System.Windows.Forms.Design;
+
+namespace System.Windows.Forms
+{
+ public class SelectedGridItemChangedEventArgs : EventArgs
+ {
+ #region Local Variables
+ private GridItem new_selection;
+ private GridItem old_selection;
+ #endregion
+
+ #region Constructors
+ public SelectedGridItemChangedEventArgs ( GridItem oldSel , GridItem newSel )
+ {
+ old_selection = oldSel;
+ new_selection = newSel;
+ }
+ #endregion // Constructors
+
+ #region Public Instance Properties
+ public GridItem NewSelection
+ {
+ get {
+ return new_selection;
+ }
+ }
+
+ public GridItem OldSelection
+ {
+ get {
+ return old_selection;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectedGridItemChangedEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectedGridItemChangedEventHandler.cs
new file mode 100644
index 00000000000..1a1a7db7191
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectedGridItemChangedEventHandler.cs
@@ -0,0 +1,32 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jonathan Chambers (jonathan.chambers@ansys.com)
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public delegate void SelectedGridItemChangedEventHandler(object sender, SelectedGridItemChangedEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectionMode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectionMode.cs
new file mode 100644
index 00000000000..2dad4a22c19
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectionMode.cs
@@ -0,0 +1,43 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+
+//COMPLETE
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ [ComVisible(true)]
+ public enum SelectionMode
+ {
+ None = 0,
+ One = 1,
+ MultiSimple = 2,
+ MultiExtended = 3,
+
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectionRange.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectionRange.cs
new file mode 100644
index 00000000000..92c152f20de
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectionRange.cs
@@ -0,0 +1,100 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// John BouAntoun jba-mono@optusnet.com.au
+//
+
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+ [TypeConverter(typeof(SelectionRangeConverter))]
+ public sealed class SelectionRange {
+ #region local members
+
+ DateTime end;
+ DateTime start;
+
+ #endregion // local members
+
+ #region public constructors
+
+ // default parameterless construcor, use default values
+ public SelectionRange () {
+ }
+
+ // constructor that receives another range, copies it's Start and End values
+ public SelectionRange (SelectionRange selectionRange) {
+ end = selectionRange.End;
+ start = selectionRange.Start;
+ }
+
+ // constructor that receives two dates, uses the lower of the two as start
+ public SelectionRange (DateTime lower, DateTime upper) {
+ if (lower <= upper) {
+ end = upper;
+ start = lower;
+ } else {
+ end = lower;
+ start = upper;
+ }
+ }
+
+ #endregion // public constructors
+
+ #region public properties
+
+ // end date of this range
+ public DateTime End {
+ set {
+ if (end != value) {
+ end = value;
+ }
+ }
+ get {
+ return end;
+ }
+ }
+
+ // start date of this range
+ public DateTime Start {
+ set {
+ if (start != value) {
+ start = value;
+ }
+ }
+ get {
+ return start;
+ }
+ }
+
+ #endregion // public properties
+
+ #region public methods
+
+ public override string ToString() {
+ return "SelectionRange: Start: " + Start.ToString() + ", End: " + End.ToString();
+ }
+
+ #endregion // public methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectionRangeConverter.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectionRangeConverter.cs
new file mode 100644
index 00000000000..eb293b88ddc
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectionRangeConverter.cs
@@ -0,0 +1,109 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+using System.ComponentModel;
+using System.Globalization;
+
+namespace System.Windows.Forms {
+ public class SelectionRangeConverter : TypeConverter {
+ #region Public Constructors
+ public SelectionRangeConverter() {
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Methods
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
+ if (sourceType == typeof(string)) {
+ return true;
+ }
+ return false;
+ }
+
+ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) {
+ if (destinationType == typeof(string)) {
+ return true;
+ }
+ return false;
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+ string[] parts;
+ DateTime start;
+ DateTime end;
+
+ if ((value == null) || !(value is String)) {
+ return base.ConvertFrom (context, culture, value);
+ }
+
+ if (culture == null) {
+ culture = CultureInfo.CurrentCulture;
+ }
+
+ parts = ((string)value).Split(culture.TextInfo.ListSeparator.ToCharArray());
+
+ start = (DateTime)TypeDescriptor.GetConverter(typeof(DateTime)).ConvertFromString(context, culture, parts[0]);
+ end = (DateTime)TypeDescriptor.GetConverter(typeof(DateTime)).ConvertFromString(context, culture, parts[1]);
+
+ return new SelectionRange(start, end);
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) {
+ SelectionRange s;
+
+ if ((value == null) || !(value is SelectionRange) || (destinationType != typeof(string))) {
+ return base.ConvertTo (context, culture, value, destinationType);
+ }
+
+ if (culture == null) {
+ culture = CultureInfo.CurrentCulture;
+ }
+
+ s = (SelectionRange)value;
+
+
+ return s.Start.ToShortDateString() + culture.TextInfo.ListSeparator + s.End.ToShortDateString();
+ }
+
+ public override object CreateInstance(ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) {
+ return new SelectionRange((DateTime)propertyValues["Start"], (DateTime)propertyValues["End"]);
+ }
+
+ public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) {
+ return true;
+ }
+
+ public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) {
+ return TypeDescriptor.GetProperties(typeof(SelectionRange), attributes);
+ }
+
+ public override bool GetPropertiesSupported(ITypeDescriptorContext context) {
+ return true;
+ }
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SendKeys.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SendKeys.cs
new file mode 100644
index 00000000000..1b8837b32f9
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SendKeys.cs
@@ -0,0 +1,199 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// NOT COMPLETE
+
+using System.Collections;
+
+namespace System.Windows.Forms {
+ public class SendKeys {
+ #region Local variables
+ private static Queue keys = new Queue();
+ #endregion
+
+ #region Private methods
+ private SendKeys() {
+ }
+
+ private static IntPtr CharToVKey(char key) {
+ // FIXME - build a table to translate between vkeys and chars
+ throw new NotImplementedException();
+ }
+
+ private static IntPtr SymbolToVKey(string symbol) {
+ // FIXME - build a table to translate between vkeys and symbols
+ throw new NotImplementedException();
+ }
+
+ private static void SendSymbol(IntPtr hwnd, string symbol, int repeat_count, bool down) {
+ MSG msg;
+
+ if (down) {
+ for (int i = 0; i < repeat_count; i++ ) {
+ msg = new MSG();
+ msg.hwnd = hwnd;
+ msg.message = Msg.WM_KEYDOWN;
+ msg.wParam = SymbolToVKey(symbol);
+ msg.lParam = IntPtr.Zero;
+
+ keys.Enqueue(msg);
+ }
+ } else {
+ msg = new MSG();
+ msg.hwnd = hwnd;
+ msg.message = Msg.WM_KEYUP;
+ msg.wParam = SymbolToVKey(symbol);
+ msg.lParam = IntPtr.Zero;
+
+ keys.Enqueue(msg);
+ }
+ }
+
+ private static void SendKey(IntPtr hwnd, char key, int repeat_count) {
+ MSG msg;
+
+ for (int i = 0; i < repeat_count; i++ ) {
+ msg = new MSG();
+ msg.hwnd = hwnd;
+ msg.message = Msg.WM_KEYDOWN;
+ msg.wParam = CharToVKey(key);
+ msg.lParam = IntPtr.Zero;
+
+ keys.Enqueue(msg);
+ }
+
+ msg = new MSG();
+ msg.hwnd = hwnd;
+ msg.message = Msg.WM_KEYUP;
+ msg.wParam = CharToVKey(key);
+ msg.lParam = IntPtr.Zero;
+
+ keys.Enqueue(msg);
+ }
+
+ #endregion // Private Methods
+
+ #region Public Static Methods
+ public static void Flush() {
+ MSG msg;
+
+ // FIXME - we only send to our own app, instead of the active app
+ while (keys.Count > 0) {
+ msg = (MSG)keys.Dequeue();
+ XplatUI.TranslateMessage (ref msg);
+ XplatUI.DispatchMessage (ref msg);
+ }
+ }
+
+ [MonoTODO("Finish")]
+ public static void Send(string key_string) {
+ IntPtr hwnd;
+ int shift_reset;
+ int control_reset;
+ int alt_reset;
+
+ hwnd = XplatUI.GetActive();
+
+ shift_reset = 0;
+ control_reset = 0;
+ alt_reset = 0;
+
+ for (int i = 0; i < key_string.Length; i++) {
+ switch(key_string[i]) {
+ case '+': {
+ SendSymbol(hwnd, "SHIFT", 1, true);
+ shift_reset = 2;
+ break;
+ }
+
+ case '^': {
+ SendSymbol(hwnd, "CONTROL", 1, true);
+ control_reset = 2;
+ break;
+ }
+
+ case '%': {
+ SendSymbol(hwnd, "ALT", 1, true);
+ alt_reset = 2;
+ break;
+ }
+
+ case '~': {
+ SendSymbol(hwnd, "ENTER", 1, true);
+ SendSymbol(hwnd, "ENTER", 1, false);
+ break;
+ }
+
+ case '(':
+ case ')': {
+ // FIXME - implement group parser
+ break;
+ }
+
+ case '{':
+ case '}': {
+ // FIXME - implement symbol parser
+ break;
+ }
+
+ default: {
+ SendKey(hwnd, key_string[i], 1);
+ break;
+ }
+ }
+
+
+
+ if (shift_reset > 0) {
+ shift_reset--;
+ if (shift_reset == 0) {
+ SendSymbol(hwnd, "SHIFT", 1, false);
+ }
+ }
+
+ if (control_reset > 0) {
+ control_reset--;
+ if (control_reset == 0) {
+ SendSymbol(hwnd, "CONTROL", 1, false);
+ }
+ }
+
+ if (alt_reset > 0) {
+ alt_reset--;
+ if (alt_reset == 0) {
+ SendSymbol(hwnd, "ALT", 1, false);
+ }
+ }
+ }
+ }
+
+ public static void SendWait(string keys) {
+ Send(keys);
+ Flush();
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Shortcut.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Shortcut.cs
new file mode 100644
index 00000000000..ca6b72ed8b0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Shortcut.cs
@@ -0,0 +1,187 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+//
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+ [ComVisible (true)]
+ public enum Shortcut
+ {
+ Alt0 = 0x040030,
+ Alt1 = 0x040031,
+ Alt2 = 0x040032,
+ Alt3 = 0x040033,
+ Alt4 = 0x040034,
+ Alt5 = 0x040035,
+ Alt6 = 0x040036,
+ Alt7 = 0x040037,
+ Alt8 = 0x040038,
+ Alt9 = 0x040039,
+ AltBksp = 0x040008,
+ AltF1 = 0x040070,
+ AltF10 = 0x040079,
+ AltF11 = 0x04007A,
+ AltF12 = 0x04007B,
+ AltF2 = 0x040071,
+ AltF3 = 0x040072,
+ AltF4 = 0x040073,
+ AltF5 = 0x040074,
+ AltF6 = 0x040075,
+ AltF7 = 0x040076,
+ AltF8 = 0x040077,
+ AltF9 = 0x040078,
+ Ctrl0 = 0x020030,
+ Ctrl1 = 0x020031,
+ Ctrl2 = 0x020032,
+ Ctrl3 = 0x020033,
+ Ctrl4 = 0x020034,
+ Ctrl5 = 0x020035,
+ Ctrl6 = 0x020036,
+ Ctrl7 = 0x020037,
+ Ctrl8 = 0x020038,
+ Ctrl9 = 0x020039,
+ CtrlA = 0x020041,
+ CtrlB = 0x020042,
+ CtrlC = 0x020043,
+ CtrlD = 0x020044,
+ CtrlDel = 0x02002E,
+ CtrlE = 0x020045,
+ CtrlF = 0x020046,
+ CtrlF1 = 0x020070,
+ CtrlF10 = 0x020079,
+ CtrlF11 = 0x02007A,
+ CtrlF12 = 0x02007B,
+ CtrlF2 = 0x020071,
+ CtrlF3 = 0x020072,
+ CtrlF4 = 0x020073,
+ CtrlF5 = 0x020074,
+ CtrlF6 = 0x020075,
+ CtrlF7 = 0x020076,
+ CtrlF8 = 0x020077,
+ CtrlF9 = 0x020078,
+ CtrlG = 0x020047,
+ CtrlH = 0x020048,
+ CtrlI = 0x020049,
+ CtrlIns = 0x02002D,
+ CtrlJ = 0x02004A,
+ CtrlK = 0x02004B,
+ CtrlL = 0x02004C,
+ CtrlM = 0x02004D,
+ CtrlN = 0x02004E,
+ CtrlO = 0x02004F,
+ CtrlP = 0x020050,
+ CtrlQ = 0x020051,
+ CtrlR = 0x020052,
+ CtrlS = 0x020053,
+ CtrlShift0 = 0x030030,
+ CtrlShift1 = 0x030031,
+ CtrlShift2 = 0x030032,
+ CtrlShift3 = 0x030033,
+ CtrlShift4 = 0x030034,
+ CtrlShift5 = 0x030035,
+ CtrlShift6 = 0x030036,
+ CtrlShift7 = 0x030037,
+ CtrlShift8 = 0x030038,
+ CtrlShift9 = 0x030039,
+ CtrlShiftA = 0x030041,
+ CtrlShiftB = 0x030042,
+ CtrlShiftC = 0x030043,
+ CtrlShiftD = 0x030044,
+ CtrlShiftE = 0x030045,
+ CtrlShiftF = 0x030046,
+ CtrlShiftF1 = 0x030070,
+ CtrlShiftF10 = 0x030079,
+ CtrlShiftF11 = 0x03007A,
+ CtrlShiftF12 = 0x03007B,
+ CtrlShiftF2 = 0x030071,
+ CtrlShiftF3 = 0x030072,
+ CtrlShiftF4 = 0x030073,
+ CtrlShiftF5 = 0x030074,
+ CtrlShiftF6 = 0x030075,
+ CtrlShiftF7 = 0x030076,
+ CtrlShiftF8 = 0x030077,
+ CtrlShiftF9 = 0x030078,
+ CtrlShiftG = 0x030047,
+ CtrlShiftH = 0x030048,
+ CtrlShiftI = 0x030049,
+ CtrlShiftJ = 0x03004A,
+ CtrlShiftK = 0x03004B,
+ CtrlShiftL = 0x03004C,
+ CtrlShiftM = 0x03004D,
+ CtrlShiftN = 0x03004E,
+ CtrlShiftO = 0x03004F,
+ CtrlShiftP = 0x030050,
+ CtrlShiftQ = 0x030051,
+ CtrlShiftR = 0x030052,
+ CtrlShiftS = 0x030053,
+ CtrlShiftT = 0x030054,
+ CtrlShiftU = 0x030055,
+ CtrlShiftV = 0x030056,
+ CtrlShiftW = 0x030057,
+ CtrlShiftX = 0x030058,
+ CtrlShiftY = 0x030059,
+ CtrlShiftZ = 0x03005A,
+ CtrlT = 0x020054,
+ CtrlU = 0x020055,
+ CtrlV = 0x020056,
+ CtrlW = 0x020057,
+ CtrlX = 0x020058,
+ CtrlY = 0x020059,
+ CtrlZ = 0x02005A,
+ Del = 0x00002E,
+ F1 = 0x000070,
+ F10 = 0x000079,
+ F11 = 0x00007A,
+ F12 = 0x00007B,
+ F2 = 0x000071,
+ F3 = 0x000072,
+ F4 = 0x000073,
+ F5 = 0x000074,
+ F6 = 0x000075,
+ F7 = 0x000076,
+ F8 = 0x000077,
+ F9 = 0x000078,
+ Ins = 0x00002D,
+ None = 0x000000,
+ ShiftDel = 65582,
+ ShiftF1 = 65648,
+ ShiftF10 = 65657,
+ ShiftF11 = 65658,
+ ShiftF12 = 65659,
+ ShiftF2 = 65649,
+ ShiftF3 = 65650,
+ ShiftF4 = 65651,
+ ShiftF5 = 65652,
+ ShiftF6 = 65653,
+ ShiftF7 = 65654,
+ ShiftF8 = 65655,
+ ShiftF9 = 65656,
+ ShiftIns = 65581,
+ }
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeGrip.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeGrip.cs
new file mode 100644
index 00000000000..c2056a6844f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeGrip.cs
@@ -0,0 +1,134 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+using System;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+
+ internal class SizeGrip : Control {
+ #region Local Variables
+ private bool redraw;
+ private Point capture_point;
+ private int window_w;
+ private int window_h;
+ private bool show_grip;
+ private bool hide_pending;
+ #endregion // Local Variables
+
+ #region Constructors
+ public SizeGrip ()
+ {
+ this.Cursor = Cursors.SizeNWSE;
+ show_grip = true;
+ redraw = true;
+ hide_pending = false;
+ }
+ #endregion // Constructors
+
+ #region Properties
+ public bool ShowGrip {
+ get {
+ return show_grip;
+ }
+
+ set {
+ show_grip = value;
+ redraw = true;
+ }
+ }
+ #endregion // Properties
+
+ #region Methods
+ protected override void OnPaint (PaintEventArgs pe) {
+ if (redraw && show_grip) {
+ pe.Graphics.FillRectangle (new SolidBrush (ThemeEngine.Current.ColorControl), ClientRectangle);
+ ControlPaint.DrawSizeGrip (pe.Graphics, BackColor, ClientRectangle);
+ }
+ base.OnPaint (pe);
+ }
+
+ protected override void OnSizeChanged (EventArgs e) {
+ base.OnSizeChanged (e);
+ redraw = true;
+ }
+
+ protected override void OnVisibleChanged (EventArgs e) {
+ base.OnVisibleChanged (e);
+ redraw = true;
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e) {
+ Capture = true;
+
+ capture_point = Control.MousePosition;
+
+ window_w = parent.Width;
+ window_h = parent.Height;
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e) {
+ if (this.is_captured) {
+ int delta_x;
+ int delta_y;
+ Point current_point;
+
+ current_point = Control.MousePosition;
+
+ delta_x = current_point.X - capture_point.X;
+ delta_y = current_point.Y - capture_point.Y;
+
+ this.parent.Size = new Size(window_w + delta_x, window_h + delta_y);
+ XplatUI.DoEvents();
+ }
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e) {
+ if (Capture) {
+ Capture = false;
+ if (hide_pending) {
+ Hide();
+ hide_pending = false;
+ }
+ }
+ }
+
+
+ protected override void SetVisibleCore(bool value) {
+ if (Capture) {
+ if (value == false) {
+ hide_pending = true;
+ } else {
+ hide_pending = false;
+ }
+ return;
+ }
+ base.SetVisibleCore (value);
+ }
+
+ #endregion // Methods
+ }
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeGripStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeGripStyle.cs
new file mode 100644
index 00000000000..e2c32be9118
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeGripStyle.cs
@@ -0,0 +1,38 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+// COMPLETE
+
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public enum SizeGripStyle
+ {
+ Auto = 0,
+ Show = 1,
+ Hide = 2
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeType.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeType.cs
new file mode 100644
index 00000000000..464dcea3390
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeType.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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:
+// Miguel de Icaza (miguel@gnome.org)
+//
+// (C) 2004 Novell, Inc.
+//
+#if NET_2_0
+namespace System.Windows.Forms {
+ public enum SizeType {
+ AutoSize = 0,
+ Absolute = 1,
+ Percent = 2
+ }
+}
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SortOrder.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SortOrder.cs
new file mode 100644
index 00000000000..804a78dd6da
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SortOrder.cs
@@ -0,0 +1,38 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+// COMPLETE
+
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public enum SortOrder
+ {
+ None = 0,
+ Ascending = 1,
+ Descending = 2
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Splitter.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Splitter.cs
new file mode 100644
index 00000000000..d547072c4d2
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Splitter.cs
@@ -0,0 +1,749 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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-2006 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Peter Dennis Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+#undef Debug
+
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [DefaultEvent("SplitterMoved")]
+ [Designer("System.Windows.Forms.Design.SplitterDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ [DefaultProperty("Dock")]
+ public class Splitter : Control, IMessageFilter {
+ #region Enums
+ private enum DrawType {
+ Initial,
+ Redraw,
+ Finish
+ }
+ #endregion // Enums
+
+ #region Local Variables
+ static private Cursor splitter_ns;
+ static private Cursor splitter_we;
+ private BorderStyle border_style;
+ private int min_extra;
+ private int min_size;
+ private int split_position; // Current splitter position
+ private int prev_split_position; // Previous splitter position, only valid during drag
+ private int click_offset; // Click offset from border of splitter control
+ private int splitter_size; // Size (width or height) of our splitter control
+ private bool horizontal; // true if we've got a horizontal splitter
+ private Control affected; // The control that the splitter resizes
+ private Control filler; // The control that MinExtra prevents from being shrunk to 0 size
+ private SplitterEventArgs sevent; // We cache the object, prevents fragmentation
+ private int limit_min; // The max we're allowed to move the splitter left/up
+ private int limit_max; // The max we're allowed to move the splitter right/down
+ #endregion // Local Variables
+
+ #region Constructors
+ static Splitter() {
+ try {
+ splitter_ns = new Cursor(typeof(Splitter), "SplitterNS.cur");
+ }
+
+ catch (System.IO.FileNotFoundException) {
+ splitter_ns = Cursors.SizeNS;
+ }
+
+ try {
+ splitter_we = new Cursor(typeof(Splitter), "SplitterWE.cur");
+ }
+
+ catch (System.IO.FileNotFoundException) {
+ splitter_we = Cursors.SizeWE;
+ }
+ }
+
+ public Splitter() {
+
+ min_extra = 25;
+ min_size = 25;
+ split_position = -1;
+ splitter_size = 3;
+ horizontal = false;
+ sevent = new SplitterEventArgs(0, 0, 0, 0);
+
+ SetStyle(ControlStyles.Selectable, false);
+ Anchor = AnchorStyles.None;
+ Dock = DockStyle.Left;
+
+ Paint += new PaintEventHandler(PaintSplitter);
+ Layout += new LayoutEventHandler(LayoutSplitter);
+ this.ParentChanged += new EventHandler(ReparentSplitter);
+ Cursor = splitter_we;
+ }
+ #endregion // Constructors
+
+ #region Public Instance Properties
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool AllowDrop {
+ get {
+ return base.AllowDrop;
+ }
+
+ set {
+ base.AllowDrop = value;
+ }
+ }
+
+ [Browsable(false)]
+ [DefaultValue(AnchorStyles.None)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override AnchorStyles Anchor {
+ get {
+ return AnchorStyles.None;
+ }
+
+ set {
+ ; // MS doesn't set it
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Image BackgroundImage {
+ get {
+ return base.BackgroundImage;
+ }
+
+ set {
+ base.BackgroundImage = value;
+ }
+ }
+
+ [DispId(-504)]
+ [DefaultValue (BorderStyle.None)]
+ [MWFDescription("Sets the border style for the splitter")]
+ [MWFCategory("Appearance")]
+ public BorderStyle BorderStyle {
+ get {
+ return border_style;
+ }
+
+ set {
+ border_style = value;
+
+ switch(value) {
+ case BorderStyle.FixedSingle: {
+ splitter_size = 4; // We don't get motion events for 1px wide windows on X11. sigh.
+ break;
+ }
+
+ case BorderStyle.Fixed3D: {
+ value = BorderStyle.None;
+ splitter_size = 3;
+ break;
+ }
+
+ case BorderStyle.None: {
+ splitter_size = 3;
+ break;
+ }
+
+ default: {
+ throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
+ }
+ }
+
+ base.InternalBorderStyle = value;
+ }
+ }
+
+ [DefaultValue(DockStyle.Left)]
+ [Localizable(true)]
+ public override DockStyle Dock {
+ get {
+ return base.Dock;
+ }
+
+ set {
+ if (!Enum.IsDefined (typeof (DockStyle), value) || (value == DockStyle.None) || (value == DockStyle.Fill)) {
+ throw new ArgumentException("Splitter must be docked left, top, bottom or right");
+ }
+
+ if ((value == DockStyle.Top) || (value == DockStyle.Bottom)) {
+ horizontal = true;
+ Cursor = splitter_ns;
+ } else {
+ horizontal = false;
+ Cursor = splitter_we;
+ }
+ base.Dock = value;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Font Font {
+ get {
+ return base.Font;
+ }
+
+ set {
+ base.Font = value;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Color ForeColor {
+ get {
+ return base.ForeColor;
+ }
+
+ set {
+ base.ForeColor = value;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new ImeMode ImeMode {
+ get {
+ return base.ImeMode;
+ }
+
+ set {
+ base.ImeMode = value;
+ }
+ }
+
+ [DefaultValue(25)]
+ [Localizable(true)]
+ [MWFDescription("Sets minimum size of undocked window")]
+ [MWFCategory("Behaviour")]
+ public int MinExtra {
+ get {
+ return min_extra;
+ }
+
+ set {
+ min_extra = value;
+ }
+ }
+
+ [DefaultValue(25)]
+ [Localizable(true)]
+ [MWFDescription("Sets minimum size of the resized control")]
+ [MWFCategory("Behaviour")]
+ public int MinSize {
+ get {
+ return min_size;
+ }
+
+ set {
+ min_size = value;
+ }
+ }
+
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [MWFDescription("Current splitter position")]
+ [MWFCategory("Layout")]
+ public int SplitPosition {
+ get {
+ affected = AffectedControl;
+ if (affected == null) {
+ return -1;
+ }
+
+ if (Capture) {
+ return CalculateSplitPosition();
+ }
+
+ if (horizontal) {
+ return affected.Height;
+ } else {
+ return affected.Width;
+ }
+ }
+
+ set {
+ affected = AffectedControl;
+
+ if (Capture || (affected == null)) {
+ return;
+ }
+
+ if (horizontal) {
+ affected.Height = value;
+ } else {
+ affected.Width = value;
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool TabStop {
+ get {
+ return base.TabStop;
+ }
+
+ set {
+ base.TabStop = value;
+ }
+ }
+
+ [Bindable(false)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override string Text {
+ get {
+ return base.Text;
+ }
+
+ set {
+ base.Text = value;
+ }
+ }
+
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Properties
+ protected override CreateParams CreateParams {
+ get {
+ return base.CreateParams;
+ }
+ }
+
+ protected override ImeMode DefaultImeMode {
+ get {
+ return ImeMode.Disable;
+ }
+ }
+
+ protected override Size DefaultSize {
+ get {
+ return new Size (3, 3);
+ }
+ }
+ #endregion // Protected Instance Properties
+
+ #region Public Instance Methods
+ public bool PreFilterMessage(ref Message m) {
+ return false;
+ }
+
+ public override string ToString() {
+ return base.ToString () + String.Format(", MinExtra: {0}, MinSize: {1}", min_extra, min_size);
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected override void OnKeyDown(KeyEventArgs e) {
+ base.OnKeyDown (e);
+ if (Capture && (e.KeyCode == Keys.Escape)) {
+ Capture = false;
+ DrawDragHandle(DrawType.Finish);
+ }
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e) {
+ Point pt;
+
+ base.OnMouseDown (e);
+
+ // Only allow if we are set up properly
+ if ((affected == null) || (filler == null)) {
+ affected = AffectedControl;
+ filler = FillerControl;
+ }
+
+ if (affected == null || e.Button != MouseButtons.Left) {
+ return;
+ }
+
+ // Prepare the job
+ Capture = true;
+
+ // Calculate limits
+ if (filler != null) {
+ if (horizontal) {
+ if (dock_style == DockStyle.Top) {
+ limit_min = affected.Bounds.Top + min_size;
+ limit_max = filler.Bounds.Bottom - min_extra + this.bounds.Top - filler.Bounds.Top;
+ } else {
+ limit_min = filler.Bounds.Top + min_extra + this.bounds.Top - filler.Bounds.Bottom;
+ limit_max = affected.Bounds.Bottom - min_size - this.Height;
+ }
+ } else {
+ if (dock_style == DockStyle.Left) {
+ limit_min = affected.Bounds.Left + min_size;
+ limit_max = filler.Bounds.Right - min_extra + this.bounds.Left - filler.Bounds.Left;
+ } else {
+ limit_min = filler.Bounds.Left + min_extra + this.bounds.Left - filler.Bounds.Right;
+ limit_max = affected.Bounds.Right - min_size - this.Width;
+ }
+ }
+ } else {
+ limit_min = 0;
+ if (horizontal) {
+ limit_max = affected.Parent.Height;
+ } else {
+ limit_max = affected.Parent.Width;
+ }
+ }
+
+ #if Debug
+ Console.WriteLine("Sizing limits: Min:{0}, Max:{1}", limit_min, limit_max);
+ #endif
+
+ pt = PointToScreen(parent.PointToClient(new Point(e.X, e.Y)));
+
+ if (horizontal) {
+ split_position = pt.Y;
+ if (dock_style == DockStyle.Top) {
+ click_offset = e.Y;
+ } else {
+ click_offset = -e.Y;
+ }
+ } else {
+ split_position = pt.X;
+ if (dock_style == DockStyle.Left) {
+ click_offset = e.X;
+ } else {
+ click_offset = -e.X;
+ }
+ }
+
+ // We need to set this, in case we never get a mouse move
+ prev_split_position = split_position;
+
+ #if Debug
+ Console.WriteLine("Click-offset: {0} MouseDown split position: {1}", click_offset, split_position);
+ #endif
+
+ // Draw our initial handle
+ DrawDragHandle(DrawType.Initial);
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e) {
+ Point pt;
+
+ base.OnMouseMove (e);
+
+ if (!Capture || e.Button != MouseButtons.Left) {
+ return;
+ }
+
+ // We need our mouse coordinates relative to our parent
+ pt = PointToScreen(parent.PointToClient(new Point(e.X, e.Y)));
+
+ // Grab our new coordinates
+ prev_split_position = split_position;
+ if (horizontal) {
+ split_position = pt.Y;
+ } else {
+ split_position = pt.X;
+ }
+ // Enforce limits
+ if (split_position < limit_min) {
+ #if Debug
+ Console.WriteLine("SplitPosition {0} less than minimum {1}, setting to minimum", split_position, limit_min);
+ #endif
+ split_position = limit_min;
+ } else if (split_position > limit_max) {
+ #if Debug
+ Console.WriteLine("SplitPosition {0} more than maximum {1}, setting to maximum", split_position, limit_max);
+ #endif
+ split_position = limit_max;
+ }
+
+ // Don't waste cycles
+ if (prev_split_position != split_position) {
+ // Update our handle location
+ DrawDragHandle(DrawType.Redraw);
+ }
+
+ // Prepare the event
+ if (horizontal) {
+ sevent.split_x = 0;
+ sevent.split_y = split_position;
+ } else {
+ sevent.split_x = split_position;
+ sevent.split_y = 0;
+ }
+
+ sevent.x = pt.X;
+ sevent.y = pt.Y;
+
+ // Fire the event
+ OnSplitterMoving(sevent);
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e) {
+ if (!Capture || e.Button != MouseButtons.Left) {
+ base.OnMouseUp (e);
+ return;
+ }
+
+ Capture = false;
+ DrawDragHandle(DrawType.Finish);
+
+ // Resize the affected window
+ if (horizontal) {
+ affected.Height = CalculateSplitPosition() - click_offset;
+ #if Debug
+ Console.WriteLine("Setting height of affected control to {0}", CalculateSplitPosition() - click_offset);
+ #endif
+ } else {
+ affected.Width = CalculateSplitPosition() - click_offset;
+ #if Debug
+ Console.WriteLine("Setting width of affected control to {0}", CalculateSplitPosition() - click_offset);
+ #endif
+ }
+
+ base.OnMouseUp (e);
+
+ // It seems that MS is sending some data that doesn't quite make sense
+ // In this event. It tried to match their stuff.., not sure about split_x...
+
+ // Prepare the event
+ if (horizontal) {
+ sevent.x = 0;
+ sevent.y = split_position;
+ sevent.split_x = 200;
+ sevent.split_y = split_position;
+ } else {
+ sevent.x = split_position;
+ sevent.y = 0;
+ sevent.split_x = split_position;
+ sevent.split_y = 200;
+ }
+
+
+ // Fire the event
+ OnSplitterMoved(sevent);
+ }
+
+ protected virtual void OnSplitterMoved(SplitterEventArgs sevent) {
+ if (SplitterMoved != null) {
+ SplitterMoved(this, sevent);
+ }
+ }
+
+ protected virtual void OnSplitterMoving(SplitterEventArgs sevent) {
+ if (SplitterMoving != null) {
+ SplitterMoving(this, sevent);
+ }
+ }
+
+ protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
+ // enforce our width / height
+ if (horizontal) {
+ base.SetBoundsCore (x, y, width, splitter_size, specified);
+ } else {
+ base.SetBoundsCore (x, y, splitter_size, height, specified);
+ }
+ }
+ #endregion // Protected Instance Methods
+
+ #region Private Properties and Methods
+ private Control AffectedControl {
+ get {
+ if (parent == null) {
+ return null;
+ }
+
+ // Doc says the first control preceeding us in the zorder
+ for (int i = parent.Controls.GetChildIndex(this) + 1; i < parent.Controls.Count; i++) {
+ switch(this.Dock) {
+ case DockStyle.Top: {
+ if (Top == parent.Controls[i].Bottom) {
+ return parent.Controls[i];
+ }
+ break;
+ }
+
+ case DockStyle.Bottom: {
+ if (Bottom == parent.Controls[i].Top) {
+ return parent.Controls[i];
+ }
+ break;
+ }
+
+ case DockStyle.Left: {
+ if (Left == parent.Controls[i].Right) {
+ return parent.Controls[i];
+ }
+ break;
+ }
+
+ case DockStyle.Right: {
+ if (Right == parent.Controls[i].Left) {
+ return parent.Controls[i];
+ }
+ break;
+ }
+ }
+ }
+ return null;
+ }
+ }
+
+ private Control FillerControl {
+ get {
+ if (parent == null) {
+ return null;
+ }
+
+ // Doc says the first control preceeding us in the zorder
+ for (int i = parent.Controls.GetChildIndex(this) - 1; i >= 0; i--) {
+ if (parent.Controls[i].Dock == DockStyle.Fill) {
+ return parent.Controls[i];
+ }
+ }
+ return null;
+ }
+ }
+
+ private int CalculateSplitPosition() {
+ if (horizontal) {
+ if (dock_style == DockStyle.Top) {
+ return split_position;
+ } else {
+ return affected.Bottom - split_position - splitter_size;
+ }
+ } else {
+ if (dock_style == DockStyle.Left) {
+ return split_position;
+ } else {
+ return affected.Right - split_position - splitter_size;
+ }
+ }
+ }
+
+ private void PaintSplitter(object sender, PaintEventArgs e) {
+ e.Graphics.FillRectangle(ThemeEngine.Current.ResPool.GetSolidBrush(this.BackColor), e.ClipRectangle);
+ }
+
+ private void LayoutSplitter(object sender, LayoutEventArgs e) {
+ affected = AffectedControl;
+ filler = FillerControl;
+ }
+
+ private void ReparentSplitter(object sender, EventArgs e) {
+ affected = null;
+ filler = null;
+ }
+
+ private void DrawDragHandle(DrawType type) {
+ Rectangle prev;
+ Rectangle current;
+
+ if (horizontal) {
+ prev = new Rectangle(0, prev_split_position - click_offset + 1, Width, 0);
+ current = new Rectangle(0, split_position - click_offset + 1, Width, 0);
+ } else {
+ prev = new Rectangle(prev_split_position - click_offset + 1, 0, 0, Height);
+ current = new Rectangle(split_position - click_offset + 1, 0, 0, Height);
+ }
+
+ switch(type) {
+ case DrawType.Initial: {
+ XplatUI.DrawReversibleRectangle(Parent.window.Handle, current, 3);
+ return;
+ }
+
+ case DrawType.Redraw: {
+ if (prev.X == current.X && prev.Y == current.Y) {
+ return;
+ }
+
+ XplatUI.DrawReversibleRectangle(Parent.window.Handle, prev, 3);
+ XplatUI.DrawReversibleRectangle(Parent.window.Handle, current, 3);
+ return;
+ }
+
+ case DrawType.Finish: {
+ XplatUI.DrawReversibleRectangle(Parent.window.Handle, prev, 3);
+ return;
+ }
+ }
+ }
+ #endregion // Private Properties and Methods
+
+ #region Events
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler BackgroundImageChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler Enter;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler FontChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler ForeColorChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler ImeModeChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event KeyEventHandler KeyDown;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event KeyPressEventHandler KeyPress;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event KeyEventHandler KeyUp;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler Leave;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler TabStopChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler TextChanged;
+
+ public event SplitterEventHandler SplitterMoved;
+ public event SplitterEventHandler SplitterMoving;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SplitterEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SplitterEventArgs.cs
new file mode 100644
index 00000000000..3570f84df50
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SplitterEventArgs.cs
@@ -0,0 +1,79 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Aleksandar Dezelin adezelin@beotel.net
+// Peter Dennis Bartok pbartok@novell.com
+//
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [ComVisible(true)]
+ public class SplitterEventArgs : EventArgs
+ {
+ #region Private fields
+
+ internal int split_x;
+ internal int split_y;
+ internal int x;
+ internal int y;
+
+ #endregion
+
+ #region Constructors
+
+ public SplitterEventArgs(int x, int y, int splitX, int splitY)
+ {
+ this.x = x;
+ this.y = y;
+ SplitX = splitX;
+ SplitY = splitY;
+ }
+
+ #endregion
+
+ #region Properties
+
+ public int SplitX {
+ get { return split_x; }
+ set { split_x = value; }
+ }
+
+ public int SplitY {
+ get { return split_y; }
+ set { split_y = value; }
+ }
+
+ public int X {
+ get { return x; }
+ }
+
+ public int Y {
+ get { return y; }
+ }
+
+ #endregion
+ }
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SplitterEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SplitterEventHandler.cs
new file mode 100644
index 00000000000..c1c6131a7b5
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SplitterEventHandler.cs
@@ -0,0 +1,32 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Aleksandar Dezelin adezelin@beotel.net
+//
+
+using System;
+
+namespace System.Windows.Forms
+{
+ public delegate void SplitterEventHandler(object sender, SplitterEventArgs e);
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBar.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBar.cs
new file mode 100644
index 00000000000..3b87051dfe1
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBar.cs
@@ -0,0 +1,616 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+//
+// TODO:
+// - Change cursor when mouse is over grip
+//
+
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.Drawing.Text;
+using System.Drawing.Imaging;
+
+namespace System.Windows.Forms {
+ [DefaultEvent("PanelClick")]
+ [Designer("System.Windows.Forms.Design.StatusBarDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ [DefaultProperty("Text")]
+ public class StatusBar : Control {
+ #region Fields
+ private StatusBarPanelCollection panels;
+
+ private Color back_color;
+ private Color fore_color;
+
+ private bool show_panels = false;
+ private bool sizing_grip = true;
+
+ #endregion // Fields
+
+ #region Public Constructors
+ [MonoTODO("Change cursor when mouse is over grip")]
+ public StatusBar ()
+ {
+ base.Dock = DockStyle.Bottom;
+ back_color = SystemColors.Control;
+ fore_color = SystemColors.ControlText;
+ Anchor = AnchorStyles.Top | AnchorStyles.Left;
+ this.TabStop = false;
+ this.SetStyle(ControlStyles.UserPaint | ControlStyles.Selectable, false);
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Color BackColor {
+ get { return back_color; }
+ set {
+ if (value == BackColor)
+ return;
+ back_color = value;
+ if (BackColorChanged != null)
+ BackColorChanged (this, EventArgs.Empty);
+ Update ();
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Image BackgroundImage {
+ get { return base.BackgroundImage; }
+ set {
+ if (value == BackgroundImage)
+ return;
+ base.BackgroundImage = value;
+ if (BackgroundImageChanged != null)
+ BackgroundImageChanged (this, EventArgs.Empty);
+ }
+ }
+
+ [Localizable(true)]
+ [DefaultValue(DockStyle.Bottom)]
+ public override DockStyle Dock {
+ get { return base.Dock; }
+ set {
+ if (value == Dock)
+ return;
+ base.Dock = value;
+ Update ();
+ }
+ }
+
+ [Localizable(true)]
+ public override Font Font {
+ get { return base.Font; }
+ set {
+ if (value == Font)
+ return;
+ base.Font = value;
+ Update ();
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Color ForeColor {
+ get { return fore_color; }
+ set {
+ if (value == ForeColor)
+ return;
+ fore_color = value;
+ if (ForeColorChanged != null)
+ ForeColorChanged (this, EventArgs.Empty);
+ Update ();
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new ImeMode ImeMode {
+ get { return base.ImeMode; }
+ set {
+ if (value == ImeMode)
+ return;
+ base.ImeMode = value;
+ if (ImeModeChanged != null)
+ ImeModeChanged (this, EventArgs.Empty);
+ }
+ }
+
+ [MergableProperty(false)]
+ [Localizable(true)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public StatusBarPanelCollection Panels {
+ get {
+ if (panels == null)
+ panels = new StatusBarPanelCollection (this);
+ return panels;
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool ShowPanels {
+ get { return show_panels; }
+ set {
+ if (show_panels == value)
+ return;
+ show_panels = value;
+ Update ();
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool SizingGrip {
+ get { return sizing_grip; }
+ set {
+ if (sizing_grip == value)
+ return;
+ sizing_grip = value;
+ Update ();
+ }
+ }
+
+ [DefaultValue(false)]
+ public new bool TabStop {
+ get { return base.TabStop; }
+ set { base.TabStop = value; }
+ }
+
+ [Localizable(true)]
+ public override string Text {
+ get { return base.Text; }
+ set {
+ if (value == Text)
+ return;
+ base.Text = value;
+ Update ();
+ }
+
+ }
+
+ #endregion Public Instance Properties
+
+ #region Protected Instance Properties
+ protected override CreateParams CreateParams {
+ get {
+ return base.CreateParams;
+ }
+ }
+
+ protected override ImeMode DefaultImeMode {
+ get { return ImeMode.Disable; }
+ }
+
+ protected override Size DefaultSize {
+ get { return ThemeEngine.Current.StatusBarDefaultSize; }
+ }
+
+ #endregion // Protected Instance Properties
+
+ #region Public Instance Methods
+ public override string ToString () {
+ return base.ToString () + ", Panels.Count: " + Panels.Count +
+ (Panels.Count > 0 ? ", Panels[0]: " + Panels [0] : String.Empty);
+ }
+
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected override void CreateHandle ()
+ {
+ base.CreateHandle ();
+ }
+
+ protected override void Dispose (bool disposing) {
+ base.Dispose (disposing);
+ }
+
+ protected virtual void OnDrawItem (StatusBarDrawItemEventArgs e) {
+ if (DrawItem != null)
+ DrawItem (this, e);
+ }
+
+ protected override void OnHandleCreated (EventArgs e) {
+ base.OnHandleCreated (e);
+ CalcPanelSizes ();
+ }
+
+ protected override void OnHandleDestroyed (EventArgs e) {
+ base.OnHandleDestroyed (e);
+ }
+
+ protected override void OnLayout (LayoutEventArgs e) {
+ base.OnLayout (e);
+ }
+
+ protected override void OnMouseDown (MouseEventArgs e) {
+ if (panels == null)
+ return;
+
+ float prev_x = 0;
+ float gap = ThemeEngine.Current.StatusBarHorzGapWidth;
+ for (int i = 0; i < panels.Count; i++) {
+ float x = panels [i].Width + prev_x + (i == panels.Count - 1 ? gap : gap / 2);
+ if (e.X >= prev_x && e.X <= x) {
+ OnPanelClick (new StatusBarPanelClickEventArgs (panels [i],
+ e.Button, e.Clicks, e.X, e.Y));
+ break;
+ }
+ prev_x = x;
+ }
+
+ base.OnMouseDown (e);
+ }
+
+ protected virtual void OnPanelClick (StatusBarPanelClickEventArgs e) {
+ if (PanelClick != null)
+ PanelClick (this, e);
+ }
+
+ protected override void OnResize (EventArgs e)
+ {
+ base.OnResize (e);
+
+ if (Width <= 0 || Height <= 0)
+ return;
+
+ Update ();
+ }
+
+ protected override void WndProc(ref Message m) {
+ switch ((Msg) m.Msg) {
+ case Msg.WM_PAINT: {
+ PaintEventArgs paint_event;
+
+ paint_event = XplatUI.PaintEventStart (Handle, true);
+ DoPaint (paint_event);
+ XplatUI.PaintEventEnd (Handle, true);
+ return;
+ }
+ }
+ base.WndProc (ref m);
+ }
+
+ #endregion // Methods
+
+
+ #region Internal Methods
+ internal void OnDrawItemInternal (StatusBarDrawItemEventArgs e)
+ {
+ OnDrawItem (e);
+ }
+
+ internal void UpdatePanel (StatusBarPanel panel)
+ {
+ if (panel.AutoSize == StatusBarPanelAutoSize.Contents) {
+ Update ();
+ return;
+ }
+
+ Update ();
+ }
+
+ internal void UpdatePanelContents (StatusBarPanel panel)
+ {
+ if (panel.AutoSize == StatusBarPanelAutoSize.Contents) {
+ Update ();
+ return;
+ }
+
+ Update ();
+ }
+
+ internal void Update ()
+ {
+ CalcPanelSizes ();
+ Refresh ();
+ }
+
+ private void DoPaint (PaintEventArgs pevent)
+ {
+ if (Width <= 0 || Height <= 0 || Visible == false)
+ return;
+
+ Draw (pevent.Graphics, pevent.ClipRectangle);
+ }
+
+ private void CalcPanelSizes ()
+ {
+ if (panels == null || !show_panels)
+ return;
+
+ if (Width == 0 || Height == 0)
+ return;
+
+ int border = 2;
+ int gap = ThemeEngine.Current.StatusBarHorzGapWidth;
+ int taken = 0;
+ ArrayList springs = null;
+
+ taken = border;
+ for (int i = 0; i < panels.Count; i++) {
+ StatusBarPanel p = panels [i];
+
+ if (p.AutoSize == StatusBarPanelAutoSize.None) {
+ taken += p.Width;
+ taken += gap;
+ continue;
+ }
+ if (p.AutoSize == StatusBarPanelAutoSize.Contents) {
+ int len = (int) (DeviceContext.MeasureString (p.Text, Font).Width + 0.5F);
+ p.SetWidth (len + 8);
+ taken += p.Width;
+ taken += gap;
+ continue;
+ }
+ if (p.AutoSize == StatusBarPanelAutoSize.Spring) {
+ if (springs == null)
+ springs = new ArrayList ();
+ springs.Add (p);
+ taken += gap;
+ continue;
+ }
+ }
+
+ if (springs == null)
+ return;
+
+ int spring_total = springs.Count;
+ int total_width = Width - taken - (SizingGrip ? ThemeEngine.Current.StatusBarSizeGripWidth : 0);
+ for (int i = 0; i < spring_total; i++) {
+ StatusBarPanel p = (StatusBarPanel) springs [i];
+ int width = total_width / spring_total;
+ p.SetWidth (width >= p.MinWidth ? width : p.MinWidth);
+ }
+
+ taken = border;
+ for (int i = 0; i < panels.Count; i++) {
+ StatusBarPanel p = panels [i];
+ p.X = taken;
+ taken += p.Width + gap;
+ }
+ }
+
+ private void Draw (Graphics dc, Rectangle clip)
+ {
+ ThemeEngine.Current.DrawStatusBar (dc, this.ClientRectangle, this);
+ }
+ #endregion // Internal Methods
+
+
+ #region Events
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler BackColorChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler BackgroundImageChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler ForeColorChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler ImeModeChanged;
+
+ public event StatusBarDrawItemEventHandler DrawItem;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event PaintEventHandler Paint;
+ public event StatusBarPanelClickEventHandler PanelClick;
+ #endregion // Events
+
+
+ #region Subclass StatusBarPanelCollection
+ public class StatusBarPanelCollection : IList, ICollection, IEnumerable {
+ #region Fields
+ private StatusBar owner;
+ private ArrayList panels;
+ #endregion // Fields
+
+ #region Public Constructors
+ public StatusBarPanelCollection (StatusBar owner)
+ {
+ this.owner = owner;
+ }
+
+ #endregion // Public Constructors
+
+ #region Private & Internal Methods
+ private int AddInternal (StatusBarPanel p, bool refresh) {
+ if (p == null)
+ throw new ArgumentNullException ("value");
+ if (panels == null)
+ panels = new ArrayList ();
+
+ int res = panels.Add (p);
+ p.SetParent (owner);
+
+ if (refresh) {
+ owner.CalcPanelSizes ();
+ owner.Refresh ();
+ }
+
+ return res;
+ }
+
+ #endregion // Private & Internal Methods
+
+ #region Public Instance Properties
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual int Count {
+ get {
+ if (panels == null)
+ return 0;
+ return panels.Count;
+ }
+ }
+
+ public virtual bool IsReadOnly {
+ get { return false; }
+ }
+
+ public virtual StatusBarPanel this [int index] {
+ get {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("index");
+ return (StatusBarPanel) panels [index];
+ }
+ set {
+ if (value == null)
+ throw new ArgumentNullException ("index");
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("index");
+ panels [index] = value;
+ }
+ }
+
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public virtual int Add (StatusBarPanel p) {
+ return AddInternal (p, true);
+ }
+
+ public virtual StatusBarPanel Add (string text) {
+ StatusBarPanel res = new StatusBarPanel ();
+ res.Text = text;
+ Add (res);
+ return res;
+ }
+
+ public virtual void AddRange (StatusBarPanel [] range) {
+ if (range == null)
+ throw new ArgumentNullException ("panels");
+ if (range.Length == 0)
+ return;
+ if (panels == null)
+ panels = new ArrayList (range.Length);
+
+ for (int i = 0; i < range.Length; i++)
+ AddInternal (range [i], false);
+ owner.Refresh ();
+ }
+
+ public virtual void Clear () {
+ panels.Clear ();
+
+ owner.Refresh ();
+ }
+
+ public bool Contains (StatusBarPanel panel) {
+ return panels.Contains (panel);
+ }
+
+ public virtual IEnumerator GetEnumerator () {
+ return panels.GetEnumerator ();
+ }
+
+ public int IndexOf (StatusBarPanel panel) {
+ return panels.IndexOf (panel);
+ }
+
+ public virtual void Insert (int index, StatusBarPanel value) {
+ if (value == null)
+ throw new ArgumentNullException ("value");
+ if (index > Count)
+ throw new ArgumentOutOfRangeException ("index");
+ // TODO: InvalidArgumentException for bad AutoSize values
+ // although it seems impossible to set it to a bad value
+ value.SetParent (owner);
+ panels [index] = value;
+
+ owner.Refresh ();
+ }
+
+ public virtual void Remove (StatusBarPanel panel) {
+ panels.Remove (panel);
+ }
+
+ public virtual void RemoveAt (int index) {
+ panels.RemoveAt (index);
+ }
+
+ #endregion // Public Instance Methods
+
+ #region IList & ICollection Interfaces
+ bool ICollection.IsSynchronized {
+ get { return panels.IsSynchronized; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return panels.SyncRoot; }
+ }
+
+ void ICollection.CopyTo (Array dest, int index)
+ {
+ panels.CopyTo (dest, index);
+ }
+
+
+ object IList.this [int index] {
+ get { return panels [index]; }
+ set { panels [index] = value; }
+ }
+
+ int IList.Add (object value) {
+ return panels.Add (value);
+ }
+
+ bool IList.Contains (object panel) {
+ return panels.Contains (panel);
+ }
+
+ int IList.IndexOf (object panel)
+ {
+ return panels.IndexOf (panel);
+ }
+
+ void IList.Insert (int index, object value)
+ {
+ panels.Insert (index, value);
+ }
+
+ bool IList.IsFixedSize {
+ get { return false; }
+ }
+
+ void IList.Remove (object value)
+ {
+ panels.Remove (value);
+ }
+ #endregion // IList & ICollection Interfaces
+ }
+ #endregion // Subclass StatusBarPanelCollection
+ }
+
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarDrawItemEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarDrawItemEventArgs.cs
new file mode 100644
index 00000000000..a07ab170fea
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarDrawItemEventArgs.cs
@@ -0,0 +1,57 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+using System;
+using System.Drawing;
+
+
+namespace System.Windows.Forms {
+
+ public class StatusBarDrawItemEventArgs : DrawItemEventArgs {
+
+ private StatusBarPanel panel;
+
+ public StatusBarDrawItemEventArgs (Graphics g, Font font, Rectangle rect,
+ int item, DrawItemState state, StatusBarPanel panel) :
+ this (g, font, rect, item, state, panel, Control.DefaultForeColor,
+ Control.DefaultBackColor)
+
+ {
+ }
+
+ public StatusBarDrawItemEventArgs (Graphics g, Font font, Rectangle rect,
+ int item, DrawItemState state, StatusBarPanel panel,
+ Color foreColor, Color backColor) : base (g, font, rect,
+ item, state)
+ {
+ this.panel = panel;
+ }
+
+ public StatusBarPanel Panel {
+ get { return panel; }
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarDrawItemEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarDrawItemEventHandler.cs
new file mode 100644
index 00000000000..db550ee27b3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarDrawItemEventHandler.cs
@@ -0,0 +1,36 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+using System;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+
+ public delegate void StatusBarDrawItemEventHandler (object sender,
+ StatusBarDrawItemEventArgs sbdevent);
+
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanel.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanel.cs
new file mode 100644
index 00000000000..5419b971f02
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanel.cs
@@ -0,0 +1,215 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+// COMPLETE
+
+using System;
+using System.Drawing;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [DefaultProperty("Text")]
+ [DesignTimeVisible(false)]
+ public class StatusBarPanel : Component, ISupportInitialize {
+ #region Local Variables
+ private StatusBar parent;
+
+ private bool initializing;
+ private string text = String.Empty;
+ private string tool_tip_text = String.Empty;
+
+ private Icon icon;
+ private HorizontalAlignment alignment = HorizontalAlignment.Left;
+ private StatusBarPanelAutoSize auto_size = StatusBarPanelAutoSize.None;
+ private StatusBarPanelBorderStyle border_style = StatusBarPanelBorderStyle.Sunken;
+ private StatusBarPanelStyle style;
+ private int width = 100;
+ private int twidth = -1;
+ private int min_width = 10;
+ internal int X;
+ #endregion // Local Variables
+
+ #region Constructors
+ public StatusBarPanel ()
+ {
+ }
+ #endregion // Constructors
+
+ [DefaultValue(HorizontalAlignment.Left)]
+ [Localizable(true)]
+ public HorizontalAlignment Alignment {
+ get { return alignment; }
+ set {
+ alignment = value;
+ InvalidateContents ();
+ }
+ }
+
+ [DefaultValue(StatusBarPanelAutoSize.None)]
+ public StatusBarPanelAutoSize AutoSize {
+ get { return auto_size; }
+ set {
+ auto_size = value;
+ Invalidate ();
+ }
+ }
+
+ [DefaultValue(StatusBarPanelBorderStyle.Sunken)]
+ [DispId(-504)]
+ public StatusBarPanelBorderStyle BorderStyle {
+ get { return border_style; }
+ set {
+ border_style = value;
+ Invalidate ();
+ }
+ }
+
+ [DefaultValue(null)]
+ [Localizable(true)]
+ public Icon Icon {
+ get { return icon; }
+ set {
+ icon = value;
+ InvalidateContents ();
+ }
+ }
+
+ [DefaultValue(10)]
+ [Localizable(true)]
+ [RefreshProperties(RefreshProperties.All)]
+ public int MinWidth {
+ get {
+ if (AutoSize == StatusBarPanelAutoSize.None)
+ return Width;
+ return min_width;
+ }
+ set {
+ if (value < 0)
+ throw new ArgumentException ("value");
+ min_width = value;
+ Invalidate ();
+ }
+ }
+
+ [DefaultValue(100)]
+ [Localizable(true)]
+ public int Width {
+ get { return width; }
+ set {
+ if (value < 0)
+ throw new ArgumentException ("value");
+
+ if (initializing)
+ twidth = value;
+ else
+ width = value;
+
+ Invalidate ();
+ }
+ }
+
+ [DefaultValue(StatusBarPanelStyle.Text)]
+ public StatusBarPanelStyle Style {
+ get { return style; }
+ set {
+ style = value;
+ Invalidate ();
+ }
+ }
+
+ [DefaultValue("")]
+ [Localizable(true)]
+ public string Text {
+ get { return text; }
+ set {
+ text = value;
+ InvalidateContents ();
+ }
+ }
+
+ [DefaultValue("")]
+ [Localizable(true)]
+ public string ToolTipText {
+ get { return tool_tip_text; }
+ set { tool_tip_text = value; }
+ }
+
+ [Browsable(false)]
+ public StatusBar Parent {
+ get { return parent; }
+ }
+
+ private void Invalidate ()
+ {
+ if (parent == null)
+ return;
+ parent.UpdatePanel (this);
+ }
+
+ private void InvalidateContents ()
+ {
+ if (parent == null)
+ return;
+ parent.UpdatePanelContents (this);
+ }
+
+ internal void SetParent (StatusBar parent)
+ {
+ this.parent = parent;
+ }
+
+ internal void SetWidth (int width)
+ {
+ this.width = width;
+ }
+
+ public override string ToString ()
+ {
+ return "StatusBarPanel: {" + Text +"}";
+ }
+
+ protected override void Dispose (bool disposing)
+ {
+ }
+
+ public virtual void BeginInit ()
+ {
+ initializing = true;
+ }
+
+ public virtual void EndInit ()
+ {
+ if (!initializing || twidth == -1)
+ return;
+
+ width = twidth;
+ twidth = -1;
+ initializing = false;
+ }
+ }
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelAutoSize.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelAutoSize.cs
new file mode 100644
index 00000000000..e4cfc3b4956
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelAutoSize.cs
@@ -0,0 +1,33 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+namespace System.Windows.Forms {
+
+ public enum StatusBarPanelAutoSize {
+ None = 1,
+ Spring,
+ Contents
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelBorderStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelBorderStyle.cs
new file mode 100644
index 00000000000..d86dfef8bd8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelBorderStyle.cs
@@ -0,0 +1,33 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+namespace System.Windows.Forms {
+
+ public enum StatusBarPanelBorderStyle {
+ None = 1,
+ Raised,
+ Sunken
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelClickEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelClickEventArgs.cs
new file mode 100644
index 00000000000..880b6194841
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelClickEventArgs.cs
@@ -0,0 +1,46 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+using System;
+
+namespace System.Windows.Forms {
+
+ public class StatusBarPanelClickEventArgs : MouseEventArgs {
+
+ private StatusBarPanel panel;
+
+ public StatusBarPanelClickEventArgs (StatusBarPanel panel,
+ MouseButtons buttons, int clicks, int x, int y) :
+ base (buttons, clicks, x, y, 0)
+ {
+ this.panel = panel;
+ }
+
+ public StatusBarPanel StatusBarPanel {
+ get { return panel; }
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelClickEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelClickEventHandler.cs
new file mode 100644
index 00000000000..cef19cd2c23
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelClickEventHandler.cs
@@ -0,0 +1,32 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+namespace System.Windows.Forms {
+
+ public delegate void StatusBarPanelClickEventHandler (object sender,
+ StatusBarPanelClickEventArgs e);
+
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelStyle.cs
new file mode 100644
index 00000000000..086aa4c7e52
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanelStyle.cs
@@ -0,0 +1,33 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+namespace System.Windows.Forms {
+
+ public enum StatusBarPanelStyle {
+ Text = 1,
+ OwnerDraw
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StructFormat.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StructFormat.cs
new file mode 100644
index 00000000000..74bc4f8a455
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StructFormat.cs
@@ -0,0 +1,37 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public enum StructFormat
+ {
+ Ansi = 1,
+ Unicode = 2,
+ Auto = 3
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SystemInformation.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SystemInformation.cs
new file mode 100644
index 00000000000..d289d614bac
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SystemInformation.cs
@@ -0,0 +1,429 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Miguel de Icaza (miguel@novell.com).
+// Peter Bartok (pbartok@novell.com)
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+ public class SystemInformation {
+ #region Constructor
+ internal SystemInformation() {
+ }
+ #endregion
+
+ #region Public Static Properties
+ public static ArrangeDirection ArrangeDirection {
+ get {
+ return ThemeEngine.Current.ArrangeDirection;
+ }
+ }
+
+ public static ArrangeStartingPosition ArrangeStartingPosition {
+ get {
+ return ThemeEngine.Current.ArrangeStartingPosition;
+ }
+ }
+
+ public static BootMode BootMode {
+ get {
+ return BootMode.Normal;
+ }
+ }
+
+ public static Size Border3DSize {
+ get {
+ return ThemeEngine.Current.Border3DSize;
+ }
+ }
+
+ public static Size BorderSize {
+ get {
+ return ThemeEngine.Current.Border3DSize;
+ }
+ }
+
+ public static Size CaptionButtonSize {
+ get {
+ return ThemeEngine.Current.CaptionButtonSize;
+ }
+ }
+
+ public static int CaptionHeight {
+ get {
+ return ThemeEngine.Current.CaptionHeight;
+ }
+ }
+
+ public static string ComputerName {
+ get {
+ return Environment.MachineName;
+ }
+ }
+
+ public static Size CursorSize {
+ get {
+ return XplatUI.CursorSize;
+ }
+ }
+
+ public static bool DbcsEnabled {
+ get {
+ return false;
+ }
+ }
+
+ public static bool DebugOS {
+ get {
+ return false;
+ }
+ }
+
+ public static Size DoubleClickSize {
+ get {
+ return ThemeEngine.Current.DoubleClickSize;
+ }
+ }
+
+ public static int DoubleClickTime {
+ get {
+ return ThemeEngine.Current.DoubleClickTime;
+ }
+ }
+
+ public static bool DragFullWindows {
+ get {
+ return XplatUI.DragFullWindows;
+ }
+ }
+
+ public static Size DragSize {
+ get {
+ return XplatUI.DragSize;
+ }
+ }
+
+ public static Size FixedFrameBorderSize {
+ get {
+ return ThemeEngine.Current.FixedFrameBorderSize;
+ }
+ }
+
+ public static Size FrameBorderSize {
+ get {
+ return ThemeEngine.Current.FrameBorderSize;
+ }
+ }
+
+ public static bool HighContrast {
+ get {
+ return false;
+ }
+ }
+
+ public static int HorizontalScrollBarArrowWidth {
+ get {
+ return ThemeEngine.Current.HorizontalScrollBarArrowWidth;
+ }
+ }
+
+ public static int HorizontalScrollBarHeight {
+ get {
+ return ThemeEngine.Current.HorizontalScrollBarHeight;
+ }
+ }
+
+ public static int HorizontalScrollBarThumbWidth {
+ get {
+ return ThemeEngine.Current.HorizontalScrollBarThumbWidth;
+ }
+ }
+
+ public static Size IconSize {
+ get {
+ return XplatUI.IconSize;
+ }
+ }
+
+ public static Size IconSpacingSize {
+ get {
+ return ThemeEngine.Current.IconSpacingSize;
+ }
+ }
+
+ public static int KanjiWindowHeight {
+ get {
+ return 0;
+ }
+ }
+
+ public static Size MaxWindowTrackSize {
+ get {
+ return XplatUI.MaxWindowTrackSize;
+ }
+ }
+
+ public static Size MenuButtonSize {
+ get {
+ return ThemeEngine.Current.MenuButtonSize;
+ }
+ }
+
+ public static Size MenuCheckSize {
+ get {
+ return ThemeEngine.Current.MenuCheckSize;
+ }
+ }
+
+ public static Font MenuFont {
+ get {
+ return ThemeEngine.Current.MenuFont;
+ }
+ }
+
+ public static int MenuHeight {
+ get {
+ return ThemeEngine.Current.MenuHeight;
+ }
+ }
+
+ public static bool MidEastEnabled {
+ get {
+ return false; // ??? how do we decide?
+ }
+ }
+
+ public static Size MinimizedWindowSize {
+ get {
+ return XplatUI.MinimizedWindowSize;
+ }
+ }
+
+ public static Size MinimizedWindowSpacingSize {
+ get {
+ return XplatUI.MinimizedWindowSpacingSize;
+ }
+ }
+
+ public static Size MinimumWindowSize {
+ get {
+ return XplatUI.MinimumWindowSize;
+ }
+ }
+
+ public static Size MinWindowTrackSize {
+ get {
+ return XplatUI.MinWindowTrackSize;
+ }
+ }
+
+ public static int MonitorCount {
+ get {
+ return 1; // Why bother...
+ }
+ }
+
+ public static bool MonitorsSameDisplayFormat {
+ get {
+ return true;
+ }
+ }
+
+ public static int MouseButtons {
+ get {
+ return XplatUI.MouseButtonCount;
+ }
+ }
+
+ public static bool MouseButtonsSwapped {
+ get {
+ return XplatUI.MouseButtonsSwapped;
+ }
+ }
+
+#if NET_2_0
+ public static Size MouseHoverSize {
+ get {
+ return XplatUI.MouseHoverSize;
+ }
+ }
+
+ public static int MouseHoverTime {
+ get {
+ return XplatUI.MouseHoverTime;
+ }
+ }
+#endif
+
+ public static bool MousePresent {
+ get {
+ return true;
+ }
+ }
+
+ public static bool MouseWheelPresent {
+ get {
+ return XplatUI.MouseWheelPresent;
+ }
+ }
+
+ public static int MouseWheelScrollLines {
+ get {
+ return ThemeEngine.Current.MouseWheelScrollLines;
+ }
+ }
+
+ public static bool NativeMouseWheelSupport {
+ get {
+ return MouseWheelPresent;
+ }
+ }
+
+ public static bool Network {
+ get {
+ return true;
+ }
+ }
+
+ public static bool PenWindows {
+ get {
+ return false;
+ }
+ }
+
+ public static Size PrimaryMonitorMaximizedWindowSize {
+ get {
+ return new Size(WorkingArea.Width, WorkingArea.Height);
+ }
+ }
+
+ public static Size PrimaryMonitorSize {
+ get {
+ return new Size(WorkingArea.Width, WorkingArea.Height);
+ }
+ }
+
+ public static bool RightAlignedMenus {
+ get {
+ return ThemeEngine.Current.RightAlignedMenus;
+ }
+ }
+
+ public static bool Secure {
+ get {
+ return true; // FIXME - figure out if we're running 98/Me and return false
+ }
+ }
+
+ public static bool ShowSounds {
+ get {
+ return false;
+ }
+ }
+
+ public static Size SmallIconSize {
+ get {
+ return XplatUI.SmallIconSize;
+ }
+ }
+
+ public static Size ToolWindowCaptionButtonSize {
+ get {
+ return ThemeEngine.Current.ToolWindowCaptionButtonSize;
+ }
+ }
+
+ public static int ToolWindowCaptionHeight {
+ get {
+ return ThemeEngine.Current.ToolWindowCaptionHeight;
+ }
+ }
+
+ public static string UserDomainName {
+ get {
+ return Environment.UserDomainName;
+ }
+ }
+
+ public static bool UserInteractive {
+ get {
+ return Environment.UserInteractive;
+ }
+ }
+
+ public static string UserName {
+ get {
+ return Environment.UserName;
+ }
+ }
+
+ public static int VerticalScrollBarArrowHeight {
+ get {
+ return ThemeEngine.Current.VerticalScrollBarArrowHeight;
+ }
+ }
+
+ public static int VerticalScrollBarThumbHeight {
+ get {
+ return ThemeEngine.Current.VerticalScrollBarThumbHeight;
+ }
+ }
+
+ public static int VerticalScrollBarWidth {
+ get {
+ return ThemeEngine.Current.VerticalScrollBarWidth;
+ }
+ }
+
+ public static Rectangle VirtualScreen {
+ get {
+ return XplatUI.VirtualScreen;
+ }
+ }
+
+ public static Rectangle WorkingArea {
+ get {
+ return XplatUI.WorkingArea;
+ }
+ }
+ #endregion // Public Static Properties
+
+ #region Internal Static Properties
+ internal static int KeyboardSpeed {
+ get {
+ return XplatUI.KeyboardSpeed;
+ }
+ }
+
+ internal static int KeyboardDelay {
+ get {
+ return XplatUI.KeyboardDelay;
+ }
+ }
+ #endregion // Internal Static Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabAlignment.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabAlignment.cs
new file mode 100644
index 00000000000..5e5c2ef3346
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabAlignment.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+namespace System.Windows.Forms {
+
+ public enum TabAlignment {
+ Top,
+ Bottom,
+ Left,
+ Right
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabAppearance.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabAppearance.cs
new file mode 100644
index 00000000000..59a7bd83d73
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabAppearance.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+namespace System.Windows.Forms {
+
+ public enum TabAppearance {
+ Normal,
+ Buttons,
+ FlatButtons
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabControl.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabControl.cs
new file mode 100644
index 00000000000..de6c042cc49
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabControl.cs
@@ -0,0 +1,1224 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+
+
+namespace System.Windows.Forms {
+ [DefaultEvent("SelectedIndexChanged")]
+ [DefaultProperty("TabPages")]
+ [Designer("System.Windows.Forms.Design.TabControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ public class TabControl : Control {
+ #region Fields
+ private int selected_index = -1;
+ private TabAlignment alignment;
+ private TabAppearance appearance;
+ private TabDrawMode draw_mode;
+ private bool multiline;
+ private ImageList image_list;
+ private Size item_size = Size.Empty;
+ private Point padding;
+ private int row_count = 1;
+ private bool hottrack;
+ private TabPageCollection tab_pages;
+ private bool show_tool_tips;
+ private TabSizeMode size_mode;
+ private Rectangle display_rect;
+ private bool show_slider = false;
+ private ButtonState right_slider_state;
+ private ButtonState left_slider_state;
+ private int slider_pos = 0;
+ #endregion // Fields
+
+ #region Public Constructors
+ public TabControl ()
+ {
+ tab_pages = new TabPageCollection (this);
+ SetStyle (ControlStyles.UserPaint, false);
+ padding = ThemeEngine.Current.TabControlDefaultPadding;
+ item_size = ThemeEngine.Current.TabControlDefaultItemSize;
+
+ MouseDown += new MouseEventHandler (MouseDownHandler);
+ MouseUp += new MouseEventHandler (MouseUpHandler);
+ SizeChanged += new EventHandler (SizeChangedHandler);
+ }
+
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ [DefaultValue(TabAlignment.Top)]
+ [Localizable(true)]
+ [RefreshProperties(RefreshProperties.All)]
+ public TabAlignment Alignment {
+ get { return alignment; }
+ set {
+ if (alignment == value)
+ return;
+ alignment = value;
+ if (alignment == TabAlignment.Left || alignment == TabAlignment.Right)
+ multiline = true;
+ Redraw ();
+ }
+ }
+
+ [DefaultValue(TabAppearance.Normal)]
+ [Localizable(true)]
+ public TabAppearance Appearance {
+ get { return appearance; }
+ set {
+ if (appearance == value)
+ return;
+ appearance = value;
+ Redraw ();
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Color BackColor {
+ get { return base.BackColor; }
+ set { /* nothing happens on set on MS */ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Image BackgroundImage {
+ get { return base.BackgroundImage; }
+ set { base.BackgroundImage = value; }
+ }
+
+ public override Rectangle DisplayRectangle {
+ get {
+ return ThemeEngine.Current.GetTabControlDisplayRectangle (this);
+ }
+ }
+
+ [DefaultValue(TabDrawMode.Normal)]
+ public TabDrawMode DrawMode {
+ get { return draw_mode; }
+ set {
+ if (draw_mode == value)
+ return;
+ draw_mode = value;
+ Redraw ();
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Color ForeColor {
+ get { return base.ForeColor; }
+ set { base.ForeColor = value; }
+ }
+
+ [DefaultValue(false)]
+ public bool HotTrack {
+ get { return hottrack; }
+ set {
+ if (hottrack == value)
+ return;
+ hottrack = value;
+ Redraw ();
+ }
+ }
+
+ [DefaultValue(null)]
+ public ImageList ImageList {
+ get { return image_list; }
+ set { image_list = value; }
+ }
+
+ [Localizable(true)]
+ public Size ItemSize {
+ get {
+ return item_size;
+ }
+ set {
+ if (value.Height < 0 || value.Width < 0)
+ throw new ArgumentException ("'" + value + "' is not a valid value for 'ItemSize'.");
+ item_size = value;
+ Redraw ();
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool Multiline {
+ get { return multiline; }
+ set {
+ if (multiline == value)
+ return;
+ multiline = value;
+ if (!multiline && alignment == TabAlignment.Left || alignment == TabAlignment.Right)
+ alignment = TabAlignment.Top;
+ Redraw ();
+ }
+ }
+
+ [Localizable(true)]
+ public Point Padding {
+ get { return padding; }
+ set {
+ if (value.X < 0 || value.Y < 0)
+ throw new ArgumentException ("'" + value + "' is not a valid value for 'Padding'.");
+ if (padding == value)
+ return;
+ padding = value;
+ Redraw ();
+ }
+
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int RowCount {
+ get { return row_count; }
+ }
+
+ [DefaultValue(-1)]
+ [Browsable(false)]
+ public int SelectedIndex {
+ get { return selected_index; }
+ set {
+ if (selected_index == value)
+ return;
+ if (selected_index < -1) {
+ throw new ArgumentException ("'" + value + "' is not a valid value for 'value'. " +
+ "'value' must be greater than or equal to -1.");
+ }
+
+ SuspendLayout ();
+
+ Rectangle invalid = Rectangle.Empty;
+ bool refresh = false;
+
+ if (-1 != value && show_slider && value < slider_pos) {
+ slider_pos = value;
+ refresh = true;
+ }
+
+ int le = TabPages [value].TabBounds.Right;
+ int re = ThemeEngine.Current.GetTabControlLeftScrollRect (this).Left;
+
+ if (-1 != value && show_slider && le > re) {
+ int diff = le - re;
+ int ind = value - 1;
+ while (ind > 0 && diff > 0) {
+ diff -= TabPages [ind++].Width;
+ }
+ slider_pos = ind - 1;
+ refresh = true;
+ }
+
+ if (selected_index != -1) {
+ if (!refresh)
+ invalid = GetTabRect (selected_index);
+ Controls [selected_index].Visible = false;
+ }
+ selected_index = value;
+
+ OnSelectedIndexChanged (EventArgs.Empty);
+
+ TabPage selected = (TabPage) Controls [selected_index];
+
+ if (selected_index != -1) {
+ invalid = Rectangle.Union (invalid, GetTabRect (selected_index));
+ selected.Visible = true;
+ }
+
+ ResumeLayout ();
+
+ if (refresh) {
+ SizeTabs ();
+ Refresh ();
+ } else if (selected_index != -1 && selected.Row != BottomRow) {
+ DropRow (TabPages [selected_index].Row);
+ // calculating what to invalidate here seems to be slower then just
+ // refreshing the whole thing
+ SizeTabs ();
+ Refresh ();
+ } else {
+ SizeTabs ();
+ // The lines are drawn on the edges of the tabs so the invalid area should
+ // needs to include the extra pixels of line width.
+ if (appearance == TabAppearance.Normal) {
+ invalid.Inflate (6, 4);
+ }
+ Invalidate (invalid);
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public TabPage SelectedTab {
+ get {
+ if (selected_index == -1)
+ return null;
+ return tab_pages [selected_index];
+ }
+ set {
+ int index = IndexForTabPage (value);
+ if (index == selected_index)
+ return;
+ SelectedIndex = index;
+ }
+ }
+
+ [DefaultValue(false)]
+ [Localizable(true)]
+ public bool ShowToolTips {
+ get { return show_tool_tips; }
+ set {
+ if (show_tool_tips == value)
+ return;
+ show_tool_tips = value;
+ Redraw ();
+ }
+ }
+
+ [DefaultValue(TabSizeMode.Normal)]
+ [RefreshProperties(RefreshProperties.Repaint)]
+ public TabSizeMode SizeMode {
+ get { return size_mode; }
+ set {
+ if (size_mode == value)
+ return;
+ size_mode = value;
+ Redraw ();
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int TabCount {
+ get {
+ return tab_pages.Count;
+ }
+ }
+
+ [DefaultValue(null)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [MergableProperty(false)]
+ public TabPageCollection TabPages {
+ get { return tab_pages; }
+ }
+
+ [Browsable(false)]
+ [Bindable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override string Text {
+ get { return base.Text; }
+ set { base.Text = value; }
+ }
+
+ #endregion // Public Instance Properties
+
+ #region Internal Properties
+ internal bool ShowSlider {
+ get { return show_slider; }
+ set { show_slider = value; }
+ }
+
+ internal int SliderPos {
+ get { return slider_pos; }
+ }
+
+ internal ButtonState RightSliderState {
+ get { return right_slider_state; }
+ }
+
+ internal ButtonState LeftSliderState {
+ get { return left_slider_state; }
+ }
+
+ private Size DefaultItemSize {
+ get {
+ return ThemeEngine.Current.TabControlDefaultItemSize;
+ }
+ }
+
+ #endregion // Internal Properties
+
+ #region Protected Instance Properties
+ protected override CreateParams CreateParams {
+ get {
+ CreateParams c = base.CreateParams;
+ return c;
+ }
+ }
+
+ protected override Size DefaultSize {
+ get { return new Size (200, 100); }
+ }
+
+ #endregion // Protected Instance Properties
+
+ #region Public Instance Methods
+ public Rectangle GetTabRect (int index)
+ {
+ TabPage page = GetTab (index);
+ return page.TabBounds;
+ }
+
+ public Control GetControl (int index)
+ {
+ return GetTab (index);
+ }
+
+ public override string ToString ()
+ {
+ string res = String.Concat (base.ToString (),
+ ", TabPages.Count: ",
+ TabCount);
+ if (TabCount > 0)
+ res = String.Concat (res, ", TabPages[0]: ",
+ TabPages [0]);
+ return res;
+ }
+
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected override Control.ControlCollection CreateControlsInstance ()
+ {
+ return new TabControl.ControlCollection (this);
+ }
+
+ protected void UpdateTabSelection (bool uiselected)
+ {
+ ResizeTabPages ();
+ }
+
+ protected override void CreateHandle ()
+ {
+ base.CreateHandle ();
+ ResizeTabPages ();
+ }
+
+ protected override void OnHandleCreated (EventArgs e)
+ {
+ base.OnHandleCreated (e);
+ }
+
+ protected override void OnHandleDestroyed (EventArgs e)
+ {
+ base.OnHandleDestroyed (e);
+ }
+
+ protected virtual void OnDrawItem (DrawItemEventArgs e)
+ {
+ if (DrawItem != null && DrawMode == TabDrawMode.OwnerDrawFixed)
+ DrawItem (this, e);
+ }
+
+ internal void OnDrawItemInternal (DrawItemEventArgs e)
+ {
+ OnDrawItem (e);
+ }
+
+ protected override void OnFontChanged (EventArgs e)
+ {
+ base.OnFontChanged (e);
+ ResizeTabPages ();
+ }
+
+ protected override void OnResize (EventArgs e)
+ {
+ base.OnResize (e);
+ }
+
+ protected override void OnStyleChanged (EventArgs e)
+ {
+ base.OnStyleChanged (e);
+ }
+
+ protected override bool ProcessKeyPreview (ref Message m)
+ {
+ return base.ProcessKeyPreview (ref m);
+ }
+
+ protected override void OnKeyDown (KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.Tab && (e.KeyData & Keys.Control) != 0) {
+ if ((e.KeyData & Keys.Shift) == 0)
+ SelectedIndex = (SelectedIndex + 1) % TabCount;
+ else
+ SelectedIndex = (SelectedIndex - 1) % TabCount;
+ e.Handled = true;
+ } else if (e.KeyCode == Keys.Home) {
+ SelectedIndex = 0;
+ e.Handled = true;
+ } else if (e.KeyCode == Keys.End) {
+ SelectedIndex = TabCount - 1;
+ e.Handled = true;
+ } else if (e.KeyCode == Keys.Left && SelectedIndex > 0) {
+ SelectedIndex--;
+ e.Handled = true;
+ } else if (e.KeyCode == Keys.Right && SelectedIndex < TabCount - 1) {
+ SelectedIndex++;
+ e.Handled = true;
+ }
+
+ base.OnKeyDown (e);
+ }
+
+ protected override bool IsInputKey (Keys key)
+ {
+ switch (key & Keys.KeyCode) {
+ case Keys.Home:
+ case Keys.End:
+ case Keys.Left:
+ case Keys.Right:
+ case Keys.Tab:
+ return true;
+ }
+ return base.IsInputKey (key);
+ }
+
+ protected override void Dispose (bool disposing)
+ {
+ base.Dispose (disposing);
+ }
+
+ protected void RemoveAll ()
+ {
+ Controls.Clear ();
+ }
+
+ protected virtual object [] GetItems ()
+ {
+ TabPage [] pages = new TabPage [Controls.Count];
+ Controls.CopyTo (pages, 0);
+ return pages;
+ }
+
+ protected virtual object [] GetItems (Type type)
+ {
+ object [] pages = (object []) Array.CreateInstance (type, Controls.Count);
+ Controls.CopyTo (pages, 0);
+ return pages;
+ }
+
+ protected string GetToolTipText (object item)
+ {
+ TabPage page = (TabPage) item;
+ return page.ToolTipText;
+ }
+
+ protected override void WndProc (ref Message m)
+ {
+ switch ((Msg) m.Msg) {
+ case Msg.WM_PAINT:
+ PaintEventArgs paint_event;
+ paint_event = XplatUI.PaintEventStart (Handle, true);
+ PaintInternal (paint_event);
+ XplatUI.PaintEventEnd (Handle, true);
+ break;
+ default:
+ base.WndProc (ref m);
+ break;
+ }
+ }
+
+ protected virtual void OnSelectedIndexChanged (EventArgs e)
+ {
+ if (SelectedIndexChanged != null)
+ SelectedIndexChanged (this, e);
+ }
+
+ #endregion // Protected Instance Methods
+
+ #region Internal & Private Methods
+ private bool CanScrollRight {
+ get {
+ return (slider_pos < TabCount - 1);
+ }
+ }
+
+ private bool CanScrollLeft {
+ get { return slider_pos > 0; }
+ }
+
+ private void MouseDownHandler (object sender, MouseEventArgs e)
+ {
+ if (ShowSlider) {
+ Rectangle right = ThemeEngine.Current.GetTabControlRightScrollRect (this);
+ Rectangle left = ThemeEngine.Current.GetTabControlLeftScrollRect (this);
+ if (right.Contains (e.X, e.Y)) {
+ right_slider_state = ButtonState.Pushed;
+ if (CanScrollRight) {
+ slider_pos++;
+ SizeTabs ();
+
+ Invalidate (new Rectangle (0, 0, Width, DisplayRectangle.Top));
+ } else {
+ Invalidate (right);
+ }
+ return;
+ } else if (left.Contains (e.X, e.Y)) {
+ left_slider_state = ButtonState.Pushed;
+ if (CanScrollLeft) {
+ slider_pos--;
+ SizeTabs ();
+
+ Invalidate (new Rectangle (0, 0, Width, DisplayRectangle.Top));
+ } else {
+ Invalidate (left);
+ }
+ return;
+ }
+ }
+
+ int count = Controls.Count;
+ for (int i = SliderPos; i < count; i++) {
+ if (!GetTabRect (i).Contains (e.X, e.Y))
+ continue;
+ SelectedIndex = i;
+ break;
+ }
+ }
+
+ private void MouseUpHandler (object sender, MouseEventArgs e)
+ {
+ if (ShowSlider && (left_slider_state == ButtonState.Pushed || right_slider_state == ButtonState.Pushed)) {
+ Rectangle invalid;
+ if (left_slider_state == ButtonState.Pushed)
+ invalid = ThemeEngine.Current.GetTabControlLeftScrollRect (this);
+ else
+ invalid = ThemeEngine.Current.GetTabControlRightScrollRect (this);
+ left_slider_state = ButtonState.Normal;
+ right_slider_state = ButtonState.Normal;
+
+ Invalidate (invalid);
+ }
+ }
+
+ private void SizeChangedHandler (object sender, EventArgs e)
+ {
+ Redraw ();
+ }
+
+ internal void UpdateTabpage (TabPage page)
+ {
+
+ }
+
+ internal int IndexForTabPage (TabPage page)
+ {
+ for (int i = 0; i < tab_pages.Count; i++) {
+ if (page == tab_pages [i])
+ return i;
+ }
+ return -1;
+ }
+
+ private void ResizeTabPages ()
+ {
+ CalcTabRows ();
+ SizeTabs ();
+ Rectangle r = DisplayRectangle;
+ foreach (TabPage page in Controls) {
+ page.Bounds = r;
+ }
+ }
+
+ private int MinimumTabWidth {
+ get {
+ return ThemeEngine.Current.TabControlMinimumTabWidth;
+ }
+ }
+
+ private Size TabSpacing {
+ get {
+ return ThemeEngine.Current.TabControlGetSpacing (this);
+ }
+ }
+
+ private void CalcTabRows ()
+ {
+ switch (Alignment) {
+ case TabAlignment.Right:
+ case TabAlignment.Left:
+ CalcTabRows (Height);
+ break;
+ default:
+ CalcTabRows (Width);
+ break;
+ }
+ }
+
+ private void CalcTabRows (int row_width)
+ {
+ int xpos = 4;
+ Size spacing = TabSpacing;
+
+ row_count = 1;
+ show_slider = false;
+
+ for (int i = 0; i < TabPages.Count; i++) {
+ TabPage page = TabPages [i];
+ int width;
+
+ page.Row = 1;
+
+ if (SizeMode == TabSizeMode.Fixed) {
+ width = item_size.Width;
+ } else {
+ width = (int) DeviceContext.MeasureString (page.Text, Font).Width + (Padding.X * 2);
+ }
+
+ if (i == SelectedIndex)
+ width += 8;
+ if (width < MinimumTabWidth)
+ width = MinimumTabWidth;
+
+ if (xpos + width > row_width && multiline) {
+ xpos = 4;
+ for (int j = 0; j < i; j++) {
+ TabPages [j].Row++;
+ }
+ row_count++;
+ } else if (xpos + width > row_width) {
+ show_slider = true;
+ }
+
+ xpos += width + 1 + spacing.Width;
+ }
+
+ if (SelectedIndex != -1 && TabPages [SelectedIndex].Row != BottomRow)
+ DropRow (TabPages [SelectedIndex].Row);
+ }
+
+ private int BottomRow {
+ get {
+ switch (Alignment) {
+ case TabAlignment.Right:
+ case TabAlignment.Bottom:
+ return row_count;
+ default:
+ return 1;
+ }
+ }
+ }
+
+ private int Direction
+ {
+ get {
+ switch (Alignment) {
+ case TabAlignment.Right:
+ case TabAlignment.Bottom:
+ return -1;
+ default:
+ return 1;
+ }
+ }
+ }
+
+ private void DropRow (int row)
+ {
+ int bottom = BottomRow;
+ int direction = Direction;
+
+ foreach (TabPage page in TabPages) {
+ if (page.Row == row) {
+ page.Row = bottom;
+ } else if (direction == 1 && page.Row < row) {
+ page.Row += direction;
+ } else if (direction == -1 && page.Row > row) {
+ page.Row += direction;
+ }
+ }
+ }
+
+ private int CalcYPos ()
+ {
+ if (Alignment == TabAlignment.Bottom) {
+ Rectangle r = ThemeEngine.Current.GetTabControlDisplayRectangle (this);
+ return r.Bottom + 3;
+ }
+ return 1;
+ }
+
+ private int CalcXPos ()
+ {
+ if (Alignment == TabAlignment.Right) {
+ Rectangle r = ThemeEngine.Current.GetTabControlDisplayRectangle (this);
+ return r.Right + 4;
+ }
+ return 4;
+
+ }
+
+ private void SizeTabs ()
+ {
+ switch (Alignment) {
+ case TabAlignment.Right:
+ case TabAlignment.Left:
+ SizeTabsV (Height);
+ break;
+ default:
+ SizeTabs (Width);
+ break;
+ }
+ }
+
+ private void SizeTabsV (int row_width)
+ {
+ int ypos = 1;
+ int prev_row = 1;
+ Size spacing = TabSpacing;
+ int xpos = CalcXPos ();
+ int begin_prev = 0;
+
+ if (TabPages.Count == 0)
+ return;
+
+ prev_row = TabPages [0].Row;
+
+ for (int i = 0; i < TabPages.Count; i++) {
+ TabPage page = TabPages [i];
+ int width;
+
+ if (SizeMode == TabSizeMode.Fixed) {
+ width = item_size.Width;
+ } else {
+ width = (int) DeviceContext.MeasureString (page.Text, Font).Width + (Padding.X * 2);
+ }
+
+ if (width < MinimumTabWidth)
+ width = MinimumTabWidth;
+ if (page.Row != prev_row)
+ ypos = 1;
+
+ page.TabBounds = new Rectangle (xpos + (row_count - page.Row) * ((item_size.Height - 2) + spacing.Width),
+ ypos, item_size.Height - 2, width);
+
+ if (page.Row != prev_row) {
+ if (SizeMode == TabSizeMode.FillToRight && !ShowSlider) {
+ FillRowV (begin_prev, i - 1, ((row_width - TabPages [i - 1].TabBounds.Bottom) / (i - begin_prev)), spacing);
+ }
+ begin_prev = i;
+ }
+
+ ypos += width + spacing.Width;
+ prev_row = page.Row;
+ }
+
+ if (SizeMode == TabSizeMode.FillToRight && !ShowSlider) {
+ FillRowV (begin_prev, TabPages.Count - 1,
+ ((row_width - TabPages [TabPages.Count - 1].TabBounds.Bottom) / (TabPages.Count - begin_prev)), spacing);
+ }
+
+ if (SelectedIndex != -1) {
+ ExpandSelected (TabPages [SelectedIndex], 2, row_width - 1);
+ }
+ }
+
+ private void SizeTabs (int row_width)
+ {
+ int ypos = CalcYPos ();
+ int prev_row = 1;
+ Size spacing = TabSpacing;
+ int xpos = 4;
+ int begin_prev = 0;
+
+ if (TabPages.Count == 0)
+ return;
+
+ prev_row = TabPages [0].Row;
+
+ // Reset the slider position if the slider isn't needed
+ // anymore (ie window size was increased so all tabs are visible)
+ if (!show_slider)
+ slider_pos = 0;
+
+ for (int i = slider_pos; i < TabPages.Count; i++) {
+ TabPage page = TabPages [i];
+ int width;
+
+ if (SizeMode == TabSizeMode.Fixed) {
+ width = item_size.Width;
+ } else {
+ width = (int) DeviceContext.MeasureString (page.Text, Font).Width + (Padding.X * 2);
+ }
+
+ if (width < MinimumTabWidth)
+ width = MinimumTabWidth;
+ if (page.Row != prev_row)
+ xpos = 4;
+
+ page.TabBounds = new Rectangle (xpos,
+ ypos + (row_count - page.Row) * (item_size.Height + spacing.Height),
+ width, item_size.Height);
+
+ if (page.Row != prev_row) {
+ if (SizeMode == TabSizeMode.FillToRight && !ShowSlider) {
+ FillRow (begin_prev, i - 1, ((row_width - TabPages [i - 1].TabBounds.Right) / (i - begin_prev)), spacing);
+ }
+ begin_prev = i;
+ }
+
+ xpos += width + 1 + spacing.Width;
+ prev_row = page.Row;
+ }
+
+ if (SizeMode == TabSizeMode.FillToRight && !ShowSlider) {
+ FillRow (begin_prev, TabPages.Count - 1,
+ ((row_width - TabPages [TabPages.Count - 1].TabBounds.Right) / (TabPages.Count - begin_prev)), spacing);
+ }
+
+ if (SelectedIndex != -1) {
+ ExpandSelected (TabPages [SelectedIndex], 2, row_width - 1);
+ }
+ }
+
+ private void FillRow (int start, int end, int amount, Size spacing)
+ {
+ int xpos = TabPages [start].TabBounds.Left;
+ for (int i = start; i <= end; i++) {
+ TabPage page = TabPages [i];
+ int left = xpos;
+ int width = (i == end ? Width - left - 3 : page.TabBounds.Width + amount);
+
+ page.TabBounds = new Rectangle (left, page.TabBounds.Top,
+ width, page.TabBounds.Height);
+ xpos = page.TabBounds.Right + 1 + spacing.Width;
+ }
+ }
+
+ private void FillRowV (int start, int end, int amount, Size spacing)
+ {
+ int ypos = TabPages [start].TabBounds.Top;
+ for (int i = start; i <= end; i++) {
+ TabPage page = TabPages [i];
+ int top = ypos;
+ int height = (i == end ? Height - top - 5 : page.TabBounds.Height + amount);
+
+ page.TabBounds = new Rectangle (page.TabBounds.Left, top,
+ page.TabBounds.Width, height);
+ ypos = page.TabBounds.Bottom + 1;
+ }
+ }
+
+ private void ExpandSelected (TabPage page, int left_edge, int right_edge)
+ {
+ if (Appearance != TabAppearance.Normal)
+ return;
+
+ if (Alignment == TabAlignment.Top || Alignment == TabAlignment.Bottom) {
+ int l = page.TabBounds.Left - 4;
+ int r = page.TabBounds.Right + 4;
+ int y = page.TabBounds.Y;
+ int h = page.TabBounds.Height + 3;
+
+ if (l < left_edge)
+ l = left_edge;
+ if (r > right_edge && SizeMode != TabSizeMode.Normal)
+ r = right_edge;
+ if (Alignment == TabAlignment.Top)
+ y -= 1;
+ if (Alignment == TabAlignment.Bottom)
+ y -= 2;
+
+ page.TabBounds = new Rectangle (l, y, r - l, h);
+ } else {
+ int l = page.TabBounds.Left - 3;
+ int r = page.TabBounds.Right + 3;
+ int t = page.TabBounds.Top - 3;
+ int b = page.TabBounds.Bottom + 3;
+
+ if (t < left_edge)
+ t = left_edge;
+ if (b > right_edge)
+ b = right_edge;
+
+ page.TabBounds = new Rectangle (l, t, r - l, b - t);
+ }
+ }
+
+ private void PaintInternal (PaintEventArgs pe)
+ {
+ Draw (pe.Graphics, pe.ClipRectangle);
+ // On MS the Paint event never seems to be raised
+ }
+
+ private void Draw (Graphics dc, Rectangle clip)
+ {
+ ThemeEngine.Current.DrawTabControl (dc, clip, this);
+ }
+
+ private TabPage GetTab (int index)
+ {
+ return Controls [index] as TabPage;
+ }
+
+ private void SetTab (int index, TabPage value)
+ {
+ ((IList) Controls).Insert (index, value);
+ Redraw ();
+ }
+
+ internal void Redraw ()
+ {
+ ResizeTabPages ();
+ Refresh ();
+ }
+
+ #endregion // Internal & Private Methods
+
+ #region Events
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler BackColorChanged {
+ add { base.BackColorChanged += value; }
+ remove { base.BackColorChanged -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler BackgroundImageChanged {
+ add { base.BackgroundImageChanged += value; }
+ remove { base.BackgroundImageChanged -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler ForeColorChanged {
+ add { base.ForeColorChanged += value; }
+ remove { base.ForeColorChanged -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event PaintEventHandler Paint {
+ add { base.Paint += value; }
+ remove { base.Paint -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler TextChanged {
+ add { base.TextChanged += value; }
+ remove { base.TextChanged -= value; }
+ }
+
+ public event DrawItemEventHandler DrawItem;
+ public event EventHandler SelectedIndexChanged;
+ #endregion // Events
+
+
+ #region Class TaControl.ControlCollection
+ public class ControlCollection : System.Windows.Forms.Control.ControlCollection {
+
+ private TabControl owner;
+ private ArrayList list = new ArrayList ();
+
+ public ControlCollection (TabControl owner) : base (owner)
+ {
+ this.owner = owner;
+ }
+
+ public override void Add (Control value)
+ {
+ if (!(value is TabPage))
+ throw new ArgumentException ("Cannot add " +
+ value.GetType ().Name + " to TabControl. " +
+ "Only TabPages can be directly added to TabControls.");
+
+ value.Visible = false;
+ base.Add (value);
+ if (Count == 1) {
+ owner.SelectedIndex = 0;
+ } else {
+ // Setting the selected index will calc the tab rows so
+ // we don't need to do it again
+ owner.ResizeTabPages ();
+ }
+ }
+
+ public override void Remove (Control value)
+ {
+ TabPage page = value as TabPage;
+ if (page != null) {
+ int index = owner.IndexForTabPage (page);
+ if (index == owner.SelectedIndex)
+ owner.SelectedIndex = (index + 1) % owner.TabCount;
+ }
+ base.Remove (value);
+ }
+ }
+ #endregion // Class TabControl.ControlCollection
+
+ #region Class TabPage.TabPageCollection
+ public class TabPageCollection : IList, ICollection, IEnumerable {
+
+ private TabControl owner;
+ private IList controls;
+
+ public TabPageCollection (TabControl owner)
+ {
+ if (owner == null)
+ throw new ArgumentNullException ("Value cannot be null.");
+ this.owner = owner;
+ controls = owner.Controls;
+ }
+
+ [Browsable(false)]
+ public virtual int Count {
+ get { return owner.Controls.Count; }
+ }
+
+ public virtual bool IsReadOnly {
+ get { return false; }
+ }
+
+ public virtual TabPage this [int index] {
+ get {
+ return owner.GetTab (index);
+ }
+ set {
+ owner.SetTab (index, value);
+ }
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return false; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return this; }
+ }
+
+ bool IList.IsFixedSize {
+ get { return false; }
+ }
+
+ object IList.this [int index] {
+ get {
+ return owner.GetTab (index);
+ }
+ set {
+ owner.SetTab (index, (TabPage) value);
+ }
+ }
+
+ public void Add (TabPage page)
+ {
+ if (page == null)
+ throw new ArgumentNullException ("Value cannot be null.");
+ owner.Controls.Add (page);
+ }
+
+ public void AddRange (TabPage [] pages)
+ {
+ if (pages == null)
+ throw new ArgumentNullException ("Value cannot be null.");
+ owner.Controls.AddRange (pages);
+ }
+
+ public virtual void Clear ()
+ {
+ owner.Controls.Clear ();
+ }
+
+ public bool Contains (TabPage page)
+ {
+ if (page == null)
+ throw new ArgumentNullException ("Value cannot be null.");
+ return owner.Controls.Contains (page);
+ }
+
+ public virtual IEnumerator GetEnumerator ()
+ {
+ return owner.Controls.GetEnumerator ();
+ }
+
+ public int IndexOf (TabPage page)
+ {
+ return owner.Controls.IndexOf (page);
+ }
+
+ public void Remove (TabPage page)
+ {
+ owner.Controls.Remove (page);
+ }
+
+ public virtual void RemoveAt (int index)
+ {
+ owner.Controls.RemoveAt (index);
+ }
+
+ void ICollection.CopyTo (Array dest, int index)
+ {
+ owner.Controls.CopyTo (dest, index);
+ }
+
+ int IList.Add (object value)
+ {
+ TabPage page = value as TabPage;
+ if (value == null)
+ throw new ArgumentException ("value");
+ owner.Controls.Add (page);
+ return owner.Controls.IndexOf (page);
+ }
+
+ bool IList.Contains (object value)
+ {
+ TabPage page = value as TabPage;
+ if (page == null)
+ return false;
+ return Contains (page);
+ }
+
+ int IList.IndexOf (object value)
+ {
+ TabPage page = value as TabPage;
+ if (page == null)
+ return -1;
+ return IndexOf ((TabPage) page);
+ }
+
+ void IList.Insert (int index, object value)
+ {
+ throw new NotSupportedException ();
+ }
+
+ void IList.Remove (object value)
+ {
+ TabPage page = value as TabPage;
+ if (page == null)
+ return;
+ Remove ((TabPage) value);
+ }
+ }
+ #endregion // Class TabPage.TabPageCollection
+ }
+}
+
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabDrawMode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabDrawMode.cs
new file mode 100644
index 00000000000..8de82769517
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabDrawMode.cs
@@ -0,0 +1,33 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+namespace System.Windows.Forms {
+
+ public enum TabDrawMode {
+ Normal,
+ OwnerDrawFixed
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabPage.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabPage.cs
new file mode 100644
index 00000000000..49d44e88e29
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabPage.cs
@@ -0,0 +1,284 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+ [DefaultEvent("Click")]
+ [DesignTimeVisible(false)]
+ [DefaultProperty("Text")]
+ [Designer("System.Windows.Forms.Design.TabPageDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ [ToolboxItem(false)]
+ public class TabPage : Panel {
+ #region Fields
+ private int image_index = -1;
+ private string tooltip_text = String.Empty;
+ private Rectangle tab_bounds;
+ private int row;
+ private bool use_visual_style_back_color;
+ #endregion // Fields
+
+ #region Public Constructors
+ public TabPage ()
+ {
+ Visible = true;
+
+ SetStyle (ControlStyles.CacheText, true);
+ }
+
+ public TabPage (string text) : base ()
+ {
+ base.Text = text;
+ }
+
+ #endregion // Public Constructors
+
+ #region .NET 2.0 Public Instance Properties
+#if NET_2_0
+ public bool UseVisualStyleBackColor {
+ get { return use_visual_style_back_color; }
+ set { use_visual_style_back_color = value; }
+ }
+
+ public override Color BackColor {
+ get { return base.BackColor; }
+ set { use_visual_style_back_color = false; base.BackColor = value; }
+ }
+#endif
+ #endregion
+
+ #region Public Instance Properties
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override AnchorStyles Anchor {
+ get { return base.Anchor; }
+ set { base.Anchor = value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override DockStyle Dock {
+ get { return base.Dock; }
+ set { base.Dock = value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new bool Enabled {
+ get { return base.Enabled; }
+ set { base.Enabled = value; }
+ }
+
+ [DefaultValue(-1)]
+ [Editor("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
+ [Localizable(true)]
+ [TypeConverter(typeof(ImageIndexConverter))]
+ public int ImageIndex {
+ get { return image_index; }
+ set {
+ if (image_index == value)
+ return;
+ image_index = value;
+ UpdateOwner ();
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new int TabIndex {
+ get { return base.TabIndex; }
+ set { base.TabIndex = value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new bool TabStop {
+ get { return base.TabStop; }
+ set { base.TabStop = value; }
+ }
+
+ [Browsable(true)]
+ [Localizable(true)]
+ public override string Text {
+ get { return base.Text; }
+ set {
+ if (value == base.Text)
+ return;
+ base.Text = value;
+ UpdateOwner ();
+ }
+ }
+
+ [Localizable(true)]
+ [DefaultValue("")]
+ public string ToolTipText {
+ get { return tooltip_text; }
+ set {
+ if (value == null)
+ value = String.Empty;
+ tooltip_text = value;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new bool Visible {
+ get { return base.Visible; }
+ set { base.Visible = value; }
+ }
+
+ #endregion // Public Instance Properties
+
+ #region Public Static Methods
+ public static TabPage GetTabPageOfComponent (object comp)
+ {
+ Control control = comp as Control;
+ if (control == null)
+ return null;
+ control = control.Parent;
+ while (control != null) {
+ if (control is TabPage)
+ break;
+ control = control.Parent;
+ }
+ return control as TabPage;
+ }
+
+ #endregion // Public Static Methods
+
+ #region Public Instance Methods
+ public override string ToString ()
+ {
+ return "TabPage: {" + Text + "}";
+ }
+
+ #endregion // Public Instance Methods
+
+ #region Internal & Private Methods and Properties
+ internal Rectangle TabBounds {
+ get { return tab_bounds; }
+ set { tab_bounds = value; }
+ }
+
+ internal int Row {
+ get { return row; }
+ set { row = value; }
+ }
+
+ private void UpdateOwner ()
+ {
+ if (Owner != null) {
+ Owner.Redraw ();
+ }
+ }
+
+ private TabControl Owner {
+ get { return base.Parent as TabControl; }
+ }
+
+ #endregion // Internal & Private Methods and Properties
+
+ #region Protected Instance Methods
+ protected override ControlCollection CreateControlsInstance ()
+ {
+ return new TabPageControlCollection (this);
+ }
+
+ protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified)
+ {
+ if (Owner != null && Owner.IsHandleCreated) {
+ Rectangle display = Owner.DisplayRectangle;
+
+ base.SetBoundsCore (display.X, display.Y,
+ display.Width, display.Height,
+ BoundsSpecified.All);
+ } else {
+ base.SetBoundsCore (x, y, width, height, specified);
+ }
+ }
+
+ #endregion // Protected Instance Methods
+
+ #region Events
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler DockChanged {
+ add { base.DockChanged += value; }
+ remove { base.DockChanged -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler EnabledChanged {
+ add { base.EnabledChanged += value; }
+ remove { base.EnabledChanged -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler TabIndexChanged {
+ add { base.TabIndexChanged += value; }
+ remove { base.TabIndexChanged -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler TabStopChanged {
+ add { base.TabStopChanged += value; }
+ remove { base.TabStopChanged -= value; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler VisibleChanged {
+ add { base.VisibleChanged += value; }
+ remove { base.VisibleChanged -= value; }
+ }
+
+ #endregion // Events
+
+ #region Class TabPageControlCollection
+ public class TabPageControlCollection : ControlCollection {
+
+ private TabPage owner;
+
+ public TabPageControlCollection (TabPage owner) : base (owner)
+ {
+ this.owner = owner;
+ }
+
+ public override void Add (Control value)
+ {
+ base.Add (value);
+ }
+ }
+ #endregion // Class TabPageControlCollection
+ }
+
+
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabSizeMode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabSizeMode.cs
new file mode 100644
index 00000000000..45cf1508950
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabSizeMode.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+namespace System.Windows.Forms {
+
+ public enum TabSizeMode {
+ Normal,
+ FillToRight,
+ Fixed
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayout.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayout.cs
new file mode 100644
index 00000000000..8065e61e253
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayout.cs
@@ -0,0 +1,45 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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:
+// Miguel de Icaza (miguel@gnome.org)
+//
+// (C) 2004 Novell, Inc.
+//
+#if NET_2_0
+using System;
+using System.ComponentModel;
+using System.Windows.Forms.Layout;
+
+namespace System.Windows.Forms {
+
+ public class TableLayout : LayoutEngine {
+
+ public override void InitLayout (object child, BoundsSpecified specified)
+ {
+ }
+
+ public override bool Layout (object container, LayoutEventArgs args)
+ {
+ return false;
+ }
+ }
+}
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanel.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanel.cs
new file mode 100644
index 00000000000..005736fa1bb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanel.cs
@@ -0,0 +1,87 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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:
+// Miguel de Icaza (miguel@gnome.org)
+//
+// (C) 2004 Novell, Inc.
+//
+#if NET_2_0
+using System;
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+
+ public class TableLayoutPanel : Panel, IExtenderProvider {
+ TableLayoutSettings settings;
+
+ public TableLayoutPanel ()
+ {
+ settings = new TableLayoutSettings (this);
+ }
+
+ internal void Relayout ()
+ {
+ }
+
+#region Proxy Properties
+ new public BorderStyle BorderStyle {
+ get {
+ return base.BorderStyle;
+ }
+
+ set {
+ base.BorderStyle = value;
+ }
+ }
+
+ public int ColumnCount {
+ get {
+ return settings.ColumnCount;
+ }
+
+ set {
+ settings.ColumnCount = value;
+ }
+ }
+
+ public int RowCount {
+ get {
+ return settings.RowCount;
+ }
+
+ set {
+ settings.RowCount = value;
+ }
+ }
+#endregion
+
+#region IExtenderProvider
+ bool IExtenderProvider.CanExtend (object extendee)
+ {
+ //
+ // Read: `Implementing an Extender Provider'
+ //
+ throw new NotImplementedException ();
+ }
+#endregion
+ }
+}
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanelGrowStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanelGrowStyle.cs
new file mode 100644
index 00000000000..7a3593c1f88
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanelGrowStyle.cs
@@ -0,0 +1,34 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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:
+// Miguel de Icaza (miguel@gnome.org)
+//
+// (C) 2004 Novell, Inc.
+//
+#if NET_2_0
+namespace System.Windows.Forms {
+ public enum TableLayoutPanelGrowStyle {
+ FixedSize,
+ AddRows,
+ AddColumns,
+ }
+}
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutSettings.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutSettings.cs
new file mode 100644
index 00000000000..cd48738c2bc
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutSettings.cs
@@ -0,0 +1,208 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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:
+// Miguel de Icaza (miguel@gnome.org)
+//
+// (C) 2004 Novell, Inc.
+//
+#if NET_2_0
+using System;
+using System.ComponentModel;
+using System.Collections;
+using System.Windows.Forms.Layout;
+
+namespace System.Windows.Forms {
+
+ public class TableLayoutSettings : LayoutSettings {
+ TableLayoutPanel panel;
+ ColumnStyleCollection column_style;
+ TableLayoutPanelGrowStyle grow_style;
+ int column_count;
+ int row_count;
+
+ // Statics
+ static LayoutEngine layout_engine = new TableLayout ();
+
+ internal TableLayoutSettings (TableLayoutPanel panel)
+ {
+ this.panel = panel;
+ column_count = 0;
+ row_count = 0;
+ grow_style = TableLayoutPanelGrowStyle.AddRows;
+ column_style = new ColumnStyleCollection (panel);
+ }
+
+ public int ColumnCount {
+ get {
+ return column_count;
+ }
+
+ set {
+ column_count = value;
+ }
+ }
+
+ public int RowCount {
+ get {
+ return row_count;
+ }
+
+ set {
+ row_count = value;
+ }
+ }
+
+ public TableLayoutPanelGrowStyle GrowStyle {
+ get {
+ return grow_style;
+ }
+ }
+
+ public override LayoutEngine LayoutEngine {
+ get {
+ return layout_engine;
+ }
+ }
+
+ public TableLayoutSettings.ColumnStyleCollection ColumnStyle {
+ get {
+ return column_style;
+ }
+ }
+
+ public abstract class StyleCollection {
+ ArrayList al = new ArrayList ();
+ TableLayoutPanel table;
+
+ internal StyleCollection (TableLayoutPanel table)
+ {
+ this.table = table;
+ }
+
+ public int Add (TableLayoutSettings.Style style)
+ {
+ return al.Add (style);
+ }
+
+ // FIXME; later this should be an override.
+ public void Clear ()
+ {
+ al.Clear ();
+
+ // FIXME: Need to investigate what happens when the style is gone.
+ table.Relayout ();
+ }
+
+#region IList methods
+ //
+ // The IList methods will later be implemeneted, this is to get us started
+ //
+ internal bool Contains (Style style)
+ {
+ return al.Contains (style);
+ }
+
+ internal int IndexOf (Style style)
+ {
+ return al.IndexOf (style);
+ }
+
+ internal void Insert (int index, Style style)
+ {
+ al.Insert (index, style);
+ }
+
+ internal void Remove (Style style)
+ {
+ al.Remove (style);
+ }
+
+#endregion
+ public Style this [int idx] {
+ get {
+ return (Style) al [idx];
+ }
+
+ set {
+ al [idx] = value;
+ }
+ }
+ }
+
+ public class ColumnStyleCollection : StyleCollection {
+
+ internal ColumnStyleCollection (TableLayoutPanel panel) : base (panel)
+ {
+ }
+
+ public void Add (ColumnStyle style)
+ {
+ base.Add (style);
+ }
+
+ public bool Contains (ColumnStyle style)
+ {
+ return base.Contains (style);
+ }
+
+ public int IndexOf (ColumnStyle style)
+ {
+ return base.IndexOf (style);
+ }
+
+ public void Insert (int index, ColumnStyle style)
+ {
+ base.Insert (index, style);
+ }
+
+ public void Remove (ColumnStyle style)
+ {
+ base.Remove (style);
+ }
+
+ public new ColumnStyle this [int index] {
+ get {
+ return (ColumnStyle) base [index];
+ }
+
+ set {
+ base [index] = value;
+ }
+ }
+ }
+
+ public class Style {
+ internal SizeType size_type;
+
+ public SizeType SizeType {
+ get {
+ return size_type;
+ }
+
+ set {
+ size_type = value;
+ }
+ }
+ }
+ }
+
+}
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs
new file mode 100644
index 00000000000..fb10abc6f7a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs
@@ -0,0 +1,238 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+// NOT COMPLETE
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+ public class TextBox : TextBoxBase {
+ #region Public Constructors
+ public TextBox() {
+ scrollbars = RichTextBoxScrollBars.None;
+ alignment = HorizontalAlignment.Left;
+ this.LostFocus +=new EventHandler(TextBox_LostFocus);
+ this.BackColor = ThemeEngine.Current.ColorWindow;
+ this.ForeColor = ThemeEngine.Current.ColorWindowText;
+
+ SetStyle (ControlStyles.StandardClick | ControlStyles.StandardDoubleClick, false);
+ SetStyle (ControlStyles.FixedHeight, true);
+ }
+ #endregion // Public Constructors
+
+
+ #region Private & Internal Methods
+ private void TextBox_LostFocus(object sender, EventArgs e) {
+ has_focus = false;
+ Invalidate();
+ }
+ #endregion // Private & Internal Methods
+
+ #region Public Instance Properties
+#if NET_2_0
+ private bool use_system_password_char = false;
+
+ [DefaultValue(false)]
+ public bool UseSystemPasswordChar {
+ get {
+ return use_system_password_char;
+ }
+
+ set {
+ use_system_password_char = value;
+ }
+ }
+#endif
+
+ [DefaultValue(false)]
+ public bool AcceptsReturn {
+ get {
+ return accepts_return;
+ }
+
+ set {
+ if (value != accepts_return) {
+ accepts_return = value;
+ }
+ }
+ }
+
+ [DefaultValue(CharacterCasing.Normal)]
+ public CharacterCasing CharacterCasing {
+ get {
+ return character_casing;
+ }
+
+ set {
+ if (value != character_casing) {
+ character_casing = value;
+ }
+ }
+ }
+
+ [Localizable(true)]
+ [DefaultValue('\0')]
+ public char PasswordChar {
+ get {
+#if NET_2_0
+ if (use_system_password_char) {
+ return '*';
+ }
+#endif
+ return password_char;
+ }
+
+ set {
+ if (value != password_char) {
+ password_char = value;
+ if (!multiline) {
+ document.PasswordChar = value.ToString();
+ } else {
+ document.PasswordChar = "";
+ }
+ }
+ }
+ }
+
+ [DefaultValue(ScrollBars.None)]
+ [Localizable(true)]
+ public ScrollBars ScrollBars {
+ get {
+ return (ScrollBars)scrollbars;
+ }
+
+ set {
+ if (value != (ScrollBars)scrollbars) {
+ scrollbars = (RichTextBoxScrollBars)value;
+ base.CalculateScrollBars();
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public override int SelectionLength {
+ get {
+ return base.SelectionLength;
+ }
+ set {
+ base.SelectionLength = value;
+ }
+ }
+
+
+ public override string Text {
+ get {
+ return base.Text;
+ }
+
+ set {
+ base.Text = value;
+ }
+ }
+
+ [DefaultValue(HorizontalAlignment.Left)]
+ [Localizable(true)]
+ public HorizontalAlignment TextAlign {
+ get {
+ return alignment;
+ }
+
+ set {
+ if (value != alignment) {
+ alignment = value;
+
+ // MS word-wraps if alignment isn't left
+ if (multiline) {
+ if (alignment != HorizontalAlignment.Left) {
+ document.Wrap = true;
+ } else {
+ document.Wrap = word_wrap;
+ }
+ }
+
+ for (int i = 1; i <= document.Lines; i++) {
+ document.GetLine(i).Alignment = value;
+ }
+ document.RecalculateDocument(CreateGraphicsInternal());
+ OnTextAlignChanged(EventArgs.Empty);
+ }
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Methods
+ protected override CreateParams CreateParams {
+ get {
+ return base.CreateParams;
+ }
+ }
+
+ protected override ImeMode DefaultImeMode {
+ get {
+ return base.DefaultImeMode;
+ }
+ }
+ #endregion // Protected Instance Methods
+
+ #region Protected Instance Methods
+ protected override bool IsInputKey(Keys keyData) {
+ return base.IsInputKey (keyData);
+ }
+
+ protected override void OnGotFocus(EventArgs e) {
+ has_focus=true;
+ Invalidate();
+ base.OnGotFocus (e);
+ }
+
+ protected override void OnHandleCreated(EventArgs e) {
+ base.OnHandleCreated (e);
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e) {
+ base.OnMouseUp (e);
+ }
+
+ protected virtual void OnTextAlignChanged(EventArgs e) {
+ if (TextAlignChanged != null) {
+ TextAlignChanged(this, e);
+ }
+ }
+
+ protected override void WndProc(ref Message m) {
+ base.WndProc(ref m);
+ }
+ #endregion // Protected Instance Methods
+
+ #region Events
+ public event EventHandler TextAlignChanged;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
new file mode 100644
index 00000000000..442649c7a6a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
@@ -0,0 +1,1669 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+// NOT COMPLETE
+#undef Debug
+#undef DebugClick
+
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.Drawing.Text;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [DefaultEvent("TextChanged")]
+ [Designer("System.Windows.Forms.Design.TextBoxBaseDesigner, " + Consts.AssemblySystem_Design)]
+ public abstract class TextBoxBase : Control {
+ #region Local Variables
+ internal HorizontalAlignment alignment;
+ internal bool accepts_tab;
+ internal bool accepts_return;
+ internal bool auto_size;
+ internal CharacterCasing character_casing;
+ internal bool undo;
+ internal bool hide_selection;
+ internal int max_length;
+ internal bool modified;
+ internal bool multiline;
+ internal char password_char;
+ internal bool read_only;
+ internal bool word_wrap;
+ internal Document document;
+ internal LineTag caret_tag; // tag our cursor is in
+ internal int caret_pos; // position on the line our cursor is in (can be 0 = beginning of line)
+ internal ImplicitHScrollBar hscroll;
+ internal ImplicitVScrollBar vscroll;
+ internal RichTextBoxScrollBars scrollbars;
+ internal bool richtext;
+ internal int requested_height;
+ internal int canvas_width;
+ internal int canvas_height;
+ static internal int track_width = 20;
+ static internal int track_border = 5;
+ internal DateTime click_last;
+ internal CaretSelection click_mode;
+ internal Bitmap bmp;
+ #if Debug
+ internal static bool draw_lines = false;
+ #endif
+
+ #endregion // Local Variables
+
+ #region Internal Constructor
+ // Constructor will go when complete, only for testing - pdb
+ internal TextBoxBase() {
+ alignment = HorizontalAlignment.Left;
+ accepts_return = false;
+ accepts_tab = false;
+ auto_size = true;
+ border_style = BorderStyle.Fixed3D;
+ character_casing = CharacterCasing.Normal;
+ undo = false;
+ hide_selection = true;
+ max_length = 32767;
+ modified = false;
+ multiline = false;
+ password_char = '\0';
+ read_only = false;
+ word_wrap = true;
+ richtext = false;
+ document = new Document(this);
+ document.WidthChanged += new EventHandler(document_WidthChanged);
+ document.HeightChanged += new EventHandler(document_HeightChanged);
+ //document.CaretMoved += new EventHandler(CaretMoved);
+ document.Wrap = false;
+ requested_height = -1;
+ click_last = DateTime.Now;
+ click_mode = CaretSelection.Position;
+ bmp = new Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
+
+ MouseDown += new MouseEventHandler(TextBoxBase_MouseDown);
+ MouseUp += new MouseEventHandler(TextBoxBase_MouseUp);
+ MouseMove += new MouseEventHandler(TextBoxBase_MouseMove);
+ SizeChanged += new EventHandler(TextBoxBase_SizeChanged);
+ FontChanged += new EventHandler(TextBoxBase_FontOrColorChanged);
+ ForeColorChanged += new EventHandler(TextBoxBase_FontOrColorChanged);
+ MouseWheel += new MouseEventHandler(TextBoxBase_MouseWheel);
+
+ scrollbars = RichTextBoxScrollBars.None;
+
+ hscroll = new ImplicitHScrollBar();
+ hscroll.ValueChanged += new EventHandler(hscroll_ValueChanged);
+ hscroll.control_style &= ~ControlStyles.Selectable;
+ hscroll.Enabled = false;
+ hscroll.Visible = false;
+
+ vscroll = new ImplicitVScrollBar();
+ vscroll.ValueChanged += new EventHandler(vscroll_ValueChanged);
+ vscroll.control_style &= ~ControlStyles.Selectable;
+ vscroll.Enabled = false;
+ vscroll.Visible = false;
+
+ SuspendLayout ();
+ this.Controls.AddImplicit (hscroll);
+ this.Controls.AddImplicit (vscroll);
+ ResumeLayout ();
+
+ //SetStyle(ControlStyles.ResizeRedraw, true);
+ SetStyle(ControlStyles.UserPaint | ControlStyles.StandardClick, false);
+
+ canvas_width = ClientSize.Width;
+ canvas_height = ClientSize.Height;
+
+ CalculateScrollBars();
+ }
+ #endregion // Internal Constructor
+
+ #region Private and Internal Methods
+ internal string CaseAdjust(string s) {
+ if (character_casing == CharacterCasing.Normal) {
+ return s;
+ }
+ if (character_casing == CharacterCasing.Lower) {
+ return s.ToLower();
+ } else {
+ return s.ToUpper();
+ }
+ }
+ #endregion // Private and Internal Methods
+
+ #region Public Instance Properties
+ [DefaultValue(false)]
+ public bool AcceptsTab {
+ get {
+ return accepts_tab;
+ }
+
+ set {
+ if (value != accepts_tab) {
+ accepts_tab = value;
+ OnAcceptsTabChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ [DefaultValue(true)]
+ [Localizable(true)]
+ [RefreshProperties(RefreshProperties.Repaint)]
+ public virtual bool AutoSize {
+ get {
+ return auto_size;
+ }
+
+ set {
+ if (value != auto_size) {
+ auto_size = value;
+ if (auto_size) {
+ if (PreferredHeight != ClientSize.Height) {
+ ClientSize = new Size(ClientSize.Width, PreferredHeight);
+ }
+ }
+ OnAutoSizeChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ [DispId(-501)]
+ public override System.Drawing.Color BackColor {
+ get {
+ return base.BackColor;
+ }
+ set {
+ base.BackColor = value;
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override System.Drawing.Image BackgroundImage {
+ get {
+ return base.BackgroundImage;
+ }
+ set {
+ base.BackgroundImage = value;
+ }
+ }
+
+ [DefaultValue(BorderStyle.Fixed3D)]
+ [DispId(-504)]
+ public BorderStyle BorderStyle {
+ get { return InternalBorderStyle; }
+ set {
+ InternalBorderStyle = value;
+ OnBorderStyleChanged(EventArgs.Empty);
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool CanUndo {
+ get {
+ return undo;
+ }
+ }
+
+ [DispId(-513)]
+ public override System.Drawing.Color ForeColor {
+ get {
+ return base.ForeColor;
+ }
+ set {
+ base.ForeColor = value;
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool HideSelection {
+ get {
+ return hide_selection;
+ }
+
+ set {
+ if (value != hide_selection) {
+ hide_selection = value;
+ OnHideSelectionChanged(EventArgs.Empty);
+ }
+ if (hide_selection) {
+ document.selection_visible = false;
+ } else {
+ document.selection_visible = true;
+ }
+ document.InvalidateSelectionArea();
+
+ }
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [Editor("System.Windows.Forms.Design.StringArrayEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
+ [Localizable(true)]
+ public string[] Lines {
+ get {
+ string[] lines;
+ int i;
+ int l;
+
+ l = document.Lines;
+ lines = new string[l];
+
+ for (i = 1; i <= l; i++) {
+ lines[i - 1] = document.GetLine(i).text.ToString();
+ }
+
+ return lines;
+ }
+
+ set {
+ int i;
+ int l;
+ Brush brush;
+
+ document.Empty();
+
+ l = value.Length;
+ brush = ThemeEngine.Current.ResPool.GetSolidBrush(this.ForeColor);
+
+ for (i = 0; i < l; i++) {
+ document.Add(i+1, CaseAdjust(value[i]), alignment, Font, brush);
+ }
+ CalculateDocument();
+ OnTextChanged(EventArgs.Empty);
+ }
+ }
+
+ [DefaultValue(32767)]
+ [Localizable(true)]
+ public virtual int MaxLength {
+ get {
+ if (max_length == 2147483646) { // We don't distinguish between single and multi-line limits
+ return 0;
+ }
+ return max_length;
+ }
+
+ set {
+ if (value != max_length) {
+ max_length = value;
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool Modified {
+ get {
+ return modified;
+ }
+
+ set {
+ if (value != modified) {
+ modified = value;
+ OnModifiedChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ [DefaultValue(false)]
+ [Localizable(true)]
+ [RefreshProperties(RefreshProperties.All)]
+ public virtual bool Multiline {
+ get {
+ return multiline;
+ }
+
+ set {
+ if (value != multiline) {
+ multiline = value;
+ // Make sure we update our size; the user may have already set the size before going to multiline
+ if (multiline && requested_height != -1) {
+ Height = requested_height;
+ requested_height = -1;
+ }
+
+ OnMultilineChanged(EventArgs.Empty);
+ }
+
+ document.multiline = multiline;
+
+ if (multiline) {
+ document.Wrap = word_wrap;
+ document.PasswordChar = "";
+
+ } else {
+ document.Wrap = false;
+ if (this.password_char != '\0') {
+ document.PasswordChar = password_char.ToString();
+ } else {
+ document.PasswordChar = "";
+ }
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public int PreferredHeight {
+ get {
+ return this.Font.Height + 7; // FIXME - consider border style as well
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool ReadOnly {
+ get {
+ return read_only;
+ }
+
+ set {
+ if (value != read_only) {
+ read_only = value;
+ OnReadOnlyChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public virtual string SelectedText {
+ get {
+ return document.GetSelection();
+ }
+
+ set {
+ if (!read_only) {
+ document.ReplaceSelection(CaseAdjust(value));
+ ScrollToCaret();
+ OnTextChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public virtual int SelectionLength {
+ get {
+ return document.SelectionLength();
+ }
+
+ set {
+ if (value != 0) {
+ int start;
+ Line line;
+ LineTag tag;
+ int pos;
+
+ start = document.LineTagToCharIndex(document.selection_start.line, document.selection_start.pos);
+
+ document.CharIndexToLineTag(start + value, out line, out tag, out pos);
+ document.SetSelectionEnd(line, pos);
+ document.PositionCaret(line, pos);
+ } else {
+ document.SetSelectionEnd(document.selection_start.line, document.selection_start.pos);
+ document.PositionCaret(document.selection_start.line, document.selection_start.pos);
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int SelectionStart {
+ get {
+ int index;
+
+ index = document.LineTagToCharIndex(document.selection_start.line, document.selection_start.pos);
+
+ return index;
+ }
+
+ set {
+ Line line;
+ LineTag tag;
+ int pos;
+
+ document.CharIndexToLineTag(value, out line, out tag, out pos);
+ document.SetSelectionStart(line, pos);
+ ScrollToCaret();
+ }
+ }
+
+ [Localizable(true)]
+ public override string Text {
+ get {
+ if (document == null || document.Root == null || document.Root.text == null) {
+ return string.Empty;
+ }
+
+ if (!multiline) {
+ return document.Root.text.ToString();
+ } else {
+ StringBuilder sb;
+ int i;
+
+ sb = new StringBuilder();
+
+ for (i = 1; i < document.Lines; i++) {
+ sb.Append(document.GetLine(i).text.ToString() + Environment.NewLine);
+ }
+ sb.Append(document.GetLine(document.Lines).text.ToString());
+ return sb.ToString();
+ }
+ }
+
+ set {
+ if (value == base.Text) {
+ return;
+ }
+
+ if ((value != null) && (value != "")) {
+ Line line;
+
+ if (multiline) {
+ string[] lines;
+
+ lines = value.Split(new char[] {'\n'});
+
+ for (int i = 0; i < lines.Length; i++) {
+ if (lines[i].EndsWith("\r")) {
+ lines[i] = lines[i].Substring(0, lines[i].Length - 1);
+ }
+ }
+ this.Lines = lines;
+
+ line = document.GetLine(1);
+ document.SetSelectionStart(line, 0);
+
+ line = document.GetLine(document.Lines);
+ document.SetSelectionEnd(line, line.text.Length);
+ document.PositionCaret(line, line.text.Length);
+ } else {
+ document.Clear();
+ document.Add(1, CaseAdjust(value), alignment, Font, ThemeEngine.Current.ResPool.GetSolidBrush(ForeColor));
+ CalculateDocument();
+ line = document.GetLine(1);
+ document.SetSelectionStart(line, 0);
+ document.SetSelectionEnd(line, value.Length);
+ document.PositionCaret(line, value.Length);
+ }
+ } else {
+ document.Empty();
+ CalculateDocument();
+ }
+ base.Text = value;
+ // Not needed, base.Text already fires it
+ // OnTextChanged(EventArgs.Empty);
+ }
+ }
+
+ [Browsable(false)]
+ public virtual int TextLength {
+ get {
+ if (document == null || document.Root == null || document.Root.text == null) {
+ return 0;
+ }
+
+ if (!multiline) {
+ return document.Root.text.Length;
+ } else {
+ int total;
+ int i;
+
+ total = 0;
+ for (i = 1; i < document.Lines; i++) {
+ total += document.GetLine(i).text.Length + Environment.NewLine.Length;
+ }
+ total += document.GetLine(i).text.Length;
+
+ return total;
+ }
+ }
+ }
+
+ [DefaultValue(true)]
+ [Localizable(true)]
+ public bool WordWrap {
+ get {
+ return word_wrap;
+ }
+
+ set {
+ if (value != word_wrap) {
+ if (multiline) {
+ word_wrap = value;
+ document.Wrap = value;
+ }
+ }
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Properties
+ protected override CreateParams CreateParams {
+ get {
+ return base.CreateParams;
+ }
+ }
+
+ protected override System.Drawing.Size DefaultSize {
+ get {
+ return new Size(100, 20);
+ }
+ }
+ #endregion // Protected Instance Properties
+
+ #region Public Instance Methods
+ public void AppendText(string text) {
+ if (multiline) {
+ // Grab the formatting for the last element
+ document.MoveCaret(CaretDirection.CtrlEnd);
+ // grab the end tag
+ if (document.CaretTag.next != null) {
+ document.CaretTag = document.CaretTag.next;
+ }
+ document.Insert(document.CaretLine, document.CaretTag, document.CaretPosition, false, text);
+
+ CalculateDocument();
+ } else {
+ document.MoveCaret(CaretDirection.CtrlEnd);
+ document.InsertStringAtCaret(text, true);
+
+ Invalidate();
+ }
+
+ document.MoveCaret(CaretDirection.CtrlEnd);
+ document.SetSelectionStart(document.CaretLine, document.CaretPosition);
+ document.SetSelectionEnd(document.CaretLine, document.CaretPosition);
+
+ OnTextChanged(EventArgs.Empty);
+ }
+
+ public void Clear() {
+ Text = null;
+ }
+
+ public void ClearUndo() {
+ document.undo.Clear();
+ }
+
+ public void Copy() {
+ DataObject o;
+
+ o = new DataObject(DataFormats.Text, SelectedText);
+ if (this is RichTextBox) {
+ o.SetData(DataFormats.Rtf, ((RichTextBox)this).SelectedRtf);
+ }
+ Clipboard.SetDataObject(o);
+ }
+
+ public void Cut() {
+ DataObject o;
+
+ o = new DataObject(DataFormats.Text, SelectedText);
+ if (this is RichTextBox) {
+ o.SetData(DataFormats.Rtf, ((RichTextBox)this).SelectedRtf);
+ }
+ Clipboard.SetDataObject(o);
+ document.ReplaceSelection("");
+ }
+
+ public void Paste() {
+ Paste(null, false);
+ }
+
+ public void ScrollToCaret() {
+ this.CaretMoved(this, EventArgs.Empty);
+ }
+
+ public void Select(int start, int length) {
+ SelectionStart = start;
+ SelectionLength = length;
+ }
+
+
+ public void SelectAll() {
+ Line last;
+
+ last = document.GetLine(document.Lines);
+ document.SetSelectionStart(document.GetLine(1), 0);
+ document.SetSelectionEnd(last, last.text.Length);
+ }
+
+ public override string ToString() {
+ return Text;
+ }
+
+ public void Undo() {
+ document.undo.Undo();
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected override void CreateHandle() {
+ base.CreateHandle ();
+ }
+
+ protected override bool IsInputKey(Keys keyData) {
+ if ((keyData & Keys.Alt) != 0) {
+ return base.IsInputKey(keyData);
+ }
+
+ switch (keyData & Keys.KeyCode) {
+ case Keys.Enter: {
+ if (multiline && accepts_return) {
+ return true;
+ }
+ return false;
+ }
+
+ case Keys.Tab: {
+ if (accepts_tab && multiline) {
+ if ((keyData & Keys.Control) == 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ case Keys.Left:
+ case Keys.Right:
+ case Keys.Up:
+ case Keys.Down:
+ case Keys.PageUp:
+ case Keys.PageDown:
+ case Keys.Home:
+ case Keys.End: {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ protected virtual void OnAcceptsTabChanged(EventArgs e) {
+ if (AcceptsTabChanged != null) {
+ AcceptsTabChanged(this, e);
+ }
+ }
+
+ protected virtual void OnAutoSizeChanged(EventArgs e) {
+ if (AutoSizeChanged != null) {
+ AutoSizeChanged(this, e);
+ }
+ }
+
+ protected virtual void OnBorderStyleChanged(EventArgs e) {
+ if (BorderStyleChanged != null) {
+ BorderStyleChanged(this, e);
+ }
+ }
+
+ protected override void OnFontChanged(EventArgs e) {
+ base.OnFontChanged (e);
+
+ if (auto_size) {
+ if (PreferredHeight != ClientSize.Height) {
+ Height = PreferredHeight;
+ }
+ }
+ }
+
+ protected override void OnHandleCreated(EventArgs e) {
+ base.OnHandleCreated (e);
+ }
+
+ protected override void OnHandleDestroyed(EventArgs e) {
+ base.OnHandleDestroyed (e);
+ }
+
+ protected virtual void OnHideSelectionChanged(EventArgs e) {
+ if (HideSelectionChanged != null) {
+ HideSelectionChanged(this, e);
+ }
+ }
+
+ protected virtual void OnModifiedChanged(EventArgs e) {
+ if (ModifiedChanged != null) {
+ ModifiedChanged(this, e);
+ }
+ }
+
+ protected virtual void OnMultilineChanged(EventArgs e) {
+ if (MultilineChanged != null) {
+ MultilineChanged(this, e);
+ }
+ }
+
+ protected virtual void OnReadOnlyChanged(EventArgs e) {
+ if (ReadOnlyChanged != null) {
+ ReadOnlyChanged(this, e);
+ }
+ }
+
+ protected override bool ProcessDialogKey(Keys keyData) {
+ return base.ProcessDialogKey(keyData);
+ }
+
+ private bool ProcessKey(Keys keyData) {
+ bool control;
+ bool shift;
+
+ control = (Control.ModifierKeys & Keys.Control) != 0;
+ shift = (Control.ModifierKeys & Keys.Shift) != 0;
+
+ switch (keyData & Keys.KeyCode) {
+ case Keys.X: { // Cut (Ctrl-X)
+ if (control) {
+ Cut();
+ return true;
+ }
+ return false;
+ }
+
+ case Keys.C: { // Copy (Ctrl-C)
+ if (control) {
+ Copy();
+ return true;
+ }
+ return false;
+ }
+
+ case Keys.V: { // Paste (Ctrl-V)
+ if (control) {
+ return Paste(null, true);
+ }
+ return false;
+ }
+
+ case Keys.Z: { // Undo (Ctrl-Z)
+ if (control) {
+ Undo();
+ return true;
+ }
+ return false;
+ }
+
+ case Keys.Left: {
+ if (control) {
+ document.MoveCaret(CaretDirection.WordBack);
+ } else {
+ if (!document.selection_visible || shift) {
+ document.MoveCaret(CaretDirection.CharBack);
+ } else {
+ document.MoveCaret(CaretDirection.SelectionStart);
+ }
+ }
+
+ if (!shift) {
+ document.SetSelectionToCaret(true);
+ } else {
+ document.SetSelectionToCaret(false);
+ }
+
+ CaretMoved(this, null);
+ return true;
+ }
+
+ case Keys.Right: {
+ if (control) {
+ document.MoveCaret(CaretDirection.WordForward);
+ } else {
+ if (!document.selection_visible || shift) {
+ document.MoveCaret(CaretDirection.CharForward);
+ } else {
+ document.MoveCaret(CaretDirection.SelectionEnd);
+ }
+ }
+ if (!shift) {
+ document.SetSelectionToCaret(true);
+ } else {
+ document.SetSelectionToCaret(false);
+ }
+
+ CaretMoved(this, null);
+ return true;
+ }
+
+ case Keys.Up: {
+ if (control) {
+ if (document.CaretPosition == 0) {
+ document.MoveCaret(CaretDirection.LineUp);
+ } else {
+ document.MoveCaret(CaretDirection.Home);
+ }
+ } else {
+ document.MoveCaret(CaretDirection.LineUp);
+ }
+
+ if ((Control.ModifierKeys & Keys.Shift) == 0) {
+ document.SetSelectionToCaret(true);
+ } else {
+ document.SetSelectionToCaret(false);
+ }
+
+ CaretMoved(this, null);
+ return true;
+ }
+
+ case Keys.Down: {
+ if (control) {
+ if (document.CaretPosition == document.CaretLine.Text.Length) {
+ document.MoveCaret(CaretDirection.LineDown);
+ } else {
+ document.MoveCaret(CaretDirection.End);
+ }
+ } else {
+ document.MoveCaret(CaretDirection.LineDown);
+ }
+
+ if ((Control.ModifierKeys & Keys.Shift) == 0) {
+ document.SetSelectionToCaret(true);
+ } else {
+ document.SetSelectionToCaret(false);
+ }
+
+ CaretMoved(this, null);
+ return true;
+ }
+
+ case Keys.Home: {
+ if ((Control.ModifierKeys & Keys.Control) != 0) {
+ document.MoveCaret(CaretDirection.CtrlHome);
+ } else {
+ document.MoveCaret(CaretDirection.Home);
+ }
+
+ if ((Control.ModifierKeys & Keys.Shift) == 0) {
+ document.SetSelectionToCaret(true);
+ } else {
+ document.SetSelectionToCaret(false);
+ }
+
+ CaretMoved(this, null);
+ return true;
+ }
+
+ case Keys.End: {
+ if ((Control.ModifierKeys & Keys.Control) != 0) {
+ document.MoveCaret(CaretDirection.CtrlEnd);
+ } else {
+ document.MoveCaret(CaretDirection.End);
+ }
+
+ if ((Control.ModifierKeys & Keys.Shift) == 0) {
+ document.SetSelectionToCaret(true);
+ } else {
+ document.SetSelectionToCaret(false);
+ }
+
+ CaretMoved(this, null);
+ return true;
+ }
+
+ case Keys.Enter: {
+ // ignoring accepts_return, fixes bug #76355
+ if (!read_only && multiline && (accepts_return || (FindForm() != null && FindForm().AcceptButton == null) || ((Control.ModifierKeys & Keys.Control) != 0))) {
+ Line line;
+
+ if (document.selection_visible) {
+ document.ReplaceSelection("");
+ }
+ document.SetSelectionToCaret(true);
+
+ line = document.CaretLine;
+
+ document.Split(document.CaretLine, document.CaretTag, document.CaretPosition, false);
+ OnTextChanged(EventArgs.Empty);
+ document.UpdateView(line, 2, 0);
+ document.MoveCaret(CaretDirection.CharForward);
+ CaretMoved(this, null);
+ return true;
+ }
+ break;
+ }
+
+ case Keys.Tab: {
+ if (!read_only && accepts_tab && multiline) {
+ document.InsertChar(document.CaretLine, document.CaretPosition, '\t');
+ if (document.selection_visible) {
+ document.ReplaceSelection("");
+ }
+ document.SetSelectionToCaret(true);
+
+ OnTextChanged(EventArgs.Empty);
+ CaretMoved(this, null);
+ return true;
+ }
+ break;
+ }
+
+
+ case Keys.Back: {
+ if (read_only) {
+ break;
+ }
+
+ // delete only deletes on the line, doesn't do the combine
+ if (document.selection_visible) {
+ document.ReplaceSelection("");
+ }
+ document.SetSelectionToCaret(true);
+
+ if (document.CaretPosition == 0) {
+ if (document.CaretLine.LineNo > 1) {
+ Line line;
+ int new_caret_pos;
+
+ line = document.GetLine(document.CaretLine.LineNo - 1);
+ new_caret_pos = line.text.Length;
+
+ document.Combine(line, document.CaretLine);
+ document.UpdateView(line, 1, 0);
+ document.PositionCaret(line, new_caret_pos);
+ //document.MoveCaret(CaretDirection.CharForward);
+ document.UpdateCaret();
+ OnTextChanged(EventArgs.Empty);
+ }
+ } else {
+ if (!control || document.CaretPosition == 0) {
+ document.DeleteChar(document.CaretTag, document.CaretPosition, false);
+ document.MoveCaret(CaretDirection.CharBack);
+ } else {
+ int start_pos;
+
+ start_pos = document.CaretPosition - 1;
+
+ while ((start_pos > 0) && !Document.IsWordSeparator(document.CaretLine.Text[start_pos - 1])) {
+ start_pos--;
+ }
+ document.DeleteChars(document.CaretTag, start_pos, document.CaretPosition - start_pos);
+ document.PositionCaret(document.CaretLine, start_pos);
+ }
+ document.UpdateCaret();
+ OnTextChanged(EventArgs.Empty);
+ }
+ CaretMoved(this, null);
+ return true;
+ }
+
+ case Keys.Insert: {
+ if (shift) {
+ Paste(null, true);
+ return true;
+ }
+
+ if (control) {
+ Copy();
+ return true;
+ }
+
+ // FIXME - need overwrite/insert toggle?
+ return false;
+ }
+
+ case Keys.Delete: {
+ if (shift) {
+ Cut();
+ return true;
+ }
+
+ if (read_only) {
+ break;
+ }
+
+ if (document.selection_visible) {
+ document.ReplaceSelection("");
+ } else {
+ // DeleteChar only deletes on the line, doesn't do the combine
+ if (document.CaretPosition == document.CaretLine.Text.Length) {
+ if (document.CaretLine.LineNo < document.Lines) {
+ Line line;
+
+ line = document.GetLine(document.CaretLine.LineNo + 1);
+ document.Combine(document.CaretLine, line);
+ document.UpdateView(document.CaretLine, 2, 0);
+
+ #if not_Debug
+ Line check_first;
+ Line check_second;
+
+ check_first = document.GetLine(document.CaretLine.LineNo);
+ check_second = document.GetLine(check_first.line_no + 1);
+
+ Console.WriteLine("Post-UpdateView: Y of first line: {0}, second line: {1}", check_first.Y, check_second.Y);
+ #endif
+
+ // Caret doesn't move
+ }
+ } else {
+ if (!control) {
+ document.DeleteChar(document.CaretTag, document.CaretPosition, true);
+ } else {
+ int end_pos;
+
+ end_pos = document.CaretPosition;
+
+ while ((end_pos < document.CaretLine.Text.Length) && !Document.IsWordSeparator(document.CaretLine.Text[end_pos])) {
+ end_pos++;
+ }
+
+ if (end_pos < document.CaretLine.Text.Length) {
+ end_pos++;
+ }
+ document.DeleteChars(document.CaretTag, document.CaretPosition, end_pos - document.CaretPosition);
+ }
+ }
+ }
+
+ OnTextChanged(EventArgs.Empty);
+ document.AlignCaret();
+ document.UpdateCaret();
+ CaretMoved(this, null);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
+ // Make sure we don't get sized bigger than we want to be
+ if (!richtext) {
+ if (!multiline) {
+ if (height != PreferredHeight) {
+ requested_height = height;
+ height = PreferredHeight;
+ specified |= BoundsSpecified.Height;
+ }
+ }
+ }
+
+ base.SetBoundsCore (x, y, width, height, specified);
+
+ TextBoxBase_SizeChanged(this, EventArgs.Empty);
+ CalculateDocument();
+ }
+
+ protected override void WndProc(ref Message m) {
+ switch ((Msg)m.Msg) {
+ case Msg.WM_PAINT: {
+ PaintEventArgs paint_event;
+
+ paint_event = XplatUI.PaintEventStart(Handle, true);
+
+ PaintControl(paint_event);
+ XplatUI.PaintEventEnd(Handle, true);
+ DefWndProc(ref m);
+ return;
+ }
+
+ case Msg.WM_SETFOCUS: {
+ // Set caret
+ document.CaretHasFocus();
+ base.WndProc(ref m);
+ return;
+ }
+
+ case Msg.WM_KILLFOCUS: {
+ // Kill caret
+ document.CaretLostFocus();
+ base.WndProc(ref m);
+ return;
+ }
+
+ case Msg.WM_KEYDOWN: {
+ if (ProcessKeyMessage(ref m) || ProcessKey((Keys)m.WParam.ToInt32() | XplatUI.State.ModifierKeys)) {
+ m.Result = IntPtr.Zero;
+ return;
+ }
+ DefWndProc (ref m);
+ return;
+ }
+
+ case Msg.WM_CHAR: {
+ if (ProcessKeyMessage(ref m)) {
+ m.Result = IntPtr.Zero;
+ return;
+ }
+
+ // Ctrl-Backspace generates a real char, whack it
+ if (m.WParam.ToInt32() == 127) {
+ base.WndProc(ref m);
+ return;
+ }
+
+ if (!read_only && (m.WParam.ToInt32() >= 32)) { // FIXME, tabs should probably go through
+ if (document.selection_visible) {
+ document.ReplaceSelection("");
+ }
+
+ switch (character_casing) {
+ case CharacterCasing.Normal: {
+ if (document.Length < max_length) {
+ document.InsertCharAtCaret((char)m.WParam, true);
+ OnTextChanged(EventArgs.Empty);
+ CaretMoved(this, null);
+ } else {
+ XplatUI.AudibleAlert();
+ }
+ return;
+ }
+
+ case CharacterCasing.Lower: {
+ if (document.Length < max_length) {
+ document.InsertCharAtCaret(Char.ToLower((char)m.WParam), true);
+ OnTextChanged(EventArgs.Empty);
+ CaretMoved(this, null);
+ } else {
+ XplatUI.AudibleAlert();
+ }
+ return;
+ }
+
+ case CharacterCasing.Upper: {
+ if (document.Length < max_length) {
+ document.InsertCharAtCaret(Char.ToUpper((char)m.WParam), true);
+ OnTextChanged(EventArgs.Empty);
+ CaretMoved(this, null);
+ } else {
+ XplatUI.AudibleAlert();
+ }
+ return;
+ }
+ }
+ }
+ return;
+ }
+
+ default: {
+ base.WndProc(ref m);
+ return;
+ }
+ }
+ }
+
+ #endregion // Protected Instance Methods
+
+ #region Events
+ public event EventHandler AcceptsTabChanged;
+ public event EventHandler AutoSizeChanged;
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler BackgroundImageChanged {
+ add { base.BackgroundImageChanged += value; }
+ remove { base.BackgroundImageChanged -= value; }
+ }
+ public event EventHandler BorderStyleChanged;
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public event EventHandler Click;
+ public event EventHandler HideSelectionChanged;
+ public event EventHandler ModifiedChanged;
+ public event EventHandler MultilineChanged;
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event PaintEventHandler Paint;
+ public event EventHandler ReadOnlyChanged;
+
+ internal event EventHandler HScrolled;
+ internal event EventHandler VScrolled;
+ #endregion // Events
+
+ #region Private Methods
+ internal Document Document {
+ get {
+ return document;
+ }
+
+ set {
+ document = value;
+ }
+ }
+
+ internal Graphics CreateGraphicsInternal() {
+ if (IsHandleCreated) {
+ return base.CreateGraphics();
+ }
+
+ return Graphics.FromImage(bmp);
+ }
+
+ #if Debug
+ static int current;
+ #endif
+
+ private void PaintControl(PaintEventArgs pevent) {
+ // Fill background
+ pevent.Graphics.FillRectangle(ThemeEngine.Current.ResPool.GetSolidBrush(BackColor), pevent.ClipRectangle);
+ pevent.Graphics.TextRenderingHint=TextRenderingHint.AntiAlias;
+
+ // Draw the viewable document
+ document.Draw(pevent.Graphics, pevent.ClipRectangle);
+
+ Rectangle rect = ClientRectangle;
+ rect.Width--;
+ rect.Height--;
+ //pevent.Graphics.DrawRectangle(ThemeEngine.Current.ResPool.GetPen(ThemeEngine.Current.ColorControlDark), rect);
+
+ #if Debug
+ int start;
+ int end;
+ Line line;
+ int line_no;
+ Pen p;
+
+ p = new Pen(Color.Red, 1);
+
+ // First, figure out from what line to what line we need to draw
+ start = document.GetLineByPixel(pevent.ClipRectangle.Top - document.ViewPortY, false).line_no;
+ end = document.GetLineByPixel(pevent.ClipRectangle.Bottom - document.ViewPortY, false).line_no;
+
+ //Console.WriteLine("Starting drawing on line '{0}'", document.GetLine(start));
+ //Console.WriteLine("Ending drawing on line '{0}'", document.GetLine(end));
+
+ line_no = start;
+ while (line_no <= end) {
+ line = document.GetLine(line_no);
+
+ if (draw_lines) {
+ for (int i = 0; i < line.text.Length; i++) {
+ pevent.Graphics.DrawLine(p, (int)line.widths[i] - document.ViewPortX, line.Y - document.ViewPortY, (int)line.widths[i] - document.ViewPortX, line.Y + line.height - document.ViewPortY);
+ }
+ }
+
+ line_no++;
+ }
+ #endif
+ }
+
+ private void TextBoxBase_MouseDown(object sender, MouseEventArgs e) {
+ if (e.Button == MouseButtons.Left) {
+ TimeSpan interval;
+
+ interval = DateTime.Now - click_last;
+ document.PositionCaret(e.X + document.ViewPortX, e.Y + document.ViewPortY);
+
+ // Handle place caret/select word/select line behaviour
+ if (e.Clicks == 1) {
+ if (SystemInformation.DoubleClickTime < interval.TotalMilliseconds) {
+ #if DebugClick
+ Console.WriteLine("Single Click Invalidating from char {0} to char {1} ({2})", document.selection_start.pos, document.selection_end.pos, document.selection_start.line.text.ToString(document.selection_start.pos, document.selection_end.pos - document.selection_start.pos));
+ #endif
+ document.SetSelectionToCaret(true);
+ click_mode = CaretSelection.Position;
+ } else {
+ #if DebugClick
+ Console.WriteLine("Tripple Click Selecting line");
+ #endif
+ document.ExpandSelection(CaretSelection.Line, false);
+ click_mode = CaretSelection.Line;
+ }
+ } else {
+ // We select the line if the word is already selected, and vice versa
+ if (click_mode != CaretSelection.Word) {
+ if (click_mode == CaretSelection.Line) {
+ document.Invalidate(document.selection_start.line, 0, document.selection_start.line, document.selection_start.line.text.Length);
+ }
+ click_mode = CaretSelection.Word;
+ document.ExpandSelection(CaretSelection.Word, false); // Setting initial selection
+ } else {
+ click_mode = CaretSelection.Line;
+ document.ExpandSelection(CaretSelection.Line, false); // Setting initial selection
+ }
+ }
+
+ // Reset
+ click_last = DateTime.Now;
+ return;
+ }
+
+ #if Debug
+ LineTag tag;
+ Line line;
+ int pos;
+
+ if (e.Button == MouseButtons.Right) {
+ draw_lines = !draw_lines;
+ this.Invalidate();
+ Console.WriteLine("SelectedText: {0}, length {1}", this.SelectedText, this.SelectionLength);
+ Console.WriteLine("Selection start: {0}", this.SelectionStart);
+
+ this.SelectionStart = 10;
+ this.SelectionLength = 5;
+
+ return;
+ }
+
+ tag = document.FindTag(e.X + document.ViewPortX, e.Y + document.ViewPortY, out pos, false);
+
+ Console.WriteLine("Click found tag {0}, character {1}", tag, pos);
+ line = tag.line;
+ switch(current) {
+ case 4: LineTag.FormatText(tag.line, pos, (pos+10)<line.Text.Length ? 10 : line.Text.Length - pos+1, new Font("impact", 20, FontStyle.Bold, GraphicsUnit.Pixel), ThemeEngine.Current.ResPool.GetSolidBrush(Color.Red)); break;
+ case 1: LineTag.FormatText(tag.line, pos, (pos+10)<line.Text.Length ? 10 : line.Text.Length - pos+1, new Font("arial unicode ms", 24, FontStyle.Italic, GraphicsUnit.Pixel), ThemeEngine.Current.ResPool.GetSolidBrush(Color.DarkGoldenrod)); break;
+ case 2: LineTag.FormatText(tag.line, pos, (pos+10)<line.Text.Length ? 10 : line.Text.Length - pos+1, new Font("arial", 10, FontStyle.Regular, GraphicsUnit.Pixel), ThemeEngine.Current.ResPool.GetSolidBrush(Color.Aquamarine)); break;
+ case 3: LineTag.FormatText(tag.line, pos, (pos+10)<line.Text.Length ? 10 : line.Text.Length - pos+1, new Font("times roman", 16, FontStyle.Underline, GraphicsUnit.Pixel), ThemeEngine.Current.ResPool.GetSolidBrush(Color.Turquoise)); break;
+ case 0: LineTag.FormatText(tag.line, pos, (pos+10)<line.Text.Length ? 10 : line.Text.Length - pos+1, new Font("times roman", 64, FontStyle.Italic | FontStyle.Bold, GraphicsUnit.Pixel), ThemeEngine.Current.ResPool.GetSolidBrush(Color.LightSeaGreen)); break;
+ case 5: LineTag.FormatText(tag.line, pos, (pos+10)<line.Text.Length ? 10 : line.Text.Length - pos+1, ((TextBoxBase)sender).Font, ThemeEngine.Current.ResPool.GetSolidBrush(ForeColor)); break;
+ }
+ current++;
+ if (current==6) {
+ current=0;
+ }
+
+ // Update/Recalculate what we see
+ document.UpdateView(line, 0);
+
+ // Make sure our caret is properly positioned and sized
+ document.AlignCaret();
+ #endif
+ }
+
+ private void TextBoxBase_MouseUp(object sender, MouseEventArgs e) {
+ if (e.Button == MouseButtons.Left) {
+ document.PositionCaret(e.X + document.ViewPortX, e.Y + document.ViewPortY);
+ if (click_mode == CaretSelection.Position) {
+ document.SetSelectionToCaret(false);
+ document.DisplayCaret();
+ } else {
+ document.ExpandSelection(click_mode, true);
+ }
+ return;
+ }
+ }
+
+ private void TextBoxBase_SizeChanged(object sender, EventArgs e) {
+ canvas_width = ClientSize.Width;
+ canvas_height = ClientSize.Height;
+ document.ViewPortWidth = canvas_width;
+ document.ViewPortHeight = canvas_height;
+
+ // We always move them, they just might not be displayed
+ hscroll.Bounds = new Rectangle (ClientRectangle.Left, ClientRectangle.Bottom - hscroll.Height, ClientSize.Width - (vscroll.Visible ? SystemInformation.VerticalScrollBarWidth : 0), hscroll.Height);
+ vscroll.Bounds = new Rectangle (ClientRectangle.Right - vscroll.Width, ClientRectangle.Top, vscroll.Width, ClientSize.Height - (hscroll.Visible ? SystemInformation.HorizontalScrollBarHeight : 0));
+
+ }
+
+ private void TextBoxBase_MouseWheel(object sender, MouseEventArgs e) {
+ Line line;
+ int line_no;
+ int target;
+
+ if (!vscroll.Enabled) {
+ return;
+ }
+
+ if (e.Delta < 0) {
+ line_no = document.GetLineByPixel(document.ViewPortY, false).line_no + SystemInformation.MouseWheelScrollLines;
+ if (line_no > document.Lines) {
+ line_no = document.Lines;
+ }
+ } else {
+ line_no = document.GetLineByPixel(document.ViewPortY, false).line_no - SystemInformation.MouseWheelScrollLines;
+ if (line_no < 1) {
+ line_no = 1;
+ }
+ }
+
+ line = document.GetLine(line_no);
+ if (line.Y < vscroll.Maximum) {
+ vscroll.Value = line.Y;
+ } else {
+ vscroll.Value = vscroll.Maximum;
+ }
+ }
+
+ internal void CalculateDocument() {
+ if (!IsHandleCreated) {
+ return;
+ }
+ document.RecalculateDocument(CreateGraphicsInternal());
+ CalculateScrollBars();
+ Invalidate(); // FIXME - do we need this?
+ }
+
+ internal void CalculateScrollBars() {
+ // FIXME - need separate calculations for center and right alignment
+ // No scrollbars for a single line
+ if (document.Width >= ClientSize.Width) {
+ hscroll.Enabled = true;
+ hscroll.Minimum = 0;
+ hscroll.Maximum = document.Width - ClientSize.Width + track_border;
+ } else {
+ hscroll.Maximum = document.ViewPortWidth;
+ hscroll.Enabled = false;
+ }
+
+ if (document.Height >= ClientSize.Height) {
+ vscroll.Enabled = true;
+ vscroll.Minimum = 0;
+ vscroll.Maximum = document.Height - ClientSize.Height + 1;
+ } else {
+ vscroll.Maximum = document.ViewPortHeight;
+ vscroll.Enabled = false;
+ }
+
+
+ if (!multiline) {
+ return;
+ }
+
+ if (!WordWrap) {
+ if ((scrollbars & RichTextBoxScrollBars.Horizontal) != 0) {
+ if (((scrollbars & RichTextBoxScrollBars.ForcedHorizontal) != 0) || hscroll.Enabled) {
+ hscroll.Visible = true;
+ }
+ }
+ }
+
+ if ((scrollbars & RichTextBoxScrollBars.Vertical) != 0) {
+ if (((scrollbars & RichTextBoxScrollBars.ForcedVertical) != 0) || vscroll.Enabled) {
+ vscroll.Visible = true;
+ }
+ }
+
+ if (hscroll.Visible) {
+ vscroll.Maximum += hscroll.Height;
+ canvas_height = ClientSize.Height - hscroll.Height;
+ }
+
+ if (vscroll.Visible) {
+ hscroll.Maximum += vscroll.Width * 2;
+ canvas_width = ClientSize.Width - vscroll.Width * 2;
+ }
+
+ TextBoxBase_SizeChanged(this, EventArgs.Empty);
+ }
+
+ private void document_WidthChanged(object sender, EventArgs e) {
+ CalculateScrollBars();
+ }
+
+ private void document_HeightChanged(object sender, EventArgs e) {
+ CalculateScrollBars();
+ }
+
+ private void hscroll_ValueChanged(object sender, EventArgs e) {
+ XplatUI.ScrollWindow(this.Handle, document.ViewPortX-this.hscroll.Value, 0, false);
+ document.ViewPortX = this.hscroll.Value;
+ document.UpdateCaret();
+
+ if (HScrolled != null) {
+ HScrolled(this, EventArgs.Empty);
+ }
+ }
+
+ private void vscroll_ValueChanged(object sender, EventArgs e) {
+ XplatUI.ScrollWindow(this.Handle, 0, document.ViewPortY-this.vscroll.Value, false);
+ document.ViewPortY = this.vscroll.Value;
+ document.UpdateCaret();
+
+ if (VScrolled != null) {
+ VScrolled(this, EventArgs.Empty);
+ }
+ }
+
+ private void TextBoxBase_MouseMove(object sender, MouseEventArgs e) {
+ // FIXME - handle auto-scrolling if mouse is to the right/left of the window
+ if (Capture) {
+ document.PositionCaret(e.X + document.ViewPortX, e.Y + document.ViewPortY);
+ if (click_mode == CaretSelection.Position) {
+ document.SetSelectionToCaret(false);
+ document.DisplayCaret();
+ } else {
+ document.ExpandSelection(click_mode, true);
+ }
+ }
+ }
+
+ private void TextBoxBase_FontOrColorChanged(object sender, EventArgs e) {
+ if (!richtext) {
+ Line line;
+
+ // Font changes apply to the whole document
+ for (int i = 1; i <= document.Lines; i++) {
+ line = document.GetLine(i);
+ LineTag.FormatText(line, 1, line.text.Length, Font, ThemeEngine.Current.ResPool.GetSolidBrush(ForeColor));
+ document.UpdateView(line, 0);
+ }
+ // Make sure the caret height is matching the new font height
+ document.AlignCaret();
+ }
+ }
+
+ /// <summary>Ensure the caret is always visible</summary>
+ internal void CaretMoved(object sender, EventArgs e) {
+ Point pos;
+ int height;
+
+ pos = document.Caret;
+ //Console.WriteLine("Caret now at {0} (Thumb: {1}x{2}, Canvas: {3}x{4}, Document {5}x{6})", pos, hscroll.Value, vscroll.Value, canvas_width, canvas_height, document.Width, document.Height);
+
+ // Handle horizontal scrolling
+ if (document.CaretLine.alignment == HorizontalAlignment.Left) {
+ if (pos.X < (document.ViewPortX + track_width)) {
+ do {
+ if ((hscroll.Value - track_width) >= hscroll.Minimum) {
+ hscroll.Value -= track_width;
+ } else {
+ hscroll.Value = hscroll.Minimum;
+ }
+ } while (hscroll.Value > pos.X);
+ }
+
+ if ((pos.X > (this.canvas_width + document.ViewPortX - track_width)) && (hscroll.Enabled && (hscroll.Value != hscroll.Maximum))) {
+ do {
+ if ((hscroll.Value + track_width) <= hscroll.Maximum) {
+ hscroll.Value += track_width;
+ } else {
+ hscroll.Value = hscroll.Maximum;
+ }
+ } while (pos.X > (hscroll.Value + this.canvas_width));
+ }
+ } else if (document.CaretLine.alignment == HorizontalAlignment.Right) {
+ if (pos.X < document.ViewPortX) {
+ if (pos.X > hscroll.Minimum) {
+ hscroll.Value = pos.X;
+ } else {
+ hscroll.Value = hscroll.Minimum;
+ }
+ }
+
+ if ((pos.X > (this.canvas_width + document.ViewPortX)) && (hscroll.Enabled && (hscroll.Value != hscroll.Maximum))) {
+ hscroll.Value = hscroll.Maximum;
+ }
+ } else {
+ }
+
+ if (!multiline) {
+ return;
+ }
+
+ // Handle vertical scrolling
+ height = document.CaretLine.Height + 1;
+
+ if (pos.Y < document.ViewPortY) {
+ vscroll.Value = pos.Y;
+ }
+
+ if ((pos.Y + height) > (document.ViewPortY + canvas_height)) {
+ vscroll.Value = pos.Y - canvas_height + height;
+ }
+ }
+
+ internal bool Paste(DataFormats.Format format, bool obey_length) {
+ IDataObject clip;
+ string s;
+
+ clip = Clipboard.GetDataObject();
+ if (clip == null)
+ return false;
+
+ if (format == null) {
+ if ((this is RichTextBox) && clip.GetDataPresent(DataFormats.Rtf)) {
+ format = DataFormats.GetFormat(DataFormats.Rtf);
+ } else if (clip.GetDataPresent(DataFormats.UnicodeText)) {
+ format = DataFormats.GetFormat(DataFormats.UnicodeText);
+ } else if (clip.GetDataPresent(DataFormats.Text)) {
+ format = DataFormats.GetFormat(DataFormats.Text);
+ } else {
+ return false;
+ }
+ } else {
+ if ((format.Name == DataFormats.Rtf) && !(this is RichTextBox)) {
+ return false;
+ }
+
+ if (!clip.GetDataPresent(format.Name)) {
+ return false;
+ }
+ }
+
+ if (format.Name == DataFormats.Rtf) {
+ ((RichTextBox)this).SelectedRtf = (string)clip.GetData(DataFormats.Rtf);
+ return true;
+ } else if (format.Name == DataFormats.UnicodeText) {
+ s = (string)clip.GetData(DataFormats.UnicodeText);
+ } else if (format.Name == DataFormats.Text) {
+ s = (string)clip.GetData(DataFormats.Text);
+ } else {
+ return false;
+ }
+
+ if (!obey_length) {
+ this.SelectedText = s;
+ } else {
+ if ((s.Length + document.Length) < max_length) {
+ this.SelectedText = s;
+ } else if (document.Length < max_length) {
+ this.SelectedText = s.Substring(0, max_length - document.Length);
+ }
+ }
+
+ return true;
+ }
+ #endregion // Private Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
new file mode 100644
index 00000000000..bd175ee269a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
@@ -0,0 +1,4727 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+// NOT COMPLETE
+
+// There's still plenty of things missing, I've got most of it planned, just hadn't had
+// the time to write it all yet.
+// Stuff missing (in no particular order):
+// - Align text after RecalculateLine
+// - Implement tag types for hotlinks, images, etc.
+// - Implement CaretPgUp/PgDown
+
+// NOTE:
+// selection_start.pos and selection_end.pos are 0-based
+// selection_start.pos = first selected char
+// selection_end.pos = first NOT-selected char
+//
+// FormatText methods are 1-based (as are all tags, LineTag.Start is 1 for
+// the first character on a line; the reason is that 0 is the position
+// *before* the first character on a line
+
+
+#undef Debug
+
+using System;
+using System.Collections;
+using System.Drawing;
+using System.Drawing.Text;
+using System.Text;
+
+namespace System.Windows.Forms {
+ internal enum LineColor {
+ Red = 0,
+ Black = 1
+ }
+
+ internal enum CaretSelection {
+ Position, // Selection=Caret
+ Word, // Selection=Word under caret
+ Line // Selection=Line under caret
+ }
+
+ internal class FontDefinition {
+ internal String face;
+ internal int size;
+ internal FontStyle add_style;
+ internal FontStyle remove_style;
+ internal Color color;
+ internal Font font_obj;
+
+ internal FontDefinition() {
+ face = null;
+ size = 0;
+ color = Color.Empty;
+ }
+ }
+
+ internal enum CaretDirection {
+ CharForward, // Move a char to the right
+ CharBack, // Move a char to the left
+ LineUp, // Move a line up
+ LineDown, // Move a line down
+ Home, // Move to the beginning of the line
+ End, // Move to the end of the line
+ PgUp, // Move one page up
+ PgDn, // Move one page down
+ CtrlHome, // Move to the beginning of the document
+ CtrlEnd, // Move to the end of the document
+ WordBack, // Move to the beginning of the previous word (or beginning of line)
+ WordForward, // Move to the beginning of the next word (or end of line)
+ SelectionStart, // Move to the beginning of the current selection
+ SelectionEnd // Move to the end of the current selection
+ }
+
+ // Being cloneable should allow for nice line and document copies...
+ internal class Line : ICloneable, IComparable {
+ #region Local Variables
+ // Stuff that matters for our line
+ internal StringBuilder text; // Characters for the line
+ internal float[] widths; // Width of each character; always one larger than text.Length
+ internal int space; // Number of elements in text and widths
+ internal int line_no; // Line number
+ internal LineTag tags; // Tags describing the text
+ internal int Y; // Baseline
+ internal int height; // Height of the line (height of tallest tag)
+ internal int ascent; // Ascent of the line (ascent of the tallest tag)
+ internal HorizontalAlignment alignment; // Alignment of the line
+ internal int align_shift; // Pixel shift caused by the alignment
+ internal bool soft_break; // Tag is 'broken soft' and continuation from previous line
+ internal int indent; // Left indent for the first line
+ internal int hanging_indent; // Hanging indent (left indent for all but the first line)
+ internal int right_indent; // Right indent for all lines
+
+
+ // Stuff that's important for the tree
+ internal Line parent; // Our parent line
+ internal Line left; // Line with smaller line number
+ internal Line right; // Line with higher line number
+ internal LineColor color; // We're doing a black/red tree. this is the node color
+ internal int DEFAULT_TEXT_LEN; //
+ internal static StringFormat string_format; // For calculating widths/heights
+ internal bool recalc; // Line changed
+ #endregion // Local Variables
+
+ #region Constructors
+ internal Line() {
+ color = LineColor.Red;
+ left = null;
+ right = null;
+ parent = null;
+ text = null;
+ recalc = true;
+ soft_break = false;
+ alignment = HorizontalAlignment.Left;
+
+ if (string_format == null) {
+ string_format = new StringFormat(StringFormat.GenericTypographic);
+ string_format.Trimming = StringTrimming.None;
+ string_format.FormatFlags = StringFormatFlags.MeasureTrailingSpaces;
+ }
+ }
+
+ internal Line(int LineNo, string Text, Font font, Brush color) : this() {
+ space = Text.Length > DEFAULT_TEXT_LEN ? Text.Length+1 : DEFAULT_TEXT_LEN;
+
+ text = new StringBuilder(Text, space);
+ line_no = LineNo;
+
+ widths = new float[space + 1];
+ tags = new LineTag(this, 1, text.Length);
+ tags.font = font;
+ tags.color = color;
+ }
+
+ internal Line(int LineNo, string Text, HorizontalAlignment align, Font font, Brush color) : this() {
+ space = Text.Length > DEFAULT_TEXT_LEN ? Text.Length+1 : DEFAULT_TEXT_LEN;
+
+ text = new StringBuilder(Text, space);
+ line_no = LineNo;
+ alignment = align;
+
+ widths = new float[space + 1];
+ tags = new LineTag(this, 1, text.Length);
+ tags.font = font;
+ tags.color = color;
+ }
+
+ internal Line(int LineNo, string Text, LineTag tag) : this() {
+ space = Text.Length > DEFAULT_TEXT_LEN ? Text.Length+1 : DEFAULT_TEXT_LEN;
+
+ text = new StringBuilder(Text, space);
+ line_no = LineNo;
+
+ widths = new float[space + 1];
+ tags = tag;
+ }
+
+ #endregion // Constructors
+
+ #region Internal Properties
+ internal int Indent {
+ get {
+ return indent;
+ }
+
+ set {
+ indent = value;
+ recalc = true;
+ }
+ }
+
+ internal int HangingIndent {
+ get {
+ return hanging_indent;
+ }
+
+ set {
+ hanging_indent = value;
+ recalc = true;
+ }
+ }
+
+ internal int RightIndent {
+ get {
+ return right_indent;
+ }
+
+ set {
+ right_indent = value;
+ recalc = true;
+ }
+ }
+
+
+ internal int Height {
+ get {
+ return height;
+ }
+
+ set {
+ height = value;
+ }
+ }
+
+ internal int LineNo {
+ get {
+ return line_no;
+ }
+
+ set {
+ line_no = value;
+ }
+ }
+
+ internal string Text {
+ get {
+ return text.ToString();
+ }
+
+ set {
+ text = new StringBuilder(value, value.Length > DEFAULT_TEXT_LEN ? value.Length : DEFAULT_TEXT_LEN);
+ }
+ }
+
+ internal HorizontalAlignment Alignment {
+ get {
+ return alignment;
+ }
+
+ set {
+ if (alignment != value) {
+ alignment = value;
+ recalc = true;
+ }
+ }
+ }
+#if no
+ internal StringBuilder Text {
+ get {
+ return text;
+ }
+
+ set {
+ text = value;
+ }
+ }
+#endif
+ #endregion // Internal Properties
+
+ #region Internal Methods
+ // Make sure we always have enoughs space in text and widths
+ internal void Grow(int minimum) {
+ int length;
+ float[] new_widths;
+
+ length = text.Length;
+
+ if ((length + minimum) > space) {
+ // We need to grow; double the size
+
+ if ((length + minimum) > (space * 2)) {
+ new_widths = new float[length + minimum * 2 + 1];
+ space = length + minimum * 2;
+ } else {
+ new_widths = new float[space * 2 + 1];
+ space *= 2;
+ }
+ widths.CopyTo(new_widths, 0);
+
+ widths = new_widths;
+ }
+ }
+
+ internal void Streamline(int lines) {
+ LineTag current;
+ LineTag next;
+
+ current = this.tags;
+ next = current.next;
+
+ // Catch what the loop below wont; eliminate 0 length
+ // tags, but only if there are other tags after us
+ while ((current.length == 0) && (next != null)) {
+ tags = next;
+ tags.previous = null;
+ current = next;
+ next = current.next;
+ }
+
+ if (next == null) {
+ return;
+ }
+
+ while (next != null) {
+ // Take out 0 length tags unless it's the last tag in the document
+ if (next.length == 0) {
+ if ((next.next != null) || (line_no != lines)) {
+ current.next = next.next;
+ if (current.next != null) {
+ current.next.previous = current;
+ }
+ next = current.next;
+ continue;
+ }
+ }
+ if (current.Combine(next)) {
+ next = current.next;
+ continue;
+ }
+
+ current = current.next;
+ next = current.next;
+ }
+ }
+
+ /// <summary> Find the tag on a line based on the character position, pos is 0-based</summary>
+ internal LineTag FindTag(int pos) {
+ LineTag tag;
+
+ if (pos == 0) {
+ return tags;
+ }
+
+ tag = this.tags;
+
+ if (pos >= text.Length) {
+ pos = text.Length - 1;
+ }
+
+ while (tag != null) {
+ if (((tag.start - 1) <= pos) && (pos < (tag.start + tag.length - 1))) {
+ return tag;
+ }
+ tag = tag.next;
+ }
+ return null;
+ }
+
+ /// <summary>
+ /// Recalculate a single line using the same char for every character in the line
+ /// </summary>
+
+ internal bool RecalculatePasswordLine(Graphics g, Document doc) {
+ LineTag tag;
+ int pos;
+ int len;
+ float w;
+ bool ret;
+ int descent;
+
+ pos = 0;
+ len = this.text.Length;
+ tag = this.tags;
+ ascent = 0;
+ tag.shift = 0;
+ tag.width = 0;
+
+ this.recalc = false;
+ widths[0] = indent;
+ tag.X = indent;
+
+ w = g.MeasureString(doc.password_char, tags.font, 10000, string_format).Width;
+
+ if (this.height != (int)tag.font.Height) {
+ ret = true;
+ } else {
+ ret = false;
+ }
+
+ this.height = (int)tag.font.Height;
+ tag.height = this.height;
+
+ XplatUI.GetFontMetrics(g, tag.font, out tag.ascent, out descent);
+ this.ascent = tag.ascent;
+
+ while (pos < len) {
+ tag.width += w;
+ pos++;
+ widths[pos] = widths[pos-1] + w;
+ }
+
+ return ret;
+ }
+
+ /// <summary>
+ /// Go through all tags on a line and recalculate all size-related values;
+ /// returns true if lineheight changed
+ /// </summary>
+ internal bool RecalculateLine(Graphics g, Document doc) {
+ LineTag tag;
+ int pos;
+ int len;
+ SizeF size;
+ float w;
+ int prev_height;
+ bool retval;
+ bool wrapped;
+ Line line;
+ int wrap_pos;
+ float wrap_width;
+
+ pos = 0;
+ len = this.text.Length;
+ tag = this.tags;
+ prev_height = this.height; // For drawing optimization calculations
+ this.height = 0; // Reset line height
+ this.ascent = 0; // Reset the ascent for the line
+ tag.shift = 0;
+ tag.width = 0;
+
+ if (this.soft_break) {
+ widths[0] = hanging_indent;
+ } else {
+ widths[0] = indent;
+ }
+
+ this.recalc = false;
+ retval = false;
+ wrapped = false;
+
+ wrap_pos = 0;
+ wrap_width = 0;
+
+ while (pos < len) {
+ size = g.MeasureString(this.text.ToString(pos, 1), tag.font, 10000, string_format);
+
+ while (tag.length == 0) { // We should always have tags after a tag.length==0 unless len==0
+ tag.width = 0;
+ tag.ascent = 0;
+ if (tag.previous != null) {
+ tag.X = tag.previous.X;
+ } else {
+ tag.X = (int)widths[pos];
+ }
+ tag = tag.next;
+ tag.width = 0;
+ tag.shift = 0;
+ }
+
+ w = size.Width;
+
+ if (Char.IsWhiteSpace(text[pos])) {
+ wrap_pos = pos + 1;
+ wrap_width = tag.width + w;
+ }
+
+ if (doc.wrap) {
+ if ((wrap_pos > 0) && (wrap_pos != len) && (widths[pos] + w) + 27 > (doc.viewport_width - this.right_indent)) {
+ pos = wrap_pos;
+ tag.width = wrap_width;
+ doc.Split(this, tag, pos, true);
+ len = this.text.Length;
+ retval = true;
+ wrapped = true;
+ }
+ }
+
+ // Contract all soft lines that follow back into our line
+ if (!wrapped) {
+ tag.width += w;
+
+ pos++;
+
+ widths[pos] = widths[pos-1] + w;
+
+ if (pos == len) {
+ line = doc.GetLine(this.line_no + 1);
+ if ((line != null) && (line.soft_break)) {
+ // Pull the previous line back into this one
+ doc.Combine(this.line_no, this.line_no + 1);
+ len = this.text.Length;
+ retval = true;
+ }
+ }
+ }
+
+ if (pos == (tag.start-1 + tag.length)) {
+ // We just found the end of our current tag
+ tag.height = (int)tag.font.Height;
+
+ // Check if we're the tallest on the line (so far)
+ if (tag.height > this.height) {
+ this.height = tag.height; // Yep; make sure the line knows
+ }
+
+ if (tag.ascent == 0) {
+ int descent;
+
+ XplatUI.GetFontMetrics(g, tag.font, out tag.ascent, out descent);
+ }
+
+ if (tag.ascent > this.ascent) {
+ LineTag t;
+
+ // We have a tag that has a taller ascent than the line;
+
+ t = tags;
+ while (t != tag) {
+ t.shift = tag.ascent - t.ascent;
+ t = t.next;
+ }
+
+ // Save on our line
+ this.ascent = tag.ascent;
+ } else {
+ tag.shift = this.ascent - tag.ascent;
+ }
+
+ // Update our horizontal starting pixel position
+ if (tag.previous == null) {
+ tag.X = (int)widths[0];
+ } else {
+ tag.X = tag.previous.X + (int)tag.previous.width;
+ }
+
+ tag = tag.next;
+ if (tag != null) {
+ tag.width = 0;
+ tag.shift = 0;
+ wrap_pos = pos;
+ wrap_width = tag.width;
+ }
+ }
+ }
+
+ if (this.height == 0) {
+ this.height = tags.font.Height;
+ tag.height = this.height;
+ }
+
+ if (prev_height != this.height) {
+ retval = true;
+ }
+ return retval;
+ }
+ #endregion // Internal Methods
+
+ #region Administrative
+ public int CompareTo(object obj) {
+ if (obj == null) {
+ return 1;
+ }
+
+ if (! (obj is Line)) {
+ throw new ArgumentException("Object is not of type Line", "obj");
+ }
+
+ if (line_no < ((Line)obj).line_no) {
+ return -1;
+ } else if (line_no > ((Line)obj).line_no) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
+ public object Clone() {
+ Line clone;
+
+ clone = new Line();
+
+ clone.text = text;
+
+ if (left != null) {
+ clone.left = (Line)left.Clone();
+ }
+
+ if (left != null) {
+ clone.left = (Line)left.Clone();
+ }
+
+ return clone;
+ }
+
+ internal object CloneLine() {
+ Line clone;
+
+ clone = new Line();
+
+ clone.text = text;
+
+ return clone;
+ }
+
+ public override bool Equals(object obj) {
+ if (obj == null) {
+ return false;
+ }
+
+ if (!(obj is Line)) {
+ return false;
+ }
+
+ if (obj == this) {
+ return true;
+ }
+
+ if (line_no == ((Line)obj).line_no) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public override int GetHashCode() {
+ return base.GetHashCode ();
+ }
+
+ public override string ToString() {
+ return "Line " + line_no;
+ }
+
+ #endregion // Administrative
+ }
+
+ internal class Document : ICloneable, IEnumerable {
+ #region Structures
+ // FIXME - go through code and check for places where
+ // we do explicit comparisons instead of using the compare overloads
+ internal struct Marker {
+ internal Line line;
+ internal LineTag tag;
+ internal int pos;
+ internal int height;
+
+ public static bool operator<(Marker lhs, Marker rhs) {
+ if (lhs.line.line_no < rhs.line.line_no) {
+ return true;
+ }
+
+ if (lhs.line.line_no == rhs.line.line_no) {
+ if (lhs.pos < rhs.pos) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static bool operator>(Marker lhs, Marker rhs) {
+ if (lhs.line.line_no > rhs.line.line_no) {
+ return true;
+ }
+
+ if (lhs.line.line_no == rhs.line.line_no) {
+ if (lhs.pos > rhs.pos) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static bool operator==(Marker lhs, Marker rhs) {
+ if ((lhs.line.line_no == rhs.line.line_no) && (lhs.pos == rhs.pos)) {
+ return true;
+ }
+ return false;
+ }
+
+ public static bool operator!=(Marker lhs, Marker rhs) {
+ if ((lhs.line.line_no != rhs.line.line_no) || (lhs.pos != rhs.pos)) {
+ return true;
+ }
+ return false;
+ }
+
+ public void Combine(Line move_to_line, int move_to_line_length) {
+ line = move_to_line;
+ pos += move_to_line_length;
+ tag = LineTag.FindTag(line, pos);
+ }
+
+ // This is for future use, right now Document.Split does it by hand, with some added shortcut logic
+ public void Split(Line move_to_line, int split_at) {
+ line = move_to_line;
+ pos -= split_at;
+ tag = LineTag.FindTag(line, pos);
+ }
+
+ public override bool Equals(object obj) {
+ return this==(Marker)obj;
+ }
+
+ public override int GetHashCode() {
+ return base.GetHashCode ();
+ }
+
+ public override string ToString() {
+ return "Marker Line " + line + ", Position " + pos;
+ }
+
+ }
+ #endregion Structures
+
+ #region Local Variables
+ private Line document;
+ private int lines;
+ private Line sentinel;
+ private Line last_found;
+ private int document_id;
+ private Random random = new Random();
+ internal string password_char;
+ private StringBuilder password_cache;
+ private bool calc_pass;
+ private int char_count;
+
+ private bool no_recalc;
+ private bool recalc_pending;
+ private int recalc_start;
+ private int recalc_end;
+ private bool recalc_optimize;
+
+ internal bool multiline;
+ internal bool wrap;
+
+ internal UndoClass undo;
+
+ internal Marker caret;
+ internal Marker selection_start;
+ internal Marker selection_end;
+ internal bool selection_visible;
+ internal Marker selection_anchor;
+ internal Marker selection_prev;
+ internal bool selection_end_anchor;
+
+ internal int viewport_x;
+ internal int viewport_y; // The visible area of the document
+ internal int viewport_width;
+ internal int viewport_height;
+
+ internal int document_x; // Width of the document
+ internal int document_y; // Height of the document
+
+ internal Rectangle invalid;
+
+ internal int crlf_size; // 1 or 2, depending on whether we use \r\n or just \n
+
+ internal TextBoxBase owner; // Who's owning us?
+ static internal int caret_width = 1;
+ static internal int caret_shift = 1;
+ #endregion // Local Variables
+
+ #region Constructors
+ internal Document(TextBoxBase owner) {
+ lines = 0;
+
+ this.owner = owner;
+
+ multiline = true;
+ password_char = "";
+ calc_pass = false;
+ no_recalc = false;
+ recalc_pending = false;
+
+ // Tree related stuff
+ sentinel = new Line();
+ sentinel.color = LineColor.Black;
+
+ document = sentinel;
+ last_found = sentinel;
+
+ // We always have a blank line
+ owner.HandleCreated += new EventHandler(owner_HandleCreated);
+ owner.VisibleChanged += new EventHandler(owner_VisibleChanged);
+ Add(1, "", owner.Font, ThemeEngine.Current.ResPool.GetSolidBrush(owner.ForeColor));
+ lines=1;
+
+ undo = new UndoClass(this);
+
+ selection_visible = false;
+ selection_start.line = this.document;
+ selection_start.pos = 0;
+ selection_start.tag = selection_start.line.tags;
+ selection_end.line = this.document;
+ selection_end.pos = 0;
+ selection_end.tag = selection_end.line.tags;
+ selection_anchor.line = this.document;
+ selection_anchor.pos = 0;
+ selection_anchor.tag = selection_anchor.line.tags;
+
+ viewport_x = 0;
+ viewport_y = 0;
+
+ crlf_size = 2;
+
+ // Default selection is empty
+
+ document_id = random.Next();
+ }
+ #endregion
+
+ #region Internal Properties
+ internal Line Root {
+ get {
+ return document;
+ }
+
+ set {
+ document = value;
+ }
+ }
+
+ internal int Lines {
+ get {
+ return lines;
+ }
+ }
+
+ internal Line CaretLine {
+ get {
+ return caret.line;
+ }
+ }
+
+ internal int CaretPosition {
+ get {
+ return caret.pos;
+ }
+ }
+
+ internal Point Caret {
+ get {
+ return new Point((int)caret.tag.line.widths[caret.pos] + caret.line.align_shift, caret.line.Y);
+ }
+ }
+
+ internal LineTag CaretTag {
+ get {
+ return caret.tag;
+ }
+
+ set {
+ caret.tag = value;
+ }
+ }
+
+ internal int CRLFSize {
+ get {
+ return crlf_size;
+ }
+
+ set {
+ crlf_size = value;
+ }
+ }
+
+ internal string PasswordChar {
+ get {
+ return password_char;
+ }
+
+ set {
+ password_char = value;
+ if ((password_char.Length != 0) && (password_char[0] != '\0')) {
+ char ch;
+
+ calc_pass = true;
+ ch = value[0];
+ password_cache = new StringBuilder(1024);
+ for (int i = 0; i < 1024; i++) {
+ password_cache.Append(ch);
+ }
+ } else {
+ calc_pass = false;
+ password_cache = null;
+ }
+ }
+ }
+
+ internal int ViewPortX {
+ get {
+ return viewport_x;
+ }
+
+ set {
+ viewport_x = value;
+ }
+ }
+
+ internal int Length {
+ get {
+ return char_count + lines - 1; // Add \n for each line but the last
+ }
+ }
+
+ private int CharCount {
+ get {
+ return char_count;
+ }
+
+ set {
+ char_count = value;
+
+ if (LengthChanged != null) {
+ LengthChanged(this, EventArgs.Empty);
+ }
+ }
+ }
+
+ ///<summary>Setting NoRecalc to true will prevent the document from being recalculated.
+ ///This ensures that coordinates of added text are predictable after adding the text even with wrapped view</summary>
+ internal bool NoRecalc {
+ get {
+ return no_recalc;
+ }
+
+ set {
+ no_recalc = value;
+ if (!no_recalc && recalc_pending) {
+ RecalculateDocument(owner.CreateGraphicsInternal(), recalc_start, recalc_end, recalc_optimize);
+ recalc_pending = false;
+ }
+ }
+ }
+
+ internal int ViewPortY {
+ get {
+ return viewport_y;
+ }
+
+ set {
+ viewport_y = value;
+ }
+ }
+
+ internal int ViewPortWidth {
+ get {
+ return viewport_width;
+ }
+
+ set {
+ viewport_width = value - 2;
+ }
+ }
+
+ internal int ViewPortHeight {
+ get {
+ return viewport_height;
+ }
+
+ set {
+ viewport_height = value;
+ }
+ }
+
+
+ internal int Width {
+ get {
+ return this.document_x;
+ }
+ }
+
+ internal int Height {
+ get {
+ return this.document_y;
+ }
+ }
+
+ internal bool SelectionVisible {
+ get {
+ return selection_visible;
+ }
+ }
+
+ internal bool Wrap {
+ get {
+ return wrap;
+ }
+
+ set {
+ wrap = value;
+ }
+ }
+
+ #endregion // Internal Properties
+
+ #region Private Methods
+ // For debugging
+ internal int DumpTree(Line line, bool with_tags) {
+ int total;
+
+ total = 1;
+
+ Console.Write("Line {0}, Y: {1} Text {2}", line.line_no, line.Y, line.text != null ? line.text.ToString() : "undefined");
+
+ if (line.left == sentinel) {
+ Console.Write(", left = sentinel");
+ } else if (line.left == null) {
+ Console.Write(", left = NULL");
+ }
+
+ if (line.right == sentinel) {
+ Console.Write(", right = sentinel");
+ } else if (line.right == null) {
+ Console.Write(", right = NULL");
+ }
+
+ Console.WriteLine("");
+
+ if (with_tags) {
+ LineTag tag;
+ int count;
+ int length;
+
+ tag = line.tags;
+ count = 1;
+ length = 0;
+ Console.Write(" Tags: ");
+ while (tag != null) {
+ Console.Write("{0} <{1}>-<{2}> ", count++, tag.start, tag.length);
+ length += tag.length;
+
+ if (tag.line != line) {
+ Console.Write("BAD line link");
+ throw new Exception("Bad line link in tree");
+ }
+ tag = tag.next;
+ if (tag != null) {
+ Console.Write(", ");
+ }
+ }
+ if (length > line.text.Length) {
+ throw new Exception(String.Format("Length of tags more than length of text on line (expected {0} calculated {1})", line.text.Length, length));
+ } else if (length < line.text.Length) {
+ throw new Exception(String.Format("Length of tags less than length of text on line (expected {0} calculated {1})", line.text.Length, length));
+ }
+ Console.WriteLine("");
+ }
+ if (line.left != null) {
+ if (line.left != sentinel) {
+ total += DumpTree(line.left, with_tags);
+ }
+ } else {
+ if (line != sentinel) {
+ throw new Exception("Left should not be NULL");
+ }
+ }
+
+ if (line.right != null) {
+ if (line.right != sentinel) {
+ total += DumpTree(line.right, with_tags);
+ }
+ } else {
+ if (line != sentinel) {
+ throw new Exception("Right should not be NULL");
+ }
+ }
+
+ for (int i = 1; i <= this.lines; i++) {
+ if (GetLine(i) == null) {
+ throw new Exception(String.Format("Hole in line order, missing {0}", i));
+ }
+ }
+
+ if (line == this.Root) {
+ if (total < this.lines) {
+ throw new Exception(String.Format("Not enough nodes in tree, found {0}, expected {1}", total, this.lines));
+ } else if (total > this.lines) {
+ throw new Exception(String.Format("Too many nodes in tree, found {0}, expected {1}", total, this.lines));
+ }
+ }
+
+ return total;
+ }
+
+ private void DecrementLines(int line_no) {
+ int current;
+
+ current = line_no;
+ while (current <= lines) {
+ GetLine(current).line_no--;
+ current++;
+ }
+ return;
+ }
+
+ private void IncrementLines(int line_no) {
+ int current;
+
+ current = this.lines;
+ while (current >= line_no) {
+ GetLine(current).line_no++;
+ current--;
+ }
+ return;
+ }
+
+ private void RebalanceAfterAdd(Line line1) {
+ Line line2;
+
+ while ((line1 != document) && (line1.parent.color == LineColor.Red)) {
+ if (line1.parent == line1.parent.parent.left) {
+ line2 = line1.parent.parent.right;
+
+ if ((line2 != null) && (line2.color == LineColor.Red)) {
+ line1.parent.color = LineColor.Black;
+ line2.color = LineColor.Black;
+ line1.parent.parent.color = LineColor.Red;
+ line1 = line1.parent.parent;
+ } else {
+ if (line1 == line1.parent.right) {
+ line1 = line1.parent;
+ RotateLeft(line1);
+ }
+
+ line1.parent.color = LineColor.Black;
+ line1.parent.parent.color = LineColor.Red;
+
+ RotateRight(line1.parent.parent);
+ }
+ } else {
+ line2 = line1.parent.parent.left;
+
+ if ((line2 != null) && (line2.color == LineColor.Red)) {
+ line1.parent.color = LineColor.Black;
+ line2.color = LineColor.Black;
+ line1.parent.parent.color = LineColor.Red;
+ line1 = line1.parent.parent;
+ } else {
+ if (line1 == line1.parent.left) {
+ line1 = line1.parent;
+ RotateRight(line1);
+ }
+
+ line1.parent.color = LineColor.Black;
+ line1.parent.parent.color = LineColor.Red;
+ RotateLeft(line1.parent.parent);
+ }
+ }
+ }
+ document.color = LineColor.Black;
+ }
+
+ private void RebalanceAfterDelete(Line line1) {
+ Line line2;
+
+ while ((line1 != document) && (line1.color == LineColor.Black)) {
+ if (line1 == line1.parent.left) {
+ line2 = line1.parent.right;
+ if (line2.color == LineColor.Red) {
+ line2.color = LineColor.Black;
+ line1.parent.color = LineColor.Red;
+ RotateLeft(line1.parent);
+ line2 = line1.parent.right;
+ }
+ if ((line2.left.color == LineColor.Black) && (line2.right.color == LineColor.Black)) {
+ line2.color = LineColor.Red;
+ line1 = line1.parent;
+ } else {
+ if (line2.right.color == LineColor.Black) {
+ line2.left.color = LineColor.Black;
+ line2.color = LineColor.Red;
+ RotateRight(line2);
+ line2 = line1.parent.right;
+ }
+ line2.color = line1.parent.color;
+ line1.parent.color = LineColor.Black;
+ line2.right.color = LineColor.Black;
+ RotateLeft(line1.parent);
+ line1 = document;
+ }
+ } else {
+ line2 = line1.parent.left;
+ if (line2.color == LineColor.Red) {
+ line2.color = LineColor.Black;
+ line1.parent.color = LineColor.Red;
+ RotateRight(line1.parent);
+ line2 = line1.parent.left;
+ }
+ if ((line2.right.color == LineColor.Black) && (line2.left.color == LineColor.Black)) {
+ line2.color = LineColor.Red;
+ line1 = line1.parent;
+ } else {
+ if (line2.left.color == LineColor.Black) {
+ line2.right.color = LineColor.Black;
+ line2.color = LineColor.Red;
+ RotateLeft(line2);
+ line2 = line1.parent.left;
+ }
+ line2.color = line1.parent.color;
+ line1.parent.color = LineColor.Black;
+ line2.left.color = LineColor.Black;
+ RotateRight(line1.parent);
+ line1 = document;
+ }
+ }
+ }
+ line1.color = LineColor.Black;
+ }
+
+ private void RotateLeft(Line line1) {
+ Line line2 = line1.right;
+
+ line1.right = line2.left;
+
+ if (line2.left != sentinel) {
+ line2.left.parent = line1;
+ }
+
+ if (line2 != sentinel) {
+ line2.parent = line1.parent;
+ }
+
+ if (line1.parent != null) {
+ if (line1 == line1.parent.left) {
+ line1.parent.left = line2;
+ } else {
+ line1.parent.right = line2;
+ }
+ } else {
+ document = line2;
+ }
+
+ line2.left = line1;
+ if (line1 != sentinel) {
+ line1.parent = line2;
+ }
+ }
+
+ private void RotateRight(Line line1) {
+ Line line2 = line1.left;
+
+ line1.left = line2.right;
+
+ if (line2.right != sentinel) {
+ line2.right.parent = line1;
+ }
+
+ if (line2 != sentinel) {
+ line2.parent = line1.parent;
+ }
+
+ if (line1.parent != null) {
+ if (line1 == line1.parent.right) {
+ line1.parent.right = line2;
+ } else {
+ line1.parent.left = line2;
+ }
+ } else {
+ document = line2;
+ }
+
+ line2.right = line1;
+ if (line1 != sentinel) {
+ line1.parent = line2;
+ }
+ }
+
+
+ internal void UpdateView(Line line, int pos) {
+ if (!owner.IsHandleCreated) {
+ return;
+ }
+
+ if (no_recalc) {
+ recalc_start = line.line_no;
+ recalc_end = line.line_no;
+ recalc_optimize = true;
+ recalc_pending = true;
+ return;
+ }
+
+ // Optimize invalidation based on Line alignment
+ if (RecalculateDocument(owner.CreateGraphicsInternal(), line.line_no, line.line_no, true)) {
+ // Lineheight changed, invalidate the rest of the document
+ if ((line.Y - viewport_y) >=0 ) {
+ // We formatted something that's in view, only draw parts of the screen
+ owner.Invalidate(new Rectangle(0, line.Y - viewport_y, viewport_width, owner.Height - line.Y - viewport_y));
+ } else {
+ // The tag was above the visible area, draw everything
+ owner.Invalidate();
+ }
+ } else {
+ switch(line.alignment) {
+ case HorizontalAlignment.Left: {
+ owner.Invalidate(new Rectangle((int)line.widths[pos] - viewport_x - 1, line.Y - viewport_y, viewport_width, line.height + 1));
+ break;
+ }
+
+ case HorizontalAlignment.Center: {
+ owner.Invalidate(new Rectangle(0, line.Y - viewport_y, viewport_width, line.height + 1));
+ break;
+ }
+
+ case HorizontalAlignment.Right: {
+ owner.Invalidate(new Rectangle(0, line.Y - viewport_y, (int)line.widths[pos + 1] - viewport_x + line.align_shift, line.height + 1));
+ break;
+ }
+ }
+ }
+ }
+
+
+ // Update display from line, down line_count lines; pos is unused, but required for the signature
+ internal void UpdateView(Line line, int line_count, int pos) {
+ if (!owner.IsHandleCreated) {
+ return;
+ }
+
+ if (no_recalc) {
+ recalc_start = line.line_no;
+ recalc_end = line.line_no + line_count - 1;
+ recalc_optimize = true;
+ recalc_pending = true;
+ return;
+ }
+
+ if (RecalculateDocument(owner.CreateGraphicsInternal(), line.line_no, line.line_no + line_count - 1, true)) {
+ // Lineheight changed, invalidate the rest of the document
+ if ((line.Y - viewport_y) >=0 ) {
+ // We formatted something that's in view, only draw parts of the screen
+//blah Console.WriteLine("TextControl.cs(981) Invalidate called in UpdateView(line, line_count, pos)");
+ owner.Invalidate(new Rectangle(0, line.Y - viewport_y, viewport_width, owner.Height - line.Y - viewport_y));
+ } else {
+ // The tag was above the visible area, draw everything
+//blah Console.WriteLine("TextControl.cs(985) Invalidate called in UpdateView(line, line_count, pos)");
+ owner.Invalidate();
+ }
+ } else {
+ Line end_line;
+
+ end_line = GetLine(line.line_no + line_count -1);
+ if (end_line == null) {
+ end_line = line;
+ }
+
+//blah Console.WriteLine("TextControl.cs(996) Invalidate called in UpdateView(line, line_count, pos)");
+ owner.Invalidate(new Rectangle(0 - viewport_x, line.Y - viewport_y, (int)line.widths[line.text.Length], end_line.Y + end_line.height));
+ }
+ }
+ #endregion // Private Methods
+
+ #region Internal Methods
+ // Clear the document and reset state
+ internal void Empty() {
+
+ document = sentinel;
+ last_found = sentinel;
+ lines = 0;
+
+ // We always have a blank line
+ Add(1, "", owner.Font, ThemeEngine.Current.ResPool.GetSolidBrush(owner.ForeColor));
+ this.RecalculateDocument(owner.CreateGraphicsInternal());
+ PositionCaret(0, 0);
+
+ selection_visible = false;
+ selection_start.line = this.document;
+ selection_start.pos = 0;
+ selection_start.tag = selection_start.line.tags;
+ selection_end.line = this.document;
+ selection_end.pos = 0;
+ selection_end.tag = selection_end.line.tags;
+ char_count = 0;
+
+ viewport_x = 0;
+ viewport_y = 0;
+
+ document_x = 0;
+ document_y = 0;
+ }
+
+ internal void PositionCaret(Line line, int pos) {
+ if (!owner.IsHandleCreated) {
+ return;
+ }
+
+ undo.RecordCursor();
+
+ caret.tag = line.FindTag(pos);
+ caret.line = line;
+ caret.pos = pos;
+ caret.height = caret.tag.height;
+
+ if (owner.Focused) {
+ XplatUI.SetCaretPos(owner.Handle, (int)caret.tag.line.widths[caret.pos] + caret.line.align_shift - viewport_x, caret.line.Y + caret.tag.shift - viewport_y + caret_shift);
+ }
+
+ if (CaretMoved != null) CaretMoved(this, EventArgs.Empty);
+ }
+
+ internal void PositionCaret(int x, int y) {
+ if (!owner.IsHandleCreated) {
+ return;
+ }
+
+ undo.RecordCursor();
+
+ caret.tag = FindCursor(x, y, out caret.pos);
+ caret.line = caret.tag.line;
+ caret.height = caret.tag.height;
+
+ if (owner.Focused) {
+ XplatUI.SetCaretPos(owner.Handle, (int)caret.tag.line.widths[caret.pos] + caret.line.align_shift - viewport_x, caret.line.Y + caret.tag.shift - viewport_y + caret_shift);
+ }
+
+ if (CaretMoved != null) CaretMoved(this, EventArgs.Empty);
+ }
+
+ internal void CaretHasFocus() {
+ if ((caret.tag != null) && owner.IsHandleCreated) {
+ XplatUI.CreateCaret(owner.Handle, caret_width, caret.height);
+ XplatUI.SetCaretPos(owner.Handle, (int)caret.tag.line.widths[caret.pos] + caret.line.align_shift - viewport_x, caret.line.Y + caret.tag.shift - viewport_y + caret_shift);
+
+ if (!selection_visible) {
+ XplatUI.CaretVisible(owner.Handle, true);
+ } else {
+ XplatUI.CaretVisible(owner.Handle, false);
+ }
+ }
+ }
+
+ internal void CaretLostFocus() {
+ if (!owner.IsHandleCreated) {
+ return;
+ }
+ XplatUI.DestroyCaret(owner.Handle);
+ }
+
+ internal void AlignCaret() {
+ if (!owner.IsHandleCreated) {
+ return;
+ }
+
+ undo.RecordCursor();
+
+ caret.tag = LineTag.FindTag(caret.line, caret.pos);
+ caret.height = caret.tag.height;
+
+ if (owner.Focused) {
+ XplatUI.CreateCaret(owner.Handle, caret_width, caret.height);
+ XplatUI.SetCaretPos(owner.Handle, (int)caret.tag.line.widths[caret.pos] + caret.line.align_shift - viewport_x, caret.line.Y + caret.tag.shift - viewport_y + caret_shift);
+ XplatUI.CaretVisible(owner.Handle, true);
+ }
+
+ if (CaretMoved != null) CaretMoved(this, EventArgs.Empty);
+ }
+
+ internal void UpdateCaret() {
+ if (!owner.IsHandleCreated) {
+ return;
+ }
+
+ undo.RecordCursor();
+
+ if (caret.tag.height != caret.height) {
+ caret.height = caret.tag.height;
+ if (owner.Focused) {
+ XplatUI.CreateCaret(owner.Handle, caret_width, caret.height);
+ }
+ }
+
+ if (owner.Focused) {
+ XplatUI.SetCaretPos(owner.Handle, (int)caret.tag.line.widths[caret.pos] + caret.line.align_shift - viewport_x, caret.line.Y + caret.tag.shift - viewport_y + caret_shift);
+ XplatUI.CaretVisible(owner.Handle, true);
+ }
+
+ if (CaretMoved != null) CaretMoved(this, EventArgs.Empty);
+ }
+
+ internal void DisplayCaret() {
+ if (!owner.IsHandleCreated) {
+ return;
+ }
+
+ if (owner.Focused) {
+ XplatUI.CaretVisible(owner.Handle, true);
+ }
+ }
+
+ internal void HideCaret() {
+ if (!owner.IsHandleCreated) {
+ return;
+ }
+
+ if (owner.Focused) {
+ XplatUI.CaretVisible(owner.Handle, false);
+ }
+ }
+
+ internal void MoveCaret(CaretDirection direction) {
+ // FIXME should we use IsWordSeparator to detect whitespace, instead
+ // of looking for actual spaces in the Word move cases?
+ switch(direction) {
+ case CaretDirection.CharForward: {
+ caret.pos++;
+ if (caret.pos > caret.line.text.Length) {
+ if (multiline) {
+ // Go into next line
+ if (caret.line.line_no < this.lines) {
+ caret.line = GetLine(caret.line.line_no+1);
+ caret.pos = 0;
+ caret.tag = caret.line.tags;
+ } else {
+ caret.pos--;
+ }
+ } else {
+ // Single line; we stay where we are
+ caret.pos--;
+ }
+ } else {
+ if ((caret.tag.start - 1 + caret.tag.length) < caret.pos) {
+ caret.tag = caret.tag.next;
+ }
+ }
+ UpdateCaret();
+ return;
+ }
+
+ case CaretDirection.CharBack: {
+ if (caret.pos > 0) {
+ // caret.pos--; // folded into the if below
+ if (--caret.pos > 0) {
+ if (caret.tag.start > caret.pos) {
+ caret.tag = caret.tag.previous;
+ }
+ }
+ } else {
+ if (caret.line.line_no > 1) {
+ caret.line = GetLine(caret.line.line_no - 1);
+ caret.pos = caret.line.text.Length;
+ caret.tag = LineTag.FindTag(caret.line, caret.pos);
+ }
+ }
+ UpdateCaret();
+ return;
+ }
+
+ case CaretDirection.WordForward: {
+ int len;
+
+ len = caret.line.text.Length;
+ if (caret.pos < len) {
+ while ((caret.pos < len) && (caret.line.text[caret.pos] != ' ')) {
+ caret.pos++;
+ }
+ if (caret.pos < len) {
+ // Skip any whitespace
+ while ((caret.pos < len) && (caret.line.text[caret.pos] == ' ')) {
+ caret.pos++;
+ }
+ }
+ caret.tag = LineTag.FindTag(caret.line, caret.pos);
+ } else {
+ if (caret.line.line_no < this.lines) {
+ caret.line = GetLine(caret.line.line_no + 1);
+ caret.pos = 0;
+ caret.tag = caret.line.tags;
+ }
+ }
+ UpdateCaret();
+ return;
+ }
+
+ case CaretDirection.WordBack: {
+ if (caret.pos > 0) {
+ caret.pos--;
+
+ while ((caret.pos > 0) && (caret.line.text[caret.pos] == ' ')) {
+ caret.pos--;
+ }
+
+ while ((caret.pos > 0) && (caret.line.text[caret.pos] != ' ')) {
+ caret.pos--;
+ }
+
+ if (caret.line.text.ToString(caret.pos, 1) == " ") {
+ if (caret.pos != 0) {
+ caret.pos++;
+ } else {
+ caret.line = GetLine(caret.line.line_no - 1);
+ caret.pos = caret.line.text.Length;
+ }
+ }
+ caret.tag = LineTag.FindTag(caret.line, caret.pos);
+ } else {
+ if (caret.line.line_no > 1) {
+ caret.line = GetLine(caret.line.line_no - 1);
+ caret.pos = caret.line.text.Length;
+ caret.tag = LineTag.FindTag(caret.line, caret.pos);
+ }
+ }
+ UpdateCaret();
+ return;
+ }
+
+ case CaretDirection.LineUp: {
+ if (caret.line.line_no > 1) {
+ int pixel;
+
+ pixel = (int)caret.line.widths[caret.pos];
+ PositionCaret(pixel, GetLine(caret.line.line_no - 1).Y);
+ if (!owner.IsHandleCreated) {
+ return;
+ }
+ XplatUI.CaretVisible(owner.Handle, true);
+ }
+ return;
+ }
+
+ case CaretDirection.LineDown: {
+ if (caret.line.line_no < lines) {
+ int pixel;
+
+ pixel = (int)caret.line.widths[caret.pos];
+ PositionCaret(pixel, GetLine(caret.line.line_no + 1).Y);
+ if (!owner.IsHandleCreated) {
+ return;
+ }
+ XplatUI.CaretVisible(owner.Handle, true);
+ }
+ return;
+ }
+
+ case CaretDirection.Home: {
+ if (caret.pos > 0) {
+ caret.pos = 0;
+ caret.tag = caret.line.tags;
+ UpdateCaret();
+ }
+ return;
+ }
+
+ case CaretDirection.End: {
+ if (caret.pos < caret.line.text.Length) {
+ caret.pos = caret.line.text.Length;
+ caret.tag = LineTag.FindTag(caret.line, caret.pos);
+ UpdateCaret();
+ }
+ return;
+ }
+
+ case CaretDirection.PgUp: {
+ return;
+ }
+
+ case CaretDirection.PgDn: {
+ return;
+ }
+
+ case CaretDirection.CtrlHome: {
+ caret.line = GetLine(1);
+ caret.pos = 0;
+ caret.tag = caret.line.tags;
+
+ UpdateCaret();
+ return;
+ }
+
+ case CaretDirection.CtrlEnd: {
+ caret.line = GetLine(lines);
+ caret.pos = caret.line.text.Length;
+ caret.tag = LineTag.FindTag(caret.line, caret.pos);
+
+ UpdateCaret();
+ return;
+ }
+
+ case CaretDirection.SelectionStart: {
+ caret.line = selection_start.line;
+ caret.pos = selection_start.pos;
+ caret.tag = selection_start.tag;
+
+ UpdateCaret();
+ return;
+ }
+
+ case CaretDirection.SelectionEnd: {
+ caret.line = selection_end.line;
+ caret.pos = selection_end.pos;
+ caret.tag = selection_end.tag;
+
+ UpdateCaret();
+ return;
+ }
+ }
+ }
+
+ // Draw the document
+ internal void Draw(Graphics g, Rectangle clip) {
+ Line line; // Current line being drawn
+ LineTag tag; // Current tag being drawn
+ int start; // First line to draw
+ int end; // Last line to draw
+ StringBuilder text; // String representing the current line
+ int line_no; //
+ Brush disabled;
+ Brush hilight;
+ Brush hilight_text;
+
+ // First, figure out from what line to what line we need to draw
+ start = GetLineByPixel(clip.Top + viewport_y, false).line_no;
+ end = GetLineByPixel(clip.Bottom + viewport_y, false).line_no;
+//Console.WriteLine("Starting drawing at line {0}, ending at line {1} (clip-bottom:{2})", start, end, clip.Bottom);
+
+ // Now draw our elements; try to only draw those that are visible
+ line_no = start;
+
+ #if Debug
+ DateTime n = DateTime.Now;
+ Console.WriteLine("Started drawing: {0}s {1}ms", n.Second, n.Millisecond);
+ #endif
+
+ disabled = ThemeEngine.Current.ResPool.GetSolidBrush(ThemeEngine.Current.ColorGrayText);
+ hilight = ThemeEngine.Current.ResPool.GetSolidBrush(ThemeEngine.Current.ColorHighlight);
+ hilight_text = ThemeEngine.Current.ResPool.GetSolidBrush(ThemeEngine.Current.ColorHighlightText);
+
+ while (line_no <= end) {
+ line = GetLine(line_no);
+ tag = line.tags;
+ if (!calc_pass) {
+ text = line.text;
+ } else {
+ // This fails if there's a password > 1024 chars...
+ text = this.password_cache;
+ }
+ while (tag != null) {
+ if (tag.length == 0) {
+ tag = tag.next;
+ continue;
+ }
+
+ if (((tag.X + tag.width) > (clip.Left - viewport_x)) || (tag.X < (clip.Right - viewport_x))) {
+ // Check for selection
+ if ((!selection_visible) || (!owner.has_focus) || (line_no < selection_start.line.line_no) || (line_no > selection_end.line.line_no)) {
+ // regular drawing, no selection to deal with
+ //g.DrawString(s.Substring(tag.start-1, tag.length), tag.font, tag.color, tag.X + line.align_shift - viewport_x, line.Y + tag.shift - viewport_y, StringFormat.GenericTypographic);
+ if (owner.is_enabled) {
+ g.DrawString(text.ToString(tag.start-1, tag.length), tag.font, tag.color, tag.X + line.align_shift - viewport_x, line.Y + tag.shift - viewport_y, StringFormat.GenericTypographic);
+ } else {
+ Color a;
+ Color b;
+
+ a = ((SolidBrush)tag.color).Color;
+ b = ThemeEngine.Current.ColorWindowText;
+
+ if ((a.R == b.R) && (a.G == b.G) && (a.B == b.B)) {
+ g.DrawString(text.ToString(tag.start-1, tag.length), tag.font, disabled, tag.X + line.align_shift - viewport_x, line.Y + tag.shift - viewport_y, StringFormat.GenericTypographic);
+ } else {
+ g.DrawString(text.ToString(tag.start-1, tag.length), tag.font, tag.color, tag.X + line.align_shift - viewport_x, line.Y + tag.shift - viewport_y, StringFormat.GenericTypographic);
+ }
+ }
+ } else {
+ // we might have to draw our selection
+ if ((line_no != selection_start.line.line_no) && (line_no != selection_end.line.line_no)) {
+ // Special case, whole line is selected, draw this tag selected
+ g.FillRectangle(
+ hilight, // Brush
+ tag.X + line.align_shift - viewport_x, // X
+ line.Y + tag.shift - viewport_y, // Y
+ line.widths[tag.start + tag.length - 1], // width
+ tag.height // Height
+ );
+
+ g.DrawString(
+ //s.Substring(tag.start-1, tag.length), // String
+ text.ToString(tag.start-1, tag.length), // String
+ tag.font, // Font
+ hilight_text, // Brush
+ tag.X + line.align_shift - viewport_x, // X
+ line.Y + tag.shift - viewport_y, // Y
+ StringFormat.GenericTypographic);
+ } else {
+ bool highlight;
+ bool partial;
+
+ highlight = false;
+ partial = false;
+
+ // One or more, but not all tags on the line are selected
+ if ((selection_start.tag == tag) && (selection_end.tag == tag)) {
+ // Single tag selected, draw "normalSELECTEDnormal"
+ partial = true;
+ // First, the regular part
+ g.DrawString(
+ //s.Substring(tag.start - 1, selection_start.pos - tag.start + 1), // String
+ text.ToString(tag.start - 1, selection_start.pos - tag.start + 1), // String
+ tag.font, // Font
+ tag.color, // Brush
+ tag.X + line.align_shift - viewport_x, // X
+ line.Y + tag.shift - viewport_y, // Y
+ StringFormat.GenericTypographic);
+
+ // Now the highlight
+ g.FillRectangle(
+ hilight, // Brush
+ line.widths[selection_start.pos] + line.align_shift, // X
+ line.Y + tag.shift - viewport_y, // Y
+ line.widths[selection_end.pos] - line.widths[selection_start.pos], // Width
+ tag.height); // Height
+
+ g.DrawString(
+ //s.Substring(selection_start.pos, selection_end.pos - selection_start.pos), // String
+ text.ToString(selection_start.pos, selection_end.pos - selection_start.pos), // String
+ tag.font, // Font
+ hilight_text, // Brush
+ line.widths[selection_start.pos] + line.align_shift - viewport_x, // X
+ line.Y + tag.shift - viewport_y, // Y
+ StringFormat.GenericTypographic);
+
+ // And back to the regular
+ g.DrawString(
+ //s.Substring(selection_end.pos, tag.start + tag.length - selection_end.pos - 1), // String
+ text.ToString(selection_end.pos, tag.start + tag.length - selection_end.pos - 1), // String
+ tag.font, // Font
+ tag.color, // Brush
+ line.widths[selection_end.pos] + line.align_shift - viewport_x, // X
+ line.Y + tag.shift - viewport_y, // Y
+ StringFormat.GenericTypographic);
+
+ } else if (selection_start.tag == tag) {
+ partial = true;
+
+ // The highlighted part
+ g.FillRectangle(
+ hilight,
+ line.widths[selection_start.pos] + line.align_shift,
+ line.Y + tag.shift - viewport_y,
+ line.widths[tag.start + tag.length - 1] - line.widths[selection_start.pos],
+ tag.height);
+
+ g.DrawString(
+ //s.Substring(selection_start.pos, tag.start + tag.length - selection_start.pos - 1), // String
+ text.ToString(selection_start.pos, tag.start + tag.length - selection_start.pos - 1), // String
+ tag.font, // Font
+ hilight_text, // Brush
+ line.widths[selection_start.pos] + line.align_shift - viewport_x, // X
+ line.Y + tag.shift - viewport_y, // Y
+ StringFormat.GenericTypographic);
+
+ // The regular part
+ g.DrawString(
+ //s.Substring(tag.start - 1, selection_start.pos - tag.start + 1), // String
+ text.ToString(tag.start - 1, selection_start.pos - tag.start + 1), // String
+ tag.font, // Font
+ tag.color, // Brush
+ tag.X + line.align_shift - viewport_x, // X
+ line.Y + tag.shift - viewport_y, // Y
+ StringFormat.GenericTypographic);
+ } else if (selection_end.tag == tag) {
+ partial = true;
+
+ // The highlighted part
+ g.FillRectangle(
+ hilight,
+ tag.X + line.align_shift - viewport_x,
+ line.Y + tag.shift - viewport_y,
+ line.widths[selection_end.pos] - line.widths[tag.start - 1],
+ tag.height);
+
+ g.DrawString(
+ //s.Substring(tag.start - 1, selection_end.pos - tag.start + 1), // String
+ text.ToString(tag.start - 1, selection_end.pos - tag.start + 1), // String
+ tag.font, // Font
+ hilight_text, // Brush
+ tag.X + line.align_shift - viewport_x, // X
+ line.Y + tag.shift - viewport_y, // Y
+ StringFormat.GenericTypographic);
+
+ // The regular part
+ g.DrawString(
+ //s.Substring(selection_end.pos, tag.start + tag.length - selection_end.pos - 1), // String
+ text.ToString(selection_end.pos, tag.start + tag.length - selection_end.pos - 1), // String
+ tag.font, // Font
+ tag.color, // Brush
+ line.widths[selection_end.pos] + line.align_shift - viewport_x, // X
+ line.Y + tag.shift - viewport_y, // Y
+ StringFormat.GenericTypographic);
+ } else {
+ // no partially selected tags here, simple checks...
+ if (selection_start.line == line) {
+ int begin;
+ int stop;
+
+ begin = tag.start - 1;
+ stop = tag.start + tag.length - 1;
+ if (selection_end.line == line) {
+ if ((begin >= selection_start.pos) && (stop < selection_end.pos)) {
+ highlight = true;
+ }
+ } else {
+ if (stop > selection_start.pos) {
+ highlight = true;
+ }
+ }
+ } else if (selection_end.line == line) {
+ if ((tag.start - 1) < selection_end.pos) {
+ highlight = true;
+ }
+ }
+ }
+
+ if (!partial) {
+ if (highlight) {
+ g.FillRectangle(
+ hilight,
+ tag.X + line.align_shift - viewport_x,
+ line.Y + tag.shift - viewport_y,
+ line.widths[tag.start + tag.length - 1] - line.widths[tag.start - 1],
+ tag.height);
+
+ g.DrawString(
+ //s.Substring(tag.start-1, tag.length), // String
+ text.ToString(tag.start-1, tag.length), // String
+ tag.font, // Font
+ hilight_text, // Brush
+ tag.X + line.align_shift - viewport_x, // X
+ line.Y + tag.shift - viewport_y, // Y
+ StringFormat.GenericTypographic);
+ } else {
+ g.DrawString(
+ //s.Substring(tag.start-1, tag.length), // String
+ text.ToString(tag.start-1, tag.length), // String
+ tag.font, // Font
+ tag.color, // Brush
+ tag.X + line.align_shift - viewport_x, // X
+ line.Y + tag.shift - viewport_y, // Y
+ StringFormat.GenericTypographic);
+ }
+ }
+ }
+
+ }
+ }
+
+ tag = tag.next;
+ }
+
+ line_no++;
+ }
+ #if Debug
+ n = DateTime.Now;
+ Console.WriteLine("Finished drawing: {0}s {1}ms", n.Second, n.Millisecond);
+ #endif
+
+ }
+
+ internal void Insert(Line line, int pos, string s) {
+ Insert(line, null, pos, false, s);
+ }
+
+ // Insert multi-line text at the given position; use formatting at insertion point for inserted text
+ internal void Insert(Line line, LineTag tag, int pos, bool update_caret, string s) {
+ int i;
+ int base_line;
+ string[] ins;
+ int insert_lines;
+
+
+ // The formatting at the insertion point is used for the inserted text
+ if (tag == null) {
+ tag = LineTag.FindTag(line, pos);
+ }
+
+ base_line = line.line_no;
+
+ ins = s.Split(new char[] {'\n'});
+
+ for (int j = 0; j < ins.Length; j++) {
+ if (ins[j].EndsWith("\r")) {
+ ins[j] = ins[j].Substring(0, ins[j].Length - 1);
+ }
+ }
+
+ insert_lines = ins.Length;
+
+ // Bump the text at insertion point a line down if we're inserting more than one line
+ if (insert_lines > 1) {
+ Split(line, pos);
+ // Remainder of start line is now in base_line + 1
+ }
+
+ // Insert the first line
+ InsertString(tag, pos, ins[0]);
+
+ if (insert_lines > 1) {
+ for (i = 1; i < insert_lines; i++) {
+ Add(base_line + i, ins[i], line.alignment, tag.font, tag.color);
+ }
+ if (!s.EndsWith("\n\n")) {
+ this.Combine(base_line + insert_lines - 1, base_line + insert_lines);
+ }
+ }
+
+ UpdateView(line, insert_lines + 1, pos);
+
+ if (update_caret && owner.IsHandleCreated) {
+ // Move caret to the end of the inserted text
+ if (insert_lines > 1) {
+ PositionCaret(GetLine(line.line_no + insert_lines - 1), ins[ins.Length - 1].Length);
+ } else {
+ PositionCaret(line, pos + ins[0].Length);
+ }
+ XplatUI.CaretVisible(owner.Handle, true);
+ }
+ }
+
+ // Inserts a character at the given position
+ internal void InsertString(Line line, int pos, string s) {
+ InsertString(line.FindTag(pos), pos, s);
+ }
+
+ // Inserts a string at the given position
+ internal void InsertString(LineTag tag, int pos, string s) {
+ Line line;
+ int len;
+
+ len = s.Length;
+
+ CharCount += len;
+
+ line = tag.line;
+ line.text.Insert(pos, s);
+ tag.length += len;
+
+ tag = tag.next;
+ while (tag != null) {
+ tag.start += len;
+ tag = tag.next;
+ }
+ line.Grow(len);
+ line.recalc = true;
+
+ UpdateView(line, pos);
+ }
+
+ // Inserts a string at the caret position
+ internal void InsertStringAtCaret(string s, bool move_caret) {
+ LineTag tag;
+ int len;
+
+ len = s.Length;
+
+ CharCount += len;
+
+ caret.line.text.Insert(caret.pos, s);
+ caret.tag.length += len;
+
+ if (caret.tag.next != null) {
+ tag = caret.tag.next;
+ while (tag != null) {
+ tag.start += len;
+ tag = tag.next;
+ }
+ }
+ caret.line.Grow(len);
+ caret.line.recalc = true;
+
+ UpdateView(caret.line, caret.pos);
+ if (move_caret) {
+ caret.pos += len;
+ UpdateCaret();
+ }
+ }
+
+
+
+ // Inserts a character at the given position
+ internal void InsertChar(Line line, int pos, char ch) {
+ InsertChar(line.FindTag(pos), pos, ch);
+ }
+
+ // Inserts a character at the given position
+ internal void InsertChar(LineTag tag, int pos, char ch) {
+ Line line;
+
+ CharCount++;
+
+ line = tag.line;
+ line.text.Insert(pos, ch);
+ tag.length++;
+
+ tag = tag.next;
+ while (tag != null) {
+ tag.start++;
+ tag = tag.next;
+ }
+ line.Grow(1);
+ line.recalc = true;
+
+ UpdateView(line, pos);
+ }
+
+ // Inserts a character at the current caret position
+ internal void InsertCharAtCaret(char ch, bool move_caret) {
+ LineTag tag;
+
+ CharCount++;
+
+ caret.line.text.Insert(caret.pos, ch);
+ caret.tag.length++;
+
+ if (caret.tag.next != null) {
+ tag = caret.tag.next;
+ while (tag != null) {
+ tag.start++;
+ tag = tag.next;
+ }
+ }
+ caret.line.Grow(1);
+ caret.line.recalc = true;
+
+ UpdateView(caret.line, caret.pos);
+ if (move_caret) {
+ caret.pos++;
+ UpdateCaret();
+ SetSelectionToCaret(true);
+ }
+ }
+
+ // Deletes n characters at the given position; it will not delete past line limits
+ // pos is 0-based
+ internal void DeleteChars(LineTag tag, int pos, int count) {
+ Line line;
+ bool streamline;
+
+ streamline = false;
+ line = tag.line;
+
+ CharCount -= count;
+
+ if (pos == line.text.Length) {
+ return;
+ }
+
+ line.text.Remove(pos, count);
+
+ // Make sure the tag points to the right spot
+ while ((tag != null) && (tag.start + tag.length - 1) <= pos) {
+ tag = tag.next;
+ }
+
+ if (tag == null) {
+ return;
+ }
+
+ // Check if we're crossing tag boundaries
+ if ((pos + count) > (tag.start + tag.length - 1)) {
+ int left;
+
+ // We have to delete cross tag boundaries
+ streamline = true;
+ left = count;
+
+ left -= tag.start + tag.length - pos - 1;
+ tag.length -= tag.start + tag.length - pos - 1;
+
+ tag = tag.next;
+ while ((tag != null) && (left > 0)) {
+ tag.start -= count - left;
+ if (tag.length > left) {
+ tag.length -= left;
+ left = 0;
+ } else {
+ left -= tag.length;
+ tag.length = 0;
+
+ tag = tag.next;
+ }
+ }
+ } else {
+ // We got off easy, same tag
+
+ tag.length -= count;
+
+ if (tag.length == 0) {
+ streamline = true;
+ }
+ }
+
+ // Adjust the start point of any tags following
+ if (tag != null) {
+ tag = tag.next;
+ while (tag != null) {
+ tag.start -= count;
+ tag = tag.next;
+ }
+ }
+
+ line.recalc = true;
+ if (streamline) {
+ line.Streamline(lines);
+ }
+
+ UpdateView(line, pos);
+ }
+
+ // Deletes a character at or after the given position (depending on forward); it will not delete past line limits
+ internal void DeleteChar(LineTag tag, int pos, bool forward) {
+ Line line;
+ bool streamline;
+
+ CharCount--;
+
+ streamline = false;
+ line = tag.line;
+
+ if ((pos == 0 && forward == false) || (pos == line.text.Length && forward == true)) {
+ return;
+ }
+
+
+ if (forward) {
+ line.text.Remove(pos, 1);
+
+ while ((tag != null) && (tag.start + tag.length - 1) <= pos) {
+ tag = tag.next;
+ }
+
+ if (tag == null) {
+ return;
+ }
+
+ tag.length--;
+
+ if (tag.length == 0) {
+ streamline = true;
+ }
+ } else {
+ pos--;
+ line.text.Remove(pos, 1);
+ if (pos >= (tag.start - 1)) {
+ tag.length--;
+ if (tag.length == 0) {
+ streamline = true;
+ }
+ } else if (tag.previous != null) {
+ tag.previous.length--;
+ if (tag.previous.length == 0) {
+ streamline = true;
+ }
+ }
+ }
+
+ tag = tag.next;
+ while (tag != null) {
+ tag.start--;
+ tag = tag.next;
+ }
+ line.recalc = true;
+ if (streamline) {
+ line.Streamline(lines);
+ }
+
+ UpdateView(line, pos);
+ }
+
+ // Combine two lines
+ internal void Combine(int FirstLine, int SecondLine) {
+ Combine(GetLine(FirstLine), GetLine(SecondLine));
+ }
+
+ internal void Combine(Line first, Line second) {
+ LineTag last;
+ int shift;
+
+ // Combine the two tag chains into one
+ last = first.tags;
+
+ while (last.next != null) {
+ last = last.next;
+ }
+
+ last.next = second.tags;
+ last.next.previous = last;
+
+ shift = last.start + last.length - 1;
+
+ // Fix up references within the chain
+ last = last.next;
+ while (last != null) {
+ last.line = first;
+ last.start += shift;
+ last = last.next;
+ }
+
+ // Combine both lines' strings
+ first.text.Insert(first.text.Length, second.text.ToString());
+ first.Grow(first.text.Length);
+
+ // Remove the reference to our (now combined) tags from the doomed line
+ second.tags = null;
+
+ // Renumber lines
+ DecrementLines(first.line_no + 2); // first.line_no + 1 will be deleted, so we need to start renumbering one later
+
+ // Mop up
+ first.recalc = true;
+ first.height = 0; // This forces RecalcDocument/UpdateView to redraw from this line on
+ first.Streamline(lines);
+
+ // Update Caret, Selection, etc
+ if (caret.line == second) {
+ caret.Combine(first, shift);
+ }
+ if (selection_anchor.line == second) {
+ selection_anchor.Combine(first, shift);
+ }
+ if (selection_start.line == second) {
+ selection_start.Combine(first, shift);
+ }
+ if (selection_end.line == second) {
+ selection_end.Combine(first, shift);
+ }
+
+ #if Debug
+ Line check_first;
+ Line check_second;
+
+ check_first = GetLine(first.line_no);
+ check_second = GetLine(check_first.line_no + 1);
+
+ Console.WriteLine("Pre-delete: Y of first line: {0}, second line: {1}", check_first.Y, check_second.Y);
+ #endif
+
+ this.Delete(second);
+
+ #if Debug
+ check_first = GetLine(first.line_no);
+ check_second = GetLine(check_first.line_no + 1);
+
+ Console.WriteLine("Post-delete Y of first line: {0}, second line: {1}", check_first.Y, check_second.Y);
+ #endif
+
+ }
+
+ // Split the line at the position into two
+ internal void Split(int LineNo, int pos) {
+ Line line;
+ LineTag tag;
+
+ line = GetLine(LineNo);
+ tag = LineTag.FindTag(line, pos);
+ Split(line, tag, pos, false);
+ }
+
+ internal void Split(Line line, int pos) {
+ LineTag tag;
+
+ tag = LineTag.FindTag(line, pos);
+ Split(line, tag, pos, false);
+ }
+
+ ///<summary>Split line at given tag and position into two lines</summary>
+ ///<param name="soft">True if the split should be marked as 'soft', indicating that it can be contracted
+ ///if more space becomes available on previous line</param>
+ internal void Split(Line line, LineTag tag, int pos, bool soft) {
+ LineTag new_tag;
+ Line new_line;
+ bool move_caret;
+ bool move_sel_start;
+ bool move_sel_end;
+
+ move_caret = false;
+ move_sel_start = false;
+ move_sel_end = false;
+
+ // Adjust selection and cursors
+ if (soft && (caret.line == line) && (caret.pos > pos)) {
+ move_caret = true;
+ }
+ if (selection_start.line == line && selection_start.pos > pos) {
+ move_sel_start = true;
+ }
+
+ if (selection_end.line == line && selection_end.pos > pos) {
+ move_sel_end = true;
+ }
+
+ // cover the easy case first
+ if (pos == line.text.Length) {
+ Add(line.line_no + 1, "", line.alignment, tag.font, tag.color);
+
+ new_line = GetLine(line.line_no + 1);
+
+ if (soft) {
+ if (move_caret) {
+ caret.line = new_line;
+ caret.line.soft_break = true;
+ caret.tag = new_line.tags;
+ caret.pos = 0;
+ } else {
+ new_line.soft_break = true;
+ }
+ }
+
+ if (move_sel_start) {
+ selection_start.line = new_line;
+ selection_start.pos = 0;
+ selection_start.tag = new_line.tags;
+ }
+
+ if (move_sel_end) {
+ selection_end.line = new_line;
+ selection_end.pos = 0;
+ selection_end.tag = new_line.tags;
+ }
+ return;
+ }
+
+ // We need to move the rest of the text into the new line
+ Add(line.line_no + 1, line.text.ToString(pos, line.text.Length - pos), line.alignment, tag.font, tag.color);
+
+ // Now transfer our tags from this line to the next
+ new_line = GetLine(line.line_no + 1);
+ line.recalc = true;
+ new_line.recalc = true;
+
+ if ((tag.start - 1) == pos) {
+ int shift;
+
+ // We can simply break the chain and move the tag into the next line
+ if (tag == line.tags) {
+ new_tag = new LineTag(line, 1, 0);
+ new_tag.font = tag.font;
+ new_tag.color = tag.color;
+ line.tags = new_tag;
+ }
+
+ if (tag.previous != null) {
+ tag.previous.next = null;
+ }
+ new_line.tags = tag;
+ tag.previous = null;
+ tag.line = new_line;
+
+ // Walk the list and correct the start location of the tags we just bumped into the next line
+ shift = tag.start - 1;
+
+ new_tag = tag;
+ while (new_tag != null) {
+ new_tag.start -= shift;
+ new_tag.line = new_line;
+ new_tag = new_tag.next;
+ }
+ } else {
+ int shift;
+
+ new_tag = new LineTag(new_line, 1, tag.start - 1 + tag.length - pos);
+ new_tag.next = tag.next;
+ new_tag.font = tag.font;
+ new_tag.color = tag.color;
+ new_line.tags = new_tag;
+ if (new_tag.next != null) {
+ new_tag.next.previous = new_tag;
+ }
+ tag.next = null;
+ tag.length = pos - tag.start + 1;
+
+ shift = pos;
+ new_tag = new_tag.next;
+ while (new_tag != null) {
+ new_tag.start -= shift;
+ new_tag.line = new_line;
+ new_tag = new_tag.next;
+
+ }
+ }
+
+ if (soft) {
+ if (move_caret) {
+ caret.line = new_line;
+ caret.pos = caret.pos - pos;
+ caret.tag = caret.line.FindTag(caret.pos);
+ }
+ new_line.soft_break = true;
+ }
+
+ if (move_sel_start) {
+ selection_start.line = new_line;
+ selection_start.pos = selection_start.pos - pos;
+ selection_start.tag = new_line.FindTag(selection_start.pos);
+ }
+
+ if (move_sel_end) {
+ selection_end.line = new_line;
+ selection_end.pos = selection_end.pos - pos;
+ selection_end.tag = new_line.FindTag(selection_end.pos);
+ }
+
+ CharCount -= line.text.Length - pos;
+ line.text.Remove(pos, line.text.Length - pos);
+ }
+
+ // Adds a line of text, with given font.
+ // Bumps any line at that line number that already exists down
+ internal void Add(int LineNo, string Text, Font font, Brush color) {
+ Add(LineNo, Text, HorizontalAlignment.Left, font, color);
+ }
+
+ internal void Add(int LineNo, string Text, HorizontalAlignment align, Font font, Brush color) {
+ Line add;
+ Line line;
+ int line_no;
+
+ CharCount += Text.Length;
+
+ if (LineNo<1 || Text == null) {
+ if (LineNo<1) {
+ throw new ArgumentNullException("LineNo", "Line numbers must be positive");
+ } else {
+ throw new ArgumentNullException("Text", "Cannot insert NULL line");
+ }
+ }
+
+ add = new Line(LineNo, Text, align, font, color);
+
+ line = document;
+ while (line != sentinel) {
+ add.parent = line;
+ line_no = line.line_no;
+
+ if (LineNo > line_no) {
+ line = line.right;
+ } else if (LineNo < line_no) {
+ line = line.left;
+ } else {
+ // Bump existing line numbers; walk all nodes to the right of this one and increment line_no
+ IncrementLines(line.line_no);
+ line = line.left;
+ }
+ }
+
+ add.left = sentinel;
+ add.right = sentinel;
+
+ if (add.parent != null) {
+ if (LineNo > add.parent.line_no) {
+ add.parent.right = add;
+ } else {
+ add.parent.left = add;
+ }
+ } else {
+ // Root node
+ document = add;
+ }
+
+ RebalanceAfterAdd(add);
+
+ lines++;
+ }
+
+ internal virtual void Clear() {
+ lines = 0;
+ CharCount = 0;
+ document = sentinel;
+ }
+
+ public virtual object Clone() {
+ Document clone;
+
+ clone = new Document(null);
+
+ clone.lines = this.lines;
+ clone.document = (Line)document.Clone();
+
+ return clone;
+ }
+
+ internal void Delete(int LineNo) {
+ Line line;
+
+ if (LineNo>lines) {
+ return;
+ }
+
+ line = GetLine(LineNo);
+
+ CharCount -= line.text.Length;
+
+ DecrementLines(LineNo + 1);
+ Delete(line);
+ }
+
+ internal void Delete(Line line1) {
+ Line line2;// = new Line();
+ Line line3;
+
+ if ((line1.left == sentinel) || (line1.right == sentinel)) {
+ line3 = line1;
+ } else {
+ line3 = line1.right;
+ while (line3.left != sentinel) {
+ line3 = line3.left;
+ }
+ }
+
+ if (line3.left != sentinel) {
+ line2 = line3.left;
+ } else {
+ line2 = line3.right;
+ }
+
+ line2.parent = line3.parent;
+ if (line3.parent != null) {
+ if(line3 == line3.parent.left) {
+ line3.parent.left = line2;
+ } else {
+ line3.parent.right = line2;
+ }
+ } else {
+ document = line2;
+ }
+
+ if (line3 != line1) {
+ LineTag tag;
+
+ line1.ascent = line3.ascent;
+ line1.height = line3.height;
+ line1.line_no = line3.line_no;
+ line1.recalc = line3.recalc;
+ line1.space = line3.space;
+ line1.tags = line3.tags;
+ line1.text = line3.text;
+ line1.widths = line3.widths;
+ line1.Y = line3.Y;
+ line1.soft_break = line3.soft_break;
+
+ tag = line1.tags;
+ while (tag != null) {
+ tag.line = line1;
+ tag = tag.next;
+ }
+ }
+
+ if (line3.color == LineColor.Black)
+ RebalanceAfterDelete(line2);
+
+ this.lines--;
+
+ last_found = sentinel;
+ }
+
+ // Invalidate a section of the document to trigger redraw
+ internal void Invalidate(Line start, int start_pos, Line end, int end_pos) {
+ Line l1;
+ Line l2;
+ int p1;
+ int p2;
+
+ if ((start == end) && (start_pos == end_pos)) {
+ return;
+ }
+
+ if (end_pos == -1) {
+ end_pos = end.text.Length;
+ }
+
+ // figure out what's before what so the logic below is straightforward
+ if (start.line_no < end.line_no) {
+ l1 = start;
+ p1 = start_pos;
+
+ l2 = end;
+ p2 = end_pos;
+ } else if (start.line_no > end.line_no) {
+ l1 = end;
+ p1 = end_pos;
+
+ l2 = start;
+ p2 = start_pos;
+ } else {
+ if (start_pos < end_pos) {
+ l1 = start;
+ p1 = start_pos;
+
+ l2 = end;
+ p2 = end_pos;
+ } else {
+ l1 = end;
+ p1 = end_pos;
+
+ l2 = start;
+ p2 = start_pos;
+ }
+
+ #if Debug
+ Console.WriteLine("Invaliding from {0}:{1} to {2}:{3}", l1.line_no, p1, l2.line_no, p2);
+ #endif
+
+ owner.Invalidate(
+ new Rectangle(
+ (int)l1.widths[p1] + l1.align_shift - viewport_x,
+ l1.Y - viewport_y,
+ (int)l2.widths[p2] - (int)l1.widths[p1] + 1,
+ l1.height
+ )
+ );
+ return;
+ }
+
+ #if Debug
+ Console.WriteLine("Invaliding from {0}:{1} to {2}:{3} Start => x={4}, y={5}, {6}x{7}", l1.line_no, p1, l2.line_no, p2, (int)l1.widths[p1] + l1.align_shift - viewport_x, l1.Y - viewport_y, viewport_width, l1.height);
+ #endif
+
+ // Three invalidates:
+ // First line from start
+ owner.Invalidate(new Rectangle((int)l1.widths[p1] + l1.align_shift - viewport_x, l1.Y - viewport_y, viewport_width, l1.height));
+
+ // lines inbetween
+ if ((l1.line_no + 1) < l2.line_no) {
+ int y;
+
+ y = GetLine(l1.line_no + 1).Y;
+ owner.Invalidate(new Rectangle(0, y - viewport_y, viewport_width, GetLine(l2.line_no).Y - y - viewport_y));
+
+ #if Debug
+ Console.WriteLine("Invaliding from {0}:{1} to {2}:{3} Middle => x={4}, y={5}, {6}x{7}", l1.line_no, p1, l2.line_no, p2, 0, y - viewport_y, viewport_width, GetLine(l2.line_no).Y - y - viewport_y);
+ #endif
+ }
+
+ // Last line to end
+ owner.Invalidate(new Rectangle((int)l2.widths[0] + l2.align_shift - viewport_x, l2.Y - viewport_y, (int)l2.widths[p2] + 1, l2.height));
+ #if Debug
+ Console.WriteLine("Invaliding from {0}:{1} to {2}:{3} End => x={4}, y={5}, {6}x{7}", l1.line_no, p1, l2.line_no, p2, (int)l2.widths[0] + l2.align_shift - viewport_x, l2.Y - viewport_y, (int)l2.widths[p2] + 1, l2.height);
+ #endif
+ }
+
+ /// <summary>Select text around caret</summary>
+ internal void ExpandSelection(CaretSelection mode, bool to_caret) {
+ if (to_caret) {
+ // We're expanding the selection to the caret position
+ switch(mode) {
+ case CaretSelection.Line: {
+ // Invalidate the selection delta
+ if (caret > selection_prev) {
+ Invalidate(selection_prev.line, 0, caret.line, caret.line.text.Length);
+ } else {
+ Invalidate(selection_prev.line, selection_prev.line.text.Length, caret.line, 0);
+ }
+
+ if (caret.line.line_no <= selection_anchor.line.line_no) {
+ selection_start.line = caret.line;
+ selection_start.tag = caret.line.tags;
+ selection_start.pos = 0;
+
+ selection_end.line = selection_anchor.line;
+ selection_end.tag = selection_anchor.tag;
+ selection_end.pos = selection_anchor.pos;
+
+ selection_end_anchor = true;
+ } else {
+ selection_start.line = selection_anchor.line;
+ selection_start.pos = selection_anchor.height;
+ selection_start.tag = selection_anchor.line.FindTag(selection_anchor.height);
+
+ selection_end.line = caret.line;
+ selection_end.tag = caret.line.tags;
+ selection_end.pos = caret.line.text.Length;
+
+ selection_end_anchor = false;
+ }
+ selection_prev.line = caret.line;
+ selection_prev.tag = caret.tag;
+ selection_prev.pos = caret.pos;
+
+ break;
+ }
+
+ case CaretSelection.Word: {
+ int start_pos;
+ int end_pos;
+
+ start_pos = FindWordSeparator(caret.line, caret.pos, false);
+ end_pos = FindWordSeparator(caret.line, caret.pos, true);
+
+
+ // Invalidate the selection delta
+ if (caret > selection_prev) {
+ Invalidate(selection_prev.line, selection_prev.pos, caret.line, end_pos);
+ } else {
+ Invalidate(selection_prev.line, selection_prev.pos, caret.line, start_pos);
+ }
+ if (caret < selection_anchor) {
+ selection_start.line = caret.line;
+ selection_start.tag = caret.line.FindTag(start_pos);
+ selection_start.pos = start_pos;
+
+ selection_end.line = selection_anchor.line;
+ selection_end.tag = selection_anchor.tag;
+ selection_end.pos = selection_anchor.pos;
+
+ selection_prev.line = caret.line;
+ selection_prev.tag = caret.tag;
+ selection_prev.pos = start_pos;
+
+ selection_end_anchor = true;
+ } else {
+ selection_start.line = selection_anchor.line;
+ selection_start.pos = selection_anchor.height;
+ selection_start.tag = selection_anchor.line.FindTag(selection_anchor.height);
+
+ selection_end.line = caret.line;
+ selection_end.tag = caret.line.FindTag(end_pos);
+ selection_end.pos = end_pos;
+
+ selection_prev.line = caret.line;
+ selection_prev.tag = caret.tag;
+ selection_prev.pos = end_pos;
+
+ selection_end_anchor = false;
+ }
+ break;
+ }
+
+ case CaretSelection.Position: {
+ SetSelectionToCaret(false);
+ return;
+ }
+ }
+ } else {
+ // We're setting the selection 'around' the caret position
+ switch(mode) {
+ case CaretSelection.Line: {
+ this.Invalidate(caret.line, 0, caret.line, caret.line.text.Length);
+
+ selection_start.line = caret.line;
+ selection_start.tag = caret.line.tags;
+ selection_start.pos = 0;
+
+ selection_end.line = caret.line;
+ selection_end.pos = caret.line.text.Length;
+ selection_end.tag = caret.line.FindTag(selection_end.pos);
+
+ selection_anchor.line = selection_end.line;
+ selection_anchor.tag = selection_end.tag;
+ selection_anchor.pos = selection_end.pos;
+ selection_anchor.height = 0;
+
+ selection_prev.line = caret.line;
+ selection_prev.tag = caret.tag;
+ selection_prev.pos = caret.pos;
+
+ this.selection_end_anchor = true;
+
+ break;
+ }
+
+ case CaretSelection.Word: {
+ int start_pos;
+ int end_pos;
+
+ start_pos = FindWordSeparator(caret.line, caret.pos, false);
+ end_pos = FindWordSeparator(caret.line, caret.pos, true);
+
+ this.Invalidate(selection_start.line, start_pos, caret.line, end_pos);
+
+ selection_start.line = caret.line;
+ selection_start.tag = caret.line.FindTag(start_pos);
+ selection_start.pos = start_pos;
+
+ selection_end.line = caret.line;
+ selection_end.tag = caret.line.FindTag(end_pos);
+ selection_end.pos = end_pos;
+
+ selection_anchor.line = selection_end.line;
+ selection_anchor.tag = selection_end.tag;
+ selection_anchor.pos = selection_end.pos;
+ selection_anchor.height = start_pos;
+
+ selection_prev.line = caret.line;
+ selection_prev.tag = caret.tag;
+ selection_prev.pos = caret.pos;
+
+ this.selection_end_anchor = true;
+
+ break;
+ }
+ }
+ }
+
+ if (selection_start == selection_end) {
+ selection_visible = false;
+ } else {
+ selection_visible = true;
+ }
+ }
+
+ internal void SetSelectionToCaret(bool start) {
+ if (start) {
+ // Invalidate old selection; selection is being reset to empty
+ this.Invalidate(selection_start.line, selection_start.pos, selection_end.line, selection_end.pos);
+
+ selection_start.line = caret.line;
+ selection_start.tag = caret.tag;
+ selection_start.pos = caret.pos;
+
+ // start always also selects end
+ selection_end.line = caret.line;
+ selection_end.tag = caret.tag;
+ selection_end.pos = caret.pos;
+
+ selection_anchor.line = caret.line;
+ selection_anchor.tag = caret.tag;
+ selection_anchor.pos = caret.pos;
+ } else {
+ // Invalidate from previous end to caret (aka new end)
+ if (selection_end_anchor) {
+ if (selection_start != caret) {
+ this.Invalidate(selection_start.line, selection_start.pos, caret.line, caret.pos);
+ }
+ } else {
+ if (selection_end != caret) {
+ this.Invalidate(selection_end.line, selection_end.pos, caret.line, caret.pos);
+ }
+ }
+
+ if (caret < selection_anchor) {
+ selection_start.line = caret.line;
+ selection_start.tag = caret.tag;
+ selection_start.pos = caret.pos;
+
+ selection_end.line = selection_anchor.line;
+ selection_end.tag = selection_anchor.tag;
+ selection_end.pos = selection_anchor.pos;
+
+ selection_end_anchor = true;
+ } else {
+ selection_start.line = selection_anchor.line;
+ selection_start.tag = selection_anchor.tag;
+ selection_start.pos = selection_anchor.pos;
+
+ selection_end.line = caret.line;
+ selection_end.tag = caret.tag;
+ selection_end.pos = caret.pos;
+
+ selection_end_anchor = false;
+ }
+ }
+
+ if (selection_start == selection_end) {
+ selection_visible = false;
+ } else {
+ selection_visible = true;
+ }
+ }
+
+ internal void SetSelection(Line start, int start_pos, Line end, int end_pos) {
+ if (selection_visible) {
+ Invalidate(selection_start.line, selection_start.pos, selection_end.line, selection_end.pos);
+ }
+
+ if ((end.line_no < start.line_no) || ((end == start) && (end_pos <= start_pos))) {
+ selection_start.line = end;
+ selection_start.tag = LineTag.FindTag(end, end_pos);
+ selection_start.pos = end_pos;
+
+ selection_end.line = start;
+ selection_end.tag = LineTag.FindTag(start, start_pos);
+ selection_end.pos = start_pos;
+
+ selection_end_anchor = true;
+ } else {
+ selection_start.line = start;
+ selection_start.tag = LineTag.FindTag(start, start_pos);
+ selection_start.pos = start_pos;
+
+ selection_end.line = end;
+ selection_end.tag = LineTag.FindTag(end, end_pos);
+ selection_end.pos = end_pos;
+
+ selection_end_anchor = false;
+ }
+
+ selection_anchor.line = start;
+ selection_anchor.tag = selection_start.tag;
+ selection_anchor.pos = start_pos;
+
+ if (((start == end) && (start_pos == end_pos)) || start == null || end == null) {
+ selection_visible = false;
+ } else {
+ selection_visible = true;
+
+ }
+ }
+
+ internal void SetSelectionStart(Line start, int start_pos) {
+ // Invalidate from the previous to the new start pos
+ Invalidate(selection_start.line, selection_start.pos, start, start_pos);
+
+ selection_start.line = start;
+ selection_start.pos = start_pos;
+ selection_start.tag = LineTag.FindTag(start, start_pos);
+
+ selection_anchor.line = start;
+ selection_anchor.pos = start_pos;
+ selection_anchor.tag = selection_start.tag;
+
+ selection_end_anchor = false;
+
+ if ((selection_end.line != selection_start.line) || (selection_end.pos != selection_start.pos)) {
+ selection_visible = true;
+
+ // This could be calculated better
+ Invalidate(selection_start.line, selection_start.pos, selection_end.line, selection_end.pos);
+ }
+
+ }
+
+ internal void SetSelectionEnd(Line end, int end_pos) {
+ if ((end.line_no < selection_anchor.line.line_no) || ((end == selection_anchor.line) && (end_pos <= selection_anchor.pos))) {
+ selection_start.line = end;
+ selection_start.tag = LineTag.FindTag(end, end_pos);
+ selection_start.pos = end_pos;
+
+ selection_end.line = selection_anchor.line;
+ selection_end.tag = selection_anchor.tag;
+ selection_end.pos = selection_anchor.pos;
+
+ selection_end_anchor = true;
+ } else {
+ selection_start.line = selection_anchor.line;
+ selection_start.tag = selection_anchor.tag;
+ selection_start.pos = selection_anchor.pos;
+
+ selection_end.line = end;
+ selection_end.tag = LineTag.FindTag(end, end_pos);
+ selection_end.pos = end_pos;
+
+ selection_end_anchor = false;
+ }
+
+ if ((selection_end.line != selection_start.line) || (selection_end.pos != selection_start.pos)) {
+ selection_visible = true;
+ Invalidate(selection_start.line, selection_start.pos, selection_end.line, selection_end.pos);
+ }
+ }
+
+ internal void SetSelection(Line start, int start_pos) {
+ if (selection_visible) {
+ Invalidate(selection_start.line, selection_start.pos, selection_end.line, selection_end.pos);
+ }
+
+ selection_start.line = start;
+ selection_start.pos = start_pos;
+ selection_start.tag = LineTag.FindTag(start, start_pos);
+
+ selection_end.line = start;
+ selection_end.tag = selection_start.tag;
+ selection_end.pos = start_pos;
+
+ selection_anchor.line = start;
+ selection_anchor.tag = selection_start.tag;
+ selection_anchor.pos = start_pos;
+
+ selection_end_anchor = false;
+ selection_visible = false;
+ }
+
+ internal void InvalidateSelectionArea() {
+ // FIXME - the only place that calls this right now should really calculate the redraw itself; if done this function can go
+ // Invalidate(selection_start.line, selection_start.pos, selection_end.line, selection_end.pos);
+ }
+
+ // Return the current selection, as string
+ internal string GetSelection() {
+ // We return String.Empty if there is no selection
+ if ((selection_start.pos == selection_end.pos) && (selection_start.line == selection_end.line)) {
+ return string.Empty;
+ }
+
+ if (!multiline || (selection_start.line == selection_end.line)) {
+ return selection_start.line.text.ToString(selection_start.pos, selection_end.pos - selection_start.pos);
+ } else {
+ StringBuilder sb;
+ int i;
+ int start;
+ int end;
+
+ sb = new StringBuilder();
+ start = selection_start.line.line_no;
+ end = selection_end.line.line_no;
+
+ sb.Append(selection_start.line.text.ToString(selection_start.pos, selection_start.line.text.Length - selection_start.pos) + Environment.NewLine);
+
+ if ((start + 1) < end) {
+ for (i = start + 1; i < end; i++) {
+ sb.Append(GetLine(i).text.ToString() + Environment.NewLine);
+ }
+ }
+
+ sb.Append(selection_end.line.text.ToString(0, selection_end.pos));
+
+ return sb.ToString();
+ }
+ }
+
+ internal void ReplaceSelection(string s) {
+ int i;
+ int base_line;
+ string[] ins;
+ int insert_lines;
+
+ base_line = selection_start.line.line_no;
+
+ // First, delete any selected text
+ if ((selection_start.pos != selection_end.pos) || (selection_start.line != selection_end.line)) {
+ if (!multiline || (selection_start.line == selection_end.line)) {
+ undo.RecordDeleteChars(selection_start.line, selection_start.pos + 1, selection_end.pos - selection_start.pos);
+
+ DeleteChars(selection_start.tag, selection_start.pos, selection_end.pos - selection_start.pos);
+
+ // The tag might have been removed, we need to recalc it
+ selection_start.tag = selection_start.line.FindTag(selection_start.pos);
+ } else {
+ int start;
+ int end;
+
+ start = selection_start.line.line_no;
+ end = selection_end.line.line_no;
+
+ undo.RecordDelete(selection_start.line, selection_start.pos + 1, selection_end.line, selection_end.pos);
+
+ // Delete first line
+ DeleteChars(selection_start.tag, selection_start.pos, selection_start.line.text.Length - selection_start.pos);
+
+ // Delete last line
+ DeleteChars(selection_end.line.tags, 0, selection_end.pos);
+
+ start++;
+ if (start < end) {
+ for (i = end - 1; i >= start; i--) {
+ Delete(i);
+ }
+ }
+
+ // BIG FAT WARNING - selection_end.line might be stale due
+ // to the above Delete() call. DONT USE IT before hitting the end of this method!
+
+ // Join start and end
+ Combine(selection_start.line.line_no, start);
+ }
+ }
+
+ Insert(selection_start.line, null, selection_start.pos, true, s);
+
+ selection_end.line = selection_start.line;
+ selection_end.pos = selection_start.pos;
+ selection_end.tag = selection_start.tag;
+
+ selection_visible = false;
+ }
+
+ internal void CharIndexToLineTag(int index, out Line line_out, out LineTag tag_out, out int pos) {
+ Line line;
+ LineTag tag;
+ int i;
+ int chars;
+ int start;
+
+ chars = 0;
+
+ for (i = 1; i < lines; i++) {
+ line = GetLine(i);
+
+ start = chars;
+ chars += line.text.Length + crlf_size;
+
+ if (index <= chars) {
+ // we found the line
+ tag = line.tags;
+
+ while (tag != null) {
+ if (index < (start + tag.start + tag.length)) {
+ line_out = line;
+ tag_out = tag;
+ pos = index - start;
+ return;
+ }
+ if (tag.next == null) {
+ Line next_line;
+
+ next_line = GetLine(line.line_no + 1);
+
+ if (next_line != null) {
+ line_out = next_line;
+ tag_out = next_line.tags;
+ pos = 0;
+ return;
+ } else {
+ line_out = line;
+ tag_out = tag;
+ pos = line_out.text.Length;
+ return;
+ }
+ }
+ tag = tag.next;
+ }
+ }
+ }
+
+ line_out = GetLine(lines);
+ tag = line_out.tags;
+ while (tag.next != null) {
+ tag = tag.next;
+ }
+ tag_out = tag;
+ pos = line_out.text.Length;
+ }
+
+ internal int LineTagToCharIndex(Line line, int pos) {
+ int i;
+ int length;
+
+ // Count first and last line
+ length = 0;
+
+ // Count the lines in the middle
+
+ for (i = 1; i < line.line_no; i++) {
+ length += GetLine(i).text.Length + crlf_size;
+ }
+
+ length += pos;
+
+ return length;
+ }
+
+ internal int SelectionLength() {
+ if ((selection_start.pos == selection_end.pos) && (selection_start.line == selection_end.line)) {
+ return 0;
+ }
+
+ if (!multiline || (selection_start.line == selection_end.line)) {
+ return selection_end.pos - selection_start.pos;
+ } else {
+ int i;
+ int start;
+ int end;
+ int length;
+
+ // Count first and last line
+ length = selection_start.line.text.Length - selection_start.pos + selection_end.pos + crlf_size;
+
+ // Count the lines in the middle
+ start = selection_start.line.line_no + 1;
+ end = selection_end.line.line_no;
+
+ if (start < end) {
+ for (i = start; i < end; i++) {
+ length += GetLine(i).text.Length + crlf_size;
+ }
+ }
+
+ return length;
+ }
+
+
+ }
+
+
+ /// <summary>Give it a Line number and it returns the Line object at with that line number</summary>
+ internal Line GetLine(int LineNo) {
+ Line line = document;
+
+ while (line != sentinel) {
+ if (LineNo == line.line_no) {
+ return line;
+ } else if (LineNo < line.line_no) {
+ line = line.left;
+ } else {
+ line = line.right;
+ }
+ }
+
+ return null;
+ }
+
+ /// <summary>Retrieve the previous tag; walks line boundaries</summary>
+ internal LineTag PreviousTag(LineTag tag) {
+ Line l;
+
+ if (tag.previous != null) {
+ return tag.previous;
+ }
+
+ // Next line
+ if (tag.line.line_no == 1) {
+ return null;
+ }
+
+ l = GetLine(tag.line.line_no - 1);
+ if (l != null) {
+ LineTag t;
+
+ t = l.tags;
+ while (t.next != null) {
+ t = t.next;
+ }
+ return t;
+ }
+
+ return null;
+ }
+
+ /// <summary>Retrieve the next tag; walks line boundaries</summary>
+ internal LineTag NextTag(LineTag tag) {
+ Line l;
+
+ if (tag.next != null) {
+ return tag.next;
+ }
+
+ // Next line
+ l = GetLine(tag.line.line_no + 1);
+ if (l != null) {
+ return l.tags;
+ }
+
+ return null;
+ }
+
+ internal Line ParagraphStart(Line line) {
+ while (line.soft_break) {
+ line = GetLine(line.line_no - 1);
+ }
+ return line;
+ }
+
+ internal Line ParagraphEnd(Line line) {
+ Line l;
+
+ while (line.soft_break) {
+ l = GetLine(line.line_no + 1);
+ if ((l == null) || (!l.soft_break)) {
+ break;
+ }
+ line = l;
+ }
+ return line;
+ }
+
+ /// <summary>Give it a Y pixel coordinate and it returns the Line covering that Y coordinate</summary>
+ internal Line GetLineByPixel(int y, bool exact) {
+ Line line = document;
+ Line last = null;
+
+ while (line != sentinel) {
+ last = line;
+ if ((y >= line.Y) && (y < (line.Y+line.height))) {
+ return line;
+ } else if (y < line.Y) {
+ line = line.left;
+ } else {
+ line = line.right;
+ }
+ }
+
+ if (exact) {
+ return null;
+ }
+ return last;
+ }
+
+ // Give it x/y pixel coordinates and it returns the Tag at that position; optionally the char position is returned in index
+ internal LineTag FindTag(int x, int y, out int index, bool exact) {
+ Line line;
+ LineTag tag;
+
+ line = GetLineByPixel(y, exact);
+ if (line == null) {
+ index = 0;
+ return null;
+ }
+ tag = line.tags;
+
+ // Alignment adjustment
+ x += line.align_shift;
+
+ while (true) {
+ if (x >= tag.X && x < (tag.X+tag.width)) {
+ int end;
+
+ end = tag.start + tag.length - 1;
+
+ for (int pos = tag.start; pos < end; pos++) {
+ if (x < line.widths[pos]) {
+ index = pos;
+ return tag;
+ }
+ }
+ index=end;
+ return tag;
+ }
+ if (tag.next != null) {
+ tag = tag.next;
+ } else {
+ if (exact) {
+ index = 0;
+ return null;
+ }
+
+ index = line.text.Length;
+ return tag;
+ }
+ }
+ }
+
+ // Give it x/y pixel coordinates and it returns the Tag at that position; optionally the char position is returned in index
+ internal LineTag FindCursor(int x, int y, out int index) {
+ Line line;
+ LineTag tag;
+
+ line = GetLineByPixel(y, false);
+ tag = line.tags;
+
+ // Adjust for alignment
+ x += line.align_shift;
+
+ while (true) {
+ if (x >= tag.X && x < (tag.X+tag.width)) {
+ int end;
+
+ end = tag.start + tag.length - 1;
+
+ for (int pos = tag.start-1; pos < end; pos++) {
+ // When clicking on a character, we position the cursor to whatever edge
+ // of the character the click was closer
+ if (x < (line.widths[pos] + ((line.widths[pos+1]-line.widths[pos])/2))) {
+ index = pos;
+ return tag;
+ }
+ }
+ index=end;
+ return tag;
+ }
+ if (tag.next != null) {
+ tag = tag.next;
+ } else {
+ index = line.text.Length;
+ return tag;
+ }
+ }
+ }
+
+ /// <summary>Format area of document in specified font and color</summary>
+ /// <param name="start_pos">1-based start position on start_line</param>
+ /// <param name="end_pos">1-based end position on end_line </param>
+ internal void FormatText(Line start_line, int start_pos, Line end_line, int end_pos, Font font, Brush color) {
+ Line l;
+
+ // First, format the first line
+ if (start_line != end_line) {
+ // First line
+ LineTag.FormatText(start_line, start_pos, start_line.text.Length - start_pos + 1, font, color);
+
+ // Format last line
+ LineTag.FormatText(end_line, 1, end_pos, font, color);
+
+ // Now all the lines inbetween
+ for (int i = start_line.line_no + 1; i < end_line.line_no; i++) {
+ l = GetLine(i);
+ LineTag.FormatText(l, 1, l.text.Length, font, color);
+ }
+ } else {
+ // Special case, single line
+ LineTag.FormatText(start_line, start_pos, end_pos - start_pos, font, color);
+ }
+ }
+
+ /// <summary>Re-format areas of the document in specified font and color</summary>
+ /// <param name="start_pos">1-based start position on start_line</param>
+ /// <param name="end_pos">1-based end position on end_line </param>
+ /// <param name="font">Font specifying attributes</param>
+ /// <param name="color">Color (or NULL) to apply</param>
+ /// <param name="apply">Attributes from font and color to apply</param>
+ internal void FormatText(Line start_line, int start_pos, Line end_line, int end_pos, FontDefinition attributes) {
+ Line l;
+
+ // First, format the first line
+ if (start_line != end_line) {
+ // First line
+ LineTag.FormatText(start_line, start_pos, start_line.text.Length - start_pos + 1, attributes);
+
+ // Format last line
+ LineTag.FormatText(end_line, 1, end_pos - 1, attributes);
+
+ // Now all the lines inbetween
+ for (int i = start_line.line_no + 1; i < end_line.line_no; i++) {
+ l = GetLine(i);
+ LineTag.FormatText(l, 1, l.text.Length, attributes);
+ }
+ } else {
+ // Special case, single line
+ LineTag.FormatText(start_line, start_pos, end_pos - start_pos, attributes);
+ }
+ }
+
+ internal void RecalculateAlignments() {
+ Line line;
+ int line_no;
+
+ line_no = 1;
+
+ while (line_no <= lines) {
+ line = GetLine(line_no);
+
+ if (line != null && line.alignment != HorizontalAlignment.Left) {
+ if (line.alignment == HorizontalAlignment.Center) {
+ line.align_shift = (viewport_width - (int)line.widths[line.text.Length]) / 2;
+ } else {
+ line.align_shift = viewport_width - (int)line.widths[line.text.Length];
+ }
+ }
+
+ line_no++;
+ }
+ return;
+ }
+
+ /// <summary>Calculate formatting for the whole document</summary>
+ internal bool RecalculateDocument(Graphics g) {
+ return RecalculateDocument(g, 1, this.lines, false);
+ }
+
+ /// <summary>Calculate formatting starting at a certain line</summary>
+ internal bool RecalculateDocument(Graphics g, int start) {
+ return RecalculateDocument(g, start, this.lines, false);
+ }
+
+ /// <summary>Calculate formatting within two given line numbers</summary>
+ internal bool RecalculateDocument(Graphics g, int start, int end) {
+ return RecalculateDocument(g, start, end, false);
+ }
+
+ /// <summary>With optimize on, returns true if line heights changed</summary>
+ internal bool RecalculateDocument(Graphics g, int start, int end, bool optimize) {
+ Line line;
+ int line_no;
+ int Y;
+ int new_width;
+ bool changed;
+ int shift;
+
+ if (no_recalc) {
+ recalc_pending = true;
+ recalc_start = start;
+ recalc_end = end;
+ recalc_optimize = optimize;
+ return false;
+ }
+
+ Y = GetLine(start).Y;
+ line_no = start;
+ new_width = 0;
+ shift = this.lines;
+ if (!optimize) {
+ changed = true; // We always return true if we run non-optimized
+ } else {
+ changed = false;
+ }
+
+ while (line_no <= (end + this.lines - shift)) {
+ line = GetLine(line_no++);
+ line.Y = Y;
+
+ if (!calc_pass) {
+ if (!optimize) {
+ line.RecalculateLine(g, this);
+ } else {
+ if (line.recalc && line.RecalculateLine(g, this)) {
+ changed = true;
+ // If the height changed, all subsequent lines change
+ end = this.lines;
+ shift = this.lines;
+ }
+ }
+ } else {
+ if (!optimize) {
+ line.RecalculatePasswordLine(g, this);
+ } else {
+ if (line.recalc && line.RecalculatePasswordLine(g, this)) {
+ changed = true;
+ // If the height changed, all subsequent lines change
+ end = this.lines;
+ shift = this.lines;
+ }
+ }
+ }
+
+ if (line.widths[line.text.Length] > new_width) {
+ new_width = (int)line.widths[line.text.Length];
+ }
+
+ // Calculate alignment
+ if (line.alignment != HorizontalAlignment.Left) {
+ if (line.alignment == HorizontalAlignment.Center) {
+ line.align_shift = (viewport_width - (int)line.widths[line.text.Length]) / 2;
+ } else {
+ line.align_shift = viewport_width - (int)line.widths[line.text.Length];
+ }
+ }
+
+ Y += line.height;
+
+ if (line_no > lines) {
+ break;
+ }
+ }
+
+ if (document_x != new_width) {
+ document_x = new_width;
+ if (WidthChanged != null) {
+ WidthChanged(this, null);
+ }
+ }
+
+ RecalculateAlignments();
+
+ line = GetLine(lines);
+
+ if (document_y != line.Y + line.height) {
+ document_y = line.Y + line.height;
+ if (HeightChanged != null) {
+ HeightChanged(this, null);
+ }
+ }
+
+ return changed;
+ }
+
+ internal int Size() {
+ return lines;
+ }
+
+ private void owner_HandleCreated(object sender, EventArgs e) {
+ RecalculateDocument(owner.CreateGraphicsInternal());
+ PositionCaret(0, 0);
+ }
+
+ private void owner_VisibleChanged(object sender, EventArgs e) {
+ if (owner.Visible) {
+ RecalculateDocument(owner.CreateGraphicsInternal());
+ }
+ }
+
+ internal static bool IsWordSeparator(char ch) {
+ switch(ch) {
+ case ' ':
+ case '\t':
+ case '(':
+ case ')': {
+ return true;
+ }
+
+ default: {
+ return false;
+ }
+ }
+ }
+ internal int FindWordSeparator(Line line, int pos, bool forward) {
+ int len;
+
+ len = line.text.Length;
+
+ if (forward) {
+ for (int i = pos + 1; i < len; i++) {
+ if (IsWordSeparator(line.Text[i])) {
+ return i + 1;
+ }
+ }
+ return len;
+ } else {
+ for (int i = pos - 1; i > 0; i--) {
+ if (IsWordSeparator(line.Text[i - 1])) {
+ return i;
+ }
+ }
+ return 0;
+ }
+ }
+
+ /* Search document for text */
+ internal bool FindChars(char[] chars, Marker start, Marker end, out Marker result) {
+ Line line;
+ int line_no;
+ int pos;
+ int line_len;
+
+ // Search for occurence of any char in the chars array
+ result = new Marker();
+
+ line = start.line;
+ line_no = start.line.line_no;
+ pos = start.pos;
+ while (line_no <= end.line.line_no) {
+ line_len = line.text.Length;
+ while (pos < line_len) {
+ for (int i = 0; i < chars.Length; i++) {
+ if (line.text[pos] == chars[i]) {
+ // Special case
+ if ((line.line_no == end.line.line_no) && (pos >= end.pos)) {
+ return false;
+ }
+
+ result.line = line;
+ result.pos = pos;
+ return true;
+ }
+ }
+ pos++;
+ }
+
+ pos = 0;
+ line_no++;
+ line = GetLine(line_no);
+ }
+
+ return false;
+ }
+
+ // This version does not build one big string for searching, instead it handles
+ // line-boundaries, which is faster and less memory intensive
+ // FIXME - Depending on culture stuff we might have to create a big string and use culturespecific
+ // search stuff and change it to accept and return positions instead of Markers (which would match
+ // RichTextBox behaviour better but would be inconsistent with the rest of TextControl)
+ internal bool Find(string search, Marker start, Marker end, out Marker result, RichTextBoxFinds options) {
+ Marker last;
+ string search_string;
+ Line line;
+ int line_no;
+ int pos;
+ int line_len;
+ int current;
+ bool word;
+ bool word_option;
+ bool ignore_case;
+ bool reverse;
+ char c;
+
+ result = new Marker();
+ word_option = ((options & RichTextBoxFinds.WholeWord) != 0);
+ ignore_case = ((options & RichTextBoxFinds.MatchCase) == 0);
+ reverse = ((options & RichTextBoxFinds.Reverse) != 0);
+
+ line = start.line;
+ line_no = start.line.line_no;
+ pos = start.pos;
+ current = 0;
+
+ // Prep our search string, lowercasing it if we do case-independent matching
+ if (ignore_case) {
+ StringBuilder sb;
+ sb = new StringBuilder(search);
+ for (int i = 0; i < sb.Length; i++) {
+ sb[i] = Char.ToLower(sb[i]);
+ }
+ search_string = sb.ToString();
+ } else {
+ search_string = search;
+ }
+
+ // We need to check if the character before our start position is a wordbreak
+ if (word_option) {
+ if (line_no == 1) {
+ if ((pos == 0) || (IsWordSeparator(line.text[pos - 1]))) {
+ word = true;
+ } else {
+ word = false;
+ }
+ } else {
+ if (pos > 0) {
+ if (IsWordSeparator(line.text[pos - 1])) {
+ word = true;
+ } else {
+ word = false;
+ }
+ } else {
+ // Need to check the end of the previous line
+ Line prev_line;
+
+ prev_line = GetLine(line_no - 1);
+ if (prev_line.soft_break) {
+ if (IsWordSeparator(prev_line.text[prev_line.text.Length - 1])) {
+ word = true;
+ } else {
+ word = false;
+ }
+ } else {
+ word = true;
+ }
+ }
+ }
+ } else {
+ word = false;
+ }
+
+ // To avoid duplication of this loop with reverse logic, we search
+ // through the document, remembering the last match and when returning
+ // report that last remembered match
+
+ last = new Marker();
+ last.height = -1; // Abused - we use it to track change
+
+ while (line_no <= end.line.line_no) {
+ if (line_no != end.line.line_no) {
+ line_len = line.text.Length;
+ } else {
+ line_len = end.pos;
+ }
+
+ while (pos < line_len) {
+ if (word_option && (current == search_string.Length)) {
+ if (IsWordSeparator(line.text[pos])) {
+ if (!reverse) {
+ goto FindFound;
+ } else {
+ last = result;
+ current = 0;
+ }
+ } else {
+ current = 0;
+ }
+ }
+
+ if (ignore_case) {
+ c = Char.ToLower(line.text[pos]);
+ } else {
+ c = line.text[pos];
+ }
+
+ if (c == search_string[current]) {
+ if (current == 0) {
+ result.line = line;
+ result.pos = pos;
+ }
+ if (!word_option || (word_option && (word || (current > 0)))) {
+ current++;
+ }
+
+ if (!word_option && (current == search_string.Length)) {
+ if (!reverse) {
+ goto FindFound;
+ } else {
+ last = result;
+ current = 0;
+ }
+ }
+ } else {
+ current = 0;
+ }
+ pos++;
+
+ if (!word_option) {
+ continue;
+ }
+
+ if (IsWordSeparator(c)) {
+ word = true;
+ } else {
+ word = false;
+ }
+ }
+
+ if (word_option) {
+ // Mark that we just saw a word boundary
+ if (!line.soft_break) {
+ word = true;
+ }
+
+ if (current == search_string.Length) {
+ if (word) {
+ if (!reverse) {
+ goto FindFound;
+ } else {
+ last = result;
+ current = 0;
+ }
+ } else {
+ current = 0;
+ }
+ }
+ }
+
+ pos = 0;
+ line_no++;
+ line = GetLine(line_no);
+ }
+
+ if (reverse) {
+ if (last.height != -1) {
+ result = last;
+ return true;
+ }
+ }
+
+ return false;
+
+ FindFound:
+ if (!reverse) {
+// if ((line.line_no == end.line.line_no) && (pos >= end.pos)) {
+// return false;
+// }
+ return true;
+ }
+
+ result = last;
+ return true;
+
+ }
+
+ /* Marker stuff */
+ internal void GetMarker(out Marker mark, bool start) {
+ mark = new Marker();
+
+ if (start) {
+ mark.line = GetLine(1);
+ mark.tag = mark.line.tags;
+ mark.pos = 0;
+ } else {
+ mark.line = GetLine(lines);
+ mark.tag = mark.line.tags;
+ while (mark.tag.next != null) {
+ mark.tag = mark.tag.next;
+ }
+ mark.pos = mark.line.text.Length;
+ }
+ }
+ #endregion // Internal Methods
+
+ #region Events
+ internal event EventHandler CaretMoved;
+ internal event EventHandler WidthChanged;
+ internal event EventHandler HeightChanged;
+ internal event EventHandler LengthChanged;
+ #endregion // Events
+
+ #region Administrative
+ public IEnumerator GetEnumerator() {
+ // FIXME
+ return null;
+ }
+
+ public override bool Equals(object obj) {
+ if (obj == null) {
+ return false;
+ }
+
+ if (!(obj is Document)) {
+ return false;
+ }
+
+ if (obj == this) {
+ return true;
+ }
+
+ if (ToString().Equals(((Document)obj).ToString())) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public override int GetHashCode() {
+ return document_id;
+ }
+
+ public override string ToString() {
+ return "document " + this.document_id;
+ }
+ #endregion // Administrative
+ }
+
+ internal class LineTag {
+ #region Local Variables;
+ // Payload; formatting
+ internal Font font; // System.Drawing.Font object for this tag
+ internal Brush color; // System.Drawing.Brush object
+
+ // Payload; text
+ internal int start; // start, in chars; index into Line.text
+ internal int length; // length, in chars
+ internal bool r_to_l; // Which way is the font
+
+ // Drawing support
+ internal int height; // Height in pixels of the text this tag describes
+ internal int X; // X location of the text this tag describes
+ internal float width; // Width in pixels of the text this tag describes
+ internal int ascent; // Ascent of the font for this tag
+ internal int shift; // Shift down for this tag, to stay on baseline
+
+ // Administrative
+ internal Line line; // The line we're on
+ internal LineTag next; // Next tag on the same line
+ internal LineTag previous; // Previous tag on the same line
+ #endregion;
+
+ #region Constructors
+ internal LineTag(Line line, int start, int length) {
+ this.line = line;
+ this.start = start;
+ this.length = length;
+ this.X = 0;
+ this.width = 0;
+ }
+ #endregion // Constructors
+
+ #region Internal Methods
+ ///<summary>Break a tag into two with identical attributes; pos is 1-based; returns tag starting at &gt;pos&lt; or null if end-of-line</summary>
+ internal LineTag Break(int pos) {
+ LineTag new_tag;
+
+ // Sanity
+ if (pos == this.start) {
+ return this;
+ } else if (pos >= (start + length)) {
+ return null;
+ }
+
+ new_tag = new LineTag(line, pos, start + length - pos);
+ new_tag.color = color;
+ new_tag.font = font;
+ this.length -= new_tag.length;
+ new_tag.next = this.next;
+ this.next = new_tag;
+ new_tag.previous = this;
+ if (new_tag.next != null) {
+ new_tag.next.previous = new_tag;
+ }
+
+ return new_tag;
+ }
+
+ ///<summary>Create new font and brush from existing font and given new attributes. Returns true if fontheight changes</summary>
+ internal static bool GenerateTextFormat(Font font_from, Brush color_from, FontDefinition attributes, out Font new_font, out Brush new_color) {
+ float size;
+ string face;
+ FontStyle style;
+ GraphicsUnit unit;
+
+ if (attributes.font_obj == null) {
+ size = font_from.SizeInPoints;
+ unit = font_from.Unit;
+ face = font_from.Name;
+ style = font_from.Style;
+
+ if (attributes.face != null) {
+ face = attributes.face;
+ }
+
+ if (attributes.size != 0) {
+ size = attributes.size;
+ }
+
+ style |= attributes.add_style;
+ style &= ~attributes.remove_style;
+
+ // Create new font
+ new_font = new Font(face, size, style, unit);
+ } else {
+ new_font = attributes.font_obj;
+ }
+
+ // Create 'new' color brush
+ if (attributes.color != Color.Empty) {
+ new_color = new SolidBrush(attributes.color);
+ } else {
+ new_color = color_from;
+ }
+
+ if (new_font.Height == font_from.Height) {
+ return false;
+ }
+ return true;
+ }
+
+ /// <summary>Applies 'font' and 'brush' to characters starting at 'start' for 'length' chars;
+ /// Removes any previous tags overlapping the same area;
+ /// returns true if lineheight has changed</summary>
+ /// <param name="start">1-based character position on line</param>
+ internal static bool FormatText(Line line, int start, int length, Font font, Brush color) {
+ LineTag tag;
+ LineTag start_tag;
+ int end;
+ bool retval = false; // Assume line-height doesn't change
+
+ // Too simple?
+ if (font.Height != line.height) {
+ retval = true;
+ }
+ line.recalc = true; // This forces recalculation of the line in RecalculateDocument
+
+ // A little sanity, not sure if it's needed, might be able to remove for speed
+ if (length > line.text.Length) {
+ length = line.text.Length;
+ }
+
+ tag = line.tags;
+ end = start + length;
+
+ // Common special case
+ if ((start == 1) && (length == tag.length)) {
+ tag.ascent = 0;
+ tag.font = font;
+ tag.color = color;
+ return retval;
+ }
+
+ //Console.WriteLine("Finding tag for {0} {1}", line, start);
+ start_tag = FindTag(line, start);
+ if (start_tag == null) { // FIXME - is there a better way to handle this, or do we even need it?
+ throw new Exception(String.Format("Could not find start_tag in document at line {0} position {1}", line.line_no, start));
+ }
+
+ tag = new LineTag(line, start, length);
+ tag.font = font;
+ tag.color = color;
+
+ if (start == 1) {
+ line.tags = tag;
+ }
+ //Console.WriteLine("Start tag: '{0}'", start_tag!=null ? start_tag.ToString() : "NULL");
+ if (start_tag.start == start) {
+ tag.next = start_tag;
+ tag.previous = start_tag.previous;
+ if (start_tag.previous != null) {
+ start_tag.previous.next = tag;
+ }
+ start_tag.previous = tag;
+ } else {
+ // Insert ourselves 'in the middle'
+ if ((start_tag.next != null) && (start_tag.next.start < end)) {
+ tag.next = start_tag.next;
+ } else {
+ tag.next = new LineTag(line, start_tag.start, start_tag.length);
+ tag.next.font = start_tag.font;
+ tag.next.color = start_tag.color;
+
+ if (start_tag.next != null) {
+ tag.next.next = start_tag.next;
+ tag.next.next.previous = tag.next;
+ }
+ }
+ tag.next.previous = tag;
+
+ start_tag.length = start - start_tag.start;
+
+ tag.previous = start_tag;
+ start_tag.next = tag;
+#if nope
+ if (tag.next.start > (tag.start + tag.length)) {
+ tag.next.length += tag.next.start - (tag.start + tag.length);
+ tag.next.start = tag.start + tag.length;
+ }
+#endif
+ }
+
+ // Elimination loop
+ tag = tag.next;
+ while ((tag != null) && (tag.start < end)) {
+ if ((tag.start + tag.length) <= end) {
+ // remove the tag
+ tag.previous.next = tag.next;
+ if (tag.next != null) {
+ tag.next.previous = tag.previous;
+ }
+ tag = tag.previous;
+ } else {
+ // Adjust the length of the tag
+ tag.length = (tag.start + tag.length) - end;
+ tag.start = end;
+ }
+ tag = tag.next;
+ }
+
+ return retval;
+ }
+
+ /// <summary>Applies font attributes specified to characters starting at 'start' for 'length' chars;
+ /// Breaks tags at start and end point, keeping middle tags with altered attributes.
+ /// Returns true if lineheight has changed</summary>
+ /// <param name="start">1-based character position on line</param>
+ internal static bool FormatText(Line line, int start, int length, FontDefinition attributes) {
+ LineTag tag;
+ LineTag start_tag;
+ LineTag end_tag;
+ bool retval = false; // Assume line-height doesn't change
+
+ line.recalc = true; // This forces recalculation of the line in RecalculateDocument
+
+ // A little sanity, not sure if it's needed, might be able to remove for speed
+ if (length > line.text.Length) {
+ length = line.text.Length;
+ }
+
+ tag = line.tags;
+
+ // Common special case
+ if ((start == 1) && (length == tag.length)) {
+ tag.ascent = 0;
+ GenerateTextFormat(tag.font, tag.color, attributes, out tag.font, out tag.color);
+ return retval;
+ }
+
+ start_tag = FindTag(line, start);
+
+ if (start_tag == null) {
+ if (length == 0) {
+ // We are 'starting' after all valid tags; create a new tag with the right attributes
+ start_tag = FindTag(line, line.text.Length - 1);
+ start_tag.next = new LineTag(line, line.text.Length + 1, 0);
+ start_tag.next.font = start_tag.font;
+ start_tag.next.color = start_tag.color;
+ start_tag.next.previous = start_tag;
+ start_tag = start_tag.next;
+ } else {
+ throw new Exception(String.Format("Could not find start_tag in document at line {0} position {1}", line.line_no, start));
+ }
+ } else {
+ start_tag = start_tag.Break(start);
+ }
+
+ end_tag = FindTag(line, start + length);
+ if (end_tag != null) {
+ end_tag = end_tag.Break(start + length);
+ }
+
+ // start_tag or end_tag might be null; we're cool with that
+ // we now walk from start_tag to end_tag, applying new attributes
+ tag = start_tag;
+ while ((tag != null) && tag != end_tag) {
+ if (LineTag.GenerateTextFormat(tag.font, tag.color, attributes, out tag.font, out tag.color)) {
+ retval = true;
+ }
+ tag = tag.next;
+ }
+ return retval;
+ }
+
+
+ /// <summary>Finds the tag that describes the character at position 'pos' on 'line'</summary>
+ internal static LineTag FindTag(Line line, int pos) {
+ LineTag tag = line.tags;
+
+ // Beginning of line is a bit special
+ if (pos == 0) {
+ return tag;
+ }
+
+ while (tag != null) {
+ if ((tag.start <= pos) && (pos < (tag.start+tag.length))) {
+ return tag;
+ }
+
+ tag = tag.next;
+ }
+
+ return null;
+ }
+
+ /// <summary>Combines 'this' tag with 'other' tag</summary>
+ internal bool Combine(LineTag other) {
+ if (!this.Equals(other)) {
+ return false;
+ }
+
+ this.width += other.width;
+ this.length += other.length;
+ this.next = other.next;
+ if (this.next != null) {
+ this.next.previous = this;
+ }
+
+ return true;
+ }
+
+
+ /// <summary>Remove 'this' tag ; to be called when formatting is to be removed</summary>
+ internal bool Remove() {
+ if ((this.start == 1) && (this.next == null)) {
+ // We cannot remove the only tag
+ return false;
+ }
+ if (this.start != 1) {
+ this.previous.length += this.length;
+ this.previous.width = -1;
+ this.previous.next = this.next;
+ this.next.previous = this.previous;
+ } else {
+ this.next.start = 1;
+ this.next.length += this.length;
+ this.next.width = -1;
+ this.line.tags = this.next;
+ this.next.previous = null;
+ }
+ return true;
+ }
+
+
+ /// <summary>Checks if 'this' tag describes the same formatting options as 'obj'</summary>
+ public override bool Equals(object obj) {
+ LineTag other;
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (!(obj is LineTag)) {
+ return false;
+ }
+
+ if (obj == this) {
+ return true;
+ }
+
+ other = (LineTag)obj;
+
+ if (this.font.Equals(other.font) && this.color.Equals(other.color)) { // FIXME add checking for things like link or type later
+ return true;
+ }
+
+ return false;
+ }
+
+ public override int GetHashCode() {
+ return base.GetHashCode ();
+ }
+
+ public override string ToString() {
+ return "Tag starts at index " + this.start + "length " + this.length + " text: " + this.line.Text.Substring(this.start-1, this.length) + "Font " + this.font.ToString();
+ }
+
+ #endregion // Internal Methods
+ }
+
+ internal class UndoClass {
+ internal enum ActionType {
+ InsertChar,
+ InsertString,
+ DeleteChar,
+ DeleteChars,
+ CursorMove,
+ Mark,
+ }
+
+ internal class Action {
+ internal ActionType type;
+ internal int line_no;
+ internal int pos;
+ internal object data;
+ }
+
+ #region Local Variables
+ private Document document;
+ private Stack undo_actions;
+ private Stack redo_actions;
+ private int caret_line;
+ private int caret_pos;
+ #endregion // Local Variables
+
+ #region Constructors
+ internal UndoClass(Document doc) {
+ document = doc;
+ undo_actions = new Stack(50);
+ redo_actions = new Stack(50);
+ }
+ #endregion // Constructors
+
+ #region Properties
+ [MonoTODO("Change this to be configurable")]
+ internal int UndoLevels {
+ get {
+ return undo_actions.Count;
+ }
+ }
+
+ [MonoTODO("Change this to be configurable")]
+ internal int RedoLevels {
+ get {
+ return redo_actions.Count;
+ }
+ }
+
+ [MonoTODO("Come up with good naming and localization")]
+ internal string UndoName {
+ get {
+ Action action;
+
+ action = (Action)undo_actions.Peek();
+ switch(action.type) {
+ case ActionType.InsertChar: {
+ Locale.GetText("Insert character");
+ break;
+ }
+
+ case ActionType.DeleteChar: {
+ Locale.GetText("Delete character");
+ break;
+ }
+
+ case ActionType.InsertString: {
+ Locale.GetText("Insert string");
+ break;
+ }
+
+ case ActionType.DeleteChars: {
+ Locale.GetText("Delete string");
+ break;
+ }
+
+ case ActionType.CursorMove: {
+ Locale.GetText("Cursor move");
+ break;
+ }
+ }
+ return null;
+ }
+ }
+
+ internal string RedoName() {
+ return null;
+ }
+ #endregion // Properties
+
+ #region Internal Methods
+ internal void Clear() {
+ undo_actions.Clear();
+ redo_actions.Clear();
+ }
+
+ internal void Undo() {
+ Action action;
+
+ if (undo_actions.Count == 0) {
+ return;
+ }
+
+ action = (Action)undo_actions.Pop();
+
+ // Put onto redo stack
+ redo_actions.Push(action);
+
+ // Do the thing
+ switch(action.type) {
+ case ActionType.InsertChar: {
+ break;
+ }
+
+ case ActionType.DeleteChars: {
+ this.Insert(document.GetLine(action.line_no), action.pos, (Line)action.data);
+ break;
+ }
+
+ case ActionType.CursorMove: {
+ document.caret.line = document.GetLine(action.line_no);
+ document.caret.tag = document.caret.line.FindTag(action.pos);
+ document.caret.pos = action.pos;
+ document.caret.height = document.caret.tag.height;
+
+ if (document.owner.IsHandleCreated) {
+ XplatUI.DestroyCaret(document.owner.Handle);
+ XplatUI.CreateCaret(document.owner.Handle, 2, document.caret.height);
+ XplatUI.SetCaretPos(document.owner.Handle, (int)document.caret.tag.line.widths[document.caret.pos] + document.caret.line.align_shift - document.viewport_x, document.caret.line.Y + document.caret.tag.shift - document.viewport_y + Document.caret_shift);
+ XplatUI.CaretVisible(document.owner.Handle, true);
+ }
+
+ // FIXME - enable call
+ //if (document.CaretMoved != null) document.CaretMoved(this, EventArgs.Empty);
+ break;
+ }
+ }
+ }
+
+ internal void Redo() {
+ if (redo_actions.Count == 0) {
+ return;
+ }
+ }
+ #endregion // Internal Methods
+
+ #region Private Methods
+ // pos = 1-based
+ public void RecordDeleteChars(Line line, int pos, int length) {
+ RecordDelete(line, pos, line, pos + length - 1);
+ }
+
+ // start_pos, end_pos = 1 based
+ public void RecordDelete(Line start_line, int start_pos, Line end_line, int end_pos) {
+ Line l;
+ Action a;
+
+ l = Duplicate(start_line, start_pos, end_line, end_pos);
+
+ a = new Action();
+ a.type = ActionType.DeleteChars;
+ a.data = l;
+ a.line_no = start_line.line_no;
+ a.pos = start_pos - 1;
+
+ undo_actions.Push(a);
+ }
+
+ public void RecordCursor() {
+ if (document.caret.line == null) {
+ return;
+ }
+
+ RecordCursor(document.caret.line, document.caret.pos);
+ }
+
+ public void RecordCursor(Line line, int pos) {
+ Action a;
+
+ if ((line.line_no == caret_line) && (pos == caret_pos)) {
+ return;
+ }
+
+ caret_line = line.line_no;
+ caret_pos = pos;
+
+ a = new Action();
+ a.type = ActionType.CursorMove;
+ a.line_no = line.line_no;
+ a.pos = pos;
+
+ undo_actions.Push(a);
+ }
+
+ // start_pos = 1-based
+ // end_pos = 1-based
+ public Line Duplicate(Line start_line, int start_pos, Line end_line, int end_pos) {
+ Line ret;
+ Line line;
+ Line current;
+ LineTag tag;
+ LineTag current_tag;
+ int start;
+ int end;
+ int tag_start;
+ int tag_length;
+
+ line = new Line();
+ ret = line;
+
+ for (int i = start_line.line_no; i <= end_line.line_no; i++) {
+ current = document.GetLine(i);
+
+ if (start_line.line_no == i) {
+ start = start_pos;
+ } else {
+ start = 1;
+ }
+
+ if (end_line.line_no == i) {
+ end = end_pos;
+ } else {
+ end = current.text.Length;
+ }
+
+ // Text for the tag
+ line.text = new StringBuilder(current.text.ToString(start - 1, end - start + 1));
+
+ // Copy tags from start to start+length onto new line
+ current_tag = current.FindTag(start - 1);
+ while ((current_tag != null) && (current_tag.start < end)) {
+ if ((current_tag.start <= start) && (start < (current_tag.start + current_tag.length))) {
+ // start tag is within this tag
+ tag_start = start;
+ } else {
+ tag_start = current_tag.start;
+ }
+
+ if (end < (current_tag.start + current_tag.length)) {
+ tag_length = end - tag_start + 1;
+ } else {
+ tag_length = current_tag.start + current_tag.length - tag_start;
+ }
+ tag = new LineTag(line, tag_start - start + 1, tag_length);
+ tag.color = current_tag.color;
+ tag.font = current_tag.font;
+
+ current_tag = current_tag.next;
+
+ // Add the new tag to the line
+ if (line.tags == null) {
+ line.tags = tag;
+ } else {
+ LineTag tail;
+ tail = line.tags;
+
+ while (tail.next != null) {
+ tail = tail.next;
+ }
+ tail.next = tag;
+ tag.previous = tail;
+ }
+ }
+
+ if ((i + 1) <= end_line.line_no) {
+ line.soft_break = current.soft_break;
+
+ // Chain them (we use right/left as next/previous)
+ line.right = new Line();
+ line.right.left = line;
+ line = line.right;
+ }
+ }
+
+ return ret;
+ }
+
+ // Insert multi-line text at the given position; use formatting at insertion point for inserted text
+ internal void Insert(Line line, int pos, Line insert) {
+ Line current;
+ LineTag tag;
+ int offset;
+ int lines;
+ Line first;
+
+ // Handle special case first
+ if (insert.right == null) {
+
+ // Single line insert
+ document.Split(line, pos);
+
+ if (insert.tags == null) {
+ return; // Blank line
+ }
+
+ //Insert our tags at the end
+ tag = line.tags;
+
+ while (tag.next != null) {
+ tag = tag.next;
+ }
+
+ offset = tag.start + tag.length - 1;
+
+ tag.next = insert.tags;
+ line.text.Insert(offset, insert.text.ToString());
+
+ // Adjust start locations
+ tag = tag.next;
+ while (tag != null) {
+ tag.start += offset;
+ tag.line = line;
+ tag = tag.next;
+ }
+ // Put it back together
+ document.Combine(line.line_no, line.line_no + 1);
+ document.UpdateView(line, pos);
+ return;
+ }
+
+ first = line;
+ lines = 1;
+ current = insert;
+ while (current != null) {
+ if (current == insert) {
+ // Inserting the first line we split the line (and make space)
+ document.Split(line, pos);
+ //Insert our tags at the end of the line
+ tag = line.tags;
+
+ if (tag != null) {
+ while (tag.next != null) {
+ tag = tag.next;
+ }
+ offset = tag.start + tag.length - 1;
+ tag.next = current.tags;
+ tag.next.previous = tag;
+
+ tag = tag.next;
+
+ } else {
+ offset = 0;
+ line.tags = current.tags;
+ line.tags.previous = null;
+ tag = line.tags;
+ }
+ } else {
+ document.Split(line.line_no, 0);
+ offset = 0;
+ line.tags = current.tags;
+ line.tags.previous = null;
+ tag = line.tags;
+ }
+ // Adjust start locations and line pointers
+ while (tag != null) {
+ tag.start += offset;
+ tag.line = line;
+ tag = tag.next;
+ }
+
+ line.text.Insert(offset, current.text.ToString());
+ line.Grow(line.text.Length);
+
+ line.recalc = true;
+ line = document.GetLine(line.line_no + 1);
+
+ // FIXME? Test undo of line-boundaries
+ if ((current.right == null) && (current.tags.length != 0)) {
+ document.Combine(line.line_no - 1, line.line_no);
+ }
+ current = current.right;
+ lines++;
+
+ }
+
+ // Recalculate our document
+ document.UpdateView(first, lines, pos);
+ return;
+ }
+ #endregion // Private Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextFormatFlags.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextFormatFlags.cs
new file mode 100644
index 00000000000..35487bc368f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextFormatFlags.cs
@@ -0,0 +1,66 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+namespace System.Windows.Forms {
+
+ [FlagsAttribute()]
+ public enum TextFormatFlags {
+ Left = 0,
+ Top = 0,
+ Default = 0,
+ GlyphOverhangPadding = 0,
+ HorizontalCenter = 1,
+ Right = 2,
+ VerticalCenter = 4,
+ Bottom = 8,
+ WordBreak = 16,
+ SingleLine = 32,
+ ExpandTabs = 64,
+ TabStop = 128,
+ NoClipping = 256,
+ ExternalLeading = 512,
+ NoPrefix = 2048,
+ Internal = 4096,
+ TextBoxControl = 8192,
+ PathEllipsis = 16384,
+ EndEllipsis = 32768,
+ ModifyString = 65536,
+ RightToLeft = 131072,
+ WordEllipsis = 262144,
+ NoFullWidthCharacterBreak = 524288,
+ HidePrefix = 1048576,
+ PrefixOnly = 2097152,
+ PreserveGraphicsClipping = 16777216,
+ PreserveGraphicsTranslateTransform = 33554432,
+ NoPadding = 268435456,
+ LeftAndRightPadding = 536870912
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs
new file mode 100644
index 00000000000..30914006e1b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs
@@ -0,0 +1,851 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+// Peter Dennis Bartok, pbartok@novell.com
+//
+
+
+using System.Collections;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+using System.Reflection;
+
+namespace System.Windows.Forms
+{
+ internal enum UIIcon {
+ PlacesRecentDocuments,
+ PlacesDesktop,
+ PlacesPersonal,
+ PlacesMyComputer,
+ PlacesMyNetwork,
+ MessageBoxError,
+ MessageBoxQuestion,
+ MessageBoxWarning,
+ MessageBoxInfo,
+
+ NormalFolder
+ }
+
+ // Implements a pool of system resources
+ internal class SystemResPool
+ {
+ private Hashtable pens = new Hashtable ();
+ private Hashtable solidbrushes = new Hashtable ();
+ private Hashtable hatchbrushes = new Hashtable ();
+ private Hashtable uiImages = new Hashtable();
+
+ public SystemResPool () {}
+
+ public Pen GetPen (Color color)
+ {
+ int hash = color.ToArgb ();
+
+ Pen res = pens [hash] as Pen;
+ if (res != null)
+ return res;
+
+ Pen pen = new Pen (color);
+ pens.Add (hash, pen);
+ return pen;
+ }
+
+ public SolidBrush GetSolidBrush (Color color)
+ {
+ int hash = color.ToArgb ();
+
+ SolidBrush res = solidbrushes [hash] as SolidBrush;
+ if (res != null)
+ return res;
+
+ SolidBrush brush = new SolidBrush (color);
+ solidbrushes.Add (hash, brush);
+ return brush;
+ }
+
+ public HatchBrush GetHatchBrush (HatchStyle hatchStyle, Color foreColor, Color backColor)
+ {
+ string hash = hatchStyle.ToString () + foreColor.ToString () + backColor.ToString ();
+
+ if (hatchbrushes.Contains (hash))
+ return (HatchBrush) hatchbrushes[hash];
+
+ HatchBrush brush = new HatchBrush (hatchStyle, foreColor, backColor);
+ hatchbrushes.Add (hash, brush);
+ return brush;
+ }
+
+ public void AddUIImage (Image image, string name, int size)
+ {
+ string hash = name + size.ToString();
+
+ if (uiImages.Contains (hash))
+ return;
+ uiImages.Add (hash, image);
+ }
+
+ public Image GetUIImage(string name, int size)
+ {
+ string hash = name + size.ToString();
+
+ Image image = uiImages [hash] as Image;
+
+ return image;
+ }
+ }
+
+ internal abstract class Theme
+ {
+ protected Array syscolors;
+ protected Font default_font;
+ protected Color defaultWindowBackColor;
+ protected Color defaultWindowForeColor;
+ protected bool always_draw_hotkeys = true;
+ internal SystemResPool ResPool = new SystemResPool ();
+ private Type system_colors = Type.GetType("System.Drawing.SystemColors, System.Drawing");
+
+ private void SetSystemColors(string name, Color value) {
+ if (system_colors != null) {
+ MethodInfo update;
+
+ system_colors.GetField(name, System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).SetValue(null, value);
+ update = system_colors.GetMethod("UpdateColors", BindingFlags.Static | BindingFlags.NonPublic);
+ if (update != null) {
+ update.Invoke(null, null);
+ }
+ }
+ }
+
+
+ /* OS Feature support */
+ public abstract Version Version {
+ get;
+ }
+
+ /* Default properties */
+ public virtual Color ColorScrollBar {
+ get { return SystemColors.ScrollBar;}
+ set { SetSystemColors("scroll_bar", value); }
+ }
+
+ public virtual Color ColorDesktop {
+ get { return SystemColors.Desktop;}
+ set { SetSystemColors("desktop", value); }
+ }
+
+ public virtual Color ColorActiveCaption {
+ get { return SystemColors.ActiveCaption;}
+ set { SetSystemColors("active_caption", value); }
+ }
+
+ public virtual Color ColorInactiveCaption {
+ get { return SystemColors.InactiveCaption;}
+ set { SetSystemColors("inactive_caption", value); }
+ }
+
+ public virtual Color ColorMenu {
+ get { return SystemColors.Menu;}
+ set { SetSystemColors("menu", value); }
+ }
+
+ public virtual Color ColorWindow {
+ get { return SystemColors.Window;}
+ set { SetSystemColors("window", value); }
+ }
+
+ public virtual Color ColorWindowFrame {
+ get { return SystemColors.WindowFrame;}
+ set { SetSystemColors("window_frame", value); }
+ }
+
+ public virtual Color ColorMenuText {
+ get { return SystemColors.MenuText;}
+ set { SetSystemColors("menu_text", value); }
+ }
+
+ public virtual Color ColorWindowText {
+ get { return SystemColors.WindowText;}
+ set { SetSystemColors("window_text", value); }
+ }
+
+ public virtual Color ColorActiveCaptionText {
+ get { return SystemColors.ActiveCaptionText;}
+ set { SetSystemColors("active_caption_text", value); }
+ }
+
+ public virtual Color ColorActiveBorder {
+ get { return SystemColors.ActiveBorder;}
+ set { SetSystemColors("active_border", value); }
+ }
+
+ public virtual Color ColorInactiveBorder{
+ get { return SystemColors.InactiveBorder;}
+ set { SetSystemColors("inactive_border", value); }
+ }
+
+ public virtual Color ColorAppWorkspace {
+ get { return SystemColors.AppWorkspace;}
+ set { SetSystemColors("app_workspace", value); }
+ }
+
+ public virtual Color ColorHighlight {
+ get { return SystemColors.Highlight;}
+ set { SetSystemColors("highlight", value); }
+ }
+
+ public virtual Color ColorHighlightText {
+ get { return SystemColors.HighlightText;}
+ set { SetSystemColors("highlight_text", value); }
+ }
+
+ public virtual Color ColorControl {
+ get { return SystemColors.Control;}
+ set { SetSystemColors("control", value); }
+ }
+
+ public virtual Color ColorControlDark {
+ get { return SystemColors.ControlDark;}
+ set { SetSystemColors("control_dark", value); }
+ }
+
+ public virtual Color ColorGrayText {
+ get { return SystemColors.GrayText;}
+ set { SetSystemColors("gray_text", value); }
+ }
+
+ public virtual Color ColorControlText {
+ get { return SystemColors.ControlText;}
+ set { SetSystemColors("control_text", value); }
+ }
+
+ public virtual Color ColorInactiveCaptionText {
+ get { return SystemColors.InactiveCaptionText;}
+ set { SetSystemColors("inactive_caption_text", value); }
+ }
+
+ public virtual Color ColorControlLight {
+ get { return SystemColors.ControlLight;}
+ set { SetSystemColors("control_light", value); }
+ }
+
+ public virtual Color ColorControlDarkDark {
+ get { return SystemColors.ControlDarkDark;}
+ set { SetSystemColors("control_dark_dark", value); }
+ }
+
+ public virtual Color ColorControlLightLight {
+ get { return SystemColors.ControlLightLight;}
+ set { SetSystemColors("control_light_light", value); }
+ }
+
+ public virtual Color ColorInfoText {
+ get { return SystemColors.InfoText;}
+ set { SetSystemColors("info_text", value); }
+ }
+
+ public virtual Color ColorInfo {
+ get { return SystemColors.Info;}
+ set { SetSystemColors("info", value); }
+ }
+
+ public virtual Color ColorHotTrack {
+ get { return SystemColors.HotTrack;}
+ set { SetSystemColors("hot_track", value);}
+ }
+
+ public virtual Color DefaultControlBackColor {
+ get { return ColorControl; }
+ set { ColorControl = value; }
+ }
+
+ public virtual Color DefaultControlForeColor {
+ get { return ColorControlText; }
+ set { ColorControlText = value; }
+ }
+
+ public virtual Font DefaultFont {
+ get { return default_font; }
+ }
+
+ public virtual Color DefaultWindowBackColor {
+ get { return defaultWindowBackColor; }
+ }
+
+ public virtual Color DefaultWindowForeColor {
+ get { return defaultWindowForeColor; }
+ }
+
+ public virtual Color GetColor (XplatUIWin32.GetSysColorIndex idx)
+ {
+ return (Color) syscolors.GetValue ((int)idx);
+ }
+
+ public virtual void SetColor (XplatUIWin32.GetSysColorIndex idx, Color color)
+ {
+ syscolors.SetValue (color, (int) idx);
+ }
+
+ // Theme/UI specific defaults
+ public virtual ArrangeDirection ArrangeDirection {
+ get {
+ return ArrangeDirection.Down;
+ }
+ }
+
+ public virtual ArrangeStartingPosition ArrangeStartingPosition {
+ get {
+ return ArrangeStartingPosition.BottomLeft;
+ }
+ }
+
+ public virtual Size Border3DSize {
+ get {
+ return new Size(2, 2);
+ }
+ }
+
+ public virtual Size BorderSize {
+ get {
+ return new Size(1, 1);
+ }
+ }
+
+ public virtual Size CaptionButtonSize {
+ get {
+ return new Size(18, 18);
+ }
+ }
+
+ public virtual int CaptionHeight {
+ get {
+ return XplatUI.CaptionHeight;
+ }
+ }
+
+ public virtual Size DoubleClickSize {
+ get {
+ return new Size(4, 4);
+ }
+ }
+
+ public virtual int DoubleClickTime {
+ get {
+ return 500;
+ }
+ }
+
+ public virtual Size FixedFrameBorderSize {
+ get {
+ return new Size(3, 3);
+ }
+ }
+
+ public virtual Size FrameBorderSize {
+ get {
+ return XplatUI.FrameBorderSize;
+ }
+ }
+
+ public virtual int HorizontalScrollBarArrowWidth {
+ get {
+ return 16;
+ }
+ }
+
+ public virtual int HorizontalScrollBarHeight {
+ get {
+ return 16;
+ }
+ }
+
+ public virtual int HorizontalScrollBarThumbWidth {
+ get {
+ return 16;
+ }
+ }
+
+ public virtual Size IconSpacingSize {
+ get {
+ return new Size(75, 75);
+ }
+ }
+
+ public virtual Size MenuButtonSize {
+ get {
+ return new Size(18, 18);
+ }
+ }
+
+ public virtual Size MenuCheckSize {
+ get {
+ return new Size(13, 13);
+ }
+ }
+
+ public virtual Font MenuFont {
+ get {
+ return default_font;
+ }
+ }
+
+ public virtual int MenuHeight {
+ get {
+ return 19;
+ }
+ }
+
+ public virtual int MouseWheelScrollLines {
+ get {
+ return 3;
+ }
+ }
+
+ public virtual bool RightAlignedMenus {
+ get {
+ return false;
+ }
+ }
+
+ public virtual Size ToolWindowCaptionButtonSize {
+ get {
+ return new Size(15, 15);
+ }
+ }
+
+ public virtual int ToolWindowCaptionHeight {
+ get {
+ return 16;
+ }
+ }
+
+ public virtual int VerticalScrollBarArrowHeight {
+ get {
+ return 16;
+ }
+ }
+
+ public virtual int VerticalScrollBarThumbHeight {
+ get {
+ return 16;
+ }
+ }
+
+ public virtual int VerticalScrollBarWidth {
+ get {
+ return 16;
+ }
+ }
+
+ [MonoTODO("Figure out where to point for My Network Places")]
+ public virtual string Places(UIIcon index) {
+ switch (index) {
+ case UIIcon.PlacesRecentDocuments: {
+ // Default = "Recent Documents"
+ return Environment.GetFolderPath(Environment.SpecialFolder.Recent);
+ }
+
+ case UIIcon.PlacesDesktop: {
+ // Default = "Desktop"
+ return Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
+ }
+
+ case UIIcon.PlacesPersonal: {
+ // Default = "My Documents"
+ return Environment.GetFolderPath(Environment.SpecialFolder.Personal);
+ }
+
+ case UIIcon.PlacesMyComputer: {
+ // Default = "My Computer"
+ return Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
+ }
+
+ case UIIcon.PlacesMyNetwork: {
+ // Default = "My Network Places"
+ return "/tmp";
+ }
+
+ default: {
+ throw new ArgumentOutOfRangeException("index", index, "Unsupported place");
+ }
+ }
+ }
+
+ private Image GetSizedResourceImage(string name, int size) {
+
+ Image image = ResPool.GetUIImage (name, size);
+ if (image != null)
+ return image;
+
+ string fullname;
+
+ if (size > 0) {
+ // Try name name_sizexsize
+ fullname = String.Format("{0}_{1}x{1}", name, size);
+ image = ResPool.GetUIImage (fullname, size);
+ if (image != null)
+ return image;
+ else {
+ image = (Image)Locale.GetResource(fullname);
+ if (image != null) {
+ ResPool.AddUIImage (image, fullname, size);
+ return image;
+ }
+ }
+
+ // Try name_size
+ fullname = String.Format("{0}_{1}", name, size);
+ image = ResPool.GetUIImage (fullname, size);
+ if (image != null)
+ return image;
+ else {
+ image = (Image)Locale.GetResource(fullname);
+ if (image != null) {
+ ResPool.AddUIImage (image, fullname, size);
+ return image;
+ }
+ }
+
+ image = (Image)Locale.GetResource(name);
+ if (image != null) {
+ image = new Bitmap (image, new Size (size, size));
+ ResPool.AddUIImage (image, name, size);
+ return image;
+ }
+ }
+
+ // Just try name
+ image = (Image)Locale.GetResource(name);
+ ResPool.AddUIImage (image, name, size);
+ return image;
+ }
+
+ public virtual Image Images(UIIcon index) {
+ return Images(index, 0);
+ }
+
+ public virtual Image Images(UIIcon index, int size) {
+ switch (index) {
+ case UIIcon.PlacesRecentDocuments: return GetSizedResourceImage ("last_open", size);
+ case UIIcon.PlacesDesktop: return GetSizedResourceImage ("desktop", size);
+ case UIIcon.PlacesPersonal: return GetSizedResourceImage ("folder_with_paper", size);
+ case UIIcon.PlacesMyComputer: return GetSizedResourceImage ("monitor-computer", size);
+ case UIIcon.PlacesMyNetwork: return GetSizedResourceImage ("monitor-planet", size);
+
+ // Icons for message boxes
+ case UIIcon.MessageBoxError: return GetSizedResourceImage ("mbox_error.png", size);
+ case UIIcon.MessageBoxInfo: return GetSizedResourceImage ("mbox_info.png", size);
+ case UIIcon.MessageBoxQuestion: return GetSizedResourceImage ("mbox_question.png", size);
+ case UIIcon.MessageBoxWarning: return GetSizedResourceImage ("mbox_warn.png", size);
+
+ // misc Icons
+ case UIIcon.NormalFolder: return GetSizedResourceImage ("folder", size);
+
+ default: {
+ throw new ArgumentException("Invalid Icon type requested", "index");
+ }
+ }
+ return null;
+ }
+
+ public virtual Image Images(string mimetype, string extension, int size) {
+ return null;
+ }
+
+ #region Principal Theme Methods
+ // To let the theme now that a change of defaults (colors, etc) was detected and force a re-read (and possible recreation of cached resources)
+ public abstract void ResetDefaults();
+
+ // If the theme writes directly to a window instead of a device context
+ public abstract bool DoubleBufferingSupported {get;}
+ #endregion // Principal Theme Methods
+
+ #region OwnerDraw Support
+ public abstract void DrawOwnerDrawBackground (DrawItemEventArgs e);
+ public abstract void DrawOwnerDrawFocusRectangle (DrawItemEventArgs e);
+ #endregion // OwnerDraw Support
+
+ #region Button
+ #endregion // Button
+
+ #region ButtonBase
+ // Drawing
+ public abstract void DrawButtonBase(Graphics dc, Rectangle clip_area, ButtonBase button);
+
+ // Sizing
+ public abstract Size ButtonBaseDefaultSize{get;}
+ #endregion // ButtonBase
+
+ #region CheckBox
+ public abstract void DrawCheckBox(Graphics dc, Rectangle clip_area, CheckBox checkbox);
+ #endregion // CheckBox
+
+ #region CheckedListBox
+ // Drawing
+ public abstract void DrawCheckedListBoxItem (CheckedListBox ctrl, DrawItemEventArgs e);
+ public abstract Rectangle CheckedListBoxCheckRectangle ();
+ #endregion // CheckedListBox
+
+ #region ComboBox
+ // Drawing
+ public abstract void DrawComboBoxEditDecorations (Graphics dc, ComboBox ctrl, Rectangle rect);
+ public abstract void DrawComboListBoxDecorations (Graphics dc, ComboBox ctrl, Rectangle rect);
+ public abstract void DrawComboBoxItem (ComboBox ctrl, DrawItemEventArgs e);
+
+ // Sizing
+ public abstract int DrawComboBoxEditDecorationTop ();
+ public abstract int DrawComboBoxEditDecorationBottom ();
+ public abstract int DrawComboBoxEditDecorationRight ();
+ public abstract int DrawComboBoxEditDecorationLeft ();
+ public abstract int DrawComboListBoxDecorationTop (ComboBoxStyle style);
+ public abstract int DrawComboListBoxDecorationBottom (ComboBoxStyle style);
+ public abstract int DrawComboListBoxDecorationRight (ComboBoxStyle style);
+ public abstract int DrawComboListBoxDecorationLeft (ComboBoxStyle style);
+ #endregion // ComboBox
+
+ #region Control
+ #endregion // Control
+
+ #region Datagrid
+ public abstract int DataGridPreferredColumnWidth { get; }
+ public abstract int DataGridMinimumColumnCheckBoxHeight { get; }
+ public abstract int DataGridMinimumColumnCheckBoxWidth { get; }
+
+ // Default colours
+ public abstract Color DataGridAlternatingBackColor { get; }
+ public abstract Color DataGridBackColor { get; }
+ public abstract Color DataGridBackgroundColor { get; }
+ public abstract Color DataGridCaptionBackColor { get; }
+ public abstract Color DataGridCaptionForeColor { get; }
+ public abstract Color DataGridGridLineColor { get; }
+ public abstract Color DataGridHeaderBackColor { get; }
+ public abstract Color DataGridHeaderForeColor { get; }
+ public abstract Color DataGridLinkColor { get; }
+ public abstract Color DataGridLinkHoverColor { get; }
+ public abstract Color DataGridParentRowsBackColor { get; }
+ public abstract Color DataGridParentRowsForeColor { get; }
+ public abstract Color DataGridSelectionBackColor { get; }
+ public abstract Color DataGridSelectionForeColor { get; }
+ // Paint
+ public abstract void DataGridPaint (PaintEventArgs pe, DataGrid grid);
+ public abstract void DataGridPaintCaption (Graphics g, Rectangle clip, DataGrid grid);
+ public abstract void DataGridPaintColumnsHdrs (Graphics g, Rectangle clip, DataGrid grid);
+ public abstract void DataGridPaintRowsHeaders (Graphics g, Rectangle clip, DataGrid grid);
+ public abstract void DataGridPaintRowHeader (Graphics g, Rectangle bounds, int row, DataGrid grid);
+ public abstract void DataGridPaintRowHeaderArrow (Graphics g, Rectangle bounds, DataGrid grid);
+ public abstract void DataGridPaintRows (Graphics g, Rectangle cells, Rectangle clip, DataGrid grid);
+ public abstract void DataGridPaintRow (Graphics g, int row, Rectangle row_rect, bool is_newrow, DataGrid grid);
+
+
+ #endregion // Datagrid
+
+ #region DateTimePicker
+
+ public abstract void DrawDateTimePicker(Graphics dc, Rectangle clip_rectangle, DateTimePicker dtp);
+
+ #endregion // DateTimePicker
+
+ #region GroupBox
+ // Drawing
+ public abstract void DrawGroupBox (Graphics dc, Rectangle clip_area, GroupBox box);
+
+ // Sizing
+ public abstract Size GroupBoxDefaultSize{get;}
+ #endregion // GroupBox
+
+ #region HScrollBar
+ public abstract Size HScrollBarDefaultSize{get;} // Default size of the scrollbar
+ #endregion // HScrollBar
+
+ #region Label
+ // Drawing
+ public abstract void DrawLabel (Graphics dc, Rectangle clip_rectangle, Label label);
+
+ // Sizing
+ public abstract Size LabelDefaultSize{get;}
+ #endregion // Label
+
+ #region LinkLabel
+ public abstract void DrawLinkLabel (Graphics dc, Rectangle clip_rectangle, LinkLabel label);
+ #endregion // LinkLabel
+
+ #region ListBox
+ // Drawing
+ public abstract void DrawListBoxItem (ListBox ctrl, DrawItemEventArgs e);
+ #endregion // ListBox
+
+ #region ListView
+ // Drawing
+ public abstract void DrawListViewItems (Graphics dc, Rectangle clip_rectangle, ListView control);
+ public abstract void DrawListViewHeader (Graphics dc, Rectangle clip_rectangle, ListView control);
+ public abstract void DrawListViewHeaderDragDetails (Graphics dc, ListView control, ColumnHeader drag_column, int target_x);
+
+ // Sizing
+ public abstract Size ListViewCheckBoxSize { get; }
+ public abstract int ListViewColumnHeaderHeight { get; }
+ public abstract int ListViewDefaultColumnWidth { get; }
+ public abstract int ListViewVerticalSpacing { get; }
+ public abstract int ListViewEmptyColumnWidth { get; }
+ public abstract int ListViewHorizontalSpacing { get; }
+ public abstract Size ListViewDefaultSize { get; }
+ #endregion // ListView
+
+ #region Menus
+ public abstract void CalcItemSize (Graphics dc, MenuItem item, int y, int x, bool menuBar);
+ public abstract void CalcPopupMenuSize (Graphics dc, Menu menu);
+ public abstract int CalcMenuBarSize (Graphics dc, Menu menu, int width);
+ public abstract void DrawMenuBar (Graphics dc, Menu menu, Rectangle rect);
+ public abstract void DrawMenuItem (MenuItem item, DrawItemEventArgs e);
+ public abstract void DrawPopupMenu (Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect);
+ #endregion // Menus
+
+ #region MonthCalendar
+ public abstract void DrawMonthCalendar(Graphics dc, Rectangle clip_rectangle, MonthCalendar month_calendar);
+ #endregion // MonthCalendar
+
+ #region Panel
+ // Sizing
+ public abstract Size PanelDefaultSize{get;}
+ #endregion // Panel
+
+ #region PictureBox
+ // Drawing
+ public abstract void DrawPictureBox (Graphics dc, Rectangle clip, PictureBox pb);
+
+ // Sizing
+ public abstract Size PictureBoxDefaultSize{get;}
+ #endregion // PictureBox
+
+ #region ProgressBar
+ // Drawing
+ public abstract void DrawProgressBar (Graphics dc, Rectangle clip_rectangle, ProgressBar progress_bar);
+
+ // Sizing
+ public abstract Size ProgressBarDefaultSize{get;}
+ #endregion // ProgressBar
+
+ #region RadioButton
+ // Drawing
+ public abstract void DrawRadioButton (Graphics dc, Rectangle clip_rectangle, RadioButton radio_button);
+
+ // Sizing
+ public abstract Size RadioButtonDefaultSize{get;}
+ #endregion // RadioButton
+
+ #region ScrollBar
+ // Drawing
+ //public abstract void DrawScrollBar (Graphics dc, Rectangle area, ScrollBar bar, ref Rectangle thumb_pos, ref Rectangle first_arrow_area, ref Rectangle second_arrow_area, ButtonState first_arrow, ButtonState second_arrow, ref int scrollbutton_width, ref int scrollbutton_height, bool vert);
+ public abstract void DrawScrollBar (Graphics dc, Rectangle clip_rectangle, ScrollBar bar);
+
+ // Sizing
+ public abstract int ScrollBarButtonSize {get;} // Size of the scroll button
+ #endregion // ScrollBar
+
+ #region StatusBar
+ // Drawing
+ public abstract void DrawStatusBar (Graphics dc, Rectangle clip_rectangle, StatusBar sb);
+
+ // Sizing
+ public abstract int StatusBarSizeGripWidth {get;} // Size of Resize area
+ public abstract int StatusBarHorzGapWidth {get;} // Gap between panels
+ public abstract Size StatusBarDefaultSize{get;}
+ #endregion // StatusBar
+
+ #region TabControl
+ public abstract Size TabControlDefaultItemSize { get; }
+ public abstract Point TabControlDefaultPadding { get; }
+ public abstract int TabControlMinimumTabWidth { get; }
+
+ public abstract Rectangle GetTabControlLeftScrollRect (TabControl tab);
+ public abstract Rectangle GetTabControlRightScrollRect (TabControl tab);
+ public abstract Rectangle GetTabControlDisplayRectangle (TabControl tab);
+ public abstract Size TabControlGetSpacing (TabControl tab);
+ public abstract void DrawTabControl (Graphics dc, Rectangle area, TabControl tab);
+ #endregion
+
+ #region ToolBar
+ // Drawing
+ public abstract void DrawToolBar (Graphics dc, Rectangle clip_rectangle, ToolBar control);
+
+ // Sizing
+ public abstract int ToolBarGripWidth {get;} // Grip width for the ToolBar
+ public abstract int ToolBarImageGripWidth {get;} // Grip width for the Image on the ToolBarButton
+ public abstract int ToolBarSeparatorWidth {get;} // width of the separator
+ public abstract int ToolBarDropDownWidth { get; } // width of the dropdown arrow rect
+ public abstract int ToolBarDropDownArrowWidth { get; } // width for the dropdown arrow on the ToolBarButton
+ public abstract int ToolBarDropDownArrowHeight { get; } // height for the dropdown arrow on the ToolBarButton
+ public abstract Size ToolBarDefaultSize{get;}
+ #endregion // ToolBar
+
+ #region ToolTip
+ public abstract void DrawToolTip(Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control);
+ public abstract Size ToolTipSize(ToolTip.ToolTipWindow tt, string text);
+ #endregion // ToolTip
+
+
+ #region TrackBar
+ // Drawing
+ public abstract void DrawTrackBar (Graphics dc, Rectangle clip_rectangle, TrackBar tb);
+
+ // Sizing
+ public abstract Size TrackBarDefaultSize{get; } // Default size for the TrackBar control
+ #endregion // TrackBar
+
+ #region VScrollBar
+ public abstract Size VScrollBarDefaultSize{get;} // Default size of the scrollbar
+ #endregion // VScrollBar
+
+ #region TreeView
+ public abstract Size TreeViewDefaultSize { get; }
+ #endregion
+
+ #region ControlPaint Methods
+ public abstract void CPDrawBorder (Graphics graphics, Rectangle bounds, Color leftColor, int leftWidth,
+ ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
+ Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor,
+ int bottomWidth, ButtonBorderStyle bottomStyle);
+
+ public abstract void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides);
+ public abstract void CPDrawButton (Graphics graphics, Rectangle rectangle, ButtonState state);
+ public abstract void CPDrawCaptionButton (Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state);
+ public abstract void CPDrawCheckBox (Graphics graphics, Rectangle rectangle, ButtonState state);
+ public abstract void CPDrawComboButton (Graphics graphics, Rectangle rectangle, ButtonState state);
+ public abstract void CPDrawContainerGrabHandle (Graphics graphics, Rectangle bounds);
+ public abstract void CPDrawFocusRectangle (Graphics graphics, Rectangle rectangle, Color foreColor, Color backColor);
+ public abstract void CPDrawGrabHandle (Graphics graphics, Rectangle rectangle, bool primary, bool enabled);
+ public abstract void CPDrawGrid (Graphics graphics, Rectangle area, Size pixelsBetweenDots, Color backColor);
+ public abstract void CPDrawImageDisabled (Graphics graphics, Image image, int x, int y, Color background);
+ public abstract void CPDrawLockedFrame (Graphics graphics, Rectangle rectangle, bool primary);
+ public abstract void CPDrawMenuGlyph (Graphics graphics, Rectangle rectangle, MenuGlyph glyph, Color color);
+ public abstract void CPDrawRadioButton (Graphics graphics, Rectangle rectangle, ButtonState state);
+ public abstract void CPDrawReversibleFrame (Rectangle rectangle, Color backColor, FrameStyle style);
+ public abstract void CPDrawReversibleLine (Point start, Point end, Color backColor);
+ public abstract void CPDrawScrollButton (Graphics graphics, Rectangle rectangle, ScrollButton button, ButtonState state);
+ public abstract void CPDrawSelectionFrame (Graphics graphics, bool active, Rectangle outsideRect, Rectangle insideRect,
+ Color backColor);
+ public abstract void CPDrawSizeGrip (Graphics graphics, Color backColor, Rectangle bounds);
+ public abstract void CPDrawStringDisabled (Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle,
+ StringFormat format);
+ public abstract void CPDrawBorderStyle (Graphics dc, Rectangle area, BorderStyle border_style);
+ #endregion // ControlPaint Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeClearlooks.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeClearlooks.cs
new file mode 100644
index 00000000000..633a4b33422
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeClearlooks.cs
@@ -0,0 +1,3405 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Alexander Olk, alex.olk@googlemail.com
+//
+// based on ThemeWin32Classic
+//
+// - You can activate this Theme with export MONO_THEME=clearlooks
+//
+// This theme tries to match clearlooks theme
+//
+// TODO:
+// - if an other control draws over a ScrollBar button you can see artefacts on the rounded edges
+// (maybe use theme backcolor, but that looks ugly on a white background, need to find a way to get the backcolor of the parent control)
+// - more correct drawing of disabled controls
+
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+using System.Drawing.Text;
+
+namespace System.Windows.Forms {
+ internal class ThemeClearlooks : ThemeWin32Classic {
+ public override Version Version {
+ get {
+ return new Version( 0, 0, 0, 2 );
+ }
+ }
+
+ static readonly Color theme_back_color = Color.FromArgb( 239, 235, 231 );
+
+ static readonly Color gradient_first_color = Color.FromArgb( 250, 248, 247 );
+ static readonly Color gradient_second_color = Color.FromArgb( 226, 219, 212 );
+ static readonly Color gradient_second_color_nr2 = Color.FromArgb( 234, 229, 224 );
+ static readonly Color pressed_gradient_first_color = Color.FromArgb( 217, 207, 202 );
+ static readonly Color pressed_gradient_second_color = Color.FromArgb( 199, 193, 187 );
+ static readonly Color border_normal_dark_color = Color.FromArgb( 129, 117, 106 );
+ static readonly Color border_normal_light_color = Color.FromArgb( 158, 145, 131 );
+ static readonly Color border_pressed_dark_color = Color.FromArgb( 109, 103, 98 );
+ static readonly Color border_pressed_light_color = Color.FromArgb( 120, 114, 107 );
+ static readonly Color button_outer_border_dark_color = Color.FromArgb( 232, 226, 220 );
+ static readonly Color button_outer_border_light_color = Color.FromArgb( 250, 248, 247 );
+ static readonly Color inner_border_dark_color = Color.FromArgb( 226, 219, 212 );
+ static readonly Color pressed_inner_border_dark_color = Color.FromArgb( 192, 181, 169 );
+ static readonly Color edge_top_inner_color = Color.FromArgb( 206, 200, 194 );
+ static readonly Color edge_bottom_inner_color = Color.FromArgb( 215, 209, 202 );
+ static readonly Color button_edge_top_outer_color = Color.FromArgb( 237, 233, 228 );
+ static readonly Color button_edge_bottom_outer_color = Color.FromArgb( 243, 239, 236 );
+ static readonly Color button_focus_color = Color.FromArgb( 101, 94, 86 );
+ static readonly Color button_mouse_entered_second_gradient_color = Color.FromArgb( 230, 226, 219 );
+
+ static readonly Color scrollbar_background_color = Color.FromArgb( 209, 200, 191 );
+ static readonly Color scrollbar_border_color = Color.FromArgb( 170, 156, 143 );
+ static readonly Color scrollbar_gradient_first_color = Color.FromArgb( 248, 247, 245 );
+ static readonly Color scrollbar_gradient_second_color = Color.FromArgb( 234, 229, 224 );
+
+ static readonly Color arrow_color = Color.FromArgb( 16, 16, 16 );
+
+ static readonly Color tab_border_color = Color.FromArgb( 166, 151, 138 );
+ static readonly Color tab_not_selected_gradient_first_color = Color.FromArgb( 227, 223, 220 );
+ static readonly Color tab_not_selected_gradient_second_color = Color.FromArgb( 214, 209, 204 );
+ static readonly Color tab_selected_gradient_first_color = Color.FromArgb( 243, 239, 236 );
+ static readonly Color tab_selected_gradient_second_color = Color.FromArgb( 234, 228, 223 );
+ static readonly Color tab_edge_color = Color.FromArgb( 200, 196, 191 );
+ static readonly Color tab_inner_border_color = Color.FromArgb( 221, 212, 205 );
+ static readonly Color tab_top_border_focus_color = Color.FromArgb( 70, 91, 110 );
+ static readonly Color tab_focus_color = Color.FromArgb( 105, 147, 185 );
+
+ static readonly Color menuitem_gradient_first_color = Color.FromArgb( 98, 140, 178 );
+ static readonly Color menuitem_gradient_second_color = Color.FromArgb( 81, 113, 142 );
+ static readonly Color menuitem_border_color = Color.FromArgb( 80, 112, 141 );
+ static readonly Color menu_separator_color = Color.FromArgb( 219, 211, 203 );
+ static readonly Color menu_background_color = Color.FromArgb( 248, 245, 242 );
+ static readonly Color menu_border_color = Color.FromArgb( 141, 122, 104 );
+ static readonly Color menu_inner_border_color = Color.FromArgb( 236, 228, 221 );
+
+ static readonly Color combobox_border_color = Color.FromArgb( 159, 146, 132 );
+ static readonly Color combobox_focus_border_color = Color.FromArgb( 70, 91, 110 );
+ static readonly Color combobox_focus_inner_border_color = Color.FromArgb( 167, 198, 225 );
+ static readonly Color combobox_button_second_gradient_color = Color.FromArgb( 226, 220, 213 );
+
+ static readonly Color progressbar_edge_dot_color = Color.FromArgb( 219, 212, 205 );
+ static readonly Color progressbar_inner_border_color = Color.FromArgb( 139, 176, 209 );
+ static readonly Color progressbar_first_gradient_color = Color.FromArgb( 104, 146, 184 );
+ static readonly Color progressbar_second_gradient_color = Color.FromArgb( 91, 133, 172 );
+
+ static readonly Color checkbox_inner_boder_color = Color.FromArgb( 237, 234, 231 );
+ static readonly Color checkbox_pressed_inner_boder_color = Color.FromArgb( 203, 196, 189 );
+ static readonly Color checkbox_pressed_backcolor = Color.FromArgb( 212, 207, 202 );
+
+ static readonly Color trackbar_second_gradient_color = Color.FromArgb( 114, 154, 190 );
+ static readonly Color trackbar_third_gradient_color = Color.FromArgb( 130, 168, 202 );
+ static readonly Color trackbar_inner_first_gradient_color = Color.FromArgb( 238, 233, 229 );
+ static readonly Color trackbar_inner_second_gradient_color = Color.FromArgb( 223, 215, 208 );
+ static readonly Color trackbar_inner_pressed_second_gradient_color = Color.FromArgb( 224, 217, 210 );
+
+ static readonly Color disabled_color_foreground = Color.FromArgb( 182, 180, 173 );
+
+ static readonly Color active_caption = Color.FromArgb( 85, 152, 215 );
+
+ static readonly Color radio_button_border_circle_color = Color.FromArgb( 126, 118, 105 );
+ static readonly Color radio_button_dot_color = Color.FromArgb( 94, 160, 221 );
+
+ const int SEPARATOR_HEIGHT = 7;
+ const int MENU_TAB_SPACE = 8; // Pixels added to the width of an item because of a tab
+ const int MENU_BAR_ITEMS_SPACE = 8; // Space between menu bar items
+
+ int platform = (int) Environment.OSVersion.Platform;
+
+ static Color control_parent_backcolor;
+
+ #region Principal Theme Methods
+ public ThemeClearlooks( ) {
+ ColorControl = theme_back_color;
+ always_draw_hotkeys = true;
+ }
+
+ public override Color DefaultControlBackColor {
+ get { return theme_back_color; }
+ }
+
+ public override Color DefaultWindowBackColor {
+ get { return theme_back_color; }
+ }
+
+ public override Color ColorControl {
+ get { return theme_back_color;}
+ }
+
+ public override Color ColorHighlight {
+ get { return menuitem_gradient_first_color; }
+ }
+
+ public override Color ColorActiveCaption {
+ get { return active_caption; }
+ }
+
+ public override Size Border3DSize {
+ get {
+ return new Size( 3, 3 );
+ }
+ }
+
+ public override Image Images(UIIcon index, int size) {
+ switch (index) {
+ case UIIcon.PlacesRecentDocuments:
+ if ((platform == 4) || (platform == 128))
+ return MimeIconEngine.GetIconForMimeTypeAndSize( "recently/recently", new Size(size, size) );
+ else
+ return base.Images (UIIcon.PlacesRecentDocuments, size);
+ case UIIcon.PlacesDesktop:
+ if ((platform == 4) || (platform == 128))
+ return MimeIconEngine.GetIconForMimeTypeAndSize( "desktop/desktop", new Size(size, size) );
+ else
+ return base.Images (UIIcon.PlacesDesktop, size);
+ case UIIcon.PlacesPersonal:
+ if ((platform == 4) || (platform == 128))
+ return MimeIconEngine.GetIconForMimeTypeAndSize( "directory/home", new Size(size, size) );
+ else
+ return base.Images (UIIcon.PlacesPersonal, size);
+ case UIIcon.PlacesMyComputer:
+ if ((platform == 4) || (platform == 128))
+ return MimeIconEngine.GetIconForMimeTypeAndSize( "workplace/workplace", new Size(size, size) );
+ else
+ return base.Images (UIIcon.PlacesMyComputer, size);
+ case UIIcon.PlacesMyNetwork:
+ if ((platform == 4) || (platform == 128))
+ return MimeIconEngine.GetIconForMimeTypeAndSize( "network/network", new Size(size, size) );
+ else
+ return base.Images (UIIcon.PlacesMyNetwork, size);
+
+ // Icons for message boxes
+ case UIIcon.MessageBoxError: return base.Images (UIIcon.MessageBoxError, size);
+ case UIIcon.MessageBoxInfo: return base.Images (UIIcon.MessageBoxInfo, size);
+ case UIIcon.MessageBoxQuestion: return base.Images (UIIcon.MessageBoxQuestion, size);
+ case UIIcon.MessageBoxWarning: return base.Images (UIIcon.MessageBoxWarning, size);
+
+ // misc Icons
+ case UIIcon.NormalFolder:
+ if ((platform == 4) || (platform == 128))
+ return MimeIconEngine.GetIconForMimeTypeAndSize( "inode/directory", new Size(size, size) );
+ else
+ return base.Images (UIIcon.NormalFolder, size);
+
+ default: {
+ throw new ArgumentException("Invalid Icon type requested", "index");
+ }
+ }
+ }
+ #endregion // Internal Methods
+
+ #region ButtonBase
+ protected override void ButtonBase_DrawButton( ButtonBase button, Graphics dc ) {
+ dc.FillRectangle( ResPool.GetSolidBrush( button.BackColor ), button.ClientRectangle );
+
+ Color first_gradient_color = gradient_first_color;
+ Color second_gradient_color = gradient_second_color;
+
+ if (((button is CheckBox) && (((CheckBox)button).check_state == CheckState.Checked)) ||
+ ((button is RadioButton) && (((RadioButton)button).check_state == CheckState.Checked))) {
+ first_gradient_color = button.is_entered ? gradient_second_color : pressed_gradient_first_color;
+ second_gradient_color = button.is_entered ? gradient_second_color : pressed_gradient_second_color;
+ } else
+ if (!button.is_enabled) {
+ button.is_entered = false;
+ } else
+ if (button.is_entered) {
+ if (!button.is_pressed) {
+ first_gradient_color = Color.White;
+ second_gradient_color = button_mouse_entered_second_gradient_color;
+ } else {
+ first_gradient_color = pressed_gradient_first_color;
+ second_gradient_color = pressed_gradient_second_color;
+ }
+ }
+
+ bool paint_acceptbutton_black_border = false;
+ Form form = button.TopLevelControl as Form;
+
+ if (form != null && (form.AcceptButton == button as IButtonControl))
+ paint_acceptbutton_black_border = true;
+
+ CL_Draw_Button(dc, button.ClientRectangle, button.flat_style,
+ button.is_entered, button.is_enabled, button.is_pressed,
+ first_gradient_color, second_gradient_color,
+ paint_acceptbutton_black_border);
+ }
+
+ private void CL_Draw_Button(Graphics dc, Rectangle buttonRectangle, FlatStyle flat_style,
+ bool is_entered, bool is_enabled, bool is_pressed,
+ Color first_gradient_color, Color second_gradient_color,
+ bool paint_acceptbutton_black_border)
+ {
+ Rectangle lgbRectangle = new Rectangle (buttonRectangle.X + 3, buttonRectangle.Y + 3,
+ is_pressed ? buttonRectangle.Width - 5 : buttonRectangle.Width - 6,
+ buttonRectangle.Height - 6);
+
+ if (flat_style != FlatStyle.Popup || ((flat_style == FlatStyle.Popup) && is_entered)) {
+ LinearGradientBrush lgbr;
+ if (flat_style == FlatStyle.Flat)
+ lgbr = new LinearGradientBrush (new Point (buttonRectangle.X, buttonRectangle.Y + 3),
+ new Point (buttonRectangle.X, buttonRectangle.Bottom - 3),
+ second_gradient_color, first_gradient_color);
+ else
+ lgbr = new LinearGradientBrush (new Point (buttonRectangle.X, buttonRectangle.Y + 3),
+ new Point (buttonRectangle.X, buttonRectangle.Bottom - 3),
+ first_gradient_color, second_gradient_color);
+ dc.FillRectangle (lgbr, lgbRectangle);
+ lgbr.Dispose ();
+
+ Point[] points_top = {
+ new Point (buttonRectangle.X + 2, buttonRectangle.Y + 2),
+ new Point (buttonRectangle.X + 3, buttonRectangle.Y + 1),
+ new Point (buttonRectangle.Right - 4, buttonRectangle.Y + 1),
+ new Point (buttonRectangle.Right - 3 , buttonRectangle.Y + 2)
+ };
+
+ Point[] points_bottom = {
+ new Point (buttonRectangle.X + 2, buttonRectangle.Bottom - 3),
+ new Point (buttonRectangle.X + 3, buttonRectangle.Bottom - 2),
+ new Point (buttonRectangle.Right - 4, buttonRectangle.Bottom - 2),
+ new Point (buttonRectangle.Right - 3, buttonRectangle.Bottom - 3)
+ };
+
+ Point[] points_top_outer = {
+ new Point (buttonRectangle.X + 1, buttonRectangle.Y + 1),
+ new Point (buttonRectangle.X + 2, buttonRectangle.Y),
+ new Point (buttonRectangle.Right - 3, buttonRectangle.Y),
+ new Point (buttonRectangle.Right - 2 , buttonRectangle.Y + 1)
+ };
+
+ Point[] points_bottom_outer = {
+ new Point (buttonRectangle.X + 1, buttonRectangle.Bottom - 2),
+ new Point (buttonRectangle.X + 2, buttonRectangle.Bottom - 1),
+ new Point (buttonRectangle.Right - 3, buttonRectangle.Bottom - 1),
+ new Point (buttonRectangle.Right - 2, buttonRectangle.Bottom - 2)
+ };
+
+ Pen pen = null;
+
+ // normal border
+ if (is_enabled) {
+ Color top_color = Color.Black;
+ Color bottom_color = Color.Black;
+
+ if (!paint_acceptbutton_black_border) {
+ top_color = is_pressed ? border_pressed_dark_color : border_normal_dark_color;
+ bottom_color = is_pressed ? border_pressed_light_color : border_normal_light_color;
+ }
+
+ pen = ResPool.GetPen (top_color);
+ dc.DrawLines (pen, points_top);
+ pen = ResPool.GetPen (bottom_color);
+ dc.DrawLines (pen, points_bottom);
+
+ using (LinearGradientBrush lgbr2 = new LinearGradientBrush (new Point (buttonRectangle.X, buttonRectangle.Y + 3),
+ new Point (buttonRectangle.X, buttonRectangle.Bottom - 3),
+ top_color, bottom_color)) {
+ dc.FillRectangle (lgbr2, buttonRectangle.X + 1, buttonRectangle.Y + 3, 1, buttonRectangle.Height - 6);
+ dc.FillRectangle (lgbr2, buttonRectangle.Right - 2, buttonRectangle.Y + 3, 1, buttonRectangle.Height - 6);
+ }
+ } else {
+ Point[] points_button_complete = {
+ new Point (buttonRectangle.X + 1, buttonRectangle.Y + 3),
+ new Point (buttonRectangle.X + 3, buttonRectangle.Y + 1),
+ new Point (buttonRectangle.Right - 4, buttonRectangle.Y + 1),
+ new Point (buttonRectangle.Right - 2, buttonRectangle.Y + 3),
+ new Point (buttonRectangle.Right - 2, buttonRectangle.Bottom - 4),
+ new Point (buttonRectangle.Right - 4, buttonRectangle.Bottom - 2),
+ new Point (buttonRectangle.X + 3, buttonRectangle.Bottom - 2),
+ new Point (buttonRectangle.X + 1, buttonRectangle.Bottom - 4),
+ new Point (buttonRectangle.X + 1, buttonRectangle.Y + 3)
+ };
+
+ pen = ResPool.GetPen (pressed_inner_border_dark_color);
+ dc.DrawLines (pen, points_button_complete);
+ }
+
+ // outer border
+ pen = ResPool.GetPen (button_outer_border_dark_color);
+ dc.DrawLines (pen, points_top_outer);
+ pen = ResPool.GetPen (button_outer_border_light_color);
+ dc.DrawLines (pen, points_bottom_outer);
+
+ using (LinearGradientBrush lgbr2 = new LinearGradientBrush (new Point (buttonRectangle.X, buttonRectangle.Y + 2),
+ new Point (buttonRectangle.X, buttonRectangle.Bottom - 1),
+ button_outer_border_dark_color, button_outer_border_light_color)) {
+ dc.FillRectangle (lgbr2, buttonRectangle.X, buttonRectangle.Y + 2, 1, buttonRectangle.Height - 4);
+ dc.FillRectangle (lgbr2, buttonRectangle.Right - 1, buttonRectangle.Y + 2, 1, buttonRectangle.Height - 4);
+ }
+
+ // inner border
+ pen = ResPool.GetPen (is_pressed ? pressed_inner_border_dark_color : inner_border_dark_color);
+ if (!is_pressed) {
+ dc.DrawLine (pen, buttonRectangle.Right - 3, buttonRectangle.Y + 3, buttonRectangle.Right - 3, buttonRectangle.Bottom - 4);
+ }
+ dc.DrawLine (pen, buttonRectangle.X + 3, buttonRectangle.Bottom - 3, buttonRectangle.Right - 4, buttonRectangle.Bottom - 3);
+ pen = ResPool.GetPen (is_pressed ? pressed_inner_border_dark_color : Color.White);
+ dc.DrawLine (pen, buttonRectangle.X + 2, buttonRectangle.Y + 3, buttonRectangle.X + 2, buttonRectangle.Bottom - 4);
+ dc.DrawLine (pen, buttonRectangle.X + 3 , buttonRectangle.Y + 2, buttonRectangle.Right - 4, buttonRectangle.Y + 2);
+
+ // edges
+ pen = ResPool.GetPen (edge_top_inner_color);
+ dc.DrawLine (pen, buttonRectangle.X + 1, buttonRectangle.Y + 2, buttonRectangle.X + 2, buttonRectangle.Y + 1);
+ dc.DrawLine (pen, buttonRectangle.Right - 3, buttonRectangle.Y + 1, buttonRectangle.Right - 2, buttonRectangle.Y + 2);
+
+ pen = ResPool.GetPen (button_edge_top_outer_color);
+ dc.DrawLine (pen, buttonRectangle.X, buttonRectangle.Y + 1, buttonRectangle.X + 1, buttonRectangle.Y);
+ dc.DrawLine (pen, buttonRectangle.Right - 2, buttonRectangle.Y, buttonRectangle.Right - 1, buttonRectangle.Y + 1);
+
+ pen = ResPool.GetPen (edge_bottom_inner_color);
+ dc.DrawLine (pen, buttonRectangle.X + 1, buttonRectangle.Bottom - 3, buttonRectangle.X + 2, buttonRectangle.Bottom - 2);
+ dc.DrawLine (pen, buttonRectangle.Right - 2, buttonRectangle.Bottom - 3, buttonRectangle.Right - 3, buttonRectangle.Bottom - 2);
+
+ pen = ResPool.GetPen (button_edge_bottom_outer_color);
+ dc.DrawLine (pen, buttonRectangle.X, buttonRectangle.Bottom - 2, buttonRectangle.X + 1, buttonRectangle.Bottom - 1);
+ dc.DrawLine (pen, buttonRectangle.Right - 1, buttonRectangle.Bottom - 2, buttonRectangle.Right - 2, buttonRectangle.Bottom - 1);
+ }
+ }
+
+ protected override void ButtonBase_DrawFocus( ButtonBase button, Graphics dc ) {
+
+ if ( !button.is_enabled || button.flat_style == FlatStyle.Popup )
+ return;
+
+ Pen pen = ResPool.GetPen( button_focus_color );
+ DashStyle old_dash_style = pen.DashStyle;
+ pen.DashStyle = DashStyle.Dot;
+
+ Rectangle focus_rect = new Rectangle( button.ClientRectangle.X + 4, button.ClientRectangle.Y + 4, button.ClientRectangle.Width - 9, button.ClientRectangle.Height - 9 );
+
+ dc.DrawRectangle( pen, focus_rect );
+
+ pen.DashStyle = old_dash_style;
+ }
+
+ // FIXME: remove if libgdiplus DrawOrMeasureString is fixed
+ protected override void ButtonBase_DrawText( ButtonBase button, Graphics dc ) {
+ if ( !( button is CheckBox ) && !( button is RadioButton ) ) {
+ Rectangle buttonRectangle = button.ClientRectangle;
+ Rectangle text_rect = Rectangle.Inflate( buttonRectangle, -4, -4 );
+
+ string text = button.Text;
+
+ if ( text.Length > 1 ) {
+ SizeF sizef = dc.MeasureString( text, button.Font, text_rect.Width, button.text_format );
+
+ if ( (int)sizef.Width > text_rect.Width - 3 ) {
+ for ( int i = 1; i < text.Length + 1; i++ ) {
+ sizef = dc.MeasureString( text.Substring( 0, i ), button.Font, text_rect.Width, button.text_format );
+
+ if ( (int)sizef.Width > text_rect.Width - 3 ) {
+ text = text.Substring( 0, i - 1 );
+ break;
+ }
+ }
+ }
+ }
+
+ if ( button.is_pressed ) {
+ text_rect.X++;
+ text_rect.Y++;
+ }
+
+ if ( button.is_enabled ) {
+ dc.DrawString( text, button.Font, ResPool.GetSolidBrush( button.ForeColor ), text_rect, button.text_format );
+ } else {
+ if ( button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup ) {
+ dc.DrawString( text, button.Font, ResPool.GetSolidBrush( ControlPaint.DarkDark( this.ColorControl ) ), text_rect, button.text_format );
+ } else {
+ CPDrawStringDisabled( dc, text, button.Font, ColorControlText, text_rect, button.text_format );
+ }
+ }
+ }
+ }
+ #endregion // ButtonBase
+
+ #region CheckBox
+ protected override void CheckBox_DrawCheckBox( Graphics dc, CheckBox checkbox, ButtonState state, Rectangle checkbox_rectangle ) {
+ dc.FillRectangle( ResPool.GetSolidBrush( checkbox.BackColor ), checkbox.ClientRectangle );
+ // render as per normal button
+ if ( checkbox.appearance == Appearance.Button ) {
+ DrawButtonBase( dc, checkbox.ClientRectangle, checkbox );
+ } else {
+ // establish if we are rendering a flat style of some sort
+ if ( checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup ) {
+ DrawFlatStyleCheckBox( dc, checkbox_rectangle, checkbox );
+ } else {
+ ControlPaint.DrawCheckBox( dc, checkbox_rectangle, state );
+ }
+ }
+ }
+ #endregion // CheckBox
+
+ #region ComboBox
+
+ // Drawing
+ public override void DrawComboBoxEditDecorations( Graphics dc, ComboBox ctrl, Rectangle cl ) {
+
+ Color inner_border = (ctrl.Focused && !ctrl.DroppedDown) ? combobox_focus_inner_border_color : Color.White; // Color.White should be the backcolor of the textctrl
+ Color border_color = (ctrl.Focused && !ctrl.DroppedDown) ? combobox_focus_border_color : combobox_border_color;
+
+ Point[] border_points = null;
+
+ Pen tmp_pen = ResPool.GetPen( inner_border );
+
+ dc.DrawLine( tmp_pen, cl.X + 1, cl.Y + 1, cl.X + 1, cl.Bottom - 2 );
+
+ if (!ctrl.Focused || (ctrl.Focused && ctrl.DropDownStyle == ComboBoxStyle.Simple))
+ {
+ dc.DrawLine( tmp_pen, cl.X + 2, cl.Y + 1, cl.Right - 2, cl.Y + 1 );
+ dc.DrawLine( tmp_pen, cl.X + 2, cl.Bottom - 2, cl.Right - 2, cl.Bottom - 2 );
+ dc.DrawLine( tmp_pen, cl.Right - 2, cl.Y + 1, cl.Right - 2, cl.Bottom - 2 );
+ } else {
+ dc.DrawLine( tmp_pen, cl.X + 2, cl.Y + 1, cl.Right - ctrl.combobox_info.button_rect.Width - 3, cl.Y + 1 );
+ dc.DrawLine( tmp_pen, cl.X + 2, cl.Bottom - 2, cl.Right - ctrl.combobox_info.button_rect.Width - 3, cl.Bottom - 2 );
+ }
+ if (ctrl.combobox_info.show_button) {
+ border_points = new Point[6] {
+ new Point( cl.Right - ctrl.combobox_info.button_rect.Width - 3, cl.Y ),
+ new Point( cl.X + 2, cl.Y ),
+ new Point( cl.X, cl.Y + 2 ),
+ new Point( cl.X, cl.Bottom - 3 ),
+ new Point( cl.X + 2, cl.Bottom - 1 ),
+ new Point( cl.Right - ctrl.combobox_info.button_rect.Width - 3, cl.Bottom - 1 )
+ };
+ } else {
+ border_points = new Point[9] {
+ new Point( cl.X + 2, cl.Y ),
+ new Point( cl.Right - 3, cl.Y ),
+ new Point( cl.Right - 1, cl.Y + 2 ),
+ new Point( cl.Right - 1, cl.Bottom - 3 ),
+ new Point( cl.Right - 3, cl.Bottom - 1 ),
+ new Point( cl.X + 2, cl.Bottom - 1 ),
+ new Point( cl.X, cl.Bottom - 3 ),
+ new Point( cl.X, cl.Y + 2 ),
+ new Point( cl.X + 2, cl.Y )
+ };
+ }
+
+ tmp_pen = ResPool.GetPen( ctrl.Parent.BackColor );
+ dc.DrawLine( tmp_pen, cl.X, cl.Y, cl.X, cl.Y + 1 );
+ dc.DrawLine( tmp_pen, cl.X, cl.Bottom - 1, cl.X, cl.Bottom - 2 );
+ dc.DrawLine( tmp_pen, cl.Right - 1, cl.Y, cl.Right - 1, cl.Y + 1 );
+ dc.DrawLine( tmp_pen, cl.Right - 1, cl.Bottom - 1, cl.Right - 1, cl.Bottom - 2 );
+
+ dc.DrawLines( ResPool.GetPen( border_color ), border_points );
+
+ tmp_pen = ResPool.GetPen( edge_bottom_inner_color );
+ dc.DrawLine( tmp_pen, cl.X, cl.Y + 1, cl.X + 1, cl.Y );
+ dc.DrawLine( tmp_pen, cl.X, cl.Bottom - 2, cl.X + 1, cl.Bottom - 1 );
+ dc.DrawLine( tmp_pen, cl.Right - 2, cl.Y, cl.Right - 1, cl.Y + 1 );
+ dc.DrawLine( tmp_pen, cl.Right - 2, cl.Bottom - 1, cl.Right - 1, cl.Bottom - 2 );
+
+ // FIXME:
+ // here we need to draw the combobox button again,
+ // as DrawComboBoxEditDecorations paints over a fullsize combox button.
+ // ComboBox code calls CPDrawComboButton first then DrawComboBoxEditDecorations
+ // It would be better to move that code out of ComboBox
+
+ if ( ctrl.combobox_info.show_button )
+ {
+ control_parent_backcolor = ctrl.Parent.BackColor;
+
+ ButtonState bs = ctrl.Enabled ? ctrl.combobox_info.button_status : ButtonState.Inactive;
+
+ Rectangle crect = new Rectangle( ctrl.combobox_info.button_rect.X, ctrl.combobox_info.button_rect.Y - 2,
+ ctrl.combobox_info.button_rect.Width + 2, ctrl.combobox_info.button_rect.Height + 4 );
+ CPDrawComboButton( dc, crect, bs );
+ }
+ }
+
+ public override void DrawComboListBoxDecorations( Graphics dc, ComboBox ctrl, Rectangle cl ) {
+ if ( ctrl.DropDownStyle == ComboBoxStyle.Simple ) {
+ DrawComboBoxEditDecorations( dc, ctrl, cl );
+ } else {
+ dc.DrawRectangle( ResPool.GetPen( combobox_border_color ), cl.X, cl.Y, cl.Width - 1, cl.Height - 1 );
+ }
+ }
+ #endregion ComboBox
+
+ #region Menus
+ public override void DrawMenuItem( MenuItem item, DrawItemEventArgs e ) {
+ StringFormat string_format;
+ Rectangle rect_text = e.Bounds;
+
+ if ( item.Visible == false )
+ return;
+
+ if ( item.MenuBar ) {
+ string_format = string_format_menu_menubar_text;
+ } else {
+ string_format = string_format_menu_text;
+ }
+
+ if ( item.Separator ) {
+ e.Graphics.DrawLine( ResPool.GetPen( menu_separator_color ),
+ e.Bounds.X, e.Bounds.Y + 1, e.Bounds.X + e.Bounds.Right - 4, e.Bounds.Y + 1 );
+
+ e.Graphics.DrawLine( ResPool.GetPen( Color.White ),
+ e.Bounds.X, e.Bounds.Y + 2, e.Bounds.X + e.Bounds.Right - 4, e.Bounds.Y + 2 );
+
+ return;
+ }
+
+ if ( !item.MenuBar )
+ rect_text.X += MenuCheckSize.Width;
+
+ if ( item.BarBreak ) { /* Draw vertical break bar*/
+ Rectangle rect = e.Bounds;
+ rect.Y++;
+ rect.Width = 3;
+ rect.Height = item.MenuHeight - 6;
+
+ e.Graphics.DrawLine( ResPool.GetPen( menu_separator_color ),
+ rect.X, rect.Y , rect.X, rect.Y + rect.Height );
+
+ e.Graphics.DrawLine( ResPool.GetPen( ColorControlLight ),
+ rect.X + 1, rect.Y , rect.X + 1, rect.Y + rect.Height );
+ }
+
+ Color color_text = ColorMenuText;
+ Color color_back;
+
+ /* Draw background */
+ Rectangle rect_back = e.Bounds;
+ rect_back.X++;
+ rect_back.Width -= 2;
+
+ if ( ( e.State & DrawItemState.Selected ) == DrawItemState.Selected ) {
+ color_text = ColorHighlightText;
+ color_back = item.MenuBar ? theme_back_color : menu_background_color;
+
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( rect_back.X, rect_back.Y + 1 ), new Point( rect_back.X, rect_back.Bottom - 1 ), menuitem_gradient_first_color, menuitem_gradient_second_color ) ) {
+ e.Graphics.FillRectangle( lgbr, rect_back.X + 1, rect_back.Y + 1, rect_back.Width - 1, rect_back.Height - 1 );
+ }
+
+ rect_back.Height--;
+ Pen tmp_pen = ResPool.GetPen( menuitem_border_color );
+ e.Graphics.DrawLine( tmp_pen, rect_back.X + 1, rect_back.Y, rect_back.Right - 1, rect_back.Y );
+ e.Graphics.DrawLine( tmp_pen, rect_back.Right, rect_back.Y + 1, rect_back.Right, rect_back.Bottom - 1 );
+ e.Graphics.DrawLine( tmp_pen, rect_back.Right - 1, rect_back.Bottom, rect_back.X + 1, rect_back.Bottom );
+ e.Graphics.DrawLine( tmp_pen, rect_back.X, rect_back.Bottom - 1, rect_back.X, rect_back.Y + 1 );
+ } else {
+ color_text = ColorMenuText;
+ color_back = item.MenuBar ? theme_back_color : menu_background_color;
+
+ e.Graphics.FillRectangle( ResPool.GetSolidBrush( color_back ), rect_back );
+ }
+
+ if ( item.Enabled ) {
+ e.Graphics.DrawString( item.Text, e.Font,
+ ResPool.GetSolidBrush( color_text ),
+ rect_text, string_format );
+
+ if ( !item.MenuBar && item.Shortcut != Shortcut.None && item.ShowShortcut ) {
+ string str = item.GetShortCutText( );
+ Rectangle rect = rect_text;
+ rect.X = item.XTab;
+ rect.Width -= item.XTab;
+
+ e.Graphics.DrawString( str, e.Font, ResPool.GetSolidBrush( color_text ),
+ rect, string_format_menu_shortcut );
+ }
+ } else {
+ ControlPaint.DrawStringDisabled( e.Graphics, item.Text, e.Font,
+ Color.Black, rect_text, string_format );
+ }
+
+ /* Draw arrow */
+ if ( item.MenuBar == false && item.IsPopup ) {
+ int cx = MenuCheckSize.Width;
+ int cy = MenuCheckSize.Height;
+ using ( Bitmap bmp = new Bitmap( cx, cy ) ) {
+ using ( Graphics dc = Graphics.FromImage( bmp ) ) {
+ SmoothingMode old_smoothing_mode = dc.SmoothingMode;
+ dc.SmoothingMode = SmoothingMode.AntiAlias;
+
+ Rectangle rect_arrow = new Rectangle( 0, 0, cx, cy );
+ ControlPaint.DrawMenuGlyph( dc, rect_arrow, MenuGlyph.Arrow );
+ bmp.MakeTransparent( );
+
+ if ( item.Enabled ) {
+ e.Graphics.DrawImage( bmp, e.Bounds.X + e.Bounds.Width - cx,
+ e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ) );
+ } else {
+ ControlPaint.DrawImageDisabled( e.Graphics, bmp, e.Bounds.X + e.Bounds.Width - cx,
+ e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ), color_back );
+ }
+
+ dc.SmoothingMode = old_smoothing_mode;
+ }
+ }
+ }
+
+ /* Draw checked or radio */
+ if ( item.MenuBar == false && item.Checked ) {
+
+ Rectangle area = e.Bounds;
+ int cx = MenuCheckSize.Width;
+ int cy = MenuCheckSize.Height;
+ using ( Bitmap bmp = new Bitmap( cx, cy ) ) {
+ using ( Graphics gr = Graphics.FromImage( bmp ) ) {
+ Rectangle rect_arrow = new Rectangle( 0, 0, cx, cy );
+
+ if ( item.RadioCheck )
+ ControlPaint.DrawMenuGlyph( gr, rect_arrow, MenuGlyph.Bullet );
+ else
+ ControlPaint.DrawMenuGlyph( gr, rect_arrow, MenuGlyph.Checkmark );
+
+ bmp.MakeTransparent( );
+ e.Graphics.DrawImage( bmp, area.X, e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ) );
+ }
+ }
+ }
+ }
+
+ public override void DrawPopupMenu( Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect ) {
+
+ dc.FillRectangle( ResPool.GetSolidBrush
+ ( menu_background_color ), cliparea );
+
+ /* Draw menu borders */
+ dc.DrawRectangle( ResPool.GetPen( menu_border_color ), rect.X, rect.Y, rect.Width - 1, rect.Height - 1 );
+
+ // inner border
+ Pen tmp_pen = ResPool.GetPen( Color.White );
+ dc.DrawLine( tmp_pen, rect.X + 1, rect.Y + 1, rect.Right - 2, rect.Y + 1 );
+ dc.DrawLine( tmp_pen, rect.X + 1, rect.Y + 2, rect.X + 1, rect.Bottom - 2 );
+
+ tmp_pen = ResPool.GetPen( menu_inner_border_color );
+ dc.DrawLine( tmp_pen, rect.Right - 2, rect.Y + 2, rect.Right - 2, rect.Bottom - 2 );
+ dc.DrawLine( tmp_pen, rect.Right - 3, rect.Bottom - 2, rect.X + 2, rect.Bottom - 2 );
+
+ for ( int i = 0; i < menu.MenuItems.Count; i++ )
+ if ( cliparea.IntersectsWith( menu.MenuItems[ i ].bounds ) ) {
+ MenuItem item = menu.MenuItems[ i ];
+ item.MenuHeight = menu.Height;
+ item.PerformDrawItem( new DrawItemEventArgs( dc, MenuFont,
+ item.bounds, i, item.Status ) );
+ }
+ }
+ #endregion // Menus
+
+ #region ProgressBar
+ public override void DrawProgressBar( Graphics dc, Rectangle clip_rect, ProgressBar ctrl ) {
+ Rectangle client_area = ctrl.client_area;
+ int barpos_pixels;
+ Rectangle bar = ctrl.client_area;
+
+ barpos_pixels = ( ( ctrl.Value - ctrl.Minimum ) * client_area.Width ) / ( ctrl.Maximum - ctrl.Minimum );
+
+ bar.Width = barpos_pixels + 1;
+
+ // Draw bar background
+ dc.FillRectangle( ResPool.GetSolidBrush( menu_separator_color ), ctrl.ClientRectangle.X + 1, ctrl.ClientRectangle.Y + 1, ctrl.ClientRectangle.Width - 2, ctrl.ClientRectangle.Height - 2 );
+
+ /* Draw border */
+ Pen tmp_pen = ResPool.GetPen( progressbar_edge_dot_color );
+ dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Y, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Y + 1 );
+ dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Bottom - 1, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Bottom - 2 );
+ dc.DrawLine( tmp_pen, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Y, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Y + 1 );
+ dc.DrawLine( tmp_pen, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Bottom - 1, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Bottom - 2 );
+
+ tmp_pen = ResPool.GetPen( scrollbar_border_color );
+ dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X + 1, ctrl.ClientRectangle.Y, ctrl.ClientRectangle.Right - 2, ctrl.ClientRectangle.Y );
+ dc.DrawLine( tmp_pen, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Y + 1, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Bottom - 2 );
+ dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X + 1, ctrl.ClientRectangle.Bottom - 1, ctrl.ClientRectangle.Right - 2, ctrl.ClientRectangle.Bottom - 1 );
+ dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Y + 1, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Bottom - 2 );
+
+ if ( barpos_pixels <= 0 )
+ return;
+
+ if ((bar.Width - 2) <= 0 || (bar.Height - 1) <= 0)
+ return;
+
+ // Draw bar
+ dc.DrawRectangle( ResPool.GetPen( combobox_focus_border_color ), bar.X - 1, bar.Y - 1, bar.Width, bar.Height + 1 );
+ tmp_pen = ResPool.GetPen( progressbar_inner_border_color );
+ dc.DrawLine( tmp_pen, bar.X, bar.Y, bar.Right - 2, bar.Y );
+ dc.DrawLine( tmp_pen, bar.X, bar.Y, bar.X, bar.Bottom - 1 );
+
+ using ( Bitmap bmp = new Bitmap( bar.Width - 2, bar.Height - 1 ) ) {
+ using ( Graphics gr = Graphics.FromImage( bmp ) ) {
+ gr.FillRectangle( ResPool.GetSolidBrush( tab_focus_color ), 0, 0, bmp.Width, bmp.Height );
+
+ LinearGradientBrush lgbr = new LinearGradientBrush( new Rectangle( 0, 0, bmp.Height, bmp.Height ), progressbar_first_gradient_color, progressbar_second_gradient_color, 0.0f, true );
+
+ lgbr.RotateTransform( 45.0f, MatrixOrder.Append );
+
+ float pen_width = bmp.Height / 2;
+
+ Pen pen = new Pen( lgbr, pen_width );
+
+ int add = bmp.Height + (int)pen.Width / 2;
+
+ int x_top = 0;
+ int x_bottom = - bmp.Height;
+
+ while ( x_bottom < bmp.Width ) {
+ gr.DrawLine( pen, x_top, 0, x_bottom, bmp.Height );
+ x_top += add;
+ x_bottom += add;
+ }
+ pen.Dispose( );
+ lgbr.Dispose( );
+ }
+
+ dc.DrawImage( bmp, bar.X + 1, bar.Y + 1 );
+ }
+ }
+ #endregion // ProgressBar
+
+ #region RadioButton
+ protected override void RadioButton_DrawButton( RadioButton radio_button, Graphics dc, ButtonState state, Rectangle radiobutton_rectangle ) {
+ SolidBrush sb = new SolidBrush( radio_button.BackColor );
+ dc.FillRectangle( sb, radio_button.ClientRectangle );
+ sb.Dispose( );
+
+ if ( radio_button.appearance == Appearance.Button ) {
+ if ( radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup ) {
+ DrawFlatStyleButton( dc, radio_button.ClientRectangle, radio_button );
+ } else {
+ DrawButtonBase( dc, radio_button.ClientRectangle, radio_button );
+ }
+ } else {
+ // establish if we are rendering a flat style of some sort
+ if ( radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup ) {
+ DrawFlatStyleRadioButton( dc, radiobutton_rectangle, radio_button );
+ } else {
+ ControlPaint.DrawRadioButton( dc, radiobutton_rectangle, state );
+ }
+ }
+ }
+
+ protected override void RadioButton_DrawFocus( RadioButton radio_button, Graphics dc, Rectangle text_rectangle ) {
+ if ( radio_button.Focused && radio_button.appearance != Appearance.Button ) {
+ if ( radio_button.FlatStyle != FlatStyle.Flat && radio_button.FlatStyle != FlatStyle.Popup ) {
+ DrawInnerFocusRectangle( dc, text_rectangle, radio_button.BackColor );
+ }
+ }
+ }
+
+ // renders a radio button with the Flat and Popup FlatStyle
+ protected void DrawFlatStyleRadioButton (Graphics dc, Rectangle rectangle, RadioButton radio_button)
+ {
+ if (radio_button.Enabled) {
+ // draw the outer flatstyle arcs
+ if (radio_button.FlatStyle == FlatStyle.Flat) {
+ dc.DrawArc (ResPool.GetPen (radio_button.ForeColor), rectangle, 0, 359);
+
+ // fill in the area depending on whether or not the mouse is hovering
+ if (radio_button.is_entered && radio_button.Capture) {
+ dc.FillPie (ResPool.GetSolidBrush (ControlPaint.Light (radio_button.BackColor)), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
+ } else {
+ dc.FillPie (ResPool.GetSolidBrush (ControlPaint.LightLight (radio_button.BackColor)), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
+ }
+ } else {
+ // must be a popup radio button
+ // fill the control
+ dc.FillPie (ResPool.GetSolidBrush (ControlPaint.LightLight (radio_button.BackColor)), rectangle, 0, 359);
+
+ if (radio_button.is_entered || radio_button.Capture) {
+ // draw the popup 3d button knob
+ dc.DrawArc (ResPool.GetPen (ControlPaint.Light (radio_button.BackColor)), rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 0, 359);
+
+ dc.DrawArc (ResPool.GetPen (ControlPaint.Dark (radio_button.BackColor)), rectangle, 135, 180);
+ dc.DrawArc (ResPool.GetPen (ControlPaint.LightLight (radio_button.BackColor)), rectangle, 315, 180);
+
+ } else {
+ // just draw lighter flatstyle outer circle
+ dc.DrawArc (ResPool.GetPen (ControlPaint.Dark (this.ColorControl)), rectangle, 0, 359);
+ }
+ }
+ } else {
+ // disabled
+ // fill control background color regardless of actual backcolor
+ dc.FillPie (ResPool.GetSolidBrush (this.ColorControl), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
+ // draw the ark as control dark
+ dc.DrawArc (ResPool.GetPen (ControlPaint.Dark(this.ColorControl)), rectangle, 0, 359);
+ }
+
+ // draw the check
+ if (radio_button.Checked) {
+ SmoothingMode old_smoothing_mode = dc.SmoothingMode;
+ dc.SmoothingMode = SmoothingMode.AntiAlias;
+
+ CL_Draw_RadioButton_Dot (dc, rectangle, true, false);
+
+ dc.SmoothingMode = old_smoothing_mode;
+ }
+ }
+ #endregion // RadioButton
+
+ #region ScrollBar
+ public override void DrawScrollBar( Graphics dc, Rectangle clip, ScrollBar bar ) {
+ int scrollbutton_width = bar.scrollbutton_width;
+ int scrollbutton_height = bar.scrollbutton_height;
+ Rectangle first_arrow_area;
+ Rectangle second_arrow_area;
+ Rectangle thumb_pos;
+
+ thumb_pos = bar.ThumbPos;
+
+ if ( bar.vert ) {
+ first_arrow_area = new Rectangle( 0, 0, bar.Width, scrollbutton_height + 1 );
+ bar.FirstArrowArea = first_arrow_area;
+
+ second_arrow_area = new Rectangle( 0, bar.ClientRectangle.Height - scrollbutton_height - 1, bar.Width, scrollbutton_height + 1 );
+ bar.SecondArrowArea = second_arrow_area;
+
+ thumb_pos.Width = bar.Width;
+ bar.ThumbPos = thumb_pos;
+
+ /* Background */
+ switch ( bar.thumb_moving ) {
+ case ScrollBar.ThumbMoving.None: {
+ ScrollBar_Vertical_Draw_ThumbMoving_None( scrollbutton_height, bar, clip, dc );
+ break;
+ }
+ case ScrollBar.ThumbMoving.Forward: {
+ ScrollBar_Vertical_Draw_ThumbMoving_Forward( scrollbutton_height, bar, thumb_pos, clip, dc );
+ break;
+ }
+
+ case ScrollBar.ThumbMoving.Backwards: {
+ ScrollBar_Vertical_Draw_ThumbMoving_Backwards( scrollbutton_height, bar, thumb_pos, clip, dc );
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ /* Buttons */
+ if ( clip.IntersectsWith( first_arrow_area ) )
+ CPDrawScrollButton( dc, first_arrow_area, ScrollButton.Up, bar.firstbutton_state );
+ if ( clip.IntersectsWith( second_arrow_area ) )
+ CPDrawScrollButton( dc, second_arrow_area, ScrollButton.Down, bar.secondbutton_state );
+ } else {
+ first_arrow_area = new Rectangle( 0, 0, scrollbutton_width + 1, bar.Height );
+ bar.FirstArrowArea = first_arrow_area;
+
+ second_arrow_area = new Rectangle( bar.ClientRectangle.Width - scrollbutton_width - 1, 0, scrollbutton_width + 1, bar.Height );
+ bar.SecondArrowArea = second_arrow_area;
+
+ thumb_pos.Height = bar.Height;
+ bar.ThumbPos = thumb_pos;
+
+ /* Background */
+ switch ( bar.thumb_moving ) {
+ case ScrollBar.ThumbMoving.None: {
+ ScrollBar_Horizontal_Draw_ThumbMoving_None( scrollbutton_width, bar, clip, dc );
+ break;
+ }
+
+ case ScrollBar.ThumbMoving.Forward: {
+ ScrollBar_Horizontal_Draw_ThumbMoving_Forward( scrollbutton_width, thumb_pos, bar, clip, dc );
+ break;
+ }
+
+ case ScrollBar.ThumbMoving.Backwards: {
+ ScrollBar_Horizontal_Draw_ThumbMoving_Backwards( scrollbutton_width, thumb_pos, bar, clip, dc );
+ break;
+ }
+ }
+
+ /* Buttons */
+ if ( clip.IntersectsWith( first_arrow_area ) )
+ CPDrawScrollButton( dc, first_arrow_area, ScrollButton.Left, bar.firstbutton_state );
+ if ( clip.IntersectsWith( second_arrow_area ) )
+ CPDrawScrollButton( dc, second_arrow_area, ScrollButton.Right, bar.secondbutton_state );
+ }
+
+ /* Thumb */
+ ScrollBar_DrawThumb( bar, thumb_pos, clip, dc );
+ }
+
+ protected override void ScrollBar_DrawThumb( ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc ) {
+ if ( bar.Enabled && thumb_pos.Width > 0 && thumb_pos.Height > 0 && clip.IntersectsWith( thumb_pos ) )
+ DrawScrollBarThumb( dc, thumb_pos, bar );
+ }
+
+ protected override void ScrollBar_Vertical_Draw_ThumbMoving_None( int scrollbutton_height, ScrollBar bar, Rectangle clip, Graphics dc ) {
+ Rectangle r = new Rectangle( 0,
+ scrollbutton_height, bar.ClientRectangle.Width, bar.ClientRectangle.Height - ( scrollbutton_height * 2 ) );
+ Rectangle intersect = Rectangle.Intersect( clip, r );
+
+ if ( intersect != Rectangle.Empty ) {
+ dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
+ Pen pen = ResPool.GetPen( scrollbar_border_color );
+ dc.DrawLine( pen, intersect.X, intersect.Y, intersect.X, intersect.Bottom - 1 );
+ dc.DrawLine( pen, intersect.Right - 1, intersect.Y, intersect.Right - 1, intersect.Bottom - 1 );
+ }
+ }
+
+ protected override void ScrollBar_Vertical_Draw_ThumbMoving_Forward( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc ) {
+ Rectangle r = new Rectangle( 0, scrollbutton_height,
+ bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
+ Rectangle intersect = Rectangle.Intersect( clip, r );
+
+ if ( intersect != Rectangle.Empty ) {
+ dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
+ Pen pen = ResPool.GetPen( scrollbar_border_color );
+ dc.DrawLine( pen, intersect.X, intersect.Y, intersect.X, intersect.Bottom - 1 );
+ dc.DrawLine( pen, intersect.Right - 1, intersect.Y, intersect.Right - 1, intersect.Bottom - 1 );
+ }
+
+ r.X = 0;
+ r.Y = thumb_pos.Y + thumb_pos.Height;
+ r.Width = bar.ClientRectangle.Width;
+ r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
+
+ intersect = Rectangle.Intersect( clip, r );
+ if ( intersect != Rectangle.Empty ) {
+ dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
+ Pen pen = ResPool.GetPen( scrollbar_border_color );
+ dc.DrawLine( pen, intersect.X, intersect.Y, intersect.X, intersect.Bottom - 1 );
+ dc.DrawLine( pen, intersect.Right - 1, intersect.Y, intersect.Right - 1, intersect.Bottom - 1 );
+ }
+ }
+
+ protected override void ScrollBar_Vertical_Draw_ThumbMoving_Backwards( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc ) {
+ Rectangle r = new Rectangle( 0, scrollbutton_height,
+ bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
+ Rectangle intersect = Rectangle.Intersect( clip, r );
+
+ if ( intersect != Rectangle.Empty ) {
+ dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
+ Pen pen = ResPool.GetPen( scrollbar_border_color );
+ dc.DrawLine( pen, intersect.X, intersect.Y, intersect.X, intersect.Bottom - 1 );
+ dc.DrawLine( pen, intersect.Right - 1, intersect.Y, intersect.Right - 1, intersect.Bottom - 1 );
+ }
+
+ r.X = 0;
+ r.Y = thumb_pos.Y + thumb_pos.Height;
+ r.Width = bar.ClientRectangle.Width;
+ r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
+
+ intersect = Rectangle.Intersect( clip, r );
+ if ( intersect != Rectangle.Empty ) {
+ dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
+ Pen pen = ResPool.GetPen( scrollbar_border_color );
+ dc.DrawLine( pen, intersect.X, intersect.Y, intersect.X, intersect.Bottom - 1 );
+ dc.DrawLine( pen, intersect.Right - 1, intersect.Y, intersect.Right - 1, intersect.Bottom - 1 );
+ }
+ }
+
+ protected override void ScrollBar_Horizontal_Draw_ThumbMoving_None( int scrollbutton_width, ScrollBar bar, Rectangle clip, Graphics dc ) {
+ Rectangle r = new Rectangle( scrollbutton_width,
+ 0, bar.ClientRectangle.Width - ( scrollbutton_width * 2 ), bar.ClientRectangle.Height );
+ Rectangle intersect = Rectangle.Intersect( clip, r );
+
+ if ( intersect != Rectangle.Empty ) {
+ dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
+ Pen pen = ResPool.GetPen( scrollbar_border_color );
+ dc.DrawLine( pen, intersect.X, intersect.Y, intersect.Right - 1, intersect.Y );
+ dc.DrawLine( pen, intersect.X, intersect.Bottom - 1, intersect.Right - 1, intersect.Bottom - 1 );
+ }
+ }
+
+ protected override void ScrollBar_Horizontal_Draw_ThumbMoving_Forward( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc ) {
+ Rectangle r = new Rectangle( scrollbutton_width, 0,
+ thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
+ Rectangle intersect = Rectangle.Intersect( clip, r );
+
+ if ( intersect != Rectangle.Empty ) {
+ dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
+ Pen pen = ResPool.GetPen( scrollbar_border_color );
+ dc.DrawLine( pen, intersect.X, intersect.Y, intersect.Right - 1, intersect.Y );
+ dc.DrawLine( pen, intersect.X, intersect.Bottom - 1, intersect.Right - 1, intersect.Bottom - 1 );
+ }
+
+ r.X = thumb_pos.X + thumb_pos.Width;
+ r.Y = 0;
+ r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
+ r.Height = bar.ClientRectangle.Height;
+
+ intersect = Rectangle.Intersect( clip, r );
+ if ( intersect != Rectangle.Empty ) {
+ dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
+ Pen pen = ResPool.GetPen( scrollbar_border_color );
+ dc.DrawLine( pen, intersect.X, intersect.Y, intersect.Right - 1, intersect.Y );
+ dc.DrawLine( pen, intersect.X, intersect.Bottom - 1, intersect.Right - 1, intersect.Bottom - 1 );
+ }
+ }
+
+ protected override void ScrollBar_Horizontal_Draw_ThumbMoving_Backwards( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc ) {
+ Rectangle r = new Rectangle( scrollbutton_width, 0,
+ thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
+ Rectangle intersect = Rectangle.Intersect( clip, r );
+
+ if ( intersect != Rectangle.Empty ) {
+ dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
+ Pen pen = ResPool.GetPen( scrollbar_border_color );
+ dc.DrawLine( pen, intersect.X, intersect.Y, intersect.Right - 1, intersect.Y );
+ dc.DrawLine( pen, intersect.X, intersect.Bottom - 1, intersect.Right - 1, intersect.Bottom - 1 );
+ }
+
+ r.X = thumb_pos.X + thumb_pos.Width;
+ r.Y = 0;
+ r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
+ r.Height = bar.ClientRectangle.Height;
+
+ intersect = Rectangle.Intersect( clip, r );
+ if ( intersect != Rectangle.Empty ) {
+ dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
+ Pen pen = ResPool.GetPen( scrollbar_border_color );
+ dc.DrawLine( pen, intersect.X, intersect.Y, intersect.Right - 1, intersect.Y );
+ dc.DrawLine( pen, intersect.X, intersect.Bottom - 1, intersect.Right - 1, intersect.Bottom - 1 );
+ }
+ }
+ #endregion // ScrollBar
+
+ #region StatusBar
+ protected override void DrawStatusBarPanel( Graphics dc, Rectangle area, int index,
+ SolidBrush br_forecolor, StatusBarPanel panel ) {
+ int border_size = 3; // this is actually const, even if the border style is none
+
+ area.Height -= border_size;
+ if ( panel.BorderStyle != StatusBarPanelBorderStyle.None ) {
+ dc.DrawRectangle( ResPool.GetPen( pressed_inner_border_dark_color ), area );
+ }
+
+ if ( panel.Style == StatusBarPanelStyle.OwnerDraw ) {
+ StatusBarDrawItemEventArgs e = new StatusBarDrawItemEventArgs(
+ dc, panel.Parent.Font, area, index, DrawItemState.Default,
+ panel, panel.Parent.ForeColor, panel.Parent.BackColor );
+ panel.Parent.OnDrawItemInternal( e );
+ return;
+ }
+
+ int left = area.Left;
+ if ( panel.Icon != null ) {
+ left += 2;
+ dc.DrawIcon( panel.Icon, left, area.Top );
+ left += panel.Icon.Width;
+ }
+
+ if ( panel.Text == String.Empty )
+ return;
+
+ string text = panel.Text;
+ StringFormat string_format = new StringFormat( );
+ string_format.Trimming = StringTrimming.Character;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+
+ if ( text[ 0 ] == '\t' ) {
+ string_format.Alignment = StringAlignment.Center;
+ text = text.Substring( 1 );
+ if ( text[ 0 ] == '\t' ) {
+ string_format.Alignment = StringAlignment.Far;
+ text = text.Substring( 1 );
+ }
+ }
+
+ int x = left + border_size;
+ int y = border_size + 2;
+ Rectangle r = new Rectangle( x, y,
+ area.Right - x - border_size,
+ area.Bottom - y - border_size );
+
+ dc.DrawString( text, panel.Parent.Font, br_forecolor, r, string_format );
+ }
+ #endregion // StatusBar
+
+ // FIXME: regions near the borders don't get filled with the correct backcolor
+ // TODO: TabAlignment.Left and TabAlignment.Bottom
+ public override void DrawTabControl( Graphics dc, Rectangle area, TabControl tab ) {
+ if (tab.Parent != null)
+ dc.FillRectangle( ResPool.GetSolidBrush( tab.Parent.BackColor ), area );
+ else
+ dc.FillRectangle( ResPool.GetSolidBrush( tab.BackColor ), area );
+ Rectangle panel_rect = GetTabPanelRectExt( tab );
+
+ if ( tab.Appearance == TabAppearance.Normal ) {
+
+ switch ( tab.Alignment ) {
+ case TabAlignment.Top:
+ // inner border...
+ Pen pen = ResPool.GetPen( Color.White );
+
+ dc.DrawLine( pen, panel_rect.Left + 1, panel_rect.Top, panel_rect.Left + 1, panel_rect.Bottom - 1 );
+ dc.DrawLine( pen, panel_rect.Left + 2, panel_rect.Top , panel_rect.Right - 2, panel_rect.Top );
+
+ pen = ResPool.GetPen( tab_inner_border_color );
+ dc.DrawLine( pen, panel_rect.Right - 2, panel_rect.Top + 1, panel_rect.Right - 2, panel_rect.Bottom - 2 );
+ dc.DrawLine( pen, panel_rect.Right - 2, panel_rect.Bottom - 1, panel_rect.Left + 2, panel_rect.Bottom - 1 );
+
+ // border
+ pen = ResPool.GetPen( tab_border_color );
+
+ dc.DrawLine( pen, panel_rect.Left, panel_rect.Top - 1, panel_rect.Right - 1, panel_rect.Top - 1 );
+ dc.DrawLine( pen, panel_rect.Right - 1, panel_rect.Top - 1, panel_rect.Right - 1, panel_rect.Bottom - 2 );
+ dc.DrawLine( pen, panel_rect.Right - 1, panel_rect.Bottom - 2, panel_rect.Right - 3, panel_rect.Bottom );
+ dc.DrawLine( pen, panel_rect.Right - 3, panel_rect.Bottom, panel_rect.Left + 2, panel_rect.Bottom );
+ dc.DrawLine( pen, panel_rect.Left + 2, panel_rect.Bottom, panel_rect.Left, panel_rect.Bottom - 2 );
+ dc.DrawLine( pen, panel_rect.Left, panel_rect.Bottom - 2, panel_rect.Left, panel_rect.Top - 1 );
+ break;
+
+ // FIXME: the size of the tab page is to big to draw the upper inner white border
+ case TabAlignment.Right:
+ // inner border...
+ pen = ResPool.GetPen( Color.White );
+
+ dc.DrawLine( pen, panel_rect.Left + 1, panel_rect.Top + 1, panel_rect.Left + 1, panel_rect.Bottom - 1 );
+ dc.DrawLine( pen, panel_rect.Left + 2, panel_rect.Top + 1 , panel_rect.Right - 2, panel_rect.Top + 1 );
+
+ pen = ResPool.GetPen( tab_inner_border_color );
+ dc.DrawLine( pen, panel_rect.Right - 2, panel_rect.Top + 1, panel_rect.Right - 2, panel_rect.Bottom - 2 );
+ dc.DrawLine( pen, panel_rect.Right - 2, panel_rect.Bottom - 1, panel_rect.Left + 2, panel_rect.Bottom - 1 );
+
+ // border
+ pen = ResPool.GetPen( tab_border_color );
+
+ dc.DrawLine( pen, panel_rect.Left + 2, panel_rect.Top, panel_rect.Right - 1, panel_rect.Top );
+ dc.DrawLine( pen, panel_rect.Right - 1, panel_rect.Top, panel_rect.Right - 1, panel_rect.Bottom );
+ dc.DrawLine( pen, panel_rect.Right - 1, panel_rect.Bottom, panel_rect.Left + 2, panel_rect.Bottom );
+ dc.DrawLine( pen, panel_rect.Left + 2, panel_rect.Bottom, panel_rect.Left, panel_rect.Bottom - 2 );
+ dc.DrawLine( pen, panel_rect.Left, panel_rect.Bottom - 2, panel_rect.Left, panel_rect.Top + 2 );
+ dc.DrawLine( pen, panel_rect.Left, panel_rect.Top + 2, panel_rect.Left + 2, panel_rect.Top );
+ break;
+ }
+ }
+
+ if (tab.Alignment == TabAlignment.Top) {
+ for (int r = tab.TabPages.Count; r > 0; r--) {
+ for (int i = tab.SliderPos; i < tab.TabPages.Count; i++) {
+ if (i == tab.SelectedIndex)
+ continue;
+ if (r != tab.TabPages [i].Row)
+ continue;
+ Rectangle rect = tab.GetTabRect (i);
+ if (!rect.IntersectsWith (area))
+ continue;
+ DrawTab (dc, tab.TabPages [i], tab, rect, false);
+ }
+ }
+ } else {
+ for (int r = 0; r < tab.TabPages.Count; r++) {
+ for (int i = tab.SliderPos; i < tab.TabPages.Count; i++) {
+ if (i == tab.SelectedIndex)
+ continue;
+ if (r != tab.TabPages [i].Row)
+ continue;
+ Rectangle rect = tab.GetTabRect (i);
+ if (!rect.IntersectsWith (area))
+ continue;
+ DrawTab (dc, tab.TabPages [i], tab, rect, false);
+ }
+ }
+ }
+
+ if (tab.SelectedIndex != -1 && tab.SelectedIndex >= tab.SliderPos) {
+ Rectangle rect = tab.GetTabRect (tab.SelectedIndex);
+ if (rect.IntersectsWith (area))
+ DrawTab (dc, tab.TabPages [tab.SelectedIndex], tab, rect, true);
+ }
+
+ if (tab.ShowSlider) {
+ Rectangle right = GetTabControlRightScrollRect (tab);
+ Rectangle left = GetTabControlLeftScrollRect (tab);
+ CPDrawScrollButton (dc, right, ScrollButton.Right, tab.RightSliderState);
+ CPDrawScrollButton (dc, left, ScrollButton.Left, tab.LeftSliderState);
+ }
+ }
+
+ protected override int DrawTab (Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected)
+ {
+ int FlatButtonSpacing = 8;
+ Rectangle interior;
+ int res = bounds.Width;
+
+ if (page.BackColor != tab_selected_gradient_second_color)
+ page.BackColor = tab_selected_gradient_second_color;
+
+ // we can't fill the background right away because the bounds might be adjusted if the tab is selected
+
+ StringFormat string_format = new StringFormat ();
+
+ if (tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons) {
+ dc.FillRectangle (ResPool.GetSolidBrush (tab_selected_gradient_second_color), bounds);
+
+ // Separators
+ if (tab.Appearance == TabAppearance.FlatButtons) {
+ int width = bounds.Width;
+ bounds.Width += (FlatButtonSpacing - 2);
+ res = bounds.Width;
+ CPDrawBorder3D (dc, bounds, Border3DStyle.Etched, Border3DSide.Right);
+ bounds.Width = width;
+ }
+
+ if (is_selected) {
+ CPDrawBorder3D (dc, bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
+ } else if (tab.Appearance != TabAppearance.FlatButtons) {
+ CPDrawBorder3D (dc, bounds, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
+ }
+
+ interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4);
+
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+ } else {
+ Color tab_first_color = is_selected ? tab_selected_gradient_first_color : tab_not_selected_gradient_first_color;
+ Color tab_second_color = is_selected ? tab_selected_gradient_second_color : tab_not_selected_gradient_second_color;
+
+ switch (tab.Alignment) {
+ case TabAlignment.Top:
+
+ Rectangle tab_interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 3);
+
+ using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left + 2, bounds.Top + 2), new Point (bounds.Left + 2, bounds.Bottom), tab_first_color, tab_second_color)) {
+ dc.FillRectangle (lgbr, tab_interior);
+ }
+
+ // edges
+ Pen tmp_pen = ResPool.GetPen (tab_edge_color);
+ dc.DrawLine (tmp_pen, bounds.Left, bounds.Top + 1, bounds.Left + 1, bounds.Top);
+ dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Top, bounds.Right, bounds.Top + 1);
+
+ // inner border
+ tmp_pen = ResPool.GetPen (Color.White);
+ dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Bottom - 2, bounds.Left + 1, bounds.Top + 1);
+ dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top + 1, bounds.Right - 1, bounds.Top + 1);
+
+ // border
+ tmp_pen = ResPool.GetPen (border_pressed_dark_color);
+ dc.DrawLine (tmp_pen, bounds.Left, bounds.Top + 2, bounds.Left + 2, bounds.Top);
+ dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top, bounds.Right - 2, bounds.Top);
+ dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Top, bounds.Right, bounds.Top + 2);
+
+ using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left, bounds.Top + 2), new Point (bounds.Left, bounds.Bottom - 1), border_pressed_dark_color, border_pressed_light_color)) {
+ int diff = is_selected ? 4 : 3;
+ dc.FillRectangle (lgbr, bounds.Left, bounds.Top + 2, 1, bounds.Height - diff);
+ dc.FillRectangle (lgbr, bounds.Right, bounds.Top + 2, 1, bounds.Height - diff);
+ }
+
+ if (page.Focused) {
+ tmp_pen = ResPool.GetPen (tab_focus_color);
+ dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Top + 2, bounds.Right - 1, bounds.Top + 2);
+ dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top + 1, bounds.Right - 2, bounds.Top + 1);
+
+ tmp_pen = ResPool.GetPen (tab_top_border_focus_color);
+ dc.DrawLine (tmp_pen, bounds.Left, bounds.Top + 2, bounds.Left + 2, bounds.Top);
+ dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top, bounds.Right - 2, bounds.Top);
+ dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Top, bounds.Right, bounds.Top + 2);
+ }
+
+ interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
+
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+
+ break;
+
+ case TabAlignment.Bottom:
+
+ tab_interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 3);
+
+ using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left + 2, bounds.Top + 2), new Point (bounds.Left + 2, bounds.Bottom - 1), tab_first_color, tab_second_color)) {
+ dc.FillRectangle (lgbr, tab_interior);
+ }
+
+ // edges
+ tmp_pen = ResPool.GetPen (tab_edge_color);
+ dc.DrawLine (tmp_pen, bounds.Left, bounds.Bottom - 1, bounds.Left + 1, bounds.Bottom);
+ dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Bottom, bounds.Right, bounds.Bottom - 1);
+
+ // inner border
+ tmp_pen = ResPool.GetPen (Color.White);
+ dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Bottom - 2, bounds.Left + 1, bounds.Top + 2);
+ dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Bottom - 1, bounds.Right - 1, bounds.Bottom - 1);
+
+ // border
+ tmp_pen = ResPool.GetPen (border_pressed_dark_color);
+ dc.DrawLine (tmp_pen, bounds.Left, bounds.Bottom - 2, bounds.Left + 2, bounds.Bottom);
+ dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Bottom, bounds.Right - 2, bounds.Bottom);
+ dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Bottom, bounds.Right, bounds.Bottom - 2);
+
+ using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left, bounds.Top + 2), new Point (bounds.Left, bounds.Bottom - 1), border_pressed_light_color, border_pressed_dark_color)) {
+ int diff = is_selected ? 4 : 3;
+ dc.FillRectangle (lgbr, bounds.Left, bounds.Top + 2, 1, bounds.Height - diff);
+ dc.FillRectangle (lgbr, bounds.Right, bounds.Top + 2, 1, bounds.Height - diff);
+ }
+
+ if (page.Focused) {
+ tmp_pen = ResPool.GetPen (tab_focus_color);
+ dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Bottom - 2, bounds.Right - 1, bounds.Bottom - 2);
+ dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom - 1);
+
+ tmp_pen = ResPool.GetPen (tab_top_border_focus_color);
+ dc.DrawLine (tmp_pen, bounds.Left, bounds.Bottom - 2, bounds.Left + 2, bounds.Bottom);
+ dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Bottom, bounds.Right - 2, bounds.Bottom);
+ dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Bottom, bounds.Right, bounds.Bottom - 2);
+ }
+
+ interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
+
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+
+ break;
+
+ case TabAlignment.Left:
+
+ int w_diff = is_selected ? 2 : 0;
+
+ tab_interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 2 - w_diff, bounds.Height - 2);
+
+ using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left + 2, bounds.Top + 2), new Point (bounds.Right - w_diff, bounds.Top + 2), tab_first_color, tab_second_color)) {
+ dc.FillRectangle (lgbr, tab_interior);
+ }
+
+ // edges
+ tmp_pen = ResPool.GetPen (tab_edge_color);
+ dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Top, bounds.Left, bounds.Top + 1);
+ dc.DrawLine (tmp_pen, bounds.Left, bounds.Bottom - 1, bounds.Left + 1, bounds.Bottom);
+
+ // inner border
+ tmp_pen = ResPool.GetPen (Color.White);
+ dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top + 1, bounds.Right - 3, bounds.Top + 1);
+ dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Top + 2, bounds.Left + 1, bounds.Bottom - 2);
+
+ // border
+ tmp_pen = ResPool.GetPen (border_pressed_dark_color);
+ dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top, bounds.Left, bounds.Top + 2);
+ dc.DrawLine (tmp_pen, bounds.Left, bounds.Top + 2, bounds.Left, bounds.Bottom - 2);
+ dc.DrawLine (tmp_pen, bounds.Left, bounds.Bottom - 2, bounds.Left + 2, bounds.Bottom);
+
+ using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left, bounds.Top + 2), new Point (bounds.Right - 2, bounds.Top + 2), border_pressed_dark_color, border_pressed_light_color)) {
+ int diff = is_selected ? 4 : 2;
+
+ dc.FillRectangle (lgbr, bounds.Left + 2, bounds.Top, bounds.Width - diff, 1);
+ dc.FillRectangle (lgbr, bounds.Left + 2, bounds.Bottom, bounds.Width - diff, 1);
+ }
+
+ if (page.Focused) {
+ tmp_pen = ResPool.GetPen (tab_focus_color);
+ dc.DrawLine (tmp_pen, bounds.Left + 3, bounds.Top + 1, bounds.Left + 3, bounds.Bottom - 1);
+ dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top + 2, bounds.Left + 2, bounds.Bottom - 2);
+
+ tmp_pen = ResPool.GetPen (tab_top_border_focus_color);
+ dc.DrawLine (tmp_pen, bounds.Left + 3, bounds.Top, bounds.Left + 1, bounds.Top + 2);
+ dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Top + 2, bounds.Left + 1, bounds.Bottom - 2);
+ dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Bottom - 2, bounds.Left + 3, bounds.Bottom);
+ }
+
+ interior = new Rectangle (bounds.Left + 2, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
+
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+ string_format.FormatFlags = StringFormatFlags.DirectionVertical;
+
+ break;
+
+ default:
+ // TabAlignment.Right
+
+ tab_interior = new Rectangle (bounds.Left, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2);
+
+ using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left, bounds.Top + 2), new Point (bounds.Right, bounds.Top + 2), tab_second_color, tab_first_color)) {
+ dc.FillRectangle (lgbr, tab_interior);
+ }
+
+ int l_diff = is_selected ? 2 : 0;
+
+ // edges
+ tmp_pen = ResPool.GetPen (tab_edge_color);
+ dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Top, bounds.Right - 1, bounds.Top + 1);
+ dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom);
+
+ // inner border
+ tmp_pen = ResPool.GetPen (Color.White);
+ dc.DrawLine (tmp_pen, bounds.Left + l_diff, bounds.Top + 1, bounds.Right - 2, bounds.Top + 1);
+ dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Top + 2, bounds.Right - 2, bounds.Bottom - 2);
+
+ // border
+ tmp_pen = ResPool.GetPen (border_pressed_dark_color);
+ dc.DrawLine (tmp_pen, bounds.Right - 3, bounds.Top, bounds.Right - 1, bounds.Top + 2);
+ dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Top + 2, bounds.Right - 1, bounds.Bottom - 2);
+ dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Bottom - 2, bounds.Right - 3, bounds.Bottom);
+
+ using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left, bounds.Top + 2), new Point (bounds.Right - 2, bounds.Top + 2), border_pressed_light_color, border_pressed_dark_color)) {
+ int diff = is_selected ? 4 : 2;
+
+ dc.FillRectangle (lgbr, bounds.Left + l_diff, bounds.Top, bounds.Width - diff, 1);
+ dc.FillRectangle (lgbr, bounds.Left + l_diff, bounds.Bottom, bounds.Width - diff, 1);
+ }
+
+ if (page.Focused) {
+ tmp_pen = ResPool.GetPen (tab_focus_color);
+ dc.DrawLine (tmp_pen, bounds.Right - 3, bounds.Top + 1, bounds.Right - 3, bounds.Bottom - 1);
+ dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Top + 2, bounds.Right - 2, bounds.Bottom - 2);
+
+ tmp_pen = ResPool.GetPen (tab_top_border_focus_color);
+ dc.DrawLine (tmp_pen, bounds.Right - 3, bounds.Top, bounds.Right - 1, bounds.Top + 2);
+ dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Top + 2, bounds.Right - 1, bounds.Bottom - 2);
+ dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Bottom - 2, bounds.Right - 3, bounds.Bottom);
+ }
+
+ interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
+
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+ string_format.FormatFlags = StringFormatFlags.DirectionVertical;
+
+ break;
+ }
+ }
+
+ if (tab.DrawMode == TabDrawMode.Normal && page.Text != null) {
+ if (tab.Alignment == TabAlignment.Left) {
+ int wo = interior.Width / 2;
+ int ho = interior.Height / 2;
+ dc.TranslateTransform (interior.X + wo, interior.Y + ho);
+ dc.RotateTransform (180);
+ dc.DrawString (page.Text, page.Font, ResPool.GetSolidBrush (SystemColors.ControlText), 0, 0, string_format);
+ dc.ResetTransform ();
+ } else {
+ dc.DrawString (page.Text, page.Font,
+ ResPool.GetSolidBrush (SystemColors.ControlText),
+ interior, string_format);
+ }
+ } else if (page.Text != null) {
+ DrawItemState state = DrawItemState.None;
+ if (page == tab.SelectedTab)
+ state |= DrawItemState.Selected;
+ DrawItemEventArgs e = new DrawItemEventArgs (dc,
+ tab.Font, bounds, tab.IndexForTabPage (page),
+ state, page.ForeColor, page.BackColor);
+ tab.OnDrawItemInternal (e);
+ return res;
+ }
+
+ return res;
+ }
+
+ public override void CPDrawComboButton( Graphics dc, Rectangle rectangle, ButtonState state ) {
+ Point[] arrow = new Point[ 3 ];
+ Point P1;
+ Point P2;
+ Point P3;
+ int centerX;
+ int centerY;
+ int shiftX;
+ int shiftY;
+ Rectangle rect;
+
+ bool pushed = false;
+
+ Color first_color = Color.White;
+ Color second_color = combobox_button_second_gradient_color;
+
+ dc.FillRectangle( ResPool.GetSolidBrush( Color.White ), rectangle );
+
+ if ( state == ButtonState.Pushed ) {
+ first_color = pressed_gradient_first_color;
+ second_color = pressed_gradient_second_color;
+ pushed = true;
+ }
+
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( rectangle.X, rectangle.Y + 2 ), new Point( rectangle.X, rectangle.Bottom - 2 ), first_color, second_color ) ) {
+ dc.FillRectangle( lgbr, rectangle.X + 2, rectangle.Y + 2, rectangle.Width - 4, rectangle.Height - 4 );
+ }
+
+ // inner borders
+ Pen tmp_pen = ResPool.GetPen( !pushed ? Color.White : pressed_inner_border_dark_color );
+ dc.DrawLine( tmp_pen, rectangle.X + 1, rectangle.Y + 1, rectangle.Right - 2, rectangle.Y + 1 );
+ dc.DrawLine( tmp_pen, rectangle.X + 1, rectangle.Y + 1, rectangle.X + 1, rectangle.Bottom - 2 );
+
+ tmp_pen = ResPool.GetPen( !pushed ? inner_border_dark_color : pressed_inner_border_dark_color );
+ dc.DrawLine( tmp_pen, rectangle.Right - 2, rectangle.Y + 2, rectangle.Right - 2, rectangle.Bottom - 2 );
+ dc.DrawLine( tmp_pen, rectangle.X + 2, rectangle.Bottom - 2, rectangle.Right - 2, rectangle.Bottom - 2 );
+
+ // border
+ Point[] points = new Point[] {
+ new Point( rectangle.X, rectangle.Y ),
+ new Point( rectangle.Right - 3, rectangle.Y ),
+ new Point( rectangle.Right - 1, rectangle.Y + 2 ),
+ new Point( rectangle.Right - 1, rectangle.Bottom - 3 ),
+ new Point( rectangle.Right - 3, rectangle.Bottom - 1 ),
+ new Point( rectangle.X, rectangle.Bottom - 1 ),
+ new Point( rectangle.X, rectangle.Y )
+ };
+
+ dc.DrawPolygon( ResPool.GetPen( pushed ? border_pressed_dark_color : border_normal_dark_color ), points );
+
+ // edges on right side
+ tmp_pen = ResPool.GetPen( control_parent_backcolor );
+ dc.DrawLine( tmp_pen, rectangle.Right - 1, rectangle.Y, rectangle.Right - 1, rectangle.Y + 1 );
+ dc.DrawLine( tmp_pen, rectangle.Right - 1, rectangle.Bottom - 1, rectangle.Right - 1, rectangle.Bottom - 2 );
+
+ tmp_pen = ResPool.GetPen( edge_bottom_inner_color );
+ dc.DrawLine( tmp_pen, rectangle.Right - 2, rectangle.Y, rectangle.Right - 1, rectangle.Y + 1 );
+ dc.DrawLine( tmp_pen, rectangle.Right - 2, rectangle.Bottom - 1, rectangle.Right - 1, rectangle.Bottom - 2 );
+
+ rect = new Rectangle( rectangle.X + 1 + rectangle.Width / 4, rectangle.Y + rectangle.Height / 4, rectangle.Width / 2 - 1, rectangle.Height / 2 );
+ centerX = rect.Left + rect.Width / 2;
+ centerY = rect.Top + rect.Height / 2;
+ shiftX = Math.Max( 1, rect.Width / 8 );
+ shiftY = Math.Max( 1, rect.Height / 8 );
+
+ if ( ( state & ButtonState.Pushed ) != 0 ) {
+ shiftX--;
+ shiftY--;
+ }
+
+ rect.Y -= shiftY;
+ centerY -= shiftY;
+
+ P1 = new Point( rect.Left, centerY );
+ P2 = new Point( centerX, rect.Bottom );
+ P3 = new Point( rect.Right, centerY );
+
+ arrow[ 0 ] = P1;
+ arrow[ 1 ] = P2;
+ arrow[ 2 ] = P3;
+
+ SmoothingMode old_smoothing_mode = dc.SmoothingMode;
+ dc.SmoothingMode = SmoothingMode.AntiAlias;
+
+ /* Draw the arrow */
+ if ( state == ButtonState.Inactive ) {
+ /* Move away from the shadow */
+ P1.X += 1; P1.Y += 1;
+ P2.X += 1; P2.Y += 1;
+ P3.X += 1; P3.Y += 1;
+
+ arrow[ 0 ] = P1;
+ arrow[ 1 ] = P2;
+ arrow[ 2 ] = P3;
+
+ using ( Pen pen = new Pen( SystemColors.ControlLightLight, 2 ) ) {
+ dc.DrawLines( pen, arrow );
+ }
+
+ P1 = new Point( rect.Left, centerY );
+ P2 = new Point( centerX, rect.Bottom );
+ P3 = new Point( rect.Right, centerY );
+
+ arrow[ 0 ] = P1;
+ arrow[ 1 ] = P2;
+ arrow[ 2 ] = P3;
+
+ using ( Pen pen = new Pen( SystemColors.ControlDark, 2 ) ) {
+ dc.DrawLines( pen, arrow );
+ }
+ } else {
+ using ( Pen pen = new Pen( SystemColors.ControlText, 2 ) ) {
+ dc.DrawLines( pen, arrow );
+ }
+ }
+
+ dc.SmoothingMode = old_smoothing_mode;
+ }
+
+ /* Scroll button: regular button + direction arrow */
+ public override void CPDrawScrollButton( Graphics dc, Rectangle area, ScrollButton scroll_button_type, ButtonState state ) {
+ bool enabled = ( state == ButtonState.Inactive ) ? false: true;
+
+ DrawScrollButtonPrimitive( dc, area, state, scroll_button_type );
+
+ if ( area.Width < 12 || area.Height < 12 ) /* Cannot see a thing at smaller sizes */
+ return;
+
+ Color color_arrow;
+
+ if ( enabled )
+ color_arrow = arrow_color;
+ else
+ color_arrow = ColorGrayText;
+
+ /* Paint arrows */
+
+ int centerX = area.Left + area.Width / 2;
+ int centerY = area.Top + area.Height / 2;
+
+ int shift = 0;
+
+ if ( ( state & ButtonState.Pushed ) != 0 )
+ shift = 1;
+
+ Point[] arrow = new Point[ 4 ];
+
+ switch ( scroll_button_type ) {
+ case ScrollButton.Down:
+ centerY += shift + 1;
+ arrow[ 0 ] = new Point( centerX - 4, centerY - 2 );
+ arrow[ 1 ] = new Point( centerX, centerY + 2 );
+ arrow[ 2 ] = new Point( centerX + 4, centerY - 2 );
+ arrow[ 3 ] = new Point( centerX - 4, centerY - 2 );
+ break;
+ case ScrollButton.Up:
+ centerY -= shift;
+ arrow[ 0 ] = new Point( centerX - 4, centerY + 2 );
+ arrow[ 1 ] = new Point( centerX, centerY - 2 );
+ arrow[ 2 ] = new Point( centerX + 4, centerY + 2 );
+ arrow[ 3 ] = new Point( centerX - 4, centerY + 2 );
+ break;
+ case ScrollButton.Left:
+ centerX -= shift;
+ arrow[ 0 ] = new Point( centerX + 2, centerY - 4 );
+ arrow[ 1 ] = new Point( centerX + 2, centerY + 4 );
+ arrow[ 2 ] = new Point( centerX - 2, centerY );
+ arrow[ 3 ] = new Point( centerX + 2, centerY - 4 );
+ break;
+ case ScrollButton.Right:
+ centerX += shift + 1;
+ arrow[ 0 ] = new Point( centerX - 2, centerY - 4 );
+ arrow[ 1 ] = new Point( centerX + 2, centerY );
+ arrow[ 2 ] = new Point( centerX - 2, centerY + 4 );
+ arrow[ 3 ] = new Point( centerX - 2, centerY - 4 );
+ break;
+ default:
+ break;
+ }
+
+ SmoothingMode old_smoothing_mode = dc.SmoothingMode;
+ dc.SmoothingMode = SmoothingMode.AntiAlias;
+ dc.FillPolygon( ResPool.GetSolidBrush( color_arrow ), arrow );
+ dc.SmoothingMode = old_smoothing_mode;
+ }
+
+ public override void CPDrawSizeGrip( Graphics dc, Color backColor, Rectangle bounds ) {
+ Point pt1 = new Point( bounds.Right - 3, bounds.Bottom );
+ Point pt2 = new Point( bounds.Right, bounds.Bottom - 3 );
+
+ // diagonals
+ Pen tmp_pen = ResPool.GetPen( Color.White );
+ for ( int i = 0; i < 4; i++ ) {
+ dc.DrawLine( tmp_pen, pt1.X - i * 4, pt1.Y, pt2.X, pt2.Y - i * 4 );
+ }
+
+ pt1.X += 1;
+ pt2.Y += 1;
+
+ tmp_pen = ResPool.GetPen( pressed_inner_border_dark_color );
+ for ( int i = 0; i < 4; i++ ) {
+ dc.DrawLine( tmp_pen, pt1.X - i * 4, pt1.Y, pt2.X, pt2.Y - i * 4 );
+ }
+ }
+
+ private void DrawScrollBarThumb( Graphics dc, Rectangle area, ScrollBar bar ) {
+ LinearGradientBrush lgbr = null;
+
+ if ( bar.vert )
+ lgbr = new LinearGradientBrush( new Point( area.X + 2, area.Y + 2 ), new Point( area.Right - 2, area.Y + 2 ), scrollbar_gradient_first_color, scrollbar_gradient_second_color );
+ else
+ lgbr = new LinearGradientBrush( new Point( area.X + 2, area.Y + 2 ), new Point( area.X + 2, area.Bottom - 2 ), scrollbar_gradient_first_color, scrollbar_gradient_second_color );
+
+ dc.FillRectangle( lgbr, area.X + 2, area.Y + 2, area.Width - 4, area.Height - 4 );
+
+ lgbr.Dispose( );
+
+ // outer border
+ Pen pen = ResPool.GetPen( border_normal_dark_color );
+
+ dc.DrawRectangle( pen, area.X, area.Y, area.Width - 1, area.Height - 1 );
+
+ // inner border
+ pen = ResPool.GetPen( Color.White );
+ dc.DrawLine( pen, area.X + 1, area.Bottom - 2, area.X + 1, area.Y + 1 );
+ dc.DrawLine( pen, area.X + 2, area.Y + 1, area.Right - 2, area.Y + 1 );
+
+ pen = ResPool.GetPen( inner_border_dark_color );
+ dc.DrawLine( pen, area.Right - 2, area.Y + 2, area.Right - 2, area.Bottom - 2 );
+ dc.DrawLine( pen, area.X + 2, area.Bottom - 2, area.Right - 3, area.Bottom - 2 );
+
+ if ( bar.vert ) {
+ if ( area.Height > 12 ) {
+ int mid_y = area.Y + ( area.Height / 2 );
+ int mid_x = area.X + ( area.Width / 2 );
+
+ pen = ResPool.GetPen( pressed_inner_border_dark_color );
+ dc.DrawLine( pen, mid_x - 3, mid_y, mid_x + 3, mid_y );
+ dc.DrawLine( pen, mid_x - 3, mid_y - 3, mid_x + 3, mid_y - 3 );
+ dc.DrawLine( pen, mid_x - 3, mid_y + 3, mid_x + 3, mid_y + 3 );
+
+ Pen spen = ResPool.GetPen( Color.White );
+ dc.DrawLine( spen, mid_x - 3, mid_y + 1, mid_x + 3, mid_y + 1 );
+ dc.DrawLine( spen, mid_x - 3, mid_y - 2, mid_x + 3, mid_y - 2 );
+ dc.DrawLine( spen, mid_x - 3, mid_y + 4, mid_x + 3, mid_y + 4 );
+ }
+ } else {
+ // draw grip lines only if there is enough space
+ if ( area.Width > 12 ) {
+ int mid_x = area.X + ( area.Width / 2 );
+ int mid_y = area.Y + ( area.Height / 2 );
+
+ pen = ResPool.GetPen( pressed_inner_border_dark_color );
+ dc.DrawLine( pen, mid_x, mid_y - 3, mid_x, mid_y + 3 );
+ dc.DrawLine( pen, mid_x - 3, mid_y - 3, mid_x - 3, mid_y + 3 );
+ dc.DrawLine( pen, mid_x + 3, mid_y - 3, mid_x + 3, mid_y + 3 );
+
+ Pen spen = ResPool.GetPen( Color.White );
+ dc.DrawLine( spen, mid_x + 1, mid_y - 3, mid_x + 1, mid_y + 3 );
+ dc.DrawLine( spen, mid_x - 2, mid_y - 3, mid_x - 2, mid_y + 3 );
+ dc.DrawLine( spen, mid_x + 4, mid_y - 3, mid_x + 4, mid_y + 3 );
+ }
+ }
+ }
+
+ public void DrawScrollButtonPrimitive( Graphics dc, Rectangle area, ButtonState state, ScrollButton scroll_button_type ) {
+ Pen pen = ResPool.GetPen( border_normal_dark_color );
+
+ Color first_gradient_color = gradient_first_color;
+ Color second_gradient_color = gradient_second_color_nr2;
+
+ bool pushed = false;
+
+ if ( ( state & ButtonState.Pushed ) == ButtonState.Pushed ) {
+ first_gradient_color = pressed_gradient_first_color;
+ second_gradient_color = pressed_gradient_second_color;
+ pushed = true;
+ }
+
+ Point[] points = null;
+
+ LinearGradientBrush lgbr = null;
+
+ switch ( scroll_button_type ) {
+ case ScrollButton.Left:
+ // FIXME: temporary fix for artefacts, it should use the backcolor of the parent control
+ dc.DrawLine( ResPool.GetPen( ColorControl ), area.X, area.Y, area.X, area.Bottom - 1 );
+
+ lgbr = new LinearGradientBrush( new Point( area.X + 2, area.Y + 2 ), new Point( area.X + 2, area.Bottom - 2 ), first_gradient_color, second_gradient_color );
+ dc.FillRectangle( lgbr, area.X + 2, area.Y + 2, area.Width - 4, area.Height - 2 );
+
+ Pen tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : Color.White );
+ dc.DrawLine( tmp_pen, area.X + 1, area.Y + 2, area.X + 1, area.Bottom - 2 );
+ dc.DrawLine( tmp_pen, area.X + 2, area.Y + 1, area.Right - 2, area.Y + 1 );
+
+ tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : inner_border_dark_color );
+ dc.DrawLine( tmp_pen, area.Right - 2, area.Y + 2, area.Right - 2, area.Bottom - 2 );
+ dc.DrawLine( tmp_pen, area.X + 2, area.Bottom - 2, area.Right - 3, area.Bottom - 2 );
+
+ tmp_pen = ResPool.GetPen( edge_top_inner_color );
+ dc.DrawLine( tmp_pen, area.X, area.Y + 1, area.X + 1, area.Y );
+ dc.DrawLine( tmp_pen, area.X, area.Bottom - 2, area.X + 1, area.Bottom - 1 );
+
+ points = new Point[] {
+ new Point( area.X + 2, area.Y ),
+ new Point( area.Right - 1, area.Y ),
+ new Point( area.Right - 1, area.Bottom - 1 ),
+ new Point( area.X + 2, area.Bottom - 1 ),
+ new Point( area.X, area.Bottom - 3 ),
+ new Point( area.X, area.Y + 2 ),
+ new Point( area.X + 2, area.Y )
+ };
+ dc.DrawPolygon( pen, points );
+ break;
+ case ScrollButton.Right:
+ // FIXME: temporary fix for artefacts, it should use the backcolor of the parent control
+ dc.DrawLine( ResPool.GetPen( ColorControl ), area.Right - 1, area.Y, area.Right - 1, area.Bottom - 1 );
+
+ lgbr = new LinearGradientBrush( new Point( area.X + 2, area.Y + 2 ), new Point( area.X + 2, area.Bottom - 2 ), first_gradient_color, second_gradient_color );
+ dc.FillRectangle( lgbr, area.X + 2, area.Y + 2, area.Width - 4, area.Height - 2 );
+
+ tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : Color.White );
+ dc.DrawLine( tmp_pen, area.X + 1, area.Y + 1, area.X + 1, area.Bottom - 2 );
+ dc.DrawLine( tmp_pen, area.X + 2, area.Y + 1, area.Right - 2, area.Y + 1 );
+
+ tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : inner_border_dark_color );
+ dc.DrawLine( tmp_pen, area.Right - 2, area.Y + 2, area.Right - 2, area.Bottom - 2 );
+ dc.DrawLine( tmp_pen, area.X + 2, area.Bottom - 2, area.Right - 3, area.Bottom - 2 );
+
+ tmp_pen = ResPool.GetPen( edge_top_inner_color );
+ dc.DrawLine( tmp_pen, area.Right - 2, area.Y, area.Right - 1, area.Y + 1 );
+ dc.DrawLine( tmp_pen, area.Right - 1, area.Bottom - 2, area.Right - 2, area.Bottom - 1 );
+
+ points = new Point[] {
+ new Point( area.X, area.Y ),
+ new Point( area.Right - 3, area.Y ),
+ new Point( area.Right - 1, area.Y + 2 ),
+ new Point( area.Right - 1, area.Bottom - 3 ),
+ new Point( area.Right - 3, area.Bottom - 1 ),
+ new Point( area.X, area.Bottom - 1 ),
+ new Point( area.X, area.Y ),
+ };
+ dc.DrawPolygon( pen, points );
+ break;
+ case ScrollButton.Up:
+ // FIXME: temporary fix for artefacts, it should use the backcolor of the parent control
+ dc.DrawLine( ResPool.GetPen( ColorControl ), area.X, area.Y, area.Right - 1, area.Y );
+
+ lgbr = new LinearGradientBrush( new Point( area.X + 2, area.Y ), new Point( area.Right - 2, area.Y ), first_gradient_color, second_gradient_color );
+ dc.FillRectangle( lgbr, area.X + 2, area.Y + 2, area.Width - 4, area.Height - 4 );
+
+ tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : Color.White );
+ dc.DrawLine( tmp_pen, area.X + 1, area.Y + 1, area.X + 1, area.Bottom - 2 );
+ dc.DrawLine( tmp_pen, area.X + 2, area.Y + 1, area.Right - 2, area.Y + 1 );
+
+ tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : inner_border_dark_color );
+ dc.DrawLine( tmp_pen, area.Right - 2, area.Y + 2, area.Right - 2, area.Bottom - 2 );
+ dc.DrawLine( tmp_pen, area.X + 2, area.Bottom - 2, area.Right - 3, area.Bottom - 2 );
+
+ tmp_pen = ResPool.GetPen( edge_top_inner_color );
+ dc.DrawLine( tmp_pen, area.X, area.Y + 1, area.X + 1, area.Y );
+ dc.DrawLine( tmp_pen, area.Right - 2, area.Y, area.Right - 1, area.Y + 1 );
+
+ points = new Point[] {
+ new Point( area.X + 2, area.Y ),
+ new Point( area.Right - 3, area.Y ),
+ new Point( area.Right - 1, area.Y + 2 ),
+ new Point( area.Right - 1, area.Bottom - 1 ),
+ new Point( area.X, area.Bottom - 1 ),
+ new Point( area.X, area.Y + 2 ),
+ new Point( area.X + 2, area.Y )
+ };
+ dc.DrawPolygon( pen, points );
+ break;
+ case ScrollButton.Down:
+ // FIXME: temporary fix for artefacts, it should use the backcolor of the parent control
+ dc.DrawLine( ResPool.GetPen( ColorControl ), area.X, area.Bottom - 1, area.Right - 1, area.Bottom - 1 );
+
+ lgbr = new LinearGradientBrush( new Point( area.X + 2, area.Y ), new Point( area.Right - 2, area.Y ), first_gradient_color, second_gradient_color );
+ dc.FillRectangle( lgbr, area.X + 2, area.Y + 2, area.Width - 4, area.Height - 4 );
+
+ tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : Color.White );
+ dc.DrawLine( tmp_pen, area.X + 1, area.Y + 1, area.X + 1, area.Bottom - 2 );
+ dc.DrawLine( tmp_pen, area.X + 2, area.Y + 1, area.Right - 2, area.Y + 1 );
+
+ tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : inner_border_dark_color );
+ dc.DrawLine( tmp_pen, area.Right - 2, area.Y + 2, area.Right - 2, area.Bottom - 2 );
+ dc.DrawLine( tmp_pen, area.X + 2, area.Bottom - 2, area.Right - 3, area.Bottom - 2 );
+
+ tmp_pen = ResPool.GetPen( edge_top_inner_color );
+ dc.DrawLine( tmp_pen, area.X, area.Bottom - 2, area.X + 1, area.Bottom - 1 );
+ dc.DrawLine( tmp_pen, area.Right - 2, area.Bottom - 1, area.Right - 1, area.Bottom - 2 );
+
+ points = new Point[] {
+ new Point( area.X, area.Y ),
+ new Point( area.Right - 1, area.Y ),
+ new Point( area.Right - 1, area.Bottom - 3 ),
+ new Point( area.Right - 3, area.Bottom - 1 ),
+ new Point( area.X + 2, area.Bottom - 1 ),
+ new Point( area.X, area.Bottom - 3 ),
+ new Point( area.X, area.Y )
+ };
+ dc.DrawPolygon( pen, points );
+ break;
+ }
+
+ lgbr.Dispose( );
+ }
+
+ #region GroupBox
+ public override void DrawGroupBox( Graphics dc, Rectangle area, GroupBox box ) {
+ StringFormat text_format;
+ SizeF size;
+ int width;
+ int y;
+ Rectangle rect;
+
+ rect = box.ClientRectangle;
+
+ dc.FillRectangle( ResPool.GetSolidBrush( box.BackColor ), rect );
+
+ text_format = new StringFormat( );
+ text_format.HotkeyPrefix = HotkeyPrefix.Show;
+
+ size = dc.MeasureString( box.Text, box.Font );
+ width = (int) size.Width;
+
+ if ( width > box.Width - 16 )
+ width = box.Width - 16;
+
+ y = box.Font.Height / 2;
+
+ Pen pen = ResPool.GetPen( pressed_inner_border_dark_color );
+
+ /* Draw group box*/
+ Point[] points = {
+ new Point( 8 + width, y ),
+ new Point( box.Width - 3, y ),
+ new Point( box.Width - 1, y + 2 ),
+ new Point( box.Width - 1, box.Height - 3 ),
+ new Point( box.Width - 3, box.Height - 1 ),
+ new Point( 2, box.Height - 1 ),
+ new Point( 0, box.Height - 3 ),
+ new Point( 0, y + 2 ),
+ new Point( 2, y ),
+ new Point( 8, y )
+ };
+ dc.DrawLines( pen, points );
+
+ /* Text */
+ if ( box.Enabled ) {
+ dc.DrawString( box.Text, box.Font, ResPool.GetSolidBrush( box.ForeColor ), 10, 0, text_format );
+ } else {
+ CPDrawStringDisabled( dc, box.Text, box.Font, box.ForeColor,
+ new RectangleF( 10, 0, width, box.Font.Height ), text_format );
+ }
+ text_format.Dispose( );
+ }
+ #endregion
+
+ #region TrackBar
+ private void DrawTrackBar_Vertical( Graphics dc, Rectangle clip_rectangle, TrackBar tb,
+ ref Rectangle thumb_pos, ref Rectangle thumb_area,
+ float ticks, int value_pos, bool mouse_value ) {
+
+ Point toptick_startpoint = new Point( );
+ Point bottomtick_startpoint = new Point( );
+ Point channel_startpoint = new Point( );
+ float pixel_len;
+ float pixels_betweenticks;
+ const int space_from_right = 8;
+ const int space_from_left = 8;
+ Rectangle area = tb.ClientRectangle;
+
+ switch ( tb.TickStyle ) {
+ case TickStyle.BottomRight:
+ case TickStyle.None:
+ channel_startpoint.Y = 8;
+ channel_startpoint.X = 9;
+ bottomtick_startpoint.Y = 13;
+ bottomtick_startpoint.X = 24;
+ break;
+ case TickStyle.TopLeft:
+ channel_startpoint.Y = 8;
+ channel_startpoint.X = 19;
+ toptick_startpoint.Y = 13;
+ toptick_startpoint.X = 8;
+ break;
+ case TickStyle.Both:
+ channel_startpoint.Y = 8;
+ channel_startpoint.X = 18;
+ bottomtick_startpoint.Y = 13;
+ bottomtick_startpoint.X = 32;
+ toptick_startpoint.Y = 13;
+ toptick_startpoint.X = 8;
+ break;
+ default:
+ break;
+ }
+
+ thumb_area.X = area.X + channel_startpoint.X;
+ thumb_area.Y = area.Y + channel_startpoint.Y;
+ thumb_area.Height = area.Height - space_from_right - space_from_left;
+ thumb_area.Width = 4;
+
+ pixel_len = thumb_area.Height - 11;
+ pixels_betweenticks = pixel_len / ( tb.Maximum - tb.Minimum );
+
+ /* Convert thumb position from mouse position to value*/
+ if ( mouse_value ) {
+
+ if ( value_pos >= channel_startpoint.Y )
+ value_pos = (int)( ( (float) ( value_pos - channel_startpoint.Y ) ) / pixels_betweenticks );
+ else
+ value_pos = 0;
+
+ if ( value_pos + tb.Minimum > tb.Maximum )
+ value_pos = tb.Maximum - tb.Minimum;
+
+ tb.Value = value_pos + tb.Minimum;
+ }
+
+ thumb_pos.Width = 13;
+ thumb_pos.Height = 29;
+
+ thumb_pos.Y = channel_startpoint.Y + (int) ( pixels_betweenticks * (float) value_pos ) - ( thumb_pos.Height / 3 );
+
+ if ( thumb_pos.Y < channel_startpoint.Y )
+ thumb_pos.Y = channel_startpoint.Y;
+
+ if ( thumb_pos.Y > thumb_area.Bottom - 29 )
+ thumb_pos.Y = thumb_area.Bottom - 29;
+
+ /* Draw channel */
+ // bottom
+ Pen pen = ResPool.GetPen( tab_top_border_focus_color );
+ dc.DrawLine( pen, channel_startpoint.X, thumb_pos.Y + 29, channel_startpoint.X, thumb_area.Bottom );
+ dc.DrawLine( pen, channel_startpoint.X, thumb_area.Bottom, channel_startpoint.X + 4, thumb_area.Bottom );
+ dc.DrawLine( pen, channel_startpoint.X + 4, thumb_pos.Y + 29, channel_startpoint.X + 4, thumb_area.Bottom );
+
+ pen = ResPool.GetPen( menuitem_gradient_first_color );
+ dc.DrawLine( pen, channel_startpoint.X + 1, thumb_pos.Y + 28, channel_startpoint.X + 1, thumb_area.Bottom - 1 );
+ pen = ResPool.GetPen( trackbar_second_gradient_color );
+ dc.DrawLine( pen, channel_startpoint.X + 2, thumb_pos.Y + 28, channel_startpoint.X + 2, thumb_area.Bottom - 1 );
+ pen = ResPool.GetPen( trackbar_third_gradient_color );
+ dc.DrawLine( pen, channel_startpoint.X + 3, thumb_pos.Y + 28, channel_startpoint.X + 3, thumb_area.Bottom - 1 );
+
+ // top
+ pen = ResPool.GetPen( pressed_inner_border_dark_color );
+ dc.DrawLine( pen, channel_startpoint.X + 1, channel_startpoint.Y + 1, channel_startpoint.X + 1, thumb_pos.Y );
+ dc.DrawRectangle( ResPool.GetPen( scrollbar_background_color ), channel_startpoint.X + 2, channel_startpoint.Y + 1, 1, thumb_pos.Y );
+
+ pen = ResPool.GetPen( scrollbar_border_color );
+ dc.DrawLine( pen, channel_startpoint.X, channel_startpoint.Y, channel_startpoint.X, thumb_pos.Y );
+ dc.DrawLine( pen, channel_startpoint.X, channel_startpoint.Y, channel_startpoint.X + 4, channel_startpoint.Y );
+ dc.DrawLine( pen, channel_startpoint.X + 4, channel_startpoint.Y, channel_startpoint.X + 4, thumb_pos.Y );
+
+ /* Draw thumb */
+ thumb_pos.X = channel_startpoint.X - 4;
+
+ // inner border
+ pen = ResPool.GetPen( Color.White );
+ dc.DrawLine( pen, thumb_pos.X + 1, thumb_pos.Y + 1, thumb_pos.X + 1, thumb_pos.Bottom - 2 );
+ dc.DrawLine( pen, thumb_pos.X + 2, thumb_pos.Y + 1, thumb_pos.Right - 2, thumb_pos.Y + 1 );
+
+ pen = ResPool.GetPen( menu_separator_color );
+ dc.DrawLine( pen, thumb_pos.X + 2, thumb_pos.Bottom - 2, thumb_pos.Right - 2, thumb_pos.Bottom - 2 );
+ dc.DrawLine( pen, thumb_pos.Right - 2, thumb_pos.Y + 2, thumb_pos.Right - 2, thumb_pos.Bottom - 2 );
+
+ // outer border
+ Point[] points = {
+ new Point( thumb_pos.X + 2, thumb_pos.Y ),
+ new Point( thumb_pos.Right - 3 , thumb_pos.Y ),
+ new Point( thumb_pos.Right - 1, thumb_pos.Y + 2 ),
+ new Point( thumb_pos.Right - 1, thumb_pos.Bottom - 3 ),
+ new Point( thumb_pos.Right - 3, thumb_pos.Bottom - 1 ),
+ new Point( thumb_pos.X + 2, thumb_pos.Bottom - 1 ),
+ new Point( thumb_pos.X, thumb_pos.Bottom - 3 ),
+ new Point( thumb_pos.X, thumb_pos.Y + 2 ),
+ new Point( thumb_pos.X + 2, thumb_pos.Y )
+ };
+
+ dc.DrawLines( ResPool.GetPen( border_normal_dark_color ), points );
+
+ Color first_gradient_color = mouse_value ? button_edge_bottom_outer_color : trackbar_inner_first_gradient_color;
+ Color second_gradient_color = mouse_value ? trackbar_inner_pressed_second_gradient_color : trackbar_inner_second_gradient_color;
+
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( thumb_pos.X, thumb_pos.Y + 2 ), new Point( thumb_pos.X, thumb_pos.Bottom - 2 ), first_gradient_color, second_gradient_color ) ) {
+ dc.FillRectangle( lgbr, thumb_pos.X + 2, thumb_pos.Y + 2, thumb_pos.Width - 4, thumb_pos.Height - 4 );
+ }
+
+ // outer egdes
+ pen = ResPool.GetPen( edge_top_inner_color );
+ dc.DrawLine( pen, thumb_pos.X, thumb_pos.Y + 1, thumb_pos.X + 1, thumb_pos.Y );
+ dc.DrawLine( pen, thumb_pos.Right - 2, thumb_pos.Y, thumb_pos.Right - 1, thumb_pos.Y + 1 );
+
+ pen = ResPool.GetPen( edge_bottom_inner_color );
+ dc.DrawLine( pen, thumb_pos.X, thumb_pos.Bottom - 2, thumb_pos.X + 1, thumb_pos.Bottom - 1 );
+ dc.DrawLine( pen, thumb_pos.Right - 1, thumb_pos.Bottom - 2, thumb_pos.Right - 2, thumb_pos.Bottom - 1 );
+
+ // draw grip lines
+ pen = ResPool.GetPen( pressed_inner_border_dark_color );
+ dc.DrawLine( pen, thumb_pos.X + 4, thumb_pos.Y + 11, thumb_pos.X + 8, thumb_pos.Y + 11 );
+ dc.DrawLine( pen, thumb_pos.X + 4, thumb_pos.Y + 14, thumb_pos.X + 8, thumb_pos.Y + 14 );
+ dc.DrawLine( pen, thumb_pos.X + 4, thumb_pos.Y + 17, thumb_pos.X + 8, thumb_pos.Y + 17 );
+
+ pen = ResPool.GetPen( Color.White );
+ dc.DrawLine( pen, thumb_pos.X + 4, thumb_pos.Y + 12, thumb_pos.X + 8, thumb_pos.Y + 12 );
+ dc.DrawLine( pen, thumb_pos.X + 4, thumb_pos.Y + 15, thumb_pos.X + 8, thumb_pos.Y + 15 );
+ dc.DrawLine( pen, thumb_pos.X + 4, thumb_pos.Y + 18, thumb_pos.X + 8, thumb_pos.Y + 18 );
+
+ pixel_len = thumb_area.Height - 11;
+ pixels_betweenticks = pixel_len / ticks;
+
+ /* Draw ticks*/
+ thumb_area.X = thumb_pos.X;
+ thumb_area.Y = channel_startpoint.Y;
+ thumb_area.Width = thumb_pos.Width;
+
+ Region outside = new Region( area );
+ outside.Exclude( thumb_area );
+
+ if ( outside.IsVisible( clip_rectangle ) ) {
+ if ( pixels_betweenticks > 0 && ( ( tb.TickStyle & TickStyle.BottomRight ) == TickStyle.BottomRight ||
+ ( ( tb.TickStyle & TickStyle.Both ) == TickStyle.Both ) ) ) {
+
+ for ( float inc = 0; inc < ( pixel_len + 1 ); inc += pixels_betweenticks ) {
+ if ( inc == 0 || ( inc + pixels_betweenticks ) >= pixel_len + 1 )
+ dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + bottomtick_startpoint.X , area.Y + bottomtick_startpoint.Y + inc,
+ area.X + bottomtick_startpoint.X + 3, area.Y + bottomtick_startpoint.Y + inc );
+ else
+ dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + bottomtick_startpoint.X, area.Y + bottomtick_startpoint.Y + inc,
+ area.X + bottomtick_startpoint.X + 2, area.Y + bottomtick_startpoint.Y + inc );
+ }
+ }
+
+ if ( pixels_betweenticks > 0 && ( ( tb.TickStyle & TickStyle.TopLeft ) == TickStyle.TopLeft ||
+ ( ( tb.TickStyle & TickStyle.Both ) == TickStyle.Both ) ) ) {
+
+ pixel_len = thumb_area.Height - 11;
+ pixels_betweenticks = pixel_len / ticks;
+
+ for ( float inc = 0; inc < ( pixel_len + 1 ); inc += pixels_betweenticks ) {
+ if ( inc == 0 || ( inc + pixels_betweenticks ) >= pixel_len + 1 )
+ dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + toptick_startpoint.X - 3 , area.Y + toptick_startpoint.Y + inc,
+ area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc );
+ else
+ dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + toptick_startpoint.X - 2, area.Y + toptick_startpoint.Y + inc,
+ area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc );
+ }
+ }
+ }
+
+ outside.Dispose( );
+
+ }
+
+ private void DrawTrackBar_Horizontal( Graphics dc, Rectangle clip_rectangle, TrackBar tb,
+ ref Rectangle thumb_pos, ref Rectangle thumb_area,
+ float ticks, int value_pos, bool mouse_value ) {
+ Point toptick_startpoint = new Point( );
+ Point bottomtick_startpoint = new Point( );
+ Point channel_startpoint = new Point( );
+ float pixel_len;
+ float pixels_betweenticks;
+ const int space_from_right = 8;
+ const int space_from_left = 8;
+ Rectangle area = tb.ClientRectangle;
+
+ switch ( tb.TickStyle ) {
+ case TickStyle.BottomRight:
+ case TickStyle.None:
+ channel_startpoint.X = 8;
+ channel_startpoint.Y = 9;
+ bottomtick_startpoint.X = 13;
+ bottomtick_startpoint.Y = 24;
+ break;
+ case TickStyle.TopLeft:
+ channel_startpoint.X = 8;
+ channel_startpoint.Y = 19;
+ toptick_startpoint.X = 13;
+ toptick_startpoint.Y = 8;
+ break;
+ case TickStyle.Both:
+ channel_startpoint.X = 8;
+ channel_startpoint.Y = 18;
+ bottomtick_startpoint.X = 13;
+ bottomtick_startpoint.Y = 32;
+ toptick_startpoint.X = 13;
+ toptick_startpoint.Y = 8;
+ break;
+ default:
+ break;
+ }
+
+ thumb_area.X = area.X + channel_startpoint.X;
+ thumb_area.Y = area.Y + channel_startpoint.Y;
+ thumb_area.Width = area.Width - space_from_right - space_from_left;
+ thumb_area.Height = 4;
+
+ pixel_len = thumb_area.Width - 11;
+ pixels_betweenticks = pixel_len / ( tb.Maximum - tb.Minimum );
+
+ /* Convert thumb position from mouse position to value*/
+ if ( mouse_value ) {
+ if ( value_pos >= channel_startpoint.X )
+ value_pos = (int)( ( (float) ( value_pos - channel_startpoint.X ) ) / pixels_betweenticks );
+ else
+ value_pos = 0;
+
+ if ( value_pos + tb.Minimum > tb.Maximum )
+ value_pos = tb.Maximum - tb.Minimum;
+
+ tb.Value = value_pos + tb.Minimum;
+ }
+
+ thumb_pos.Width = 29;
+ thumb_pos.Height = 13;
+
+ thumb_pos.X = channel_startpoint.X + (int) ( pixels_betweenticks * (float) value_pos ) - ( thumb_pos.Width / 3 );
+
+ if ( thumb_pos.X < channel_startpoint.X )
+ thumb_pos.X = channel_startpoint.X;
+
+ if ( thumb_pos.X > thumb_area.Right - 29 )
+ thumb_pos.X = thumb_area.Right - 29;
+
+ /* Draw channel */
+ // left side
+ Pen pen = ResPool.GetPen( tab_top_border_focus_color );
+ dc.DrawLine( pen, channel_startpoint.X, channel_startpoint.Y, thumb_pos.X, channel_startpoint.Y );
+ dc.DrawLine( pen, channel_startpoint.X, channel_startpoint.Y, channel_startpoint.X, channel_startpoint.Y + 4 );
+ dc.DrawLine( pen, channel_startpoint.X, channel_startpoint.Y + 4, thumb_pos.X, channel_startpoint.Y + 4 );
+
+ pen = ResPool.GetPen( menuitem_gradient_first_color );
+ dc.DrawLine( pen, channel_startpoint.X + 1, channel_startpoint.Y + 1, thumb_pos.X, channel_startpoint.Y + 1 );
+ pen = ResPool.GetPen( trackbar_second_gradient_color );
+ dc.DrawLine( pen, channel_startpoint.X + 1, channel_startpoint.Y + 2, thumb_pos.X, channel_startpoint.Y + 2 );
+ pen = ResPool.GetPen( trackbar_third_gradient_color );
+ dc.DrawLine( pen, channel_startpoint.X + 1, channel_startpoint.Y + 3, thumb_pos.X, channel_startpoint.Y + 3 );
+
+ // right side
+ pen = ResPool.GetPen( pressed_inner_border_dark_color );
+ dc.DrawLine( pen, thumb_pos.X + 29, channel_startpoint.Y + 1, thumb_area.Right - 1, channel_startpoint.Y + 1 );
+ dc.DrawRectangle( ResPool.GetPen( scrollbar_background_color ), thumb_pos.X + 29, channel_startpoint.Y + 2, thumb_area.Right - thumb_pos.X - 30, 1 );
+
+ pen = ResPool.GetPen( scrollbar_border_color );
+ dc.DrawLine( pen, thumb_pos.X + 29, channel_startpoint.Y, thumb_area.Right, channel_startpoint.Y );
+ dc.DrawLine( pen, thumb_area.Right, channel_startpoint.Y, thumb_area.Right, channel_startpoint.Y + 4 );
+ dc.DrawLine( pen, thumb_pos.X + 29, channel_startpoint.Y + 4, thumb_area.Right, channel_startpoint.Y + 4 );
+
+ /* Draw thumb */
+
+ thumb_pos.Y = channel_startpoint.Y - 4;
+
+ // inner border
+ pen = ResPool.GetPen( Color.White );
+ dc.DrawLine( pen, thumb_pos.X + 1, thumb_pos.Y + 1, thumb_pos.X + 1, thumb_pos.Bottom - 2 );
+ dc.DrawLine( pen, thumb_pos.X + 2, thumb_pos.Y + 1, thumb_pos.Right - 2, thumb_pos.Y + 1 );
+
+ pen = ResPool.GetPen( menu_separator_color );
+ dc.DrawLine( pen, thumb_pos.X + 2, thumb_pos.Bottom - 2, thumb_pos.Right - 2, thumb_pos.Bottom - 2 );
+ dc.DrawLine( pen, thumb_pos.Right - 2, thumb_pos.Y + 2, thumb_pos.Right - 2, thumb_pos.Bottom - 2 );
+
+ // outer border
+ Point[] points = {
+ new Point( thumb_pos.X + 2, thumb_pos.Y ),
+ new Point( thumb_pos.Right - 3 , thumb_pos.Y ),
+ new Point( thumb_pos.Right - 1, thumb_pos.Y + 2 ),
+ new Point( thumb_pos.Right - 1, thumb_pos.Bottom - 3 ),
+ new Point( thumb_pos.Right - 3, thumb_pos.Bottom - 1 ),
+ new Point( thumb_pos.X + 2, thumb_pos.Bottom - 1 ),
+ new Point( thumb_pos.X, thumb_pos.Bottom - 3 ),
+ new Point( thumb_pos.X, thumb_pos.Y + 2 ),
+ new Point( thumb_pos.X + 2, thumb_pos.Y )
+ };
+
+ dc.DrawLines( ResPool.GetPen( border_normal_dark_color ), points );
+
+ Color first_gradient_color = mouse_value ? button_edge_bottom_outer_color : trackbar_inner_first_gradient_color;
+ Color second_gradient_color = mouse_value ? trackbar_inner_pressed_second_gradient_color : trackbar_inner_second_gradient_color;
+
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( thumb_pos.X, thumb_pos.Y + 2 ), new Point( thumb_pos.X, thumb_pos.Bottom - 2 ), first_gradient_color, second_gradient_color ) ) {
+ dc.FillRectangle( lgbr, thumb_pos.X + 2, thumb_pos.Y + 2, thumb_pos.Width - 4, thumb_pos.Height - 4 );
+ }
+
+ // outer egdes
+ pen = ResPool.GetPen( edge_top_inner_color );
+ dc.DrawLine( pen, thumb_pos.X, thumb_pos.Y + 1, thumb_pos.X + 1, thumb_pos.Y );
+ dc.DrawLine( pen, thumb_pos.Right - 2, thumb_pos.Y, thumb_pos.Right - 1, thumb_pos.Y + 1 );
+
+ pen = ResPool.GetPen( edge_bottom_inner_color );
+ dc.DrawLine( pen, thumb_pos.X, thumb_pos.Bottom - 2, thumb_pos.X + 1, thumb_pos.Bottom - 1 );
+ dc.DrawLine( pen, thumb_pos.Right - 1, thumb_pos.Bottom - 2, thumb_pos.Right - 2, thumb_pos.Bottom - 1 );
+
+ // draw grip lines
+ pen = ResPool.GetPen( pressed_inner_border_dark_color );
+ dc.DrawLine( pen, thumb_pos.X + 11, thumb_pos.Y + 4, thumb_pos.X + 11, thumb_pos.Y + 8 );
+ dc.DrawLine( pen, thumb_pos.X + 14, thumb_pos.Y + 4, thumb_pos.X + 14, thumb_pos.Y + 8 );
+ dc.DrawLine( pen, thumb_pos.X + 17, thumb_pos.Y + 4, thumb_pos.X + 17, thumb_pos.Y + 8 );
+
+ pen = ResPool.GetPen( Color.White );
+ dc.DrawLine( pen, thumb_pos.X + 12, thumb_pos.Y + 4, thumb_pos.X + 12, thumb_pos.Y + 8 );
+ dc.DrawLine( pen, thumb_pos.X + 15, thumb_pos.Y + 4, thumb_pos.X + 15, thumb_pos.Y + 8 );
+ dc.DrawLine( pen, thumb_pos.X + 18, thumb_pos.Y + 4, thumb_pos.X + 18, thumb_pos.Y + 8 );
+
+ pixel_len = thumb_area.Width - 11;
+ pixels_betweenticks = pixel_len / ticks;
+
+ /* Draw ticks*/
+ thumb_area.Y = thumb_pos.Y;
+ thumb_area.X = channel_startpoint.X;
+ thumb_area.Height = thumb_pos.Height;
+ Region outside = new Region( area );
+ outside.Exclude( thumb_area );
+
+ if ( outside.IsVisible( clip_rectangle ) ) {
+ if ( pixels_betweenticks > 0 && ( ( tb.TickStyle & TickStyle.BottomRight ) == TickStyle.BottomRight ||
+ ( ( tb.TickStyle & TickStyle.Both ) == TickStyle.Both ) ) ) {
+
+ for ( float inc = 0; inc < ( pixel_len + 1 ); inc += pixels_betweenticks ) {
+ if ( inc == 0 || ( inc + pixels_betweenticks ) >= pixel_len + 1 )
+ dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y,
+ area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y + 3 );
+ else
+ dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y,
+ area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y + 2 );
+ }
+ }
+
+ if ( pixels_betweenticks > 0 && ( ( tb.TickStyle & TickStyle.TopLeft ) == TickStyle.TopLeft ||
+ ( ( tb.TickStyle & TickStyle.Both ) == TickStyle.Both ) ) ) {
+
+ for ( float inc = 0; inc < ( pixel_len + 1 ); inc += pixels_betweenticks ) {
+ if ( inc == 0 || ( inc + pixels_betweenticks ) >= pixel_len + 1 )
+ dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y - 3,
+ area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y );
+ else
+ dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y - 2,
+ area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y );
+ }
+ }
+ }
+
+ outside.Dispose( );
+ }
+
+ public override void DrawTrackBar( Graphics dc, Rectangle clip_rectangle, TrackBar tb ) {
+ int value_pos;
+ bool mouse_value;
+ float ticks = ( tb.Maximum - tb.Minimum ) / tb.tickFrequency; /* N of ticks draw*/
+ Rectangle area;
+ Rectangle thumb_pos = tb.ThumbPos;
+ Rectangle thumb_area = tb.ThumbArea;
+
+ if ( tb.thumb_pressed ) {
+ value_pos = tb.thumb_mouseclick;
+ mouse_value = true;
+ } else {
+ value_pos = tb.Value - tb.Minimum;
+ mouse_value = false;
+ }
+
+ area = tb.ClientRectangle;
+
+ /* Control Background */
+ if ( tb.BackColor == DefaultControlBackColor ) {
+ dc.FillRectangle( ResPool.GetSolidBrush( ColorControl ), clip_rectangle );
+ } else {
+ dc.FillRectangle( ResPool.GetSolidBrush( tb.BackColor ), clip_rectangle );
+ }
+
+ if ( tb.Orientation == Orientation.Vertical ) {
+ DrawTrackBar_Vertical( dc, clip_rectangle, tb, ref thumb_pos, ref thumb_area,
+ ticks, value_pos, mouse_value );
+
+ } else {
+ DrawTrackBar_Horizontal( dc, clip_rectangle, tb, ref thumb_pos, ref thumb_area,
+ ticks, value_pos, mouse_value );
+ }
+
+ // TODO: draw better focus rectangle
+ if ( tb.Focused ) {
+ dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorControl, Color.Black ), area.X, area.Y, area.Width - 1, 1 );
+ dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorControl, Color.Black ), area.X, area.Y + area.Height - 1, area.Width - 1, 1 );
+ dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorControl, Color.Black ), area.X, area.Y, 1, area.Height - 1 );
+ dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorControl, Color.Black ), area.X + area.Width - 1, area.Y, 1, area.Height - 1 );
+ }
+
+ tb.ThumbPos = thumb_pos;
+ tb.ThumbArea = thumb_area;
+ }
+ #endregion // TrackBar
+
+ #region ListView
+ // draws the ListViewItem of the given index
+ protected override void DrawListViewItem( Graphics dc, ListView control, ListViewItem item ) {
+ Rectangle rect_checkrect = item.CheckRectReal;
+ Rectangle rect_iconrect = item.GetBounds( ItemBoundsPortion.Icon );
+ Rectangle full_rect = item.GetBounds( ItemBoundsPortion.Entire );
+ Rectangle text_rect = item.GetBounds( ItemBoundsPortion.Label );
+
+ if ( control.CheckBoxes ) {
+ if ( control.StateImageList == null ) {
+ // Make sure we've got at least a line width of 1
+ int check_wd = Math.Max( 3, rect_checkrect.Width / 6 );
+ int scale = Math.Max( 1, rect_checkrect.Width / 12 );
+
+ // set the checkbox background
+ dc.FillRectangle( this.ResPool.GetSolidBrush( this.ColorWindow ),
+ rect_checkrect );
+ // define a rectangle inside the border area
+ Rectangle rect = new Rectangle( rect_checkrect.X + 2,
+ rect_checkrect.Y + 2,
+ rect_checkrect.Width - 4,
+ rect_checkrect.Height - 4 );
+ Pen pen = new Pen( this.ColorWindowText, 2 );
+ dc.DrawRectangle( pen, rect );
+
+ // Need to draw a check-mark
+ if ( item.Checked ) {
+ pen.Width = 1;
+ // adjustments to get the check-mark at the right place
+ rect.X ++; rect.Y ++;
+ // following logic is taken from DrawFrameControl method
+ for ( int i = 0; i < check_wd; i++ ) {
+ dc.DrawLine( pen, rect.Left + check_wd / 2,
+ rect.Top + check_wd + i,
+ rect.Left + check_wd / 2 + 2 * scale,
+ rect.Top + check_wd + 2 * scale + i );
+ dc.DrawLine( pen,
+ rect.Left + check_wd / 2 + 2 * scale,
+ rect.Top + check_wd + 2 * scale + i,
+ rect.Left + check_wd / 2 + 6 * scale,
+ rect.Top + check_wd - 2 * scale + i );
+ }
+ }
+ } else {
+ if ( item.Checked && control.StateImageList.Images.Count > 1 )
+ control.StateImageList.Draw( dc,
+ rect_checkrect.Location, 1 );
+ else if ( ! item.Checked && control.StateImageList.Images.Count > 0 )
+ control.StateImageList.Draw( dc,
+ rect_checkrect.Location, 0 );
+ }
+ }
+
+ // Item is drawn as a special case, as it is not just text
+ if ( control.View == View.LargeIcon ) {
+ if ( item.ImageIndex > -1 &&
+ control.LargeImageList != null &&
+ item.ImageIndex < control.LargeImageList.Images.Count ) {
+ // center image
+ Point image_location = rect_iconrect.Location;
+ Image image = control.LargeImageList.Images[ item.ImageIndex ];
+ if ( image.Width < rect_iconrect.Width ) {
+ int icon_rect_middle = rect_iconrect.Width / 2;
+ int image_middle = image.Width / 2;
+ image_location.X = image_location.X + icon_rect_middle - image_middle;
+ }
+ control.LargeImageList.Draw( dc, image_location,
+ item.ImageIndex );
+ }
+ } else {
+ if ( item.ImageIndex > -1 &&
+ control.SmallImageList != null &&
+ item.ImageIndex < control.SmallImageList.Images.Count )
+ control.SmallImageList.Draw( dc, rect_iconrect.Location,
+ item.ImageIndex );
+ }
+
+ // draw the item text
+ // format for the item text
+ StringFormat format = new StringFormat( );
+ format.LineAlignment = StringAlignment.Center;
+ if ( control.View == View.LargeIcon )
+ format.Alignment = StringAlignment.Center;
+ else
+ format.Alignment = StringAlignment.Near;
+
+ if ( !control.LabelWrap )
+ format.FormatFlags = StringFormatFlags.NoWrap;
+
+ if ( item.Selected ) {
+ if ( control.View == View.Details ) {
+ if ( control.FullRowSelect ) {
+ // fill the entire rect excluding the checkbox
+ full_rect.Location = item.GetBounds (ItemBoundsPortion.Label).Location;
+ dc.FillRectangle( this.ResPool.GetSolidBrush
+ ( this.ColorHighlight ), full_rect );
+ } else {
+ Size text_size = Size.Ceiling( dc.MeasureString( item.Text,
+ item.Font ) );
+ text_rect.Width = text_size.Width;
+ dc.FillRectangle( this.ResPool.GetSolidBrush
+ ( this.ColorHighlight ), text_rect );
+ }
+ } else {
+ /*Size text_size = Size.Ceiling (dc.MeasureString (item.Text,
+ item.Font));
+ Point loc = text_rect.Location;
+ loc.X += (text_rect.Width - text_size.Width) / 2;
+ text_rect.Width = text_size.Width;*/
+ dc.FillRectangle( this.ResPool.GetSolidBrush( this.ColorHighlight ),
+ text_rect );
+ }
+ } else
+ dc.FillRectangle( ResPool.GetSolidBrush( item.BackColor ), text_rect );
+
+ if ( item.Text != null && item.Text.Length > 0 ) {
+
+ if ( control.View != View.LargeIcon ) {
+ if ( item.Selected )
+ dc.DrawString( item.Text, item.Font, this.ResPool.GetSolidBrush
+ ( this.ColorHighlightText ), text_rect, format );
+ else
+ dc.DrawString( item.Text, item.Font, this.ResPool.GetSolidBrush
+ ( item.ForeColor ), text_rect, format );
+ } else {
+ // ListView CalcTextSize says wrapping is done for two lines only !?!
+ // text is centered for the complete text_rect but it should be centered per available row/line
+
+ // calculate how much lines we get out of text_rect and current item.Font
+ int nr_lines = text_rect.Height / item.Font.Height;
+ int rest = text_rect.Height % item.Font.Height;
+ int line_height = item.Font.Height + ( rest > 1 ? 2 : 0 );
+
+ Rectangle[] text_rects = new Rectangle[ nr_lines ];
+
+ for ( int i = 0; i < nr_lines; i++ ) {
+ text_rects[ i ].X = text_rect.X;
+ text_rects[ i ].Y = text_rect.Y + i * line_height;
+ text_rects[ i ].Width = text_rect.Width;
+ text_rects[ i ].Height = line_height;
+ }
+
+ string[] lines = new string[ nr_lines ];
+
+ string text = item.Text;
+
+ int line_nr = 0;
+ int current_pos = 0;
+ for ( int k = 1; k <= text.Length; k++ ) {
+ lines[ line_nr ] = text.Substring( current_pos, k - current_pos );
+
+ // FIXME: Graphics.MeasureString returns wrong results if there is a
+ // space char in the string
+ SizeF sizef = dc.MeasureString( lines[ line_nr ], item.Font, text_rect.Width, format );
+
+ if ( (int)sizef.Width > text_rect.Width - 3 ) {
+ lines[ line_nr ] = lines[ line_nr ].Remove( lines[ line_nr ].Length - 1, 1 );
+ k--;
+ current_pos = k;
+ line_nr++;
+ if ( line_nr == nr_lines )
+ break;
+ }
+ }
+
+ int j = 0;
+ foreach ( Rectangle t_rect in text_rects ) {
+ if ( item.Selected )
+ dc.DrawString( lines[ j ], item.Font, this.ResPool.GetSolidBrush
+ ( this.ColorHighlightText ), t_rect, format );
+ else
+ dc.DrawString( lines[ j ], item.Font, this.ResPool.GetSolidBrush
+ ( item.ForeColor ), t_rect, format );
+ j++;
+ }
+ }
+ }
+
+ if ( control.View == View.Details && control.Columns.Count > 0 ) {
+ // draw subitems for details view
+ ListViewItem.ListViewSubItemCollection subItems = item.SubItems;
+ int count = ( control.Columns.Count < subItems.Count ?
+ control.Columns.Count : subItems.Count );
+
+ if ( count > 0 ) {
+ ColumnHeader col;
+ ListViewItem.ListViewSubItem subItem;
+ Rectangle sub_item_rect = text_rect;
+
+ // set the format for subitems
+ format.FormatFlags = StringFormatFlags.NoWrap;
+ format.Alignment = StringAlignment.Near;
+
+ // 0th subitem is the item already drawn
+ for ( int index = 1; index < count; index++ ) {
+ subItem = subItems[ index ];
+ col = control.Columns[ index ];
+ sub_item_rect.X = col.Rect.Left;
+ sub_item_rect.Width = col.Wd;
+ sub_item_rect.X -= control.h_marker;
+
+ SolidBrush sub_item_back_br = null;
+ SolidBrush sub_item_fore_br = null;
+ Font sub_item_font = null;
+
+ if ( item.UseItemStyleForSubItems ) {
+ sub_item_back_br = this.ResPool.GetSolidBrush
+ ( item.BackColor );
+ sub_item_fore_br = this.ResPool.GetSolidBrush
+ ( item.ForeColor );
+ sub_item_font = item.Font;
+ } else {
+ sub_item_back_br = this.ResPool.GetSolidBrush
+ ( subItem.BackColor );
+ sub_item_fore_br = this.ResPool.GetSolidBrush
+ ( subItem.ForeColor );
+ sub_item_font = subItem.Font;
+ }
+
+ // In case of fullrowselect, background is filled
+ // for the entire rect above
+ if ( item.Selected && control.FullRowSelect ) {
+ if ( subItem.Text != null && subItem.Text.Length > 0 )
+ dc.DrawString( subItem.Text, sub_item_font,
+ this.ResPool.GetSolidBrush
+ ( this.ColorHighlightText ),
+ sub_item_rect, format );
+ } else {
+ dc.FillRectangle( sub_item_back_br, sub_item_rect );
+ if ( subItem.Text != null && subItem.Text.Length > 0 )
+ dc.DrawString( subItem.Text, sub_item_font,
+ sub_item_fore_br,
+ sub_item_rect, format );
+ }
+ sub_item_rect.X += col.Wd;
+ }
+ }
+ }
+
+ if ( item.Focused ) {
+ if ( item.Selected )
+ CPDrawFocusRectangle( dc, text_rect, ColorHighlightText, ColorHighlight );
+ else
+ CPDrawFocusRectangle( dc, text_rect, control.ForeColor, control.BackColor );
+ }
+
+ format.Dispose( );
+ }
+ #endregion ListView
+
+ #region DateTimePicker
+ public override void DrawDateTimePicker (Graphics dc, Rectangle clip_rectangle, DateTimePicker dtp) {
+ // if not showing the numeric updown control then render border
+ if (!dtp.ShowUpDown && clip_rectangle.IntersectsWith (dtp.ClientRectangle)) {
+ // draw the outer border
+ Rectangle button_bounds = dtp.ClientRectangle;
+ CPDrawBorder3D (dc, button_bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, dtp.BackColor);
+
+ // deflate by the border width
+ if (clip_rectangle.IntersectsWith (dtp.drop_down_arrow_rect)) {
+ button_bounds.Inflate (-2,-2);
+ ButtonState state = dtp.is_drop_down_visible ? ButtonState.Pushed : ButtonState.Normal;
+ Rectangle button_rect = new Rectangle(dtp.drop_down_arrow_rect.X, dtp.drop_down_arrow_rect.Y + 1,
+ dtp.drop_down_arrow_rect.Width - 1, dtp.drop_down_arrow_rect.Height - 2);
+ this.CPDrawComboButton (
+ dc,
+ button_rect,
+ state);
+ }
+ }
+
+ // render the date part
+ if (clip_rectangle.IntersectsWith (dtp.date_area_rect)) {
+ // fill the background
+ Rectangle date_area_rect = new Rectangle( dtp.date_area_rect.X + 1, dtp.date_area_rect.Y + 1,
+ dtp.date_area_rect.Width - 2, dtp.date_area_rect.Height - 2);
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorWindow), date_area_rect);
+
+ // fill the currently highlighted area
+ if (dtp.hilight_date_area != Rectangle.Empty) {
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorHighlight), dtp.hilight_date_area);
+ }
+
+ // draw the text part
+ // TODO: if date format is CUstom then we need to draw the dates as separate parts
+ StringFormat text_format = new StringFormat();
+ text_format.LineAlignment = StringAlignment.Center;
+ text_format.Alignment = StringAlignment.Near;
+ dc.DrawString (dtp.Text, dtp.Font, ResPool.GetSolidBrush (dtp.ForeColor), Rectangle.Inflate(dtp.date_area_rect, -1, -1), text_format);
+ text_format.Dispose ();
+ }
+ }
+ #endregion // DateTimePicker
+
+ #region MonthCalendar
+ // draw the month calendar
+ public override void DrawMonthCalendar(Graphics dc, Rectangle clip_rectangle, MonthCalendar mc)
+ {
+ Rectangle client_rectangle = mc.ClientRectangle;
+ Size month_size = mc.SingleMonthSize;
+ // cache local copies of Marshal-by-ref internal members (gets around error CS0197)
+ Size calendar_spacing = (Size)((object)mc.calendar_spacing);
+ Size date_cell_size = (Size)((object)mc.date_cell_size);
+
+ // draw the singlecalendars
+ int x_offset = 1;
+ int y_offset = 1;
+ // adjust for the position of the specific month
+ for (int i=0; i < mc.CalendarDimensions.Height; i++)
+ {
+ if (i > 0)
+ {
+ y_offset += month_size.Height + calendar_spacing.Height;
+ }
+ // now adjust for x position
+ for (int j=0; j < mc.CalendarDimensions.Width; j++)
+ {
+ if (j > 0)
+ {
+ x_offset += month_size.Width + calendar_spacing.Width;
+ }
+ else
+ {
+ x_offset = 1;
+ }
+
+ Rectangle month_rect = new Rectangle (x_offset, y_offset, month_size.Width, month_size.Height);
+ if (month_rect.IntersectsWith (clip_rectangle)) {
+ DrawSingleMonth (
+ dc,
+ clip_rectangle,
+ month_rect,
+ mc,
+ i,
+ j);
+ }
+ }
+ }
+
+ Rectangle bottom_rect = new Rectangle (
+ client_rectangle.X,
+ Math.Max(client_rectangle.Bottom - date_cell_size.Height - 3, 0),
+ client_rectangle.Width,
+ date_cell_size.Height + 2);
+ // draw the today date if it's set
+ if (mc.ShowToday && bottom_rect.IntersectsWith (clip_rectangle))
+ {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), bottom_rect);
+ if (mc.ShowToday) {
+ int today_offset = 5;
+ if (mc.ShowTodayCircle)
+ {
+ Rectangle today_circle_rect = new Rectangle (
+ client_rectangle.X + 5,
+ Math.Max(client_rectangle.Bottom - date_cell_size.Height - 2, 0),
+ date_cell_size.Width,
+ date_cell_size.Height);
+ DrawTodayCircle (dc, today_circle_rect);
+ today_offset += date_cell_size.Width + 5;
+ }
+ // draw today's date
+ StringFormat text_format = new StringFormat();
+ text_format.LineAlignment = StringAlignment.Center;
+ text_format.Alignment = StringAlignment.Near;
+ Font bold_font = new Font (mc.Font.FontFamily, mc.Font.Size, mc.Font.Style | FontStyle.Bold);
+ Rectangle today_rect = new Rectangle (
+ today_offset + client_rectangle.X,
+ Math.Max(client_rectangle.Bottom - date_cell_size.Height, 0),
+ Math.Max(client_rectangle.Width - today_offset, 0),
+ date_cell_size.Height);
+ dc.DrawString ("Today: " + DateTime.Now.ToShortDateString(), bold_font, ResPool.GetSolidBrush (mc.ForeColor), today_rect, text_format);
+ text_format.Dispose ();
+ bold_font.Dispose ();
+ }
+ }
+
+ // finally paint the borders of the calendars as required
+ for (int i = 0; i <= mc.CalendarDimensions.Width; i++) {
+ if (i == 0 && clip_rectangle.X == client_rectangle.X) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Y, 1, client_rectangle.Height));
+ } else if (i == mc.CalendarDimensions.Width && clip_rectangle.Right == client_rectangle.Right) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.Right-1, client_rectangle.Y, 1, client_rectangle.Height));
+ } else {
+ Rectangle rect = new Rectangle (
+ client_rectangle.X + (month_size.Width*i) + (calendar_spacing.Width * (i-1)) + 1,
+ client_rectangle.Y,
+ calendar_spacing.Width,
+ client_rectangle.Height);
+ if (i < mc.CalendarDimensions.Width && i > 0 && clip_rectangle.IntersectsWith (rect)) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), rect);
+ }
+ }
+ }
+ for (int i = 0; i <= mc.CalendarDimensions.Height; i++) {
+ if (i == 0 && clip_rectangle.Y == client_rectangle.Y) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Y, client_rectangle.Width, 1));
+ } else if (i == mc.CalendarDimensions.Height && clip_rectangle.Bottom == client_rectangle.Bottom) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Bottom-1, client_rectangle.Width, 1));
+ } else {
+ Rectangle rect = new Rectangle (
+ client_rectangle.X,
+ client_rectangle.Y + (month_size.Height*i) + (calendar_spacing.Height*(i-1)) + 1,
+ client_rectangle.Width,
+ calendar_spacing.Height);
+ if (i < mc.CalendarDimensions.Height && i > 0 && clip_rectangle.IntersectsWith (rect)) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), rect);
+ }
+ }
+ }
+
+ // draw the drop down border if need
+ if (mc.owner != null) {
+ Rectangle bounds = mc.ClientRectangle;
+ if (clip_rectangle.Contains (mc.Location)) {
+ // find out if top or left line to draw
+ if(clip_rectangle.Contains (new Point (bounds.Left, bounds.Bottom))) {
+
+ dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Y, bounds.X, bounds.Bottom-1);
+ }
+ if(clip_rectangle.Contains (new Point (bounds.Right, bounds.Y))) {
+ dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Y, bounds.Right-1, bounds.Y);
+ }
+ }
+ if (clip_rectangle.Contains (new Point(bounds.Right, bounds.Bottom))) {
+ // find out if bottom or right line to draw
+ if(clip_rectangle.Contains (new Point (bounds.Left, bounds.Bottom))) {
+ dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Bottom-1, bounds.Right-1, bounds.Bottom-1);
+ }
+ if(clip_rectangle.Contains (new Point (bounds.Right, bounds.Y))) {
+ dc.DrawLine (SystemPens.ControlText, bounds.Right-1, bounds.Y, bounds.Right-1, bounds.Bottom-1);
+ }
+ }
+ }
+ }
+
+ // darws a single part of the month calendar (with one month)
+ private void DrawSingleMonth(Graphics dc, Rectangle clip_rectangle, Rectangle rectangle, MonthCalendar mc, int row, int col)
+ {
+ // cache local copies of Marshal-by-ref internal members (gets around error CS0197)
+ Size title_size = (Size)((object)mc.title_size);
+ Size date_cell_size = (Size)((object)mc.date_cell_size);
+ DateTime current_month = (DateTime)((object)mc.current_month);
+
+ // set up some standard string formating variables
+ StringFormat text_format = new StringFormat();
+ text_format.LineAlignment = StringAlignment.Center;
+ text_format.Alignment = StringAlignment.Center;
+
+
+ // draw the title back ground
+ DateTime this_month = current_month.AddMonths (row*mc.CalendarDimensions.Width+col);
+ Rectangle title_rect = new Rectangle(rectangle.X, rectangle.Y, title_size.Width, title_size.Height);
+ if (title_rect.IntersectsWith (clip_rectangle)) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), title_rect);
+ // draw the title
+ string title_text = this_month.ToString ("MMMM yyyy");
+ dc.DrawString (title_text, mc.Font, ResPool.GetSolidBrush (mc.TitleForeColor), title_rect, text_format);
+
+ // draw previous and next buttons if it's time
+ if (row == 0 && col == 0)
+ {
+ // draw previous button
+ DrawMonthCalendarButton (
+ dc,
+ rectangle,
+ mc,
+ title_size,
+ mc.button_x_offset,
+ (System.Drawing.Size)((object)mc.button_size),
+ true);
+ }
+ if (row == 0 && col == mc.CalendarDimensions.Width-1)
+ {
+ // draw next button
+ DrawMonthCalendarButton (
+ dc,
+ rectangle,
+ mc,
+ title_size,
+ mc.button_x_offset,
+ (System.Drawing.Size)((object)mc.button_size),
+ false);
+ }
+ }
+
+ // set the week offset and draw week nums if needed
+ int col_offset = (mc.ShowWeekNumbers) ? 1 : 0;
+ Rectangle day_name_rect = new Rectangle(
+ rectangle.X,
+ rectangle.Y + title_size.Height,
+ (7 + col_offset) * date_cell_size.Width,
+ date_cell_size.Height);
+ if (day_name_rect.IntersectsWith (clip_rectangle)) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), day_name_rect);
+ // draw the day names
+ DayOfWeek first_day_of_week = mc.GetDayOfWeek(mc.FirstDayOfWeek);
+ for (int i=0; i < 7; i++)
+ {
+ int position = i - (int) first_day_of_week;
+ if (position < 0)
+ {
+ position = 7 + position;
+ }
+ // draw it
+ Rectangle day_rect = new Rectangle(
+ day_name_rect.X + ((i + col_offset)* date_cell_size.Width),
+ day_name_rect.Y,
+ date_cell_size.Width,
+ date_cell_size.Height);
+ dc.DrawString (((DayOfWeek)i).ToString().Substring(0, 3), mc.Font, ResPool.GetSolidBrush (mc.TitleBackColor), day_rect, text_format);
+ }
+
+ // draw the vertical divider
+ int vert_divider_y = Math.Max(title_size.Height+ date_cell_size.Height-1, 0);
+ dc.DrawLine (
+ ResPool.GetPen (mc.ForeColor),
+ rectangle.X + (col_offset * date_cell_size.Width) + mc.divider_line_offset,
+ rectangle.Y + vert_divider_y,
+ rectangle.Right - mc.divider_line_offset,
+ rectangle.Y + vert_divider_y);
+ }
+
+
+ // draw the actual date items in the grid (including the week numbers)
+ Rectangle date_rect = new Rectangle (
+ rectangle.X,
+ rectangle.Y + title_size.Height + date_cell_size.Height,
+ date_cell_size.Width,
+ date_cell_size.Height);
+ int month_row_count = 0;
+ bool draw_week_num_divider = false;
+ DateTime current_date = mc.GetFirstDateInMonthGrid ( new DateTime (this_month.Year, this_month.Month, 1));
+ for (int i=0; i < 6; i++)
+ {
+ // establish if this row is in our clip_area
+ Rectangle row_rect = new Rectangle (
+ rectangle.X,
+ rectangle.Y + title_size.Height + (date_cell_size.Height * (i+1)),
+ date_cell_size.Width * 7,
+ date_cell_size.Height);
+ if (mc.ShowWeekNumbers) {
+ row_rect.Width += date_cell_size.Width;
+ }
+
+ bool draw_row = row_rect.IntersectsWith (clip_rectangle);
+ if (draw_row) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), row_rect);
+ }
+ // establish if this is a valid week to draw
+ if (mc.IsValidWeekToDraw (this_month, current_date, row, col)) {
+ month_row_count = i;
+ }
+
+ // draw the week number if required
+ if (mc.ShowWeekNumbers && month_row_count == i) {
+ if (!draw_week_num_divider) {
+ draw_week_num_divider = draw_row;
+ }
+ // get the week for this row
+ int week = mc.GetWeekOfYear (current_date);
+
+ if (draw_row) {
+ dc.DrawString (
+ week.ToString(),
+ mc.Font,
+ ResPool.GetSolidBrush (mc.TitleBackColor),
+ date_rect,
+ text_format);
+ }
+ date_rect.Offset(date_cell_size.Width, 0);
+ }
+
+ // only draw the days if we have to
+ if(month_row_count == i) {
+ for (int j=0; j < 7; j++)
+ {
+ if (draw_row) {
+ DrawMonthCalendarDate (
+ dc,
+ date_rect,
+ mc,
+ current_date,
+ this_month,
+ row,
+ col);
+ }
+
+ // move the day on
+ current_date = current_date.AddDays(1);
+ date_rect.Offset(date_cell_size.Width, 0);
+ }
+
+ // shift the rectangle down one row
+ int offset = (mc.ShowWeekNumbers) ? -8 : -7;
+ date_rect.Offset(offset*date_cell_size.Width, date_cell_size.Height);
+ }
+ }
+
+ // month_row_count is zero based, so add one
+ month_row_count++;
+
+ // draw week numbers if required
+ if (draw_week_num_divider) {
+ col_offset = 1;
+ dc.DrawLine (
+ ResPool.GetPen (mc.ForeColor),
+ rectangle.X + date_cell_size.Width - 1,
+ rectangle.Y + title_size.Height + date_cell_size.Height + mc.divider_line_offset,
+ rectangle.X + date_cell_size.Width - 1,
+ rectangle.Y + title_size.Height + date_cell_size.Height + (month_row_count * date_cell_size.Height) - mc.divider_line_offset);
+ }
+ text_format.Dispose ();
+ }
+
+ // draws the pervious or next button
+ private void DrawMonthCalendarButton (Graphics dc, Rectangle rectangle, MonthCalendar mc, Size title_size, int x_offset, Size button_size, bool is_previous)
+ {
+ bool is_clicked = false;
+ Rectangle button_rect;
+ Rectangle arrow_rect = new Rectangle (rectangle.X, rectangle.Y, 4, 7);
+ Point[] arrow_path = new Point[3];
+ // prepare the button
+ if (is_previous)
+ {
+ is_clicked = mc.is_previous_clicked;
+ button_rect = new Rectangle (
+ rectangle.X + 1 + x_offset,
+ rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
+ Math.Max(button_size.Width - 1, 0),
+ Math.Max(button_size.Height - 1, 0));
+ arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
+ arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
+ if (is_clicked) {
+ arrow_rect.Offset(1,1);
+ }
+ arrow_path[0] = new Point (arrow_rect.Right, arrow_rect.Y);
+ arrow_path[1] = new Point (arrow_rect.X, arrow_rect.Y + arrow_rect.Height/2);
+ arrow_path[2] = new Point (arrow_rect.Right, arrow_rect.Bottom);
+ }
+ else
+ {
+ is_clicked = mc.is_next_clicked;
+ button_rect = new Rectangle (
+ rectangle.Right - 1 - x_offset - button_size.Width,
+ rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
+ Math.Max(button_size.Width - 1, 0),
+ Math.Max(button_size.Height - 1, 0));
+ arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
+ arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
+ if (is_clicked) {
+ arrow_rect.Offset(1,1);
+ }
+ arrow_path[0] = new Point (arrow_rect.X, arrow_rect.Y);
+ arrow_path[1] = new Point (arrow_rect.Right, arrow_rect.Y + arrow_rect.Height/2);
+ arrow_path[2] = new Point (arrow_rect.X, arrow_rect.Bottom);
+ }
+
+ // fill the background
+ dc.FillRectangle (ResPool.GetSolidBrush(mc.TitleBackColor), button_rect);
+
+ // draw the button
+ Color first_gradient_color = is_clicked ? pressed_gradient_first_color : gradient_first_color;
+ Color second_gradient_color = is_clicked ? pressed_gradient_second_color : gradient_second_color;
+
+ CL_Draw_Button (dc, button_rect, FlatStyle.Standard,
+ false, true, is_clicked,
+ first_gradient_color, second_gradient_color,
+ false);
+
+ // draw the arrow
+ SmoothingMode old_smooting_mode = dc.SmoothingMode;
+ dc.SmoothingMode = SmoothingMode.AntiAlias;
+ dc.FillPolygon (SystemBrushes.ControlText, arrow_path);
+ dc.SmoothingMode = old_smooting_mode;
+ }
+
+
+ // draws one day in the calendar grid
+ private void DrawMonthCalendarDate (Graphics dc, Rectangle rectangle, MonthCalendar mc, DateTime date, DateTime month, int row, int col) {
+ Color date_color = mc.ForeColor;
+ Rectangle interior = new Rectangle (rectangle.X, rectangle.Y, Math.Max(rectangle.Width - 1, 0), Math.Max(rectangle.Height - 1, 0));
+
+ // find out if we are the lead of the first calendar or the trail of the last calendar
+ if (date.Year != month.Year || date.Month != month.Month) {
+ DateTime check_date = month.AddMonths (-1);
+ // check if it's the month before
+ if (check_date.Year == date.Year && check_date.Month == date.Month && row == 0 && col == 0) {
+ date_color = mc.TrailingForeColor;
+ } else {
+ // check if it's the month after
+ check_date = month.AddMonths (1);
+ if (check_date.Year == date.Year && check_date.Month == date.Month && row == mc.CalendarDimensions.Height-1 && col == mc.CalendarDimensions.Width-1) {
+ date_color = mc.TrailingForeColor;
+ } else {
+ return;
+ }
+ }
+ } else {
+ date_color = mc.ForeColor;
+ }
+
+
+ if (date == mc.SelectionStart && date == mc.SelectionEnd) {
+ // see if the date is in the start of selection
+ date_color = mc.BackColor;
+ // draw the left hand of the back ground
+ Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
+ dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 0, 359);
+ } else if (date == mc.SelectionStart) {
+ // see if the date is in the start of selection
+ date_color = mc.BackColor;
+ // draw the left hand of the back ground
+ Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
+ dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 90, 180);
+ // fill the other side as a straight rect
+ if (date < mc.SelectionEnd)
+ {
+ // use rectangle instead of rectangle to go all the way to edge of rect
+ selection_rect.X = (int) Math.Floor((double)(rectangle.X + rectangle.Width / 2));
+ selection_rect.Width = Math.Max(rectangle.Right - selection_rect.X, 0);
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
+ }
+ } else if (date == mc.SelectionEnd) {
+ // see if it is the end of selection
+ date_color = mc.BackColor;
+ // draw the left hand of the back ground
+ Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
+ dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 270, 180);
+ // fill the other side as a straight rect
+ if (date > mc.SelectionStart) {
+ selection_rect.X = rectangle.X;
+ selection_rect.Width = rectangle.Width - (rectangle.Width / 2);
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
+ }
+ } else if (date > mc.SelectionStart && date < mc.SelectionEnd) {
+ // now see if it's in the middle
+ date_color = mc.BackColor;
+ // draw the left hand of the back ground
+ Rectangle selection_rect = Rectangle.Inflate(rectangle, 0, -3);
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
+ }
+
+ // set up some standard string formating variables
+ StringFormat text_format = new StringFormat();
+ text_format.LineAlignment = StringAlignment.Center;
+ text_format.Alignment = StringAlignment.Center;
+
+
+ // establish if it's a bolded font
+ Font font;
+ if (mc.IsBoldedDate (date)) {
+ font = new Font (mc.Font.FontFamily, mc.Font.Size, mc.Font.Style | FontStyle.Bold);
+ } else {
+ font = mc.Font;
+ }
+
+ // just draw the date now
+ dc.DrawString (date.Day.ToString(), font, ResPool.GetSolidBrush (date_color), rectangle, text_format);
+
+ // today circle if needed
+ if (mc.ShowTodayCircle && date == DateTime.Now.Date) {
+ DrawTodayCircle (dc, interior);
+ }
+
+ // draw the selection grid
+ if (mc.is_date_clicked && mc.clicked_date == date) {
+ using (Pen pen = new Pen (Color.Black, 1) ) {
+ pen.DashStyle = DashStyle.Dot;
+ dc.DrawRectangle (pen, interior);
+ }
+ }
+ text_format.Dispose ();
+ }
+
+ private void DrawTodayCircle (Graphics dc, Rectangle rectangle) {
+ Color circle_color = Color.FromArgb (248, 0, 0);
+ // draw the left hand of the circle
+ Rectangle lhs_circle_rect = new Rectangle (rectangle.X + 1, rectangle.Y + 4, Math.Max(rectangle.Width - 2, 0), Math.Max(rectangle.Height - 5, 0));
+ Rectangle rhs_circle_rect = new Rectangle (rectangle.X + 1, rectangle.Y + 1, Math.Max(rectangle.Width - 2, 0), Math.Max(rectangle.Height - 2, 0));
+ Point [] curve_points = new Point [3];
+ curve_points [0] = new Point (lhs_circle_rect.X, rhs_circle_rect.Y + rhs_circle_rect.Height/12);
+ curve_points [1] = new Point (lhs_circle_rect.X + lhs_circle_rect.Width/9, rhs_circle_rect.Y);
+ curve_points [2] = new Point (lhs_circle_rect.X + lhs_circle_rect.Width/2 + 1, rhs_circle_rect.Y);
+
+ SmoothingMode old_smoothing_mode = dc.SmoothingMode;
+ dc.SmoothingMode = SmoothingMode.AntiAlias;
+
+ using (Pen pen = new Pen (circle_color, 2)) {
+ dc.DrawArc (pen, lhs_circle_rect, 90, 180);
+ dc.DrawArc (pen, rhs_circle_rect, 270, 180);
+ dc.DrawCurve (pen, curve_points);
+ dc.DrawLine (ResPool.GetPen (circle_color), curve_points [2], new Point (curve_points [2].X, lhs_circle_rect.Y));
+ }
+
+ dc.SmoothingMode = old_smoothing_mode;
+ }
+ #endregion // MonthCalendar
+
+ public override void CPDrawBorder3D( Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides ) {
+ CPDrawBorder3D( graphics, rectangle, style, sides, ColorControl );
+ }
+
+ private void CPDrawBorder3D( Graphics dc, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color ) {
+ // currently we don't take care of Border3DStyle or Border3DSide
+
+ // FIXME: temporary fix for artefacts, it should use the backcolor of the parent control
+ dc.DrawLine( ResPool.GetPen( ColorControl ), rectangle.X, rectangle.Y, rectangle.X, rectangle.Bottom - 1 );
+ dc.DrawLine( ResPool.GetPen( ColorControl ), rectangle.Right - 1, rectangle.Y, rectangle.Right - 1, rectangle.Bottom - 1 );
+
+ Pen tmp_pen = ResPool.GetPen( edge_bottom_inner_color );
+ dc.DrawLine( tmp_pen, rectangle.X + 1, rectangle.Y + 2, rectangle.X + 2, rectangle.Y + 1 );
+ dc.DrawLine( tmp_pen, rectangle.Right - 3, rectangle.Y + 1, rectangle.Right - 2, rectangle.Y + 2 );
+ dc.DrawLine( tmp_pen, rectangle.Right - 3, rectangle.Bottom - 2, rectangle.Right - 2, rectangle.Bottom - 3 );
+ dc.DrawLine( tmp_pen, rectangle.X + 1, rectangle.Bottom - 3, rectangle.X + 2, rectangle.Bottom - 2 );
+
+ tmp_pen = ResPool.GetPen( theme_back_color );
+ dc.DrawLine( tmp_pen, rectangle.X + 2, rectangle.Y + 2, rectangle.Right - 3, rectangle.Y + 2 );
+ dc.DrawLine( tmp_pen, rectangle.X + 2, rectangle.Y + 3, rectangle.X + 2, rectangle.Bottom - 3 );
+
+ tmp_pen = ResPool.GetPen( Color.White );
+ dc.DrawLine( tmp_pen, rectangle.X + 3, rectangle.Bottom - 3, rectangle.Right - 3, rectangle.Bottom - 3 );
+ dc.DrawLine( tmp_pen, rectangle.Right - 3, rectangle.Y + 3, rectangle.Right - 3, rectangle.Bottom - 3 );
+
+ Point[] points = {
+ new Point( rectangle.X + 3, rectangle.Y + 1 ),
+ new Point( rectangle.Right - 4, rectangle.Y + 1 ),
+ new Point( rectangle.Right - 2, rectangle.Y + 3 ),
+ new Point( rectangle.Right - 2, rectangle.Bottom - 4 ),
+ new Point( rectangle.Right - 4, rectangle.Bottom - 2 ),
+ new Point( rectangle.X + 3, rectangle.Bottom - 2 ),
+ new Point( rectangle.X + 1, rectangle.Bottom - 4 ),
+ new Point( rectangle.X + 1, rectangle.Y + 3 ),
+ new Point( rectangle.X + 3, rectangle.Y + 1 )
+ };
+
+ dc.DrawLines( ResPool.GetPen( combobox_border_color ), points );
+
+ Point[] points_top_outer = {
+ new Point( rectangle.X + 1, rectangle.Y + 1 ),
+ new Point( rectangle.X + 2, rectangle.Y ),
+ new Point( rectangle.Right - 3, rectangle.Y ),
+ new Point( rectangle.Right - 2 , rectangle.Y + 1 )
+ };
+
+ Point[] points_bottom_outer = {
+ new Point( rectangle.X + 1, rectangle.Bottom - 2 ),
+ new Point( rectangle.X + 2, rectangle.Bottom - 1 ),
+ new Point( rectangle.Right - 3, rectangle.Bottom - 1 ),
+ new Point( rectangle.Right - 2, rectangle.Bottom - 2 )
+ };
+
+ // outer border
+ tmp_pen = ResPool.GetPen( button_outer_border_dark_color );
+ dc.DrawLines( tmp_pen, points_top_outer );
+ tmp_pen = ResPool.GetPen( button_outer_border_light_color );
+ dc.DrawLines( tmp_pen, points_bottom_outer );
+
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 2 ), new Point( 0, rectangle.Height - 1 ), button_outer_border_dark_color, button_outer_border_light_color ) ) {
+ dc.FillRectangle( lgbr, rectangle.X, rectangle.Y + 2, 1, rectangle.Height - 4 );
+ dc.FillRectangle( lgbr, rectangle.Right - 1, rectangle.Y + 2, 1, rectangle.Height - 4 );
+ }
+
+ tmp_pen = ResPool.GetPen( button_edge_top_outer_color );
+ dc.DrawLine( tmp_pen, rectangle.X, rectangle.Y + 1, rectangle.X + 1, rectangle.Y );
+ dc.DrawLine( tmp_pen, rectangle.Right - 2, rectangle.Y, rectangle.Right - 1, rectangle.Y + 1 );
+
+ tmp_pen = ResPool.GetPen( button_edge_bottom_outer_color );
+ dc.DrawLine( tmp_pen, rectangle.X, rectangle.Bottom - 2, rectangle.X + 1, rectangle.Bottom - 1 );
+ dc.DrawLine( tmp_pen, rectangle.Right - 1, rectangle.Bottom - 2, rectangle.Right - 2, rectangle.Bottom - 1 );
+ }
+
+ public override void CPDrawBorder( Graphics dc, Rectangle bounds, Color leftColor, int leftWidth,
+ ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
+ Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor,
+ int bottomWidth, ButtonBorderStyle bottomStyle ) {
+ dc.DrawRectangle( ResPool.GetPen( combobox_border_color ), bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1 );
+ }
+
+ // TODO: inactive...
+ public override void CPDrawCheckBox( Graphics dc, Rectangle rectangle, ButtonState state ) {
+
+ bool pushed = ( state & ButtonState.Pushed ) != 0;
+
+ int lineWidth;
+ Rectangle rect;
+ int scale;
+
+ // background
+ dc.FillRectangle( ResPool.GetSolidBrush( pushed ? checkbox_pressed_backcolor : Color.White ), rectangle );
+
+ // border
+ dc.DrawRectangle( ResPool.GetPen( scrollbar_border_color ), rectangle );
+
+ Color inner_border_color = pushed ? checkbox_pressed_inner_boder_color : checkbox_inner_boder_color;
+
+ Pen tmp_pen = ResPool.GetPen( inner_border_color );
+ dc.DrawLine( tmp_pen, rectangle.X + 1, rectangle.Y + 1, rectangle.Right - 1, rectangle.Y + 1 );
+ dc.DrawLine( tmp_pen, rectangle.X + 1, rectangle.Y + 2, rectangle.X + 1, rectangle.Bottom - 1 );
+
+ /* Make sure we've got at least a line width of 1 */
+ lineWidth = Math.Max( 3, rectangle.Width / 6 );
+ scale = Math.Max( 1, rectangle.Width / 12 );
+
+ // define a rectangle inside the border area
+ rect = new Rectangle( rectangle.X + 2, rectangle.Y + 2, rectangle.Width - 4, rectangle.Height - 4 );
+ if ( ( state & ButtonState.Inactive ) != 0 ) {
+ tmp_pen = SystemPens.ControlDark;
+ } else {
+ tmp_pen = SystemPens.ControlText;
+ }
+
+ if ( ( state & ButtonState.Checked ) != 0 ) {
+ /* Need to draw a check-mark */
+ for ( int i=0; i < lineWidth; i++ ) {
+ dc.DrawLine( tmp_pen, rect.Left + lineWidth / 2, rect.Top + lineWidth + i, rect.Left + lineWidth / 2 + 2 * scale, rect.Top + lineWidth + 2 * scale + i );
+ dc.DrawLine( tmp_pen, rect.Left + lineWidth / 2 + 2 * scale, rect.Top + lineWidth + 2 * scale + i, rect.Left + lineWidth / 2 + 6 * scale, rect.Top + lineWidth - 2 * scale + i );
+ }
+ }
+ }
+
+ public override void CPDrawStringDisabled( Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle,
+ StringFormat format ) {
+
+ graphics.DrawString( s, font, ResPool.GetSolidBrush( ColorGrayText), layoutRectangle, format );
+
+ }
+
+ public override void CPDrawButton (Graphics dc, Rectangle buttonRectangle, ButtonState state)
+ {
+ bool is_enabled = true;
+ FlatStyle flat_style = FlatStyle.Standard;
+ bool is_pressed = false;
+
+ if ((state & ButtonState.Pushed) != 0) {
+ is_pressed = true;
+ }
+
+// if ((state & ButtonState.Checked)!=0) {
+// dfcs |= DrawFrameControlStates.Checked;
+// }
+
+ if ((state & ButtonState.Flat) != 0) {
+ flat_style = FlatStyle.Flat;
+ }
+
+ if ((state & ButtonState.Inactive) != 0) {
+ is_enabled = false;
+ }
+
+ Color first_gradient_color = gradient_first_color;
+ Color second_gradient_color = gradient_second_color;
+
+ if (is_pressed) {
+ first_gradient_color = pressed_gradient_first_color;
+ second_gradient_color = pressed_gradient_second_color;
+ }
+
+ CL_Draw_Button (dc, buttonRectangle, flat_style,
+ false, is_enabled, is_pressed,
+ first_gradient_color, second_gradient_color,
+ false);
+ }
+
+ public override void CPDrawRadioButton (Graphics dc, Rectangle rectangle, ButtonState state)
+ {
+ bool is_checked = false;
+ bool is_inactive = false;
+
+ if ((state & ButtonState.Checked) != 0) {
+ is_checked = true;
+ }
+
+ if ((state & ButtonState.Inactive) != 0) {
+ is_inactive = true;
+ }
+
+ SmoothingMode old_smooting_mode = dc.SmoothingMode;
+ dc.SmoothingMode = SmoothingMode.AntiAlias;
+
+ dc.FillPie (ResPool.GetSolidBrush (this.ColorWindow), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
+
+ dc.DrawArc (ResPool.GetPen (radio_button_border_circle_color), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
+
+ CL_Draw_RadioButton_Dot (dc, rectangle, is_checked, is_inactive);
+
+ dc.SmoothingMode = old_smooting_mode;
+ }
+
+ private void CL_Draw_RadioButton_Dot (Graphics dc, Rectangle rectangle, bool is_checked, bool is_inactive)
+ {
+ if (is_checked) {
+ int lineWidth = Math.Max (1, Math.Min (rectangle.Width, rectangle.Height) / 4);
+
+ SolidBrush buttonBrush;
+
+ if (is_inactive) {
+ buttonBrush = SystemBrushes.ControlDark as SolidBrush;
+ } else {
+ buttonBrush = ResPool.GetSolidBrush (radio_button_dot_color);
+ }
+ dc.FillPie (buttonBrush, rectangle.X + lineWidth, rectangle.Y + lineWidth, rectangle.Width - lineWidth * 2, rectangle.Height - lineWidth * 2, 0, 359);
+
+ // the white shiny dott
+ buttonBrush = ResPool.GetSolidBrush (ColorWindow);
+ dc.FillPie (buttonBrush, rectangle.X + lineWidth + lineWidth / 2, rectangle.Y + lineWidth + lineWidth / 2, (rectangle.Width - lineWidth * 2) / 3, (rectangle.Height - lineWidth * 2) / 3, 0, 359);
+ }
+ }
+ } //class
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeEngine.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeEngine.cs
new file mode 100644
index 00000000000..ad1b4108ebf
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeEngine.cs
@@ -0,0 +1,65 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+//
+
+
+using System;
+
+namespace System.Windows.Forms
+{
+ internal class ThemeEngine
+ {
+ static private Theme theme = null;
+
+ static ThemeEngine ()
+ {
+ string theme_var;
+
+ theme_var = Environment.GetEnvironmentVariable("MONO_THEME");
+
+ if (theme_var == null)
+ theme_var = "win32";
+
+ theme_var.ToLower ();
+
+ if (theme_var == "gtk")
+ theme = new ThemeGtk ();
+ else
+ if ( theme_var == "nice" )
+ theme = new ThemeNice ();
+ else
+ if ( theme_var == "clearlooks" )
+ theme = new ThemeClearlooks ();
+ else
+ theme = new ThemeWin32Classic ();
+ }
+
+
+ public static Theme Current {
+ get { return theme; }
+ }
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeGtk.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeGtk.cs
new file mode 100644
index 00000000000..b5540b6c20a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeGtk.cs
@@ -0,0 +1,1593 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+// Alexander Olk, alex.olk@googlemail.com
+//
+// This is an experimental GTK theme.
+//
+// Comments:
+// - For now we would keep all the themes in the same assembly to have
+// handy the internals methods.
+// - We are using Pinovoke for now to access GTK/GDK to avoid adding
+// gtk-sharp as a SWF dependency
+// - The ThemeGtk comes from ThemeWin32Classic, we use it as the default
+// implementation for the methods that we are not taking care of.
+// - When GDK is initialised it opens its own display. There is not way of changing it,
+// then we use that display as SWF display
+// - You can activate this Theme in Linux doing export MONO_THEME=gtk
+// - GTK paints controls into a window not a device context. We should inverstigate if we
+// we can encapsulate a dc in a gtkwindow.
+
+
+// NOT COMPLETE
+
+// TODO: - fix position of button focus rectangle
+// - fix TrackBar drawing location
+
+
+//#define _EXPERIMENTAL_
+
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.IO;
+
+namespace System.Windows.Forms
+{
+ internal class ThemeGtk : ThemeWin32Classic
+ {
+ /* GTK enums */
+ internal enum StateType
+ {
+ Normal,
+ Active,
+ Prelight,
+ Selected,
+ Insensitive,
+ }
+
+ internal enum ShadowType
+ {
+ None,
+ In,
+ Out,
+ EtchedIn,
+ EtchedOut,
+ }
+
+ internal enum ArrowType
+ {
+ Up,
+ Down,
+ Left,
+ Right,
+ }
+
+ /* Structs */
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct GdkColorStruct
+ {
+ internal int pixel;
+ internal short red;
+ internal short green;
+ internal short blue;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct GObjectStruct {
+ IntPtr Instance;
+ IntPtr ref_count;
+ IntPtr data;
+ }
+
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct GtkStyleStruct
+ {
+ internal GObjectStruct obj;
+ [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=5)]
+ internal GdkColorStruct[] fg;
+ [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=5)]
+ internal GdkColorStruct[] bg;
+ [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=5)]
+ internal GdkColorStruct[] light;
+ [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=5)]
+ internal GdkColorStruct[] dark;
+ [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=5)]
+ internal GdkColorStruct[] mid;
+ [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=5)]
+ internal GdkColorStruct[] text;
+ [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=5)]
+ internal GdkColorStruct[] baseclr;
+ [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=5)]
+ internal GdkColorStruct[] text_aa; /* Halfway between text/base */
+
+ internal GdkColorStruct black;
+ internal GdkColorStruct white;
+
+ /* TODO: There is more stuff that we will add when we need it*/
+ }
+
+ /* GDK imports */
+ [DllImport("libgdk-x11-2.0.so")]
+ internal static extern IntPtr gdk_display_manager_get ();
+
+ [DllImport("libgdk-x11-2.0.so")]
+ internal static extern IntPtr gdk_display_manager_get_default_display (IntPtr display_manager);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ internal static extern void gdk_display_manager_set_default_display (IntPtr display_manager, IntPtr display);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ internal static extern IntPtr gdk_x11_display_get_xdisplay (IntPtr display);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern IntPtr gdk_window_foreign_new_for_display (IntPtr display, uint anid);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern bool gdk_init_check(out int argc, string argv);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern IntPtr gdk_pixmap_new (IntPtr drawable, int width, int height, int depth);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern IntPtr gdk_pixbuf_get_from_drawable (IntPtr dest, IntPtr drawable_src, IntPtr cmap,
+ int src_x, int src_y, int dest_x, int dest_y, int width, int height);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern bool gdk_pixbuf_save_to_buffer (IntPtr pixbuf, out IntPtr buffer, out UIntPtr buffer_size, string type, out IntPtr error, IntPtr option_dummy);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern IntPtr gdk_drawable_get_colormap (IntPtr drawable);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern IntPtr gdk_colormap_get_system ();
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern IntPtr gdk_pixbuf_new (int colorspace, bool has_alpha, int bits_per_sample, int width, int height);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern IntPtr gdk_gc_new (IntPtr drawable);
+
+ /* glib imports*/
+ [DllImport("libglib-2.0.so")]
+ static extern void g_free (IntPtr mem);
+
+ [DllImport("libgobject-2.0.so")]
+ static extern void g_object_unref (IntPtr nativeObject);
+
+ /* GTK imports */
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern bool gtk_init_check (out int argc, string argv);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern IntPtr gtk_adjustment_new (double value, double lower, double upper, double step_increment, double page_increment, double page_size);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern IntPtr gtk_rc_get_style (IntPtr widget);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern IntPtr gtk_vscrollbar_new(IntPtr adjustment);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern IntPtr gtk_hscrollbar_new(IntPtr adjustment);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern IntPtr gtk_style_attach (IntPtr raw, IntPtr window);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern IntPtr gtk_rc_style_new ();
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern IntPtr gtk_invisible_new ();
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern void gtk_widget_ensure_style (IntPtr raw);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern IntPtr gtk_widget_get_style (IntPtr raw);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern void gtk_style_detach (IntPtr raw);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern IntPtr gtk_button_new ();
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern IntPtr gtk_progress_bar_new ();
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern IntPtr gtk_radio_button_new (IntPtr group);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern IntPtr gtk_check_button_new ();
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern IntPtr gtk_hscale_new (IntPtr adjustment);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern IntPtr gtk_vscale_new (IntPtr adjustment);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern void gtk_range_set_range (IntPtr range, double min, double max);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern void gtk_range_set_value (IntPtr range, double value);
+
+ /* GTK Drawing */
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern void gtk_paint_handle (IntPtr style, IntPtr window, int state_type, int shadow_type, IntPtr area, IntPtr widget, string detail, int x, int y, int width, int height, int orientation);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern void gtk_paint_arrow (IntPtr style, IntPtr window, int state_type, int shadow_type,
+ IntPtr area, IntPtr widget, string detail, int arrow_type, bool fill, int x, int y, int width, int height);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern void gtk_paint_slider (IntPtr style, IntPtr window, int state_type, int shadow_type,
+ IntPtr area, IntPtr widget, string detail, int x, int y, int width, int height, int orientation);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern void gtk_paint_box (IntPtr style, IntPtr window, int state_type, int shadow_type,
+ IntPtr area, IntPtr widget, string detail, int x, int y, int width, int height);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern void gtk_paint_flat_box (IntPtr style, IntPtr window, int state_type, int shadow_type,
+ IntPtr area, IntPtr widget, string detail, int x, int y, int width, int height);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern void gtk_paint_hline(IntPtr style, IntPtr window, int state_type, IntPtr area, IntPtr widget, string detail, int x1, int x2, int y);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern void gtk_paint_vline(IntPtr style, IntPtr window, int state_type, IntPtr area, IntPtr widget, string detail, int y1, int y2, int x);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern void gtk_paint_check(IntPtr style, IntPtr window, int state_type, int shadow_type, IntPtr area, IntPtr widget, string detail, int x, int y, int width, int height);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern void gtk_paint_focus(IntPtr style, IntPtr window, int state_type, IntPtr area, IntPtr widget, string detail, int x, int y, int width, int height);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern void gtk_widget_size_allocate (IntPtr widget, ref Rectangle allocation);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern void gtk_paint_option (IntPtr style, IntPtr window, int state_type, int shadow_type, IntPtr area, IntPtr widget, string detail, int x, int y, int width, int height);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern void gtk_widget_grab_focus (IntPtr widget);
+
+ /* Data */
+ static protected IntPtr dispmgr;
+ static protected IntPtr gdkdisplay;
+ static protected IntPtr widget;
+ static protected IntPtr global_style;
+
+ #if _EXPERIMENTAL_
+ static protected IntPtr global_color_map = IntPtr.Zero;
+ #endif
+
+ static protected IntPtr global_gtk_button = IntPtr.Zero;
+ static protected IntPtr global_gtk_button_style = IntPtr.Zero;
+
+ static protected IntPtr global_gtk_vscrollbar = IntPtr.Zero;
+ static protected IntPtr global_gtk_vscrollbar_style = IntPtr.Zero;
+
+ static protected IntPtr global_gtk_hscrollbar = IntPtr.Zero;
+ static protected IntPtr global_gtk_hscrollbar_style = IntPtr.Zero;
+
+ static protected IntPtr global_gtk_progress_bar = IntPtr.Zero;
+ static protected IntPtr global_gtk_progress_bar_style = IntPtr.Zero;
+
+ static protected IntPtr global_gtk_radio_button = IntPtr.Zero;
+ static protected IntPtr global_gtk_radio_button_style = IntPtr.Zero;
+
+ static protected IntPtr global_gtk_check_button = IntPtr.Zero;
+ static protected IntPtr global_gtk_check_button_style = IntPtr.Zero;
+
+ static protected IntPtr global_gtk_hscale = IntPtr.Zero;
+ static protected IntPtr global_gtk_hscale_style = IntPtr.Zero;
+
+ static protected IntPtr global_gtk_vscale = IntPtr.Zero;
+ static protected IntPtr global_gtk_vscale_style = IntPtr.Zero;
+
+ static protected IntPtr current_gdk_drawable = IntPtr.Zero;
+ static protected IntPtr current_style = IntPtr.Zero;
+ static protected IntPtr current_widget = IntPtr.Zero;
+
+ public static void InitGtk ()
+ {
+ Console.WriteLine ("ThemeGtk Init");
+ int argc = 0;
+ string argv = "";
+
+ gdk_init_check (out argc, argv);
+
+ dispmgr = gdk_display_manager_get ();
+ gdkdisplay = gdk_display_manager_get_default_display (dispmgr);
+ gtk_init_check (out argc, argv);
+
+ widget = gtk_invisible_new ();
+ gtk_widget_ensure_style (widget);
+ global_style = gtk_widget_get_style (widget);
+
+ XplatUIX11.GetInstance().SetDisplay (gdk_x11_display_get_xdisplay (gdkdisplay));
+
+ global_gtk_button = gtk_button_new();
+ gtk_widget_ensure_style (global_gtk_button);
+ global_gtk_button_style = gtk_rc_get_style (global_gtk_button);
+
+ IntPtr adj = gtk_adjustment_new (0, 0, 0, 0, 0, 0);
+ global_gtk_vscrollbar = gtk_vscrollbar_new (adj);
+ gtk_widget_ensure_style (global_gtk_vscrollbar);
+ global_gtk_vscrollbar_style = gtk_rc_get_style (global_gtk_vscrollbar);
+
+ global_gtk_hscrollbar = gtk_hscrollbar_new (adj);
+ gtk_widget_ensure_style (global_gtk_hscrollbar);
+ global_gtk_hscrollbar_style = gtk_rc_get_style (global_gtk_hscrollbar);
+
+ global_gtk_progress_bar = gtk_progress_bar_new ();
+ gtk_widget_ensure_style (global_gtk_progress_bar);
+ global_gtk_progress_bar_style = gtk_rc_get_style (global_gtk_progress_bar);
+
+ global_gtk_radio_button = gtk_radio_button_new (IntPtr.Zero);
+ gtk_widget_ensure_style (global_gtk_radio_button);
+ global_gtk_radio_button_style = gtk_rc_get_style (global_gtk_radio_button);
+
+ global_gtk_check_button = gtk_check_button_new ();
+ gtk_widget_ensure_style (global_gtk_check_button);
+ global_gtk_check_button_style = gtk_rc_get_style (global_gtk_check_button);
+
+ global_gtk_hscale = gtk_hscale_new (adj);
+ gtk_widget_ensure_style (global_gtk_hscale);
+ global_gtk_hscale_style = gtk_rc_get_style (global_gtk_hscale);
+
+ global_gtk_vscale = gtk_vscale_new (adj);
+ gtk_widget_ensure_style (global_gtk_vscale);
+ global_gtk_vscale_style = gtk_rc_get_style (global_gtk_vscale);
+
+ #if _EXPERIMENTAL_
+ global_color_map = gdk_colormap_get_system ();
+ #endif
+ }
+
+ public void LoadSysDefaultColors ()
+ {
+ GtkStyleStruct style_struct;
+
+ style_struct = (GtkStyleStruct) Marshal.PtrToStructure (global_style, typeof (GtkStyleStruct));
+ defaultWindowBackColor = ColorFromGdkColor (style_struct.bg[0]);
+ defaultWindowForeColor = ColorFromGdkColor (style_struct.fg[0]);
+ }
+
+ public ThemeGtk () : base ()
+ {
+ Console.WriteLine ("ThemeGtk constructor");
+ InitGtk ();
+ default_font = new Font (FontFamily.GenericSansSerif, 8.25f);
+
+ LoadSysDefaultColors ();
+
+ always_draw_hotkeys = true;
+ }
+
+ public override bool DoubleBufferingSupported {
+ #if _EXPERIMENTAL_
+ get {return true; }
+ #else
+ get {return false; }
+ #endif
+ }
+
+ private void SetDrawableAndStyle (Control control)
+ {
+ #if _EXPERIMENTAL_
+ if (current_gdk_drawable != IntPtr.Zero) {
+ g_object_unref (current_gdk_drawable);
+ current_gdk_drawable = IntPtr.Zero;
+ }
+ current_gdk_drawable = gdk_pixmap_new (IntPtr.Zero, control.ClientRectangle.Width, control.ClientRectangle.Height, 24);
+ #else
+ current_gdk_drawable = gdk_window_foreign_new_for_display (gdkdisplay, (uint) control.Handle);
+ #endif
+
+ IntPtr tmp_style = IntPtr.Zero;
+
+ if (control is ButtonBase) {
+ tmp_style = global_gtk_button_style;
+ current_widget = global_gtk_button;
+ } else
+ if (control is ScrollBar) {
+ ScrollBar bar = control as ScrollBar;
+ if (bar.vert) {
+ tmp_style = global_gtk_vscrollbar_style;
+ current_widget = global_gtk_vscrollbar;
+ } else {
+ tmp_style = global_gtk_hscrollbar_style;
+ current_widget = global_gtk_hscrollbar;
+ }
+ } else
+ if (control is ProgressBar) {
+ tmp_style = global_gtk_progress_bar_style;
+ current_widget = global_gtk_progress_bar;
+ } else
+ if (control is RadioButton) {
+ tmp_style = global_gtk_radio_button_style;
+ current_widget = global_gtk_radio_button;
+ } else
+ if (control is CheckBox) {
+ tmp_style = global_gtk_check_button_style;
+ current_widget = global_gtk_check_button;
+ } else
+ if (control is TrackBar) {
+ TrackBar bar = control as TrackBar;
+ if (bar.Orientation == Orientation.Vertical) {
+ tmp_style = global_gtk_vscale_style;
+ current_widget = global_gtk_vscale;
+ } else {
+ tmp_style = global_gtk_hscale_style;
+ current_widget = global_gtk_hscale;
+ }
+ } else
+ tmp_style = global_style;
+
+ current_style = gtk_style_attach (tmp_style, current_gdk_drawable); // need it
+ }
+
+ #if _EXPERIMENTAL_
+ private void SetDrawableAndStyle (Rectangle area, Type type, Orientation orientation)
+ {
+ if (current_gdk_drawable != IntPtr.Zero) {
+ g_object_unref (current_gdk_drawable);
+ current_gdk_drawable = IntPtr.Zero;
+ }
+ current_gdk_drawable = gdk_pixmap_new (IntPtr.Zero, area.Width, area.Height, 24);
+
+ IntPtr tmp_style = IntPtr.Zero;
+
+ if (type == typeof(ButtonBase)) {
+ tmp_style = global_gtk_button_style;
+ current_widget = global_gtk_button;
+ } else
+ if (type == typeof(ScrollBar)) {
+ if (orientation == Orientation.Vertical) {
+ tmp_style = global_gtk_vscrollbar_style;
+ current_widget = global_gtk_vscrollbar;
+ } else {
+ tmp_style = global_gtk_hscrollbar_style;
+ current_widget = global_gtk_hscrollbar;
+ }
+ } else
+ if (type == typeof(ProgressBar)) {
+ tmp_style = global_gtk_progress_bar_style;
+ current_widget = global_gtk_progress_bar;
+ } else
+ if (type == typeof(RadioButton)) {
+ tmp_style = global_gtk_radio_button_style;
+ current_widget = global_gtk_radio_button;
+ } else
+ if (type == typeof(CheckBox)) {
+ tmp_style = global_gtk_check_button_style;
+ current_widget = global_gtk_check_button;
+ } else
+ if (type == typeof(TrackBar)) {
+ if (orientation == Orientation.Vertical) {
+ tmp_style = global_gtk_vscale_style;
+ current_widget = global_gtk_vscale;
+ } else {
+ tmp_style = global_gtk_hscale_style;
+ current_widget = global_gtk_hscale;
+ }
+ } else
+ tmp_style = global_style;
+
+ current_style = gtk_style_attach (tmp_style, current_gdk_drawable); // need it
+ }
+ #endif
+
+ #if _EXPERIMENTAL_
+ private void DrawDrawableToDC (Graphics dc, Control control)
+ {
+ IntPtr new_pixbuf = gdk_pixbuf_new (0, true, 8, control.ClientRectangle.Width, control.ClientRectangle.Height);
+
+ gdk_pixbuf_get_from_drawable (new_pixbuf,
+ current_gdk_drawable,
+ global_color_map,
+ 0,
+ 0,
+ 0,
+ 0,
+ -1,
+ -1);
+
+ IntPtr error = IntPtr.Zero;
+ IntPtr buffer;
+ UIntPtr buffer_size_as_ptr;
+ string type = "png";
+
+ bool saved = gdk_pixbuf_save_to_buffer (new_pixbuf, out buffer, out buffer_size_as_ptr, type, out error, IntPtr.Zero);
+
+ if (!saved)
+ return;
+
+ int buffer_size = (int) (uint) buffer_size_as_ptr;
+ byte[] result = new byte [buffer_size];
+ Marshal.Copy (buffer, result, 0, (int) buffer_size);
+ g_free (buffer);
+ g_object_unref (new_pixbuf);
+
+ Image image = null;
+ using (MemoryStream s = new MemoryStream (result))
+ image = Image.FromStream (s);
+
+ dc.DrawImage (image, control.ClientRectangle);
+ }
+
+ private void DrawDrawableToDC (Graphics dc, Rectangle area)
+ {
+ IntPtr new_pixbuf = gdk_pixbuf_new (0, true, 8, area.Width, area.Height);
+
+ gdk_pixbuf_get_from_drawable (new_pixbuf,
+ current_gdk_drawable,
+ global_color_map,
+ 0,
+ 0,
+ 0,
+ 0,
+ -1,
+ -1);
+
+ IntPtr error = IntPtr.Zero;
+ IntPtr buffer;
+ UIntPtr buffer_size_as_ptr;
+ string type = "png";
+
+ bool saved = gdk_pixbuf_save_to_buffer (new_pixbuf, out buffer, out buffer_size_as_ptr, type, out error, IntPtr.Zero);
+
+ if (!saved)
+ return;
+
+ int buffer_size = (int) (uint) buffer_size_as_ptr;
+ byte[] result = new byte [buffer_size];
+ Marshal.Copy (buffer, result, 0, (int) buffer_size);
+ g_free (buffer);
+ g_object_unref (new_pixbuf);
+
+ Image image = null;
+ using (MemoryStream s = new MemoryStream (result))
+ image = Image.FromStream (s);
+
+ dc.DrawImage (image, area);
+ }
+ #endif
+
+ public override void DrawButtonBase (Graphics dc, Rectangle clip_area, ButtonBase button)
+ {
+ SetDrawableAndStyle (button);
+
+ // Draw the button: fill rectangle, draw border, etc.
+ ButtonBase_DrawButton (button, dc);
+
+ // First, draw the image
+ if ((button.image != null) || (button.image_list != null))
+ ButtonBase_DrawImage (button, dc);
+
+ // Draw the focus rectangle
+ if (button.has_focus)
+ ButtonBase_DrawFocus (button, dc);
+
+ #if _EXPERIMENTAL_
+ DrawDrawableToDC (dc, button);
+ #endif
+
+ // Now the text
+ if (button.text != null && button.text != String.Empty)
+ ButtonBase_DrawText (button, dc);
+ }
+
+ protected override void ButtonBase_DrawButton(ButtonBase button, Graphics dc)
+ {
+ Rectangle buttonRectangle = button.ClientRectangle;
+
+ StateType state_type = StateType.Normal;
+ ShadowType shadow_type = button.flat_style == FlatStyle.Flat ? ShadowType.In : ShadowType.Out;
+ string detail = "buttondefault";
+
+ if (((button is CheckBox) && (((CheckBox)button).check_state == CheckState.Checked)) ||
+ ((button is RadioButton) && (((RadioButton)button).check_state == CheckState.Checked))) {
+ state_type = StateType.Active;
+ shadow_type = ShadowType.In;
+ detail = "button";
+ } else
+ if (!button.is_enabled) {
+ state_type = StateType.Insensitive;
+ } else
+ if (button.is_pressed) {
+ state_type = StateType.Active;
+ shadow_type = ShadowType.In;
+ detail = "button";
+ } else
+ if (button.is_entered) {
+ state_type = StateType.Prelight;
+ }
+
+ if (button.Focused)
+ gtk_widget_grab_focus (global_gtk_button);
+
+ if (button.flat_style == FlatStyle.Flat)
+ gtk_paint_flat_box (current_style,
+ current_gdk_drawable,
+ (int) state_type,
+ (int) shadow_type,
+ IntPtr.Zero,
+ global_gtk_button,
+ detail,
+ buttonRectangle.X, buttonRectangle.Y,
+ buttonRectangle.Width, buttonRectangle.Height);
+ else
+ if (button.flat_style != FlatStyle.Popup || (button.flat_style == FlatStyle.Popup && button.is_entered))
+ gtk_paint_box (current_style,
+ current_gdk_drawable,
+ (int) state_type,
+ (int) shadow_type,
+ IntPtr.Zero,
+ global_gtk_button,
+ detail,
+ buttonRectangle.X, buttonRectangle.Y,
+ buttonRectangle.Width, buttonRectangle.Height);
+ }
+
+ protected override void ButtonBase_DrawFocus (ButtonBase button, Graphics dc)
+ {
+ if (!button.is_enabled)
+ return;
+
+ Rectangle focus_rect = new Rectangle (button.ClientRectangle.X + 4, button.ClientRectangle.Y + 4, button.ClientRectangle.Width - 9, button.ClientRectangle.Height - 9);
+
+ gtk_widget_grab_focus (global_gtk_button);
+
+ gtk_paint_focus (current_style,
+ current_gdk_drawable,
+ (int) StateType.Active,
+ IntPtr.Zero,
+ global_gtk_button,
+ "button",
+ focus_rect.X,
+ focus_rect.Y,
+ focus_rect.Width,
+ focus_rect.Height);
+ }
+
+ #region ScrollBar
+ public override void DrawScrollBar( Graphics dc, Rectangle clip, ScrollBar bar ) {
+ int scrollbutton_width = bar.scrollbutton_width;
+ int scrollbutton_height = bar.scrollbutton_height;
+ Rectangle first_arrow_area;
+ Rectangle second_arrow_area;
+ Rectangle thumb_pos;
+
+ SetDrawableAndStyle (bar);
+
+ Rectangle allocation = new Rectangle (bar.ClientRectangle.X, bar.ClientRectangle.Y, bar.ClientRectangle.Width, bar.ClientRectangle.Height);
+
+ // fix for artefacts
+ Color fix_color = bar.Parent != null ? bar.Parent.BackColor : ColorControl;
+
+ if (bar.vert) {
+ gtk_widget_size_allocate (global_gtk_vscrollbar, ref allocation);
+
+ // fix for artefacts
+ dc.FillRectangle (ResPool.GetSolidBrush (fix_color),
+ bar.ClientRectangle.X, bar.ClientRectangle.Y, bar.ClientRectangle.Width, 3);
+ dc.FillRectangle (ResPool.GetSolidBrush (fix_color),
+ bar.ClientRectangle.X, bar.ClientRectangle.Bottom - 4, bar.ClientRectangle.Width, 3);
+ } else {
+ gtk_widget_size_allocate (global_gtk_hscrollbar, ref allocation);
+
+ // fix for artefacts
+ dc.FillRectangle (ResPool.GetSolidBrush (fix_color),
+ bar.ClientRectangle.X, bar.ClientRectangle.Y, 3, bar.ClientRectangle.Height);
+ dc.FillRectangle (ResPool.GetSolidBrush (fix_color),
+ bar.ClientRectangle.Right - 4, bar.ClientRectangle.Y, 3, bar.ClientRectangle.Height);
+ }
+
+ thumb_pos = bar.ThumbPos;
+
+ if ( bar.vert ) {
+ first_arrow_area = new Rectangle( 0, 0, bar.Width, scrollbutton_height + 1 );
+ bar.FirstArrowArea = first_arrow_area;
+
+ second_arrow_area = new Rectangle( 0, bar.ClientRectangle.Height - scrollbutton_height - 1, bar.Width, scrollbutton_height + 1 );
+ bar.SecondArrowArea = second_arrow_area;
+
+ thumb_pos.Width = bar.Width;
+ bar.ThumbPos = thumb_pos;
+
+ ScrollBar_Vertical_Draw_ThumbMoving_None (scrollbutton_height, bar, clip, dc);
+
+ /* Buttons */
+ if ( clip.IntersectsWith( first_arrow_area ) )
+ CPDrawScrollButton( dc, first_arrow_area, ScrollButton.Up, bar.firstbutton_state );
+ if ( clip.IntersectsWith( second_arrow_area ) )
+ CPDrawScrollButton( dc, second_arrow_area, ScrollButton.Down, bar.secondbutton_state );
+ } else {
+ first_arrow_area = new Rectangle( 0, 0, scrollbutton_width + 1, bar.Height );
+ bar.FirstArrowArea = first_arrow_area;
+
+ second_arrow_area = new Rectangle( bar.ClientRectangle.Width - scrollbutton_width - 1, 0, scrollbutton_width + 1, bar.Height );
+ bar.SecondArrowArea = second_arrow_area;
+
+ thumb_pos.Height = bar.Height;
+ bar.ThumbPos = thumb_pos;
+
+ /* Background */
+ ScrollBar_Horizontal_Draw_ThumbMoving_None (scrollbutton_width, bar, clip, dc);
+
+ /* Buttons */
+ if ( clip.IntersectsWith( first_arrow_area ) )
+ CPDrawScrollButton( dc, first_arrow_area, ScrollButton.Left, bar.firstbutton_state );
+ if ( clip.IntersectsWith( second_arrow_area ) )
+ CPDrawScrollButton( dc, second_arrow_area, ScrollButton.Right, bar.secondbutton_state );
+ }
+
+ /* Thumb */
+ ScrollBar_DrawThumb( bar, thumb_pos, clip, dc );
+
+ #if _EXPERIMENTAL_
+ DrawDrawableToDC (dc, bar);
+ #endif
+ }
+
+ protected override void ScrollBar_DrawThumb( ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc ) {
+ if ( bar.Enabled)
+ DrawScrollBarThumb( dc, thumb_pos, bar );
+ }
+
+ protected override void ScrollBar_Vertical_Draw_ThumbMoving_None (int scrollbutton_height, ScrollBar bar, Rectangle clip, Graphics dc)
+ {
+ Rectangle r = new Rectangle (0,
+ scrollbutton_height, bar.ClientRectangle.Width, bar.ClientRectangle.Height - (scrollbutton_height * 2));
+ gtk_paint_box (current_style,
+ current_gdk_drawable,
+ (int) StateType.Active,
+ (int) ShadowType.In,
+ IntPtr.Zero,
+ global_gtk_vscrollbar,
+ "vscrollbar",
+ r.X, r.Y,
+ r.Width, r.Height);
+ }
+
+ protected override void ScrollBar_Horizontal_Draw_ThumbMoving_None (int scrollbutton_width, ScrollBar bar, Rectangle clip, Graphics dc)
+ {
+ Rectangle r = new Rectangle (scrollbutton_width,
+ 0, bar.ClientRectangle.Width - (scrollbutton_width * 2), bar.ClientRectangle.Height);
+
+ gtk_paint_box (current_style,
+ current_gdk_drawable,
+ (int) StateType.Active,
+ (int) ShadowType.In,
+ IntPtr.Zero,
+ global_gtk_hscrollbar,
+ "hscrollbar",
+ r.X, r.Y,
+ r.Width, r.Height);
+ }
+
+ private void DrawScrollBarThumb( Graphics dc, Rectangle area, ScrollBar bar ) {
+ IntPtr gtk_scrollbar = bar.vert ? global_gtk_vscrollbar : global_gtk_hscrollbar;
+
+ gtk_paint_box (current_style,
+ current_gdk_drawable,
+ (int) StateType.Active,
+ (int) ShadowType.Out,
+ IntPtr.Zero,
+ gtk_scrollbar,
+ "slider",
+ area.X, area.Y,
+ area.Width, area.Height);
+ }
+ #endregion // ScrollBar
+
+ #region ProgressBar
+ public override void DrawProgressBar (Graphics dc, Rectangle clip_rect, ProgressBar ctrl)
+ {
+ Rectangle client_area = ctrl.client_area;
+ int barpos_pixels;
+
+ SetDrawableAndStyle (ctrl);
+
+ // draw background
+ gtk_paint_box (current_style,
+ current_gdk_drawable,
+ (int) StateType.Normal,
+ (int) ShadowType.In,
+ IntPtr.Zero,
+ global_gtk_progress_bar,
+ "trough",
+ ctrl.ClientRectangle.X,
+ ctrl.ClientRectangle.Y,
+ ctrl.ClientRectangle.Width,
+ ctrl.ClientRectangle.Height);
+
+ // don't draw the bar if Value is = 0
+ if (ctrl.Value <= 0)
+ return;
+
+ int value = ctrl.Value;
+
+ if (value > ctrl.Maximum)
+ value = ctrl.Maximum;
+
+ if (value == ctrl.Maximum)
+ barpos_pixels = client_area.Width + 2;
+ else
+ barpos_pixels = (((value - ctrl.Minimum) * client_area.Width) / (ctrl.Maximum - ctrl.Minimum)) + 1;
+
+ gtk_paint_box (current_style,
+ current_gdk_drawable,
+ (int) StateType.Prelight,
+ (int) ShadowType.Out,
+ IntPtr.Zero,
+ global_gtk_progress_bar,
+ "bar",
+ client_area.X - 1, client_area.Y - 1,
+ barpos_pixels, client_area.Height + 2);
+
+ #if _EXPERIMENTAL_
+ DrawDrawableToDC (dc, ctrl);
+ #endif
+ }
+ #endregion // ProgressBar
+
+ #region RadioButton
+ protected override void RadioButton_DrawButton (RadioButton radio_button, Graphics dc, ButtonState state, Rectangle radiobutton_rectangle)
+ {
+ // we currently don't care for flat or popup radio buttons
+ if (radio_button.appearance == Appearance.Button) {
+ DrawButtonBase (dc, radio_button.ClientRectangle, radio_button);
+ } else {
+ DrawRadioButton (dc, radio_button, state, radiobutton_rectangle);
+ }
+ }
+
+ private void DrawRadioButton (Graphics dc, RadioButton radio_button, ButtonState state, Rectangle radiobutton_rectangle)
+ {
+ SetDrawableAndStyle (radio_button);
+
+ ShadowType shadow_type;
+
+ if (!radio_button.Enabled)
+ shadow_type = ShadowType.Out;
+ else
+ shadow_type = radio_button.Checked ? ShadowType.In : ShadowType.EtchedIn;
+
+ StateType state_type = StateType.Normal;
+
+ if (!radio_button.Enabled)
+ state_type = StateType.Insensitive;
+ else
+ if (radio_button.is_pressed)
+ state_type = StateType.Active;
+ else
+ if (radio_button.is_entered)
+ state_type = StateType.Prelight;
+
+ gtk_paint_option (current_style,
+ current_gdk_drawable,
+ (int) state_type,
+ (int) shadow_type,
+ IntPtr.Zero,
+ global_gtk_radio_button,
+ "radiobutton",
+ radiobutton_rectangle.X,
+ radiobutton_rectangle.Y,
+ radiobutton_rectangle.Width,
+ radiobutton_rectangle.Height);
+
+ #if _EXPERIMENTAL_
+ DrawDrawableToDC (dc, radio_button);
+ #endif
+ }
+
+ protected override void RadioButton_DrawText (RadioButton radio_button, Rectangle text_rectangle, Graphics dc, StringFormat text_format)
+ {
+ if (radio_button.Appearance != Appearance.Button)
+ base.RadioButton_DrawText (radio_button, text_rectangle, dc, text_format);
+ }
+
+ protected override void RadioButton_DrawFocus (RadioButton radio_button, Graphics dc, Rectangle text_rectangle)
+ {
+ if (radio_button.Focused && radio_button.appearance != Appearance.Button) {
+ gtk_paint_focus (current_style,
+ current_gdk_drawable,
+ (int) StateType.Active,
+ IntPtr.Zero,
+ global_gtk_radio_button,
+ "radiobutton",
+ text_rectangle.X,
+ text_rectangle.Y,
+ text_rectangle.Width,
+ text_rectangle.Height);
+ }
+
+ #if _EXPERIMENTAL_
+ DrawDrawableToDC (dc, radio_button);
+ #endif
+ }
+ #endregion // RadioButton
+
+ #region CheckBox
+ protected override void CheckBox_DrawCheckBox (Graphics dc, CheckBox checkbox, ButtonState state, Rectangle checkbox_rectangle)
+ {
+ // render as per normal button
+ if (checkbox.appearance == Appearance.Button) {
+ DrawButtonBase (dc, checkbox.ClientRectangle, checkbox);
+ } else {
+ InternalDrawCheckBox (dc, checkbox, state, checkbox_rectangle);
+ }
+ }
+
+ private void InternalDrawCheckBox (Graphics dc, CheckBox checkbox, ButtonState state, Rectangle checkbox_rectangle)
+ {
+ SetDrawableAndStyle (checkbox);
+
+ ShadowType shadow_type;
+
+ if (!checkbox.Enabled)
+ shadow_type = ShadowType.Out;
+ else
+ shadow_type = checkbox.Checked ? ShadowType.In : ShadowType.EtchedIn;
+
+ StateType state_type = StateType.Normal;
+
+ if (!checkbox.Enabled)
+ state_type = StateType.Insensitive;
+ else
+ if (checkbox.is_pressed)
+ state_type = StateType.Active;
+ else
+ if (checkbox.is_entered)
+ state_type = StateType.Prelight;
+
+ gtk_paint_check (current_style,
+ current_gdk_drawable,
+ (int) state_type,
+ (int) shadow_type,
+ IntPtr.Zero,
+ global_gtk_check_button,
+ "checkbutton",
+ checkbox_rectangle.X,
+ checkbox_rectangle.Y,
+ checkbox_rectangle.Width,
+ checkbox_rectangle.Height);
+
+ #if _EXPERIMENTAL_
+ DrawDrawableToDC (dc, checkbox);
+ #endif
+ }
+
+ protected override void CheckBox_DrawText (CheckBox checkbox, Rectangle text_rectangle, Graphics dc, StringFormat text_format)
+ {
+ if (checkbox.Appearance != Appearance.Button)
+ base.CheckBox_DrawText (checkbox, text_rectangle, dc, text_format);
+ }
+
+ protected override void CheckBox_DrawFocus( CheckBox checkbox, Graphics dc, Rectangle text_rectangle )
+ {
+ if (checkbox.Focused && checkbox.appearance != Appearance.Button) {
+ gtk_paint_focus (current_style,
+ current_gdk_drawable,
+ (int) StateType.Active,
+ IntPtr.Zero,
+ global_gtk_check_button,
+ "checkbutton",
+ text_rectangle.X,
+ text_rectangle.Y,
+ text_rectangle.Width,
+ text_rectangle.Height);
+ }
+
+ #if _EXPERIMENTAL_
+ DrawDrawableToDC (dc, checkbox);
+ #endif
+ }
+ #endregion // CheckBox
+
+ #region TrackBar
+ private void DrawTrackBar_Vertical (Graphics dc, Rectangle clip_rectangle, TrackBar tb,
+ ref Rectangle thumb_pos, ref Rectangle thumb_area,
+ float ticks, int value_pos, bool mouse_value)
+ {
+ Point toptick_startpoint = new Point ();
+ Point bottomtick_startpoint = new Point ();
+ Point channel_startpoint = new Point ();
+ float pixel_len;
+ float pixels_betweenticks;
+ const int space_from_right = 8;
+ const int space_from_left = 8;
+ Rectangle area = tb.ClientRectangle;
+
+ Rectangle allocation = new Rectangle (area.X, area.Y, area.Width, area.Height);
+
+ gtk_widget_size_allocate (current_widget, ref allocation);
+
+ gtk_range_set_range (current_widget, tb.Minimum, tb.Maximum);
+ gtk_range_set_value (current_widget, tb.Value);
+
+ ShadowType shadow_type = ShadowType.In;
+
+ if (!tb.Enabled)
+ shadow_type = ShadowType.Out;
+
+ StateType state_type = StateType.Normal;
+
+ if (!tb.Enabled)
+ state_type = StateType.Insensitive;
+ else
+ if (tb.is_entered)
+ state_type = StateType.Prelight;
+
+ switch (tb.TickStyle) {
+ case TickStyle.BottomRight:
+ case TickStyle.None:
+ channel_startpoint.Y = 8;
+ channel_startpoint.X = 9;
+ bottomtick_startpoint.Y = 13;
+ bottomtick_startpoint.X = 24;
+ break;
+ case TickStyle.TopLeft:
+ channel_startpoint.Y = 8;
+ channel_startpoint.X = 19;
+ toptick_startpoint.Y = 13;
+ toptick_startpoint.X = 8;
+ break;
+ case TickStyle.Both:
+ channel_startpoint.Y = 8;
+ channel_startpoint.X = 18;
+ bottomtick_startpoint.Y = 13;
+ bottomtick_startpoint.X = 32;
+ toptick_startpoint.Y = 13;
+ toptick_startpoint.X = 8;
+ break;
+ default:
+ break;
+ }
+
+ thumb_area.X = area.X + channel_startpoint.X;
+ thumb_area.Y = area.Y + channel_startpoint.Y;
+ thumb_area.Height = area.Height - space_from_right - space_from_left;
+ thumb_area.Width = 4;
+
+ pixel_len = thumb_area.Height - 11;
+ pixels_betweenticks = pixel_len / (tb.Maximum - tb.Minimum);
+
+ /* Convert thumb position from mouse position to value*/
+ if (mouse_value) {
+
+ if (value_pos >= channel_startpoint.Y)
+ value_pos = (int)(((float) (value_pos - channel_startpoint.Y)) / pixels_betweenticks);
+ else
+ value_pos = 0;
+
+ if (value_pos + tb.Minimum > tb.Maximum)
+ value_pos = tb.Maximum - tb.Minimum;
+
+ tb.Value = value_pos + tb.Minimum;
+ }
+
+ thumb_pos.Width = 13;
+ thumb_pos.Height = 29;
+
+ thumb_pos.Y = channel_startpoint.Y + (int) (pixels_betweenticks * (float) value_pos) - (thumb_pos.Height / 3);
+
+ if (thumb_pos.Y < channel_startpoint.Y)
+ thumb_pos.Y = channel_startpoint.Y;
+
+ if (thumb_pos.Y > thumb_area.Bottom - 29)
+ thumb_pos.Y = thumb_area.Bottom - 29;
+
+ /* Draw channel */
+ gtk_paint_box (current_style,
+ current_gdk_drawable,
+ (int)state_type,
+ (int)shadow_type,
+ IntPtr.Zero,
+ current_widget,
+ "trough",
+ thumb_area.X,
+ thumb_area.Y,
+ 4,
+ thumb_area.Height);
+
+ /* Draw thumb */
+ thumb_pos.X = channel_startpoint.X + 2 - thumb_pos.Width / 2;
+
+ shadow_type = ShadowType.Out;
+
+ gtk_paint_slider (current_style,
+ current_gdk_drawable,
+ (int)state_type,
+ (int)shadow_type,
+ IntPtr.Zero,
+ current_widget,
+ "vscale",
+ thumb_pos.X,
+ thumb_pos.Y,
+ thumb_pos.Width,
+ thumb_pos.Height,
+ 0);
+
+ pixel_len = thumb_area.Height - 11;
+ pixels_betweenticks = pixel_len / ticks;
+
+ /* Draw ticks*/
+ thumb_area.X = thumb_pos.X;
+ thumb_area.Y = channel_startpoint.Y;
+ thumb_area.Width = thumb_pos.Width;
+
+ Region outside = new Region (area);
+ outside.Exclude (thumb_area);
+
+ if (outside.IsVisible (clip_rectangle)) {
+ if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
+ ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
+
+ for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
+ if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len + 1)
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X , area.Y + bottomtick_startpoint.Y + inc,
+ area.X + bottomtick_startpoint.X + 3, area.Y + bottomtick_startpoint.Y + inc);
+ else
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X, area.Y + bottomtick_startpoint.Y + inc,
+ area.X + bottomtick_startpoint.X + 2, area.Y + bottomtick_startpoint.Y + inc);
+ }
+ }
+
+ if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
+ ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
+
+ pixel_len = thumb_area.Height - 11;
+ pixels_betweenticks = pixel_len / ticks;
+
+ for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
+ if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len + 1)
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X - 3 , area.Y + toptick_startpoint.Y + inc,
+ area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
+ else
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X - 2, area.Y + toptick_startpoint.Y + inc,
+ area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
+ }
+ }
+ }
+
+ outside.Dispose ();
+ }
+
+ private void DrawTrackBar_Horizontal (Graphics dc, Rectangle clip_rectangle, TrackBar tb,
+ ref Rectangle thumb_pos, ref Rectangle thumb_area,
+ float ticks, int value_pos, bool mouse_value)
+ {
+ Point toptick_startpoint = new Point ();
+ Point bottomtick_startpoint = new Point ();
+ Point channel_startpoint = new Point ();
+ float pixel_len;
+ float pixels_betweenticks;
+ const int space_from_right = 8;
+ const int space_from_left = 8;
+ Rectangle area = tb.ClientRectangle;
+
+ Rectangle allocation = new Rectangle (area.X, area.Y, area.Width, area.Height);
+
+ gtk_widget_size_allocate (current_widget, ref allocation);
+
+ gtk_range_set_range (current_widget, tb.Minimum, tb.Maximum);
+ gtk_range_set_value (current_widget, tb.Value);
+
+ ShadowType shadow_type = ShadowType.In;
+
+ if (!tb.Enabled)
+ shadow_type = ShadowType.Out;
+
+ StateType state_type = StateType.Normal;
+
+ if (!tb.Enabled)
+ state_type = StateType.Insensitive;
+ else
+ if (tb.is_entered)
+ state_type = StateType.Prelight;
+
+ switch (tb.TickStyle) {
+ case TickStyle.BottomRight:
+ case TickStyle.None:
+ channel_startpoint.X = 8;
+ channel_startpoint.Y = 9;
+ bottomtick_startpoint.X = 13;
+ bottomtick_startpoint.Y = 24;
+ break;
+ case TickStyle.TopLeft:
+ channel_startpoint.X = 8;
+ channel_startpoint.Y = 19;
+ toptick_startpoint.X = 13;
+ toptick_startpoint.Y = 8;
+ break;
+ case TickStyle.Both:
+ channel_startpoint.X = 8;
+ channel_startpoint.Y = 18;
+ bottomtick_startpoint.X = 13;
+ bottomtick_startpoint.Y = 32;
+ toptick_startpoint.X = 13;
+ toptick_startpoint.Y = 8;
+ break;
+ default:
+ break;
+ }
+
+ thumb_area.X = area.X + channel_startpoint.X;
+ thumb_area.Y = area.Y + channel_startpoint.Y;
+ thumb_area.Width = area.Width - space_from_right - space_from_left;
+ thumb_area.Height = 4;
+
+ pixel_len = thumb_area.Width - 11;
+ pixels_betweenticks = pixel_len / (tb.Maximum - tb.Minimum);
+
+ /* Convert thumb position from mouse position to value*/
+ if (mouse_value) {
+ if (value_pos >= channel_startpoint.X)
+ value_pos = (int)(((float) (value_pos - channel_startpoint.X)) / pixels_betweenticks);
+ else
+ value_pos = 0;
+
+ if (value_pos + tb.Minimum > tb.Maximum)
+ value_pos = tb.Maximum - tb.Minimum;
+
+ tb.Value = value_pos + tb.Minimum;
+ }
+
+ thumb_pos.Width = 29;
+ thumb_pos.Height = 13;
+
+ thumb_pos.X = channel_startpoint.X + (int) (pixels_betweenticks * (float) value_pos) - (thumb_pos.Width / 3);
+
+
+ if (thumb_pos.X < channel_startpoint.X)
+ thumb_pos.X = channel_startpoint.X;
+
+ if (thumb_pos.X > thumb_area.Right - 29)
+ thumb_pos.X = thumb_area.Right - 29;
+
+ /* Draw channel */
+ gtk_paint_box (current_style,
+ current_gdk_drawable,
+ (int)state_type,
+ (int)shadow_type,
+ IntPtr.Zero,
+ current_widget,
+ "trough",
+ thumb_area.X,
+ thumb_area.Y,
+ thumb_area.Width,
+ 4);
+
+ /* Draw thumb */
+
+ thumb_pos.Y = channel_startpoint.Y + 2 - thumb_pos.Height / 2;
+
+ shadow_type = ShadowType.Out;
+
+ gtk_paint_slider (current_style,
+ current_gdk_drawable,
+ (int)state_type,
+ (int)shadow_type,
+ IntPtr.Zero,
+ current_widget,
+ "hscale",
+ thumb_pos.X,
+ thumb_pos.Y,
+ thumb_pos.Width,
+ thumb_pos.Height,
+ 0);
+
+ pixel_len = thumb_area.Width - 11;
+ pixels_betweenticks = pixel_len / ticks;
+
+ /* Draw ticks*/
+ thumb_area.Y = thumb_pos.Y;
+ thumb_area.X = channel_startpoint.X;
+ thumb_area.Height = thumb_pos.Height;
+ Region outside = new Region (area);
+ outside.Exclude (thumb_area);
+
+ if (outside.IsVisible (clip_rectangle)) {
+ if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
+ ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
+
+ for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
+ if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len + 1)
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y,
+ area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y + 3);
+ else
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y,
+ area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y + 2);
+ }
+ }
+
+ if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
+ ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
+
+ for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
+ if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len + 1)
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y - 3,
+ area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y);
+ else
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y - 2,
+ area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y);
+ }
+ }
+ }
+
+ outside.Dispose ();
+ }
+
+ public override void DrawTrackBar (Graphics dc, Rectangle clip_rectangle, TrackBar tb)
+ {
+ int value_pos;
+ bool mouse_value;
+ float ticks = (tb.Maximum - tb.Minimum) / tb.tickFrequency; /* N of ticks draw*/
+ Rectangle area;
+ Rectangle thumb_pos = tb.ThumbPos;
+ Rectangle thumb_area = tb.ThumbArea;
+
+ if (tb.thumb_pressed) {
+ value_pos = tb.thumb_mouseclick;
+ mouse_value = true;
+ } else {
+ value_pos = tb.Value - tb.Minimum;
+ mouse_value = false;
+ }
+
+ area = tb.ClientRectangle;
+
+ SetDrawableAndStyle (tb);
+
+ /* Control Background */
+ if (tb.BackColor == DefaultControlBackColor) {
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), clip_rectangle);
+ } else {
+ dc.FillRectangle (ResPool.GetSolidBrush (tb.BackColor), clip_rectangle);
+ }
+
+ if (tb.Orientation == Orientation.Vertical) {
+ DrawTrackBar_Vertical (dc, clip_rectangle, tb, ref thumb_pos, ref thumb_area,
+ ticks, value_pos, mouse_value);
+
+ } else {
+ DrawTrackBar_Horizontal (dc, clip_rectangle, tb, ref thumb_pos, ref thumb_area,
+ ticks, value_pos, mouse_value);
+ }
+
+ if (tb.Enabled && tb.Focused)
+ gtk_paint_focus (current_style,
+ current_gdk_drawable,
+ (int)StateType.Normal,
+ IntPtr.Zero,
+ current_widget,
+ "trough",
+ area.X,
+ area.Y,
+ area.Width,
+ area.Height);
+
+ tb.ThumbPos = thumb_pos;
+ tb.ThumbArea = thumb_area;
+
+ #if _EXPERIMENTAL_
+ DrawDrawableToDC (dc, tb);
+ #endif
+ }
+ #endregion // TrackBar
+
+ public override void CPDrawButton (Graphics dc, Rectangle rectangle, ButtonState state)
+ {
+ #if _EXPERIMENTAL_
+ SetDrawableAndStyle (rectangle, typeof(ButtonBase), Orientation.Horizontal);
+ #endif
+
+ bool is_pushed = false;
+// bool is_checked = false;
+// bool is_flat = false;
+ bool is_inactive = false;
+
+ if ((state & ButtonState.Pushed) != 0) {
+ is_pushed = true;
+ }
+
+// if ((state & ButtonState.Checked) != 0) {
+// is_checked = true;
+// }
+//
+// if ((state & ButtonState.Flat) != 0) {
+// is_flat = true;
+// }
+
+ if ((state & ButtonState.Inactive) != 0) {
+ is_inactive = true;
+ }
+
+ IntPtr drawbutton_style = gtk_style_attach (global_gtk_button_style, current_gdk_drawable); // need it
+
+ StateType state_type = StateType.Normal;
+ ShadowType shadow_type = ShadowType.Out;
+ string detail = "buttondefault";
+
+ if (is_inactive) {
+ state_type = StateType.Insensitive;
+ } else
+ if (is_pushed) {
+ state_type = StateType.Active;
+ shadow_type = ShadowType.In;
+ detail = "button";
+ }
+
+ gtk_paint_box (drawbutton_style, current_gdk_drawable,
+ (int) state_type,
+ (int) shadow_type,
+ IntPtr.Zero,
+ IntPtr.Zero,
+ detail,
+ rectangle.X, rectangle.Y,
+ rectangle.Width, rectangle.Height);
+
+ #if _EXPERIMENTAL_
+ DrawDrawableToDC (dc, rectangle);
+ #endif
+ }
+
+ /* Scroll button: regular button + direction arrow */
+ public override void CPDrawScrollButton (Graphics dc, Rectangle area, ScrollButton scroll_button_type, ButtonState state)
+ {
+ #if _EXPERIMENTAL_
+ Orientation orientation = Orientation.Vertical;
+ if (scroll_button_type == ScrollButton.Left || scroll_button_type == ScrollButton.Right)
+ orientation = Orientation.Horizontal;
+ SetDrawableAndStyle (area, typeof(ScrollBar), orientation);
+ #endif
+
+ bool enabled = (state == ButtonState.Inactive) ? false: true;
+
+ StateType state_type = enabled ? StateType.Normal : StateType.Insensitive;
+
+ DrawScrollButtonPrimitive (dc, area, state, scroll_button_type);
+
+ if (area.Width < 12 || area.Height < 12) /* Cannot see a thing at smaller sizes */
+ return;
+
+ ArrowType arrow_type = 0;
+
+ switch (scroll_button_type) {
+ case ScrollButton.Up:
+ arrow_type = ArrowType.Up;
+ break;
+ case ScrollButton.Down:
+ arrow_type = ArrowType.Down;
+ break;
+ case ScrollButton.Right:
+ arrow_type = ArrowType.Right;
+ break;
+ case ScrollButton.Left:
+ arrow_type = ArrowType.Left;
+ break;
+ default:
+ break;
+ }
+
+ int centerX = area.Left + area.Width / 2;
+ int centerY = area.Top + area.Height / 2;
+ int arrow_x = 0, arrow_y = 0, arrow_height = 0, arrow_width = 0;
+
+ switch (scroll_button_type) {
+ case ScrollButton.Down:
+ case ScrollButton.Up:
+ arrow_x = centerX - 4;
+ arrow_y = centerY - 2;
+ arrow_width = 8;
+ arrow_height = 4;
+ break;
+ case ScrollButton.Left:
+ case ScrollButton.Right:
+ arrow_x = centerX - 2;
+ arrow_y = centerY - 4;
+ arrow_width = 4;
+ arrow_height = 8;
+ break;
+ default:
+ break;
+ }
+
+ gtk_paint_arrow (current_style,
+ current_gdk_drawable,
+ (int) state_type,
+ (int) ShadowType.Out,
+ IntPtr.Zero,
+ current_widget,
+ "",
+ (int) arrow_type, true,
+ arrow_x,
+ arrow_y,
+ arrow_width, arrow_height);
+
+ current_widget = IntPtr.Zero;
+
+ #if _EXPERIMENTAL_
+ DrawDrawableToDC (dc, area);
+ #endif
+ }
+
+ public void DrawScrollButtonPrimitive (Graphics dc, Rectangle area, ButtonState state, ScrollButton scroll_button_type)
+ {
+ StateType state_type = StateType.Normal;
+ ShadowType shadow_type = ShadowType.Out;
+
+ if ((state & ButtonState.Pushed) == ButtonState.Pushed) {
+ state_type = StateType.Active;
+ shadow_type = ShadowType.In;
+ }
+
+ switch (scroll_button_type) {
+ case ScrollButton.Left:
+ case ScrollButton.Right:
+ gtk_paint_box (current_style,
+ current_gdk_drawable,
+ (int) state_type,
+ (int) shadow_type,
+ IntPtr.Zero,
+ global_gtk_hscrollbar,
+ "stepper",
+ area.X, area.Y,
+ area.Width, area.Height);
+ break;
+ case ScrollButton.Up:
+ case ScrollButton.Down:
+ gtk_paint_box (current_style,
+ current_gdk_drawable,
+ (int) state_type,
+ (int) shadow_type,
+ IntPtr.Zero,
+ global_gtk_vscrollbar,
+ "stepper",
+ area.X, area.Y,
+ area.Width, area.Height);
+ break;
+ }
+ }
+
+ private static Color ColorFromGdkColor (GdkColorStruct gtkcolor)
+ {
+ return Color.FromArgb (255,
+ (gtkcolor.red >> 8) & 0xff,
+ (gtkcolor.green >> 8) & 0xff,
+ (gtkcolor.blue >> 8) & 0xff );
+ }
+
+ } //class
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeNice.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeNice.cs
new file mode 100644
index 00000000000..cbf729c5852
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeNice.cs
@@ -0,0 +1,1423 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Alexander Olk, xenomorph2@onlinehome.de
+//
+// based on ThemeWin32Classic
+//
+// - You can activate this Theme with export MONO_THEME=nice
+
+
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+using System.Drawing.Text;
+
+namespace System.Windows.Forms
+{
+ internal class ThemeNice : ThemeWin32Classic
+ {
+ public override Version Version
+ {
+ get {
+ return new Version( 0, 0, 0, 2 );
+ }
+ }
+
+ static readonly Color NormalColor = Color.LightGray;
+ static readonly Color MouseOverColor = Color.DarkGray;
+ static readonly Color PressedColor = Color.Gray;
+ static readonly Color FocusColor = Color.FromArgb( System.Convert.ToInt32( "0xff00c0ff", 16 ) );
+ static readonly Color LightColor = Color.LightGray;
+ static readonly Color BorderColor = MouseOverColor;
+ static readonly Color NiceBackColor = Color.FromArgb( System.Convert.ToInt32( "0xffefebe7", 16 ) );
+
+ static Bitmap size_grip_bmp = CreateSizegripDot();
+
+ #region Principal Theme Methods
+ public ThemeNice( )
+ {
+ ColorControl = NiceBackColor;
+ always_draw_hotkeys = true;
+ }
+
+ public override Color DefaultControlBackColor
+ {
+ get { return NiceBackColor; }
+ }
+
+ public override Color DefaultWindowBackColor
+ {
+ get { return NiceBackColor; }
+ }
+
+ public override Color ColorControl {
+ get { return NiceBackColor;}
+ }
+
+ static Bitmap CreateSizegripDot()
+ {
+ Bitmap bmp = new Bitmap( 4, 4 );
+ using ( Graphics dc = Graphics.FromImage( bmp ) )
+ {
+ SmoothingMode old_smoothing_mode = dc.SmoothingMode;
+ dc.SmoothingMode = SmoothingMode.AntiAlias;
+
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 4, 4 ), PressedColor, Color.White ) )
+ dc.FillEllipse( lgbr, new Rectangle( 0, 0, 4, 4 ) );
+
+ dc.SmoothingMode = old_smoothing_mode;
+ }
+
+ return bmp;
+ }
+ #endregion // Internal Methods
+
+ #region ButtonBase
+ protected override void ButtonBase_DrawButton( ButtonBase button, Graphics dc )
+ {
+ Rectangle buttonRectangle;
+
+ int width = button.ClientSize.Width;
+ int height = button.ClientSize.Height;
+
+ dc.FillRectangle( ResPool.GetSolidBrush( button.BackColor ), button.ClientRectangle );
+
+ // set up the button rectangle
+ buttonRectangle = button.ClientRectangle;
+
+ Color use_color;
+ Color first_color = button.has_focus ? Color.LightYellow : Color.White;
+
+ if ( ( ( button is CheckBox ) && ( ( (CheckBox)button ).check_state == CheckState.Checked ) ) ||
+ ( ( button is RadioButton ) && ( ( (RadioButton)button ).check_state == CheckState.Checked ) ) )
+ {
+ use_color = PressedColor;
+ }
+ else
+ if ( !button.is_enabled )
+ {
+ use_color = NormalColor;
+ button.is_entered = false;
+ }
+ else
+ if ( !button.is_entered )
+ {
+ use_color = NormalColor;
+ }
+ else
+ {
+ if ( !button.is_pressed )
+ use_color = MouseOverColor;
+ else
+ use_color = PressedColor;
+ }
+
+ // Fill button with a nice linear gradient brush
+ Rectangle lgbRectangle = Rectangle.Inflate( buttonRectangle, -1, -1 );
+
+ if ( button.flat_style != FlatStyle.Popup || ( ( button.flat_style == FlatStyle.Popup ) && button.is_entered ) )
+ {
+ LinearGradientBrush lgbr;
+ if ( button.flat_style == FlatStyle.Flat )
+ lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, height - 1 ), use_color, first_color );
+ else
+ lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, height - 1 ), first_color, use_color );
+ dc.FillRectangle( lgbr, lgbRectangle );
+ lgbr.Dispose( );
+
+ if ( button.has_focus )
+ return;
+
+ Point[] points = new Point[] {
+ new Point( 2, 0 ),
+ new Point( width - 3, 0 ),
+ new Point( width - 1, 2 ),
+ new Point( width - 1, height - 3 ),
+ new Point( width - 3, height - 1 ),
+ new Point( 2, height - 1 ),
+ new Point( 0, height - 3 ),
+ new Point( 0, 2 ),
+ new Point( 2, 0 )
+ };
+
+ Pen pen = ResPool.GetPen( BorderColor );
+ dc.DrawLines( pen, points );
+ }
+ }
+
+ protected override void ButtonBase_DrawFocus( ButtonBase button, Graphics dc )
+ {
+ int width = button.ClientSize.Width;
+ int height = button.ClientSize.Height;
+
+ Point[] points = new Point[] {
+ new Point( 2, 0 ),
+ new Point( width - 3, 0 ),
+ new Point( width - 1, 2 ),
+ new Point( width - 1, height - 3 ),
+ new Point( width - 3, height - 1 ),
+ new Point( 2, height - 1 ),
+ new Point( 0, height - 3 ),
+ new Point( 0, 2 ),
+ new Point( 2, 0 )
+ };
+
+ Pen pen = ResPool.GetPen( FocusColor );
+ dc.DrawLines( pen, points );
+ }
+
+ protected override void ButtonBase_DrawText( ButtonBase button, Graphics dc )
+ {
+ if ( !( button is CheckBox ) && !(button is RadioButton ) )
+ {
+ base.ButtonBase_DrawText( button, dc );
+ }
+ }
+ #endregion // ButtonBase
+
+ #region CheckBox
+ protected override void CheckBox_DrawCheckBox( Graphics dc, CheckBox checkbox, ButtonState state, Rectangle checkbox_rectangle )
+ {
+ dc.FillRectangle( ResPool.GetSolidBrush( checkbox.BackColor ), checkbox.ClientRectangle );
+ // render as per normal button
+ if ( checkbox.appearance == Appearance.Button )
+ {
+ DrawButtonBase( dc, checkbox.ClientRectangle, checkbox );
+ }
+ else
+ {
+ // establish if we are rendering a flat style of some sort
+ if ( checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup )
+ {
+ DrawFlatStyleCheckBox( dc, checkbox_rectangle, checkbox );
+ }
+ else
+ {
+ ControlPaint.DrawCheckBox( dc, checkbox_rectangle, state );
+ }
+ }
+ }
+ #endregion // CheckBox
+
+ #region ComboBox
+
+ // Drawing
+
+ public override void DrawComboBoxEditDecorations( Graphics dc, ComboBox ctrl, Rectangle cl )
+ {
+ if ( !ctrl.Focused )
+ {
+ dc.DrawLine (ResPool.GetPen (BorderColor), cl.X, cl.Y, cl.X + cl.Width, cl.Y); //top
+ dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + 1, cl.Y + 1, cl.X + cl.Width - 2, cl.Y + 1);
+ dc.DrawLine (ResPool.GetPen (BorderColor), cl.X, cl.Y, cl.X, cl.Y + cl.Height); //left
+ dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + 1, cl.Y + 1, cl.X + 1, cl.Y + cl.Height - 2);
+ dc.DrawLine (ResPool.GetPen (BorderColor), cl.X + cl.Width - 1, cl.Y, cl.X + cl.Width - 1, cl.Y + cl.Height); //right
+ dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + cl.Width - 2, cl.Y + 1 , cl.X + cl.Width - 2, cl.Y + cl.Height - 1);
+ dc.DrawLine (ResPool.GetPen (BorderColor), cl.X, cl.Y + cl.Height - 2, cl.X + cl.Width, cl.Y + cl.Height - 2); //down
+ dc.DrawLine (ResPool.GetPen (ColorControl), cl.X, cl.Y + cl.Height - 1, cl.X + cl.Width, cl.Y + cl.Height - 1);
+ }
+ else
+ {
+ dc.DrawLine (ResPool.GetPen (FocusColor), cl.X, cl.Y, cl.X + cl.Width, cl.Y); //top
+ dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + 1, cl.Y + 1, cl.X + cl.Width - 2, cl.Y + 1);
+ dc.DrawLine (ResPool.GetPen (FocusColor), cl.X, cl.Y, cl.X, cl.Y + cl.Height); //left
+ dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + 1, cl.Y + 1, cl.X + 1, cl.Y + cl.Height - 2);
+ dc.DrawLine (ResPool.GetPen (FocusColor), cl.X + cl.Width - 1, cl.Y, cl.X + cl.Width - 1, cl.Y + cl.Height); //right
+ dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + cl.Width - 2, cl.Y + 1 , cl.X + cl.Width - 2, cl.Y + cl.Height - 1);
+ dc.DrawLine (ResPool.GetPen (FocusColor), cl.X, cl.Y + cl.Height - 2, cl.X + cl.Width, cl.Y + cl.Height - 2); //down
+ dc.DrawLine (ResPool.GetPen (FocusColor), cl.X, cl.Y + cl.Height - 1, cl.X + cl.Width, cl.Y + cl.Height - 1);
+ }
+ }
+
+ public override void DrawComboListBoxDecorations( Graphics dc, ComboBox ctrl, Rectangle cl )
+ {
+ if ( ctrl.DropDownStyle == ComboBoxStyle.Simple )
+ {
+ DrawComboBoxEditDecorations( dc, ctrl, cl );
+ }
+ else
+ {
+ dc.DrawRectangle( ResPool.GetPen( ColorWindowFrame ), cl.X, cl.Y, cl.Width - 1, cl.Height - 1 );
+ }
+ }
+ #endregion ComboBox
+
+ #region Menus
+ public override void DrawMenuItem( MenuItem item, DrawItemEventArgs e )
+ {
+ StringFormat string_format;
+ Rectangle rect_text = e.Bounds;
+
+ if ( item.Visible == false )
+ return;
+
+ if ( item.MenuBar )
+ {
+ string_format = string_format_menu_menubar_text;
+ }
+ else
+ {
+ string_format = string_format_menu_text;
+ }
+
+ if ( item.Separator )
+ {
+ e.Graphics.DrawLine( ResPool.GetPen( BorderColor ),
+ e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width, e.Bounds.Y );
+
+ e.Graphics.DrawLine( ResPool.GetPen( Color.White ),
+ e.Bounds.X + 1, e.Bounds.Y + 1, e.Bounds.X + e.Bounds.Width, e.Bounds.Y + 1 );
+
+ return;
+ }
+
+ if ( !item.MenuBar )
+ rect_text.X += MenuCheckSize.Width;
+
+ if ( item.BarBreak )
+ { /* Draw vertical break bar*/
+ Rectangle rect = e.Bounds;
+ rect.Y++;
+ rect.Width = 3;
+ rect.Height = item.MenuHeight - 6;
+
+ e.Graphics.DrawLine( ResPool.GetPen( LightColor ),
+ rect.X, rect.Y , rect.X, rect.Y + rect.Height );
+
+ e.Graphics.DrawLine( ResPool.GetPen( ColorControlLight ),
+ rect.X + 1, rect.Y , rect.X + 1, rect.Y + rect.Height );
+ }
+
+ Color color_text = ColorMenuText;
+ Color color_back;
+
+ /* Draw background */
+ Rectangle rect_back = e.Bounds;
+ rect_back.X++;
+ rect_back.Width -= 2;
+
+ if ( ( e.State & DrawItemState.Selected ) == DrawItemState.Selected )
+ {
+ color_text = ColorMenuText;
+ color_back = NormalColor;
+
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( rect_back.X, rect_back.Y ), new Point( rect_back.Right, rect_back.Y ), Color.White, NormalColor ) )//NormalColor, Color.White ) )
+ {
+ e.Graphics.FillRectangle( lgbr, rect_back );
+ }
+
+ rect_back.Height--;
+ e.Graphics.DrawRectangle( ResPool.GetPen( BorderColor ), rect_back );
+ }
+ else
+ {
+ color_text = ColorMenuText;
+ color_back = NiceBackColor;
+
+ e.Graphics.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), rect_back );
+ }
+
+ if ( item.Enabled )
+ {
+ e.Graphics.DrawString( item.Text, e.Font,
+ ResPool.GetSolidBrush( color_text ),
+ rect_text, string_format );
+
+ if ( !item.MenuBar && item.Shortcut != Shortcut.None && item.ShowShortcut )
+ {
+ string str = item.GetShortCutText( );
+ Rectangle rect = rect_text;
+ rect.X = item.XTab;
+ rect.Width -= item.XTab;
+
+ e.Graphics.DrawString( str, e.Font, ResPool.GetSolidBrush( color_text ),
+ rect, string_format_menu_shortcut );
+ }
+ }
+ else
+ {
+ ControlPaint.DrawStringDisabled( e.Graphics, item.Text, e.Font,
+ Color.Black, rect_text, string_format );
+ }
+
+ /* Draw arrow */
+ if ( item.MenuBar == false && item.IsPopup )
+ {
+ int cx = MenuCheckSize.Width;
+ int cy = MenuCheckSize.Height;
+ using ( Bitmap bmp = new Bitmap( cx, cy ) )
+ {
+ using ( Graphics dc = Graphics.FromImage( bmp ) )
+ {
+ SmoothingMode old_smoothing_mode = dc.SmoothingMode;
+ dc.SmoothingMode = SmoothingMode.AntiAlias;
+
+ Rectangle rect_arrow = new Rectangle( 0, 0, cx, cy );
+ ControlPaint.DrawMenuGlyph( dc, rect_arrow, MenuGlyph.Arrow );
+ bmp.MakeTransparent( );
+
+ if ( item.Enabled )
+ {
+ e.Graphics.DrawImage( bmp, e.Bounds.X + e.Bounds.Width - cx,
+ e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ) );
+ }
+ else
+ {
+ ControlPaint.DrawImageDisabled( e.Graphics, bmp, e.Bounds.X + e.Bounds.Width - cx,
+ e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ), color_back );
+ }
+
+ dc.SmoothingMode = old_smoothing_mode;
+ }
+ }
+ }
+
+ /* Draw checked or radio */
+ if ( item.MenuBar == false && item.Checked )
+ {
+
+ Rectangle area = e.Bounds;
+ int cx = MenuCheckSize.Width;
+ int cy = MenuCheckSize.Height;
+ using ( Bitmap bmp = new Bitmap( cx, cy ) )
+ {
+ using ( Graphics gr = Graphics.FromImage( bmp ) )
+ {
+ Rectangle rect_arrow = new Rectangle( 0, 0, cx, cy );
+
+ if ( item.RadioCheck )
+ ControlPaint.DrawMenuGlyph( gr, rect_arrow, MenuGlyph.Bullet );
+ else
+ ControlPaint.DrawMenuGlyph( gr, rect_arrow, MenuGlyph.Checkmark );
+
+ bmp.MakeTransparent( );
+ e.Graphics.DrawImage( bmp, area.X, e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ) );
+ }
+ }
+ }
+ }
+
+ public override void DrawPopupMenu (Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect)
+ {
+
+ dc.FillRectangle (ResPool.GetSolidBrush
+ (NiceBackColor), cliparea);
+
+ /* Draw menu borders */
+ dc.DrawLine (ResPool.GetPen (ColorHighlightText),
+ rect.X, rect.Y, rect.X + rect.Width, rect.Y);
+
+ dc.DrawLine (ResPool.GetPen (ColorHighlightText),
+ rect.X, rect.Y, rect.X, rect.Y + rect.Height);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDark),
+ rect.X + rect.Width - 1 , rect.Y , rect.X + rect.Width - 1, rect.Y + rect.Height);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark),
+ rect.X + rect.Width, rect.Y , rect.X + rect.Width, rect.Y + rect.Height);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDark),
+ rect.X , rect.Y + rect.Height - 1 , rect.X + rect.Width - 1, rect.Y + rect.Height -1);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark),
+ rect.X , rect.Y + rect.Height, rect.X + rect.Width - 1, rect.Y + rect.Height);
+
+ for (int i = 0; i < menu.MenuItems.Count; i++)
+ if (cliparea.IntersectsWith (menu.MenuItems [i].bounds)) {
+ MenuItem item = menu.MenuItems [i];
+ item.MenuHeight = menu.Height;
+ item.PerformDrawItem (new DrawItemEventArgs (dc, MenuFont,
+ item.bounds, i, item.Status));
+ }
+ }
+ #endregion // Menus
+
+ #region ProgressBar
+ public override void DrawProgressBar( Graphics dc, Rectangle clip_rect, ProgressBar ctrl )
+ {
+ Rectangle client_area = ctrl.client_area;
+ int barpos_pixels;
+ Rectangle bar = ctrl.client_area;
+
+ barpos_pixels = ( ( ctrl.Value - ctrl.Minimum ) * client_area.Width ) / ( ctrl.Maximum - ctrl.Minimum );
+
+ bar.Width = barpos_pixels;
+// bar.Height += 1;
+
+ // Draw bar background
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( client_area.Left, client_area.Top ), new Point( client_area.Left, client_area.Bottom ), LightColor, Color.White ) )
+ {
+ dc.FillRectangle( lgbr, client_area );
+ }
+
+ // Draw bar
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( bar.Location, new Point( bar.X, bar.Bottom ), Color.White, FocusColor ) )
+ {
+ dc.FillRectangle( lgbr, bar );
+ }
+
+ /* Draw border */
+ dc.DrawRectangle( ResPool.GetPen( BorderColor ), ctrl.ClientRectangle.X, ctrl.ClientRectangle.Y, ctrl.ClientRectangle.Width - 1, ctrl.ClientRectangle.Height - 1 );
+ dc.DrawRectangle( ResPool.GetPen( LightColor ), ctrl.ClientRectangle.X + 1, ctrl.ClientRectangle.Y + 1, ctrl.ClientRectangle.Width - 2, ctrl.ClientRectangle.Height - 2 );
+ }
+ #endregion // ProgressBar
+
+ #region RadioButton
+ protected override void RadioButton_DrawButton( RadioButton radio_button, Graphics dc, ButtonState state, Rectangle radiobutton_rectangle )
+ {
+ SolidBrush sb = new SolidBrush( radio_button.BackColor );
+ dc.FillRectangle( sb, radio_button.ClientRectangle );
+ sb.Dispose( );
+
+ if (radio_button.appearance==Appearance.Button) {
+ if (radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup) {
+ DrawFlatStyleButton(dc, radio_button.ClientRectangle, radio_button);
+ } else {
+ DrawButtonBase( dc, radio_button.ClientRectangle, radio_button );
+ }
+ } else {
+ // establish if we are rendering a flat style of some sort
+ if ( radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup ) {
+ DrawFlatStyleRadioButton (dc, radiobutton_rectangle, radio_button);
+ } else {
+ ControlPaint.DrawRadioButton( dc, radiobutton_rectangle, state );
+ }
+ }
+ }
+
+ protected override void RadioButton_DrawFocus(RadioButton radio_button, Graphics dc, Rectangle text_rectangle)
+ {
+ if (radio_button.Focused && radio_button.appearance != Appearance.Button)
+ {
+ if (radio_button.FlatStyle != FlatStyle.Flat && radio_button.FlatStyle != FlatStyle.Popup)
+ {
+ DrawInnerFocusRectangle (dc, text_rectangle, radio_button.BackColor);
+ }
+ }
+ }
+ #endregion // RadioButton
+
+ #region ScrollBar
+ protected override void ScrollBar_DrawThumb( ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
+ {
+ if ( bar.Enabled && thumb_pos.Width > 0 && thumb_pos.Height > 0 && clip.IntersectsWith( thumb_pos ) )
+ DrawScrollBarThumb( dc, thumb_pos, bar );
+ }
+
+ protected override void ScrollBar_Vertical_Draw_ThumbMoving_None( int scrollbutton_height, ScrollBar bar, Rectangle clip, Graphics dc )
+ {
+ Rectangle r = new Rectangle( 0,
+ scrollbutton_height, bar.ClientRectangle.Width, bar.ClientRectangle.Height - ( scrollbutton_height * 2 ) );
+ Rectangle intersect = Rectangle.Intersect( clip, r );
+
+ if ( intersect != Rectangle.Empty )
+ {
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( r. Width - 1, 0 ), LightColor, Color.White ) )
+ {
+ dc.FillRectangle( lgbr, intersect );
+ }
+ }
+ }
+
+ protected override void ScrollBar_Vertical_Draw_ThumbMoving_Forward( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
+ {
+ Rectangle r = new Rectangle( 0, scrollbutton_height,
+ bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
+ Rectangle intersect = Rectangle.Intersect( clip, r );
+
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( r. Width - 1, 0 ), LightColor, Color.White ) )
+ {
+ if ( intersect != Rectangle.Empty )
+ dc.FillRectangle( lgbr, intersect );
+
+ r.X = 0;
+ r.Y = thumb_pos.Y + thumb_pos.Height;
+ r.Width = bar.ClientRectangle.Width;
+ r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
+
+ intersect = Rectangle.Intersect( clip, r );
+ if ( intersect != Rectangle.Empty )
+ dc.FillRectangle( lgbr, intersect );
+ }
+ }
+
+ protected override void ScrollBar_Vertical_Draw_ThumbMoving_Backwards( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
+ {
+ Rectangle r = new Rectangle( 0, scrollbutton_height,
+ bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
+ Rectangle intersect = Rectangle.Intersect( clip, r );
+
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( r. Width - 1, 0 ), LightColor, Color.White ) )
+ {
+ if ( intersect != Rectangle.Empty )
+ dc.FillRectangle( lgbr, intersect );
+
+ r.X = 0;
+ r.Y = thumb_pos.Y + thumb_pos.Height;
+ r.Width = bar.ClientRectangle.Width;
+ r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
+
+ intersect = Rectangle.Intersect( clip, r );
+ if ( intersect != Rectangle.Empty )
+ dc.FillRectangle( lgbr, intersect );
+ }
+ }
+
+ protected override void ScrollBar_Horizontal_Draw_ThumbMoving_None( int scrollbutton_width, ScrollBar bar, Rectangle clip, Graphics dc )
+ {
+ Rectangle r = new Rectangle( scrollbutton_width,
+ 0, bar.ClientRectangle.Width - ( scrollbutton_width * 2 ), bar.ClientRectangle.Height );
+ Rectangle intersect = Rectangle.Intersect( clip, r );
+
+ if ( intersect != Rectangle.Empty )
+ {
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, r.Height - 1 ), LightColor, Color.White ) )
+ {
+ dc.FillRectangle( lgbr, intersect );
+ }
+ }
+ }
+
+ protected override void ScrollBar_Horizontal_Draw_ThumbMoving_Forward( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
+ {
+ Rectangle r = new Rectangle( scrollbutton_width, 0,
+ thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
+ Rectangle intersect = Rectangle.Intersect( clip, r );
+
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, r.Height - 1 ), LightColor, Color.White ) )
+ {
+ if ( intersect != Rectangle.Empty )
+ dc.FillRectangle( lgbr, intersect );
+
+ r.X = thumb_pos.X + thumb_pos.Width;
+ r.Y = 0;
+ r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
+ r.Height = bar.ClientRectangle.Height;
+
+ intersect = Rectangle.Intersect( clip, r );
+ if ( intersect != Rectangle.Empty )
+ dc.FillRectangle( lgbr, intersect );
+ }
+ }
+
+ protected override void ScrollBar_Horizontal_Draw_ThumbMoving_Backwards( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
+ {
+ Rectangle r = new Rectangle( scrollbutton_width, 0,
+ thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
+ Rectangle intersect = Rectangle.Intersect( clip, r );
+
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, r.Height - 1 ), LightColor, Color.White ) )
+ {
+ if ( intersect != Rectangle.Empty )
+ dc.FillRectangle( lgbr, intersect );
+
+ r.X = thumb_pos.X + thumb_pos.Width;
+ r.Y = 0;
+ r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
+ r.Height = bar.ClientRectangle.Height;
+
+ intersect = Rectangle.Intersect( clip, r );
+ if ( intersect != Rectangle.Empty )
+ dc.FillRectangle( lgbr, intersect );
+ }
+ }
+ #endregion // ScrollBar
+
+ #region StatusBar
+ protected override void DrawStatusBarPanel( Graphics dc, Rectangle area, int index,
+ SolidBrush br_forecolor, StatusBarPanel panel )
+ {
+ int border_size = 3; // this is actually const, even if the border style is none
+
+ area.Height -= border_size;
+ if ( panel.BorderStyle != StatusBarPanelBorderStyle.None )
+ {
+ DrawNiceRoundedBorder( dc, area, BorderColor );
+ }
+
+ if ( panel.Style == StatusBarPanelStyle.OwnerDraw )
+ {
+ StatusBarDrawItemEventArgs e = new StatusBarDrawItemEventArgs(
+ dc, panel.Parent.Font, area, index, DrawItemState.Default,
+ panel, panel.Parent.ForeColor, panel.Parent.BackColor );
+ panel.Parent.OnDrawItemInternal( e );
+ return;
+ }
+
+ int left = area.Left;
+ if ( panel.Icon != null )
+ {
+ left += 2;
+ dc.DrawIcon( panel.Icon, left, area.Top );
+ left += panel.Icon.Width;
+ }
+
+ if ( panel.Text == String.Empty )
+ return;
+
+ string text = panel.Text;
+ StringFormat string_format = new StringFormat( );
+ string_format.Trimming = StringTrimming.Character;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+
+ if ( text[ 0 ] == '\t' )
+ {
+ string_format.Alignment = StringAlignment.Center;
+ text = text.Substring( 1 );
+ if ( text[ 0 ] == '\t' )
+ {
+ string_format.Alignment = StringAlignment.Far;
+ text = text.Substring( 1 );
+ }
+ }
+
+ int x = left + border_size;
+ int y = border_size + 2;
+ Rectangle r = new Rectangle( x, y,
+ area.Right - x - border_size,
+ area.Bottom - y - border_size );
+
+ dc.DrawString( text, panel.Parent.Font, br_forecolor, r, string_format );
+ }
+
+ private void DrawNiceRoundedBorder( Graphics dc, Rectangle area, Color color )
+ {
+ Pen pen = ResPool.GetPen( color );
+
+ Point[] points = new Point[] {
+ new Point( area.Left + 2, area.Top ),
+ new Point( area.Right - 2, area.Top ),
+ new Point( area.Right, area.Top + 2 ),
+ new Point( area.Right, area.Bottom - 2 ),
+ new Point( area.Right - 2, area.Bottom ),
+ new Point( area.Left + 2, area.Bottom ),
+ new Point( area.Left, area.Bottom - 2 ),
+ new Point( area.Left, area.Top + 2 ),
+ new Point( area.Left + 2, area.Top )
+ };
+
+ dc.DrawLines( pen, points );
+ }
+ #endregion // StatusBar
+
+ public override void DrawTabControl( Graphics dc, Rectangle area, TabControl tab )
+ {
+ // Do we need to fill the back color? It can't be changed...
+ dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), area );
+ Rectangle panel_rect = GetTabPanelRectExt( tab );
+
+ if ( tab.Appearance == TabAppearance.Normal )
+ {
+ CPDrawBorder( dc, panel_rect, BorderColor, 1, ButtonBorderStyle.Solid, BorderColor, 1, ButtonBorderStyle.Solid,
+ BorderColor, 1, ButtonBorderStyle.Solid, BorderColor, 1, ButtonBorderStyle.Solid );
+ }
+
+ if ( tab.Alignment == TabAlignment.Top )
+ {
+ for ( int r = tab.TabPages.Count; r > 0; r-- )
+ {
+ for ( int i = tab.SliderPos; i < tab.TabPages.Count; i++ )
+ {
+ if ( i == tab.SelectedIndex )
+ continue;
+ if ( r != tab.TabPages[ i ].Row )
+ continue;
+ Rectangle rect = tab.GetTabRect( i );
+ if ( !rect.IntersectsWith( area ) )
+ continue;
+ DrawTab( dc, tab.TabPages[ i ], tab, rect, false );
+ }
+ }
+ }
+ else
+ {
+ for ( int r = 0; r < tab.TabPages.Count; r++ )
+ {
+ for ( int i = tab.SliderPos; i < tab.TabPages.Count; i++ )
+ {
+ if ( i == tab.SelectedIndex )
+ continue;
+ if ( r != tab.TabPages[ i ].Row )
+ continue;
+ Rectangle rect = tab.GetTabRect( i );
+ if ( !rect.IntersectsWith( area ) )
+ continue;
+ DrawTab( dc, tab.TabPages[ i ], tab, rect, false );
+ }
+ }
+ }
+
+ if ( tab.SelectedIndex != -1 && tab.SelectedIndex >= tab.SliderPos )
+ {
+ Rectangle rect = tab.GetTabRect( tab.SelectedIndex );
+ if ( rect.IntersectsWith( area ) )
+ DrawTab( dc, tab.TabPages[ tab.SelectedIndex ], tab, rect, true );
+ }
+
+ if ( tab.ShowSlider )
+ {
+ Rectangle right = GetTabControlRightScrollRect( tab );
+ Rectangle left = GetTabControlLeftScrollRect( tab );
+ CPDrawScrollButton( dc, right, ScrollButton.Right, tab.RightSliderState );
+ CPDrawScrollButton( dc, left, ScrollButton.Left, tab.LeftSliderState );
+ }
+ }
+
+ protected override int DrawTab( Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected )
+ {
+ int FlatButtonSpacing = 8;
+ Rectangle interior;
+ int res = bounds.Width;
+
+ // we can't fill the background right away because the bounds might be adjusted if the tab is selected
+
+ if ( tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons )
+ {
+ dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), bounds );
+
+ // Separators
+ if ( tab.Appearance == TabAppearance.FlatButtons )
+ {
+ int width = bounds.Width;
+ bounds.Width += ( FlatButtonSpacing - 2 );
+ res = bounds.Width;
+ CPDrawBorder3D( dc, bounds, Border3DStyle.Etched, Border3DSide.Right );
+ bounds.Width = width;
+ }
+
+ if ( is_selected )
+ {
+ CPDrawBorder3D( dc, bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
+ }
+ else if ( tab.Appearance != TabAppearance.FlatButtons )
+ {
+ CPDrawBorder3D( dc, bounds, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
+ }
+
+ interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4 );
+
+
+ StringFormat string_format = new StringFormat( );
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+
+ interior.Y++;
+ dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
+ interior.Y--;
+ }
+ else
+ {
+ Pen border_pen = ResPool.GetPen( BorderColor );
+
+ dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), bounds );
+
+ switch ( tab.Alignment )
+ {
+ case TabAlignment.Top:
+
+ if ( !is_selected )
+ {
+ interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
+
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2 ), new Point( bounds.Left + 2, bounds.Bottom ), Color.White, LightColor ) )
+ {
+ dc.FillRectangle( lgbr, interior );
+ }
+ }
+
+ dc.DrawLine( border_pen, bounds.Left, bounds.Bottom, bounds.Left, bounds.Top + 3 );
+ dc.DrawLine( border_pen, bounds.Left, bounds.Top + 3, bounds.Left + 3, bounds.Top );
+ dc.DrawLine( border_pen, bounds.Left + 3, bounds.Top, bounds.Right - 3, bounds.Top );
+ dc.DrawLine( border_pen, bounds.Right - 3, bounds.Top, bounds.Right, bounds.Top + 3 );
+ dc.DrawLine( border_pen, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom );
+
+ if ( page.Focused )
+ {
+ dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Left - 1 , bounds.Top, bounds.Right - 1, bounds.Top );
+ dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Top + 1, bounds.Right , bounds.Top + 1 );
+ dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Top + 2, bounds.Right , bounds.Top + 2 );
+ }
+
+ interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
+
+ if ( page.Text != String.Empty )
+ {
+ StringFormat string_format = new StringFormat( );
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+ interior.Y++;
+ dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
+ interior.Y--;
+ }
+
+ break;
+
+ case TabAlignment.Bottom:
+
+ if ( !is_selected )
+ {
+ interior = new Rectangle( bounds.Left + 3, bounds.Top, bounds.Width - 3, bounds.Height );
+
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 3, bounds.Top ), new Point( bounds.Left + 3, bounds.Bottom ), Color.White, LightColor ) )
+ {
+ dc.FillRectangle( lgbr, interior );
+ }
+ }
+
+ dc.DrawLine( border_pen, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom - 3 );
+ dc.DrawLine( border_pen, bounds.Left, bounds.Bottom - 3, bounds.Left + 3, bounds.Bottom );
+ dc.DrawLine( border_pen, bounds.Left + 3, bounds.Bottom, bounds.Right - 3, bounds.Bottom );
+ dc.DrawLine( border_pen, bounds.Right - 3, bounds.Bottom, bounds.Right, bounds.Bottom - 3 );
+ dc.DrawLine( border_pen, bounds.Right, bounds.Bottom - 3, bounds.Right, bounds.Top );
+
+ if ( page.Focused )
+ {
+ dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Left - 1 , bounds.Bottom, bounds.Right - 1, bounds.Bottom );
+ dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Bottom - 1, bounds.Right , bounds.Bottom - 1 );
+ dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Bottom - 2, bounds.Right , bounds.Bottom - 2 );
+ }
+
+ interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
+
+ if ( page.Text != String.Empty )
+ {
+ StringFormat string_format = new StringFormat( );
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+ interior.Y++;
+ dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
+ interior.Y--;
+ }
+
+ break;
+
+ case TabAlignment.Left:
+
+ if ( !is_selected )
+ {
+ interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
+
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2 ), new Point( bounds.Right, bounds.Top + 2 ), LightColor, Color.White ) )
+ {
+ dc.FillRectangle( lgbr, interior );
+ }
+ }
+
+ dc.DrawLine( border_pen, bounds.Right, bounds.Top, bounds.Left + 3, bounds.Top );
+ dc.DrawLine( border_pen, bounds.Left + 3, bounds.Top, bounds.Left, bounds.Top + 3 );
+ dc.DrawLine( border_pen, bounds.Left, bounds.Top + 3, bounds.Left, bounds.Bottom - 3 );
+ dc.DrawLine( border_pen, bounds.Left, bounds.Bottom - 3, bounds.Left + 3, bounds.Bottom );
+ dc.DrawLine( border_pen, bounds.Left + 3, bounds.Bottom, bounds.Right, bounds.Bottom );
+
+ if ( page.Focused )
+ {
+ dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Left , bounds.Top + 1, bounds.Left , bounds.Bottom - 1 );
+ dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left + 1 , bounds.Top, bounds.Left + 1 , bounds.Bottom );
+ dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left + 2 , bounds.Top, bounds.Left + 2 , bounds.Bottom );
+ }
+
+ interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
+
+ if ( page.Text != String.Empty )
+ {
+ StringFormat string_format = new StringFormat( );
+ // Flip the text around
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+ string_format.FormatFlags = StringFormatFlags.DirectionVertical;
+ int wo = interior.Width / 2;
+ int ho = interior.Height / 2;
+ dc.TranslateTransform( interior.X + wo, interior.Y + ho );
+ dc.RotateTransform( 180 );
+ dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), 0, 0, string_format );
+ dc.ResetTransform( );
+ }
+
+ break;
+
+ default:
+ // TabAlignment.Right
+
+ if ( !is_selected )
+ {
+ interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
+
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2 ), new Point( bounds.Right, bounds.Top + 2 ), Color.White, LightColor ) )
+ {
+ dc.FillRectangle( lgbr, interior );
+ }
+ }
+
+ dc.DrawLine( border_pen, bounds.Left, bounds.Top, bounds.Right - 3, bounds.Top );
+ dc.DrawLine( border_pen, bounds.Right - 3, bounds.Top, bounds.Right, bounds.Top + 3 );
+ dc.DrawLine( border_pen, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom - 3 );
+ dc.DrawLine( border_pen, bounds.Right, bounds.Bottom - 3, bounds.Right - 3, bounds.Bottom );
+ dc.DrawLine( border_pen, bounds.Right - 3, bounds.Bottom, bounds.Left, bounds.Bottom );
+
+ if ( page.Focused )
+ {
+ dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Right , bounds.Top + 1, bounds.Right , bounds.Bottom - 1 );
+ dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Right - 1 , bounds.Top, bounds.Right - 1 , bounds.Bottom );
+ dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Right - 2 , bounds.Top, bounds.Right - 2 , bounds.Bottom );
+ }
+
+ interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
+
+ if ( page.Text != String.Empty )
+ {
+ StringFormat string_format = new StringFormat( );
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+ string_format.FormatFlags = StringFormatFlags.DirectionVertical;
+ interior.X++;
+ dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
+ interior.X--;
+ }
+
+ break;
+ }
+ }
+
+ return res;
+ }
+
+ public override void CPDrawComboButton( Graphics dc, Rectangle rectangle, ButtonState state )
+ {
+ Point[] arrow = new Point[ 3 ];
+ Point P1;
+ Point P2;
+ Point P3;
+ int centerX;
+ int centerY;
+ int shiftX;
+ int shiftY;
+ Rectangle rect;
+
+ Color first_color = Color.White;
+ Color second_color = NormalColor;
+
+// rectangle.Width += 1;
+
+ if ( ( state & ButtonState.Checked ) != 0 )
+ {
+ dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorControlLightLight, ColorControlLight ), rectangle );
+ }
+ else
+ dc.FillRectangle( ResPool.GetSolidBrush( Color.White ), rectangle );
+
+ if ( ( state & ButtonState.Flat ) != 0 )
+ {
+ first_color = NormalColor;
+ second_color = Color.White;
+ }
+ else
+ {
+ if ( ( state & ( ButtonState.Pushed | ButtonState.Checked ) ) != 0 )
+ {
+ first_color = Color.White;
+ second_color = PressedColor;
+ }
+// else
+// {
+// CPDrawBorder3D( graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl );
+// }
+ }
+
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( rectangle.X + 1, rectangle.Y + 1 ), new Point( rectangle.X + 1, rectangle.Bottom - 2 ), first_color, second_color ) )
+ {
+ dc.FillRectangle( lgbr, rectangle.X + 2, rectangle.Y + 1, rectangle.Width - 4, rectangle.Height - 3 );
+ }
+
+ Point[] points = new Point[] {
+ new Point( rectangle.X + 3, rectangle.Y + 1 ),
+ new Point( rectangle.Right - 4, rectangle.Y + 1 ),
+ new Point( rectangle.Right - 2, rectangle.Y + 3 ),
+ new Point( rectangle.Right - 2, rectangle.Bottom - 4 ),
+ new Point( rectangle.Right - 4, rectangle.Bottom - 2 ),
+ new Point( rectangle.X + 3, rectangle.Bottom - 2 ),
+ new Point( rectangle.X + 1, rectangle.Bottom - 4 ),
+ new Point( rectangle.X + 1, rectangle.Y + 3 ),
+ new Point( rectangle.X + 3, rectangle.Y + 1 )
+ };
+
+ dc.DrawPolygon( ResPool.GetPen( BorderColor ), points );
+
+ rect = new Rectangle( rectangle.X + rectangle.Width / 4, rectangle.Y + rectangle.Height / 4, rectangle.Width / 2, rectangle.Height / 2 );
+ centerX = rect.Left + rect.Width / 2;
+ centerY = rect.Top + rect.Height / 2;
+ shiftX = Math.Max( 1, rect.Width / 8 );
+ shiftY = Math.Max( 1, rect.Height / 8 );
+
+ if ( ( state & ButtonState.Pushed ) != 0 )
+ {
+ shiftX--;
+ shiftY--;
+ }
+
+ rect.Y -= shiftY;
+ centerY -= shiftY;
+
+ P1 = new Point( rect.Left, centerY );
+ P2 = new Point( centerX, rect.Bottom );
+ P3 = new Point( rect.Right, centerY );
+
+ arrow[ 0 ] = P1;
+ arrow[ 1 ] = P2;
+ arrow[ 2 ] = P3;
+
+ SmoothingMode old_smoothing_mode = dc.SmoothingMode;
+ dc.SmoothingMode = SmoothingMode.AntiAlias;
+
+ /* Draw the arrow */
+ if ( ( state & ButtonState.Inactive ) != 0 )
+ {
+ using ( Pen pen = new Pen( SystemColors.ControlLightLight, 2 ) )
+ {
+ dc.DrawLines( pen, arrow );
+ }
+
+ /* Move away from the shadow */
+ P1.X -= 1; P1.Y -= 1;
+ P2.X -= 1; P2.Y -= 1;
+ P3.X -= 1; P3.Y -= 1;
+
+ arrow[ 0 ] = P1;
+ arrow[ 1 ] = P2;
+ arrow[ 2 ] = P3;
+
+ using ( Pen pen = new Pen( SystemColors.ControlDark, 2 ) )
+ {
+ dc.DrawLines( pen, arrow );
+ }
+ }
+ else
+ {
+ using ( Pen pen = new Pen( SystemColors.ControlText, 2 ) )
+ {
+ dc.DrawLines( pen, arrow );
+ }
+ }
+
+ dc.SmoothingMode = old_smoothing_mode;
+ }
+
+ /* Scroll button: regular button + direction arrow */
+ public override void CPDrawScrollButton( Graphics dc, Rectangle area, ScrollButton scroll_button_type, ButtonState state )
+ {
+ bool enabled = ( state == ButtonState.Inactive ) ? false: true;
+
+ DrawScrollButtonPrimitive( dc, area, state, scroll_button_type );
+
+ if ( area.Width < 12 || area.Height < 12 ) /* Cannot see a thing at smaller sizes */
+ return;
+
+ Pen pen = null;
+
+ if ( enabled )
+ pen = new Pen( arrow_color, 2 );
+ else
+ pen = new Pen( ColorGrayText, 2 );
+
+ /* Paint arrows */
+
+ int centerX = area.Left + area.Width / 2;
+ int centerY = area.Top + area.Height / 2;
+
+ int shift = 0;
+
+ if ( ( state & ButtonState.Pushed ) != 0 )
+ shift = 1;
+
+ Point[] arrow = new Point[ 3 ];
+
+ switch ( scroll_button_type )
+ {
+ case ScrollButton.Down:
+ centerY += shift;
+ arrow[ 0 ] = new Point( centerX - 3, centerY - 2 );
+ arrow[ 1 ] = new Point( centerX, centerY + 2 );
+ arrow[ 2 ] = new Point( centerX + 3, centerY - 2 );
+ break;
+ case ScrollButton.Up:
+ centerY -= shift;
+ arrow[ 0 ] = new Point( centerX - 3, centerY + 2 );
+ arrow[ 1 ] = new Point( centerX, centerY - 2 );
+ arrow[ 2 ] = new Point( centerX + 3, centerY + 2 );
+ break;
+ case ScrollButton.Left:
+ centerX -= shift;
+ arrow[ 0 ] = new Point( centerX + 2, centerY - 3 );
+ arrow[ 1 ] = new Point( centerX - 2, centerY );
+ arrow[ 2 ] = new Point( centerX + 2, centerY + 3 );
+ break;
+ case ScrollButton.Right:
+ centerX += shift;
+ arrow[ 0 ] = new Point( centerX - 2, centerY - 3 );
+ arrow[ 1 ] = new Point( centerX + 2, centerY );
+ arrow[ 2 ] = new Point( centerX - 2, centerY + 3 );
+ break;
+ default:
+ break;
+ }
+
+ SmoothingMode old_smoothing_mode = dc.SmoothingMode;
+ dc.SmoothingMode = SmoothingMode.AntiAlias;
+
+ dc.DrawLines( pen, arrow );
+
+ dc.SmoothingMode = old_smoothing_mode;
+
+ pen.Dispose( );
+ }
+
+ public override void CPDrawSizeGrip( Graphics dc, Color backColor, Rectangle bounds )
+ {
+ Point pt = new Point( bounds.Right - 4, bounds.Bottom - 4 );
+
+ dc.DrawImage( size_grip_bmp, pt );
+ dc.DrawImage( size_grip_bmp, pt.X, pt.Y - 5 );
+ dc.DrawImage( size_grip_bmp, pt.X, pt.Y - 10 );
+ dc.DrawImage( size_grip_bmp, pt.X - 5, pt.Y );
+ dc.DrawImage( size_grip_bmp, pt.X - 10, pt.Y );
+ dc.DrawImage( size_grip_bmp, pt.X - 5, pt.Y - 5 );
+ }
+
+ private void DrawScrollBarThumb( Graphics dc, Rectangle area, ScrollBar bar )
+ {
+ LinearGradientBrush lgbr = null;
+
+ if ( bar.vert )
+ lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right, area.Y ), Color.White, NormalColor );
+ else
+ lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom ), Color.White, NormalColor );
+
+ Pen pen = ResPool.GetPen( BorderColor );
+
+ Point[] points = new Point[] {
+ new Point( area.X + 2, area.Y ),
+ new Point( area.Right - 3, area.Y ),
+ new Point( area.Right - 1, area.Y + 2 ),
+ new Point( area.Right - 1, area.Bottom - 3 ),
+ new Point( area.Right - 3, area.Bottom - 1 ),
+ new Point( area.X + 2, area.Bottom - 1 ),
+ new Point( area.X, area.Bottom - 3 ),
+ new Point( area.X, area.Y + 2 ),
+ new Point( area.X + 2, area.Y )
+ };
+
+ if ( bar.vert )
+ {
+ dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
+ dc.DrawPolygon( pen, points );
+
+ // draw grip lines only if stere is enough space
+ if ( area.Height > 20 )
+ {
+ int mid_y = area.Y + ( area.Height / 2 );
+ int mid_x = area.X + ( area.Width / 2 );
+
+ using ( Pen lpen = new Pen( MouseOverColor, 2 ) )
+ {
+ dc.DrawLine( lpen, mid_x - 3, mid_y, mid_x + 3, mid_y );
+ dc.DrawLine( lpen, mid_x - 3, mid_y - 4, mid_x + 3, mid_y - 4 );
+ dc.DrawLine( lpen, mid_x - 3, mid_y + 4, mid_x + 3, mid_y + 4 );
+ }
+
+ Pen spen = ResPool.GetPen( Color.White );
+ dc.DrawLine( spen, mid_x - 3, mid_y - 1, mid_x + 3, mid_y - 1 );
+ dc.DrawLine( spen, mid_x - 3, mid_y - 5, mid_x + 3, mid_y - 5 );
+ dc.DrawLine( spen, mid_x - 3, mid_y + 3, mid_x + 3, mid_y + 3 );
+ }
+ }
+ else
+ {
+ dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
+ dc.DrawPolygon( pen, points );
+
+ // draw grip lines only if stere is enough space
+ if ( area.Width > 20 )
+ {
+ int mid_x = area.X + ( area.Width / 2 );
+ int mid_y = area.Y + ( area.Height / 2 );
+
+ using ( Pen lpen = new Pen( MouseOverColor, 2 ) )
+ {
+ dc.DrawLine( lpen, mid_x, mid_y - 3, mid_x, mid_y + 3 );
+ dc.DrawLine( lpen, mid_x - 4, mid_y - 3, mid_x - 4, mid_y + 3 );
+ dc.DrawLine( lpen, mid_x + 4, mid_y - 3, mid_x + 4, mid_y + 3 );
+ }
+
+ Pen spen = ResPool.GetPen( Color.White );
+ dc.DrawLine( spen, mid_x - 1, mid_y - 3, mid_x - 1, mid_y + 3 );
+ dc.DrawLine( spen, mid_x - 5, mid_y - 3, mid_x - 5, mid_y + 3 );
+ dc.DrawLine( spen, mid_x + 3, mid_y - 3, mid_x + 3, mid_y + 3 );
+ }
+ }
+
+ lgbr.Dispose( );
+ }
+
+ /* Nice scroll button */
+ public void DrawScrollButtonPrimitive( Graphics dc, Rectangle area, ButtonState state, ScrollButton scroll_button_type )
+ {
+ Pen pen = ResPool.GetPen( BorderColor );
+
+ dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), area );
+
+ Color use_color;
+
+ if ( ( state & ButtonState.Pushed ) == ButtonState.Pushed )
+ use_color = PressedColor;
+ else
+ use_color = NormalColor;
+
+ Point[] points = null;
+
+ LinearGradientBrush lgbr = null;
+
+ switch ( scroll_button_type )
+ {
+ case ScrollButton.Left:
+ lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right - 2, area.Y ), use_color, Color.White );
+ dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 4, area.Height - 2 );
+
+ points = new Point[] {
+ new Point( area.X + 2, area.Y ),
+ new Point( area.Right - 1, area.Y ),
+ new Point( area.Right - 1, area.Bottom - 1 ),
+ new Point( area.X + 2, area.Bottom - 1 ),
+ new Point( area.X, area.Bottom - 3 ),
+ new Point( area.X, area.Y + 2 ),
+ new Point( area.X + 2, area.Y )
+ };
+ dc.DrawPolygon( pen, points );
+ break;
+ case ScrollButton.Right:
+ lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right - 1, area.Y ), Color.White, use_color );
+ dc.FillRectangle( lgbr, area.X, area.Y + 1, area.Width - 1, area.Height - 2 );
+
+ points = new Point[] {
+ new Point( area.X, area.Y ),
+ new Point( area.Right - 3, area.Y ),
+ new Point( area.Right - 1, area.Y + 2 ),
+ new Point( area.Right - 1, area.Bottom - 3 ),
+ new Point( area.Right - 3, area.Bottom - 1 ),
+ new Point( area.X, area.Bottom - 1 ),
+ new Point( area.X, area.Y ),
+ };
+ dc.DrawPolygon( pen, points );
+ break;
+ case ScrollButton.Up:
+ lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom - 1 ), use_color, Color.White );
+ dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
+
+ points = new Point[] {
+ new Point( area.X + 2, area.Y ),
+ new Point( area.Right - 3, area.Y ),
+ new Point( area.Right - 1, area.Y + 2 ),
+ new Point( area.Right - 1, area.Bottom - 1 ),
+ new Point( area.X, area.Bottom - 1 ),
+ new Point( area.X, area.Y + 2 ),
+ new Point( area.X + 2, area.Y )
+ };
+ dc.DrawPolygon( pen, points );
+ break;
+ case ScrollButton.Down:
+ lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom - 1 ), Color.White, use_color );
+ dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
+
+ points = new Point[] {
+ new Point( area.X, area.Y ),
+ new Point( area.Right - 1, area.Y ),
+ new Point( area.Right - 1, area.Bottom - 3 ),
+ new Point( area.Right - 3, area.Bottom - 1 ),
+ new Point( area.X + 2, area.Bottom - 1 ),
+ new Point( area.X, area.Bottom - 3 ),
+ new Point( area.X, area.Y )
+ };
+ dc.DrawPolygon( pen, points );
+ break;
+ }
+
+ lgbr.Dispose( );
+ }
+
+ #region GroupBox
+ public override void DrawGroupBox (Graphics dc, Rectangle area, GroupBox box)
+ {
+ StringFormat text_format;
+ SizeF size;
+ int width;
+ int y;
+ Rectangle rect;
+
+ rect = box.ClientRectangle;
+
+ dc.FillRectangle (ResPool.GetSolidBrush (box.BackColor), rect);
+
+ text_format = new StringFormat();
+ text_format.HotkeyPrefix = HotkeyPrefix.Show;
+
+ size = dc.MeasureString (box.Text, box.Font);
+ width = (int) size.Width;
+
+ if (width > box.Width - 16)
+ width = box.Width - 16;
+
+ y = box.Font.Height / 2;
+
+ Pen pen = ResPool.GetPen( BorderColor );
+
+ /* Draw group box*/
+ Point[] points = new Point[] {
+ new Point( 8 + width, y ),
+ new Point( box.Width - 3, y ),
+ new Point( box.Width - 1, y + 2 ),
+ new Point( box.Width - 1, box.Height - 3 ),
+ new Point( box.Width - 3, box.Height - 1 ),
+ new Point( 2, box.Height - 1 ),
+ new Point( 0, box.Height - 3 ),
+ new Point( 0, y + 2 ),
+ new Point( 2, y ),
+ new Point( 8, y )
+ };
+ dc.DrawLines( pen, points );
+
+ /* Text */
+ if (box.Enabled) {
+ dc.DrawString (box.Text, box.Font, ResPool.GetSolidBrush (box.ForeColor), 10, 0, text_format);
+ } else {
+ CPDrawStringDisabled (dc, box.Text, box.Font, box.ForeColor,
+ new RectangleF (10, 0, width, box.Font.Height), text_format);
+ }
+ text_format.Dispose ();
+ }
+ #endregion
+ } //class
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
new file mode 100644
index 00000000000..f0bda348a15
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
@@ -0,0 +1,5452 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+// Peter Bartok, pbartok@novell.com
+// John BouAntoun, jba-mono@optusnet.com.au
+// Marek Safar, marek.safar@seznam.cz
+// Alexander Olk, alex.olk@googlemail.com
+//
+
+
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+using System.Drawing.Text;
+
+namespace System.Windows.Forms
+{
+
+ internal class ThemeWin32Classic : Theme
+ {
+ public override Version Version {
+ get {
+ return new Version(0, 1, 0, 0);
+ }
+ }
+
+ /* Hardcoded colour values not exposed in the API constants in all configurations */
+ protected static readonly Color arrow_color = Color.Black;
+ protected static readonly Color pen_ticks_color = Color.Black;
+ protected static readonly Color progressbarblock_color = Color.FromArgb (255, 0, 0, 128);
+ protected static StringFormat string_format_menu_text;
+ protected static StringFormat string_format_menu_shortcut;
+ protected static StringFormat string_format_menu_menubar_text;
+ static readonly Rectangle checkbox_rect = new Rectangle (2, 2, 11,11); // Position of the checkbox relative to the item
+ static ImageAttributes imagedisabled_attributes = null;
+ const int SEPARATOR_HEIGHT = 5;
+ const int SM_CXBORDER = 1;
+ const int SM_CYBORDER = 1;
+ const int MENU_TAB_SPACE = 8; // Pixels added to the width of an item because of a tab
+ const int MENU_BAR_ITEMS_SPACE = 8; // Space between menu bar items
+
+ #region Principal Theme Methods
+ public ThemeWin32Classic ()
+ {
+ defaultWindowBackColor = this.ColorWindow;
+ defaultWindowForeColor = this.ColorControlText;
+ default_font = new Font (FontFamily.GenericSansSerif, 8.25f);
+
+ /* Menu string formats */
+ string_format_menu_text = new StringFormat ();
+ string_format_menu_text.LineAlignment = StringAlignment.Center;
+ string_format_menu_text.Alignment = StringAlignment.Near;
+ string_format_menu_text.HotkeyPrefix = HotkeyPrefix.Show;
+
+ string_format_menu_shortcut = new StringFormat ();
+ string_format_menu_shortcut.LineAlignment = StringAlignment.Center;
+ string_format_menu_shortcut.Alignment = StringAlignment.Far;
+
+ string_format_menu_menubar_text = new StringFormat ();
+ string_format_menu_menubar_text.LineAlignment = StringAlignment.Center;
+ string_format_menu_menubar_text.Alignment = StringAlignment.Center;
+ string_format_menu_menubar_text.HotkeyPrefix = HotkeyPrefix.Show;
+ always_draw_hotkeys = false;
+ }
+
+ public override void ResetDefaults() {
+ throw new NotImplementedException("Need to implement ResetDefaults() for Win32 theme");
+ }
+
+ public override bool DoubleBufferingSupported {
+ get {return true; }
+ }
+ #endregion // Principal Theme Methods
+
+ #region Internal Methods
+ protected SolidBrush GetControlBackBrush (Color c) {
+ if (c == DefaultControlBackColor)
+ return ResPool.GetSolidBrush (ColorControl);
+ return ResPool.GetSolidBrush (c);
+ }
+
+ protected SolidBrush GetControlForeBrush (Color c) {
+ if (c == DefaultControlForeColor)
+ return ResPool.GetSolidBrush (ColorControlText);
+ return ResPool.GetSolidBrush (c);
+ }
+ #endregion // Internal Methods
+
+ #region OwnerDraw Support
+ public override void DrawOwnerDrawBackground (DrawItemEventArgs e)
+ {
+ if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
+ e.Graphics.FillRectangle (SystemBrushes.Highlight, e.Bounds);
+ return;
+ }
+
+ e.Graphics.FillRectangle (GetControlBackBrush (e.BackColor), e.Bounds);
+ }
+
+ public override void DrawOwnerDrawFocusRectangle (DrawItemEventArgs e)
+ {
+ if (e.State == DrawItemState.Focus)
+ CPDrawFocusRectangle (e.Graphics, e.Bounds, e.ForeColor, e.BackColor);
+ }
+ #endregion // OwnerDraw Support
+
+ #region ButtonBase
+ public override void DrawButtonBase(Graphics dc, Rectangle clip_area, ButtonBase button) {
+ // Draw the button: fill rectangle, draw border, etc.
+ ButtonBase_DrawButton(button, dc);
+
+ // First, draw the image
+ if ((button.image != null) || (button.image_list != null))
+ ButtonBase_DrawImage(button, dc);
+
+ // Draw the focus rectangle
+ if (button.has_focus)
+ ButtonBase_DrawFocus(button, dc);
+
+ // Now the text
+ if (button.text != null && button.text != String.Empty)
+ ButtonBase_DrawText(button, dc);
+ }
+
+ protected virtual void ButtonBase_DrawButton(ButtonBase button, Graphics dc)
+ {
+ Rectangle buttonRectangle;
+ Rectangle borderRectangle;
+
+ dc.FillRectangle(ResPool.GetSolidBrush (button.BackColor), button.ClientRectangle);
+
+ // set up the button rectangle
+ buttonRectangle = button.ClientRectangle;
+ if (button.has_focus || button.paint_as_acceptbutton) {
+ // shrink the rectangle for the normal button drawing inside the focus rectangle
+ borderRectangle = Rectangle.Inflate(buttonRectangle, -1, -1);
+ } else {
+ borderRectangle = buttonRectangle;
+ }
+
+ if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
+ DrawFlatStyleButton (dc, borderRectangle, button);
+ } else {
+ CPDrawButton(dc, borderRectangle, button.ButtonState);
+ if (button.has_focus || button.paint_as_acceptbutton) {
+ dc.DrawRectangle(ResPool.GetPen(button.ForeColor), borderRectangle);
+ }
+ }
+ }
+
+ protected virtual void ButtonBase_DrawImage(ButtonBase button, Graphics dc)
+ {
+ // Need to draw a picture
+ Image i;
+ int image_x;
+ int image_y;
+ int image_width;
+ int image_height;
+
+ int width = button.ClientSize.Width;
+ int height = button.ClientSize.Height;
+
+ if (button.ImageIndex != -1) { // We use ImageIndex instead of image_index since it will return -1 if image_list is null
+ i = button.image_list.Images[button.image_index];
+ } else {
+ i = button.image;
+ }
+
+ image_width = button.image.Width;
+ image_height = button.image.Height;
+
+ switch (button.image_alignment) {
+ case ContentAlignment.TopLeft: {
+ image_x=0;
+ image_y=0;
+ break;
+ }
+
+ case ContentAlignment.TopCenter: {
+ image_x=(width-image_width)/2;
+ image_y=0;
+ break;
+ }
+
+ case ContentAlignment.TopRight: {
+ image_x=width-image_width;
+ image_y=0;
+ break;
+ }
+
+ case ContentAlignment.MiddleLeft: {
+ image_x=0;
+ image_y=(height-image_height)/2;
+ break;
+ }
+
+ case ContentAlignment.MiddleCenter: {
+ image_x=(width-image_width)/2;
+ image_y=(height-image_height)/2;
+ break;
+ }
+
+ case ContentAlignment.MiddleRight: {
+ image_x=width-image_width;
+ image_y=(height-image_height)/2;
+ break;
+ }
+
+ case ContentAlignment.BottomLeft: {
+ image_x=0;
+ image_y=height-image_height;
+ break;
+ }
+
+ case ContentAlignment.BottomCenter: {
+ image_x=(width-image_width)/2;
+ image_y=height-image_height;
+ break;
+ }
+
+ case ContentAlignment.BottomRight: {
+ image_x=width-image_width;
+ image_y=height-image_height;
+ break;
+ }
+
+ default: {
+ image_x=0;
+ image_y=0;
+ break;
+ }
+ }
+
+ if (button.is_pressed) {
+ image_x+=1;
+ image_y+=1;
+ }
+
+ if (button.is_enabled) {
+ dc.DrawImage(i, image_x, image_y);
+ }
+ else {
+ CPDrawImageDisabled(dc, i, image_x, image_y, ColorControl);
+ }
+ }
+
+ protected virtual void ButtonBase_DrawFocus(ButtonBase button, Graphics dc)
+ {
+ if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
+ DrawFlatStyleFocusRectangle (dc, button.ClientRectangle, button, button.ForeColor, button.BackColor);
+ } else {
+ Rectangle rect = button.ClientRectangle;
+ rect.Inflate (-4, -4);
+ CPDrawFocusRectangle(dc, rect, button.ForeColor, button.BackColor);
+ }
+ }
+
+ protected virtual void ButtonBase_DrawText(ButtonBase button, Graphics dc)
+ {
+ Rectangle buttonRectangle = button.ClientRectangle;
+ Rectangle text_rect = Rectangle.Inflate(buttonRectangle, -4, -4);
+
+ if (button.is_pressed) {
+ text_rect.X++;
+ text_rect.Y++;
+ }
+
+ if (button.is_enabled) {
+ dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (button.ForeColor), text_rect, button.text_format);
+ } else {
+ if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
+ dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (ColorGrayText), text_rect, button.text_format);
+ } else {
+ Rectangle rect_white = new Rectangle (text_rect.X + 1, text_rect.Y + 1, text_rect.Width, text_rect.Height);
+
+ dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (ColorControlLightLight), rect_white, button.text_format);
+ dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (ColorGrayText), text_rect, button.text_format);
+ }
+ }
+ }
+
+ // draw the flat style part of the rectangle
+ public void DrawFlatStyleButton (Graphics graphics, Rectangle rectangle, ButtonBase button) {
+ Color rect_back_color = button.BackColor;
+ Color rect_fore_color = button.ForeColor;
+ Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
+
+ if (button.Enabled) {
+ if (button.Capture || button.is_entered) {
+ if (button.FlatStyle == FlatStyle.Flat) {
+ // fill the rectangle
+ graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
+
+ // now draw the outer border
+ if (button.Capture && button.is_entered) {
+ rect_back_color = ControlPaint.LightLight (rect_back_color);
+ } else {
+ rect_back_color = ControlPaint.Light (rect_back_color);
+ }
+
+ // draw rectangle and fill it
+ graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
+ graphics.DrawRectangle(ResPool.GetPen (rect_fore_color), trace_rectangle);
+ } else {
+ // else it must be a popup button
+
+ if (button.Capture && button.is_entered) {
+ graphics.DrawRectangle(ResPool.GetPen (this.ColorControlText), trace_rectangle);
+ } else {
+ // draw a 3d border
+ CPDrawBorder3D (graphics, rectangle, Border3DStyle.RaisedInner, Border3DSide.Left | Border3DSide.Top, button.BackColor);
+ graphics.DrawLine ( ResPool.GetPen (this.ColorControlText), trace_rectangle.X, trace_rectangle.Bottom, trace_rectangle.Right, trace_rectangle.Bottom);
+ graphics.DrawLine ( ResPool.GetPen (this.ColorControlText), trace_rectangle.Right, trace_rectangle.Y, trace_rectangle.Right, trace_rectangle.Bottom);
+ }
+ }
+
+ // TODO: draw inner focus rectangle
+
+ } else {
+ // popup has a ButtonColorText forecolor, not a button.ForeCOlor
+ if (button.FlatStyle == FlatStyle.Popup) {
+ rect_fore_color = ColorGrayText;
+ }
+
+ // fill then draw outer rect
+ graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
+ graphics.DrawRectangle(ResPool.GetPen (rect_fore_color), trace_rectangle);
+ }
+
+ // finally some small tweaks to render radiobutton and checkbox
+ CheckBox checkbox = button as CheckBox;
+ RadioButton radiobutton = button as RadioButton;
+ if ((checkbox != null && checkbox.Checked) ||
+ (radiobutton != null && radiobutton.Checked)) {
+ if (button.FlatStyle == FlatStyle.Flat && button.is_entered && !button.Capture) {
+ // render the hover for flat flatstyle and cheked
+ graphics.DrawRectangle(ResPool.GetPen (this.ColorControlText), trace_rectangle);
+ } else if (!button.is_entered && !button.Capture) {
+ // render the checked state for popup when unhovered
+ CPDrawBorder3D (graphics, rectangle, Border3DStyle.SunkenInner, Border3DSide.Right | Border3DSide.Bottom, button.BackColor);
+ }
+ }
+ } else {
+ // rendering checkbox or radio button style buttons
+ CheckBox checkbox = button as CheckBox;
+ RadioButton radiobutton = button as RadioButton;
+ bool draw_popup_checked = false;
+
+ if (button.FlatStyle == FlatStyle.Popup) {
+ rect_fore_color = ColorGrayText;
+
+ // see if we should draw a disabled checked popup button
+ draw_popup_checked = ((checkbox != null && checkbox.Checked) ||
+ (radiobutton != null && radiobutton.Checked));
+ }
+
+ graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
+ graphics.DrawRectangle(ResPool.GetPen (rect_fore_color), trace_rectangle);
+
+ // finally draw the flatstyle checked effect if need
+ if (draw_popup_checked) {
+ // render the checked state for popup when unhovered
+ CPDrawBorder3D (graphics, rectangle, Border3DStyle.SunkenInner, Border3DSide.Right | Border3DSide.Bottom, button.BackColor);
+ }
+ }
+ }
+
+ public override Size ButtonBaseDefaultSize {
+ get {
+ return new Size (75, 23);
+ }
+ }
+ #endregion // ButtonBase
+
+ #region CheckBox
+ public override void DrawCheckBox(Graphics dc, Rectangle clip_area, CheckBox checkbox) {
+ StringFormat text_format;
+ Rectangle client_rectangle;
+ Rectangle text_rectangle;
+ Rectangle checkbox_rectangle;
+ int checkmark_size=13;
+ int checkmark_space = 4;
+
+ client_rectangle = checkbox.ClientRectangle;
+ text_rectangle = client_rectangle;
+ checkbox_rectangle = new Rectangle(text_rectangle.X, text_rectangle.Y, checkmark_size, checkmark_size);
+
+ text_format = new StringFormat();
+ text_format.Alignment=StringAlignment.Near;
+ text_format.LineAlignment=StringAlignment.Center;
+ text_format.HotkeyPrefix = HotkeyPrefix.Show;
+
+ /* Calculate the position of text and checkbox rectangle */
+ if (checkbox.appearance!=Appearance.Button) {
+ switch(checkbox.check_alignment) {
+ case ContentAlignment.BottomCenter: {
+ checkbox_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-checkmark_size/2;
+ checkbox_rectangle.Y=client_rectangle.Bottom-checkmark_size;
+ text_rectangle.X=client_rectangle.X;
+ text_rectangle.Width=client_rectangle.Width;
+ text_rectangle.Height=client_rectangle.Height-checkbox_rectangle.Y-checkmark_space;
+ break;
+ }
+
+ case ContentAlignment.BottomLeft: {
+ checkbox_rectangle.X=client_rectangle.Left;
+ checkbox_rectangle.Y=client_rectangle.Bottom-checkmark_size;
+ text_rectangle.X=client_rectangle.X+checkmark_size+checkmark_space;
+ text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
+ break;
+ }
+
+ case ContentAlignment.BottomRight: {
+ checkbox_rectangle.X=client_rectangle.Right-checkmark_size;
+ checkbox_rectangle.Y=client_rectangle.Bottom-checkmark_size;
+ text_rectangle.X=client_rectangle.X;
+ text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
+ break;
+ }
+
+ case ContentAlignment.MiddleCenter: {
+ checkbox_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-checkmark_size/2;
+ checkbox_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-checkmark_size/2;
+ text_rectangle.X=client_rectangle.X;
+ text_rectangle.Width=client_rectangle.Width;
+ break;
+ }
+
+ default:
+ case ContentAlignment.MiddleLeft: {
+ checkbox_rectangle.X=client_rectangle.Left;
+ checkbox_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-checkmark_size/2;
+ text_rectangle.X=client_rectangle.X+checkmark_size+checkmark_space;
+ text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
+ break;
+ }
+
+ case ContentAlignment.MiddleRight: {
+ checkbox_rectangle.X=client_rectangle.Right-checkmark_size;
+ checkbox_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-checkmark_size/2;
+ text_rectangle.X=client_rectangle.X;
+ text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
+ break;
+ }
+
+ case ContentAlignment.TopCenter: {
+ checkbox_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-checkmark_size/2;
+ checkbox_rectangle.Y=client_rectangle.Top;
+ text_rectangle.X=client_rectangle.X;
+ text_rectangle.Width=client_rectangle.Width;
+ text_rectangle.Y=checkmark_size+checkmark_space;
+ text_rectangle.Height=client_rectangle.Height-checkmark_size-checkmark_space;
+ break;
+ }
+
+ case ContentAlignment.TopLeft: {
+ checkbox_rectangle.X=client_rectangle.Left;
+ text_rectangle.X=client_rectangle.X+checkmark_size+checkmark_space;
+ text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
+ break;
+ }
+
+ case ContentAlignment.TopRight: {
+ checkbox_rectangle.X=client_rectangle.Right-checkmark_size;
+ text_rectangle.X=client_rectangle.X;
+ text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
+ break;
+ }
+ }
+ } else {
+ text_rectangle.X=client_rectangle.X;
+ text_rectangle.Width=client_rectangle.Width;
+ }
+
+ /* Set the horizontal alignment of our text */
+ switch(checkbox.text_alignment) {
+ case ContentAlignment.BottomLeft:
+ case ContentAlignment.MiddleLeft:
+ case ContentAlignment.TopLeft: {
+ text_format.Alignment=StringAlignment.Near;
+ break;
+ }
+
+ case ContentAlignment.BottomCenter:
+ case ContentAlignment.MiddleCenter:
+ case ContentAlignment.TopCenter: {
+ text_format.Alignment=StringAlignment.Center;
+ break;
+ }
+
+ case ContentAlignment.BottomRight:
+ case ContentAlignment.MiddleRight:
+ case ContentAlignment.TopRight: {
+ text_format.Alignment=StringAlignment.Far;
+ break;
+ }
+ }
+
+ /* Set the vertical alignment of our text */
+ switch(checkbox.text_alignment) {
+ case ContentAlignment.TopLeft:
+ case ContentAlignment.TopCenter:
+ case ContentAlignment.TopRight: {
+ text_format.LineAlignment=StringAlignment.Near;
+ break;
+ }
+
+ case ContentAlignment.BottomLeft:
+ case ContentAlignment.BottomCenter:
+ case ContentAlignment.BottomRight: {
+ text_format.LineAlignment=StringAlignment.Far;
+ break;
+ }
+
+ case ContentAlignment.MiddleLeft:
+ case ContentAlignment.MiddleCenter:
+ case ContentAlignment.MiddleRight: {
+ text_format.LineAlignment=StringAlignment.Center;
+ break;
+ }
+ }
+
+ ButtonState state = ButtonState.Normal;
+ if (checkbox.FlatStyle == FlatStyle.Flat) {
+ state |= ButtonState.Flat;
+ }
+
+ if (checkbox.Checked) {
+ state |= ButtonState.Checked;
+ }
+
+ if (checkbox.ThreeState && (checkbox.CheckState == CheckState.Indeterminate)) {
+ state |= ButtonState.Checked;
+ state |= ButtonState.Pushed;
+ }
+
+ // finally make sure the pushed and inavtive states are rendered
+ if (!checkbox.Enabled) {
+ state |= ButtonState.Inactive;
+ }
+ else if (checkbox.is_pressed) {
+ state |= ButtonState.Pushed;
+ }
+
+
+ // Start drawing
+
+ CheckBox_DrawCheckBox(dc, checkbox, state, checkbox_rectangle);
+
+ CheckBox_DrawText(checkbox, text_rectangle, dc, text_format);
+
+ CheckBox_DrawFocus(checkbox, dc, text_rectangle);
+
+ text_format.Dispose ();
+ }
+
+ protected virtual void CheckBox_DrawCheckBox( Graphics dc, CheckBox checkbox, ButtonState state, Rectangle checkbox_rectangle )
+ {
+ dc.FillRectangle (ResPool.GetSolidBrush (checkbox.BackColor), checkbox.ClientRectangle);
+ // render as per normal button
+ if (checkbox.appearance==Appearance.Button) {
+ if (checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup) {
+ DrawFlatStyleButton(dc, checkbox.ClientRectangle, checkbox);
+ } else {
+ CPDrawButton(dc, checkbox.ClientRectangle, state);
+ }
+ } else {
+ // establish if we are rendering a flat style of some sort
+ if (checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup) {
+ DrawFlatStyleCheckBox (dc, checkbox_rectangle, checkbox);
+ } else {
+ ControlPaint.DrawCheckBox(dc, checkbox_rectangle, state);
+ }
+ }
+ }
+
+ protected virtual void CheckBox_DrawText( CheckBox checkbox, Rectangle text_rectangle, Graphics dc, StringFormat text_format )
+ {
+ SolidBrush sb;
+
+ // offset the text if it's pressed and a button
+ if (checkbox.Appearance == Appearance.Button) {
+ if (checkbox.Checked || (checkbox.Capture && checkbox.FlatStyle != FlatStyle.Flat)) {
+ text_rectangle.X ++;
+ text_rectangle.Y ++;
+ }
+
+ text_rectangle.Inflate(-4, -4);
+ }
+
+ /* Place the text; to be compatible with Windows place it after the checkbox has been drawn */
+
+ // Windows seems to not wrap text in certain situations, this matches as close as I could get it
+ if ((float)(checkbox.Font.Height * 1.5f) > text_rectangle.Height) {
+ text_format.FormatFlags |= StringFormatFlags.NoWrap;
+ }
+ if (checkbox.Enabled) {
+ sb = ResPool.GetSolidBrush(checkbox.ForeColor);
+ dc.DrawString(checkbox.Text, checkbox.Font, sb, text_rectangle, text_format);
+ } else if (checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup) {
+ dc.DrawString(checkbox.Text, checkbox.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorControl)), text_rectangle, text_format);
+ } else {
+ CPDrawStringDisabled(dc, checkbox.Text, checkbox.Font, ColorControlText, text_rectangle, text_format);
+ }
+ }
+
+ protected virtual void CheckBox_DrawFocus( CheckBox checkbox, Graphics dc, Rectangle text_rectangle )
+ {
+ if (checkbox.Focused) {
+ if (checkbox.FlatStyle != FlatStyle.Flat) {
+ DrawInnerFocusRectangle (dc, Rectangle.Inflate (text_rectangle, -1, -1), checkbox.BackColor);
+ } else {
+ dc.DrawRectangle (ResPool.GetPen (checkbox.ForeColor), Rectangle.Inflate (text_rectangle, -1, -1));
+ }
+ }
+ }
+
+ // renders a checkBox with the Flat and Popup FlatStyle
+ protected virtual void DrawFlatStyleCheckBox (Graphics graphics, Rectangle rectangle, CheckBox checkbox)
+ {
+ Pen pen;
+ Rectangle rect;
+ Rectangle checkbox_rectangle;
+ Rectangle fill_rectangle;
+ int lineWidth;
+ int Scale;
+
+ // set up our rectangles first
+ if (checkbox.FlatStyle == FlatStyle.Popup && checkbox.is_entered) {
+ // clip one pixel from bottom right for non popup rendered checkboxes
+ checkbox_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max(rectangle.Width-1, 0), Math.Max(rectangle.Height-1,0));
+ fill_rectangle = new Rectangle(checkbox_rectangle.X+1, checkbox_rectangle.Y+1, Math.Max(checkbox_rectangle.Width-3, 0), Math.Max(checkbox_rectangle.Height-3,0));
+ } else {
+ // clip two pixels from bottom right for non popup rendered checkboxes
+ checkbox_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max(rectangle.Width-2, 0), Math.Max(rectangle.Height-2,0));
+ fill_rectangle = new Rectangle(checkbox_rectangle.X+1, checkbox_rectangle.Y+1, Math.Max(checkbox_rectangle.Width-2, 0), Math.Max(checkbox_rectangle.Height-2,0));
+ }
+
+ // if disabled render in disabled state
+ if (checkbox.Enabled) {
+ // process the state of the checkbox
+ if (checkbox.is_entered || checkbox.Capture) {
+ // decide on which background color to use
+ if (checkbox.FlatStyle == FlatStyle.Popup && checkbox.is_entered && checkbox.Capture) {
+ graphics.FillRectangle(ResPool.GetSolidBrush (checkbox.BackColor), fill_rectangle);
+ } else if (checkbox.FlatStyle == FlatStyle.Flat && !(checkbox.is_entered && checkbox.Capture)) {
+ graphics.FillRectangle(ResPool.GetSolidBrush (ControlPaint.Light(checkbox.BackColor)), fill_rectangle);
+ } else {
+ // use regular window background color
+ graphics.FillRectangle(ResPool.GetSolidBrush (ControlPaint.LightLight (checkbox.BackColor)), fill_rectangle);
+ }
+
+ // render the outer border
+ if (checkbox.FlatStyle == FlatStyle.Flat) {
+ ControlPaint.DrawBorder(graphics, checkbox_rectangle, checkbox.ForeColor, ButtonBorderStyle.Solid);
+ } else {
+ // draw sunken effect
+ CPDrawBorder3D (graphics, checkbox_rectangle, Border3DStyle.SunkenInner, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, checkbox.BackColor);
+ }
+ } else {
+ graphics.FillRectangle(ResPool.GetSolidBrush (ControlPaint.LightLight (checkbox.BackColor)), fill_rectangle);
+
+ if (checkbox.FlatStyle == FlatStyle.Flat) {
+ ControlPaint.DrawBorder(graphics, checkbox_rectangle, checkbox.ForeColor, ButtonBorderStyle.Solid);
+ } else {
+ // draw the outer border
+ ControlPaint.DrawBorder(graphics, checkbox_rectangle, ControlPaint.DarkDark (checkbox.BackColor), ButtonBorderStyle.Solid);
+ }
+ }
+ } else {
+ if (checkbox.FlatStyle == FlatStyle.Popup) {
+ graphics.FillRectangle(SystemBrushes.Control, fill_rectangle);
+ }
+
+ // draw disabled state,
+ ControlPaint.DrawBorder(graphics, checkbox_rectangle, ColorControlDark, ButtonBorderStyle.Solid);
+ }
+
+ /* Make sure we've got at least a line width of 1 */
+ lineWidth = Math.Max(3, fill_rectangle.Width/3);
+ Scale=Math.Max(1, fill_rectangle.Width/9);
+
+ // flat style check box is rendered inside a rectangle shifted down by one
+ rect=new Rectangle(fill_rectangle.X, fill_rectangle.Y+1, fill_rectangle.Width, fill_rectangle.Height);
+ if (checkbox.Enabled) {
+ pen=ResPool.GetPen(checkbox.ForeColor);
+ } else {
+ pen=SystemPens.ControlDark;
+ }
+
+ if (checkbox.Checked) {
+ /* Need to draw a check-mark */
+ for (int i=0; i<lineWidth; i++) {
+ graphics.DrawLine(pen, rect.Left+lineWidth/2, rect.Top+lineWidth+i, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i);
+ graphics.DrawLine(pen, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i, rect.Left+lineWidth/2+6*Scale, rect.Top+lineWidth-2*Scale+i);
+ }
+ }
+ }
+
+
+ #endregion // CheckBox
+
+ #region CheckedListBox
+
+ public override Rectangle CheckedListBoxCheckRectangle ()
+ {
+ return checkbox_rect;
+ }
+
+ public override void DrawCheckedListBoxItem (CheckedListBox ctrl, DrawItemEventArgs e)
+ {
+ Color back_color, fore_color;
+ Rectangle item_rect = e.Bounds;
+ ButtonState state;
+ StringFormat string_format = ctrl.GetFormatString ();
+
+ /* Draw checkbox */
+
+ if ((ctrl.Items.GetListBoxItem (e.Index)).State == CheckState.Checked)
+ state = ButtonState.Checked;
+ else
+ state = ButtonState.Normal;
+
+ if (ctrl.ThreeDCheckBoxes == false)
+ state |= ButtonState.Flat;
+
+ ControlPaint.DrawCheckBox (e.Graphics,
+ item_rect.X + checkbox_rect.X, item_rect.Y + checkbox_rect.Y,
+ checkbox_rect.Width, checkbox_rect.Height,
+ state);
+
+ item_rect.X += checkbox_rect.Width + checkbox_rect.X * 2;
+ item_rect.Width -= checkbox_rect.Width + checkbox_rect.X * 2;
+
+ /* Draw text*/
+ if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
+ back_color = ColorHighlight;
+ fore_color = ColorHighlightText;
+ }
+ else {
+ back_color = e.BackColor;
+ fore_color = e.ForeColor;
+ }
+
+ e.Graphics.FillRectangle (ResPool.GetSolidBrush
+ (back_color), item_rect);
+
+ e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
+ ResPool.GetSolidBrush (fore_color),
+ item_rect, string_format);
+
+ if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
+ CPDrawFocusRectangle (e.Graphics, item_rect,
+ fore_color, back_color);
+ }
+ }
+
+ #endregion // CheckedListBox
+
+ #region ComboBox
+
+ // Drawing
+ // TODO: get rid of that and use BorderStyle Fixed3D
+ public override void DrawComboBoxEditDecorations (Graphics dc, ComboBox ctrl, Rectangle cl)
+ {
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), cl.X, cl.Y, cl.X + cl.Width, cl.Y); //top
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), cl.X + 1, cl.Y + 1, cl.X + cl.Width - 2, cl.Y + 1);
+ dc.DrawLine (ResPool.GetPen (ColorControl), cl.X, cl.Y + cl.Height - 2, cl.X + cl.Width, cl.Y + cl.Height - 2); //down
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), cl.X, cl.Y + cl.Height - 1, cl.X + cl.Width, cl.Y + cl.Height - 1);
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), cl.X, cl.Y, cl.X, cl.Y + cl.Height); //left
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), cl.X + 1, cl.Y + 1, cl.X + 1, cl.Y + cl.Height - 2);
+ dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + cl.Width - 1, cl.Y, cl.X + cl.Width - 1, cl.Y + cl.Height); //right
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), cl.X + cl.Width - 2, cl.Y + 1 , cl.X + cl.Width - 2, cl.Y + cl.Height - 1);
+ }
+
+ // Sizing
+ public override int DrawComboBoxEditDecorationTop () { return 2;}
+ public override int DrawComboBoxEditDecorationBottom () { return 2;}
+ public override int DrawComboBoxEditDecorationRight () { return 2;}
+ public override int DrawComboBoxEditDecorationLeft () { return 2;}
+
+ private int DrawComboListBoxDecoration (ComboBoxStyle style)
+ {
+ if (style == ComboBoxStyle.Simple)
+ return 2;
+ else
+ return 1;
+ }
+
+ public override int DrawComboListBoxDecorationTop (ComboBoxStyle style)
+ {
+ return DrawComboListBoxDecoration (style);
+ }
+
+ public override int DrawComboListBoxDecorationBottom (ComboBoxStyle style)
+ {
+ return DrawComboListBoxDecoration (style);
+ }
+
+ public override int DrawComboListBoxDecorationRight (ComboBoxStyle style)
+ {
+ return DrawComboListBoxDecoration (style);
+ }
+
+ public override int DrawComboListBoxDecorationLeft (ComboBoxStyle style)
+ {
+ return DrawComboListBoxDecoration (style);
+ }
+
+ public override void DrawComboListBoxDecorations (Graphics dc, ComboBox ctrl, Rectangle cl)
+ {
+ if (ctrl.DropDownStyle == ComboBoxStyle.Simple) {
+ DrawComboBoxEditDecorations (dc, ctrl, cl);
+ }
+ else {
+ dc.DrawRectangle (ResPool.GetPen (ColorWindowFrame),
+ cl.X, cl.Y, cl.Width - 1, cl.Height - 1);
+ }
+ }
+
+ public override void DrawComboBoxItem (ComboBox ctrl, DrawItemEventArgs e)
+ {
+ Color back_color, fore_color;
+ Rectangle text_draw = e.Bounds;
+ StringFormat string_format = new StringFormat ();
+ string_format.FormatFlags = StringFormatFlags.LineLimit;
+
+ if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
+ back_color = ColorHighlight;
+ fore_color = ColorHighlightText;
+ }
+ else {
+ back_color = e.BackColor;
+ fore_color = e.ForeColor;
+ }
+
+ e.Graphics.FillRectangle (ResPool.GetSolidBrush (back_color), e.Bounds);
+
+ if (e.Index != -1) {
+ e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
+ ResPool.GetSolidBrush (fore_color),
+ text_draw, string_format);
+ }
+
+ if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
+ CPDrawFocusRectangle (e.Graphics, e.Bounds, fore_color, back_color);
+ }
+
+ string_format.Dispose ();
+ }
+
+ #endregion ComboBox
+
+ #region Datagrid
+ public override int DataGridPreferredColumnWidth { get { return 75;} }
+ public override int DataGridMinimumColumnCheckBoxHeight { get { return 16;} }
+ public override int DataGridMinimumColumnCheckBoxWidth { get { return 16;} }
+ public override Color DataGridAlternatingBackColor { get { return ColorWindow;} }
+ public override Color DataGridBackColor { get { return ColorWindow;} }
+ public override Color DataGridBackgroundColor { get { return ColorAppWorkspace;} }
+ public override Color DataGridCaptionBackColor { get { return ColorActiveCaption;} }
+ public override Color DataGridCaptionForeColor { get { return ColorActiveCaptionText;} }
+ public override Color DataGridGridLineColor { get { return ColorControl;} }
+ public override Color DataGridHeaderBackColor { get { return ColorControl;} }
+ public override Color DataGridHeaderForeColor { get { return ColorControlText;} }
+ public override Color DataGridLinkColor { get { return ColorHotTrack;} }
+ public override Color DataGridLinkHoverColor { get { return ColorHotTrack;} }
+ public override Color DataGridParentRowsBackColor { get { return ColorControl;} }
+ public override Color DataGridParentRowsForeColor { get { return ColorWindowText;} }
+ public override Color DataGridSelectionBackColor { get { return ColorActiveCaption;} }
+ public override Color DataGridSelectionForeColor { get { return ColorActiveCaptionText;} }
+
+ public override void DataGridPaint (PaintEventArgs pe, DataGrid grid)
+ {
+ // Draw parent rows
+ if (pe.ClipRectangle.IntersectsWith (grid.grid_drawing.parent_rows)) {
+ pe.Graphics.FillRectangle (ResPool.GetSolidBrush (grid.ParentRowsBackColor), grid.grid_drawing.parent_rows);
+ }
+
+ DataGridPaintCaption (pe.Graphics, pe.ClipRectangle, grid);
+ DataGridPaintColumnsHdrs (pe.Graphics, pe.ClipRectangle, grid);
+ DataGridPaintRowsHeaders (pe.Graphics, pe.ClipRectangle, grid);
+ DataGridPaintRows (pe.Graphics, grid.grid_drawing.cells_area, pe.ClipRectangle, grid);
+
+ // Paint scrollBar corner
+ if (grid.vert_scrollbar.Visible && grid.horiz_scrollbar.Visible) {
+
+ Rectangle corner = new Rectangle (grid.ClientRectangle.X + grid.ClientRectangle.Width - grid.horiz_scrollbar.Height,
+ grid.ClientRectangle.Y + grid.ClientRectangle.Height - grid.horiz_scrollbar.Height,
+ grid.horiz_scrollbar.Height, grid.horiz_scrollbar.Height);
+
+ if (pe.ClipRectangle.IntersectsWith (corner)) {
+ pe.Graphics.FillRectangle (ResPool.GetSolidBrush (grid.ParentRowsBackColor),
+ corner);
+ }
+ }
+ }
+
+ public override void DataGridPaintCaption (Graphics g, Rectangle clip, DataGrid grid)
+ {
+ Rectangle modified_area = clip;
+ modified_area.Intersect (grid.grid_drawing.caption_area);
+
+ g.FillRectangle (ResPool.GetSolidBrush (grid.CaptionBackColor),
+ modified_area);
+
+ g.DrawString (grid.CaptionText, grid.CaptionFont,
+ ResPool.GetSolidBrush (grid.CaptionForeColor),
+ grid.grid_drawing.caption_area);
+ }
+
+ public override void DataGridPaintColumnsHdrs (Graphics g, Rectangle clip, DataGrid grid)
+ {
+ Rectangle columns_area = grid.grid_drawing.columnshdrs_area;
+
+ if (grid.CurrentTableStyle.CurrentRowHeadersVisible) { // Paint corner shared between row and column header
+ Rectangle rect_bloc = grid.grid_drawing.columnshdrs_area;
+ rect_bloc.Width = grid.RowHeaderWidth;
+ rect_bloc.Height = grid.grid_drawing.columnshdrs_area.Height;
+ if (clip.IntersectsWith (rect_bloc)) {
+ if (grid.visiblecolumn_count > 0) {
+ g.FillRectangle (ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderBackColor), rect_bloc);
+ }else {
+ g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), rect_bloc);
+ }
+ }
+
+ columns_area.X += grid.RowHeaderWidth;
+ columns_area.Width -= grid.RowHeaderWidth;
+ }
+
+ // Set unused area
+ Rectangle columnshdrs_area_complete = columns_area;
+ columnshdrs_area_complete.Width = grid.grid_drawing.columnshdrs_maxwidth;
+
+ if (grid.CurrentTableStyle.CurrentRowHeadersVisible) {
+ columnshdrs_area_complete.Width -= grid.RowHeaderWidth;
+ }
+
+ // Set column painting
+ Rectangle rect_columnhdr = new Rectangle ();
+ int col_pixel;
+ Region current_clip;
+ rect_columnhdr.Y = columns_area.Y;
+ rect_columnhdr.Height = columns_area.Height;
+
+ current_clip = new Region (columns_area);
+ g.Clip = current_clip;
+ int column_cnt = grid.first_visiblecolumn + grid.visiblecolumn_count;
+ for (int column = grid.first_visiblecolumn; column < column_cnt; column++) {
+
+ col_pixel = grid.grid_drawing.GetColumnStartingPixel (column);
+ rect_columnhdr.X = columns_area.X + col_pixel - grid.horz_pixeloffset;
+ rect_columnhdr.Width = grid.CurrentTableStyle.GridColumnStyles[column].Width;
+
+ if (clip.IntersectsWith (rect_columnhdr) == false)
+ continue;
+
+ grid.CurrentTableStyle.GridColumnStyles[column].PaintHeader (g, rect_columnhdr, column);
+
+
+ }
+
+ current_clip.Dispose ();
+ g.ResetClip ();
+
+ Rectangle not_usedarea = columnshdrs_area_complete;
+ not_usedarea.X = rect_columnhdr.X + rect_columnhdr.Width;
+ not_usedarea.Width = grid.ClientRectangle.X + grid.ClientRectangle.Width - rect_columnhdr.X - rect_columnhdr.Height;
+ g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
+
+ }
+
+ public override void DataGridPaintRowsHeaders (Graphics g, Rectangle clip, DataGrid grid)
+ {
+ Rectangle rowshdrs_area_complete = grid.grid_drawing.rowshdrs_area;
+ rowshdrs_area_complete.Height = grid.grid_drawing.rowshdrs_maxheight;
+ Rectangle rect_row = new Rectangle ();
+ rect_row.X = grid.grid_drawing.rowshdrs_area.X;
+ int rowcnt = grid.FirstVisibleRow + grid.VisibleRowCount;
+ Rectangle not_usedarea = rowshdrs_area_complete;
+
+ if (rowcnt < grid.RowsCount) { // Paint one row more for partial rows
+ rowcnt++;
+ }
+
+ g.SetClip (grid.grid_drawing.rowshdrs_area);
+ for (int row = grid.FirstVisibleRow; row < rowcnt; row++) {
+
+ rect_row.Width = grid.grid_drawing.rowshdrs_area.Width;
+ rect_row.Height = grid.RowHeight;
+ rect_row.Y = grid.grid_drawing.rowshdrs_area.Y + ((row - grid.FirstVisibleRow) * grid.RowHeight);
+
+ if (clip.IntersectsWith (rect_row)) {
+ DataGridPaintRowHeader (g, rect_row, row, grid);
+ }
+ }
+
+ g.ResetClip ();
+ not_usedarea.Height = grid.grid_drawing.rowshdrs_maxheight - grid.grid_drawing.rowshdrs_area.Height;
+ not_usedarea.Y = grid.grid_drawing.rowshdrs_area.Y + grid.grid_drawing.rowshdrs_area.Height;
+ g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
+ }
+
+ public override void DataGridPaintRowHeaderArrow (Graphics g, Rectangle bounds, DataGrid grid)
+ {
+ Point[] arrow = new Point[3];
+ Point P1, P2, P3;
+ int centerX, centerY, shiftX;
+ Rectangle rect;
+
+ rect = new Rectangle (bounds.X + bounds.Width /4,
+ bounds.Y + bounds.Height/4, bounds.Width / 2, bounds.Height / 2);
+
+ centerX = rect.Left + rect.Width / 2;
+ centerY = rect.Top + rect.Height / 2;
+ shiftX = Math.Max (1, rect.Width / 8);
+ rect.X -= shiftX;
+ centerX -= shiftX;
+ P1 = new Point (centerX, rect.Top - 1);
+ P2 = new Point (centerX, rect.Bottom);
+ P3 = new Point (rect.Right, centerY);
+ arrow[0] = P1;
+ arrow[1] = P2;
+ arrow[2] = P3;
+
+ g.FillPolygon (ResPool.GetSolidBrush
+ (grid.CurrentTableStyle.CurrentHeaderForeColor), arrow, FillMode.Winding);
+ }
+
+ public override void DataGridPaintRowHeader (Graphics g, Rectangle bounds, int row, DataGrid grid)
+ {
+ // Background
+ g.FillRectangle (ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderBackColor),
+ bounds);
+
+ if (grid.FlatMode == false) {
+
+ // Paint Borders
+ g.DrawLine (ResPool.GetPen (ColorControlLight),
+ bounds.X, bounds.Y, bounds.X + bounds.Width, bounds.Y);
+
+ g.DrawLine (ResPool.GetPen (ColorControlLight),
+ bounds.X, bounds.Y + 1, bounds.X, bounds.Y + bounds.Height - 1);
+
+ g.DrawLine (ResPool.GetPen (ColorControlDark),
+ bounds.X + bounds.Width - 1, bounds.Y + 1 , bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
+
+ g.DrawLine (ResPool.GetPen (ColorControlDark),
+ bounds.X, bounds.Y + bounds.Height -1, bounds.X + bounds.Width, bounds.Y + bounds.Height -1);
+ }
+
+ if (grid.ShowEditRow && grid.RowsCount > 0 && row == grid.RowsCount && !(row == grid.CurrentCell.RowNumber && grid.is_changing == true)) {
+
+ g.DrawString ("*", grid.grid_drawing.font_newrow, ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderForeColor),
+ bounds);
+
+ } else {
+ // Draw arrow
+ if (row == grid.CurrentCell.RowNumber) {
+
+ if (grid.is_changing == true) {
+ g.DrawString ("...", grid.Font,
+ ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderForeColor),
+ bounds);
+
+ } else {
+
+ Rectangle rect = new Rectangle (bounds.X - 2, bounds.Y, 18, 18);
+ DataGridPaintRowHeaderArrow (g, rect, grid);
+ }
+ }
+ }
+ }
+
+ public override void DataGridPaintRows (Graphics g, Rectangle cells, Rectangle clip, DataGrid grid)
+ {
+ Rectangle rect_row = new Rectangle ();
+ Rectangle not_usedarea = new Rectangle ();
+ rect_row.X = cells.X;
+
+ int rowcnt = grid.FirstVisibleRow + grid.VisibleRowCount;
+
+ if (grid.ShowEditRow && grid.RowsCount > 0) {
+ rowcnt--;
+ }
+
+ if (rowcnt < grid.RowsCount) { // Paint one row more for partial rows
+ rowcnt++;
+ }
+
+ rect_row.Height = grid.RowHeight;
+ rect_row.Width = cells.Width;
+ for (int row = grid.FirstVisibleRow; row < rowcnt; row++) {
+ rect_row.Y = cells.Y + ((row - grid.FirstVisibleRow) * grid.RowHeight);
+ if (clip.IntersectsWith (rect_row)) {
+ DataGridPaintRow (g, row, rect_row, false, grid);
+ }
+ }
+
+ if (grid.ShowEditRow && grid.RowsCount > 0 && grid.FirstVisibleRow + grid.VisibleRowCount == grid.RowsCount + 1) {
+ rect_row.Y = cells.Y + ((rowcnt - grid.FirstVisibleRow) * grid.RowHeight);
+ if (clip.IntersectsWith (rect_row)) {
+ DataGridPaintRow (g, rowcnt, rect_row, true, grid);
+ }
+ }
+
+ not_usedarea.Height = cells.Y + cells.Height - rect_row.Y - rect_row.Height;
+ not_usedarea.Y = rect_row.Y + rect_row.Height;
+ not_usedarea.Width = rect_row.Width = cells.Width;
+ not_usedarea.X = cells.X;
+
+ g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
+ }
+
+ public override void DataGridPaintRow (Graphics g, int row, Rectangle row_rect, bool is_newrow, DataGrid grid)
+ {
+ Rectangle rect_cell = new Rectangle ();
+ int col_pixel;
+ Color backcolor, forecolor;
+ Region prev_clip = g.Clip;
+ Region current_clip;
+ Rectangle not_usedarea = new Rectangle ();
+
+ rect_cell.Y = row_rect.Y;
+ rect_cell.Height = row_rect.Height;
+
+ // PaintCells at row, column
+ int column_cnt = grid.first_visiblecolumn + grid.visiblecolumn_count;
+ for (int column = grid.first_visiblecolumn; column < column_cnt; column++) {
+
+ col_pixel = grid.grid_drawing.GetColumnStartingPixel (column);
+
+ rect_cell.X = row_rect.X + col_pixel - grid.horz_pixeloffset;
+ rect_cell.Width = grid.CurrentTableStyle.GridColumnStyles[column].Width;
+
+ current_clip = new Region (row_rect);
+ g.Clip = current_clip;
+
+ if (grid.IsSelected (row)) {
+ backcolor = grid.SelectionBackColor;
+ forecolor = grid.SelectionForeColor;
+ } else {
+ if (row % 2 == 0) {
+ backcolor = grid.BackColor;
+ } else {
+ backcolor = grid.AlternatingBackColor;
+ }
+
+ forecolor = grid.ForeColor;
+ }
+
+ if (is_newrow) {
+ grid.CurrentTableStyle.GridColumnStyles[column].PaintNewRow (g, rect_cell,
+ ResPool.GetSolidBrush (backcolor),
+ ResPool.GetSolidBrush (forecolor));
+
+ } else {
+ grid.CurrentTableStyle.GridColumnStyles[column].Paint (g, rect_cell, grid.ListManager, row,
+ ResPool.GetSolidBrush (backcolor),
+ ResPool.GetSolidBrush (forecolor),
+ grid.RightToLeft == RightToLeft.Yes);
+ }
+
+ g.Clip = prev_clip;
+ current_clip.Dispose ();
+ }
+
+ if (row_rect.X + row_rect.Width > rect_cell.X + rect_cell.Width) {
+
+ not_usedarea.X = rect_cell.X + rect_cell.Width;
+ not_usedarea.Width = row_rect.X + row_rect.Width - rect_cell.X - rect_cell.Width;
+ not_usedarea.Y = row_rect.Y;
+ not_usedarea.Height = row_rect.Height;
+ g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor),
+ not_usedarea);
+ }
+ }
+
+ #endregion // Datagrid
+
+ #region DateTimePicker
+
+ public override void DrawDateTimePicker (Graphics dc, Rectangle clip_rectangle, DateTimePicker dtp) {
+ // if not showing the numeric updown control then render border
+ if (!dtp.ShowUpDown && clip_rectangle.IntersectsWith (dtp.ClientRectangle)) {
+ // draw the outer border
+ Rectangle button_bounds = dtp.ClientRectangle;
+ this.CPDrawBorder3D (dc, button_bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, dtp.BackColor);
+
+ // deflate by the border width
+ if (clip_rectangle.IntersectsWith (dtp.drop_down_arrow_rect)) {
+ button_bounds.Inflate (-2,-2);
+ ButtonState state = dtp.is_drop_down_visible ? ButtonState.Pushed : ButtonState.Normal;
+ this.CPDrawComboButton (
+ dc,
+ dtp.drop_down_arrow_rect,
+ state);
+ }
+ }
+
+ // render the date part
+ if (clip_rectangle.IntersectsWith (dtp.date_area_rect)) {
+ // fill the background
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorWindow), dtp.date_area_rect);
+
+ // fill the currently highlighted area
+ if (dtp.hilight_date_area != Rectangle.Empty) {
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorHighlight), dtp.hilight_date_area);
+ }
+
+ // draw the text part
+ // TODO: if date format is CUstom then we need to draw the dates as separate parts
+ StringFormat text_format = new StringFormat();
+ text_format.LineAlignment = StringAlignment.Center;
+ text_format.Alignment = StringAlignment.Near;
+ dc.DrawString (dtp.Text, dtp.Font, ResPool.GetSolidBrush (dtp.ForeColor), Rectangle.Inflate(dtp.date_area_rect, -1, -1), text_format);
+ text_format.Dispose ();
+ }
+ }
+
+ #endregion // DateTimePicker
+
+ #region GroupBox
+ public override void DrawGroupBox (Graphics dc, Rectangle area, GroupBox box) {
+ StringFormat text_format;
+ SizeF size;
+ int width;
+ int y;
+ Rectangle rect;
+
+ rect = box.ClientRectangle;
+
+ // Needed once the Dark/Light code below is enabled again
+ //Color disabled = ColorGrayText;
+
+ Pen pen_light = ResPool.GetPen (Color.FromArgb (255,255,255,255));
+ Pen pen_dark = ResPool.GetPen (Color.FromArgb (255, 128, 128,128));
+
+ // TODO: When the Light and Dark methods work this code should be activate it
+ //Pen pen_light = new Pen (ControlPaint.Light (disabled, 1));
+ //Pen pen_dark = new Pen (ControlPaint.Dark (disabled, 0));
+
+ dc.FillRectangle (ResPool.GetSolidBrush (box.BackColor), rect);
+
+ text_format = new StringFormat();
+ text_format.HotkeyPrefix = HotkeyPrefix.Show;
+
+ size = dc.MeasureString (box.Text, box.Font);
+ width = ((int) size.Width) + 7;
+
+ if (width > box.Width - 16)
+ width = box.Width - 16;
+
+ y = box.Font.Height / 2;
+
+ /* Draw group box*/
+ dc.DrawLine (pen_dark, 0, y, 8, y); // top
+ dc.DrawLine (pen_light, 0, y + 1, 8, y + 1);
+ dc.DrawLine (pen_dark, 8 + width, y, box.Width, y);
+ dc.DrawLine (pen_light, 8 + width, y + 1, box.Width, y + 1);
+
+ dc.DrawLine (pen_dark, 0, y + 1, 0, box.Height); // left
+ dc.DrawLine (pen_light, 1, y + 1, 1, box.Height);
+
+ dc.DrawLine (pen_dark, 0, box.Height - 2, box.Width, box.Height - 2); // bottom
+ dc.DrawLine (pen_light, 0, box.Height - 1, box.Width, box.Height - 1);
+
+ dc.DrawLine (pen_dark, box.Width - 2, y, box.Width - 2, box.Height - 2); // right
+ dc.DrawLine (pen_light, box.Width - 1, y, box.Width - 1, box.Height - 2);
+
+
+ /* Text */
+ if (box.Enabled) {
+ dc.DrawString (box.Text, box.Font, ResPool.GetSolidBrush (box.ForeColor), 10, 0, text_format);
+ } else {
+ CPDrawStringDisabled (dc, box.Text, box.Font, box.ForeColor,
+ new RectangleF (10, 0, width, box.Font.Height), text_format);
+ }
+ text_format.Dispose ();
+ }
+
+ public override Size GroupBoxDefaultSize {
+ get {
+ return new Size (200,100);
+ }
+ }
+ #endregion
+
+ #region HScrollBar
+ public override Size HScrollBarDefaultSize {
+ get {
+ return new Size (80, this.ScrollBarButtonSize);
+ }
+ }
+
+ #endregion // HScrollBar
+
+ #region Label
+ public override void DrawLabel (Graphics dc, Rectangle clip_rectangle, Label label)
+ {
+ dc.FillRectangle (ResPool.GetSolidBrush (label.BackColor), clip_rectangle);
+
+ if (label.Enabled) {
+ dc.DrawString (label.Text, label.Font, ResPool.GetSolidBrush (label.ForeColor), clip_rectangle, label.string_format);
+ } else {
+ ControlPaint.DrawStringDisabled (dc, label.Text, label.Font, label.ForeColor, clip_rectangle, label.string_format);
+ }
+
+ }
+
+ public override Size LabelDefaultSize {
+ get {
+ return new Size (100, 23);
+ }
+ }
+ #endregion // Label
+
+ #region LinkLabel
+ public override void DrawLinkLabel (Graphics dc, Rectangle clip_rectangle, LinkLabel label)
+ {
+ Color color;
+
+ dc.FillRectangle (ResPool.GetSolidBrush (label.BackColor), clip_rectangle);
+
+ for (int i = 0; i < label.num_pieces; i++) {
+
+ if (clip_rectangle.IntersectsWith (label.pieces[i].rect) == false) {
+ continue;
+ }
+
+ color = label.GetLinkColor (label.pieces[i], i);
+
+ if (label.pieces[i].link == null)
+ dc.DrawString (label.pieces[i].text, label.GetPieceFont (label.pieces[i]), ResPool.GetSolidBrush (Color.Black),
+ label.pieces[i].rect.X, label.pieces[i].rect.Y);
+ else
+ dc.DrawString (label.pieces[i].text, label.GetPieceFont (label.pieces[i]), ResPool.GetSolidBrush (color),
+ label.pieces[i].rect.X, label.pieces[i].rect.Y);
+
+ if (label.pieces[i].focused) {
+ CPDrawFocusRectangle (dc, label.pieces[i].rect, label.ForeColor, label.BackColor);
+ }
+ }
+
+ }
+ #endregion // LinkLabel
+ #region ListBox
+
+ // Drawing
+
+ private int DrawListBoxDecorationSize (BorderStyle border_style)
+ {
+ switch (border_style) {
+ case BorderStyle.Fixed3D:
+ return 2;
+ case BorderStyle.FixedSingle:
+ return 1;
+ case BorderStyle.None:
+ default:
+ break;
+ }
+
+ return 0;
+ }
+
+ // Sizing
+ public override void DrawListBoxItem (ListBox ctrl, DrawItemEventArgs e)
+ {
+ Color back_color, fore_color;
+ StringFormat string_format = ctrl.GetFormatString ();
+
+ if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
+ back_color = ColorHighlight;
+ fore_color = ColorHighlightText;
+ }
+ else {
+ back_color = e.BackColor;
+ fore_color = e.ForeColor;
+ }
+
+ e.Graphics.FillRectangle (ResPool.GetSolidBrush
+ (back_color), e.Bounds);
+
+ e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
+ ResPool.GetSolidBrush (fore_color),
+ e.Bounds.X, e.Bounds.Y, string_format);
+
+ if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
+ CPDrawFocusRectangle (e.Graphics, e.Bounds,
+ fore_color, back_color);
+ }
+ }
+
+ #endregion ListBox
+
+ #region ListView
+ // Drawing
+ public override void DrawListViewItems (Graphics dc, Rectangle clip, ListView control)
+ {
+ bool details = control.View == View.Details;
+
+ dc.FillRectangle (ResPool.GetSolidBrush (control.BackColor), clip);
+ int first = control.FirstVisibleIndex;
+
+ for (int i = first; i <= control.LastVisibleIndex; i ++) {
+ if (clip.IntersectsWith (control.Items[i].GetBounds (ItemBoundsPortion.Entire)))
+ DrawListViewItem (dc, control, control.Items [i]);
+ }
+
+ // draw the gridlines
+ if (details && control.GridLines) {
+ int top = (control.HeaderStyle == ColumnHeaderStyle.None) ?
+ 2 : control.Font.Height + 2;
+
+ // draw vertical gridlines
+ foreach (ColumnHeader col in control.Columns)
+ dc.DrawLine (this.ResPool.GetPen (this.ColorControl),
+ col.Rect.Right, top,
+ col.Rect.Right, control.TotalHeight);
+ // draw horizontal gridlines
+ ListViewItem last_item = null;
+ foreach (ListViewItem item in control.Items) {
+ dc.DrawLine (this.ResPool.GetPen (this.ColorControl),
+ item.GetBounds (ItemBoundsPortion.Entire).Left, item.GetBounds (ItemBoundsPortion.Entire).Top,
+ control.TotalWidth, item.GetBounds (ItemBoundsPortion.Entire).Top);
+ last_item = item;
+ }
+
+ // draw a line after at the bottom of the last item
+ if (last_item != null) {
+ dc.DrawLine (this.ResPool.GetPen (this.ColorControl),
+ last_item.GetBounds (ItemBoundsPortion.Entire).Left,
+ last_item.GetBounds (ItemBoundsPortion.Entire).Bottom,
+ control.TotalWidth,
+ last_item.GetBounds (ItemBoundsPortion.Entire).Bottom);
+ }
+ }
+
+ dc.ResetClip ();
+
+ // Draw corner between the two scrollbars
+ if (control.h_scroll.Visible == true && control.h_scroll.Visible == true) {
+ Rectangle rect = new Rectangle ();
+ rect.X = control.h_scroll.Location.X + control.h_scroll.Width;
+ rect.Width = control.v_scroll.Width;
+ rect.Y = control.v_scroll.Location.Y + control.v_scroll.Height;
+ rect.Height = control.h_scroll.Height;
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), rect);
+ }
+
+ }
+
+ public override void DrawListViewHeader (Graphics dc, Rectangle clip, ListView control)
+ {
+ bool details = (control.View == View.Details);
+
+ // border is drawn directly in the Paint method
+ if (details && control.HeaderStyle != ColumnHeaderStyle.None) {
+ dc.FillRectangle (ResPool.GetSolidBrush (control.BackColor),
+ 0, 0, control.TotalWidth, control.Font.Height + 5);
+ if (control.Columns.Count > 0) {
+ foreach (ColumnHeader col in control.Columns) {
+ Rectangle rect = col.Rect;
+ rect.X -= control.h_marker;
+ ButtonState state;
+ if (control.HeaderStyle == ColumnHeaderStyle.Clickable)
+ state = col.Pressed ? ButtonState.Pushed : ButtonState.Normal;
+ else
+ state = ButtonState.Flat;
+ this.CPDrawButton (dc, rect, state);
+ rect.X += 3;
+ rect.Width -= 8;
+ if (rect.Width <= 0)
+ continue;
+ dc.DrawString (col.Text, DefaultFont,
+ ResPool.GetSolidBrush (ColorControlText),
+ rect, col.Format);
+ }
+ }
+ }
+ }
+
+ public override void DrawListViewHeaderDragDetails (Graphics dc, ListView view, ColumnHeader col, int target_x)
+ {
+ Rectangle rect = col.Rect;
+ rect.X -= view.h_marker;
+ Color color = Color.FromArgb (0x7f, ColorControlDark.R, ColorControlDark.G, ColorControlDark.B);
+ dc.FillRectangle (ResPool.GetSolidBrush (color), rect);
+ rect.X += 3;
+ rect.Width -= 8;
+ if (rect.Width <= 0)
+ return;
+ color = Color.FromArgb (0x7f, ColorControlText.R, ColorControlText.G, ColorControlText.B);
+ dc.DrawString (col.Text, DefaultFont, ResPool.GetSolidBrush (color), rect, col.Format);
+ Pen pen = new Pen (ColorHighlight, 2);
+ dc.DrawLine (pen, target_x, 0, target_x, col.Rect.Height);
+ }
+
+ protected virtual void DrawListViewItem (Graphics dc, ListView control, ListViewItem item)
+ {
+ int col_offset;
+ if (control.View == View.Details && control.Columns.Count > 0)
+ col_offset = control.Columns [0].Rect.X;
+ else
+ col_offset = 0;
+
+ Rectangle rect_checkrect = item.CheckRectReal;
+ rect_checkrect.X += col_offset;
+ Rectangle icon_rect = item.GetBounds (ItemBoundsPortion.Icon);
+ icon_rect.X += col_offset;
+ Rectangle full_rect = item.GetBounds (ItemBoundsPortion.Entire);
+ full_rect.X += col_offset;
+ Rectangle text_rect = item.GetBounds (ItemBoundsPortion.Label);
+ text_rect.X += col_offset;
+
+ if (control.CheckBoxes) {
+ if (control.StateImageList == null) {
+ // Make sure we've got at least a line width of 1
+ int check_wd = Math.Max (3, rect_checkrect.Width / 6);
+ int scale = Math.Max (1, rect_checkrect.Width / 12);
+
+ // set the checkbox background
+ dc.FillRectangle (this.ResPool.GetSolidBrush (this.ColorWindow),
+ rect_checkrect);
+ // define a rectangle inside the border area
+ Rectangle rect = new Rectangle (rect_checkrect.X + 2,
+ rect_checkrect.Y + 2,
+ rect_checkrect.Width - 4,
+ rect_checkrect.Height - 4);
+ Pen pen = new Pen (this.ColorWindowText, 2);
+ dc.DrawRectangle (pen, rect);
+
+ // Need to draw a check-mark
+ if (item.Checked) {
+ pen.Width = 1;
+ // adjustments to get the check-mark at the right place
+ rect.X ++; rect.Y ++;
+ // following logic is taken from DrawFrameControl method
+ for (int i = 0; i < check_wd; i++) {
+ dc.DrawLine (pen, rect.Left + check_wd / 2,
+ rect.Top + check_wd + i,
+ rect.Left + check_wd / 2 + 2 * scale,
+ rect.Top + check_wd + 2 * scale + i);
+ dc.DrawLine (pen,
+ rect.Left + check_wd / 2 + 2 * scale,
+ rect.Top + check_wd + 2 * scale + i,
+ rect.Left + check_wd / 2 + 6 * scale,
+ rect.Top + check_wd - 2 * scale + i);
+ }
+ }
+ }
+ else {
+ if (item.Checked && control.StateImageList.Images.Count > 1)
+ control.StateImageList.Draw (dc,
+ rect_checkrect.Location, 1);
+ else if (! item.Checked && control.StateImageList.Images.Count > 0)
+ control.StateImageList.Draw (dc,
+ rect_checkrect.Location, 0);
+ }
+ }
+
+ if (control.View == View.LargeIcon) {
+ if (control.LargeImageList == null) {
+ Pen pen = new Pen (ColorWindowText, 2);
+ dc.DrawLine (pen, icon_rect.Left, icon_rect.Y, icon_rect.Left + 11, icon_rect.Y);
+ } else if (item.ImageIndex > -1 && item.ImageIndex < control.LargeImageList.Images.Count)
+ control.LargeImageList.Draw (dc, icon_rect.Location, item.ImageIndex);
+ } else {
+ if (item.ImageIndex > -1 && control.SmallImageList != null &&
+ item.ImageIndex < control.SmallImageList.Images.Count)
+ control.SmallImageList.Draw (dc, icon_rect.Location, item.ImageIndex);
+ }
+
+ // draw the item text
+ // format for the item text
+ StringFormat format = new StringFormat ();
+ if (control.View == View.SmallIcon)
+ format.LineAlignment = StringAlignment.Near;
+ else
+ format.LineAlignment = StringAlignment.Center;
+ if (control.View == View.LargeIcon)
+ format.Alignment = StringAlignment.Center;
+ else
+ format.Alignment = StringAlignment.Near;
+
+ if (!control.LabelWrap)
+ format.FormatFlags = StringFormatFlags.NoWrap;
+
+ if (item.Selected) {
+ if (control.View == View.Details) {
+ if (control.FullRowSelect) {
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorHighlight), text_rect);
+ }
+ else {
+ Size text_size = Size.Ceiling (dc.MeasureString (item.Text,
+ item.Font));
+ text_rect.Width = text_size.Width;
+ dc.FillRectangle (this.ResPool.GetSolidBrush
+ (this.ColorHighlight), text_rect);
+ }
+ }
+ else {
+ /*Size text_size = Size.Ceiling (dc.MeasureString (item.Text,
+ item.Font));
+ Point loc = text_rect.Location;
+ loc.X += (text_rect.Width - text_size.Width) / 2;
+ text_rect.Width = text_size.Width;*/
+ dc.FillRectangle (this.ResPool.GetSolidBrush (this.ColorHighlight),
+ text_rect);
+ }
+ }
+ else
+ dc.FillRectangle (ResPool.GetSolidBrush (item.BackColor), text_rect);
+
+ if (item.Text != null && item.Text.Length > 0) {
+ if (item.Selected)
+ dc.DrawString (item.Text, item.Font, this.ResPool.GetSolidBrush
+ (this.ColorHighlightText), text_rect, format);
+ else
+ dc.DrawString (item.Text, item.Font, this.ResPool.GetSolidBrush
+ (item.ForeColor), text_rect, format);
+ }
+
+ if (control.View == View.Details && control.Columns.Count > 0) {
+ // draw subitems for details view
+ ListViewItem.ListViewSubItemCollection subItems = item.SubItems;
+ int count = (control.Columns.Count < subItems.Count ?
+ control.Columns.Count : subItems.Count);
+
+ if (count > 0) {
+ ColumnHeader col;
+ ListViewItem.ListViewSubItem subItem;
+ Rectangle sub_item_rect = text_rect;
+
+ // set the format for subitems
+ format.FormatFlags = StringFormatFlags.NoWrap;
+
+ // 0th subitem is the item already drawn
+ for (int index = 1; index < count; index++) {
+ subItem = subItems [index];
+ col = control.Columns [index];
+ format.Alignment = col.Format.Alignment;
+ sub_item_rect.X = col.Rect.X - control.h_marker;
+ sub_item_rect.Width = col.Wd;
+ Rectangle sub_item_text_rect = sub_item_rect;
+ sub_item_text_rect.X += 3;
+ sub_item_text_rect.Width -= 6;
+
+ SolidBrush sub_item_back_br = null;
+ SolidBrush sub_item_fore_br = null;
+ Font sub_item_font = null;
+
+ if (item.UseItemStyleForSubItems) {
+ sub_item_back_br = ResPool.GetSolidBrush (item.BackColor);
+ sub_item_fore_br = ResPool.GetSolidBrush (item.ForeColor);
+ sub_item_font = item.Font;
+ } else {
+ sub_item_back_br = ResPool.GetSolidBrush (subItem.BackColor);
+ sub_item_fore_br = ResPool.GetSolidBrush (subItem.ForeColor);
+ sub_item_font = subItem.Font;
+ }
+
+ if (item.Selected && control.FullRowSelect) {
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorHighlight), sub_item_rect);
+ if (subItem.Text != null && subItem.Text.Length > 0)
+ dc.DrawString (subItem.Text, sub_item_font,
+ this.ResPool.GetSolidBrush
+ (this.ColorHighlightText),
+ sub_item_text_rect, format);
+ } else {
+ dc.FillRectangle (sub_item_back_br, sub_item_rect);
+ if (subItem.Text != null && subItem.Text.Length > 0)
+ dc.DrawString (subItem.Text, sub_item_font,
+ sub_item_fore_br,
+ sub_item_text_rect, format);
+ }
+ }
+ }
+ }
+
+ if (item.Focused) {
+ Rectangle focus_rect = text_rect;
+ if (control.FullRowSelect && control.View == View.Details) {
+ int width = 0;
+ foreach (ColumnHeader col in control.Columns)
+ width += col.Width;
+ focus_rect = new Rectangle (0, full_rect.Y, width, full_rect.Height);
+ }
+ if (item.Selected)
+ CPDrawFocusRectangle (dc, focus_rect, ColorHighlightText, ColorHighlight);
+ else
+ CPDrawFocusRectangle (dc, focus_rect, control.ForeColor, control.BackColor);
+ }
+
+ format.Dispose ();
+ }
+
+ // Sizing
+ public override Size ListViewCheckBoxSize {
+ get { return new Size (16, 16); }
+ }
+
+ public override int ListViewColumnHeaderHeight {
+ get { return 16; }
+ }
+
+ public override int ListViewDefaultColumnWidth {
+ get { return 60; }
+ }
+
+ public override int ListViewVerticalSpacing {
+ get { return 22; }
+ }
+
+ public override int ListViewEmptyColumnWidth {
+ get { return 10; }
+ }
+
+ public override int ListViewHorizontalSpacing {
+ get { return 10; }
+ }
+
+ public override Size ListViewDefaultSize {
+ get { return new Size (121, 97); }
+ }
+ #endregion // ListView
+
+ #region Menus
+ public override void CalcItemSize (Graphics dc, MenuItem item, int y, int x, bool menuBar)
+ {
+ item.X = x;
+ item.Y = y;
+
+ if (item.Visible == false) {
+ item.Width = 0;
+ item.Height = 0;
+ return;
+ }
+
+ if (item.Separator == true) {
+ item.Height = SEPARATOR_HEIGHT / 2;
+ item.Width = -1;
+ return;
+ }
+
+ if (item.MeasureEventDefined) {
+ MeasureItemEventArgs mi = new MeasureItemEventArgs (dc, item.Index);
+ item.PerformMeasureItem (mi);
+ item.Height = mi.ItemHeight;
+ item.Width = mi.ItemWidth;
+ return;
+ } else {
+ SizeF size;
+ size = dc.MeasureString (item.Text, MenuFont);
+ item.Width = (int) size.Width;
+ item.Height = (int) size.Height;
+
+ if (!menuBar) {
+ if (item.Shortcut != Shortcut.None && item.ShowShortcut) {
+ item.XTab = MenuCheckSize.Width + MENU_TAB_SPACE + (int) size.Width;
+ size = dc.MeasureString (" " + item.GetShortCutText (), MenuFont);
+ item.Width += MENU_TAB_SPACE + (int) size.Width;
+ }
+
+ item.Width += 4 + (MenuCheckSize.Width * 2);
+ } else {
+ item.Width += MENU_BAR_ITEMS_SPACE;
+ x += item.Width;
+ }
+
+ if (item.Height < MenuHeight)
+ item.Height = MenuHeight;
+ }
+ }
+
+ // Updates the menu rect and returns the height
+ public override int CalcMenuBarSize (Graphics dc, Menu menu, int width)
+ {
+ int x = 0;
+ int y = 0;
+ menu.Height = 0;
+
+ foreach (MenuItem item in menu.MenuItems) {
+
+ CalcItemSize (dc, item, y, x, true);
+
+ if (x + item.Width > width) {
+ item.X = 0;
+ y += item.Height;
+ item.Y = y;
+ x = 0;
+ }
+
+ x += item.Width;
+ item.MenuBar = true;
+
+ if (y + item.Height > menu.Height)
+ menu.Height = item.Height + y;
+ }
+
+ menu.Width = width;
+ return menu.Height;
+ }
+
+ public override void CalcPopupMenuSize (Graphics dc, Menu menu)
+ {
+ int x = 3;
+ int start = 0;
+ int i, n, y, max;
+
+ menu.Height = 0;
+
+ while (start < menu.MenuItems.Count) {
+ y = 2;
+ max = 0;
+ for (i = start; i < menu.MenuItems.Count; i++) {
+ MenuItem item = menu.MenuItems [i];
+
+ if ((i != start) && (item.Break || item.BarBreak))
+ break;
+
+ CalcItemSize (dc, item, y, x, false);
+ y += item.Height;
+
+ if (item.Width > max)
+ max = item.Width;
+ }
+
+ // Replace the -1 by the menu width (separators)
+ for (n = start; n < i; n++, start++)
+ menu.MenuItems [n].Width = max;
+
+ if (y > menu.Height)
+ menu.Height = y;
+
+ x+= max;
+ }
+
+ menu.Width = x;
+
+ //space for border
+ menu.Width += 2;
+ menu.Height += 2;
+
+ menu.Width += SM_CXBORDER;
+ menu.Height += SM_CYBORDER;
+ }
+
+ // Draws a menu bar in a window
+ public override void DrawMenuBar (Graphics dc, Menu menu, Rectangle rect)
+ {
+ if (menu.Height == 0)
+ CalcMenuBarSize (dc, menu, rect.Width);
+
+ bool keynav = (menu as MainMenu).tracker.Navigating;
+ HotkeyPrefix hp = always_draw_hotkeys || keynav ? HotkeyPrefix.Show : HotkeyPrefix.Hide;
+ string_format_menu_menubar_text.HotkeyPrefix = hp;
+ string_format_menu_text.HotkeyPrefix = hp;
+
+ rect.Height = menu.Height;
+ dc.FillRectangle (ResPool.GetSolidBrush(ColorMenu), rect);
+
+ for (int i = 0; i < menu.MenuItems.Count; i++) {
+ MenuItem item = menu.MenuItems [i];
+ Rectangle item_rect = item.bounds;
+ item_rect.X += rect.X;
+ item_rect.Y += rect.Y;
+ item.MenuHeight = menu.Height;
+ item.PerformDrawItem (new DrawItemEventArgs (dc, MenuFont, item_rect, i, item.Status));
+ }
+ }
+
+ Bitmap CreateGlyphBitmap (Size size, MenuGlyph glyph, Color color)
+ {
+ Color bg_color;
+ if (color.R == 0 && color.G == 0 && color.B == 0)
+ bg_color = Color.White;
+ else
+ bg_color = Color.Black;
+ Bitmap bmp = new Bitmap (size.Width, size.Height);
+ Graphics gr = Graphics.FromImage (bmp);
+ Rectangle rect = new Rectangle (Point.Empty, size);
+ gr.FillRectangle (ResPool.GetSolidBrush (bg_color), rect);
+ CPDrawMenuGlyph (gr, rect, glyph, color);
+ bmp.MakeTransparent (bg_color);
+ gr.Dispose ();
+ return bmp;
+ }
+
+ public override void DrawMenuItem (MenuItem item, DrawItemEventArgs e)
+ {
+ StringFormat string_format;
+ Rectangle rect_text = e.Bounds;
+
+ if (item.Visible == false)
+ return;
+
+ if (item.MenuBar)
+ string_format = string_format_menu_menubar_text;
+ else
+ string_format = string_format_menu_text;
+
+ if (item.Separator == true) {
+ e.Graphics.DrawLine (ResPool.GetPen (ColorControlDark),
+ e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width, e.Bounds.Y);
+
+ e.Graphics.DrawLine (ResPool.GetPen (ColorControlLight),
+ e.Bounds.X, e.Bounds.Y + 1, e.Bounds.X + e.Bounds.Width, e.Bounds.Y + 1);
+
+ return;
+ }
+
+ if (!item.MenuBar)
+ rect_text.X += MenuCheckSize.Width;
+
+ if (item.BarBreak) { /* Draw vertical break bar*/
+ Rectangle rect = e.Bounds;
+ rect.Y++;
+ rect.Width = 3;
+ rect.Height = item.MenuHeight - 6;
+
+ e.Graphics.DrawLine (ResPool.GetPen (ColorControlDark),
+ rect.X, rect.Y , rect.X, rect.Y + rect.Height);
+
+ e.Graphics.DrawLine (ResPool.GetPen (ColorControlLight),
+ rect.X + 1, rect.Y , rect.X +1, rect.Y + rect.Height);
+ }
+
+ Color color_text;
+ Color color_back;
+
+ if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
+ color_text = ColorHighlightText;
+ color_back = ColorHighlight;
+ } else {
+ color_text = ColorMenuText;
+ color_back = ColorMenu;
+ }
+
+ /* Draw background */
+ Rectangle rect_back = e.Bounds;
+ rect_back.X++;
+ rect_back.Width -=2;
+ e.Graphics.FillRectangle (ResPool.GetSolidBrush (color_back), rect_back);
+
+ if (item.Enabled) {
+ e.Graphics.DrawString (item.Text, e.Font,
+ ResPool.GetSolidBrush (color_text),
+ rect_text, string_format);
+
+ if (!item.MenuBar && item.Shortcut != Shortcut.None && item.ShowShortcut) {
+ string str = item.GetShortCutText ();
+ Rectangle rect = rect_text;
+ rect.X = item.XTab;
+ rect.Width -= item.XTab;
+
+ e.Graphics.DrawString (str, e.Font, ResPool.GetSolidBrush (color_text),
+ rect, string_format_menu_shortcut);
+ }
+ } else {
+ ControlPaint.DrawStringDisabled (e.Graphics, item.Text, e.Font,
+ Color.Black, rect_text, string_format);
+ }
+
+ /* Draw arrow */
+ if (item.MenuBar == false && item.IsPopup || item.MdiList) {
+
+ int cx = MenuCheckSize.Width;
+ int cy = MenuCheckSize.Height;
+ Bitmap bmp = CreateGlyphBitmap (new Size (cx, cy), MenuGlyph.Arrow, color_text);
+
+ if (item.Enabled) {
+ e.Graphics.DrawImage (bmp, e.Bounds.X + e.Bounds.Width - cx,
+ e.Bounds.Y + ((e.Bounds.Height - cy) /2));
+ } else {
+ ControlPaint.DrawImageDisabled (e.Graphics, bmp, e.Bounds.X + e.Bounds.Width - cx,
+ e.Bounds.Y + ((e.Bounds.Height - cy) /2), color_back);
+ }
+
+ bmp.Dispose ();
+ }
+
+ /* Draw checked or radio */
+ if (item.MenuBar == false && item.Checked) {
+
+ Rectangle area = e.Bounds;
+ int cx = MenuCheckSize.Width;
+ int cy = MenuCheckSize.Height;
+ Bitmap bmp = CreateGlyphBitmap (new Size (cx, cy), item.RadioCheck ? MenuGlyph.Bullet : MenuGlyph.Checkmark, color_text);
+
+ e.Graphics.DrawImage (bmp, area.X, e.Bounds.Y + ((e.Bounds.Height - cy) / 2));
+
+ bmp.Dispose ();
+ }
+ }
+
+ public override void DrawPopupMenu (Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect)
+ {
+
+ dc.FillRectangle (ResPool.GetSolidBrush
+ (ColorMenu), cliparea);
+
+ /* Draw menu borders */
+ dc.DrawLine (ResPool.GetPen (ColorHighlightText),
+ rect.X, rect.Y, rect.X + rect.Width, rect.Y);
+
+ dc.DrawLine (ResPool.GetPen (ColorHighlightText),
+ rect.X, rect.Y, rect.X, rect.Y + rect.Height);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDark),
+ rect.X + rect.Width - 1 , rect.Y , rect.X + rect.Width - 1, rect.Y + rect.Height);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark),
+ rect.X + rect.Width, rect.Y , rect.X + rect.Width, rect.Y + rect.Height);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDark),
+ rect.X , rect.Y + rect.Height - 1 , rect.X + rect.Width - 1, rect.Y + rect.Height -1);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark),
+ rect.X , rect.Y + rect.Height, rect.X + rect.Width - 1, rect.Y + rect.Height);
+
+ for (int i = 0; i < menu.MenuItems.Count; i++)
+ if (cliparea.IntersectsWith (menu.MenuItems [i].bounds)) {
+ MenuItem item = menu.MenuItems [i];
+ item.MenuHeight = menu.Height;
+ item.PerformDrawItem (new DrawItemEventArgs (dc, MenuFont,
+ item.bounds, i, item.Status));
+ }
+ }
+
+ #endregion // Menus
+
+ #region MonthCalendar
+
+ // draw the month calendar
+ public override void DrawMonthCalendar(Graphics dc, Rectangle clip_rectangle, MonthCalendar mc)
+ {
+ Rectangle client_rectangle = mc.ClientRectangle;
+ Size month_size = mc.SingleMonthSize;
+ // cache local copies of Marshal-by-ref internal members (gets around error CS0197)
+ Size calendar_spacing = (Size)((object)mc.calendar_spacing);
+ Size date_cell_size = (Size)((object)mc.date_cell_size);
+
+ // draw the singlecalendars
+ int x_offset = 1;
+ int y_offset = 1;
+ // adjust for the position of the specific month
+ for (int i=0; i < mc.CalendarDimensions.Height; i++)
+ {
+ if (i > 0)
+ {
+ y_offset += month_size.Height + calendar_spacing.Height;
+ }
+ // now adjust for x position
+ for (int j=0; j < mc.CalendarDimensions.Width; j++)
+ {
+ if (j > 0)
+ {
+ x_offset += month_size.Width + calendar_spacing.Width;
+ }
+ else
+ {
+ x_offset = 1;
+ }
+
+ Rectangle month_rect = new Rectangle (x_offset, y_offset, month_size.Width, month_size.Height);
+ if (month_rect.IntersectsWith (clip_rectangle)) {
+ DrawSingleMonth (
+ dc,
+ clip_rectangle,
+ month_rect,
+ mc,
+ i,
+ j);
+ }
+ }
+ }
+
+ Rectangle bottom_rect = new Rectangle (
+ client_rectangle.X,
+ Math.Max(client_rectangle.Bottom - date_cell_size.Height - 3, 0),
+ client_rectangle.Width,
+ date_cell_size.Height + 2);
+ // draw the today date if it's set
+ if (mc.ShowToday && bottom_rect.IntersectsWith (clip_rectangle))
+ {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), bottom_rect);
+ if (mc.ShowToday) {
+ int today_offset = 5;
+ if (mc.ShowTodayCircle)
+ {
+ Rectangle today_circle_rect = new Rectangle (
+ client_rectangle.X + 5,
+ Math.Max(client_rectangle.Bottom - date_cell_size.Height - 2, 0),
+ date_cell_size.Width,
+ date_cell_size.Height);
+ DrawTodayCircle (dc, today_circle_rect);
+ today_offset += date_cell_size.Width + 5;
+ }
+ // draw today's date
+ StringFormat text_format = new StringFormat();
+ text_format.LineAlignment = StringAlignment.Center;
+ text_format.Alignment = StringAlignment.Near;
+ Font bold_font = new Font (mc.Font.FontFamily, mc.Font.Size, mc.Font.Style | FontStyle.Bold);
+ Rectangle today_rect = new Rectangle (
+ today_offset + client_rectangle.X,
+ Math.Max(client_rectangle.Bottom - date_cell_size.Height, 0),
+ Math.Max(client_rectangle.Width - today_offset, 0),
+ date_cell_size.Height);
+ dc.DrawString ("Today: " + DateTime.Now.ToShortDateString(), bold_font, ResPool.GetSolidBrush (mc.ForeColor), today_rect, text_format);
+ text_format.Dispose ();
+ bold_font.Dispose ();
+ }
+ }
+
+ // finally paint the borders of the calendars as required
+ for (int i = 0; i <= mc.CalendarDimensions.Width; i++) {
+ if (i == 0 && clip_rectangle.X == client_rectangle.X) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Y, 1, client_rectangle.Height));
+ } else if (i == mc.CalendarDimensions.Width && clip_rectangle.Right == client_rectangle.Right) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.Right-1, client_rectangle.Y, 1, client_rectangle.Height));
+ } else {
+ Rectangle rect = new Rectangle (
+ client_rectangle.X + (month_size.Width*i) + (calendar_spacing.Width * (i-1)) + 1,
+ client_rectangle.Y,
+ calendar_spacing.Width,
+ client_rectangle.Height);
+ if (i < mc.CalendarDimensions.Width && i > 0 && clip_rectangle.IntersectsWith (rect)) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), rect);
+ }
+ }
+ }
+ for (int i = 0; i <= mc.CalendarDimensions.Height; i++) {
+ if (i == 0 && clip_rectangle.Y == client_rectangle.Y) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Y, client_rectangle.Width, 1));
+ } else if (i == mc.CalendarDimensions.Height && clip_rectangle.Bottom == client_rectangle.Bottom) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Bottom-1, client_rectangle.Width, 1));
+ } else {
+ Rectangle rect = new Rectangle (
+ client_rectangle.X,
+ client_rectangle.Y + (month_size.Height*i) + (calendar_spacing.Height*(i-1)) + 1,
+ client_rectangle.Width,
+ calendar_spacing.Height);
+ if (i < mc.CalendarDimensions.Height && i > 0 && clip_rectangle.IntersectsWith (rect)) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), rect);
+ }
+ }
+ }
+
+ // draw the drop down border if need
+ if (mc.owner != null) {
+ Rectangle bounds = mc.ClientRectangle;
+ if (clip_rectangle.Contains (mc.Location)) {
+ // find out if top or left line to draw
+ if(clip_rectangle.Contains (new Point (bounds.Left, bounds.Bottom))) {
+
+ dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Y, bounds.X, bounds.Bottom-1);
+ }
+ if(clip_rectangle.Contains (new Point (bounds.Right, bounds.Y))) {
+ dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Y, bounds.Right-1, bounds.Y);
+ }
+ }
+ if (clip_rectangle.Contains (new Point(bounds.Right, bounds.Bottom))) {
+ // find out if bottom or right line to draw
+ if(clip_rectangle.Contains (new Point (bounds.Left, bounds.Bottom))) {
+ dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Bottom-1, bounds.Right-1, bounds.Bottom-1);
+ }
+ if(clip_rectangle.Contains (new Point (bounds.Right, bounds.Y))) {
+ dc.DrawLine (SystemPens.ControlText, bounds.Right-1, bounds.Y, bounds.Right-1, bounds.Bottom-1);
+ }
+ }
+ }
+ }
+
+ // darws a single part of the month calendar (with one month)
+ private void DrawSingleMonth(Graphics dc, Rectangle clip_rectangle, Rectangle rectangle, MonthCalendar mc, int row, int col)
+ {
+ // cache local copies of Marshal-by-ref internal members (gets around error CS0197)
+ Size title_size = (Size)((object)mc.title_size);
+ Size date_cell_size = (Size)((object)mc.date_cell_size);
+ DateTime current_month = (DateTime)((object)mc.current_month);
+
+ // set up some standard string formating variables
+ StringFormat text_format = new StringFormat();
+ text_format.LineAlignment = StringAlignment.Center;
+ text_format.Alignment = StringAlignment.Center;
+
+
+ // draw the title back ground
+ DateTime this_month = current_month.AddMonths (row*mc.CalendarDimensions.Width+col);
+ Rectangle title_rect = new Rectangle(rectangle.X, rectangle.Y, title_size.Width, title_size.Height);
+ if (title_rect.IntersectsWith (clip_rectangle)) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), title_rect);
+ // draw the title
+ string title_text = this_month.ToString ("MMMM yyyy");
+ dc.DrawString (title_text, mc.Font, ResPool.GetSolidBrush (mc.TitleForeColor), title_rect, text_format);
+
+ // draw previous and next buttons if it's time
+ if (row == 0 && col == 0)
+ {
+ // draw previous button
+ DrawMonthCalendarButton (
+ dc,
+ rectangle,
+ mc,
+ title_size,
+ mc.button_x_offset,
+ (System.Drawing.Size)((object)mc.button_size),
+ true);
+ }
+ if (row == 0 && col == mc.CalendarDimensions.Width-1)
+ {
+ // draw next button
+ DrawMonthCalendarButton (
+ dc,
+ rectangle,
+ mc,
+ title_size,
+ mc.button_x_offset,
+ (System.Drawing.Size)((object)mc.button_size),
+ false);
+ }
+ }
+
+ // set the week offset and draw week nums if needed
+ int col_offset = (mc.ShowWeekNumbers) ? 1 : 0;
+ Rectangle day_name_rect = new Rectangle(
+ rectangle.X,
+ rectangle.Y + title_size.Height,
+ (7 + col_offset) * date_cell_size.Width,
+ date_cell_size.Height);
+ if (day_name_rect.IntersectsWith (clip_rectangle)) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), day_name_rect);
+ // draw the day names
+ DayOfWeek first_day_of_week = mc.GetDayOfWeek(mc.FirstDayOfWeek);
+ for (int i=0; i < 7; i++)
+ {
+ int position = i - (int) first_day_of_week;
+ if (position < 0)
+ {
+ position = 7 + position;
+ }
+ // draw it
+ Rectangle day_rect = new Rectangle(
+ day_name_rect.X + ((i + col_offset)* date_cell_size.Width),
+ day_name_rect.Y,
+ date_cell_size.Width,
+ date_cell_size.Height);
+ dc.DrawString (((DayOfWeek)i).ToString().Substring(0, 3), mc.Font, ResPool.GetSolidBrush (mc.TitleBackColor), day_rect, text_format);
+ }
+
+ // draw the vertical divider
+ int vert_divider_y = Math.Max(title_size.Height+ date_cell_size.Height-1, 0);
+ dc.DrawLine (
+ ResPool.GetPen (mc.ForeColor),
+ rectangle.X + (col_offset * date_cell_size.Width) + mc.divider_line_offset,
+ rectangle.Y + vert_divider_y,
+ rectangle.Right - mc.divider_line_offset,
+ rectangle.Y + vert_divider_y);
+ }
+
+
+ // draw the actual date items in the grid (including the week numbers)
+ Rectangle date_rect = new Rectangle (
+ rectangle.X,
+ rectangle.Y + title_size.Height + date_cell_size.Height,
+ date_cell_size.Width,
+ date_cell_size.Height);
+ int month_row_count = 0;
+ bool draw_week_num_divider = false;
+ DateTime current_date = mc.GetFirstDateInMonthGrid ( new DateTime (this_month.Year, this_month.Month, 1));
+ for (int i=0; i < 6; i++)
+ {
+ // establish if this row is in our clip_area
+ Rectangle row_rect = new Rectangle (
+ rectangle.X,
+ rectangle.Y + title_size.Height + (date_cell_size.Height * (i+1)),
+ date_cell_size.Width * 7,
+ date_cell_size.Height);
+ if (mc.ShowWeekNumbers) {
+ row_rect.Width += date_cell_size.Width;
+ }
+
+ bool draw_row = row_rect.IntersectsWith (clip_rectangle);
+ if (draw_row) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), row_rect);
+ }
+ // establish if this is a valid week to draw
+ if (mc.IsValidWeekToDraw (this_month, current_date, row, col)) {
+ month_row_count = i;
+ }
+
+ // draw the week number if required
+ if (mc.ShowWeekNumbers && month_row_count == i) {
+ if (!draw_week_num_divider) {
+ draw_week_num_divider = draw_row;
+ }
+ // get the week for this row
+ int week = mc.GetWeekOfYear (current_date);
+
+ if (draw_row) {
+ dc.DrawString (
+ week.ToString(),
+ mc.Font,
+ ResPool.GetSolidBrush (mc.TitleBackColor),
+ date_rect,
+ text_format);
+ }
+ date_rect.Offset(date_cell_size.Width, 0);
+ }
+
+ // only draw the days if we have to
+ if(month_row_count == i) {
+ for (int j=0; j < 7; j++)
+ {
+ if (draw_row) {
+ DrawMonthCalendarDate (
+ dc,
+ date_rect,
+ mc,
+ current_date,
+ this_month,
+ row,
+ col);
+ }
+
+ // move the day on
+ current_date = current_date.AddDays(1);
+ date_rect.Offset(date_cell_size.Width, 0);
+ }
+
+ // shift the rectangle down one row
+ int offset = (mc.ShowWeekNumbers) ? -8 : -7;
+ date_rect.Offset(offset*date_cell_size.Width, date_cell_size.Height);
+ }
+ }
+
+ // month_row_count is zero based, so add one
+ month_row_count++;
+
+ // draw week numbers if required
+ if (draw_week_num_divider) {
+ col_offset = 1;
+ dc.DrawLine (
+ ResPool.GetPen (mc.ForeColor),
+ rectangle.X + date_cell_size.Width - 1,
+ rectangle.Y + title_size.Height + date_cell_size.Height + mc.divider_line_offset,
+ rectangle.X + date_cell_size.Width - 1,
+ rectangle.Y + title_size.Height + date_cell_size.Height + (month_row_count * date_cell_size.Height) - mc.divider_line_offset);
+ }
+ text_format.Dispose ();
+ }
+
+ // draws the pervious or next button
+ private void DrawMonthCalendarButton (Graphics dc, Rectangle rectangle, MonthCalendar mc, Size title_size, int x_offset, Size button_size, bool is_previous)
+ {
+ bool is_clicked = false;
+ Rectangle button_rect;
+ Rectangle arrow_rect = new Rectangle (rectangle.X, rectangle.Y, 4, 7);
+ Point[] arrow_path = new Point[3];
+ // prepare the button
+ if (is_previous)
+ {
+ is_clicked = mc.is_previous_clicked;
+ button_rect = new Rectangle (
+ rectangle.X + 1 + x_offset,
+ rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
+ Math.Max(button_size.Width - 1, 0),
+ Math.Max(button_size.Height - 1, 0));
+ arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
+ arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
+ if (is_clicked) {
+ arrow_rect.Offset(1,1);
+ }
+ arrow_path[0] = new Point (arrow_rect.Right, arrow_rect.Y);
+ arrow_path[1] = new Point (arrow_rect.X, arrow_rect.Y + arrow_rect.Height/2);
+ arrow_path[2] = new Point (arrow_rect.Right, arrow_rect.Bottom);
+ }
+ else
+ {
+ is_clicked = mc.is_next_clicked;
+ button_rect = new Rectangle (
+ rectangle.Right - 1 - x_offset - button_size.Width,
+ rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
+ Math.Max(button_size.Width - 1, 0),
+ Math.Max(button_size.Height - 1, 0));
+ arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
+ arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
+ if (is_clicked) {
+ arrow_rect.Offset(1,1);
+ }
+ arrow_path[0] = new Point (arrow_rect.X, arrow_rect.Y);
+ arrow_path[1] = new Point (arrow_rect.Right, arrow_rect.Y + arrow_rect.Height/2);
+ arrow_path[2] = new Point (arrow_rect.X, arrow_rect.Bottom);
+ }
+
+ // fill the background
+ dc.FillRectangle (SystemBrushes.Control, button_rect);
+ // draw the border
+ if (is_clicked) {
+ dc.DrawRectangle (SystemPens.ControlDark, button_rect);
+ }
+ else {
+ CPDrawBorder3D (dc, button_rect, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
+ }
+ // draw the arrow
+ dc.FillPolygon (SystemBrushes.ControlText, arrow_path);
+ }
+
+
+ // draws one day in the calendar grid
+ private void DrawMonthCalendarDate (Graphics dc, Rectangle rectangle, MonthCalendar mc, DateTime date, DateTime month, int row, int col) {
+ Color date_color = mc.ForeColor;
+ Rectangle interior = new Rectangle (rectangle.X, rectangle.Y, Math.Max(rectangle.Width - 1, 0), Math.Max(rectangle.Height - 1, 0));
+
+ // find out if we are the lead of the first calendar or the trail of the last calendar
+ if (date.Year != month.Year || date.Month != month.Month) {
+ DateTime check_date = month.AddMonths (-1);
+ // check if it's the month before
+ if (check_date.Year == date.Year && check_date.Month == date.Month && row == 0 && col == 0) {
+ date_color = mc.TrailingForeColor;
+ } else {
+ // check if it's the month after
+ check_date = month.AddMonths (1);
+ if (check_date.Year == date.Year && check_date.Month == date.Month && row == mc.CalendarDimensions.Height-1 && col == mc.CalendarDimensions.Width-1) {
+ date_color = mc.TrailingForeColor;
+ } else {
+ return;
+ }
+ }
+ } else {
+ date_color = mc.ForeColor;
+ }
+
+
+ if (date == mc.SelectionStart && date == mc.SelectionEnd) {
+ // see if the date is in the start of selection
+ date_color = mc.BackColor;
+ // draw the left hand of the back ground
+ Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
+ dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 0, 359);
+ } else if (date == mc.SelectionStart) {
+ // see if the date is in the start of selection
+ date_color = mc.BackColor;
+ // draw the left hand of the back ground
+ Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
+ dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 90, 180);
+ // fill the other side as a straight rect
+ if (date < mc.SelectionEnd)
+ {
+ // use rectangle instead of rectangle to go all the way to edge of rect
+ selection_rect.X = (int) Math.Floor((double)(rectangle.X + rectangle.Width / 2));
+ selection_rect.Width = Math.Max(rectangle.Right - selection_rect.X, 0);
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
+ }
+ } else if (date == mc.SelectionEnd) {
+ // see if it is the end of selection
+ date_color = mc.BackColor;
+ // draw the left hand of the back ground
+ Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
+ dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 270, 180);
+ // fill the other side as a straight rect
+ if (date > mc.SelectionStart) {
+ selection_rect.X = rectangle.X;
+ selection_rect.Width = rectangle.Width - (rectangle.Width / 2);
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
+ }
+ } else if (date > mc.SelectionStart && date < mc.SelectionEnd) {
+ // now see if it's in the middle
+ date_color = mc.BackColor;
+ // draw the left hand of the back ground
+ Rectangle selection_rect = Rectangle.Inflate(rectangle, 0, -3);
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
+ }
+
+ // set up some standard string formating variables
+ StringFormat text_format = new StringFormat();
+ text_format.LineAlignment = StringAlignment.Center;
+ text_format.Alignment = StringAlignment.Center;
+
+
+ // establish if it's a bolded font
+ Font font;
+ if (mc.IsBoldedDate (date)) {
+ font = new Font (mc.Font.FontFamily, mc.Font.Size, mc.Font.Style | FontStyle.Bold);
+ } else {
+ font = mc.Font;
+ }
+
+ // just draw the date now
+ dc.DrawString (date.Day.ToString(), font, ResPool.GetSolidBrush (date_color), rectangle, text_format);
+
+ // today circle if needed
+ if (mc.ShowTodayCircle && date == DateTime.Now.Date) {
+ DrawTodayCircle (dc, interior);
+ }
+
+ // draw the selection grid
+ if (mc.is_date_clicked && mc.clicked_date == date) {
+ using (Pen pen = new Pen (Color.Black, 1) ) {
+ pen.DashStyle = DashStyle.Dot;
+ dc.DrawRectangle (pen, interior);
+ }
+ }
+ text_format.Dispose ();
+ }
+
+ private void DrawTodayCircle (Graphics dc, Rectangle rectangle) {
+ Color circle_color = Color.FromArgb (248, 0, 0);
+ // draw the left hand of the circle
+ Rectangle lhs_circle_rect = new Rectangle (rectangle.X + 1, rectangle.Y + 4, Math.Max(rectangle.Width - 2, 0), Math.Max(rectangle.Height - 5, 0));
+ Rectangle rhs_circle_rect = new Rectangle (rectangle.X + 1, rectangle.Y + 1, Math.Max(rectangle.Width - 2, 0), Math.Max(rectangle.Height - 2, 0));
+ Point [] curve_points = new Point [3];
+ curve_points [0] = new Point (lhs_circle_rect.X, rhs_circle_rect.Y + rhs_circle_rect.Height/12);
+ curve_points [1] = new Point (lhs_circle_rect.X + lhs_circle_rect.Width/9, rhs_circle_rect.Y);
+ curve_points [2] = new Point (lhs_circle_rect.X + lhs_circle_rect.Width/2 + 1, rhs_circle_rect.Y);
+
+ using (Pen pen = new Pen (circle_color, 2)) {
+ dc.DrawArc (pen, lhs_circle_rect, 90, 180);
+ dc.DrawArc (pen, rhs_circle_rect, 270, 180);
+ dc.DrawCurve (pen, curve_points);
+ dc.DrawLine (ResPool.GetPen (circle_color), curve_points [2], new Point (curve_points [2].X, lhs_circle_rect.Y));
+ }
+ }
+
+ #endregion // MonthCalendar
+
+ #region Panel
+ public override Size PanelDefaultSize {
+ get {
+ return new Size (200, 100);
+ }
+ }
+ #endregion // Panel
+
+ #region PictureBox
+ public override void DrawPictureBox (Graphics dc, Rectangle clip, PictureBox pb) {
+ Rectangle client = pb.ClientRectangle;
+
+ // FIXME - instead of drawing the whole picturebox every time
+ // intersect the clip rectangle with the drawn picture and only draw what's needed,
+ // Also, we only need a background fill where no image goes
+ if (pb.Image != null) {
+ switch (pb.SizeMode) {
+ case PictureBoxSizeMode.StretchImage:
+ dc.DrawImage (pb.Image, 0, 0, client.Width, client.Height);
+ break;
+
+ case PictureBoxSizeMode.CenterImage:
+ dc.FillRectangle(ResPool.GetSolidBrush(pb.BackColor), clip);
+ dc.DrawImage (pb.Image, (client.Width / 2) - (pb.Image.Width / 2), (client.Height / 2) - (pb.Image.Height / 2));
+ break;
+ default:
+ dc.FillRectangle(ResPool.GetSolidBrush(pb.BackColor), clip);
+ // Normal, AutoSize
+ dc.DrawImage(pb.Image, 0, 0, pb.Image.Width, pb.Image.Height);
+ break;
+ }
+
+ return;
+ }
+
+ // We only get here if no image is set. At least paint the background
+ dc.FillRectangle(ResPool.GetSolidBrush(pb.BackColor), clip);
+ }
+
+ public override Size PictureBoxDefaultSize {
+ get {
+ return new Size (100, 50);
+ }
+ }
+ #endregion // PictureBox
+
+ #region ProgressBar
+ public override void DrawProgressBar (Graphics dc, Rectangle clip_rect, ProgressBar ctrl)
+ {
+ Rectangle block_rect;
+ Rectangle client_area = ctrl.client_area;
+ int space_betweenblocks = 2;
+ int block_width;
+ int increment;
+ int barpos_pixels;
+
+ block_width = (client_area.Height * 2 ) / 3;
+ barpos_pixels = ((ctrl.Value - ctrl.Minimum) * client_area.Width) / (ctrl.Maximum - ctrl.Minimum);
+ increment = block_width + space_betweenblocks;
+
+ /* Draw border */
+ CPDrawBorder3D (dc, ctrl.ClientRectangle, Border3DStyle.SunkenInner, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom & ~Border3DSide.Middle, ColorControl);
+
+ /* Draw Blocks */
+ block_rect = new Rectangle (client_area.X, client_area.Y, block_width, client_area.Height);
+ while ((block_rect.X - client_area.X) < barpos_pixels) {
+
+ if (clip_rect.IntersectsWith (block_rect) == true) {
+ dc.FillRectangle (ResPool.GetSolidBrush (progressbarblock_color), block_rect);
+ }
+
+ block_rect.X += increment;
+ }
+ }
+
+ public override Size ProgressBarDefaultSize {
+ get {
+ return new Size (100, 23);
+ }
+ }
+
+ #endregion // ProgressBar
+
+ #region RadioButton
+ public override void DrawRadioButton (Graphics dc, Rectangle clip_rectangle, RadioButton radio_button) {
+ StringFormat text_format;
+ Rectangle client_rectangle;
+ Rectangle text_rectangle;
+ Rectangle radiobutton_rectangle;
+ int radiobutton_size = 12;
+ int radiobutton_space = 4;
+
+ client_rectangle = radio_button.ClientRectangle;
+ text_rectangle = client_rectangle;
+ radiobutton_rectangle = new Rectangle(text_rectangle.X, text_rectangle.Y, radiobutton_size, radiobutton_size);
+
+ text_format = new StringFormat();
+ text_format.Alignment = StringAlignment.Near;
+ text_format.LineAlignment = StringAlignment.Center;
+ text_format.HotkeyPrefix = HotkeyPrefix.Show;
+
+ /* Calculate the position of text and checkbox rectangle */
+ if (radio_button.appearance!=Appearance.Button) {
+ switch(radio_button.radiobutton_alignment) {
+ case ContentAlignment.BottomCenter: {
+ radiobutton_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-radiobutton_size/2;
+ radiobutton_rectangle.Y=client_rectangle.Bottom-radiobutton_size;
+ text_rectangle.X=client_rectangle.X;
+ text_rectangle.Width=client_rectangle.Width;
+ text_rectangle.Height=client_rectangle.Height-radiobutton_size-radiobutton_space;
+ break;
+ }
+
+ case ContentAlignment.BottomLeft: {
+ radiobutton_rectangle.X=client_rectangle.Left;
+ radiobutton_rectangle.Y=client_rectangle.Bottom-radiobutton_size;
+ text_rectangle.X=client_rectangle.X+radiobutton_size+radiobutton_space;
+ text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
+ break;
+ }
+
+ case ContentAlignment.BottomRight: {
+ radiobutton_rectangle.X=client_rectangle.Right-radiobutton_size;
+ radiobutton_rectangle.Y=client_rectangle.Bottom-radiobutton_size;
+ text_rectangle.X=client_rectangle.X;
+ text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
+ break;
+ }
+
+ case ContentAlignment.MiddleCenter: {
+ radiobutton_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-radiobutton_size/2;
+ radiobutton_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-radiobutton_size/2;
+ text_rectangle.X=client_rectangle.X;
+ text_rectangle.Width=client_rectangle.Width;
+ break;
+ }
+
+ default:
+ case ContentAlignment.MiddleLeft: {
+ radiobutton_rectangle.X=client_rectangle.Left;
+ radiobutton_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-radiobutton_size/2;
+ text_rectangle.X=client_rectangle.X+radiobutton_size+radiobutton_space;
+ text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
+ break;
+ }
+
+ case ContentAlignment.MiddleRight: {
+ radiobutton_rectangle.X=client_rectangle.Right-radiobutton_size;
+ radiobutton_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-radiobutton_size/2;
+ text_rectangle.X=client_rectangle.X;
+ text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
+ break;
+ }
+
+ case ContentAlignment.TopCenter: {
+ radiobutton_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-radiobutton_size/2;
+ radiobutton_rectangle.Y=client_rectangle.Top;
+ text_rectangle.X=client_rectangle.X;
+ text_rectangle.Y=radiobutton_size+radiobutton_space;
+ text_rectangle.Width=client_rectangle.Width;
+ text_rectangle.Height=client_rectangle.Height-radiobutton_size-radiobutton_space;
+ break;
+ }
+
+ case ContentAlignment.TopLeft: {
+ radiobutton_rectangle.X=client_rectangle.Left;
+ radiobutton_rectangle.Y=client_rectangle.Top;
+ text_rectangle.X=client_rectangle.X+radiobutton_size+radiobutton_space;
+ text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
+ break;
+ }
+
+ case ContentAlignment.TopRight: {
+ radiobutton_rectangle.X=client_rectangle.Right-radiobutton_size;
+ radiobutton_rectangle.Y=client_rectangle.Top;
+ text_rectangle.X=client_rectangle.X;
+ text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
+ break;
+ }
+ }
+ } else {
+ text_rectangle.X=client_rectangle.X;
+ text_rectangle.Width=client_rectangle.Width;
+ }
+
+ /* Set the horizontal alignment of our text */
+ switch(radio_button.text_alignment) {
+ case ContentAlignment.BottomLeft:
+ case ContentAlignment.MiddleLeft:
+ case ContentAlignment.TopLeft: {
+ text_format.Alignment=StringAlignment.Near;
+ break;
+ }
+
+ case ContentAlignment.BottomCenter:
+ case ContentAlignment.MiddleCenter:
+ case ContentAlignment.TopCenter: {
+ text_format.Alignment=StringAlignment.Center;
+ break;
+ }
+
+ case ContentAlignment.BottomRight:
+ case ContentAlignment.MiddleRight:
+ case ContentAlignment.TopRight: {
+ text_format.Alignment=StringAlignment.Far;
+ break;
+ }
+ }
+
+ /* Set the vertical alignment of our text */
+ switch(radio_button.text_alignment) {
+ case ContentAlignment.TopLeft:
+ case ContentAlignment.TopCenter:
+ case ContentAlignment.TopRight: {
+ text_format.LineAlignment=StringAlignment.Near;
+ break;
+ }
+
+ case ContentAlignment.BottomLeft:
+ case ContentAlignment.BottomCenter:
+ case ContentAlignment.BottomRight: {
+ text_format.LineAlignment=StringAlignment.Far;
+ break;
+ }
+
+ case ContentAlignment.MiddleLeft:
+ case ContentAlignment.MiddleCenter:
+ case ContentAlignment.MiddleRight: {
+ text_format.LineAlignment=StringAlignment.Center;
+ break;
+ }
+ }
+
+ ButtonState state = ButtonState.Normal;
+ if (radio_button.FlatStyle == FlatStyle.Flat) {
+ state |= ButtonState.Flat;
+ }
+
+ if (radio_button.Checked) {
+ state |= ButtonState.Checked;
+ }
+
+ // Start drawing
+ RadioButton_DrawButton(radio_button, dc, state, radiobutton_rectangle);
+
+ RadioButton_DrawText(radio_button, text_rectangle, dc, text_format);
+
+ RadioButton_DrawFocus(radio_button, dc, text_rectangle);
+ text_format.Dispose ();
+ }
+
+ protected virtual void RadioButton_DrawButton(RadioButton radio_button, Graphics dc, ButtonState state, Rectangle radiobutton_rectangle)
+ {
+ SolidBrush sb = new SolidBrush(radio_button.BackColor);
+ dc.FillRectangle(sb, radio_button.ClientRectangle);
+ sb.Dispose();
+
+ if (radio_button.appearance==Appearance.Button) {
+ if (radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup) {
+ DrawFlatStyleButton(dc, radio_button.ClientRectangle, radio_button);
+ } else {
+ CPDrawButton(dc, radio_button.ClientRectangle, state);
+ }
+ } else {
+ // establish if we are rendering a flat style of some sort
+ if (radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup) {
+ DrawFlatStyleRadioButton (dc, radiobutton_rectangle, radio_button);
+ } else {
+ ControlPaint.DrawRadioButton (dc, radiobutton_rectangle, state);
+ }
+ }
+ }
+
+ protected virtual void RadioButton_DrawText(RadioButton radio_button, Rectangle text_rectangle, Graphics dc, StringFormat text_format)
+ {
+ // offset the text if it's pressed and a button
+ if (radio_button.Appearance == Appearance.Button) {
+ if (radio_button.Checked || (radio_button.Capture && radio_button.FlatStyle != FlatStyle.Flat)) {
+ text_rectangle.X ++;
+ text_rectangle.Y ++;
+ }
+
+ text_rectangle.Inflate(-4,-4);
+ }
+
+ /* Place the text; to be compatible with Windows place it after the radiobutton has been drawn */
+
+ // Windows seems to not wrap text in certain situations, this matches as close as I could get it
+ if ((float)(radio_button.Font.Height * 1.5f) > text_rectangle.Height) {
+ text_format.FormatFlags |= StringFormatFlags.NoWrap;
+ }
+
+ if (radio_button.Enabled) {
+ dc.DrawString (radio_button.Text, radio_button.Font, ResPool.GetSolidBrush (radio_button.ForeColor), text_rectangle, text_format);
+ } else if (radio_button.FlatStyle == FlatStyle.Flat) {
+ dc.DrawString(radio_button.Text, radio_button.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorControl)), text_rectangle, text_format);
+ } else {
+ CPDrawStringDisabled(dc, radio_button.Text, radio_button.Font, this.ColorControlText, text_rectangle, text_format);
+ }
+ }
+
+ protected virtual void RadioButton_DrawFocus(RadioButton radio_button, Graphics dc, Rectangle text_rectangle)
+ {
+ if (radio_button.Focused) {
+ if (radio_button.FlatStyle != FlatStyle.Flat) {
+ DrawInnerFocusRectangle (dc, text_rectangle, radio_button.BackColor);
+ } else {
+ dc.DrawRectangle (ResPool.GetPen (radio_button.ForeColor), text_rectangle);
+ }
+ }
+ }
+
+ // renders a radio button with the Flat and Popup FlatStyle
+ protected void DrawFlatStyleRadioButton (Graphics graphics, Rectangle rectangle, RadioButton radio_button)
+ {
+ int lineWidth;
+
+ if (radio_button.Enabled) {
+ // draw the outer flatstyle arcs
+ if (radio_button.FlatStyle == FlatStyle.Flat) {
+ graphics.DrawArc (ResPool.GetPen (radio_button.ForeColor), rectangle, 0, 359);
+
+ // fill in the area depending on whether or not the mouse is hovering
+ if (radio_button.is_entered && radio_button.Capture) {
+ graphics.FillPie (ResPool.GetSolidBrush (ControlPaint.Light (radio_button.BackColor)), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
+ } else {
+ graphics.FillPie (ResPool.GetSolidBrush (ControlPaint.LightLight (radio_button.BackColor)), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
+ }
+ } else {
+ // must be a popup radio button
+ // fill the control
+ graphics.FillPie (ResPool.GetSolidBrush (ControlPaint.LightLight (radio_button.BackColor)), rectangle, 0, 359);
+
+ if (radio_button.is_entered || radio_button.Capture) {
+ // draw the popup 3d button knob
+ graphics.DrawArc (ResPool.GetPen (ControlPaint.Light (radio_button.BackColor)), rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 0, 359);
+
+ graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark (radio_button.BackColor)), rectangle, 135, 180);
+ graphics.DrawArc (ResPool.GetPen (ControlPaint.LightLight (radio_button.BackColor)), rectangle, 315, 180);
+
+ } else {
+ // just draw lighter flatstyle outer circle
+ graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark (this.ColorControl)), rectangle, 0, 359);
+ }
+ }
+ } else {
+ // disabled
+ // fill control background color regardless of actual backcolor
+ graphics.FillPie (ResPool.GetSolidBrush (this.ColorControl), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
+ // draw the ark as control dark
+ graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark(this.ColorControl)), rectangle, 0, 359);
+ }
+
+ // draw the check
+ lineWidth = Math.Max (1, Math.Min(rectangle.Width, rectangle.Height)/3);
+ if (radio_button.Checked) {
+ SolidBrush buttonBrush;
+
+ if (!radio_button.Enabled) {
+ buttonBrush = ResPool.GetSolidBrush (ControlPaint.Dark (this.ColorControl));
+ } else if (radio_button.FlatStyle == FlatStyle.Popup && radio_button.is_entered && radio_button.Capture) {
+ buttonBrush = ResPool.GetSolidBrush (this.ColorControlText);
+ } else {
+ buttonBrush = ResPool.GetSolidBrush (radio_button.ForeColor);
+ }
+ graphics.FillPie (buttonBrush, rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2, 0, 359);
+ }
+ }
+
+ public override Size RadioButtonDefaultSize {
+ get {
+ return new Size (104,24);
+ }
+ }
+ #endregion // RadioButton
+
+ #region ScrollBar
+ public override void DrawScrollBar (Graphics dc, Rectangle clip, ScrollBar bar)
+ {
+ int scrollbutton_width = bar.scrollbutton_width;
+ int scrollbutton_height = bar.scrollbutton_height;
+ Rectangle first_arrow_area;
+ Rectangle second_arrow_area;
+ Rectangle thumb_pos;
+
+ thumb_pos = bar.ThumbPos;
+
+ if (bar.vert) {
+ first_arrow_area = new Rectangle(0, 0, bar.Width, scrollbutton_height);
+ bar.FirstArrowArea = first_arrow_area;
+
+ second_arrow_area = new Rectangle(0, bar.ClientRectangle.Height - scrollbutton_height, bar.Width, scrollbutton_height);
+ bar.SecondArrowArea = second_arrow_area;
+
+ thumb_pos.Width = bar.Width;
+ bar.ThumbPos = thumb_pos;
+
+ /* Buttons */
+ if (clip.IntersectsWith (first_arrow_area))
+ CPDrawScrollButton (dc, first_arrow_area, ScrollButton.Up, bar.firstbutton_state);
+ if (clip.IntersectsWith (second_arrow_area))
+ CPDrawScrollButton (dc, second_arrow_area, ScrollButton.Down, bar.secondbutton_state);
+
+ /* Background */
+ switch (bar.thumb_moving) {
+ case ScrollBar.ThumbMoving.None: {
+ ScrollBar_Vertical_Draw_ThumbMoving_None(scrollbutton_height, bar, clip, dc);
+ break;
+ }
+ case ScrollBar.ThumbMoving.Forward: {
+ ScrollBar_Vertical_Draw_ThumbMoving_Forward(scrollbutton_height, bar, thumb_pos, clip, dc);
+ break;
+ }
+
+ case ScrollBar.ThumbMoving.Backwards: {
+ ScrollBar_Vertical_Draw_ThumbMoving_Backwards(scrollbutton_height, bar, thumb_pos, clip, dc);
+ break;
+ }
+
+ default:
+ break;
+ }
+ } else {
+ first_arrow_area = new Rectangle(0, 0, scrollbutton_width, bar.Height);
+ bar.FirstArrowArea = first_arrow_area;
+
+ second_arrow_area = new Rectangle (bar.ClientRectangle.Width - scrollbutton_width, 0, scrollbutton_width, bar.Height);
+ bar.SecondArrowArea = second_arrow_area;
+
+ thumb_pos.Height = bar.Height;
+ bar.ThumbPos = thumb_pos;
+
+ /* Buttons */
+ if (clip.IntersectsWith (first_arrow_area))
+ CPDrawScrollButton (dc, first_arrow_area, ScrollButton.Left, bar.firstbutton_state);
+ if (clip.IntersectsWith (second_arrow_area))
+ CPDrawScrollButton (dc, second_arrow_area, ScrollButton.Right, bar.secondbutton_state);
+
+ /* Background */
+ switch (bar.thumb_moving) {
+ case ScrollBar.ThumbMoving.None: {
+ ScrollBar_Horizontal_Draw_ThumbMoving_None(scrollbutton_width, bar, clip, dc);
+ break;
+ }
+
+ case ScrollBar.ThumbMoving.Forward: {
+ ScrollBar_Horizontal_Draw_ThumbMoving_Forward(scrollbutton_width, thumb_pos, bar, clip, dc);
+ break;
+ }
+
+ case ScrollBar.ThumbMoving.Backwards: {
+ ScrollBar_Horizontal_Draw_ThumbMoving_Backwards(scrollbutton_width, thumb_pos, bar, clip, dc);
+ break;
+ }
+ }
+ }
+
+ /* Thumb */
+ ScrollBar_DrawThumb(bar, thumb_pos, clip, dc);
+ }
+
+ protected virtual void ScrollBar_DrawThumb(ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc)
+ {
+ if (bar.Enabled && thumb_pos.Width > 0 && thumb_pos.Height > 0 && clip.IntersectsWith(thumb_pos))
+ DrawScrollButtonPrimitive(dc, thumb_pos, ButtonState.Normal);
+ }
+
+ protected virtual void ScrollBar_Vertical_Draw_ThumbMoving_None( int scrollbutton_height, ScrollBar bar, Rectangle clip, Graphics dc )
+ {
+ Rectangle r = new Rectangle( 0,
+ scrollbutton_height, bar.ClientRectangle.Width, bar.ClientRectangle.Height - ( scrollbutton_height * 2 ) );
+ Rectangle intersect = Rectangle.Intersect( clip, r );
+
+ if ( intersect != Rectangle.Empty )
+ {
+ Brush h = ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White);
+ dc.FillRectangle( h, intersect );
+ }
+ }
+
+ protected virtual void ScrollBar_Vertical_Draw_ThumbMoving_Forward( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
+ {
+ Rectangle r = new Rectangle( 0, scrollbutton_height,
+ bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
+ Rectangle intersect = Rectangle.Intersect( clip, r );
+
+ if ( intersect != Rectangle.Empty )
+ dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White ), intersect );
+
+ r.X = 0;
+ r.Y = thumb_pos.Y + thumb_pos.Height;
+ r.Width = bar.ClientRectangle.Width;
+ r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
+
+ intersect = Rectangle.Intersect( clip, r );
+ if ( intersect != Rectangle.Empty )
+ dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, Color.FromArgb( 255, 63, 63, 63 ), Color.Black ), intersect );
+ }
+
+ protected virtual void ScrollBar_Vertical_Draw_ThumbMoving_Backwards( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
+ {
+ Rectangle r = new Rectangle( 0, scrollbutton_height,
+ bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
+ Rectangle intersect = Rectangle.Intersect( clip, r );
+
+ if ( intersect != Rectangle.Empty )
+ dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, Color.FromArgb( 255, 63, 63, 63 ), Color.Black ), intersect );
+
+ r.X = 0;
+ r.Y = thumb_pos.Y + thumb_pos.Height;
+ r.Width = bar.ClientRectangle.Width;
+ r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
+
+ intersect = Rectangle.Intersect( clip, r );
+ if ( intersect != Rectangle.Empty )
+ dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
+ }
+
+ protected virtual void ScrollBar_Horizontal_Draw_ThumbMoving_None( int scrollbutton_width, ScrollBar bar, Rectangle clip, Graphics dc )
+ {
+ Rectangle r = new Rectangle( scrollbutton_width,
+ 0, bar.ClientRectangle.Width - ( scrollbutton_width * 2 ), bar.ClientRectangle.Height );
+ Rectangle intersect = Rectangle.Intersect( clip, r );
+
+ if ( intersect != Rectangle.Empty )
+ dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
+ }
+
+ protected virtual void ScrollBar_Horizontal_Draw_ThumbMoving_Forward( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
+ {
+ Rectangle r = new Rectangle( scrollbutton_width, 0,
+ thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
+ Rectangle intersect = Rectangle.Intersect( clip, r );
+
+ if ( intersect != Rectangle.Empty )
+ dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
+
+ r.X = thumb_pos.X + thumb_pos.Width;
+ r.Y = 0;
+ r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
+ r.Height = bar.ClientRectangle.Height;
+
+ intersect = Rectangle.Intersect( clip, r );
+ if ( intersect != Rectangle.Empty )
+ dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, Color.FromArgb( 255, 63, 63, 63 ), Color.Black ), intersect );
+ }
+
+ protected virtual void ScrollBar_Horizontal_Draw_ThumbMoving_Backwards( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
+ {
+ Rectangle r = new Rectangle( scrollbutton_width, 0,
+ thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
+ Rectangle intersect = Rectangle.Intersect( clip, r );
+
+ if ( intersect != Rectangle.Empty )
+ dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, Color.FromArgb( 255, 63, 63, 63 ), Color.Black ), intersect );
+
+ r.X = thumb_pos.X + thumb_pos.Width;
+ r.Y = 0;
+ r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
+ r.Height = bar.ClientRectangle.Height;
+
+ intersect = Rectangle.Intersect( clip, r );
+ if ( intersect != Rectangle.Empty )
+ dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
+ }
+
+ public override int ScrollBarButtonSize {
+ get { return 16; }
+ }
+ #endregion // ScrollBar
+
+ #region StatusBar
+ public override void DrawStatusBar (Graphics dc, Rectangle clip, StatusBar sb) {
+ Rectangle area = sb.ClientRectangle;
+ int horz_border = 2;
+ int vert_border = 2;
+
+ dc.FillRectangle (GetControlBackBrush (sb.BackColor), clip);
+
+ if (sb.Panels.Count == 0 && sb.Text != String.Empty) {
+ string text = sb.Text;
+ StringFormat string_format = new StringFormat ();
+ string_format.Trimming = StringTrimming.Character;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+
+ if (text [0] == '\t') {
+ string_format.Alignment = StringAlignment.Center;
+ text = text.Substring (1);
+ if (text [0] == '\t') {
+ string_format.Alignment = StringAlignment.Far;
+ text = text.Substring (1);
+ }
+ }
+
+ dc.DrawString (text, sb.Font, ResPool.GetSolidBrush (sb.ForeColor),
+ new Rectangle(area.X + 2, area.Y + 2, area.Width - 4, area.Height - 4), string_format);
+ string_format.Dispose ();
+ } else if (sb.ShowPanels) {
+ SolidBrush br_forecolor = GetControlForeBrush (sb.ForeColor);
+ int prev_x = area.X + horz_border;
+ int y = area.Y + vert_border;
+ for (int i = 0; i < sb.Panels.Count; i++) {
+ Rectangle pr = new Rectangle (prev_x, y,
+ sb.Panels [i].Width, area.Height);
+ prev_x += pr.Width + StatusBarHorzGapWidth;
+ if (pr.IntersectsWith (clip))
+ DrawStatusBarPanel (dc, pr, i, br_forecolor, sb.Panels [i]);
+ }
+ }
+
+ if (sb.SizingGrip)
+ CPDrawSizeGrip (dc, ColorControl, area);
+
+ }
+
+
+ protected virtual void DrawStatusBarPanel (Graphics dc, Rectangle area, int index,
+ SolidBrush br_forecolor, StatusBarPanel panel) {
+ int border_size = 3; // this is actually const, even if the border style is none
+
+ area.Height -= border_size;
+ if (panel.BorderStyle != StatusBarPanelBorderStyle.None) {
+ Border3DStyle border_style = Border3DStyle.SunkenInner;
+ if (panel.BorderStyle == StatusBarPanelBorderStyle.Raised)
+ border_style = Border3DStyle.RaisedOuter;
+ CPDrawBorder3D(dc, area, border_style, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, panel.Parent.BackColor);
+ }
+
+ if (panel.Style == StatusBarPanelStyle.OwnerDraw) {
+ StatusBarDrawItemEventArgs e = new StatusBarDrawItemEventArgs (
+ dc, panel.Parent.Font, area, index, DrawItemState.Default,
+ panel, panel.Parent.ForeColor, panel.Parent.BackColor);
+ panel.Parent.OnDrawItemInternal (e);
+ return;
+ }
+
+ int left = area.Left;
+ if (panel.Icon != null) {
+ left += 2;
+ dc.DrawIcon (panel.Icon, left, area.Top);
+ left += panel.Icon.Width;
+ }
+
+ if (panel.Text == String.Empty)
+ return;
+
+ string text = panel.Text;
+ StringFormat string_format = new StringFormat ();
+ string_format.Trimming = StringTrimming.Character;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+
+ if (text [0] == '\t') {
+ string_format.Alignment = StringAlignment.Center;
+ text = text.Substring (1);
+ if (text [0] == '\t') {
+ string_format.Alignment = StringAlignment.Far;
+ text = text.Substring (1);
+ }
+ }
+
+ int x = left + border_size;
+ int y = border_size + 2;
+ Rectangle r = new Rectangle (x, y,
+ area.Right - x - border_size,
+ area.Bottom - y - border_size);
+
+ dc.DrawString (text, panel.Parent.Font, br_forecolor, r, string_format);
+ string_format.Dispose ();
+ }
+
+ public override int StatusBarSizeGripWidth {
+ get { return 15; }
+ }
+
+ public override int StatusBarHorzGapWidth {
+ get { return 3; }
+ }
+
+ public override Size StatusBarDefaultSize {
+ get {
+ return new Size (100, 22);
+ }
+ }
+ #endregion // StatusBar
+
+ public override void DrawTabControl (Graphics dc, Rectangle area, TabControl tab)
+ {
+ // Do we need to fill the back color? It can't be changed...
+ dc.FillRectangle (GetControlBackBrush (tab.BackColor), area);
+ Rectangle panel_rect = GetTabPanelRectExt (tab);
+
+ if (tab.Appearance == TabAppearance.Normal) {
+ CPDrawBorder3D (dc, panel_rect, Border3DStyle.RaisedInner, Border3DSide.Left | Border3DSide.Top, ColorControl);
+ CPDrawBorder3D (dc, panel_rect, Border3DStyle.Raised, Border3DSide.Right | Border3DSide.Bottom, ColorControl);
+ }
+
+ if (tab.Alignment == TabAlignment.Top) {
+ for (int r = tab.TabPages.Count; r > 0; r--) {
+ for (int i = tab.SliderPos; i < tab.TabPages.Count; i++) {
+ if (i == tab.SelectedIndex)
+ continue;
+ if (r != tab.TabPages [i].Row)
+ continue;
+ Rectangle rect = tab.GetTabRect (i);
+ if (!rect.IntersectsWith (area))
+ continue;
+ DrawTab (dc, tab.TabPages [i], tab, rect, false);
+ }
+ }
+ } else {
+ for (int r = 0; r < tab.TabPages.Count; r++) {
+ for (int i = tab.SliderPos; i < tab.TabPages.Count; i++) {
+ if (i == tab.SelectedIndex)
+ continue;
+ if (r != tab.TabPages [i].Row)
+ continue;
+ Rectangle rect = tab.GetTabRect (i);
+ if (!rect.IntersectsWith (area))
+ continue;
+ DrawTab (dc, tab.TabPages [i], tab, rect, false);
+ }
+ }
+ }
+
+ if (tab.SelectedIndex != -1 && tab.SelectedIndex >= tab.SliderPos) {
+ Rectangle rect = tab.GetTabRect (tab.SelectedIndex);
+ if (rect.IntersectsWith (area))
+ DrawTab (dc, tab.TabPages [tab.SelectedIndex], tab, rect, true);
+ }
+
+ if (tab.ShowSlider) {
+ Rectangle right = GetTabControlRightScrollRect (tab);
+ Rectangle left = GetTabControlLeftScrollRect (tab);
+ CPDrawScrollButton (dc, right, ScrollButton.Right, tab.RightSliderState);
+ CPDrawScrollButton (dc, left, ScrollButton.Left, tab.LeftSliderState);
+ }
+ }
+
+ public override Rectangle GetTabControlLeftScrollRect (TabControl tab)
+ {
+ switch (tab.Alignment) {
+ case TabAlignment.Top:
+ return new Rectangle (tab.ClientRectangle.Right - 34, tab.ClientRectangle.Top + 1, 17, 17);
+ default:
+ Rectangle panel_rect = GetTabPanelRectExt (tab);
+ return new Rectangle (tab.ClientRectangle.Right - 34, panel_rect.Bottom + 2, 17, 17);
+ }
+ }
+
+ public override Rectangle GetTabControlRightScrollRect (TabControl tab)
+ {
+ switch (tab.Alignment) {
+ case TabAlignment.Top:
+ return new Rectangle (tab.ClientRectangle.Right - 17, tab.ClientRectangle.Top + 1, 17, 17);
+ default:
+ Rectangle panel_rect = GetTabPanelRectExt (tab);
+ return new Rectangle (tab.ClientRectangle.Right - 17, panel_rect.Bottom + 2, 17, 17);
+ }
+ }
+
+ public override Size TabControlDefaultItemSize {
+ get { return new Size (42, 21); }
+ }
+
+ public override Point TabControlDefaultPadding {
+ get { return new Point (6, 3); }
+ }
+
+ public override int TabControlMinimumTabWidth {
+ get { return 42; }
+ }
+
+ public override Rectangle GetTabControlDisplayRectangle (TabControl tab)
+ {
+ Rectangle ext = GetTabPanelRectExt (tab);
+ // Account for border size
+ return new Rectangle (ext.Left + 2, ext.Top + 1, ext.Width - 6, ext.Height - 4);
+ }
+
+ public override Size TabControlGetSpacing (TabControl tab) {
+ switch (tab.Appearance) {
+ case TabAppearance.Normal:
+ return new Size (1, -2);
+ case TabAppearance.Buttons:
+ return new Size (3, 3);
+ case TabAppearance.FlatButtons:
+ return new Size (9, 3);
+ default:
+ throw new Exception ("Invalid Appearance value: " + tab.Appearance);
+ }
+ }
+
+ protected virtual Rectangle GetTabPanelRectExt (TabControl tab)
+ {
+ // Offset the tab from the top corner
+ Rectangle res = new Rectangle (tab.ClientRectangle.X + 2,
+ tab.ClientRectangle.Y,
+ tab.ClientRectangle.Width - 2,
+ tab.ClientRectangle.Height - 1);
+
+ if (tab.TabCount == 0)
+ return res;
+
+ int spacing = TabControlGetSpacing (tab).Height;
+ int offset = (tab.ItemSize.Height + spacing) * tab.RowCount + 3;
+
+ switch (tab.Alignment) {
+ case TabAlignment.Left:
+ res.X += offset;
+ res.Width -= offset;
+ break;
+ case TabAlignment.Right:
+ res.Width -= offset;
+ break;
+ case TabAlignment.Top:
+ res.Y += offset;
+ res.Height -= offset;
+ break;
+ case TabAlignment.Bottom:
+ res.Height -= offset;
+ break;
+ }
+
+ return res;
+ }
+
+ protected virtual int DrawTab (Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected)
+ {
+ int FlatButtonSpacing = 8;
+ Rectangle interior;
+ int res = bounds.Width;
+
+
+
+ // we can't fill the background right away because the bounds might be adjusted if the tab is selected
+
+ StringFormat string_format = new StringFormat ();
+ if (tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons) {
+ dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
+
+ // Separators
+ if (tab.Appearance == TabAppearance.FlatButtons) {
+ int width = bounds.Width;
+ bounds.Width += (FlatButtonSpacing - 2);
+ res = bounds.Width;
+ CPDrawBorder3D (dc, bounds, Border3DStyle.Etched, Border3DSide.Right);
+ bounds.Width = width;
+ }
+
+ if (is_selected) {
+ CPDrawBorder3D (dc, bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
+ } else if (tab.Appearance != TabAppearance.FlatButtons) {
+ CPDrawBorder3D (dc, bounds, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
+ }
+
+ interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4);
+
+
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+ } else {
+ Pen light = ResPool.GetPen (ControlPaint.LightLight (tab.BackColor));
+
+ switch (tab.Alignment) {
+
+ case TabAlignment.Top:
+
+
+ dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
+
+ dc.DrawLine (light, bounds.Left, bounds.Bottom, bounds.Left, bounds.Top + 3);
+ dc.DrawLine (light, bounds.Left, bounds.Top + 3, bounds.Left + 3, bounds.Top);
+ dc.DrawLine (light, bounds.Left + 3, bounds.Top, bounds.Right - 3, bounds.Top);
+
+ dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Top + 1, bounds.Right - 1, bounds.Bottom);
+ dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right - 1, bounds.Top + 2, bounds.Right, bounds.Top + 3);
+ dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom);
+
+ interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
+
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+
+ break;
+
+ case TabAlignment.Bottom:
+
+ dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
+
+ dc.DrawLine (light, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom - 3);
+ dc.DrawLine (light, bounds.Left, bounds.Bottom - 3, bounds.Left + 2, bounds.Bottom - 1);
+
+ dc.DrawLine (SystemPens.ControlDark, bounds.Left + 3, bounds.Bottom - 1, bounds.Right - 3, bounds.Bottom - 1);
+ dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Bottom - 3, bounds.Right - 1, bounds.Top);
+
+ dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left + 3, bounds.Bottom, bounds.Right - 3, bounds.Bottom);
+ dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right - 3, bounds.Bottom, bounds.Right, bounds.Bottom - 3);
+ dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Bottom - 3, bounds.Right, bounds.Top);
+
+ interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
+
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+
+ break;
+
+ case TabAlignment.Left:
+
+ dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
+
+ dc.DrawLine (light, bounds.Left, bounds.Bottom - 3, bounds.Left, bounds.Top + 3);
+ dc.DrawLine (light, bounds.Left, bounds.Top + 3, bounds.Left + 3, bounds.Top);
+ dc.DrawLine (light, bounds.Left + 3, bounds.Top, bounds.Right, bounds.Top);
+
+ dc.DrawLine (SystemPens.ControlDark, bounds.Right, bounds.Bottom - 1, bounds.Left + 2, bounds.Bottom - 1);
+
+ dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Bottom, bounds.Left + 2, bounds.Bottom);
+ dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left + 2, bounds.Bottom, bounds.Left, bounds.Bottom - 3);
+
+ interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
+
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+ string_format.FormatFlags = StringFormatFlags.DirectionVertical;
+
+ break;
+
+ default:
+ // TabAlignment.Right
+
+ dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
+
+ dc.DrawLine (light, bounds.Left, bounds.Top, bounds.Right - 3, bounds.Top);
+ dc.DrawLine (light, bounds.Right - 3, bounds.Top, bounds.Right, bounds.Top + 3);
+
+ dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Top + 1, bounds.Right - 1, bounds.Bottom - 1);
+ dc.DrawLine (SystemPens.ControlDark, bounds.Left, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom - 1);
+
+ dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom - 3);
+ dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left, bounds.Bottom, bounds.Right - 3, bounds.Bottom);
+
+ interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
+
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+ string_format.FormatFlags = StringFormatFlags.DirectionVertical;
+
+ break;
+ }
+ }
+
+ if (tab.DrawMode == TabDrawMode.Normal && page.Text != null) {
+ if (tab.Alignment == TabAlignment.Left) {
+ int wo = interior.Width / 2;
+ int ho = interior.Height / 2;
+ dc.TranslateTransform (interior.X + wo, interior.Y + ho);
+ dc.RotateTransform (180);
+ dc.DrawString (page.Text, page.Font, ResPool.GetSolidBrush (SystemColors.ControlText), 0, 0, string_format);
+ dc.ResetTransform ();
+ } else {
+ dc.DrawString (page.Text, page.Font,
+ ResPool.GetSolidBrush (SystemColors.ControlText),
+ interior, string_format);
+ }
+ } else if (page.Text != null) {
+ DrawItemState state = DrawItemState.None;
+ if (page == tab.SelectedTab)
+ state |= DrawItemState.Selected;
+ DrawItemEventArgs e = new DrawItemEventArgs (dc,
+ tab.Font, bounds, tab.IndexForTabPage (page),
+ state, page.ForeColor, page.BackColor);
+ tab.OnDrawItemInternal (e);
+ return res;
+ }
+
+ if (page.parent.Focused && is_selected) {
+ CPDrawFocusRectangle (dc, interior, tab.ForeColor, tab.BackColor);
+ }
+
+ return res;
+ }
+
+ #region ToolBar
+ public override void DrawToolBar (Graphics dc, Rectangle clip_rectangle, ToolBar control)
+ {
+ StringFormat format = new StringFormat ();
+ format.Trimming = StringTrimming.EllipsisWord;
+ format.LineAlignment = StringAlignment.Center;
+ if (control.TextAlign == ToolBarTextAlign.Underneath)
+ format.Alignment = StringAlignment.Center;
+ else
+ format.Alignment = StringAlignment.Near;
+
+ dc.FillRectangle (ResPool.GetSolidBrush( DefaultControlBackColor ), clip_rectangle);
+
+ foreach (ToolBarButton button in control.Buttons)
+ if (button.Visible && clip_rectangle.IntersectsWith (button.Rectangle))
+ DrawToolBarButton (dc, control, button, format);
+
+ format.Dispose ();
+ }
+
+ void DrawToolBarButton (Graphics dc, ToolBar control, ToolBarButton button, StringFormat format)
+ {
+ bool is_flat = control.Appearance == ToolBarAppearance.Flat;
+
+ DrawToolBarButtonBorder (dc, button, is_flat);
+
+ switch (button.Style) {
+ case ToolBarButtonStyle.DropDownButton:
+ if (control.DropDownArrows)
+ DrawToolBarDropDownArrow (dc, button, is_flat);
+ DrawToolBarButtonContents (dc, control, button, format);
+ break;
+
+ case ToolBarButtonStyle.Separator:
+ if (is_flat)
+ DrawToolBarSeparator (dc, button);
+ break;
+
+ case ToolBarButtonStyle.ToggleButton:
+ DrawToolBarToggleButtonBackground (dc, button);
+ DrawToolBarButtonContents (dc, control, button, format);
+ break;
+
+ default:
+ DrawToolBarButtonContents (dc, control, button, format);
+ break;
+ }
+ }
+
+ const Border3DSide all_sides = Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom;
+
+ void DrawToolBarButtonBorder (Graphics dc, ToolBarButton button, bool is_flat)
+ {
+ if (button.Style == ToolBarButtonStyle.Separator)
+ return;
+
+ Border3DStyle style;
+
+ if (is_flat) {
+ if (button.Pushed || button.Pressed)
+ style = Border3DStyle.SunkenOuter;
+ else if (button.Hilight)
+ style = Border3DStyle.RaisedOuter;
+ else
+ return;
+
+ } else {
+ if (button.Pushed || button.Pressed)
+ style = Border3DStyle.Sunken;
+ else
+ style = Border3DStyle.Raised;
+ }
+
+ CPDrawBorder3D (dc, button.Rectangle, style, all_sides);
+ }
+
+ void DrawToolBarSeparator (Graphics dc, ToolBarButton button)
+ {
+ Rectangle area = button.Rectangle;
+ int offset = (int) ResPool.GetPen (ColorControl).Width + 1;
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), area.X + 1, area.Y, area.X + 1, area.Bottom);
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), area.X + offset, area.Y, area.X + offset, area.Bottom);
+ }
+
+ void DrawToolBarToggleButtonBackground (Graphics dc, ToolBarButton button)
+ {
+ Rectangle area = button.Rectangle;
+ area.X += ToolBarImageGripWidth;
+ area.Y += ToolBarImageGripWidth;
+ area.Width -= 2 * ToolBarImageGripWidth;
+ area.Height -= 2 * ToolBarImageGripWidth;
+
+ if (button.Pushed)
+ dc.FillRectangle (SystemBrushes.ControlLightLight, area);
+ else if (button.PartialPush)
+ dc.FillRectangle (SystemBrushes.ControlLight, area);
+ else
+ dc.FillRectangle (SystemBrushes.Control, area);
+ }
+
+ void DrawToolBarDropDownArrow (Graphics dc, ToolBarButton button, bool is_flat)
+ {
+ Rectangle rect = button.Rectangle;
+ rect.X = button.Rectangle.Right - ToolBarDropDownWidth;
+ rect.Width = ToolBarDropDownWidth;
+
+ if (button.dd_pressed) {
+ CPDrawBorder3D (dc, rect, Border3DStyle.SunkenOuter, all_sides);
+ CPDrawBorder3D (dc, rect, Border3DStyle.SunkenInner, Border3DSide.Bottom | Border3DSide.Right);
+ } else if (button.Pushed || button.Pressed)
+ CPDrawBorder3D (dc, rect, Border3DStyle.Sunken, all_sides);
+ else if (is_flat) {
+ if (button.Hilight)
+ CPDrawBorder3D (dc, rect, Border3DStyle.RaisedOuter, all_sides);
+ } else
+ CPDrawBorder3D (dc, rect, Border3DStyle.Raised, all_sides);
+
+ PointF [] vertices = new PointF [3];
+ PointF ddCenter = new PointF (rect.X + (rect.Width/2.0f), rect.Y + (rect.Height/2.0f));
+ vertices [0].X = ddCenter.X - ToolBarDropDownArrowWidth / 2.0f + 0.5f;
+ vertices [0].Y = ddCenter.Y;
+ vertices [1].X = ddCenter.X + ToolBarDropDownArrowWidth / 2.0f + 0.5f;
+ vertices [1].Y = ddCenter.Y;
+ vertices [2].X = ddCenter.X + 0.5f; // 0.5 is added for adjustment
+ vertices [2].Y = ddCenter.Y + ToolBarDropDownArrowHeight;
+ dc.FillPolygon (SystemBrushes.ControlText, vertices);
+ }
+
+ void DrawToolBarButtonContents (Graphics dc, ToolBar control, ToolBarButton button, StringFormat format)
+ {
+ if (button.Image != null) {
+ int x = button.ImageRectangle.X + ToolBarImageGripWidth;
+ int y = button.ImageRectangle.Y + ToolBarImageGripWidth;
+ if (button.Enabled)
+ dc.DrawImage (button.Image, x, y);
+ else
+ CPDrawImageDisabled (dc, button.Image, x, y, ColorControl);
+ }
+
+ if (button.Enabled)
+ dc.DrawString (button.Text, control.Font, ResPool.GetSolidBrush (ColorControlText), button.TextRectangle, format);
+ else
+ CPDrawStringDisabled (dc, button.Text, control.Font, ColorControlLight, button.TextRectangle, format);
+ }
+
+ // Grip width for the ToolBar
+ public override int ToolBarGripWidth {
+ get { return 2;}
+ }
+
+ // Grip width for the Image on the ToolBarButton
+ public override int ToolBarImageGripWidth {
+ get { return 2;}
+ }
+
+ // width of the separator
+ public override int ToolBarSeparatorWidth {
+ get { return 4; }
+ }
+
+ // width of the dropdown arrow rect
+ public override int ToolBarDropDownWidth {
+ get { return 13; }
+ }
+
+ // width for the dropdown arrow on the ToolBarButton
+ public override int ToolBarDropDownArrowWidth {
+ get { return 5;}
+ }
+
+ // height for the dropdown arrow on the ToolBarButton
+ public override int ToolBarDropDownArrowHeight {
+ get { return 3;}
+ }
+
+ public override Size ToolBarDefaultSize {
+ get {
+ return new Size (100, 42);
+ }
+ }
+ #endregion // ToolBar
+
+ #region ToolTip
+ public override void DrawToolTip(Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control) {
+ dc.FillRectangle(ResPool.GetSolidBrush(this.ColorInfo), control.client_rect);
+ dc.DrawRectangle(ResPool.GetPen(this.ColorWindowFrame), 0, 0, control.Width-1, control.Height-1);
+ dc.DrawString(control.text, control.Font, ResPool.GetSolidBrush(this.ColorInfoText), control.client_rect, control.string_format);
+ }
+
+ public override Size ToolTipSize(ToolTip.ToolTipWindow tt, string text) {
+ SizeF sizef;
+
+ sizef = tt.DeviceContext.MeasureString(text, tt.Font);
+ return new Size((int)sizef.Width+2, (int)sizef.Height+3); // Need space for the border
+ }
+ #endregion // ToolTip
+
+ #region TrackBar
+ private void DrawTrackBar_Vertical (Graphics dc, Rectangle clip_rectangle, TrackBar tb,
+ ref Rectangle thumb_pos, ref Rectangle thumb_area, Brush br_thumb,
+ float ticks, int value_pos, bool mouse_value) {
+
+ Point toptick_startpoint = new Point ();
+ Point bottomtick_startpoint = new Point ();
+ Point channel_startpoint = new Point ();
+ float pixel_len;
+ float pixels_betweenticks;
+ const int space_from_right = 8;
+ const int space_from_left = 8;
+ const int space_from_bottom = 11;
+ Rectangle area = tb.ClientRectangle;
+
+ switch (tb.TickStyle) {
+ case TickStyle.BottomRight:
+ case TickStyle.None:
+ channel_startpoint.Y = 8;
+ channel_startpoint.X = 9;
+ bottomtick_startpoint.Y = 13;
+ bottomtick_startpoint.X = 24;
+ break;
+ case TickStyle.TopLeft:
+ channel_startpoint.Y = 8;
+ channel_startpoint.X = 19;
+ toptick_startpoint.Y = 13;
+ toptick_startpoint.X = 8;
+ break;
+ case TickStyle.Both:
+ channel_startpoint.Y = 8;
+ channel_startpoint.X = 18;
+ bottomtick_startpoint.Y = 13;
+ bottomtick_startpoint.X = 32;
+ toptick_startpoint.Y = 13;
+ toptick_startpoint.X = 8;
+ break;
+ default:
+ break;
+ }
+
+ thumb_area.X = area.X + channel_startpoint.X;
+ thumb_area.Y = area.Y + channel_startpoint.Y;
+ thumb_area.Height = area.Height - space_from_right - space_from_left;
+ thumb_area.Width = 4;
+
+ /* Draw channel */
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDark), channel_startpoint.X, channel_startpoint.Y,
+ 1, thumb_area.Height);
+
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDarkDark), channel_startpoint.X + 1, channel_startpoint.Y,
+ 1, thumb_area.Height);
+
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorControlLight), channel_startpoint.X + 3, channel_startpoint.Y,
+ 1, thumb_area.Height);
+
+ pixel_len = thumb_area.Height - 11;
+ pixels_betweenticks = pixel_len / (tb.Maximum - tb.Minimum);
+
+ /* Convert thumb position from mouse position to value*/
+ if (mouse_value) {
+ if (value_pos < thumb_area.Bottom)
+ value_pos = (int) ((thumb_area.Bottom - value_pos) / pixels_betweenticks);
+ else
+ value_pos = 0;
+
+ if (value_pos + tb.Minimum > tb.Maximum)
+ value_pos = tb.Maximum - tb.Minimum;
+
+ tb.Value = value_pos + tb.Minimum;
+ }
+
+ // thumb_pos.Y = channel_startpoint.Y ; // + (int) (pixels_betweenticks * (float) value_pos);
+ thumb_pos.Y = thumb_area.Bottom - space_from_bottom - (int) (pixels_betweenticks * (float) value_pos);
+
+ /* Draw thumb fixed 10x22 size */
+ thumb_pos.Width = 10;
+ thumb_pos.Height = 22;
+
+ switch (tb.TickStyle) {
+ case TickStyle.BottomRight:
+ case TickStyle.None: {
+ thumb_pos.X = channel_startpoint.X - 8;
+
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X , thumb_pos.Y + 10);
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 16, thumb_pos.Y);
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X + 16, thumb_pos.Y, thumb_pos.X + 16 + 4, thumb_pos.Y + 4);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X +1, thumb_pos.Y + 9, thumb_pos.X +15, thumb_pos.Y +9);
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 16, thumb_pos.Y + 9, thumb_pos.X +16 + 4, thumb_pos.Y +9 - 4);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X, thumb_pos.Y + 10, thumb_pos.X +16, thumb_pos.Y +10);
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 16, thumb_pos.Y + 10, thumb_pos.X +16 + 5, thumb_pos.Y +10 - 5);
+
+ dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 16, 8);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 17, thumb_pos.Y + 2, 1, 6);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 18, thumb_pos.Y + 3, 1, 4);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 19, thumb_pos.Y + 4, 1, 2);
+
+ break;
+ }
+ case TickStyle.TopLeft: {
+ thumb_pos.X = channel_startpoint.X - 10;
+
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X + 4 + 16, thumb_pos.Y);
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 4);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 4, thumb_pos.Y + 9, thumb_pos.X + 4 + 16 , thumb_pos.Y+ 9);
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 4, thumb_pos.Y + 9, thumb_pos.X, thumb_pos.Y + 5);
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 19, thumb_pos.Y + 9, thumb_pos.X +19 , thumb_pos.Y+ 1);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 4, thumb_pos.Y+ 10, thumb_pos.X + 4 + 16, thumb_pos.Y+ 10);
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 4, thumb_pos.Y + 10, thumb_pos.X -1, thumb_pos.Y+ 5);
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 20, thumb_pos.Y, thumb_pos.X+ 20, thumb_pos.Y + 10);
+
+ dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 1, 15, 8);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 2, 1, 6);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 3, 1, 4);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 4, 1, 2);
+
+ break;
+ }
+
+ case TickStyle.Both: {
+ thumb_pos.X = area.X + 10;
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 9);
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 19, thumb_pos.Y);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 1, thumb_pos.Y + 9, thumb_pos.X+ 19, thumb_pos.Y + 9);
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 10, thumb_pos.Y+ 1, thumb_pos.X + 19, thumb_pos.Y + 8);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X, thumb_pos.Y + 10, thumb_pos.X+ 20, thumb_pos.Y +10);
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 20, thumb_pos.Y, thumb_pos.X + 20, thumb_pos.Y+ 9);
+
+ dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 18, 8);
+
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ pixel_len = thumb_area.Height - 11;
+ pixels_betweenticks = pixel_len / ticks;
+
+ thumb_area.X = thumb_pos.X;
+ thumb_area.Y = channel_startpoint.Y;
+ thumb_area.Width = thumb_pos.Height;
+
+ /* Draw ticks*/
+ Region outside = new Region (area);
+ outside.Exclude (thumb_area);
+
+ if (outside.IsVisible (clip_rectangle)) {
+ if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
+ ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
+
+ for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
+ if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X , area.Y + bottomtick_startpoint.Y + inc,
+ area.X + bottomtick_startpoint.X + 3, area.Y + bottomtick_startpoint.Y + inc);
+ else
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X, area.Y + bottomtick_startpoint.Y + inc,
+ area.X + bottomtick_startpoint.X + 2, area.Y + bottomtick_startpoint.Y + inc);
+ }
+ }
+
+ if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
+ ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
+
+ pixel_len = thumb_area.Height - 11;
+ pixels_betweenticks = pixel_len / ticks;
+
+ for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
+ if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X - 3 , area.Y + toptick_startpoint.Y + inc,
+ area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
+ else
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X - 2, area.Y + toptick_startpoint.Y + inc,
+ area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
+ }
+ }
+ }
+
+ outside.Dispose ();
+
+ }
+
+ /*
+ Horizontal trackbar
+
+ Does not matter the size of the control, Win32 always draws:
+ - Ticks starting from pixel 13, 8
+ - Channel starting at pos 8, 19 and ends at Width - 8
+ - Autosize makes always the control 40 pixels height
+ - Ticks are draw at (channel.Witdh - 10) / (Maximum - Minimum)
+
+ */
+ private void DrawTrackBar_Horizontal (Graphics dc, Rectangle clip_rectangle, TrackBar tb,
+ ref Rectangle thumb_pos, ref Rectangle thumb_area, Brush br_thumb,
+ float ticks, int value_pos, bool mouse_value) {
+ Point toptick_startpoint = new Point ();
+ Point bottomtick_startpoint = new Point ();
+ Point channel_startpoint = new Point ();
+ float pixel_len;
+ float pixels_betweenticks;
+ const int space_from_right = 8;
+ const int space_from_left = 8;
+ Rectangle area = tb.ClientRectangle;
+
+ switch (tb.TickStyle) {
+ case TickStyle.BottomRight:
+ case TickStyle.None:
+ channel_startpoint.X = 8;
+ channel_startpoint.Y = 9;
+ bottomtick_startpoint.X = 13;
+ bottomtick_startpoint.Y = 24;
+ break;
+ case TickStyle.TopLeft:
+ channel_startpoint.X = 8;
+ channel_startpoint.Y = 19;
+ toptick_startpoint.X = 13;
+ toptick_startpoint.Y = 8;
+ break;
+ case TickStyle.Both:
+ channel_startpoint.X = 8;
+ channel_startpoint.Y = 18;
+ bottomtick_startpoint.X = 13;
+ bottomtick_startpoint.Y = 32;
+ toptick_startpoint.X = 13;
+ toptick_startpoint.Y = 8;
+ break;
+ default:
+ break;
+ }
+
+ thumb_area.X = area.X + channel_startpoint.X;
+ thumb_area.Y = area.Y + channel_startpoint.Y;
+ thumb_area.Width = area.Width - space_from_right - space_from_left;
+ thumb_area.Height = 4;
+
+ /* Draw channel */
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDark), channel_startpoint.X, channel_startpoint.Y,
+ thumb_area.Width, 1);
+
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDarkDark), channel_startpoint.X, channel_startpoint.Y + 1,
+ thumb_area.Width, 1);
+
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorControlLight), channel_startpoint.X, channel_startpoint.Y +3,
+ thumb_area.Width, 1);
+
+ pixel_len = thumb_area.Width - 11;
+ pixels_betweenticks = pixel_len / (tb.Maximum - tb.Minimum);
+
+ /* Convert thumb position from mouse position to value*/
+ if (mouse_value) {
+ if (value_pos >= channel_startpoint.X)
+ value_pos = (int)(((float) (value_pos - channel_startpoint.X)) / pixels_betweenticks);
+ else
+ value_pos = 0;
+
+ if (value_pos + tb.Minimum > tb.Maximum)
+ value_pos = tb.Maximum - tb.Minimum;
+
+ tb.Value = value_pos + tb.Minimum;
+ }
+
+ thumb_pos.X = channel_startpoint.X + (int) (pixels_betweenticks * (float) value_pos);
+
+ /* Draw thumb fixed 10x22 size */
+ thumb_pos.Width = 10;
+ thumb_pos.Height = 22;
+
+ switch (tb.TickStyle) {
+ case TickStyle.BottomRight:
+ case TickStyle.None: {
+ thumb_pos.Y = channel_startpoint.Y - 8;
+
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 10, thumb_pos.Y);
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 16);
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y + 16, thumb_pos.X + 4, thumb_pos.Y + 16 + 4);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X +9, thumb_pos.Y +15);
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 9, thumb_pos.Y + 16, thumb_pos.X +9 - 4, thumb_pos.Y +16 + 4);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y +16);
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 10, thumb_pos.Y + 16, thumb_pos.X +10 - 5, thumb_pos.Y +16 + 5);
+
+ dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 8, 16);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 17, 6, 1);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 18, 4, 1);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 19, 2, 1);
+ break;
+ }
+ case TickStyle.TopLeft: {
+ thumb_pos.Y = channel_startpoint.Y - 10;
+
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X, thumb_pos.Y + 4 + 16);
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X + 4, thumb_pos.Y);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 9, thumb_pos.Y + 4 + 16);
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y);
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 9, thumb_pos.Y + 19, thumb_pos.X + 1 , thumb_pos.Y +19);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 10, thumb_pos.Y + 4 + 16);
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y -1);
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 10, thumb_pos.Y + 20);
+
+ dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 4, 8, 15);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 3, 6, 1);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 2, 4, 1);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 1, 2, 1);
+ break;
+ }
+
+ case TickStyle.Both: {
+ thumb_pos.Y = area.Y + 10;
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 9, thumb_pos.Y);
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 19);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X + 9, thumb_pos.Y + 19);
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 1, thumb_pos.Y + 10, thumb_pos.X + 8, thumb_pos.Y + 19);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y + 20);
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 9, thumb_pos.Y + 20);
+
+ dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 8, 18);
+
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ pixel_len = thumb_area.Width - 11;
+ pixels_betweenticks = pixel_len / ticks;
+
+ /* Draw ticks*/
+ thumb_area.Y = thumb_pos.Y;
+ thumb_area.X = channel_startpoint.X;
+ thumb_area.Height = thumb_pos.Height;
+ Region outside = new Region (area);
+ outside.Exclude (thumb_area);
+
+ if (outside.IsVisible (clip_rectangle)) {
+ if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
+ ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
+
+ for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
+ if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y,
+ area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y + 3);
+ else
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y,
+ area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y + 2);
+ }
+ }
+
+ if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
+ ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
+
+ for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
+ if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y - 3,
+ area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y);
+ else
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y - 2,
+ area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y );
+ }
+ }
+ }
+
+ outside.Dispose ();
+ }
+
+ public override void DrawTrackBar (Graphics dc, Rectangle clip_rectangle, TrackBar tb)
+ {
+ Brush br_thumb;
+ int value_pos;
+ bool mouse_value;
+ float ticks = (tb.Maximum - tb.Minimum) / tb.tickFrequency; /* N of ticks draw*/
+ Rectangle area;
+ Rectangle thumb_pos = tb.ThumbPos;
+ Rectangle thumb_area = tb.ThumbArea;
+
+ if (tb.thumb_pressed) {
+ value_pos = tb.thumb_mouseclick;
+ mouse_value = true;
+ } else {
+ value_pos = tb.Value - tb.Minimum;
+ mouse_value = false;
+ }
+
+ area = tb.ClientRectangle;
+
+ if (tb.thumb_pressed == true) {
+ br_thumb = (Brush) ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControlLight, ColorControl);
+ } else {
+ br_thumb = ResPool.GetSolidBrush (ColorControl);
+ }
+
+
+ /* Control Background */
+ if (tb.BackColor == DefaultControlBackColor) {
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), clip_rectangle);
+ } else {
+ dc.FillRectangle (ResPool.GetSolidBrush (tb.BackColor), clip_rectangle);
+ }
+
+
+ if (tb.Focused) {
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControl, Color.Black), area.X, area.Y, area.Width - 1, 1);
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControl, Color.Black), area.X, area.Y + area.Height - 1, area.Width - 1, 1);
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControl, Color.Black), area.X, area.Y, 1, area.Height - 1);
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControl, Color.Black), area.X + area.Width - 1, area.Y, 1, area.Height - 1);
+ }
+
+ if (tb.Orientation == Orientation.Vertical) {
+ DrawTrackBar_Vertical (dc, clip_rectangle, tb, ref thumb_pos, ref thumb_area,
+ br_thumb, ticks, value_pos, mouse_value);
+
+ } else {
+ DrawTrackBar_Horizontal (dc, clip_rectangle, tb, ref thumb_pos, ref thumb_area,
+ br_thumb, ticks, value_pos, mouse_value);
+ }
+
+ tb.ThumbPos = thumb_pos;
+ tb.ThumbArea = thumb_area;
+ }
+
+ public override Size TrackBarDefaultSize {
+ get {
+ return new Size (104, 42);
+ }
+ }
+
+ #endregion // TrackBar
+
+ #region VScrollBar
+ public override Size VScrollBarDefaultSize {
+ get {
+ return new Size (this.ScrollBarButtonSize, 80);
+ }
+ }
+ #endregion // VScrollBar
+
+ #region TreeView
+ public override Size TreeViewDefaultSize {
+ get {
+ return new Size (121, 97);
+ }
+ }
+
+ #endregion
+
+ #region ControlPaint
+ private enum DrawFrameControlStates {
+ ButtonCheck = 0x0000,
+ ButtonRadioImage = 0x0001,
+ ButtonRadioMask = 0x0002,
+ ButtonRadio = 0x0004,
+ Button3State = 0x0008,
+ ButtonPush = 0x0010,
+
+ CaptionClose = 0x0000,
+ CaptionMin = 0x0001,
+ CaptionMax = 0x0002,
+ CaptionRestore = 0x0004,
+ CaptionHelp = 0x0008,
+
+ MenuArrow = 0x0000,
+ MenuCheck = 0x0001,
+ MenuBullet = 0x0002,
+ MenuArrowRight = 0x0004,
+
+ ScrollUp = 0x0000,
+ ScrollDown = 0x0001,
+ ScrollLeft = 0x0002,
+ ScrollRight = 0x0003,
+ ScrollComboBox = 0x0005,
+ ScrollSizeGrip = 0x0008,
+ ScrollSizeGripRight = 0x0010,
+
+ Inactive = 0x0100,
+ Pushed = 0x0200,
+ Checked = 0x0400,
+ Transparent = 0x0800,
+ Hot = 0x1000,
+ AdjustRect = 0x2000,
+ Flat = 0x4000,
+ Mono = 0x8000
+
+ }
+
+ private enum DrawFrameControlTypes {
+ Caption = 1,
+ Menu = 2,
+ Scroll = 3,
+ Button = 4
+ }
+
+ public override void CPDrawBorder (Graphics graphics, Rectangle bounds, Color leftColor, int leftWidth,
+ ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
+ Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor,
+ int bottomWidth, ButtonBorderStyle bottomStyle) {
+ DrawBorderInternal(graphics, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom-1, leftWidth, leftColor, leftStyle, Border3DSide.Left);
+ DrawBorderInternal(graphics, bounds.Left, bounds.Top, bounds.Right-1, bounds.Top, topWidth, topColor, topStyle, Border3DSide.Top);
+ DrawBorderInternal(graphics, bounds.Right-1, bounds.Top, bounds.Right-1, bounds.Bottom-1, rightWidth, rightColor, rightStyle, Border3DSide.Right);
+ DrawBorderInternal(graphics, bounds.Left, bounds.Bottom-1, bounds.Right-1, bounds.Bottom-1, bottomWidth, bottomColor, bottomStyle, Border3DSide.Bottom);
+ }
+
+ public override void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides) {
+ CPDrawBorder3D(graphics, rectangle, style, sides, ColorControl);
+ }
+
+ private void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color)
+ {
+ Pen penTopLeft;
+ Pen penTopLeftInner;
+ Pen penBottomRight;
+ Pen penBottomRightInner;
+ Rectangle rect= new Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
+
+ if ((style & Border3DStyle.Adjust) != 0) {
+ rect.Y -= 2;
+ rect.X -= 2;
+ rect.Width += 4;
+ rect.Height += 4;
+ }
+
+ penTopLeft = penTopLeftInner = penBottomRight = penBottomRightInner = ResPool.GetPen (control_color);
+
+ switch (style) {
+ case Border3DStyle.Raised:
+ penTopLeftInner = ResPool.GetPen (ControlPaint.LightLight (control_color));
+ penBottomRight = ResPool.GetPen (ControlPaint.DarkDark (control_color));
+ penBottomRightInner = ResPool.GetPen (ColorInactiveCaption);
+ break;
+ case Border3DStyle.Sunken:
+ penTopLeft = ResPool.GetPen (ColorInactiveCaption);
+ penTopLeftInner = ResPool.GetPen (ControlPaint.DarkDark (control_color));
+ penBottomRight = ResPool.GetPen (ControlPaint.LightLight (control_color));
+ break;
+ case Border3DStyle.Etched:
+ penTopLeft = penBottomRightInner = ResPool.GetPen (ColorInactiveCaption);
+ penTopLeftInner = penBottomRight = ResPool.GetPen (ControlPaint.LightLight (control_color));
+ break;
+ case Border3DStyle.RaisedOuter:
+ penBottomRight = ResPool.GetPen (ControlPaint.DarkDark (control_color));
+ break;
+ case Border3DStyle.SunkenOuter:
+ penTopLeft = ResPool.GetPen (ColorInactiveCaption);
+ penBottomRight = ResPool.GetPen (ControlPaint.LightLight (control_color));
+ break;
+ case Border3DStyle.RaisedInner:
+ penTopLeft = ResPool.GetPen (ControlPaint.LightLight (control_color));
+ penBottomRight = ResPool.GetPen (ColorInactiveCaption);
+ break;
+ case Border3DStyle.SunkenInner:
+ penTopLeft = ResPool.GetPen (ControlPaint.DarkDark (control_color));
+ break;
+ case Border3DStyle.Flat:
+ penTopLeft = penBottomRight = ResPool.GetPen (ColorInactiveCaption);
+ break;
+ case Border3DStyle.Bump:
+ penTopLeftInner = penBottomRight = ResPool.GetPen (ControlPaint.DarkDark (control_color));
+ break;
+ default:
+ break;
+ }
+
+ if ((sides & Border3DSide.Middle) != 0) {
+ graphics.FillRectangle (ResPool.GetSolidBrush (control_color), rect);
+ }
+
+ if ((sides & Border3DSide.Left) != 0) {
+ graphics.DrawLine (penTopLeft, rect.Left, rect.Bottom - 2, rect.Left, rect.Top);
+ graphics.DrawLine (penTopLeftInner, rect.Left + 1, rect.Bottom - 2, rect.Left + 1, rect.Top);
+ }
+
+ if ((sides & Border3DSide.Top) != 0) {
+ graphics.DrawLine (penTopLeft, rect.Left, rect.Top, rect.Right - 2, rect.Top);
+ graphics.DrawLine (penTopLeftInner, rect.Left + 1, rect.Top + 1, rect.Right - 3, rect.Top + 1);
+ }
+
+ if ((sides & Border3DSide.Right) != 0) {
+ graphics.DrawLine (penBottomRight, rect.Right - 1, rect.Top, rect.Right - 1, rect.Bottom - 1);
+ graphics.DrawLine (penBottomRightInner, rect.Right - 2, rect.Top + 1, rect.Right - 2, rect.Bottom - 2);
+ }
+
+ if ((sides & Border3DSide.Bottom) != 0) {
+ graphics.DrawLine (penBottomRight, rect.Left, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1);
+ graphics.DrawLine (penBottomRightInner, rect.Left + 1, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 2);
+ }
+ }
+
+ public override void CPDrawButton (Graphics graphics, Rectangle rectangle, ButtonState state) {
+ DrawFrameControlStates dfcs=DrawFrameControlStates.ButtonPush;
+
+ if ((state & ButtonState.Pushed)!=0) {
+ dfcs |= DrawFrameControlStates.Pushed;
+ }
+
+ if ((state & ButtonState.Checked)!=0) {
+ dfcs |= DrawFrameControlStates.Checked;
+ }
+
+ if ((state & ButtonState.Flat)!=0) {
+ dfcs |= DrawFrameControlStates.Flat;
+ }
+
+ if ((state & ButtonState.Inactive)!=0) {
+ dfcs |= DrawFrameControlStates.Inactive;
+ }
+ DrawFrameControl(graphics, rectangle, DrawFrameControlTypes.Button, dfcs);
+ }
+
+
+ public override void CPDrawCaptionButton (Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state) {
+ Rectangle captionRect;
+ int lineWidth;
+
+ CPDrawButton(graphics, rectangle, state);
+
+ if (rectangle.Width<rectangle.Height) {
+ captionRect=new Rectangle(rectangle.X+1, rectangle.Y+rectangle.Height/2-rectangle.Width/2+1, rectangle.Width-4, rectangle.Width-4);
+ } else {
+ captionRect=new Rectangle(rectangle.X+rectangle.Width/2-rectangle.Height/2+1, rectangle.Y+1, rectangle.Height-4, rectangle.Height-4);
+ }
+
+ if ((state & ButtonState.Pushed)!=0) {
+ captionRect=new Rectangle(rectangle.X+2, rectangle.Y+2, rectangle.Width-3, rectangle.Height-3);
+ }
+
+ /* Make sure we've got at least a line width of 1 */
+ lineWidth=Math.Max(1, captionRect.Width/7);
+
+ switch(button) {
+ case CaptionButton.Close: {
+ Pen pen;
+
+ if ((state & ButtonState.Inactive)!=0) {
+ pen=new Pen(ColorControlLight, lineWidth);
+ DrawCaptionHelper(graphics, ColorControlLight, pen, lineWidth, 1, captionRect, button);
+ pen.Dispose();
+
+ pen=new Pen(ColorControlDark, lineWidth);
+ DrawCaptionHelper(graphics, ColorControlDark, pen, lineWidth, 0, captionRect, button);
+ pen.Dispose();
+ return;
+ } else {
+ pen=new Pen(ColorControlText, lineWidth);
+ DrawCaptionHelper(graphics, ColorControlText, pen, lineWidth, 0, captionRect, button);
+ pen.Dispose();
+ return;
+ }
+ }
+
+ case CaptionButton.Help:
+ case CaptionButton.Maximize:
+ case CaptionButton.Minimize:
+ case CaptionButton.Restore: {
+ if ((state & ButtonState.Inactive)!=0) {
+ DrawCaptionHelper(graphics, ColorControlLight, SystemPens.ControlLightLight, lineWidth, 1, captionRect, button);
+
+ DrawCaptionHelper(graphics, ColorControlDark, SystemPens.ControlDark, lineWidth, 0, captionRect, button);
+ return;
+ } else {
+ DrawCaptionHelper(graphics, ColorControlText, SystemPens.ControlText, lineWidth, 0, captionRect, button);
+ return;
+ }
+ }
+ }
+ }
+
+
+ public override void CPDrawCheckBox (Graphics graphics, Rectangle rectangle, ButtonState state) {
+ DrawFrameControlStates dfcs=DrawFrameControlStates.ButtonCheck;
+
+ if ((state & ButtonState.Pushed)!=0) {
+ dfcs |= DrawFrameControlStates.Pushed;
+ }
+
+ if ((state & ButtonState.Checked)!=0) {
+ dfcs |= DrawFrameControlStates.Checked;
+ }
+
+ if ((state & ButtonState.Flat)!=0) {
+ dfcs |= DrawFrameControlStates.Flat;
+ }
+
+ if ((state & ButtonState.Inactive)!=0) {
+ dfcs |= DrawFrameControlStates.Inactive;
+ }
+
+ DrawFrameControl(graphics, rectangle, DrawFrameControlTypes.Button, dfcs);
+
+ }
+
+ public override void CPDrawComboButton (Graphics graphics, Rectangle rectangle, ButtonState state) {
+ Point[] arrow = new Point[3];
+ Point P1;
+ Point P2;
+ Point P3;
+ int centerX;
+ int centerY;
+ int shiftX;
+ int shiftY;
+ Rectangle rect;
+
+ if ((state & ButtonState.Checked)!=0) {
+ graphics.FillRectangle(ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControlLightLight, ColorControlLight),rectangle);
+ }
+
+ if ((state & ButtonState.Flat)!=0) {
+ ControlPaint.DrawBorder(graphics, rectangle, ColorControlDark, ButtonBorderStyle.Solid);
+ } else {
+ if ((state & (ButtonState.Pushed | ButtonState.Checked))!=0) {
+ // this needs to render like a pushed button - jba
+ // CPDrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl);
+ Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
+ graphics.DrawRectangle (ResPool.GetPen (ControlPaint.Dark (ColorControl)), trace_rectangle);
+ } else {
+ CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl);
+ }
+ }
+
+ rect=new Rectangle(rectangle.X+rectangle.Width/4, rectangle.Y+rectangle.Height/4, rectangle.Width/2, rectangle.Height/2);
+ centerX=rect.Left+rect.Width/2;
+ centerY=rect.Top+rect.Height/2;
+ shiftX=Math.Max(1, rect.Width/8);
+ shiftY=Math.Max(1, rect.Height/8);
+
+ if ((state & ButtonState.Pushed)!=0) {
+ shiftX++;
+ shiftY++;
+ }
+
+ rect.Y-=shiftY;
+ centerY-=shiftY;
+ P1=new Point(rect.Left, centerY);
+ P2=new Point(rect.Right, centerY);
+ P3=new Point(centerX, rect.Bottom);
+
+ arrow[0]=P1;
+ arrow[1]=P2;
+ arrow[2]=P3;
+
+ /* Draw the arrow */
+ if ((state & ButtonState.Inactive)!=0) {
+ graphics.FillPolygon(SystemBrushes.ControlLightLight, arrow, FillMode.Winding);
+
+ /* Move away from the shadow */
+ P1.X-=1; P1.Y-=1;
+ P2.X-=1; P2.Y-=1;
+ P3.X-=1; P3.Y-=1;
+
+ arrow[0]=P1;
+ arrow[1]=P2;
+ arrow[2]=P3;
+
+
+ graphics.FillPolygon(SystemBrushes.ControlDark, arrow, FillMode.Winding);
+ } else {
+ graphics.FillPolygon(SystemBrushes.ControlText, arrow, FillMode.Winding);
+ }
+ }
+
+
+ public override void CPDrawContainerGrabHandle (Graphics graphics, Rectangle bounds) {
+
+ Pen pen = new Pen(Color.Black, 1);
+ Rectangle rect = new Rectangle(bounds.X, bounds.Y, bounds.Width-1, bounds.Height-1); // Dunno why, but MS does it that way, too
+ int X;
+ int Y;
+
+ graphics.FillRectangle(ResPool.GetSolidBrush (ColorControlText), rect);
+ graphics.DrawRectangle(pen, rect);
+
+ X=rect.X+rect.Width/2;
+ Y=rect.Y+rect.Height/2;
+
+ /* Draw the cross */
+ graphics.DrawLine(pen, X, rect.Y+2, X, rect.Bottom-2);
+ graphics.DrawLine(pen, rect.X+2, Y, rect.Right-2, Y);
+
+ /* Draw 'arrows' for vertical lines */
+ graphics.DrawLine(pen, X-1, rect.Y+3, X+1, rect.Y+3);
+ graphics.DrawLine(pen, X-1, rect.Bottom-3, X+1, rect.Bottom-3);
+
+ /* Draw 'arrows' for horizontal lines */
+ graphics.DrawLine(pen, rect.X+3, Y-1, rect.X+3, Y+1);
+ graphics.DrawLine(pen, rect.Right-3, Y-1, rect.Right-3, Y+1);
+ pen.Dispose ();
+
+ }
+
+ public virtual void DrawFlatStyleFocusRectangle (Graphics graphics, Rectangle rectangle, ButtonBase button, Color foreColor, Color backColor) {
+ // make a rectange to trace around border of the button
+ Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
+
+ Color outerColor = foreColor;
+ // adjust focus color according to the flatstyle
+ if (button.FlatStyle == FlatStyle.Popup && !button.is_pressed) {
+ outerColor = (backColor == ColorControl) ? ControlPaint.Dark(ColorControl) : ColorControlText;
+ }
+
+ // draw the outer rectangle
+ graphics.DrawRectangle (ResPool.GetPen (outerColor), trace_rectangle);
+
+ // draw the inner rectangle
+ if (button.FlatStyle == FlatStyle.Popup) {
+ DrawInnerFocusRectangle (graphics, Rectangle.Inflate (rectangle, -4, -4), backColor);
+ } else {
+ // draw a flat inner rectangle
+ Pen pen = ResPool.GetPen (ControlPaint.LightLight (backColor));
+ graphics.DrawRectangle(pen, Rectangle.Inflate (trace_rectangle, -4, -4));
+ }
+ }
+
+ public virtual void DrawInnerFocusRectangle(Graphics graphics, Rectangle rectangle, Color backColor)
+ {
+ // make a rectange to trace around border of the button
+ Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
+
+#if NotUntilCairoIsFixed
+ Color colorBackInverted = Color.FromArgb (Math.Abs (backColor.R-255), Math.Abs (backColor.G-255), Math.Abs (backColor.B-255));
+ DashStyle oldStyle; // used for caching old penstyle
+ Pen pen = ResPool.GetPen (colorBackInverted);
+
+ oldStyle = pen.DashStyle;
+ pen.DashStyle = DashStyle.Dot;
+
+ graphics.DrawRectangle (pen, trace_rectangle);
+ pen.DashStyle = oldStyle;
+#else
+ CPDrawFocusRectangle(graphics, trace_rectangle, Color.Wheat, backColor);
+#endif
+ }
+
+
+ public override void CPDrawFocusRectangle (Graphics graphics, Rectangle rectangle, Color foreColor, Color backColor)
+ {
+ Rectangle rect = rectangle;
+ Pen pen;
+ HatchBrush brush;
+
+ if (backColor.GetBrightness () >= 0.5) {
+ foreColor = Color.Transparent;
+ backColor = Color.Black;
+
+ } else {
+ backColor = Color.FromArgb (Math.Abs (backColor.R-255), Math.Abs (backColor.G-255), Math.Abs (backColor.B-255));
+ foreColor = Color.Black;
+ }
+
+ brush = ResPool.GetHatchBrush (HatchStyle.Percent50, backColor, foreColor);
+ pen = new Pen (brush, 1);
+
+ rect.Width--;
+ rect.Height--;
+
+ graphics.DrawRectangle (pen, rect);
+ pen.Dispose ();
+ }
+
+ public override void CPDrawGrabHandle (Graphics graphics, Rectangle rectangle, bool primary, bool enabled) {
+ SolidBrush sb;
+ Pen pen;
+
+ if (primary==true) {
+ pen=new Pen(Color.Black, 1);
+ if (enabled==true) {
+ sb=ResPool.GetSolidBrush (ColorControlText);
+ } else {
+ sb=ResPool.GetSolidBrush (ColorControl);
+ }
+ } else {
+ pen=new Pen(Color.White, 1);
+ if (enabled==true) {
+ sb=ResPool.GetSolidBrush (Color.Black);
+ } else {
+ sb=ResPool.GetSolidBrush (ColorControl);
+ }
+ }
+ graphics.FillRectangle(sb, rectangle);
+ graphics.DrawRectangle(pen, rectangle);
+ pen.Dispose();
+ }
+
+
+ public override void CPDrawGrid (Graphics graphics, Rectangle area, Size pixelsBetweenDots, Color backColor) {
+ Color foreColor;
+ int h;
+ int b;
+ int s;
+
+ ControlPaint.Color2HBS(backColor, out h, out b, out s);
+
+ if (b>127) {
+ foreColor=Color.Black;
+ } else {
+ foreColor=Color.White;
+ }
+
+#if false
+ /* Commented out until I take the time and figure out
+ which HatchStyle will match requirements. The code below
+ is only correct for Percent50.
+ */
+ if (pixelsBetweenDots.Width==pixelsBetweenDots.Height) {
+ HatchBrush brush=null;
+
+ switch(pixelsBetweenDots.Width) {
+ case 2: brush=new HatchBrush(HatchStyle.Percent50, foreColor, backColor); break;
+ case 4: brush=new HatchBrush(HatchStyle.Percent25, foreColor, backColor); break;
+ case 5: brush=new HatchBrush(HatchStyle.Percent20, foreColor, backColor); break;
+ default: {
+ /* Have to do it the slow way */
+ break;
+ }
+ }
+ if (brush!=null) {
+ graphics.FillRectangle(brush, area);
+ pen.Dispose();
+ brush.Dispose();
+ return;
+ }
+ }
+#endif
+ /* Slow method */
+
+ Bitmap bitmap = new Bitmap(area.Width, area.Height, graphics);
+
+ for (int x=0; x<area.Width; x+=pixelsBetweenDots.Width) {
+ for (int y=0; y<area.Height; y+=pixelsBetweenDots.Height) {
+ bitmap.SetPixel(x, y, foreColor);
+ }
+ }
+ graphics.DrawImage(bitmap, area.X, area.Y, area.Width, area.Height);
+ bitmap.Dispose();
+ }
+
+ public override void CPDrawImageDisabled (Graphics graphics, Image image, int x, int y, Color background) {
+ /*
+ Microsoft seems to ignore the background and simply make
+ the image grayscale. At least when having > 256 colors on
+ the display.
+ */
+
+ if (imagedisabled_attributes == null) {
+ imagedisabled_attributes = new ImageAttributes ();
+ ColorMatrix colorMatrix=new ColorMatrix(new float[][] {
+ // This table would create a perfect grayscale image, based on luminance
+ // new float[]{0.3f,0.3f,0.3f,0,0},
+ // new float[]{0.59f,0.59f,0.59f,0,0},
+ // new float[]{0.11f,0.11f,0.11f,0,0},
+ // new float[]{0,0,0,1,0,0},
+ // new float[]{0,0,0,0,1,0},
+ // new float[]{0,0,0,0,0,1}
+
+ // This table generates a image that is grayscaled and then
+ // brightened up. Seems to match MS close enough.
+ new float[]{0.2f,0.2f,0.2f,0,0},
+ new float[]{0.41f,0.41f,0.41f,0,0},
+ new float[]{0.11f,0.11f,0.11f,0,0},
+ new float[]{0.15f,0.15f,0.15f,1,0,0},
+ new float[]{0.15f,0.15f,0.15f,0,1,0},
+ new float[]{0.15f,0.15f,0.15f,0,0,1}
+ });
+
+ imagedisabled_attributes.SetColorMatrix (colorMatrix);
+ }
+
+ graphics.DrawImage(image, new Rectangle(x, y, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imagedisabled_attributes);
+
+ }
+
+
+ public override void CPDrawLockedFrame (Graphics graphics, Rectangle rectangle, bool primary) {
+ Pen penBorder;
+ Pen penInside;
+
+ if (primary) {
+ penBorder=new Pen(Color.White, 2);
+ penInside=new Pen(Color.Black, 1);
+ } else {
+ penBorder=new Pen(Color.Black, 2);
+ penInside=new Pen(Color.White, 1);
+ }
+ penBorder.Alignment=PenAlignment.Inset;
+ penInside.Alignment=PenAlignment.Inset;
+
+ graphics.DrawRectangle(penBorder, rectangle);
+ graphics.DrawRectangle(penInside, rectangle.X+2, rectangle.Y+2, rectangle.Width-5, rectangle.Height-5);
+ penBorder.Dispose();
+ penInside.Dispose();
+ }
+
+
+ public override void CPDrawMenuGlyph (Graphics graphics, Rectangle rectangle, MenuGlyph glyph, Color color) {
+ Rectangle rect;
+ int lineWidth;
+
+ Brush brush = ResPool.GetSolidBrush (color);
+
+ switch(glyph) {
+ case MenuGlyph.Arrow: {
+ Point[] arrow = new Point[3];
+ Point P1;
+ Point P2;
+ Point P3;
+ int centerX;
+ int centerY;
+ int shiftX;
+
+ rect=new Rectangle(rectangle.X+rectangle.Width/4, rectangle.Y+rectangle.Height/4, rectangle.Width/2, rectangle.Height/2);
+ centerX=rect.Left+rect.Width/2;
+ centerY=rect.Top+rect.Height/2;
+ shiftX=Math.Max(1, rect.Width/8);
+
+ rect.X-=shiftX;
+ centerX-=shiftX;
+
+ P1=new Point(centerX, rect.Top-1);
+ P2=new Point(centerX, rect.Bottom);
+ P3=new Point(rect.Right, centerY);
+
+ arrow[0]=P1;
+ arrow[1]=P2;
+ arrow[2]=P3;
+
+ graphics.FillPolygon(brush, arrow, FillMode.Winding);
+
+ return;
+ }
+
+ case MenuGlyph.Bullet: {
+
+ lineWidth=Math.Max(2, rectangle.Width/3);
+ rect=new Rectangle(rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2);
+
+ graphics.FillEllipse(brush, rect);
+
+ return;
+ }
+
+ case MenuGlyph.Checkmark: {
+ int Scale;
+ Pen pen = ResPool.GetPen (color);
+
+ lineWidth=Math.Max(2, rectangle.Width/6);
+ Scale=Math.Max(1, rectangle.Width/12);
+
+ rect=new Rectangle(rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2);
+
+ for (int i=0; i<lineWidth; i++) {
+ graphics.DrawLine(pen, rect.Left+lineWidth/2, rect.Top+lineWidth+i, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i);
+ graphics.DrawLine(pen, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i, rect.Left+lineWidth/2+6*Scale, rect.Top+lineWidth-2*Scale+i);
+ }
+ return;
+ }
+ }
+
+ }
+
+ public override void CPDrawRadioButton (Graphics graphics, Rectangle rectangle, ButtonState state) {
+ DrawFrameControlStates dfcs=DrawFrameControlStates.ButtonRadio;
+
+ if ((state & ButtonState.Pushed)!=0) {
+ dfcs |= DrawFrameControlStates.Pushed;
+ }
+
+ if ((state & ButtonState.Checked)!=0) {
+ dfcs |= DrawFrameControlStates.Checked;
+ }
+
+ if ((state & ButtonState.Flat)!=0) {
+ dfcs |= DrawFrameControlStates.Flat;
+ }
+
+ if ((state & ButtonState.Inactive)!=0) {
+ dfcs |= DrawFrameControlStates.Inactive;
+ }
+ DrawFrameControl(graphics, rectangle, DrawFrameControlTypes.Button, dfcs);
+
+ }
+
+
+ public override void CPDrawReversibleFrame (Rectangle rectangle, Color backColor, FrameStyle style) {
+
+ }
+
+
+ public override void CPDrawReversibleLine (Point start, Point end, Color backColor) {
+
+ }
+
+
+ /* Scroll button: regular button + direction arrow */
+ public override void CPDrawScrollButton (Graphics dc, Rectangle area, ScrollButton type, ButtonState state) {
+ DrawScrollButtonPrimitive (dc, area, state);
+
+ int arrow_y_pos_diff = 3;
+
+ switch (type) {
+ case ScrollButton.Up:
+ arrow_y_pos_diff = 2;
+ break;
+ case ScrollButton.Down:
+ arrow_y_pos_diff = 4;
+ break;
+ default:
+ break;
+ }
+
+ // A lot of the following is adapted from the rewind project
+ Rectangle rect = new Rectangle (area.X - 3, area.Y - arrow_y_pos_diff,
+ area.Width + 6, area.Height + 6);
+ int small_diam = rect.Width > rect.Height ? rect.Height : rect.Width;
+ if (rect.Width < rect.Height) {
+ rect.Y += (rect.Height - rect.Width) / 2;
+ rect.Height = small_diam;
+ } else if (rect.Width > rect.Height) {
+ rect.X += (rect.Width - rect.Height) / 2;
+ rect.Width = small_diam;
+ }
+
+ small_diam -= 2;
+
+ int tri = 290 * small_diam / 1000 - 1;
+ if (tri == 0)
+ tri = 1;
+
+ Point [] arrow = new Point [3];
+ for (int i = 0; i < 3; i++)
+ arrow [i] = new Point ();
+
+ switch(type) {
+ default:
+ case ScrollButton.Down:
+ arrow [2].X = rect.Left + 470 * small_diam / 1000 + 2;
+ arrow [2].Y = rect.Top + 687 * small_diam / 1000 + 1;
+ arrow [0].X = arrow [2].X - tri;
+ arrow [1].X = arrow [2].X + tri;
+ arrow [0].Y = arrow [1].Y = arrow [2].Y - tri;
+ break;
+
+ case ScrollButton.Up:
+ arrow [2].X = rect.Left + 470 * small_diam / 1000 + 2;
+ arrow [2].Y = rect.Bottom - (687 * small_diam / 1000 + 1);
+ arrow [0].X = arrow [2].X - tri;
+ arrow [1].X = arrow [2].X + tri;
+ arrow [0].Y = arrow [1].Y = arrow [2].Y + tri;
+ break;
+
+ case ScrollButton.Left:
+ arrow [2].X = rect.Right - (687 * small_diam / 1000 + 1);
+ arrow [2].Y = rect.Top + 470 * small_diam / 1000 + 2;
+ arrow [0].Y = arrow [2].Y - tri;
+ arrow [1].Y = arrow [2].Y + tri;
+ arrow [0].X = arrow [1].X = arrow [2].X + tri;
+ break;
+ // Left and Right are not drawn correctly because of libgdiplus problems
+ // once that is solved change it to the code below to match ms
+// case ScrollButton.Left:
+// arrow [2].X = rect.Right - (687 * small_diam / 1000 + 1);
+// arrow [2].Y = (rect.Top + 470 * small_diam / 1000 + 2) - 1;
+// arrow [1].Y = arrow [2].Y + tri;
+// arrow [0].Y = arrow [2].Y - tri + 1;
+// arrow [0].X = arrow [1].X = arrow [2].X + tri;
+// break;
+ case ScrollButton.Right:
+ arrow [2].X = rect.Left + 687 * small_diam / 1000 + 1;
+ arrow [2].Y = rect.Top + 470 * small_diam / 1000 + 2;
+ arrow [0].Y = arrow [2].Y - tri;
+ arrow [1].Y = arrow [2].Y + tri;
+ arrow [0].X = arrow [1].X = arrow [2].X - tri;
+ break;
+ }
+
+ /* Draw the arrow */
+ if ((state & ButtonState.Inactive)!=0) {
+ dc.FillPolygon (SystemBrushes.ControlLightLight, arrow, FillMode.Winding);
+
+ for (int i = 0; i < 3; i++) {
+ arrow [i].X--;
+ arrow [i].Y--;
+ }
+
+ dc.FillPolygon (SystemBrushes.ControlDark, arrow, FillMode.Winding);
+ } else {
+ dc.FillPolygon (SystemBrushes.ControlText, arrow, FillMode.Winding);
+ }
+ }
+
+ public override void CPDrawSelectionFrame (Graphics graphics, bool active, Rectangle outsideRect, Rectangle insideRect,
+ Color backColor) {
+
+ }
+
+
+ public override void CPDrawSizeGrip (Graphics dc, Color backColor, Rectangle bounds) {
+
+ Point pt = new Point (bounds.Right - 2, bounds.Bottom - 1);
+
+ Pen pen = ResPool.GetPen (ColorControlDark);
+
+ dc.DrawLine (pen, pt.X - 11, pt.Y, pt.X, pt.Y - 11);
+ dc.DrawLine (pen, pt.X - 10, pt.Y, pt.X, pt.Y - 10);
+
+ dc.DrawLine (pen, pt.X - 7, pt.Y, pt.X, pt.Y - 7);
+ dc.DrawLine (pen, pt.X - 6, pt.Y, pt.X, pt.Y - 6);
+
+ dc.DrawLine (pen, pt.X - 3, pt.Y, pt.X, pt.Y - 3);
+ dc.DrawLine (pen, pt.X - 2, pt.Y, pt.X, pt.Y - 2);
+
+ pen = ResPool.GetPen (ColorControlLight);
+
+ dc.DrawLine (pen, pt.X - 12, pt.Y, pt.X, pt.Y - 12);
+ dc.DrawLine (pen, pt.X - 8, pt.Y, pt.X, pt.Y - 8);
+ dc.DrawLine (pen, pt.X - 4, pt.Y, pt.X, pt.Y - 4);
+
+ dc.DrawLine (ResPool.GetPen (ColorControl), pt.X - 12, pt.Y, pt.X, pt.Y);
+ }
+
+
+ public override void CPDrawStringDisabled (Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle,
+ StringFormat format) {
+
+ graphics.DrawString(s, font, ResPool.GetSolidBrush (ColorGrayText), layoutRectangle, format);
+
+ }
+
+ private static void DrawBorderInternal(Graphics graphics, int startX, int startY, int endX, int endY,
+ int width, Color color, ButtonBorderStyle style, Border3DSide side) {
+
+ Pen pen=new Pen(color, 1);
+
+ switch(style) {
+ case ButtonBorderStyle.Solid: {
+ pen.DashStyle=DashStyle.Solid;
+ break;
+ }
+
+ case ButtonBorderStyle.Dashed: {
+ pen.DashStyle=DashStyle.Dash;
+ break;
+ }
+
+ case ButtonBorderStyle.Dotted: {
+ pen.DashStyle=DashStyle.Dot;
+ break;
+ }
+
+ case ButtonBorderStyle.Inset: {
+ pen.DashStyle=DashStyle.Solid;
+ break;
+ }
+
+ case ButtonBorderStyle.Outset: {
+ pen.DashStyle=DashStyle.Solid;
+ break;
+ }
+
+ default:
+ case ButtonBorderStyle.None: {
+ pen.Dispose();
+ return;
+ }
+ }
+
+
+ switch(style) {
+ case ButtonBorderStyle.Outset: {
+ Color colorGrade;
+ int hue, brightness, saturation;
+ int brightnessSteps;
+ int brightnessDownSteps;
+
+ ControlPaint.Color2HBS(color, out hue, out brightness, out saturation);
+
+ brightnessDownSteps=brightness/width;
+ if (brightness>127) {
+ brightnessSteps=Math.Max(6, (160-brightness)/width);
+ } else {
+ brightnessSteps=(127-brightness)/width;
+ }
+
+ for (int i=0; i<width; i++) {
+ switch(side) {
+ case Border3DSide.Left: {
+ pen.Dispose();
+ colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
+ pen=new Pen(colorGrade, 1);
+ graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
+ break;
+ }
+
+ case Border3DSide.Right: {
+ pen.Dispose();
+ colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
+ pen=new Pen(colorGrade, 1);
+ graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
+ break;
+ }
+
+ case Border3DSide.Top: {
+ pen.Dispose();
+ colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
+ pen=new Pen(colorGrade, 1);
+ graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
+ break;
+ }
+
+ case Border3DSide.Bottom: {
+ pen.Dispose();
+ colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
+ pen=new Pen(colorGrade, 1);
+ graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
+ break;
+ }
+ }
+ }
+ break;
+ }
+
+ case ButtonBorderStyle.Inset: {
+ Color colorGrade;
+ int hue, brightness, saturation;
+ int brightnessSteps;
+ int brightnessDownSteps;
+
+ ControlPaint.Color2HBS(color, out hue, out brightness, out saturation);
+
+ brightnessDownSteps=brightness/width;
+ if (brightness>127) {
+ brightnessSteps=Math.Max(6, (160-brightness)/width);
+ } else {
+ brightnessSteps=(127-brightness)/width;
+ }
+
+ for (int i=0; i<width; i++) {
+ switch(side) {
+ case Border3DSide.Left: {
+ pen.Dispose();
+ colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
+ pen=new Pen(colorGrade, 1);
+ graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
+ break;
+ }
+
+ case Border3DSide.Right: {
+ pen.Dispose();
+ colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
+ pen=new Pen(colorGrade, 1);
+ graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
+ break;
+ }
+
+ case Border3DSide.Top: {
+ pen.Dispose();
+ colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
+ pen=new Pen(colorGrade, 1);
+ graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
+ break;
+ }
+
+ case Border3DSide.Bottom: {
+ pen.Dispose();
+ colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
+ pen=new Pen(colorGrade, 1);
+ graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
+ break;
+ }
+ }
+ }
+ break;
+ }
+
+ /*
+ I decided to have the for-loop duplicated for speed reasons;
+ that way we only have to switch once (as opposed to have the
+ for-loop around the switch)
+ */
+ default: {
+ switch(side) {
+ case Border3DSide.Left: {
+ for (int i=0; i<width; i++) {
+ graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
+ }
+ break;
+ }
+
+ case Border3DSide.Right: {
+ for (int i=0; i<width; i++) {
+ graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
+ }
+ break;
+ }
+
+ case Border3DSide.Top: {
+ for (int i=0; i<width; i++) {
+ graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
+ }
+ break;
+ }
+
+ case Border3DSide.Bottom: {
+ for (int i=0; i<width; i++) {
+ graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
+ }
+ break;
+ }
+ }
+ break;
+ }
+ }
+ pen.Dispose();
+ }
+
+ /*
+ This function actually draws the various caption elements.
+ This way we can scale them nicely, no matter what size, and they
+ still look like MS's scaled caption buttons. (as opposed to scaling a bitmap)
+ */
+
+ private void DrawCaptionHelper(Graphics graphics, Color color, Pen pen, int lineWidth, int shift, Rectangle captionRect, CaptionButton button) {
+ switch(button) {
+ case CaptionButton.Close: {
+ pen.StartCap=LineCap.Triangle;
+ pen.EndCap=LineCap.Triangle;
+ if (lineWidth<2) {
+ graphics.DrawLine(pen, captionRect.Left+2*lineWidth+1+shift, captionRect.Top+2*lineWidth+shift, captionRect.Right-2*lineWidth+1+shift, captionRect.Bottom-2*lineWidth+shift);
+ graphics.DrawLine(pen, captionRect.Right-2*lineWidth+1+shift, captionRect.Top+2*lineWidth+shift, captionRect.Left+2*lineWidth+1+shift, captionRect.Bottom-2*lineWidth+shift);
+ }
+
+ graphics.DrawLine(pen, captionRect.Left+2*lineWidth+shift, captionRect.Top+2*lineWidth+shift, captionRect.Right-2*lineWidth+shift, captionRect.Bottom-2*lineWidth+shift);
+ graphics.DrawLine(pen, captionRect.Right-2*lineWidth+shift, captionRect.Top+2*lineWidth+shift, captionRect.Left+2*lineWidth+shift, captionRect.Bottom-2*lineWidth+shift);
+ return;
+ }
+
+ case CaptionButton.Help: {
+ StringFormat sf = new StringFormat();
+ Font font = new Font("Microsoft Sans Serif", captionRect.Height, FontStyle.Bold, GraphicsUnit.Pixel);
+
+ sf.Alignment=StringAlignment.Center;
+ sf.LineAlignment=StringAlignment.Center;
+
+
+ graphics.DrawString("?", font, ResPool.GetSolidBrush (color), captionRect.X+captionRect.Width/2+shift, captionRect.Y+captionRect.Height/2+shift+lineWidth/2, sf);
+
+ sf.Dispose();
+ font.Dispose();
+
+ return;
+ }
+
+ case CaptionButton.Maximize: {
+ /* Top 'caption bar' line */
+ for (int i=0; i<Math.Max(2, lineWidth); i++) {
+ graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Top+2*lineWidth+shift+i, captionRect.Right-lineWidth-lineWidth/2+shift, captionRect.Top+2*lineWidth+shift+i);
+ }
+
+ /* Left side line */
+ for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
+ graphics.DrawLine(pen, captionRect.Left+lineWidth+shift+i, captionRect.Top+2*lineWidth+shift, captionRect.Left+lineWidth+shift+i, captionRect.Bottom-lineWidth+shift);
+ }
+
+ /* Right side line */
+ for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
+ graphics.DrawLine(pen, captionRect.Right-lineWidth-lineWidth/2+shift+i, captionRect.Top+2*lineWidth+shift, captionRect.Right-lineWidth-lineWidth/2+shift+i, captionRect.Bottom-lineWidth+shift);
+ }
+
+ /* Bottom line */
+ for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
+ graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-lineWidth-lineWidth/2+shift, captionRect.Bottom-lineWidth+shift-i);
+ }
+ return;
+ }
+
+ case CaptionButton.Minimize: {
+ /* Bottom line */
+ for (int i=0; i<Math.Max(2, lineWidth); i++) {
+ graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-3*lineWidth+shift, captionRect.Bottom-lineWidth+shift-i);
+ }
+ return;
+ }
+
+ case CaptionButton.Restore: {
+ /** First 'window' **/
+ /* Top 'caption bar' line */
+ for (int i=0; i<Math.Max(2, lineWidth); i++) {
+ graphics.DrawLine(pen, captionRect.Left+3*lineWidth+shift, captionRect.Top+2*lineWidth+shift-i, captionRect.Right-lineWidth-lineWidth/2+shift, captionRect.Top+2*lineWidth+shift-i);
+ }
+
+ /* Left side line */
+ for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
+ graphics.DrawLine(pen, captionRect.Left+3*lineWidth+shift+i, captionRect.Top+2*lineWidth+shift, captionRect.Left+3*lineWidth+shift+i, captionRect.Top+4*lineWidth+shift);
+ }
+
+ /* Right side line */
+ for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
+ graphics.DrawLine(pen, captionRect.Right-lineWidth-lineWidth/2+shift-i, captionRect.Top+2*lineWidth+shift, captionRect.Right-lineWidth-lineWidth/2+shift-i, captionRect.Top+5*lineWidth-lineWidth/2+shift);
+ }
+
+ /* Bottom line */
+ for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
+ graphics.DrawLine(pen, captionRect.Right-3*lineWidth-lineWidth/2+shift, captionRect.Top+5*lineWidth-lineWidth/2+shift+1+i, captionRect.Right-lineWidth-lineWidth/2+shift, captionRect.Top+5*lineWidth-lineWidth/2+shift+1+i);
+ }
+
+ /** Second 'window' **/
+ /* Top 'caption bar' line */
+ for (int i=0; i<Math.Max(2, lineWidth); i++) {
+ graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Top+4*lineWidth+shift+1-i, captionRect.Right-3*lineWidth-lineWidth/2+shift, captionRect.Top+4*lineWidth+shift+1-i);
+ }
+
+ /* Left side line */
+ for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
+ graphics.DrawLine(pen, captionRect.Left+lineWidth+shift+i, captionRect.Top+4*lineWidth+shift+1, captionRect.Left+lineWidth+shift+i, captionRect.Bottom-lineWidth+shift);
+ }
+
+ /* Right side line */
+ for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
+ graphics.DrawLine(pen, captionRect.Right-3*lineWidth-lineWidth/2+shift-i, captionRect.Top+4*lineWidth+shift+1, captionRect.Right-3*lineWidth-lineWidth/2+shift-i, captionRect.Bottom-lineWidth+shift);
+ }
+
+ /* Bottom line */
+ for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
+ graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-3*lineWidth-lineWidth/2+shift, captionRect.Bottom-lineWidth+shift-i);
+ }
+
+ return;
+ }
+
+ }
+ }
+
+ [MonoTODO("Finish drawing code for Caption, Menu and Scroll")]
+ private void DrawFrameControl(Graphics graphics, Rectangle rectangle, DrawFrameControlTypes Type, DrawFrameControlStates State) {
+ // make a rectange to trace around border of the button
+ Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
+ switch(Type) {
+ case DrawFrameControlTypes.Button: {
+
+ if ((State & DrawFrameControlStates.ButtonPush)!=0) {
+// JBA 31 oct 2004 - I don't think that button style should be rendered like this
+// /* Goes first, affects the background */
+// if ((State & DrawFrameControlStates.Checked)!=0) {
+// HatchBrush hatchBrush=new HatchBrush(HatchStyle.Percent50, ColorControlLightLight, ColorControlLight);
+// graphics.FillRectangle(hatchBrush,rectangle);
+// hatchBrush.Dispose();
+// }
+
+ if ((State & DrawFrameControlStates.Pushed)!=0 || (State & DrawFrameControlStates.Checked)!=0) {
+ graphics.DrawRectangle (ResPool.GetPen (ControlPaint.Dark (ColorControl)), trace_rectangle);
+ } else if ((State & DrawFrameControlStates.Flat)!=0) {
+ ControlPaint.DrawBorder(graphics, rectangle, ColorControlDark, ButtonBorderStyle.Solid);
+ } else
+ CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl);
+ } else if ((State & DrawFrameControlStates.ButtonRadio)!=0) {
+ Pen penFatDark = new Pen(ColorControlDark, 1);
+ Pen penFatLight = new Pen(ColorControlLightLight, 1);
+ int lineWidth;
+
+ graphics.FillPie (ResPool.GetSolidBrush (this.ColorWindow), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
+
+ graphics.DrawArc(penFatDark, rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 135, 180);
+ graphics.DrawArc(penFatLight, rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 315, 180);
+
+ graphics.DrawArc(SystemPens.ControlDark, rectangle, 135, 180);
+ graphics.DrawArc(SystemPens.ControlLightLight, rectangle, 315, 180);
+
+ lineWidth=Math.Max(1, Math.Min(rectangle.Width, rectangle.Height)/3);
+
+ if ((State & DrawFrameControlStates.Checked)!=0) {
+ SolidBrush buttonBrush;
+
+ if ((State & DrawFrameControlStates.Inactive)!=0) {
+ buttonBrush=(SolidBrush)SystemBrushes.ControlDark;
+ } else {
+ buttonBrush=(SolidBrush)SystemBrushes.ControlText;
+ }
+ graphics.FillPie(buttonBrush, rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2, 0, 359);
+ }
+ penFatDark.Dispose();
+ penFatLight.Dispose();
+ } else if ((State & DrawFrameControlStates.ButtonRadioImage)!=0) {
+ throw new NotImplementedException () ;
+ } else if ((State & DrawFrameControlStates.ButtonRadioMask)!=0) {
+ throw new NotImplementedException ();
+ } else { /* Must be Checkbox */
+ Pen pen;
+ int lineWidth;
+ Rectangle rect;
+ int Scale;
+
+ /* Goes first, affects the background */
+ if ((State & DrawFrameControlStates.Pushed)!=0 ||
+ (State & DrawFrameControlStates.Inactive)!=0) {
+ graphics.FillRectangle(SystemBrushes.Control, rectangle);
+ } else {
+ graphics.FillRectangle(SystemBrushes.Window, rectangle);
+ }
+
+ /* Draw the sunken frame */
+ if ((State & DrawFrameControlStates.Flat)!=0) {
+ ControlPaint.DrawBorder(graphics, rectangle, ColorControlDark, ButtonBorderStyle.Solid);
+ } else {
+ CPDrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl);
+ }
+
+ /* Make sure we've got at least a line width of 1 */
+ lineWidth=Math.Max(3, rectangle.Width/6);
+ Scale=Math.Max(1, rectangle.Width/12);
+
+ // define a rectangle inside the border area
+ rect=new Rectangle(rectangle.X+2, rectangle.Y+2, rectangle.Width-4, rectangle.Height-4);
+ if ((State & DrawFrameControlStates.Inactive)!=0) {
+ pen=SystemPens.ControlDark;
+ } else {
+ pen=SystemPens.ControlText;
+ }
+
+ if ((State & DrawFrameControlStates.Checked)!=0) {
+ /* Need to draw a check-mark */
+ for (int i=0; i<lineWidth; i++) {
+ graphics.DrawLine(pen, rect.Left+lineWidth/2, rect.Top+lineWidth+i, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i);
+ graphics.DrawLine(pen, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i, rect.Left+lineWidth/2+6*Scale, rect.Top+lineWidth-2*Scale+i);
+ }
+
+ }
+ }
+ return;
+ }
+
+ case DrawFrameControlTypes.Caption: {
+ // FIXME:
+ break;
+ }
+
+ case DrawFrameControlTypes.Menu: {
+ // FIXME:
+ break;
+ }
+
+ case DrawFrameControlTypes.Scroll: {
+ // FIXME:
+ break;
+ }
+ }
+ }
+
+ /* Generic scroll button */
+ public void DrawScrollButtonPrimitive (Graphics dc, Rectangle area, ButtonState state) {
+ if ((state & ButtonState.Pushed) == ButtonState.Pushed) {
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), area.X + 1,
+ area.Y + 1, area.Width - 2 , area.Height - 2);
+
+ dc.DrawRectangle (ResPool.GetPen (ColorControlDark), area.X,
+ area.Y, area.Width, area.Height);
+
+ return;
+ }
+
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), area.X, area.Y, area.Width, 1);
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), area.X, area.Y, 1, area.Height);
+
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorControlLight), area.X + 1, area.Y + 1, area.Width - 1, 1);
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorControlLight), area.X + 1, area.Y + 2, 1,
+ area.Height - 4);
+
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDark), area.X + 1, area.Y + area.Height - 2,
+ area.Width - 2, 1);
+
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDarkDark), area.X, area.Y + area.Height -1,
+ area.Width , 1);
+
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDark), area.X + area.Width - 2,
+ area.Y + 1, 1, area.Height -3);
+
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDarkDark), area.X + area.Width -1,
+ area.Y, 1, area.Height - 1);
+
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), area.X + 2,
+ area.Y + 2, area.Width - 4, area.Height - 4);
+
+ }
+
+ public override void CPDrawBorderStyle (Graphics dc, Rectangle area, BorderStyle border_style) {
+ switch (border_style){
+ case BorderStyle.Fixed3D:
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), area.X, area.Y, area.X +area.Width, area.Y);
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), area.X, area.Y, area.X, area.Y + area.Height);
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), area.X , area.Y + area.Height - 1, area.X + area.Width ,
+ area.Y + area.Height - 1);
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), area.X + area.Width -1 , area.Y, area.X + area.Width -1,
+ area.Y + area.Height);
+
+ dc.DrawLine (ResPool.GetPen (ColorActiveBorder), area.X + 1, area.Bottom - 2, area.Right - 2, area.Bottom - 2);
+ dc.DrawLine (ResPool.GetPen (ColorActiveBorder), area.Right - 2, area.Top + 1, area.Right - 2, area.Bottom - 2);
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), area.X + 1, area.Top + 1, area.X + 1, area.Bottom - 3);
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), area.X + 1, area.Top + 1, area.Right - 3, area.Top + 1);
+ break;
+ case BorderStyle.FixedSingle:
+ dc.DrawRectangle (ResPool.GetPen (ColorWindowFrame), area.X, area.Y, area.Width - 1, area.Height - 1);
+ break;
+ case BorderStyle.None:
+ default:
+ break;
+ }
+
+ }
+ #endregion // ControlPaint
+
+
+ } //class
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThreadExceptionDialog.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThreadExceptionDialog.cs
new file mode 100644
index 00000000000..9f63bb79e25
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThreadExceptionDialog.cs
@@ -0,0 +1,203 @@
+//
+// System.Windows.Forms.ThreadExceptionDialog.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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:
+// Marek Safar marek.safar@seznam.cz
+//
+// Copyright (C) Novell Inc., 2004
+
+// COMPLETE - BUT DISABLED TEXTBOX
+
+using System;
+using System.Text;
+using System.Reflection;
+
+namespace System.Windows.Forms
+{
+ public class ThreadExceptionDialog: Form
+ {
+ Exception e;
+ bool details;
+
+ private System.Windows.Forms.Button buttonIgnore;
+ private System.Windows.Forms.Button buttonAbort;
+ private System.Windows.Forms.Button buttonDetails;
+ private System.Windows.Forms.Label labelException;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.TextBox textBoxDetails;
+ private System.Windows.Forms.Label helpText;
+
+ private void InitializeComponent()
+ {
+ this.helpText = new System.Windows.Forms.Label();
+ this.buttonAbort = new System.Windows.Forms.Button();
+ this.buttonIgnore = new System.Windows.Forms.Button();
+ this.buttonDetails = new System.Windows.Forms.Button();
+ this.labelException = new System.Windows.Forms.Label();
+ this.textBoxDetails = new System.Windows.Forms.TextBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // helpText
+ //
+ this.helpText.Location = new System.Drawing.Point(60, 8);
+ this.helpText.Name = "helpText";
+ this.helpText.Size = new System.Drawing.Size(356, 40);
+ this.helpText.TabIndex = 0;
+ this.helpText.Text = "An unhandled exception has occurred in you application. If you click Ignore the a" +
+ "pplication will ignore this error and attempt to continue. If you click Abort, t" +
+ "he application will quit immediately.";
+ //
+ // buttonAbort
+ //
+ this.buttonAbort.DialogResult = System.Windows.Forms.DialogResult.Abort;
+ this.buttonAbort.Location = new System.Drawing.Point(332, 112);
+ this.buttonAbort.Name = "buttonAbort";
+ this.buttonAbort.Size = new System.Drawing.Size(85, 23);
+ this.buttonAbort.TabIndex = 4;
+ this.buttonAbort.Text = "&Abort";
+ this.buttonAbort.Click += new System.EventHandler(this.buttonAbort_Click);
+ //
+ // buttonIgnore
+ //
+ this.buttonIgnore.DialogResult = System.Windows.Forms.DialogResult.Ignore;
+ this.buttonIgnore.Location = new System.Drawing.Point(236, 112);
+ this.buttonIgnore.Name = "buttonIgnore";
+ this.buttonIgnore.Size = new System.Drawing.Size(85, 23);
+ this.buttonIgnore.TabIndex = 3;
+ this.buttonIgnore.Text = "&Ignore";
+ //
+ // buttonDetails
+ //
+ this.buttonDetails.Location = new System.Drawing.Point(140, 112);
+ this.buttonDetails.Name = "buttonDetails";
+ this.buttonDetails.Size = new System.Drawing.Size(85, 23);
+ this.buttonDetails.TabIndex = 2;
+ this.buttonDetails.Text = "Show &Details";
+ this.buttonDetails.Click += new System.EventHandler(this.buttonDetails_Click);
+ //
+ // labelException
+ //
+ this.labelException.Location = new System.Drawing.Point(60, 64);
+ this.labelException.Name = "labelException";
+ this.labelException.Size = new System.Drawing.Size(356, 32);
+ this.labelException.TabIndex = 1;
+ //
+ // textBoxDetails
+ //
+ this.textBoxDetails.Location = new System.Drawing.Point(8, 168);
+ this.textBoxDetails.Multiline = true;
+ this.textBoxDetails.Name = "textBoxDetails";
+ this.textBoxDetails.ReadOnly = true;
+ this.textBoxDetails.ScrollBars = System.Windows.Forms.ScrollBars.Both;
+ this.textBoxDetails.Size = new System.Drawing.Size(408, 196);
+ this.textBoxDetails.TabIndex = 5;
+ this.textBoxDetails.TabStop = false;
+ this.textBoxDetails.Text = "";
+ this.textBoxDetails.WordWrap = false;
+ //
+ // label1
+ //
+ this.label1.Location = new System.Drawing.Point(8, 148);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(100, 16);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Exception details";
+ //
+ // ThreadExceptionDialog
+ //
+ this.AcceptButton = this.buttonIgnore;
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.CancelButton = this.buttonAbort;
+ this.ClientSize = new System.Drawing.Size(428, 374);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.textBoxDetails);
+ this.Controls.Add(this.labelException);
+ this.Controls.Add(this.buttonDetails);
+ this.Controls.Add(this.buttonIgnore);
+ this.Controls.Add(this.buttonAbort);
+ this.Controls.Add(this.helpText);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "ThreadExceptionDialog";
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.TopMost = true;
+ this.ResumeLayout(false);
+ }
+
+ public ThreadExceptionDialog (Exception e)
+ {
+ this.e = e;
+ InitializeComponent ();
+
+ this.labelException.Text = e.Message;
+ if (Form.ActiveForm != null)
+ this.Text = Form.ActiveForm.Text;
+ else
+ this.Text = "Mono";
+ this.buttonAbort.Enabled = Application.AllowQuit;
+ RefreshDetails ();
+ FillExceptionDetails ();
+ }
+
+ void buttonDetails_Click(object sender, System.EventArgs e)
+ {
+ details = !details;
+ RefreshDetails ();
+ }
+
+ void FillExceptionDetails ()
+ {
+ StringBuilder sb = new StringBuilder ();
+ sb.Append (e.ToString ());
+ sb.Append (Environment.NewLine + Environment.NewLine);
+ sb.Append ("Loaded assemblies:" + Environment.NewLine + Environment.NewLine);
+
+ foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies ()) {
+ AssemblyName an = a.GetName ();
+ sb.AppendFormat ("Name:\t{0}" + Environment.NewLine, an.Name);
+ sb.AppendFormat ("Version:\t{0}" + Environment.NewLine, an.Version);
+ sb.AppendFormat ("Location:\t{0}" + Environment.NewLine, an.CodeBase);
+ sb.Append (Environment.NewLine);
+ }
+ textBoxDetails.Text = sb.ToString ();
+ }
+
+ void RefreshDetails ()
+ {
+ if (details) {
+ buttonDetails.Text = "Hide &Details";
+ Height = 410;
+ return;
+ }
+ buttonDetails.Text = "Show &Details";
+ Height = 180;
+ }
+
+ void buttonAbort_Click(object sender, System.EventArgs e)
+ {
+ Application.Exit ();
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TickStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TickStyle.cs
new file mode 100644
index 00000000000..873917dc0b9
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TickStyle.cs
@@ -0,0 +1,40 @@
+//
+// System.Windows.Forms.TickStyle.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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
+//
+// Copyright (C) Novell Inc., 2004
+//
+//
+
+
+namespace System.Windows.Forms
+{
+ public enum TickStyle
+ {
+ None = 0,
+ TopLeft = 1,
+ BottomRight = 2,
+ Both = 3,
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Timer.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Timer.cs
new file mode 100644
index 00000000000..8395e86df72
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Timer.cs
@@ -0,0 +1,149 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+using System;
+using System.Threading;
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+ [DefaultProperty("Interval")]
+ [DefaultEvent("Tick")]
+ [ToolboxItemFilter("System.Windows.Forms", ToolboxItemFilterType.Allow)]
+ public class Timer : Component {
+
+ private bool enabled;
+ private IContainer container;
+ private int interval = 100;
+ private DateTime expires;
+
+ internal static readonly int Minimum = 15;
+
+ public Timer ()
+ {
+ enabled = false;
+ }
+
+ public Timer (IContainer container) : this ()
+ {
+ container.Add (this);
+ }
+
+ [DefaultValue (false)]
+ public virtual bool Enabled {
+ get {
+ return enabled;
+ }
+ set {
+ if (value != enabled) {
+ enabled = value;
+ if (value) {
+ // Use AddTicks so we get some rounding
+ expires = DateTime.Now.AddMilliseconds (interval > Minimum ? interval : Minimum);
+ XplatUI.SetTimer (this);
+ } else {
+ XplatUI.KillTimer (this);
+ }
+ }
+ }
+ }
+
+ [DefaultValue (100)]
+ public int Interval {
+ get {
+ return interval;
+ }
+ set {
+ if (interval == value) {
+ return;
+ }
+
+ interval = value;
+
+ // Use AddTicks so we get some rounding
+ expires = DateTime.Now.AddMilliseconds (interval > Minimum ? interval : Minimum);
+
+ if (enabled == true) {
+ XplatUI.KillTimer (this);
+ XplatUI.SetTimer (this);
+ }
+ }
+ }
+
+ public void Start ()
+ {
+ Enabled = true;
+ }
+
+ public void Stop ()
+ {
+ Enabled = false;
+ }
+
+ internal DateTime Expires {
+ get {
+ return expires;
+ }
+ }
+
+ public event EventHandler Tick;
+
+ public override string ToString ()
+ {
+ return base.ToString () + ", Interval: " + Interval;
+ }
+
+ internal void Update (DateTime update)
+ {
+ expires = update.AddMilliseconds (interval > Minimum ? interval : Minimum);
+ }
+
+ internal void FireTick ()
+ {
+ OnTick (EventArgs.Empty);
+ }
+
+
+ protected virtual void OnTick (EventArgs e)
+ {
+ if (Tick != null)
+ Tick (this, e);
+ }
+
+ protected override void Dispose (bool disposing)
+ {
+ base.Dispose (disposing);
+ Enabled = false;
+ }
+
+ private bool has_last_fire = false;
+ private DateTime last_fire;
+
+ internal void TickHandler (object sender, EventArgs e)
+ {
+ OnTick (e);
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBar.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBar.cs
new file mode 100644
index 00000000000..aa5b1abbf2d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBar.cs
@@ -0,0 +1,890 @@
+// System.Windows.Forms.ToolBar.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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:
+// Ravindra (rkumar@novell.com)
+// Mike Kestner <mkestner@novell.com>
+//
+// TODO:
+// - Tooltip
+//
+// Copyright (C) 2004-2006 Novell, Inc. (http://www.novell.com)
+//
+
+
+// NOT COMPLETE
+
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+ [DefaultEvent ("ButtonClick")]
+ [DefaultProperty ("Buttons")]
+ [Designer ("System.Windows.Forms.Design.ToolBarDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ public class ToolBar : Control
+ {
+ #region Instance Variables
+ bool size_specified = false;
+ ToolBarButton current_button;
+ #endregion Instance Variables
+
+ #region Events
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler BackColorChanged {
+ add { base.BackColorChanged += value; }
+ remove { base.BackColorChanged -= value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler BackgroundImageChanged {
+ add { base.BackgroundImageChanged += value; }
+ remove { base.BackgroundImageChanged -= value; }
+ }
+
+ public event ToolBarButtonClickEventHandler ButtonClick;
+ public event ToolBarButtonClickEventHandler ButtonDropDown;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler ForeColorChanged {
+ add { base.ForeColorChanged += value; }
+ remove { base.ForeColorChanged -= value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler ImeModeChanged {
+ add { base.ImeModeChanged += value; }
+ remove { base.ImeModeChanged -= value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event PaintEventHandler Paint {
+ add { base.Paint += value; }
+ remove { base.Paint -= value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler RightToLeftChanged {
+ add { base.RightToLeftChanged += value; }
+ remove { base.RightToLeftChanged -= value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler TextChanged {
+ add { base.TextChanged += value; }
+ remove { base.TextChanged -= value; }
+ }
+ #endregion Events
+
+ #region Constructor
+ public ToolBar ()
+ {
+ background_color = ThemeEngine.Current.DefaultControlBackColor;
+ foreground_color = ThemeEngine.Current.DefaultControlForeColor;
+ buttons = new ToolBarButtonCollection (this);
+ dock_style = DockStyle.Top;
+
+ MouseDown += new MouseEventHandler (ToolBar_MouseDown);
+ MouseLeave += new EventHandler (ToolBar_MouseLeave);
+ MouseMove += new MouseEventHandler (ToolBar_MouseMove);
+ MouseUp += new MouseEventHandler (ToolBar_MouseUp);
+ Paint += new PaintEventHandler (ToolBar_Paint);
+
+ SetStyle (ControlStyles.UserPaint, false);
+ SetStyle (ControlStyles.FixedHeight, true);
+ }
+ #endregion Constructor
+
+ #region protected Properties
+ protected override CreateParams CreateParams
+ {
+ get { return base.CreateParams; }
+ }
+
+ protected override ImeMode DefaultImeMode {
+ get { return ImeMode.Disable; }
+ }
+
+ protected override Size DefaultSize {
+ get { return ThemeEngine.Current.ToolBarDefaultSize; }
+ }
+ #endregion
+
+ ToolBarAppearance appearance = ToolBarAppearance.Normal;
+
+ #region Public Properties
+ [DefaultValue (ToolBarAppearance.Normal)]
+ [Localizable (true)]
+ public ToolBarAppearance Appearance {
+ get { return appearance; }
+ set {
+ if (value == appearance)
+ return;
+
+ appearance = value;
+ Redraw (false);
+ }
+ }
+
+ bool autosize = true;
+
+ [DefaultValue (true)]
+ [Localizable (true)]
+ public bool AutoSize {
+ get { return autosize; }
+ set {
+ if (value == autosize)
+ return;
+
+ autosize = value;
+ Redraw (true);
+ }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override Color BackColor {
+ get { return background_color; }
+ set {
+ if (value == background_color)
+ return;
+
+ background_color = value;
+ OnBackColorChanged (EventArgs.Empty);
+ Redraw (false);
+ }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override Image BackgroundImage {
+ get { return background_image; }
+ set {
+ if (value == background_image)
+ return;
+
+ background_image = value;
+ OnBackgroundImageChanged (EventArgs.Empty);
+ Redraw (false);
+ }
+ }
+
+ [DefaultValue (BorderStyle.None)]
+ [DispIdAttribute (-504)]
+ public BorderStyle BorderStyle {
+ get { return InternalBorderStyle; }
+ set { InternalBorderStyle = value; }
+ }
+
+ ToolBarButtonCollection buttons;
+
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
+ [Localizable (true)]
+ [MergableProperty (false)]
+ public ToolBarButtonCollection Buttons {
+ get { return buttons; }
+ }
+
+ Size button_size;
+
+ [Localizable (true)]
+ [RefreshProperties (RefreshProperties.All)]
+ public Size ButtonSize {
+ get {
+ if (button_size.IsEmpty) {
+ if (buttons.Count == 0)
+ return new Size (39, 36);
+ else
+ return CalcButtonSize ();
+ }
+ return button_size;
+ }
+ set {
+ size_specified = true;
+ if (button_size == value)
+ return;
+
+ button_size = value;
+ Redraw (true);
+ }
+ }
+
+ bool divider = true;
+
+ [DefaultValue (true)]
+ public bool Divider {
+ get { return divider; }
+ set {
+ if (value == divider)
+ return;
+
+ divider = value;
+ Redraw (false);
+ }
+ }
+
+ [DefaultValue (DockStyle.Top)]
+ [Localizable (true)]
+ public override DockStyle Dock {
+ get { return base.Dock; }
+ set { base.Dock = value; }
+ }
+
+ bool drop_down_arrows = false;
+
+ [DefaultValue (false)]
+ [Localizable (true)]
+ public bool DropDownArrows {
+ get { return drop_down_arrows; }
+ set {
+ if (value == drop_down_arrows)
+ return;
+
+ drop_down_arrows = value;
+ Redraw (true);
+ }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override Color ForeColor {
+ get { return foreground_color; }
+ set {
+ if (value == foreground_color)
+ return;
+
+ foreground_color = value;
+ OnForeColorChanged (EventArgs.Empty);
+ Redraw (false);
+ }
+ }
+
+ ImageList image_list;
+
+ [DefaultValue (null)]
+ public ImageList ImageList {
+ get { return image_list; }
+ set { image_list = value; }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ public Size ImageSize {
+ get {
+ if (ImageList == null)
+ return Size.Empty;
+
+ return ImageList.ImageSize;
+ }
+ }
+
+ ImeMode ime_mode;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new ImeMode ImeMode {
+ get { return ime_mode; }
+ set {
+ if (value == ime_mode)
+ return;
+
+ ime_mode = value;
+ OnImeModeChanged (EventArgs.Empty);
+ }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override RightToLeft RightToLeft {
+ get { return base.RightToLeft; }
+ set {
+ if (value == base.RightToLeft)
+ return;
+
+ base.RightToLeft = value;
+ OnRightToLeftChanged (EventArgs.Empty);
+ }
+ }
+
+ bool show_tooltips = false;
+
+ [DefaultValue (false)]
+ [Localizable (true)]
+ public bool ShowToolTips {
+ get { return show_tooltips; }
+ set { show_tooltips = value; }
+ }
+
+ [DefaultValue (false)]
+ public new bool TabStop {
+ get { return base.TabStop; }
+ set { base.TabStop = value; }
+ }
+
+ [Bindable (false)]
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override string Text {
+ get { return text; }
+ set {
+ if (value == text)
+ return;
+
+ text = value;
+ Redraw (true);
+ OnTextChanged (EventArgs.Empty);
+ }
+ }
+
+ ToolBarTextAlign text_alignment = ToolBarTextAlign.Underneath;
+
+ [DefaultValue (ToolBarTextAlign.Underneath)]
+ [Localizable (true)]
+ public ToolBarTextAlign TextAlign {
+ get { return text_alignment; }
+ set {
+ if (value == text_alignment)
+ return;
+
+ text_alignment = value;
+ Redraw (true);
+ }
+ }
+
+ bool wrappable = true;
+
+ [DefaultValue (true)]
+ [Localizable (true)]
+ public bool Wrappable {
+ get { return wrappable; }
+ set {
+ if (value == wrappable)
+ return;
+
+ wrappable = value;
+ Redraw (true);
+ }
+ }
+ #endregion Public Properties
+
+ #region Public Methods
+ public override string ToString ()
+ {
+ int count = this.Buttons.Count;
+
+ if (count == 0)
+ return string.Format ("System.Windows.Forms.ToolBar, Button.Count: 0");
+ else
+ return string.Format ("System.Windows.Forms.ToolBar, Button.Count: {0}, Buttons[0]: {1}",
+ count, this.Buttons [0].ToString ());
+ }
+ #endregion Public Methods
+
+ #region Protected Methods
+ protected override void CreateHandle ()
+ {
+ base.CreateHandle ();
+ }
+
+ protected override void Dispose (bool disposing)
+ {
+ if (disposing)
+ ImageList = null;
+
+ base.Dispose (disposing);
+ }
+
+ protected virtual void OnButtonClick (ToolBarButtonClickEventArgs e)
+ {
+ if (e.Button.Style == ToolBarButtonStyle.ToggleButton) {
+ if (! e.Button.Pushed)
+ e.Button.Pushed = true;
+ else
+ e.Button.Pushed = false;
+ }
+ e.Button.pressed = false;
+
+ Invalidate (e.Button.Rectangle);
+ Redraw (false);
+
+ if (ButtonClick != null)
+ ButtonClick (this, e);
+ }
+
+ protected virtual void OnButtonDropDown (ToolBarButtonClickEventArgs e)
+ {
+ if (ButtonDropDown != null)
+ ButtonDropDown (this, e);
+
+ if (e.Button.DropDownMenu == null)
+ return;
+
+ Point loc = new Point (e.Button.Rectangle.X + 1, e.Button.Rectangle.Bottom + 1);
+ ((ContextMenu) e.Button.DropDownMenu).Show (this, loc);
+
+ e.Button.dd_pressed = false;
+ Invalidate (e.Button.Rectangle);
+ }
+
+ protected override void OnFontChanged (EventArgs e)
+ {
+ base.OnFontChanged (e);
+ Redraw (true);
+ }
+
+ protected override void OnHandleCreated (EventArgs e)
+ {
+ base.OnHandleCreated (e);
+ }
+
+ protected override void OnResize (EventArgs e)
+ {
+ base.OnResize (e);
+
+ if (Width <= 0 || Height <= 0 || !Visible)
+ return;
+
+ Redraw (true);
+ }
+
+ protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified)
+ {
+ base.SetBoundsCore (x, y, width, height, specified);
+ }
+
+ protected override void WndProc (ref Message m)
+ {
+ base.WndProc (ref m);
+ }
+
+ #endregion Protected Methods
+
+ #region Private Methods
+ private void ToolBar_MouseDown (object sender, MouseEventArgs me)
+ {
+ if (!Enabled)
+ return;
+
+ Point loc = new Point (me.X, me.Y);
+
+ // draw the pushed button
+ foreach (ToolBarButton button in buttons) {
+ if (button.Enabled && button.Rectangle.Contains (loc)) {
+ // Mark the DropDown rect as pressed.
+ // We don't redraw the dropdown rect.
+ if (button.Style == ToolBarButtonStyle.DropDownButton) {
+ Rectangle rect = button.Rectangle;
+ rect.Width = ThemeEngine.Current.ToolBarDropDownWidth;
+ rect.X = button.Rectangle.Right - rect.Width;
+ if (rect.Contains (loc)) {
+ if (button.DropDownMenu != null) {
+ button.dd_pressed = true;
+ Invalidate (rect);
+ }
+ break;
+ }
+ }
+ button.pressed = true;
+ button.inside = true;
+ Invalidate (button.Rectangle);
+ break;
+ }
+ }
+ }
+
+ private void ToolBar_MouseUp (object sender, MouseEventArgs me)
+ {
+ if (!Enabled)
+ return;
+
+ Point loc = new Point (me.X, me.Y);
+
+ // draw the normal button
+ foreach (ToolBarButton button in buttons) {
+ if (button.Enabled && button.Rectangle.Contains (loc)) {
+ if (button.Style == ToolBarButtonStyle.DropDownButton) {
+ Rectangle ddRect = button.Rectangle;
+ ddRect.Width = ThemeEngine.Current.ToolBarDropDownWidth;
+ ddRect.X = button.Rectangle.Right - ddRect.Width;
+ if (ddRect.Contains (loc)) {
+ if (button.dd_pressed)
+ OnButtonDropDown (new ToolBarButtonClickEventArgs (button));
+ continue;
+ }
+ }
+ // Fire a ButtonClick
+ if (button.pressed)
+ OnButtonClick (new ToolBarButtonClickEventArgs (button));
+ } else if (button.pressed) {
+ button.pressed = false;
+ Invalidate (button.Rectangle);
+ }
+ }
+ }
+
+ private void ToolBar_MouseLeave (object sender, EventArgs e)
+ {
+ if (!Enabled || appearance != ToolBarAppearance.Flat || current_button == null)
+ return;
+
+ if (current_button.Hilight) {
+ current_button.Hilight = false;
+ Invalidate (current_button.Rectangle);
+ Redraw (false);
+ }
+ current_button = null;
+ }
+
+ private void ToolBar_MouseMove (object sender, MouseEventArgs me)
+ {
+ if (!Enabled)
+ return;
+
+ Point loc = new Point (me.X, me.Y);
+
+ if (this.Capture) {
+ // If the button was pressed and we leave, release the
+ // button press and vice versa
+ foreach (ToolBarButton button in buttons) {
+ if (button.pressed &&
+ (button.inside != button.Rectangle.Contains (loc))) {
+ button.inside = button.Rectangle.Contains (loc);
+ button.Hilight = false;
+ Invalidate (button.Rectangle);
+ Redraw (false);
+ break;
+ }
+ }
+ }
+ // following is only for flat style toolbar
+ else if (appearance == ToolBarAppearance.Flat) {
+ if (current_button != null && current_button.Rectangle.Contains (loc)) {
+ if (current_button.Hilight || current_button.Pushed)
+ return;
+ current_button.Hilight = true;
+ Invalidate (current_button.Rectangle);
+ Redraw (false);
+ }
+ else {
+ foreach (ToolBarButton button in buttons) {
+ if (button.Rectangle.Contains (loc) && button.Enabled) {
+ current_button = button;
+ if (current_button.Hilight || current_button.Pushed)
+ continue;
+ current_button.Hilight = true;
+ Invalidate (current_button.Rectangle);
+ Redraw (false);
+ }
+ else if (button.Hilight) {
+ button.Hilight = false;
+ Invalidate (button.Rectangle);
+ Redraw (false);
+ }
+ }
+ }
+ }
+ }
+
+ private void ToolBar_Paint (object sender, PaintEventArgs pevent)
+ {
+ ThemeEngine.Current.DrawToolBar (pevent.Graphics, pevent.ClipRectangle, this);
+ }
+
+ internal void Redraw (bool recalculate)
+ {
+ if (recalculate)
+ Layout ();
+
+ Refresh ();
+ }
+
+ private Size CalcButtonSize ()
+ {
+ String longestText = buttons [0].Text;
+ for (int i = 1; i < buttons.Count; i++) {
+ if (buttons[i].Text.Length > longestText.Length)
+ longestText = buttons[i].Text;
+ }
+
+ SizeF sz = this.DeviceContext.MeasureString (longestText, this.Font);
+ Size size = new Size ((int) Math.Ceiling (sz.Width), (int) Math.Ceiling (sz.Height));
+
+ if (ImageList != null) {
+ // adjustment for the image grip
+ int imgWidth = this.ImageSize.Width + 2 * ThemeEngine.Current.ToolBarImageGripWidth;
+ int imgHeight = this.ImageSize.Height + 2 * ThemeEngine.Current.ToolBarImageGripWidth;
+
+ if (text_alignment == ToolBarTextAlign.Right) {
+ size.Width = imgWidth + size.Width;
+ size.Height = (size.Height > imgHeight) ? size.Height : imgHeight;
+ }
+ else {
+ size.Height = imgHeight + size.Height;
+ size.Width = (size.Width > imgWidth) ? size.Width : imgWidth;
+ }
+ }
+ return size;
+ }
+
+ void Layout ()
+ {
+ Theme theme = ThemeEngine.Current;
+ int ht = ButtonSize.Height + theme.ToolBarGripWidth;
+ int x = theme.ToolBarGripWidth;
+ int y = theme.ToolBarGripWidth;
+
+ if (Wrappable) {
+ int separator_index = -1;
+
+ for (int i = 0; i < buttons.Count; i++) {
+ ToolBarButton button = buttons [i];
+
+ if (!button.Visible)
+ continue;
+
+ if (size_specified)
+ button.Layout (ButtonSize);
+ else
+ button.Layout ();
+
+ bool is_separator = button.Style == ToolBarButtonStyle.Separator;
+
+ if (x + button.Rectangle.Width < Width || is_separator) {
+ button.Location = new Point (x, y);
+ x += button.Rectangle.Width;
+ if (is_separator)
+ separator_index = i;
+ } else if (separator_index > 0) {
+ i = separator_index;
+ separator_index = -1;
+ x = theme.ToolBarGripWidth;
+ y += ht;
+ } else {
+ x = theme.ToolBarGripWidth;
+ y += ht;
+ button.Location = new Point (x, y);
+ x += button.Rectangle.Width;
+ }
+ }
+ if (AutoSize)
+ Height = y + ht;
+ } else {
+ if (AutoSize)
+ Height = ht;
+ else
+ Height = DefaultSize.Height;
+ foreach (ToolBarButton button in buttons) {
+ if (size_specified)
+ button.Layout (ButtonSize);
+ else
+ button.Layout ();
+ button.Location = new Point (x, y);
+ x += button.Rectangle.Width;
+ }
+ }
+ }
+ #endregion Private Methods
+
+ #region subclass
+ public class ToolBarButtonCollection : IList, ICollection, IEnumerable
+ {
+ #region instance variables
+ private ArrayList list;
+ private ToolBar owner;
+ #endregion
+
+ #region constructors
+ public ToolBarButtonCollection (ToolBar owner)
+ {
+ this.owner = owner;
+ list = new ArrayList ();
+ }
+ #endregion
+
+ #region properties
+ [Browsable (false)]
+ public virtual int Count {
+ get { return list.Count; }
+ }
+
+ public virtual bool IsReadOnly {
+ get { return list.IsReadOnly; }
+ }
+
+ public virtual ToolBarButton this [int index] {
+ get { return (ToolBarButton) list [index]; }
+ set {
+ value.SetParent (owner);
+ list [index] = value;
+ owner.Redraw (true);
+ }
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return list.IsSynchronized; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return list.SyncRoot; }
+ }
+
+ bool IList.IsFixedSize {
+ get { return list.IsFixedSize; }
+ }
+
+ object IList.this [int index] {
+ get { return this [index]; }
+ set {
+ if (! (value is ToolBarButton))
+ throw new ArgumentException("Not of type ToolBarButton", "value");
+ this [index] = (ToolBarButton) value;
+ }
+ }
+ #endregion
+
+ #region methods
+ public int Add (string text)
+ {
+ ToolBarButton button = new ToolBarButton (text);
+ return this.Add (button);
+ }
+
+ public int Add (ToolBarButton button)
+ {
+ int result;
+ button.SetParent (owner);
+ result = list.Add (button);
+ owner.Redraw (true);
+ return result;
+ }
+
+ public void AddRange (ToolBarButton [] buttons)
+ {
+ foreach (ToolBarButton button in buttons)
+ Add (button);
+ }
+
+ public virtual void Clear ()
+ {
+ list.Clear ();
+ owner.Redraw (false);
+ }
+
+ public bool Contains (ToolBarButton button)
+ {
+ return list.Contains (button);
+ }
+
+ public virtual IEnumerator GetEnumerator ()
+ {
+ return list.GetEnumerator ();
+ }
+
+ void ICollection.CopyTo (Array dest, int index)
+ {
+ list.CopyTo (dest, index);
+ }
+
+ int IList.Add (object button)
+ {
+ if (! (button is ToolBarButton)) {
+ throw new ArgumentException("Not of type ToolBarButton", "button");
+ }
+
+ return this.Add ((ToolBarButton) button);
+ }
+
+ bool IList.Contains (object button)
+ {
+ if (! (button is ToolBarButton)) {
+ throw new ArgumentException("Not of type ToolBarButton", "button");
+ }
+
+ return this.Contains ((ToolBarButton) button);
+ }
+
+ int IList.IndexOf (object button)
+ {
+ if (! (button is ToolBarButton)) {
+ throw new ArgumentException("Not of type ToolBarButton", "button");
+ }
+
+ return this.IndexOf ((ToolBarButton) button);
+ }
+
+ void IList.Insert (int index, object button)
+ {
+ if (! (button is ToolBarButton)) {
+ throw new ArgumentException("Not of type ToolBarButton", "button");
+ }
+
+ this.Insert (index, (ToolBarButton) button);
+ }
+
+ void IList.Remove (object button)
+ {
+ if (! (button is ToolBarButton)) {
+ throw new ArgumentException("Not of type ToolBarButton", "button");
+ }
+
+ this.Remove ((ToolBarButton) button);
+ }
+
+ public int IndexOf (ToolBarButton button)
+ {
+ return list.IndexOf (button);
+ }
+
+ public void Insert (int index, ToolBarButton button)
+ {
+ list.Insert (index, button);
+ owner.Redraw (true);
+ }
+
+ public void Remove (ToolBarButton button)
+ {
+ list.Remove (button);
+ owner.Redraw (true);
+ }
+
+ public virtual void RemoveAt (int index)
+ {
+ list.RemoveAt (index);
+ owner.Redraw (true);
+ }
+ #endregion methods
+ }
+ #endregion subclass
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarAppearance.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarAppearance.cs
new file mode 100644
index 00000000000..e3366639c74
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarAppearance.cs
@@ -0,0 +1,41 @@
+//
+// System.Windows.Forms.ToolBarAppearance.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Ravindra (rkumar@novell.com)
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public enum ToolBarAppearance
+ {
+ Normal = 0,
+ Flat = 1
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarButton.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarButton.cs
new file mode 100644
index 00000000000..3ac8ab90bae
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarButton.cs
@@ -0,0 +1,388 @@
+// System.Windows.Forms.ToolBarButton.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Ravindra (rkumar@novell.com)
+// Mike Kestner <mkestner@novell.com>
+
+
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.Drawing.Imaging;
+
+namespace System.Windows.Forms
+{
+ [DefaultProperty ("Text")]
+ [Designer ("System.Windows.Forms.Design.ToolBarButtonDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ [DesignTimeVisible (false)]
+ [ToolboxItem (false)]
+ public class ToolBarButton : Component
+ {
+ #region instance variable
+ private bool enabled = true;
+ private int image_index = -1;
+ private ContextMenu menu;
+ private ToolBar parent;
+ private bool partial_push = false;
+ private bool pushed = false;
+ private ToolBarButtonStyle style = ToolBarButtonStyle.PushButton;
+ private object tag;
+ private string text = "";
+ private string tooltip = "";
+ private bool visible = true;
+ internal bool dd_pressed = false; // to check for a mouse down on dropdown rect
+ internal bool hilight = false; // to hilight buttons in flat style
+ internal bool inside = false; // to handle the mouse move event with mouse pressed
+ internal bool pressed = false; // this is to check for mouse down on a button
+ #endregion
+
+ #region constructors
+ public ToolBarButton () { }
+
+ public ToolBarButton (string text)
+ {
+ this.text = text;
+ }
+ #endregion
+
+ #region internal properties
+ internal bool Hilight {
+ get { return hilight; }
+ set {
+ if (! pushed)
+ hilight = value;
+ else
+ hilight = false;
+ }
+ }
+
+ internal Image Image {
+ get {
+ if (Parent == null || Parent.ImageList == null)
+ return null;
+
+ ImageList list = Parent.ImageList;
+ if (ImageIndex > -1 && ImageIndex < list.Images.Count)
+ return list.Images [ImageIndex];
+
+ return null;
+ }
+ }
+
+ Rectangle image_rect;
+ internal Rectangle ImageRectangle {
+ get {
+ Rectangle result = image_rect;
+ result.X += bounds.X;
+ result.Y += bounds.Y;
+ return result;
+ }
+ }
+
+ Rectangle text_rect;
+ internal Rectangle TextRectangle {
+ get {
+ Rectangle result = text_rect;
+ result.X += bounds.X;
+ result.Y += bounds.Y;
+ return result;
+ }
+ }
+
+ Rectangle bounds;
+ internal Point Location {
+ //get { return location; }
+ set {
+ if (bounds.Location == value)
+ return;
+
+ if (bounds != Rectangle.Empty)
+ Invalidate ();
+
+ bounds.Location = value;
+ Invalidate ();
+ }
+ }
+
+ internal bool Pressed {
+ get {
+ if (pressed && inside)
+ return true;
+ else
+ return false;
+ }
+ set { pressed = value; }
+ }
+ #endregion internal properties
+
+ #region properties
+ [DefaultValue (null)]
+ [TypeConverter (typeof (ReferenceConverter))]
+ public Menu DropDownMenu {
+ get { return menu; }
+
+ set {
+ if (value is ContextMenu)
+ menu = (ContextMenu) value;
+ else
+ throw new ArgumentException ("DropDownMenu must be of type ContextMenu.");
+ }
+ }
+
+ [DefaultValue (true)]
+ [Localizable (true)]
+ public bool Enabled {
+ get { return enabled; }
+ set {
+ if (value == enabled)
+ return;
+
+ enabled = value;
+ Invalidate ();
+ }
+ }
+
+ [DefaultValue (-1)]
+ [Editor ("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
+ [Localizable (true)]
+ [TypeConverter (typeof (ImageIndexConverter))]
+ public int ImageIndex {
+ get { return image_index; }
+ set {
+ if (value < -1)
+ throw new ArgumentException ("ImageIndex value must be above or equal to -1.");
+
+ if (value == image_index)
+ return;
+
+ image_index = value;
+ Invalidate ();
+ }
+ }
+
+ [Browsable (false)]
+ public ToolBar Parent {
+ get { return parent; }
+ }
+
+ [DefaultValue (false)]
+ public bool PartialPush {
+ get { return partial_push; }
+ set {
+ if (value == partial_push)
+ return;
+
+ partial_push = value;
+ Invalidate ();
+ }
+ }
+
+ [DefaultValue (false)]
+ public bool Pushed {
+ get { return pushed; }
+ set {
+ if (value == pushed)
+ return;
+
+ pushed = value;
+ if (pushed)
+ hilight = false;
+ Invalidate ();
+ }
+ }
+
+ public Rectangle Rectangle {
+ get {
+ if (Visible && Parent != null && Parent.Visible) {
+ Rectangle result = bounds;
+ if (Style == ToolBarButtonStyle.DropDownButton && Parent.DropDownArrows)
+ result.Width += ThemeEngine.Current.ToolBarDropDownWidth;
+ return result;
+ } else
+ return Rectangle.Empty;
+ }
+ }
+
+ [DefaultValue (ToolBarButtonStyle.PushButton)]
+ [RefreshProperties (RefreshProperties.Repaint)]
+ public ToolBarButtonStyle Style {
+ get { return style; }
+ set {
+ if (value == style)
+ return;
+
+ style = value;
+ Invalidate ();
+ }
+ }
+
+ [Bindable (true)]
+ [DefaultValue (null)]
+ [Localizable (false)]
+ [TypeConverter (typeof (StringConverter))]
+ public object Tag {
+ get { return tag; }
+ set { tag = value; }
+ }
+
+ [DefaultValue ("")]
+ [Localizable (true)]
+ public string Text {
+ get { return text; }
+ set {
+ if (value == text)
+ return;
+
+ text = value;
+ Invalidate ();
+ }
+ }
+
+ [DefaultValue ("")]
+ [Localizable (true)]
+ public string ToolTipText {
+ get { return tooltip; }
+ set { tooltip = value; }
+ }
+
+ [DefaultValue (true)]
+ [Localizable (true)]
+ public bool Visible {
+ get { return visible; }
+ set {
+ if (value == visible)
+ return;
+
+ visible = value;
+ if (Parent != null)
+ Parent.Redraw (true);
+ }
+ }
+ #endregion
+
+ #region internal methods
+ internal void SetParent (ToolBar parent)
+ {
+ if (Parent == parent)
+ return;
+
+ if (Parent != null)
+ Parent.Buttons.Remove (this);
+
+ this.parent = parent;
+ }
+
+ internal void Layout ()
+ {
+ if (Parent == null || !Visible)
+ return;
+
+ Size sz = CalculateSize ();
+ Layout (sz);
+ }
+
+ internal void Layout (Size size)
+ {
+ if (Parent == null || !Visible)
+ return;
+
+ bounds.Size = size;
+
+ Image image = Image;
+ if (image == null) {
+ text_rect = new Rectangle (Point.Empty, size);
+ image_rect = Rectangle.Empty;
+ return;
+ }
+
+ int grip = ThemeEngine.Current.ToolBarImageGripWidth;
+
+ if (Parent.TextAlign == ToolBarTextAlign.Underneath) {
+ image_rect = new Rectangle ((size.Width - image.Width) / 2 - grip, 0, image.Width + 2 + grip, image.Height + 2 * grip);
+
+ text_rect = new Rectangle (0, image_rect.Bottom, size.Width, size.Height - image_rect.Height);
+ } else {
+ image_rect = new Rectangle (0, 0, image.Width + 2 * grip, image.Height + 2 * grip);
+
+ text_rect = new Rectangle (image_rect.Right, 0, size.Width - image_rect.Width, size.Height);
+ }
+ }
+
+ const int text_padding = 3;
+
+ Size CalculateSize ()
+ {
+ Theme theme = ThemeEngine.Current;
+
+ int ht = Parent.ButtonSize.Height + 2 * theme.ToolBarGripWidth;
+
+ if (Style == ToolBarButtonStyle.Separator)
+ return new Size (theme.ToolBarSeparatorWidth, ht);
+
+ SizeF sz = Parent.DeviceContext.MeasureString (Text, Parent.Font);
+ Size size = new Size ((int) Math.Ceiling (sz.Width) + 2 * text_padding,
+ (int) Math.Ceiling (sz.Height));
+
+ Image image = Image;
+
+ if (image == null)
+ return size;
+
+ int image_width = image.Width + 2 * theme.ToolBarImageGripWidth;
+ int image_height = image.Height + 2 * theme.ToolBarImageGripWidth;
+
+ if (Parent.TextAlign == ToolBarTextAlign.Right) {
+ size.Width = image_width + size.Width;
+ size.Height = (size.Height > image_height) ? size.Height : image_height;
+ } else {
+ size.Height = image_height + size.Height;
+ size.Width = (size.Width > image_width) ? size.Width : image_width;
+ }
+
+ size.Width += theme.ToolBarGripWidth;
+ size.Height += theme.ToolBarGripWidth;
+ return size;
+ }
+
+ void Invalidate ()
+ {
+ if (Parent != null)
+ Parent.Invalidate (Rectangle);
+ }
+
+ #endregion Internal Methods
+
+ #region methods
+ protected override void Dispose (bool disposing)
+ {
+ base.Dispose (disposing);
+ }
+
+ public override string ToString ()
+ {
+ return string.Format ("ToolBarButton: {0}, Style: {1}", text, style);
+ }
+ #endregion
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarButtonClickEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarButtonClickEventArgs.cs
new file mode 100644
index 00000000000..3f7deba81dc
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarButtonClickEventArgs.cs
@@ -0,0 +1,57 @@
+//
+// System.Windows.Forms.ToolBarButtonClickEventArgs.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Ravindra (rkumar@novell.com)
+//
+//
+
+
+// COMPLETE
+
+using System;
+
+namespace System.Windows.Forms
+{
+ public class ToolBarButtonClickEventArgs : EventArgs
+ {
+ #region Local Variables
+ private ToolBarButton button;
+ #endregion
+
+ #region Public Constructors
+ public ToolBarButtonClickEventArgs (ToolBarButton button)
+ {
+ this.button = button;
+ }
+ #endregion Public Constructors
+
+ #region Public Instance Properties
+ public ToolBarButton Button {
+ get { return button; }
+ set { button = value; }
+ }
+ #endregion Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarButtonClickEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarButtonClickEventHandler.cs
new file mode 100644
index 00000000000..c11b6b305c1
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarButtonClickEventHandler.cs
@@ -0,0 +1,36 @@
+//
+// System.Windows.Forms.ToolBarButtonClickEventHandler.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Ravindra (rkumar@novell.com)
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ [Serializable]
+ public delegate void ToolBarButtonClickEventHandler (object sender, ToolBarButtonClickEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarButtonStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarButtonStyle.cs
new file mode 100644
index 00000000000..328fec0bf57
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarButtonStyle.cs
@@ -0,0 +1,42 @@
+//
+// System.Windows.Forms.ToolBarButtonStyle.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Ravindra (rkumar@novell.com)
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public enum ToolBarButtonStyle
+ {
+ PushButton = 1,
+ ToggleButton = 2,
+ Separator = 3,
+ DropDownButton =4
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarTextAlign.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarTextAlign.cs
new file mode 100644
index 00000000000..255205498ea
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarTextAlign.cs
@@ -0,0 +1,40 @@
+//
+// System.Windows.Forms.ToolBarTextAlign.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Ravindra (rkumar@novell.com)
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public enum ToolBarTextAlign
+ {
+ Underneath = 0,
+ Right = 1
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolTip.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolTip.cs
new file mode 100644
index 00000000000..02ed0aa8b5f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolTip.cs
@@ -0,0 +1,453 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+ [ProvideProperty ("ToolTip", typeof(System.Windows.Forms.Control))]
+ [ToolboxItemFilter("System.Windows.Forms", ToolboxItemFilterType.Allow)]
+ public sealed class ToolTip : System.ComponentModel.Component, System.ComponentModel.IExtenderProvider {
+ #region Local variables
+ internal bool is_active;
+ internal int automatic_delay;
+ internal int autopop_delay;
+ internal int initial_delay;
+ internal int re_show_delay;
+ internal bool show_always;
+
+ internal ToolTipWindow tooltip_window; // The actual tooltip window
+ internal Hashtable tooltip_strings; // List of strings for each control, indexed by control
+ internal ArrayList controls;
+ internal Control active_control; // Control for which the tooltip is currently displayed
+ internal Control last_control; // last control the mouse was in
+ internal Size display_size; // Size of the screen
+ internal Timer timer; // Used for the various intervals
+ #endregion // Local variables
+
+ #region ToolTipWindow Class
+ internal class ToolTipWindow : Control {
+ #region ToolTipWindow Class Local Variables
+ internal StringFormat string_format;
+ internal ToolTip owner;
+ #endregion // ToolTipWindow Class Local Variables
+
+ #region ToolTipWindow Class Constructor
+ internal ToolTipWindow(ToolTip owner) : base() {
+ this.owner = owner;
+
+ string_format = new StringFormat();
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.Alignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+
+ Visible = false;
+ Size = new Size(100, 20);
+ ForeColor = ThemeEngine.Current.ColorInfoText;
+ BackColor = ThemeEngine.Current.ColorInfo;
+
+ VisibleChanged += new EventHandler(ToolTipWindow_VisibleChanged);
+
+ SetStyle (ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle (ControlStyles.ResizeRedraw | ControlStyles.Opaque, true);
+ }
+
+ #endregion // ToolTipWindow Class Constructor
+
+ #region ToolTipWindow Class Protected Instance Methods
+ protected override void OnCreateControl() {
+ base.OnCreateControl ();
+ XplatUI.SetTopmost(this.window.Handle, IntPtr.Zero, true);
+ }
+
+ protected override CreateParams CreateParams {
+ get {
+ CreateParams cp;
+
+ cp = base.CreateParams;
+
+ cp.Style = (int)WindowStyles.WS_POPUP;
+ cp.Style |= (int)WindowStyles.WS_CLIPSIBLINGS;
+
+ cp.ExStyle = (int)(WindowExStyles.WS_EX_TOOLWINDOW | WindowExStyles.WS_EX_TOPMOST);
+
+ return cp;
+ }
+ }
+
+ protected override void OnPaint(PaintEventArgs pevent) {
+ // We don't do double-buffering on purpose:
+ // 1) we'd have to meddle with is_visible, it destroys the buffers if !visible
+ // 2) We don't draw much, no need to double buffer
+ ThemeEngine.Current.DrawToolTip(pevent.Graphics, ClientRectangle, this);
+
+ base.OnPaint(pevent);
+ }
+
+ protected override void Dispose(bool disposing) {
+ if (disposing) {
+ this.string_format.Dispose();
+ }
+ base.Dispose (disposing);
+ }
+
+ protected override void WndProc(ref Message m) {
+ if (m.Msg == (int)Msg.WM_SETFOCUS) {
+ if (m.WParam != IntPtr.Zero) {
+ XplatUI.SetFocus(m.WParam);
+ }
+ }
+ base.WndProc (ref m);
+ }
+
+
+ #endregion // ToolTipWindow Class Protected Instance Methods
+
+ #region ToolTipWindow Class Private Methods
+ private void ToolTipWindow_VisibleChanged(object sender, EventArgs e) {
+ Control control = (Control)sender;
+
+ if (control.is_visible) {
+ XplatUI.SetTopmost(control.window.Handle, IntPtr.Zero, true);
+ } else {
+ XplatUI.SetTopmost(control.window.Handle, IntPtr.Zero, false);
+ }
+ }
+ #endregion // ToolTipWindow Class Protected Instance Methods
+ }
+ #endregion // ToolTipWindow Class
+
+ #region Public Constructors & Destructors
+ public ToolTip() {
+ XplatUI.GetDisplaySize(out display_size);
+
+ // Defaults from MS
+ is_active = true;
+ automatic_delay = 500;
+ autopop_delay = 5000;
+ initial_delay = 500;
+ re_show_delay = 100;
+ show_always = false;
+
+ tooltip_strings = new Hashtable(5);
+ controls = new ArrayList(5);
+
+ tooltip_window = new ToolTipWindow(this);
+ tooltip_window.MouseLeave += new EventHandler(control_MouseLeave);
+
+ timer = new Timer();
+ timer.Enabled = false;
+ timer.Tick +=new EventHandler(timer_Tick);
+ }
+
+ public ToolTip(System.ComponentModel.IContainer cont) : this() {
+ cont.Add (this);
+ }
+
+ ~ToolTip() {
+ }
+ #endregion // Public Constructors & Destructors
+
+ #region Public Instance Properties
+ [DefaultValue (true)]
+ public bool Active {
+ get {
+ return is_active;
+ }
+
+ set {
+ if (is_active != value) {
+ is_active = value;
+
+ if (tooltip_window.Visible) {
+ tooltip_window.Visible = false;
+ active_control = null;
+ }
+ }
+ }
+ }
+
+ [DefaultValue (500)]
+ [RefreshProperties (RefreshProperties.All)]
+ public int AutomaticDelay {
+ get {
+ return automatic_delay;
+ }
+
+ set {
+ if (automatic_delay != value) {
+ automatic_delay = value;
+ autopop_delay = automatic_delay * 10;
+ initial_delay = automatic_delay;
+ re_show_delay = automatic_delay / 5;
+ }
+ }
+ }
+
+ [RefreshProperties (RefreshProperties.All)]
+ public int AutoPopDelay {
+ get {
+ return autopop_delay;
+ }
+
+ set {
+ if (autopop_delay != value) {
+ autopop_delay = value;
+ }
+ }
+ }
+
+ [RefreshProperties (RefreshProperties.All)]
+ public int InitialDelay {
+ get {
+ return initial_delay;
+ }
+
+ set {
+ if (initial_delay != value) {
+ initial_delay = value;
+ }
+ }
+ }
+
+ [RefreshProperties (RefreshProperties.All)]
+ public int ReshowDelay {
+ get {
+ return re_show_delay;
+ }
+
+ set {
+ if (re_show_delay != value) {
+ re_show_delay = value;
+ }
+ }
+ }
+
+ [DefaultValue (false)]
+ public bool ShowAlways {
+ get {
+ return show_always;
+ }
+
+ set {
+ if (show_always != value) {
+ show_always = value;
+ }
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public bool CanExtend(object target) {
+ return false;
+ }
+
+ [Localizable (true)]
+ [DefaultValue ("")]
+ public string GetToolTip(Control control) {
+ string tooltip = (string)tooltip_strings[control];
+ if (tooltip == null)
+ return "";
+ return tooltip;
+ }
+
+ public void RemoveAll() {
+ tooltip_strings.Clear();
+ controls.Clear();
+ }
+
+ public void SetToolTip(Control control, string caption) {
+ tooltip_strings[control] = caption;
+
+ // no need for duplicates
+ if (!controls.Contains(control)) {
+ control.MouseEnter += new EventHandler(control_MouseEnter);
+ control.MouseMove += new MouseEventHandler(control_MouseMove);
+ control.MouseLeave += new EventHandler(control_MouseLeave);
+ controls.Add(control);
+ }
+
+ // if SetToolTip is called from a control and the mouse is currently over that control,
+ // make sure that tooltip_window.Text gets updated
+ if (caption != null && last_control == control) {
+ Size size = ThemeEngine.Current.ToolTipSize(tooltip_window, caption);
+ tooltip_window.Width = size.Width;
+ tooltip_window.Height = size.Height;
+ tooltip_window.Text = caption;
+ }
+ }
+
+ public override string ToString() {
+ return base.ToString() + " InitialDelay: " + initial_delay + ", ShowAlways: " + show_always;
+ }
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected override void Dispose(bool disposing) {
+ if (disposing) {
+ // Mop up the mess; or should we wait for the GC to kick in?
+ timer.Stop();
+ timer.Dispose();
+
+ // Not sure if we should clean up tooltip_window
+ tooltip_window.Dispose();
+
+ tooltip_strings.Clear();
+
+ controls.Clear();
+ }
+ }
+ #endregion // Protected Instance Methods
+
+ #region Private Methods
+ private void control_MouseEnter(object sender, EventArgs e) {
+ string text;
+
+ last_control = (Control)sender;
+
+ // Whatever we're displaying right now, we don't want it anymore
+ tooltip_window.Visible = false;
+ timer.Stop();
+
+ // if we're in the same control as before (how'd that happen?) or if we're not active, leave
+ if (!is_active || (active_control == (Control)sender)) {
+ return;
+ }
+
+ if (!show_always) {
+ if (((Control)sender).GetContainerControl().ActiveControl == null) {
+ return;
+ }
+ }
+
+ text = (string)tooltip_strings[sender];
+ if (text != null && text.Length > 0) {
+ Size size;
+
+ size = ThemeEngine.Current.ToolTipSize(tooltip_window, text);
+ tooltip_window.Width = size.Width;
+ tooltip_window.Height = size.Height;
+ tooltip_window.Text = text;
+
+ // FIXME - this needs to be improved; the tooltip will show up under the mouse, which is annoying; use cursor size once implemented
+
+ if ((Control.MousePosition.X+1+tooltip_window.Width) < display_size.Width) {
+ tooltip_window.Left = Control.MousePosition.X+1;
+ } else {
+ tooltip_window.Left = display_size.Width-tooltip_window.Width;
+ }
+
+ if ((Control.MousePosition.Y+tooltip_window.Height)<display_size.Height) {
+ tooltip_window.Top = Control.MousePosition.Y;
+ } else {
+ tooltip_window.Top = Control.MousePosition.Y-tooltip_window.Height;
+ }
+
+ // Since we get the mouse enter before the mouse leave, active_control will still be non-null if we were in a
+ // tooltip'd control; should prolly check on X11 too, and make sure that driver behaves the same way
+ if (active_control == null) {
+ timer.Interval = initial_delay;
+ } else {
+ timer.Interval = re_show_delay;
+ }
+
+ active_control = (Control)sender;
+
+ // We're all set, lets wake the timer (which will then make us visible)
+ timer.Enabled = true;
+ }
+ }
+
+ private void timer_Tick(object sender, EventArgs e) {
+ // Show our pretty selves
+ timer.Stop();
+
+ // FIXME - Should not need this check../
+ if (tooltip_window.IsDisposed) {
+ return;
+ }
+
+ if (!tooltip_window.Visible) {
+ // The initial_delay timer kicked in
+ tooltip_window.Visible = true;
+ timer.Interval = autopop_delay;
+ timer.Start();
+ } else {
+ // The autopop_delay timer happened
+ tooltip_window.Visible = false;
+ }
+ }
+
+
+ private bool MouseInControl(Control control) {
+ Point m;
+ Point c;
+ Size cw;
+
+ if (control == null) {
+ return false;
+ }
+
+ m = Control.MousePosition;
+ c = new Point(control.Bounds.X, control.Bounds.Y);
+ if (control.parent != null) {
+ c = control.parent.PointToScreen(c);
+ }
+ cw = control.ClientSize;
+
+ if (c.X<=m.X && m.X<(c.X+cw.Width) &&
+ c.Y<=m.Y && m.Y<(c.Y+cw.Height)) {
+ return true;
+ }
+ return false;
+ }
+
+ private void control_MouseLeave(object sender, EventArgs e) {
+ // In case the timer is still running, stop it
+ timer.Stop();
+
+ if (!MouseInControl(tooltip_window) && !MouseInControl(active_control)) {
+ active_control = null;
+ tooltip_window.Visible = false;
+ }
+
+ if (last_control == (Control)sender)
+ last_control = null;
+ }
+
+ private void control_MouseMove(object sender, MouseEventArgs e) {
+ // Restart the interval, the mouse moved
+ timer.Stop();
+ timer.Start();
+
+ }
+ #endregion // Private Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TrackBar.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TrackBar.cs
new file mode 100644
index 00000000000..ed8f2bbc971
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TrackBar.cs
@@ -0,0 +1,693 @@
+//
+// System.Windows.Forms.TrackBar.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+// TODO:
+// - The AutoSize functionality seems quite broken for vertical controls in .Net 1.1. Not
+// sure if we are implementing it the right way.
+//
+
+
+// NOT COMPLETE
+
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Drawing.Drawing2D;
+using System.Timers;
+
+namespace System.Windows.Forms
+{
+ [Designer("System.Windows.Forms.Design.TrackBarDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ [DefaultEvent ("Scroll")]
+ [DefaultProperty("Value")]
+ public class TrackBar : Control, ISupportInitialize
+ {
+ private int minimum;
+ private int maximum;
+ internal int tickFrequency;
+ private bool autosize;
+ private int position;
+ private int smallChange;
+ private int largeChange;
+ private Orientation orientation;
+ private TickStyle tickStyle;
+ private Rectangle thumb_pos = new Rectangle (); /* Current position and size of the thumb */
+ private Rectangle thumb_area = new Rectangle (); /* Area where the thumb can scroll */
+ internal bool thumb_pressed = false;
+ private System.Timers.Timer holdclick_timer = new System.Timers.Timer ();
+ internal int thumb_mouseclick;
+ private bool mouse_clickmove;
+
+ #region events
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler BackgroundImageChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler Click;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler DoubleClick;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler FontChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler ForeColorChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler ImeModeChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event PaintEventHandler Paint;
+
+ public event EventHandler Scroll;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler TextChanged;
+ public event EventHandler ValueChanged;
+
+ #endregion // Events
+
+ public TrackBar ()
+ {
+ orientation = Orientation.Horizontal;
+ minimum = 0;
+ maximum = 10;
+ tickFrequency = 1;
+ autosize = true;
+ position = 0;
+ tickStyle = TickStyle.BottomRight;
+ smallChange = 1;
+ largeChange = 5;
+ mouse_clickmove = false;
+ MouseDown += new MouseEventHandler (OnMouseDownTB);
+ MouseUp += new MouseEventHandler (OnMouseUpTB);
+ MouseMove += new MouseEventHandler (OnMouseMoveTB);
+ KeyDown += new KeyEventHandler (OnKeyDownTB);
+ holdclick_timer.Elapsed += new ElapsedEventHandler (OnFirstClickTimer);
+
+ SetStyle (ControlStyles.UserPaint | ControlStyles.Opaque, false);
+ }
+
+ #region Private & Internal Properties
+ internal Rectangle ThumbPos {
+ get {
+ return thumb_pos;
+ }
+
+ set {
+ thumb_pos = value;
+ }
+ }
+
+ internal Rectangle ThumbArea {
+ get {
+ return thumb_area;
+ }
+
+ set {
+ thumb_area = value;
+ }
+ }
+ #endregion // Private & Internal Properties
+
+ #region Public Properties
+
+ [DefaultValue (true)]
+ public bool AutoSize {
+ get { return autosize; }
+ set { autosize = value;}
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Browsable (false)]
+ public override Image BackgroundImage {
+ get { return base.BackgroundImage; }
+ set {
+ if (base.BackgroundImage == value)
+ return;
+
+ if (BackgroundImageChanged != null)
+ BackgroundImageChanged (this, EventArgs.Empty);
+
+ base.BackgroundImage = value;
+ }
+ }
+
+ protected override CreateParams CreateParams {
+ get {
+ return base.CreateParams;
+ }
+ }
+
+ protected override ImeMode DefaultImeMode {
+ get {return ImeMode.Disable; }
+ }
+
+ protected override Size DefaultSize {
+ get { return ThemeEngine.Current.TrackBarDefaultSize; }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override Font Font {
+ get { return base.Font; }
+ set { base.Font = value; }
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Browsable (false)]
+ public override Color ForeColor {
+ get { return base.ForeColor; }
+ set {
+ if (value == base.ForeColor)
+ return;
+
+ if (ForeColorChanged != null)
+ ForeColorChanged (this, EventArgs.Empty);
+
+ Refresh ();
+ }
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Browsable (false)]
+ public new ImeMode ImeMode {
+ get { return base.ImeMode; }
+ set {
+ if (value == base.ImeMode)
+ return;
+
+ base.ImeMode = value;
+ if (ImeModeChanged != null)
+ ImeModeChanged (this, EventArgs.Empty);
+ }
+ }
+
+ [DefaultValue (5)]
+ public int LargeChange
+ {
+ get { return largeChange; }
+ set {
+ if (value < 0)
+ throw new Exception( string.Format("Value '{0}' must be greater than or equal to 0.", value));
+
+ largeChange = value;
+ }
+ }
+
+ [DefaultValue (10)]
+ [RefreshProperties (RefreshProperties.All)]
+ public int Maximum {
+ get { return maximum; }
+ set {
+ if (maximum != value) {
+ maximum = value;
+
+ if (maximum < minimum)
+ minimum = maximum;
+
+ Refresh ();
+ }
+ }
+ }
+
+ [DefaultValue (0)]
+ [RefreshProperties (RefreshProperties.All)]
+ public int Minimum {
+ get { return minimum; }
+ set {
+
+ if (Minimum != value) {
+ minimum = value;
+
+ if (minimum > maximum)
+ maximum = minimum;
+
+ Refresh ();
+ }
+ }
+ }
+
+ [DefaultValue (Orientation.Horizontal)]
+ [Localizable (true)]
+ public Orientation Orientation {
+ get { return orientation; }
+ set {
+ if (!Enum.IsDefined (typeof (Orientation), value))
+ throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for Orientation", value));
+
+ /* Orientation can be changed once the control has been created */
+ if (orientation != value) {
+ orientation = value;
+
+ int old_witdh = Width;
+ Width = Height;
+ Height = old_witdh;
+ Refresh ();
+ }
+ }
+ }
+
+ [DefaultValue (1)]
+ public int SmallChange {
+ get { return smallChange;}
+ set {
+ if ( value < 0 )
+ throw new Exception( string.Format("Value '{0}' must be greater than or equal to 0.", value));
+
+ if (smallChange != value) {
+ smallChange = value;
+ }
+ }
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Bindable (false)]
+ [Browsable (false)]
+ public override string Text {
+ get { return base.Text; }
+ set {
+ if (value == base.Text)
+ return;
+
+ if (TextChanged != null)
+ TextChanged (this, EventArgs.Empty);
+
+ Refresh ();
+ }
+ }
+
+ [DefaultValue (1)]
+ public int TickFrequency {
+ get { return tickFrequency; }
+ set {
+ if ( value > 0 ) {
+ tickFrequency = value;
+ Refresh ();
+ }
+ }
+ }
+
+ [DefaultValue (TickStyle.BottomRight)]
+ public TickStyle TickStyle {
+ get { return tickStyle; }
+ set {
+ if (!Enum.IsDefined (typeof (TickStyle), value))
+ throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for TickStyle", value));
+
+ if (tickStyle != value) {
+ tickStyle = value;
+ Refresh ();
+ }
+ }
+ }
+
+ [DefaultValue (0)]
+ [Bindable (true)]
+ public int Value {
+ get { return position; }
+ set {
+ if (value < Minimum || value > Maximum)
+ throw new ArgumentException(
+ string.Format("'{0}' is not a valid value for 'Value'. 'Value' should be between 'Minimum' and 'Maximum'", value));
+
+ if (position != value) {
+ position = value;
+
+ if (ValueChanged != null)
+ ValueChanged (this, new EventArgs ());
+
+ Invalidate (thumb_area);
+ }
+ }
+ }
+
+ #endregion //Public Properties
+
+ #region Public Methods
+
+ public virtual void BeginInit ()
+ {
+
+ }
+
+ protected override void CreateHandle ()
+ {
+ base.CreateHandle ();
+ }
+
+
+ public virtual void EndInit ()
+ {
+
+ }
+
+ protected override bool IsInputKey (Keys keyData)
+ {
+ if ((keyData & Keys.Alt) == 0) {
+ switch (keyData & Keys.KeyCode) {
+ case Keys.Down:
+ case Keys.Right:
+ case Keys.Up:
+ case Keys.Left:
+ case Keys.PageUp:
+ case Keys.PageDown:
+ case Keys.Home:
+ case Keys.End:
+ return true;
+ }
+ }
+ return base.IsInputKey (keyData);
+ }
+
+ protected override void OnBackColorChanged (EventArgs e)
+ {
+ base.OnBackColorChanged (e);
+ }
+
+ protected override void OnHandleCreated (EventArgs e)
+ {
+ base.OnHandleCreated (e);
+
+ if (AutoSize)
+ if (Orientation == Orientation.Horizontal)
+ Size = new Size (Width, 40);
+ else
+ Size = new Size (50, Height);
+
+ UpdatePos (Value, true);
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ protected override void OnMouseWheel (MouseEventArgs e)
+ {
+ base.OnMouseWheel (e);
+
+ if (!Enabled) return;
+
+ if (e.Delta > 0)
+ SmallDecrement ();
+ else
+ SmallIncrement ();
+ }
+
+ protected virtual void OnScroll (EventArgs e)
+ {
+ if (Scroll != null)
+ Scroll (this, e);
+ }
+
+ protected virtual void OnValueChanged (EventArgs e)
+ {
+ if (ValueChanged != null)
+ ValueChanged (this, e);
+ }
+
+ public void SetRange (int minValue, int maxValue)
+ {
+ Minimum = minValue;
+ Maximum = maxValue;
+ }
+
+ public override string ToString()
+ {
+ return string.Format("System.Windows.Forms.Trackbar, Minimum: {0}, Maximum: {1}, Value: {2}",
+ Minimum, Maximum, Value);
+ }
+
+
+ protected override void WndProc (ref Message m)
+ {
+ switch ((Msg) m.Msg) {
+
+ case Msg.WM_PAINT: {
+ PaintEventArgs paint_event;
+
+ paint_event = XplatUI.PaintEventStart (Handle, true);
+ OnPaintTB (paint_event);
+ XplatUI.PaintEventEnd (Handle, true);
+ return;
+ }
+
+ case Msg.WM_ERASEBKGND:
+ m.Result = (IntPtr) 1; /* Disable background painting to avoid flickering */
+ return;
+
+ default:
+ break;
+ }
+
+ base.WndProc (ref m);
+ }
+
+ #endregion Public Methods
+
+ #region Private Methods
+
+ private void UpdatePos (int newPos, bool update_trumbpos)
+ {
+ if (newPos < minimum){
+ Value = minimum;
+ }
+ else {
+ if (newPos > maximum) {
+ Value = maximum;
+ }
+ else {
+ Value = newPos;
+ }
+ }
+ }
+
+ private void LargeIncrement ()
+ {
+ UpdatePos (position + LargeChange, true);
+ Invalidate (thumb_area);
+ OnScroll (new EventArgs ());
+ }
+
+ private void LargeDecrement ()
+ {
+ UpdatePos (position - LargeChange, true);
+ Invalidate (thumb_area);
+ OnScroll (new EventArgs ());
+ }
+
+ private void SmallIncrement ()
+ {
+ UpdatePos (position + SmallChange, true);
+ Invalidate (thumb_area);
+ OnScroll (new EventArgs ());
+ }
+
+ private void SmallDecrement ()
+ {
+ UpdatePos (position - SmallChange, true);
+ Invalidate (thumb_area);
+ OnScroll (new EventArgs ());
+ }
+
+ private void OnMouseUpTB (object sender, MouseEventArgs e)
+ {
+ if (!Enabled) return;
+
+ if (thumb_pressed == true || mouse_clickmove == true) {
+ thumb_pressed = false;
+ holdclick_timer.Enabled = false;
+ this.Capture = false;
+ Invalidate (thumb_area);
+ }
+ }
+
+ private void OnMouseDownTB (object sender, MouseEventArgs e)
+ {
+ if (!Enabled) return;
+
+ bool fire_timer = false;
+
+ Point point = new Point (e.X, e.Y);
+
+ if (orientation == Orientation.Horizontal) {
+
+ if (thumb_pos.Contains (point)) {
+ this.Capture = true;
+ thumb_pressed = true;
+ thumb_mouseclick = e.X;
+ Invalidate (thumb_area);
+ }
+ else {
+ if (ClientRectangle.Contains (point)) {
+ if (e.X > thumb_pos.X + thumb_pos.Width)
+ LargeIncrement ();
+ else
+ LargeDecrement ();
+
+ Invalidate (thumb_area);
+ fire_timer = true;
+ mouse_clickmove = true;
+ }
+ }
+ }
+ else {
+ if (thumb_pos.Contains (point)) {
+ this.Capture = true;
+ thumb_pressed = true;
+ thumb_mouseclick = e.Y;
+ Invalidate (thumb_area);
+
+ }
+ else {
+ if (ClientRectangle.Contains (point)) {
+ if (e.Y > thumb_pos.Y + thumb_pos.Height)
+ LargeDecrement ();
+ else
+ LargeIncrement ();
+
+ Invalidate (thumb_area);
+ fire_timer = true;
+ mouse_clickmove = true;
+ }
+ }
+ }
+
+ if (fire_timer) {
+ holdclick_timer.Interval = 300;
+ holdclick_timer.Enabled = true;
+ }
+ }
+
+ private void OnMouseMoveTB (object sender, MouseEventArgs e)
+ {
+ if (!Enabled) return;
+
+ /* Moving the thumb */
+ if (thumb_pressed) {
+
+ if (orientation == Orientation.Horizontal){
+ if (ClientRectangle.Contains (e.X, thumb_pos.Y))
+ thumb_mouseclick = e.X;
+ }
+ else {
+ if (ClientRectangle.Contains (thumb_pos.X, e.Y))
+ thumb_mouseclick = e.Y;
+ }
+
+ Invalidate (thumb_area);
+ OnScroll (new EventArgs ());
+ }
+ }
+
+ private void OnPaintTB (PaintEventArgs pevent)
+ {
+ if (Paint != null) {
+ Paint (this, pevent);
+ }
+ ThemeEngine.Current.DrawTrackBar (pevent.Graphics, pevent.ClipRectangle, this);
+ }
+
+ private void OnKeyDownTB (object sender, KeyEventArgs e)
+ {
+ switch (e.KeyCode) {
+
+ case Keys.Down:
+ case Keys.Right:
+ SmallDecrement ();
+ break;
+
+ case Keys.Up:
+ case Keys.Left:
+ SmallIncrement ();
+ break;
+
+ case Keys.PageUp:
+ LargeIncrement ();
+ break;
+
+ case Keys.PageDown:
+ LargeDecrement ();
+ break;
+
+ case Keys.Home:
+ Value = Maximum;
+ break;
+
+ case Keys.End:
+ Value = Minimum;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ private void OnFirstClickTimer (Object source, ElapsedEventArgs e)
+ {
+ Point pnt;
+ pnt = PointToClient (MousePosition);
+
+ if (thumb_area.Contains (pnt)) {
+ if (orientation == Orientation.Horizontal) {
+ if (pnt.X > thumb_pos.X + thumb_pos.Width)
+ LargeIncrement ();
+
+ if (pnt.X < thumb_pos.X)
+ LargeDecrement ();
+ }
+ else {
+ if (pnt.Y > thumb_pos.Y + thumb_pos.Height)
+ LargeIncrement ();
+
+ if (pnt.Y < thumb_pos.Y)
+ LargeDecrement ();
+ }
+
+ Invalidate (thumb_area);
+
+ }
+ }
+
+ protected override void SetBoundsCore (int x, int y,int width, int height, BoundsSpecified specified)
+ {
+ base.SetBoundsCore (x, y,width, height, specified);
+ }
+
+
+ #endregion // Private Methods
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNode.cs
new file mode 100644
index 00000000000..c8aa8493f92
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNode.cs
@@ -0,0 +1,686 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+// Kazuki Oikawa (kazuki@panicode.com)
+
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.Serialization;
+using System.Text;
+
+namespace System.Windows.Forms {
+ [TypeConverter(typeof(TreeNodeConverter))]
+ [Serializable]
+ public class TreeNode : MarshalByRefObject, ICloneable, ISerializable {
+ #region Fields
+ private TreeView tree_view;
+ internal TreeNode parent;
+
+ private string text;
+ private int image_index = -1;
+ private int selected_image_index = -1;
+ internal TreeNodeCollection nodes;
+ internal TreeViewAction check_reason = TreeViewAction.Unknown;
+
+ private bool is_expanded = false;
+ private Rectangle bounds = Rectangle.Empty;
+ private bool check;
+ private bool is_editing;
+ internal OwnerDrawPropertyBag prop_bag;
+
+ private object tag;
+
+ internal IntPtr handle;
+
+ #endregion // Fields
+
+ #region Internal Constructors
+ internal TreeNode (TreeView tree_view) : this ()
+ {
+ this.tree_view = tree_view;
+ is_expanded = true;
+ }
+
+ private TreeNode (SerializationInfo info, StreamingContext context) : this ()
+ {
+ Text = (string) info.GetValue ("Text", typeof (string));
+ prop_bag = (OwnerDrawPropertyBag) info.GetValue ("prop_bag", typeof (OwnerDrawPropertyBag));
+ image_index = (int) info.GetValue ("ImageIndex", typeof (int));
+ selected_image_index = (int) info.GetValue ("SelectedImageIndex", typeof (int));
+ tag = info.GetValue ("Tag", typeof (object));
+ check = (bool) info.GetValue ("Checked", typeof (bool));
+
+ int count = (int) info.GetValue ("NumberOfChildren", typeof (int));
+ for (int i = 0; i < count; i++) {
+ TreeNode node = (TreeNode) info.GetValue ("Child-" + i, typeof (TreeNode));
+ Nodes.Add (node);
+ }
+ }
+
+ #endregion // Internal Constructors
+
+ #region Public Constructors
+ public TreeNode ()
+ {
+ nodes = new TreeNodeCollection (this);
+ }
+
+ public TreeNode (string text) : this ()
+ {
+ Text = text;
+ }
+
+ public TreeNode (string text, TreeNode [] children) : this (text)
+ {
+ Nodes.AddRange (children);
+ }
+
+ public TreeNode (string text, int image_index, int selected_image_index) : this (text)
+ {
+ this.image_index = image_index;
+ this.selected_image_index = selected_image_index;
+ }
+
+ public TreeNode (string text, int image_index, int selected_image_index,
+ TreeNode [] children) : this (text, image_index, selected_image_index)
+ {
+ Nodes.AddRange (children);
+ }
+
+ #endregion // Public Constructors
+
+ #region ICloneable Members
+ public virtual object Clone()
+ {
+ TreeNode tn = new TreeNode (text, image_index, selected_image_index);
+ if (nodes != null) {
+ foreach (TreeNode child in nodes)
+ tn.Nodes.Add ((TreeNode)child.Clone ());
+ }
+ tn.Tag = tag;
+ tn.Checked = Checked;
+ if (prop_bag != null)
+ tn.prop_bag = OwnerDrawPropertyBag.Copy (prop_bag);
+ return tn;
+ }
+
+ #endregion // ICloneable Members
+
+ #region ISerializable Members
+ void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ info.AddValue ("Text", Text);
+ info.AddValue ("prop_bag", prop_bag, typeof (OwnerDrawPropertyBag));
+ info.AddValue ("ImageIndex", ImageIndex);
+ info.AddValue ("SelectedImageIndex", SelectedImageIndex);
+ info.AddValue ("Tag", Tag);
+ info.AddValue ("Checked", Checked);
+
+ info.AddValue ("NumberOfChildren", Nodes.Count);
+ for (int i = 0; i < Nodes.Count; i++)
+ info.AddValue ("Child-" + i, Nodes [i], typeof (TreeNode));
+ }
+ #endregion // ISerializable Members
+
+ #region Public Instance Properties
+ public Color BackColor {
+ get {
+ if (prop_bag != null)
+ return prop_bag.BackColor;
+ if (TreeView != null)
+ return TreeView.BackColor;
+ return Color.Empty;
+ }
+ set {
+ if (prop_bag == null)
+ prop_bag = new OwnerDrawPropertyBag ();
+ prop_bag.BackColor = value;
+
+ TreeView tree_view = TreeView;
+ if (tree_view != null)
+ tree_view.UpdateNode (this);
+ }
+ }
+
+ public Rectangle Bounds {
+ get { return bounds; }
+ }
+
+ public bool Checked {
+ get { return check; }
+ set {
+ if (check == value)
+ return;
+ TreeViewCancelEventArgs args = new TreeViewCancelEventArgs (this, false, check_reason);
+ if (TreeView != null)
+ TreeView.OnBeforeCheck (args);
+ if (!args.Cancel) {
+ check = value;
+ if (TreeView != null) {
+ TreeView.OnAfterCheck (new TreeViewEventArgs (this, check_reason));
+ TreeView.UpdateNode (this);
+ }
+ }
+ check_reason = TreeViewAction.Unknown;
+ }
+ }
+
+ public TreeNode FirstNode {
+ get {
+ if (nodes.Count > 0)
+ return nodes [0];
+ return null;
+ }
+ }
+
+ public Color ForeColor {
+ get {
+ if (prop_bag != null)
+ return prop_bag.ForeColor;
+ if (TreeView != null)
+ return TreeView.ForeColor;
+ return Color.Empty;
+ }
+ set {
+ if (prop_bag == null)
+ prop_bag = new OwnerDrawPropertyBag ();
+ prop_bag.ForeColor = value;
+
+ TreeView tree_view = TreeView;
+ if (tree_view != null)
+ tree_view.UpdateNode (this);
+ }
+ }
+
+ public string FullPath {
+ get {
+ if (TreeView == null)
+ throw new Exception ("No TreeView associated");
+
+ StringBuilder builder = new StringBuilder ();
+ BuildFullPath (builder);
+ return builder.ToString ();
+ }
+ }
+
+ [Localizable(true)]
+ public int ImageIndex {
+ get { return image_index; }
+ set {
+ if (image_index == value)
+ return;
+ image_index = value;
+ TreeView tree = TreeView;
+ if (tree != null)
+ tree.UpdateNode (this);
+ }
+ }
+
+ public bool IsEditing {
+ get { return is_editing; }
+ }
+
+ public bool IsExpanded {
+ get { return is_expanded; }
+ }
+
+ public bool IsSelected {
+ get {
+ if (TreeView == null)
+ return false;
+ return TreeView.SelectedNode == this;
+ }
+ }
+
+ public bool IsVisible {
+ get {
+ if (TreeView == null)
+ return false;
+
+ if (bounds.Y < 0 && bounds.Y > TreeView.ClientRectangle.Height)
+ return false;
+
+ TreeNode parent = Parent;
+ while (parent != null) {
+ if (!parent.IsExpanded)
+ return false;
+ parent = parent.Parent;
+ }
+ return true;
+ }
+ }
+
+ public TreeNode LastNode {
+ get {
+ return (nodes == null || nodes.Count == 0) ? null : nodes [nodes.Count - 1];
+ }
+ }
+
+ public TreeNode NextNode {
+ get {
+ if (parent == null)
+ return null;
+ int index = Index;
+ if (parent.Nodes.Count > index + 1)
+ return parent.Nodes [index + 1];
+ return null;
+ }
+ }
+
+ public TreeNode NextVisibleNode {
+ get {
+ OpenTreeNodeEnumerator o = new OpenTreeNodeEnumerator (this);
+ if (!o.MoveNext ())
+ return null;
+ TreeNode c = (TreeNode) o.Current;
+ if (!c.IsInClippingRect)
+ return null;
+ return c;
+ }
+ }
+
+ [Localizable(true)]
+ public Font NodeFont {
+ get {
+ if (prop_bag != null)
+ return prop_bag.Font;
+ if (TreeView != null)
+ return TreeView.Font;
+ return null;
+ }
+ set {
+ if (prop_bag == null)
+ prop_bag = new OwnerDrawPropertyBag ();
+ prop_bag.Font = value;
+ InvalidateWidth ();
+ }
+ }
+
+ [ListBindable(false)]
+ public TreeNodeCollection Nodes {
+ get {
+ if (nodes == null)
+ nodes = new TreeNodeCollection (this);
+ return nodes;
+ }
+ }
+
+ public TreeNode Parent {
+ get {
+ TreeView tree_view = TreeView;
+ if (tree_view != null && tree_view.root_node == parent)
+ return null;
+ return parent;
+ }
+ }
+
+ public TreeNode PrevNode {
+ get {
+ if (parent == null)
+ return null;
+ int index = Index;
+ if (index <= 0 || index > parent.Nodes.Count)
+ return null;
+ return parent.Nodes [index - 1];
+ }
+ }
+
+ public TreeNode PrevVisibleNode {
+ get {
+ OpenTreeNodeEnumerator o = new OpenTreeNodeEnumerator (this);
+ if (!o.MovePrevious ())
+ return null;
+ TreeNode c = (TreeNode) o.Current;
+ if (!c.IsInClippingRect)
+ return null;
+ return c;
+ }
+ }
+
+ [Localizable(true)]
+ public int SelectedImageIndex {
+ get { return selected_image_index; }
+ set { selected_image_index = value; }
+ }
+
+ [Bindable(true)]
+ [Localizable(false)]
+ [TypeConverter(typeof(System.ComponentModel.StringConverter))]
+ [DefaultValue(null)]
+ public object Tag {
+ get { return tag; }
+ set { tag = value; }
+ }
+
+ [Localizable(true)]
+ public string Text {
+ get {
+ if (text == null)
+ return String.Empty;
+ return text;
+ }
+ set {
+ if (text == value)
+ return;
+ text = value;
+ bounds.Width = 0;
+ }
+ }
+
+ public TreeView TreeView {
+ get {
+ if (tree_view != null)
+ return tree_view;
+ TreeNode walk = parent;
+ while (walk != null) {
+ if (walk.TreeView != null)
+ break;
+ walk = walk.parent;
+ }
+ if (walk == null)
+ return null;
+ return walk.TreeView;
+ }
+ }
+
+ public IntPtr Handle {
+ get {
+ // MS throws a NullReferenceException if the TreeView isn't set...
+ if (handle == IntPtr.Zero && TreeView != null)
+ handle = TreeView.CreateNodeHandle ();
+ return handle;
+ }
+ }
+
+ #endregion // Public Instance Properties
+
+
+ public static TreeNode FromHandle (TreeView tree, IntPtr handle)
+ {
+ if (handle == IntPtr.Zero)
+ return null;
+ // No arg checking on MS it just throws a NullRef if treeview is null
+ return tree.NodeFromHandle (handle);
+ }
+
+ #region Public Instance Methods
+ public void BeginEdit () {
+ is_editing = true;
+ }
+
+ public void Collapse () {
+ Collapse(false);
+ }
+
+ public void EndEdit (bool cancel) {
+ is_editing = false;
+ if (!cancel && TreeView != null)
+ Text = TreeView.LabelEditText;
+ }
+
+ public void Expand () {
+ Expand(false);
+ }
+
+ public void ExpandAll () {
+ ExpandRecursive (this);
+ if(TreeView != null)
+ TreeView.UpdateNode (TreeView.root_node);
+ }
+
+ public void EnsureVisible ()
+ {
+ if (TreeView == null)
+ return;
+
+ if (this.Parent != null)
+ ExpandParentRecursive (this.Parent);
+
+ if (bounds.Y < 0) {
+ TreeView.SetTop (this);
+ } else if (bounds.Bottom > TreeView.ViewportRectangle.Bottom) {
+ TreeView.SetBottom (this);
+ }
+ }
+
+ public int GetNodeCount (bool include_subtrees) {
+ if (!include_subtrees)
+ return Nodes.Count;
+
+ int count = 0;
+ GetNodeCountRecursive (this, ref count);
+
+ return count;
+ }
+
+ public void Remove () {
+ if (parent == null)
+ return;
+ int index = Index;
+ parent.Nodes.RemoveAt (index);
+ }
+
+ public void Toggle () {
+ if (is_expanded)
+ Collapse ();
+ else
+ Expand ();
+ }
+
+ public override String ToString () {
+ return String.Concat ("TreeNode: ", Text);
+ }
+
+ #endregion // Public Instance Methods
+
+ #region Internal & Private Methods and Properties
+
+ internal bool IsRoot {
+ get {
+ TreeView tree_view = TreeView;
+ if (tree_view == null)
+ return false;
+ if (tree_view.root_node == this)
+ return true;
+ return false;
+ }
+ }
+
+ bool BuildFullPath (StringBuilder path)
+ {
+ if (parent == null)
+ return false;
+
+ if (parent.BuildFullPath (path))
+ path.Append (TreeView.PathSeparator);
+
+ path.Append (text);
+ return true;
+ }
+
+ public int Index {
+ get {
+ if (parent == null)
+ return 0;
+ return parent.Nodes.IndexOf (this);
+ }
+ }
+
+ private void Expand (bool byInternal)
+ {
+ if (is_expanded)
+ return;
+ bool cancel = false;
+ if (TreeView != null) {
+ TreeViewCancelEventArgs e = new TreeViewCancelEventArgs (this, false, TreeViewAction.Expand);
+ TreeView.OnBeforeExpand (e);
+ cancel = e.Cancel;
+ }
+
+ if (!cancel) {
+ is_expanded = true;
+ if (TreeView != null)
+ TreeView.OnAfterExpand (new TreeViewEventArgs (this));
+ if (IsVisible && TreeView != null)
+ TreeView.UpdateBelow (this);
+ }
+ }
+
+ private void Collapse (bool byInternal)
+ {
+ if (!is_expanded)
+ return;
+
+ if (IsRoot)
+ return;
+
+ bool cancel = false;
+ if (TreeView != null) {
+ TreeViewCancelEventArgs e = new TreeViewCancelEventArgs (this, false, TreeViewAction.Collapse);
+ TreeView.OnBeforeCollapse (e);
+ cancel = e.Cancel;
+ }
+
+ if (!cancel) {
+ is_expanded = false;
+ if (TreeView != null)
+ TreeView.OnAfterCollapse (new TreeViewEventArgs (this));
+ if (IsVisible && TreeView != null)
+ TreeView.UpdateBelow (this);
+ if(!byInternal && TreeView != null && HasFocusInChildren ())
+ TreeView.SelectedNode = this;
+ }
+ }
+
+ private bool HasFocusInChildren()
+ {
+ if(TreeView == null) return false;
+ foreach(TreeNode node in nodes) {
+ if(node == TreeView.SelectedNode) return true;
+ if(node.HasFocusInChildren())
+ return true;
+ }
+ return false;
+ }
+
+ private void ExpandRecursive (TreeNode node)
+ {
+ node.Expand (true);
+ foreach (TreeNode child in node.Nodes) {
+ ExpandRecursive (child);
+ }
+ }
+
+ private void ExpandParentRecursive (TreeNode node)
+ {
+ node.Expand (true);
+ if (node.Parent != null)
+ ExpandParentRecursive (node.Parent);
+ }
+
+ internal void CollapseAll ()
+ {
+ CollapseRecursive (this);
+ }
+
+ internal void CollapseAllUncheck ()
+ {
+ CollapseUncheckRecursive (this);
+ }
+
+ private void CollapseRecursive (TreeNode node)
+ {
+ node.Collapse ();
+ foreach (TreeNode child in node.Nodes) {
+ CollapseRecursive (child);
+ }
+ }
+
+ private void CollapseUncheckRecursive (TreeNode node)
+ {
+ node.Collapse ();
+ node.Checked = false;
+ foreach (TreeNode child in node.Nodes) {
+ CollapseUncheckRecursive (child);
+ }
+ }
+
+ internal void SetNodes (TreeNodeCollection nodes)
+ {
+ this.nodes = nodes;
+ }
+
+ private void GetNodeCountRecursive (TreeNode node, ref int count)
+ {
+ count += node.Nodes.Count;
+ foreach (TreeNode child in node.Nodes) {
+ GetNodeCountRecursive (child, ref count);
+ }
+ }
+
+ internal bool NeedsWidth {
+ get { return bounds.Width == 0; }
+ }
+
+ internal void InvalidateWidth ()
+ {
+ bounds.Width = 0;
+ }
+
+ internal void SetWidth (int width)
+ {
+ bounds.Width = width;
+ }
+
+ internal void SetHeight (int height)
+ {
+ bounds.Height = height;
+ }
+
+ internal void SetPosition (int x, int y)
+ {
+ bounds.X = x;
+ bounds.Y = y;
+ }
+
+ internal void SetParent (TreeNode parent)
+ {
+ this.parent = parent;
+ }
+
+ private bool IsInClippingRect
+ {
+ get {
+ if (TreeView == null)
+ return false;
+ if (bounds.Y < 0 && bounds.Y > TreeView.ClientRectangle.Height)
+ return false;
+ return true;
+ }
+ }
+ #endregion // Internal & Private Methods and Properties
+
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeCollection.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeCollection.cs
new file mode 100644
index 00000000000..09a29fb7af6
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeCollection.cs
@@ -0,0 +1,373 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+// TODO: Sorting
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Globalization;
+
+namespace System.Windows.Forms {
+ [Editor("System.Windows.Forms.Design.TreeNodeCollectionEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
+ public class TreeNodeCollection : IList, ICollection, IEnumerable {
+
+ private static readonly int OrigSize = 50;
+
+ private TreeNode owner;
+ private int count;
+ private TreeNode [] nodes;
+
+ private TreeNodeCollection ()
+ {
+ }
+
+ internal TreeNodeCollection (TreeNode owner)
+ {
+ this.owner = owner;
+ nodes = new TreeNode [OrigSize];
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public virtual int Count {
+ get { return count; }
+ }
+
+ public virtual bool IsReadOnly {
+ get { return false; }
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return false; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return this; }
+ }
+
+ bool IList.IsFixedSize {
+ get { return false; }
+ }
+
+ object IList.this [int index] {
+ get {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("index");
+ return nodes [index];
+ }
+ set {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("index");
+ TreeNode node = (TreeNode) value;
+ node.parent = owner;
+ nodes [index] = node;
+ }
+ }
+
+ public virtual TreeNode this [int index] {
+ get {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("index");
+ return nodes [index];
+ }
+ set {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("index");
+ value.parent = owner;
+ nodes [index] = value;
+ }
+ }
+
+ public virtual TreeNode Add (string text)
+ {
+ TreeNode res = new TreeNode (text);
+ Add (res);
+ return res;
+ }
+
+ public virtual int Add (TreeNode node)
+ {
+ if (node == null)
+ throw new ArgumentNullException("node");
+
+ // Remove it from any old parents
+ node.Remove ();
+
+ int res;
+ TreeView tree_view = null;
+ if (owner != null)
+ tree_view = owner.TreeView;
+ if (tree_view != null && tree_view.Sorted) {
+ res = AddSorted (node);
+ } else {
+ node.parent = owner;
+ if (count >= nodes.Length)
+ Grow ();
+ nodes [count++] = node;
+ res = count;
+ }
+
+ if (owner != null && tree_view != null && (owner.IsExpanded || owner.IsRoot)) {
+ // XXX: Need to ensure the boxes for the nodes have been created
+ tree_view.UpdateBelow (owner);
+ } else if (owner != null && tree_view != null) {
+ tree_view.UpdateBelow (owner);
+ }
+
+ return res;
+ }
+
+ public virtual void AddRange (TreeNode [] nodes)
+ {
+ if (nodes == null)
+ throw new ArgumentNullException("node");
+
+ // We can't just use Array.Copy because the nodes also
+ // need to have some properties set when they are added.
+ for (int i = 0; i < nodes.Length; i++)
+ Add (nodes [i]);
+ }
+
+ public virtual void Clear ()
+ {
+ for (int i = 0; i < count; i++)
+ RemoveAt (i, false);
+
+ Array.Clear (nodes, 0, count);
+ count = 0;
+
+ TreeView tree_view = null;
+ if (owner != null) {
+ tree_view = owner.TreeView;
+ if (owner.IsRoot)
+ tree_view.top_node = null;
+ if (tree_view != null)
+ tree_view.UpdateBelow (owner);
+ }
+ }
+
+ public bool Contains (TreeNode node)
+ {
+ return (Array.BinarySearch (nodes, node) > 0);
+ }
+
+ public virtual void CopyTo (Array dest, int index)
+ {
+ nodes.CopyTo (dest, index);
+ }
+
+ public virtual IEnumerator GetEnumerator ()
+ {
+ return new TreeNodeEnumerator (this);
+ }
+
+ public int IndexOf (TreeNode node)
+ {
+ return Array.IndexOf (nodes, node);
+ }
+
+ public virtual void Insert (int index, TreeNode node)
+ {
+ node.parent = owner;
+
+ if (count >= nodes.Length)
+ Grow ();
+
+ Array.Copy (nodes, index, nodes, index + 1, count - index);
+ nodes [index] = node;
+ count++;
+ }
+
+ public void Remove (TreeNode node)
+ {
+ int index = IndexOf (node);
+ if (index > 0)
+ RemoveAt (index);
+ }
+
+ public virtual void RemoveAt (int index)
+ {
+ RemoveAt (index, true);
+ }
+
+ private void RemoveAt (int index, bool update)
+ {
+ TreeNode removed = nodes [index];
+
+ Array.Copy (nodes, index + 1, nodes, index, count - index);
+ count--;
+ if (nodes.Length > OrigSize && nodes.Length > (count * 2))
+ Shrink ();
+
+ TreeView tree_view = null;
+ if (owner != null)
+ tree_view = owner.TreeView;
+ if (tree_view != null && removed == tree_view.top_node) {
+ OpenTreeNodeEnumerator oe = new OpenTreeNodeEnumerator (removed);
+ if (oe.MoveNext () && oe.MoveNext ())
+ tree_view.top_node = oe.CurrentNode;
+ else
+ tree_view.top_node = null;
+ }
+
+ TreeNode parent = removed.parent;
+ removed.parent = null;
+
+ if (tree_view != null)
+ tree_view.UpdateBelow (parent);
+ }
+
+ int IList.Add (object node)
+ {
+ return Add ((TreeNode) node);
+ }
+
+ bool IList.Contains (object node)
+ {
+ return Contains ((TreeNode) node);
+ }
+
+ int IList.IndexOf (object node)
+ {
+ return IndexOf ((TreeNode) node);
+ }
+
+ void IList.Insert (int index, object node)
+ {
+ Insert (index, (TreeNode) node);
+ }
+
+ void IList.Remove (object node)
+ {
+ Remove ((TreeNode) node);
+ }
+
+ private int AddSorted (TreeNode node)
+ {
+ if (count >= nodes.Length)
+ Grow ();
+
+ CompareInfo compare = Application.CurrentCulture.CompareInfo;
+ int pos = 0;
+ bool found = false;
+ for (int i = 0; i < count; i++) {
+ pos = i;
+ int comp = compare.Compare (node.Text, nodes [i].Text);
+ if (comp < 0) {
+ found = true;
+ break;
+ }
+ }
+
+ // Stick it at the end
+ if (!found)
+ pos = count;
+
+ // Move the nodes up and adjust their indices
+ for (int i = count - 1; i >= pos; i--) {
+ nodes [i + 1] = nodes [i];
+ }
+ count++;
+ nodes [pos] = node;
+
+ node.parent = owner;
+ return count;
+ }
+
+ // Would be nice to do this without running through the collection twice
+ internal void Sort () {
+
+ Array.Sort (nodes, 0, count, new TreeNodeComparer (Application.CurrentCulture.CompareInfo));
+
+ for (int i = 0; i < count; i++) {
+ nodes [i].Nodes.Sort ();
+ }
+ }
+
+ private void Grow ()
+ {
+ TreeNode [] nn = new TreeNode [nodes.Length + 50];
+ Array.Copy (nodes, nn, nodes.Length);
+ nodes = nn;
+ }
+
+ private void Shrink ()
+ {
+ int len = (count > OrigSize ? count : OrigSize);
+ TreeNode [] nn = new TreeNode [len];
+ Array.Copy (nodes, nn, count);
+ nodes = nn;
+ }
+
+
+ internal class TreeNodeEnumerator : IEnumerator {
+
+ private TreeNodeCollection collection;
+ private int index = -1;
+
+ public TreeNodeEnumerator (TreeNodeCollection collection)
+ {
+ this.collection = collection;
+ }
+
+ public object Current {
+ get { return collection [index]; }
+ }
+
+ public bool MoveNext ()
+ {
+ if (index + 1 >= collection.Count)
+ return false;
+ index++;
+ return true;
+ }
+
+ public void Reset ()
+ {
+ index = 0;
+ }
+ }
+
+ private class TreeNodeComparer : IComparer {
+
+ private CompareInfo compare;
+
+ public TreeNodeComparer (CompareInfo compare)
+ {
+ this.compare = compare;
+ }
+
+ public int Compare (object x, object y)
+ {
+ TreeNode l = (TreeNode) x;
+ TreeNode r = (TreeNode) y;
+ int res = compare.Compare (l.Text, r.Text);
+
+ return (res == 0 ? l.Index - r.Index : res);
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeConverter.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeConverter.cs
new file mode 100644
index 00000000000..a0a4c93c918
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeConverter.cs
@@ -0,0 +1,54 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// NOT COMPLETE
+
+using System.ComponentModel;
+using System.Globalization;
+
+namespace System.Windows.Forms {
+ public class TreeNodeConverter : TypeConverter {
+
+ #region Public Instance Methods
+ public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
+ {
+ if (destinationType == typeof (string))
+ return true;
+ return base.CanConvertTo (context, destinationType);
+ }
+
+ public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture,
+ object value, Type destinationType)
+ {
+ // Regardless of the type of object passed in this does a ToString
+ if (destinationType == typeof (string) && value != null)
+ return value.ToString ();
+ return base.ConvertTo (context, culture, value, destinationType);
+ }
+
+ #endregion // Public Instance Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeView.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeView.cs
new file mode 100644
index 00000000000..eae661b3562
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeView.cs
@@ -0,0 +1,1571 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+// Kazuki Oikawa (kazuki@panicode.com)
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [DefaultProperty("Nodes")]
+ [DefaultEvent("AfterSelect")]
+ [Designer("System.Windows.Forms.Design.TreeViewDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ public class TreeView : Control {
+ #region Fields
+ private string path_separator = "\\";
+ private int item_height = -1;
+ private bool sorted;
+ internal TreeNode top_node;
+ internal TreeNode root_node;
+ internal bool nodes_added;
+ private TreeNodeCollection nodes;
+
+ private TreeNode selected_node = null;
+ private TreeNode focused_node = null;
+ private bool select_mmove = false;
+
+ private ImageList image_list;
+ private int image_index = -1;
+ private int selected_image_index = -1;
+
+ private bool full_row_select;
+ private bool hot_tracking;
+ private int indent = 19;
+
+ private TextBox edit_text_box;
+ private TreeNode edit_node;
+
+ private bool checkboxes;
+ private bool label_edit;
+ private bool scrollable;
+ private bool show_lines = true;
+ private bool show_root_lines = true;
+ private bool show_plus_minus = true;
+ private bool hide_selection = true;
+
+ private bool add_hscroll;
+ private bool add_vscroll;
+ private int max_node_width;
+ private VScrollBar vbar;
+ private int skipped_nodes;
+ private HScrollBar hbar;
+ private int hbar_offset;
+ private int used_height;
+ private bool update_node_bounds;
+
+ private int update_stack;
+ private bool update_needed;
+
+ private TreeViewEventHandler on_after_check;
+ private TreeViewEventHandler on_after_collapse;
+ private TreeViewEventHandler on_after_expand;
+ private NodeLabelEditEventHandler on_after_label_edit;
+ private TreeViewEventHandler on_after_select;
+ private TreeViewCancelEventHandler on_before_check;
+ private TreeViewCancelEventHandler on_before_collapse;
+ private TreeViewCancelEventHandler on_before_expand;
+ private NodeLabelEditEventHandler on_before_label_edit;
+ private TreeViewCancelEventHandler on_before_select;
+
+ private Pen dash;
+ private StringFormat string_format;
+ private int open_node_count = -1;
+
+ private int drag_begin_x = 0;
+ private int drag_begin_y = 0;
+ private long handle_count = 1;
+
+ #endregion // Fields
+
+ #region Public Constructors
+ public TreeView ()
+ {
+ base.background_color = ThemeEngine.Current.ColorWindow;
+ base.foreground_color = ThemeEngine.Current.ColorWindowText;
+
+ root_node = new TreeNode (this);
+ root_node.Text = "ROOT NODE";
+ nodes = new TreeNodeCollection (root_node);
+ root_node.SetNodes (nodes);
+
+ MouseDown += new MouseEventHandler (MouseDownHandler);
+ MouseUp += new MouseEventHandler(MouseUpHandler);
+ MouseMove += new MouseEventHandler(MouseMoveHandler);
+ SizeChanged += new EventHandler (SizeChangedHandler);
+ FontChanged += new EventHandler (FontChangedHandler);
+ LostFocus += new EventHandler (FocusChangedHandler);
+ GotFocus += new EventHandler (FocusChangedHandler);
+ MouseWheel += new MouseEventHandler(MouseWheelHandler);
+
+ SetStyle (ControlStyles.UserPaint | ControlStyles.StandardClick, false);
+
+ string_format = new StringFormat ();
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.Alignment = StringAlignment.Center;
+ }
+
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public override Color BackColor {
+ get { return base.BackColor;}
+ set { base.BackColor = value; }
+ }
+
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Image BackgroundImage {
+ get { return base.BackgroundImage; }
+ set { base.BackgroundImage = value; }
+ }
+
+ [DefaultValue(BorderStyle.Fixed3D)]
+ [DispId(-504)]
+ public BorderStyle BorderStyle {
+ get { return InternalBorderStyle; }
+ set { InternalBorderStyle = value; }
+ }
+
+ [DefaultValue(false)]
+ public bool CheckBoxes {
+ get { return checkboxes; }
+ set {
+ if (value == checkboxes)
+ return;
+ checkboxes = value;
+
+ // Match a "bug" in the MS implementation where disabling checkboxes
+ // collapses the entire tree, but enabling them does not affect the
+ // state of the tree.
+ if (!checkboxes)
+ root_node.CollapseAllUncheck ();
+
+ Refresh ();
+ }
+ }
+
+ public override Color ForeColor {
+ get { return base.ForeColor; }
+ set { base.ForeColor = value; }
+ }
+ [DefaultValue(false)]
+ public bool FullRowSelect {
+ get { return full_row_select; }
+ set {
+ if (value == full_row_select)
+ return;
+ full_row_select = value;
+ Refresh ();
+ }
+ }
+ [DefaultValue(true)]
+ public bool HideSelection {
+ get { return hide_selection; }
+ set {
+ if (hide_selection == value)
+ return;
+ hide_selection = value;
+ this.Refresh ();
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool HotTracking {
+ get { return hot_tracking; }
+ set { hot_tracking = value; }
+ }
+
+ [DefaultValue(0)]
+ [Editor("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
+ [Localizable(true)]
+ [TypeConverter(typeof(TreeViewImageIndexConverter))]
+ public int ImageIndex {
+ get { return image_index; }
+ set {
+ if (value < -1) {
+ throw new ArgumentException ("'" + value + "' is not a valid value for 'value'. " +
+ "'value' must be greater than or equal to 0.");
+ }
+ if (image_index == value)
+ return;
+ image_index = value;
+ Refresh ();
+ }
+ }
+
+ [DefaultValue(null)]
+ public ImageList ImageList {
+ get { return image_list; }
+ set {
+ image_list = value;
+ Refresh ();
+ }
+ }
+
+ [Localizable(true)]
+ public int Indent {
+ get { return indent; }
+ set {
+ if (indent == value)
+ return;
+ if (value > 32000) {
+ throw new ArgumentException ("'" + value + "' is not a valid value for 'Indent'. " +
+ "'Indent' must be less than or equal to 32000");
+ }
+ if (value < 0) {
+ throw new ArgumentException ("'" + value + "' is not a valid value for 'Indent'. " +
+ "'Indent' must be greater than or equal to 0.");
+ }
+ indent = value;
+ Refresh ();
+ }
+ }
+
+ [Localizable(true)]
+ public int ItemHeight {
+ get {
+ if (item_height == -1)
+ return FontHeight + 3;
+ return item_height;
+ }
+ set {
+ if (value == item_height)
+ return;
+ item_height = value;
+ Refresh ();
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool LabelEdit {
+ get { return label_edit; }
+ set { label_edit = value; }
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ [MergableProperty(false)]
+ [Localizable(true)]
+ public TreeNodeCollection Nodes {
+ get { return nodes; }
+ }
+
+ [DefaultValue("\\")]
+ public string PathSeparator {
+ get { return path_separator; }
+ set { path_separator = value; }
+ }
+
+ [DefaultValue(true)]
+ public bool Scrollable {
+ get { return scrollable; }
+ set {
+ if (scrollable == value)
+ return;
+ scrollable = value;
+ }
+ }
+
+ [Editor("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
+ [TypeConverter(typeof(TreeViewImageIndexConverter))]
+ [Localizable(true)]
+ [DefaultValue(0)]
+ public int SelectedImageIndex {
+ get { return selected_image_index; }
+ set {
+ if (value < -1) {
+ throw new ArgumentException ("'" + value + "' is not a valid value for 'value'. " +
+ "'value' must be greater than or equal to 0.");
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public TreeNode SelectedNode {
+ get { return selected_node; }
+ set {
+ if (selected_node == value)
+ return;
+
+ TreeViewCancelEventArgs e = new TreeViewCancelEventArgs (value, false, TreeViewAction.Unknown);
+ OnBeforeSelect (e);
+
+ if (e.Cancel)
+ return;
+
+ Rectangle invalid = Rectangle.Empty;
+
+ if (selected_node != null) {
+ invalid = Bloat (selected_node.Bounds);
+ }
+ if (focused_node != null) {
+ invalid = Rectangle.Union (invalid,
+ Bloat (focused_node.Bounds));
+ }
+
+ if (value != null)
+ invalid = Rectangle.Union (invalid, Bloat (value.Bounds));
+
+ selected_node = value;
+ focused_node = value;
+
+ if (full_row_select) {
+ invalid.X = 0;
+ invalid.Width = ViewportRectangle.Width;
+ }
+
+ if (invalid != Rectangle.Empty)
+ Invalidate (invalid);
+
+ // We ensure its visible after we update because
+ // scrolling is used for insure visible
+ if (selected_node != null)
+ selected_node.EnsureVisible ();
+
+ OnAfterSelect (new TreeViewEventArgs (value, TreeViewAction.Unknown));
+ }
+ }
+
+ private Rectangle Bloat (Rectangle rect)
+ {
+ rect.Y--;
+ rect.X--;
+ rect.Height += 2;
+ rect.Width += 2;
+ return rect;
+ }
+
+ [DefaultValue(true)]
+ public bool ShowLines {
+ get { return show_lines; }
+ set {
+ if (show_lines == value)
+ return;
+ show_lines = value;
+ Refresh ();
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool ShowPlusMinus {
+ get { return show_plus_minus; }
+ set {
+ if (show_plus_minus == value)
+ return;
+ show_plus_minus = value;
+ Refresh ();
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool ShowRootLines {
+ get { return show_root_lines; }
+ set {
+ if (show_root_lines == value)
+ return;
+ show_root_lines = value;
+ Refresh ();
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool Sorted {
+ get { return sorted; }
+ set {
+ if (sorted != value)
+ sorted = value;
+ if (sorted) {
+ Nodes.Sort ();
+ top_node = null;
+ Refresh ();
+ }
+ }
+ }
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [Bindable(false)]
+ public override string Text {
+ get { return base.Text; }
+ set { base.Text = value; }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public TreeNode TopNode {
+ get { return top_node; }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int VisibleCount {
+ get {
+ return ClientRectangle.Height / ItemHeight;
+ }
+ }
+
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Properties
+ protected override CreateParams CreateParams {
+ get {
+ CreateParams cp = base.CreateParams;
+ return cp;
+ }
+ }
+
+ protected override Size DefaultSize {
+ get { return new Size (121, 97); }
+ }
+
+ #endregion // Protected Instance Properties
+
+ #region Public Instance Methods
+ public void BeginUpdate () {
+ update_stack++;
+ }
+
+ public void CollapseAll ()
+ {
+ root_node.CollapseAll ();
+ }
+
+ public void EndUpdate ()
+ {
+ if (update_stack > 1) {
+ update_stack--;
+ } else {
+ update_stack = 0;
+ if (update_needed) {
+ Invalidate (ViewportRectangle);
+ update_needed = false;
+ }
+ }
+ }
+
+ public void ExpandAll () {
+ root_node.ExpandAll ();
+ }
+
+ public TreeNode GetNodeAt (Point pt) {
+ return GetNodeAt (pt.Y);
+ }
+
+ public TreeNode GetNodeAt (int x, int y)
+ {
+ return GetNodeAt (y);
+ }
+
+ private TreeNode GetNodeAtUseX (int x, int y) {
+ TreeNode node = GetNodeAt (y);
+ if (node == null || !(IsTextArea (node, x) || full_row_select))
+ return null;
+ return node;
+
+ }
+
+ public int GetNodeCount (bool include_subtrees) {
+ return root_node.GetNodeCount (include_subtrees);
+ }
+
+ public override string ToString () {
+ int count = Nodes.Count;
+ if (count <= 0)
+ return String.Concat (base.ToString (), "Node Count: 0");
+ return String.Concat (base.ToString (), "Node Count: ", count, " Nodes[0]: ", Nodes [0]);
+
+ }
+
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected override void CreateHandle () {
+ base.CreateHandle ();
+ }
+
+ protected override void Dispose (bool disposing) {
+ if (disposing)
+ image_list = null;
+
+ base.Dispose (disposing);
+ }
+
+ protected OwnerDrawPropertyBag GetItemRenderStyles (TreeNode node, int state) {
+ return node.prop_bag;
+ }
+
+ protected override bool IsInputKey (Keys key_data) {
+
+ if ((key_data & Keys.Alt) == 0) {
+ switch (key_data & Keys.KeyCode) {
+ case Keys.Enter:
+ case Keys.Escape:
+ case Keys.Prior:
+ case Keys.Next:
+ case Keys.End:
+ case Keys.Home:
+ case Keys.Left:
+ case Keys.Up:
+ case Keys.Right:
+ case Keys.Down:
+ return true;
+ }
+ }
+ return base.IsInputKey (key_data);
+ }
+
+ protected override void OnKeyDown (KeyEventArgs e)
+ {
+ OpenTreeNodeEnumerator ne;
+
+ switch (e.KeyData & Keys.KeyCode) {
+ case Keys.Add:
+ if (selected_node != null && selected_node.IsExpanded)
+ selected_node.Expand ();
+ break;
+ case Keys.Subtract:
+ if (selected_node != null && selected_node.IsExpanded)
+ selected_node.Collapse ();
+ break;
+ case Keys.Left:
+ if (selected_node != null) {
+ if (selected_node.IsExpanded)
+ selected_node.Collapse ();
+ else {
+ ne = new OpenTreeNodeEnumerator (selected_node);
+ if (ne.MovePrevious () && ne.MovePrevious ())
+ SelectedNode = ne.CurrentNode;
+ }
+ }
+ break;
+ case Keys.Right:
+ if (selected_node != null) {
+ if (!selected_node.IsExpanded)
+ selected_node.Expand ();
+ else {
+ ne = new OpenTreeNodeEnumerator (selected_node);
+ if (ne.MoveNext () && ne.MoveNext ())
+ SelectedNode = ne.CurrentNode;
+ }
+ }
+ break;
+ case Keys.Up:
+ if (selected_node != null) {
+ ne = new OpenTreeNodeEnumerator (selected_node);
+ if (ne.MovePrevious () && ne.MovePrevious ())
+ SelectedNode = ne.CurrentNode;
+ }
+ break;
+ case Keys.Down:
+ if (selected_node != null) {
+ ne = new OpenTreeNodeEnumerator (selected_node);
+ if (ne.MoveNext () && ne.MoveNext ())
+ SelectedNode = ne.CurrentNode;
+ }
+ break;
+ case Keys.Home:
+ if (root_node.Nodes.Count > 0) {
+ ne = new OpenTreeNodeEnumerator (root_node.Nodes [0]);
+ if (ne.MoveNext ())
+ SelectedNode = ne.CurrentNode;
+ }
+ break;
+ case Keys.End:
+ if (root_node.Nodes.Count > 0) {
+ ne = new OpenTreeNodeEnumerator (root_node.Nodes [0]);
+ while (ne.MoveNext ())
+ { }
+ SelectedNode = ne.CurrentNode;
+ }
+ break;
+ case Keys.PageDown:
+ if (selected_node != null) {
+ ne = new OpenTreeNodeEnumerator (selected_node);
+ int move = ViewportRectangle.Height / ItemHeight;
+ for (int i = 0; i < move && ne.MoveNext (); i++) {
+
+ }
+ SelectedNode = ne.CurrentNode;
+ }
+ break;
+ case Keys.PageUp:
+ if (selected_node != null) {
+ ne = new OpenTreeNodeEnumerator (selected_node);
+ int move = ViewportRectangle.Height / ItemHeight;
+ for (int i = 0; i < move && ne.MovePrevious (); i++)
+ { }
+ SelectedNode = ne.CurrentNode;
+ }
+ break;
+ case Keys.Multiply:
+ if (selected_node != null)
+ selected_node.ExpandAll ();
+ break;
+ }
+ base.OnKeyDown (e);
+
+ if (!e.Handled && checkboxes &&
+ selected_node != null &&
+ (e.KeyData & Keys.KeyCode) == Keys.Space) {
+ selected_node.check_reason = TreeViewAction.ByKeyboard;
+ selected_node.Checked = !selected_node.Checked;
+ e.Handled = true;
+ }
+ }
+
+ protected override void OnKeyPress (KeyPressEventArgs e)
+ {
+ base.OnKeyPress (e);
+ if (e.KeyChar == ' ')
+ e.Handled = true;
+ }
+
+ protected override void OnKeyUp (KeyEventArgs e)
+ {
+ base.OnKeyUp (e);
+ if ((e.KeyData & Keys.KeyCode) == Keys.Space)
+ e.Handled = true;
+ }
+
+ protected virtual void OnItemDrag (ItemDragEventArgs e)
+ {
+ if (ItemDrag != null)
+ ItemDrag (this, e);
+ }
+
+ protected internal virtual void OnAfterCheck (TreeViewEventArgs e) {
+ if (on_after_check != null)
+ on_after_check (this, e);
+ }
+
+ protected internal virtual void OnAfterCollapse (TreeViewEventArgs e) {
+ if (on_after_collapse != null)
+ on_after_collapse (this, e);
+ }
+
+ protected internal virtual void OnAfterExpand (TreeViewEventArgs e) {
+ if (on_after_expand != null)
+ on_after_expand (this, e);
+ }
+
+ protected virtual void OnAfterLabelEdit (NodeLabelEditEventArgs e) {
+ if (on_after_label_edit != null)
+ on_after_label_edit (this, e);
+ }
+
+ protected virtual void OnAfterSelect (TreeViewEventArgs e) {
+ if (on_after_select != null)
+ on_after_select (this, e);
+ }
+
+ protected internal virtual void OnBeforeCheck (TreeViewCancelEventArgs e) {
+ if (on_before_check != null)
+ on_before_check (this, e);
+ }
+
+ protected internal virtual void OnBeforeCollapse (TreeViewCancelEventArgs e) {
+ if (on_before_collapse != null)
+ on_before_collapse (this, e);
+ }
+
+ protected internal virtual void OnBeforeExpand (TreeViewCancelEventArgs e) {
+ if (on_before_expand != null)
+ on_before_expand (this, e);
+ }
+
+ protected virtual void OnBeforeLabelEdit (NodeLabelEditEventArgs e) {
+ if (on_before_label_edit != null)
+ on_before_label_edit (this, e);
+ }
+
+ protected virtual void OnBeforeSelect (TreeViewCancelEventArgs e) {
+ if (on_before_select != null)
+ on_before_select (this, e);
+ }
+
+ protected override void OnHandleCreated (EventArgs e) {
+ base.OnHandleCreated (e);
+
+ vbar = new ImplicitVScrollBar ();
+ hbar = new ImplicitHScrollBar ();
+
+ vbar.Visible = false;
+ hbar.Visible = false;
+ vbar.ValueChanged += new EventHandler (VScrollBarValueChanged);
+ hbar.ValueChanged += new EventHandler (HScrollBarValueChanged);
+
+ SuspendLayout ();
+ Controls.AddImplicit (vbar);
+ Controls.AddImplicit (hbar);
+ ResumeLayout ();
+ }
+
+ protected override void OnHandleDestroyed (EventArgs e) {
+ base.OnHandleDestroyed (e);
+ }
+
+ protected override void WndProc(ref Message m) {
+ switch ((Msg) m.Msg) {
+ case Msg.WM_PAINT: {
+ PaintEventArgs paint_event;
+
+ paint_event = XplatUI.PaintEventStart (Handle, true);
+ DoPaint (paint_event);
+ XplatUI.PaintEventEnd (Handle, true);
+ return;
+ }
+ case Msg.WM_LBUTTONDBLCLK:
+ int val = m.LParam.ToInt32();
+ DoubleClickHandler (null, new
+ MouseEventArgs (MouseButtons.Left,
+ 2, val & 0xffff,
+ (val>>16) & 0xffff, 0));
+ break;
+ }
+ base.WndProc (ref m);
+ }
+
+ #endregion // Protected Instance Methods
+
+ #region Internal & Private Methods and Properties
+ internal string LabelEditText {
+ get {
+ if (edit_text_box == null)
+ return String.Empty;
+ return edit_text_box.Text;
+ }
+ }
+
+ internal IntPtr CreateNodeHandle ()
+ {
+ return (IntPtr) handle_count++;
+ }
+
+ internal TreeNode NodeFromHandle (IntPtr handle)
+ {
+ // This method is called rarely, so instead of maintaining a table
+ // we just walk the tree nodes to find the matching handle
+ return NodeFromHandleRecursive (root_node, handle);
+ }
+
+ private TreeNode NodeFromHandleRecursive (TreeNode node, IntPtr handle)
+ {
+ if (node.handle == handle)
+ return node;
+ foreach (TreeNode child in node.Nodes) {
+ TreeNode match = NodeFromHandleRecursive (child, handle);
+ if (match != null)
+ return match;
+ }
+ return null;
+ }
+
+ // TODO: we shouldn't have to compute this on the fly
+ internal Rectangle ViewportRectangle {
+ get {
+ Rectangle res = ClientRectangle;
+
+ if (vbar != null && vbar.Visible)
+ res.Width -= vbar.Width;
+ if (hbar != null && hbar.Visible)
+ res.Height -= hbar.Height;
+ return res;
+ }
+ }
+
+ private TreeNode GetNodeAt (int y)
+ {
+ if (nodes.Count <= 0)
+ return null;
+
+ if (top_node == null)
+ top_node = nodes [0];
+
+ OpenTreeNodeEnumerator o = new OpenTreeNodeEnumerator (TopNode);
+ int move = y / ItemHeight;
+ for (int i = -1; i < move; i++) {
+ if (!o.MoveNext ())
+ return null;
+ }
+
+ return o.CurrentNode;
+ }
+
+ private bool IsTextArea (TreeNode node, int x)
+ {
+ return node != null && node.Bounds.Left <= x && node.Bounds.Right >= x;
+ }
+
+ private bool IsSelectableArea (TreeNode node, int x)
+ {
+ if (node == null)
+ return false;
+ int l = node.Bounds.Left;
+ if (ImageList != null)
+ l -= ImageList.ImageSize.Width;
+ return l <= x && node.Bounds.Right >= x;
+
+ }
+
+ private bool IsPlusMinusArea (TreeNode node, int x)
+ {
+ if (node.Nodes.Count == 0 || (node.parent == root_node && !show_root_lines))
+ return false;
+
+ int l = node.Bounds.Left + 5;
+
+ if (show_root_lines || node.Parent != null)
+ l -= indent;
+ if (ImageList != null)
+ l -= ImageList.ImageSize.Width + 3;
+ if (checkboxes)
+ l -= 19;
+ return (x > l && x < l + 8);
+ }
+
+ private bool IsCheckboxArea (TreeNode node, int x)
+ {
+ int l = node.Bounds.Left + 5;
+
+ if (show_root_lines || node.Parent != null)
+ l -= indent;
+ if (ImageList != null)
+ l -= ImageList.ImageSize.Width + 3;
+ return (x > l && x < l + 10);
+ }
+
+ internal void SetTop (TreeNode node)
+ {
+ OpenTreeNodeEnumerator walk = new OpenTreeNodeEnumerator (root_node);
+ int offset = 0;
+
+ while (walk.CurrentNode != node && walk.MoveNext ())
+ offset++;
+
+ vbar.Value = offset;
+ }
+
+ internal void SetBottom (TreeNode node)
+ {
+ OpenTreeNodeEnumerator walk = new OpenTreeNodeEnumerator (node);
+
+ int bottom = ViewportRectangle.Bottom;
+ int offset = 0;
+ while (walk.MovePrevious ()) {
+ if (walk.CurrentNode.Bounds.Bottom <= bottom)
+ break;
+ offset++;
+ }
+ vbar.Value += offset;
+ }
+
+ internal void UpdateBelow (TreeNode node)
+ {
+ if (update_stack > 0) {
+ update_needed = true;
+ return;
+ }
+
+ if (node == root_node) {
+ Refresh ();
+ return;
+ }
+
+ // We need to update the current node so the plus/minus block gets update too
+ Rectangle invalid = new Rectangle (0, node.Bounds.Top - 1,
+ Width, Height - node.Bounds.Top + 1);
+ Invalidate (invalid);
+ }
+
+ internal void UpdateNode (TreeNode node)
+ {
+ if (update_stack > 0) {
+ update_needed = true;
+ return;
+ }
+
+ if (node == root_node) {
+ Refresh ();
+ return;
+ }
+
+ Rectangle invalid = new Rectangle (0, node.Bounds.Top - 1, Width,
+ node.Bounds.Height + 1);
+ Invalidate (invalid);
+ }
+
+ internal void UpdateNodePlusMinus (TreeNode node)
+ {
+ if (update_stack > 0) {
+ update_needed = true;
+ return;
+ }
+
+ int l = node.Bounds.Left + 5;
+
+ if (show_root_lines || node.Parent != null)
+ l -= indent;
+ if (ImageList != null)
+ l -= ImageList.ImageSize.Width + 3;
+ if (checkboxes)
+ l -= 19;
+
+ Invalidate (new Rectangle (l, node.Bounds.Top, 8, node.Bounds.Height));
+ }
+
+ private void DoPaint (PaintEventArgs pe)
+ {
+ if (Width <= 0 || Height <= 0 || Visible == false)
+ return;
+
+ Draw (pe.ClipRectangle, pe.Graphics);
+ }
+
+ private void Draw (Rectangle clip, Graphics dc)
+ {
+ if (top_node == null && Nodes.Count > 0)
+ top_node = nodes [0];
+
+ if (selected_node == null && Nodes.Count > 0)
+ SelectedNode = nodes [0];
+
+ // Decide if we need a scrollbar
+ int old_open_node_count = open_node_count;
+
+ //Rectangle fill = ClientRectangle;
+ add_vscroll = false;
+ add_hscroll = false;
+
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (BackColor), clip);
+
+ Color dash_color = ControlPaint.Dark (BackColor);
+ if (dash_color == BackColor)
+ dash_color = ControlPaint.Light (BackColor);
+ dash = new Pen (dash_color, 1);
+ dash.DashStyle = DashStyle.Dot;
+
+ int depth = 0;
+ int item_height = ItemHeight;
+ int height = ClientRectangle.Height;
+
+ open_node_count = 0;
+ used_height = 0;
+ foreach (TreeNode node in nodes) {
+ DrawNode (node, dc, clip, ref depth, item_height, height);
+ depth = 0;
+ }
+
+ add_vscroll = (open_node_count * ItemHeight) > ClientRectangle.Height;
+
+ if (max_node_width > ClientRectangle.Width)
+ add_hscroll = true;
+
+ if (add_vscroll)
+ add_hscroll = max_node_width > ClientRectangle.Width - ThemeEngine.Current.VScrollBarDefaultSize.Width;
+ if (add_hscroll)
+ add_vscroll = (open_node_count * ItemHeight) > ClientRectangle.Height - ThemeEngine.Current.HScrollBarDefaultSize.Height;
+
+ if (add_hscroll) {
+ AddHorizontalScrollBar ();
+ } else if (hbar != null) {
+ hbar_offset = 0;
+ hbar.Visible = false;
+ }
+
+ if (add_vscroll) {
+ AddVerticalScrollBar (open_node_count, old_open_node_count != open_node_count);
+ } else if (vbar != null) {
+ vbar.Visible = false;
+ skipped_nodes = 0;
+ }
+
+ if (add_hscroll && add_vscroll) {
+ Rectangle corner = new Rectangle (hbar.Right, vbar.Bottom, vbar.Width, hbar.Height);
+ if (clip.IntersectsWith (corner))
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ThemeEngine.Current.ColorControl), corner);
+ }
+ }
+
+ private void DrawNodePlusMinus (TreeNode node, Graphics dc, int x, int middle)
+ {
+ dc.DrawRectangle (SystemPens.ControlDark, x, middle - 4, 8, 8);
+
+ if (node.IsExpanded) {
+ dc.DrawLine (SystemPens.ControlDarkDark, x + 2, middle, x + 6, middle);
+ } else {
+ dc.DrawLine (SystemPens.ControlDarkDark, x + 2, middle, x + 6, middle);
+ dc.DrawLine (SystemPens.ControlDarkDark, x + 4, middle - 2, x + 4, middle + 2);
+ }
+ }
+
+ private void DrawNodeCheckBox (TreeNode node, Graphics dc, int x, int middle)
+ {
+ using(Pen pen = new Pen (Color.Black, 2) )
+ dc.DrawRectangle (pen, x+ 3, middle - 4, 11, 11);
+
+ if (node.Checked) {
+ using(Pen check_pen = new Pen (Color.Black, 1)) {
+ dc.DrawLine (check_pen, x + 6, middle + 0, x + 8, middle + 3);
+ dc.DrawLine (check_pen, x + 6, middle + 1, x + 8, middle + 4);
+
+ dc.DrawLine (check_pen, x + 7, middle + 3, x + 13, middle - 2);
+ dc.DrawLine (check_pen, x + 7, middle + 4, x + 13, middle - 1);
+ }
+ }
+ }
+
+ private void DrawNodeLines (TreeNode node, Graphics dc, bool visible, Pen dash, int x, int y,
+ int middle, int item_height, int node_count)
+ {
+ int ladjust = 9; // left adjust
+ int radjust = 0; // right adjust
+
+ if (node_count > 0 && show_plus_minus)
+ ladjust = 13;
+ if (checkboxes)
+ radjust = 3;
+
+ dc.DrawLine (dash, x - indent + ladjust, middle, x + radjust, middle);
+
+ //if (!visible)
+ // return;
+
+ int ly = 0;
+ if (node.PrevNode != null) {
+ int prevadjust = (node.Nodes.Count > 0 && show_plus_minus ? (node.PrevNode.Nodes.Count == 0 ? 0 : 4) :
+ (node.PrevNode.Nodes.Count == 0 ? 0 : 4));
+ int myadjust = (node.Nodes.Count > 0 && show_plus_minus ? 4 : 0);
+ ly = node.PrevNode.Bounds.Bottom - (item_height / 2) + prevadjust;
+ dc.DrawLine (dash, x - indent + 9, middle - myadjust, x - indent + 9, ly);
+ } else if (node.Parent != null) {
+ int myadjust = (node.Nodes.Count > 0 && show_plus_minus ? 4 : 0);
+ ly = node.Parent.Bounds.Bottom + 1;
+ dc.DrawLine (dash, x - indent + 9, middle - myadjust, x - indent + 9, ly);
+ }
+ }
+
+ private void DrawNodeImage (TreeNode node, Graphics dc, Rectangle clip, int x, int y)
+ {
+ // Rectangle r = new Rectangle (x, y + 2, ImageList.ImageSize.Width, ImageList.ImageSize.Height);
+
+ if (!RectsIntersect (clip, x, y + 2, ImageList.ImageSize.Width, ImageList.ImageSize.Height))
+ return;
+
+ if (node.ImageIndex > -1 && ImageList != null && node.ImageIndex < ImageList.Images.Count) {
+ ImageList.Draw (dc, x, y + 2, ImageList.ImageSize.Width,
+ ImageList.ImageSize.Height, node.ImageIndex);
+ } else if (ImageIndex > -1 && ImageList != null && ImageIndex < ImageList.Images.Count) {
+ ImageList.Draw (dc, x, y + 2, ImageList.ImageSize.Width,
+ ImageList.ImageSize.Height, ImageIndex);
+ }
+ }
+
+ private void DrawEditNode (TreeNode node)
+ {
+ SuspendLayout ();
+
+ if (edit_text_box == null) {
+ edit_text_box = new FixedSizeTextBox ();
+ edit_text_box.BorderStyle = BorderStyle.FixedSingle;
+ edit_text_box.KeyUp += new KeyEventHandler (EditTextBoxKeyDown);
+ edit_text_box.Leave += new EventHandler (EditTextBoxLeave);
+ Controls.AddImplicit (edit_text_box);
+ }
+
+ edit_text_box.Bounds = node.Bounds;
+ edit_text_box.Width += 4;
+
+ edit_text_box.Text = node.Text;
+ edit_text_box.Visible = true;
+ edit_text_box.Focus ();
+ edit_text_box.SelectAll ();
+
+ ResumeLayout ();
+ }
+
+ private void EditTextBoxKeyDown (object sender, KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.Return)
+ EndEdit ();
+ }
+
+ private void EditTextBoxLeave (object sender, EventArgs e)
+ {
+ EndEdit ();
+ }
+
+ private void EndEdit ()
+ {
+ edit_text_box.Visible = false;
+ edit_node.EndEdit (false);
+ UpdateNode(edit_node);
+ }
+
+ private void UpdateNodeBounds (TreeNode node, int x, int y, int item_height, Graphics dc)
+ {
+ Font font = node.NodeFont;
+ if (node.NodeFont == null)
+ font = Font;
+
+ if (node.NeedsWidth || update_node_bounds)
+ node.SetWidth ((int) dc.MeasureString (node.Text, font, 0,
+ string_format).Width + 3);
+ node.SetHeight (item_height);
+ node.SetPosition (x, y);
+ }
+
+ private void DrawSelectionAndFocus(TreeNode node, Graphics dc, Rectangle r)
+ {
+ if (Focused && focused_node == node) {
+ ControlPaint.DrawFocusRectangle (dc, r, ForeColor, BackColor);
+ }
+ r.Inflate(-1, -1);
+ if ((!HideSelection || Focused) && SelectedNode == node)
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ThemeEngine.Current.ColorHighlight), r);
+ else
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (node.BackColor), r);
+ }
+
+ private void DrawStaticNode (TreeNode node, Graphics dc)
+ {
+ if (!full_row_select)
+ DrawSelectionAndFocus(node, dc, node.Bounds);
+
+ Font font = node.NodeFont;
+ if (node.NodeFont == null)
+ font = Font;
+ Color text_color = ((Focused || !HideSelection) && SelectedNode == node ?
+ ThemeEngine.Current.ColorHighlightText : node.ForeColor);
+ dc.DrawString (node.Text, font,
+ ThemeEngine.Current.ResPool.GetSolidBrush (text_color),
+ node.Bounds, string_format);
+ }
+
+ private void DrawNode (TreeNode node, Graphics dc, Rectangle clip, ref int depth, int item_height, int max_height)
+ {
+ open_node_count++;
+ int x = (!show_root_lines && node.Parent != null ? depth - 1 : depth) * indent - hbar_offset;
+ int y = item_height * (open_node_count - skipped_nodes - 1);
+ bool visible = (y >= 0 && y < max_height);
+ int _n_count = node.nodes.Count;
+ int middle = y + (item_height / 2);
+
+ // The thing is totally out of the clipping rectangle
+ if (clip.Top > y + ItemHeight || clip.Bottom < y)
+ visible = false;
+
+ if (visible && full_row_select) {
+ Rectangle r = new Rectangle(1, y+2, ViewportRectangle.Width-2, item_height);
+ DrawSelectionAndFocus(node, dc, r);
+ }
+
+ if (show_root_lines || node.Parent != null) {
+ x += 5;
+ if (_n_count > 0) {
+ if (show_plus_minus && visible) {
+ DrawNodePlusMinus (node, dc, x, middle);
+ }
+ }
+ x += indent - 5;
+ }
+
+ int ox = x;
+
+ if (checkboxes) {
+ if (visible)
+ DrawNodeCheckBox (node, dc, ox, middle);
+ ox += 19;
+ }
+
+ if (show_lines)
+ DrawNodeLines (node, dc, visible, dash, x, y, middle, item_height, _n_count);
+
+ if (ImageList != null) {
+ if (visible)
+ DrawNodeImage (node, dc, clip, ox, y);
+ // MS leaves the space for the image if the ImageList is
+ // non null regardless of whether or not an image is drawn
+ ox += ImageList.ImageSize.Width + 3; // leave a little space so the text isn't against the image
+ }
+
+ UpdateNodeBounds (node, ox, y, item_height, dc);
+
+ bool bounds_in_clip = clip.IntersectsWith (node.Bounds) || full_row_select;
+ if (visible && bounds_in_clip) {
+ if (node.IsEditing)
+ DrawEditNode (node);
+ else
+ DrawStaticNode (node, dc);
+ }
+
+ if (node.Bounds.Right > max_node_width) {
+ max_node_width = node.Bounds.Right;
+ if (max_node_width > ClientRectangle.Width && !add_hscroll) {
+ max_height -= ItemHeight;
+ add_hscroll = true;
+ }
+ }
+
+ if (node.Bounds.Bottom > used_height)
+ used_height = node.Bounds.Bottom;
+
+ depth++;
+ if (node.IsExpanded) {
+ for (int i = 0; i < _n_count; i++) {
+ int tdepth = depth;
+ DrawNode (node.nodes [i], dc, clip, ref tdepth, item_height, max_height);
+ }
+ }
+
+ }
+
+ private void AddVerticalScrollBar (int total_nodes, bool count_changed)
+ {
+ vbar.Bounds = new Rectangle (ClientRectangle.Width - vbar.Width,
+ 0, vbar.Width, (add_hscroll ? Height - ThemeEngine.Current.HScrollBarDefaultSize.Height : Height));
+
+ if (count_changed) {
+ vbar.Maximum = total_nodes;
+ int height = ClientRectangle.Height;
+ vbar.LargeChange = height / ItemHeight;
+ }
+
+ vbar.Visible = true;
+ }
+
+ private void AddHorizontalScrollBar ()
+ {
+ hbar.Bounds = new Rectangle (ClientRectangle.Left,
+ ClientRectangle.Bottom - hbar.Height,
+ (add_vscroll ? Width - ThemeEngine.Current.VScrollBarDefaultSize.Width : Width), hbar.Height);
+
+ int width = ClientRectangle.Width;
+ if (vbar.Visible)
+ width -= vbar.Width;
+
+ hbar.SmallChange = 15;
+ hbar.LargeChange = 50;
+ int num_pixels = max_node_width - width;
+ hbar.Maximum = num_pixels + 50;
+ hbar.Visible = true;
+ }
+
+ private void SizeChangedHandler (object sender, EventArgs e)
+ {
+ SuspendLayout ();
+
+ if (max_node_width > ClientRectangle.Width && ClientRectangle.Width >= 0) {
+ add_hscroll = true;
+ AddHorizontalScrollBar ();
+ return;
+ }
+
+ if (used_height > ClientRectangle.Height && ClientRectangle.Height >= 0) {
+ add_vscroll = true;
+ AddVerticalScrollBar (open_node_count, true);
+ return;
+ }
+
+ if (vbar != null && vbar.Visible) {
+ int height = (hbar != null && hbar.Visible ? Height - hbar.Height : Height);
+ vbar.SetBounds (Right - vbar.Width, 0, 0, height, BoundsSpecified.X | BoundsSpecified.Height);
+ }
+
+ if (hbar != null && hbar.Visible) {
+ int width = (vbar != null && vbar.Visible ? Width - vbar.Width : Width);
+ hbar.SetBounds (0, Bottom - hbar.Height, width, 0, BoundsSpecified.Y | BoundsSpecified.Width);
+ }
+
+ ResumeLayout ();
+ }
+
+ private void VScrollBarValueChanged (object sender, EventArgs e)
+ {
+ SetVScrollPos (vbar.Value, null);
+ }
+
+ private void SetVScrollPos (int pos, TreeNode new_top)
+ {
+ if (pos < 0)
+ pos = 0;
+
+ if (skipped_nodes == pos)
+ return;
+
+ int old_skip = skipped_nodes;
+ skipped_nodes = pos;
+ int diff = old_skip - skipped_nodes;
+
+ // Determine the new top node if we have to
+ if (new_top == null) {
+ if (top_node == null)
+ top_node = nodes [0];
+
+ OpenTreeNodeEnumerator walk = new OpenTreeNodeEnumerator (TopNode);
+ if (diff < 0) {
+ for (int i = diff; i <= 0; i++)
+ walk.MoveNext ();
+ new_top = walk.CurrentNode;
+ } else {
+ for (int i = 0; i <= diff; i++)
+ walk.MovePrevious ();
+ new_top = walk.CurrentNode;
+ }
+ }
+
+ top_node = new_top;
+ int y_move = diff * ItemHeight;
+ XplatUI.ScrollWindow (Handle, ViewportRectangle, 0, y_move, false);
+ }
+
+ private void HScrollBarValueChanged(object sender, EventArgs e)
+ {
+ int old_offset = hbar_offset;
+ hbar_offset = hbar.Value;
+
+ if (hbar_offset < 0)
+ hbar_offset = 0;
+
+ XplatUI.ScrollWindow (Handle, ViewportRectangle, old_offset - hbar_offset, 0, false);
+ }
+
+ private void MouseWheelHandler(object sender, MouseEventArgs e) {
+ if (vbar == null || !vbar.Visible) {
+ return;
+ }
+
+ if (e.Delta < 0) {
+ vbar.Value = Math.Min(vbar.Value + SystemInformation.MouseWheelScrollLines, vbar.Maximum);
+ } else {
+ vbar.Value = Math.Max(0, vbar.Value - SystemInformation.MouseWheelScrollLines);
+ }
+ }
+
+ private void FontChangedHandler (object sender, EventArgs e)
+ {
+ update_node_bounds = true;
+ }
+
+ private void FocusChangedHandler (object sender, EventArgs e)
+ {
+ if (selected_node != null)
+ UpdateNode (selected_node);
+ }
+
+ private void MouseDownHandler (object sender, MouseEventArgs e)
+ {
+ TreeNode node = GetNodeAt (e.Y);
+ if (node == null)
+ return;
+
+ if (show_plus_minus && IsPlusMinusArea (node, e.X)) {
+ node.Toggle ();
+ return;
+ } else if (checkboxes && IsCheckboxArea (node, e.X)) {
+ node.check_reason = TreeViewAction.ByMouse;
+ node.Checked = !node.Checked;
+ UpdateNode(node);
+ return;
+ } else if (IsSelectableArea (node, e.X) || full_row_select) {
+ TreeNode old_selected = selected_node;
+ SelectedNode = node;
+ if (label_edit && e.Clicks == 1 && selected_node == old_selected) {
+ node.BeginEdit ();
+ if (edit_node != null) {
+ edit_node.EndEdit (false);
+ UpdateNode (edit_node);
+ }
+ edit_node = node;
+ UpdateNode (edit_node);
+ } else if (selected_node != focused_node) {
+ select_mmove = true;
+ }
+ }
+ }
+
+ private void MouseUpHandler (object sender, MouseEventArgs e) {
+
+ drag_begin_x = -1;
+ drag_begin_y = -1;
+
+ OnClick (EventArgs.Empty);
+
+ if (!select_mmove)
+ return;
+
+ select_mmove = false;
+
+ TreeViewCancelEventArgs ce = new TreeViewCancelEventArgs (selected_node, false, TreeViewAction.ByMouse);
+ OnBeforeSelect (ce);
+
+ Rectangle invalid;
+ if (!ce.Cancel) {
+ if (focused_node != null) {
+ invalid = Rectangle.Union (Bloat (focused_node.Bounds),
+ Bloat (selected_node.Bounds));
+ } else {
+ invalid = Bloat (selected_node.Bounds);
+ }
+ focused_node = selected_node;
+ OnAfterSelect (new TreeViewEventArgs (selected_node, TreeViewAction.ByMouse));
+
+ Invalidate (invalid);
+ } else {
+ selected_node = focused_node;
+ }
+
+
+ }
+
+ private void MouseMoveHandler (object sender, MouseEventArgs e) {
+
+ if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right) {
+ if (drag_begin_x == -1 && drag_begin_y == -1) {
+ drag_begin_x = e.X;
+ drag_begin_y = e.Y;
+ } else {
+ double rise = Math.Pow (drag_begin_x - e.X, 2);
+ double run = Math.Pow (drag_begin_y - e.Y, 2);
+ double move = Math.Sqrt (rise + run);
+ if (move > 3) {
+ TreeNode drag = GetNodeAtUseX (e.X, e.Y);
+
+ if (drag != null) {
+ OnItemDrag (new ItemDragEventArgs (e.Button, drag));
+ }
+ drag_begin_x = -1;
+ drag_begin_y = -1;
+ }
+ }
+
+ }
+ if(!select_mmove)
+ return;
+ TreeNode node = GetNodeAtUseX (e.X,e.Y);
+ if(node == selected_node)
+ return;
+
+ selected_node = focused_node;
+ select_mmove = false;
+ Refresh();
+ }
+
+ private void DoubleClickHandler (object sender, MouseEventArgs e) {
+ TreeNode node = GetNodeAtUseX (e.X,e.Y);
+ if(node != null) {
+ node.Toggle();
+ }
+ }
+
+
+ private bool RectsIntersect (Rectangle r, int left, int top, int width, int height)
+ {
+ return !((r.Left > left + width) || (r.Right < left) ||
+ (r.Top > top + height) || (r.Bottom < top));
+ }
+
+ #endregion // Internal & Private Methods and Properties
+
+ #region Events
+ public event ItemDragEventHandler ItemDrag;
+
+ public event TreeViewEventHandler AfterCheck {
+ add { on_after_check += value; }
+ remove { on_after_check -= value; }
+ }
+
+ public event TreeViewEventHandler AfterCollapse {
+ add { on_after_collapse += value; }
+ remove { on_after_collapse -= value; }
+ }
+
+ public event TreeViewEventHandler AfterExpand {
+ add { on_after_expand += value; }
+ remove { on_after_expand -= value; }
+ }
+
+ public event NodeLabelEditEventHandler AfterLabelEdit {
+ add { on_after_label_edit += value; }
+ remove { on_after_label_edit -= value; }
+ }
+
+ public event TreeViewEventHandler AfterSelect {
+ add { on_after_select += value; }
+ remove { on_after_select -= value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public event EventHandler BackgroundImageChanged {
+ add { base.BackgroundImageChanged += value; }
+ remove { base.BackgroundImageChanged -= value; }
+ }
+
+ public event TreeViewCancelEventHandler BeforeCheck {
+ add { on_before_check += value; }
+ remove { on_before_check -= value; }
+ }
+
+ public event TreeViewCancelEventHandler BeforeCollapse {
+ add { on_before_collapse += value; }
+ remove { on_before_collapse -= value; }
+ }
+
+ public event TreeViewCancelEventHandler BeforeExpand {
+ add { on_before_expand += value; }
+ remove { on_before_expand -= value; }
+ }
+
+ public event NodeLabelEditEventHandler BeforeLabelEdit {
+ add { on_before_label_edit += value; }
+ remove { on_before_label_edit -= value; }
+ }
+
+ public event TreeViewCancelEventHandler BeforeSelect {
+ add { on_before_select += value; }
+ remove { on_before_select -= value; }
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Browsable (false)]
+ public new event PaintEventHandler Paint {
+ add { base.Paint += value; }
+ remove { base.Paint -= value; }
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Browsable (false)]
+ public new event EventHandler TextChanged {
+ add { base.TextChanged += value; }
+ remove { base.TextChanged -= value; }
+ }
+ #endregion // Events
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewAction.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewAction.cs
new file mode 100644
index 00000000000..66ffb6f8c97
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewAction.cs
@@ -0,0 +1,35 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+namespace System.Windows.Forms {
+
+ public enum TreeViewAction {
+ Unknown,
+ ByKeyboard,
+ ByMouse,
+ Collapse,
+ Expand
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewCancelEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewCancelEventArgs.cs
new file mode 100644
index 00000000000..c87b8337534
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewCancelEventArgs.cs
@@ -0,0 +1,52 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+using System;
+using System.ComponentModel;
+
+
+namespace System.Windows.Forms {
+
+ public class TreeViewCancelEventArgs : CancelEventArgs {
+
+ private TreeNode node;
+ private TreeViewAction action;
+
+ public TreeViewCancelEventArgs (TreeNode node, bool cancel, TreeViewAction action) : base (cancel)
+ {
+ this.node = node;
+ this.action = action;
+ }
+
+ public TreeNode Node {
+ get { return node; }
+ }
+
+ public TreeViewAction Action {
+ get { return action; }
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewCancelEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewCancelEventHandler.cs
new file mode 100644
index 00000000000..b3be92c1d33
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewCancelEventHandler.cs
@@ -0,0 +1,31 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+namespace System.Windows.Forms {
+
+ public delegate void TreeViewCancelEventHandler (object sender, TreeViewCancelEventArgs e);
+
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewEventArgs.cs
new file mode 100644
index 00000000000..0c89a6c958c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewEventArgs.cs
@@ -0,0 +1,51 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+namespace System.Windows.Forms {
+
+ public class TreeViewEventArgs : EventArgs {
+
+ private TreeNode node;
+ private TreeViewAction action;
+
+ public TreeViewEventArgs (TreeNode node)
+ {
+ this.node = node;
+ }
+
+ public TreeViewEventArgs (TreeNode node, TreeViewAction action) : this (node)
+ {
+ this.action = action;
+ }
+
+ public TreeViewAction Action {
+ get { return action; }
+ }
+
+ public TreeNode Node {
+ get { return node; }
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewEventHandler.cs
new file mode 100644
index 00000000000..99447d20251
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewEventHandler.cs
@@ -0,0 +1,30 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+namespace System.Windows.Forms {
+
+ public delegate void TreeViewEventHandler (object sender, TreeViewEventArgs e);
+
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewImageIndexConverter.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewImageIndexConverter.cs
new file mode 100644
index 00000000000..669fd4e2701
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewImageIndexConverter.cs
@@ -0,0 +1,45 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+
+
+using System;
+using System.Drawing;
+using System.Collections;
+
+
+namespace System.Windows.Forms {
+
+ public class TreeViewImageIndexConverter : ImageIndexConverter {
+
+ public TreeViewImageIndexConverter ()
+ {
+ }
+
+ protected override bool IncludeNoneAsStandardValue {
+ get { return false; }
+ }
+ }
+
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UICues.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UICues.cs
new file mode 100644
index 00000000000..8320367cac8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UICues.cs
@@ -0,0 +1,41 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+
+ [Flags]
+ public enum UICues {
+ None = 0x00000000,
+ ShowFocus = 0x00000001,
+ ShowKeyboard = 0x00000002,
+ Shown = 0x00000003,
+ ChangeFocus = 0x00000004,
+ ChangeKeyboard = 0x00000008,
+ Changed = 0x0000000C
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UICuesEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UICuesEventArgs.cs
new file mode 100644
index 00000000000..95ce41bf2e5
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UICuesEventArgs.cs
@@ -0,0 +1,87 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public class UICuesEventArgs : EventArgs {
+ private UICues cues;
+
+ #region Public Constructors
+ public UICuesEventArgs(UICues uicues) {
+ this.cues = uicues;
+ }
+ #endregion
+
+ #region Public Instance Properties
+ public UICues Changed {
+ get {
+ return (cues & UICues.Changed);
+ }
+ }
+
+ public bool ChangeFocus {
+ get {
+ if ((cues & UICues.ChangeFocus)==0) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ }
+
+ public bool ChangeKeyboard {
+ get {
+ if ((cues & UICues.ChangeKeyboard)==0) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ }
+
+ public bool ShowFocus {
+ get {
+ if ((cues & UICues.ShowFocus)==0) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ }
+
+ public bool ShowKeyboard {
+ get {
+ if ((cues & UICues.ShowKeyboard)==0) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UICuesEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UICuesEventHandler.cs
new file mode 100644
index 00000000000..0e6e424a306
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UICuesEventHandler.cs
@@ -0,0 +1,32 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void UICuesEventHandler (Object Sender, UICuesEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UpDownBase.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UpDownBase.cs
new file mode 100644
index 00000000000..8a14265d24e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UpDownBase.cs
@@ -0,0 +1,691 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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.
+//
+// Authors:
+// Jonathan Gilbert <logic@deltaq.org>
+//
+// Integration into MWF:
+// Peter Bartok <pbartok@novell.com>
+//
+
+// COMPLETE
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+
+namespace System.Windows.Forms
+{
+ [Designer("System.Windows.Forms.Design.UpDownBaseDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ public abstract class UpDownBase : System.Windows.Forms.ContainerControl {
+ #region UpDownSpinner Sub-class
+ internal sealed class UpDownSpinner : Control {
+ #region Local Variables
+ private const int InitialRepeatDelay = 50;
+ private UpDownBase owner;
+ private Timer tmrRepeat;
+ private Rectangle top_button_rect;
+ private Rectangle bottom_button_rect;
+ private int mouse_pressed;
+ private int mouse_x;
+ private int mouse_y;
+ private int repeat_delay;
+ private int repeat_counter;
+ #endregion // Local Variables
+
+ #region Constructors
+ public UpDownSpinner(UpDownBase owner) {
+ this.owner = owner;
+
+ mouse_pressed = 0;
+
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ this.SetStyle(ControlStyles.DoubleBuffer, true);
+ this.SetStyle(ControlStyles.Opaque, true);
+ this.SetStyle(ControlStyles.ResizeRedraw, true);
+ this.SetStyle(ControlStyles.UserPaint, true);
+ this.SetStyle(ControlStyles.Selectable, false);
+
+ tmrRepeat = new Timer();
+
+ tmrRepeat.Enabled = false;
+ tmrRepeat.Interval = 10;
+ tmrRepeat.Tick += new EventHandler(tmrRepeat_Tick);
+
+ compute_rects();
+ }
+ #endregion // Constructors
+
+ #region Private & Internal Methods
+ private void compute_rects() {
+ int top_button_height;
+ int bottom_button_height;
+
+ top_button_height = ClientSize.Height / 2;
+ bottom_button_height = ClientSize.Height - top_button_height;
+
+ top_button_rect = new Rectangle(0, 0, ClientSize.Width, top_button_height);
+ bottom_button_rect = new Rectangle(0, top_button_height, ClientSize.Width, bottom_button_height);
+ }
+
+ private void redraw(Graphics graphics) {
+ ButtonState top_button_state;
+ ButtonState bottom_button_state;
+
+ top_button_state = bottom_button_state = ButtonState.Normal;
+
+ if (mouse_pressed != 0) {
+ if ((mouse_pressed == 1) && top_button_rect.Contains(mouse_x, mouse_y)) {
+ top_button_state = ButtonState.Pushed;
+ }
+
+ if ((mouse_pressed == 2) && bottom_button_rect.Contains(mouse_x, mouse_y)) {
+ bottom_button_state = ButtonState.Pushed;
+ }
+ }
+
+ ControlPaint.DrawScrollButton(graphics, top_button_rect, ScrollButton.Up, top_button_state);
+ ControlPaint.DrawScrollButton(graphics, bottom_button_rect, ScrollButton.Down, bottom_button_state);
+ }
+
+ private void tmrRepeat_Tick(object sender, EventArgs e) {
+ if (repeat_delay > 1) {
+ repeat_counter++;
+
+ if (repeat_counter < repeat_delay) {
+ return;
+ }
+
+ repeat_counter = 0;
+ repeat_delay = (repeat_delay * 3 / 4);
+ }
+
+ if (mouse_pressed == 0) {
+ tmrRepeat.Enabled = false;
+ }
+
+ if ((mouse_pressed == 1) && top_button_rect.Contains(mouse_x, mouse_y)) {
+ owner.UpButton();
+ }
+
+ if ((mouse_pressed == 2) && bottom_button_rect.Contains(mouse_x, mouse_y)) {
+ owner.DownButton();
+ }
+ }
+ #endregion // Private & Internal Methods
+
+ #region Protected Instance Methods
+ protected override void OnMouseDown(MouseEventArgs e) {
+ this.Select(owner.txtView);
+
+ if (e.Button != MouseButtons.Left) {
+ return;
+ }
+
+ if (top_button_rect.Contains(e.X, e.Y)) {
+ mouse_pressed = 1;
+ owner.UpButton();
+ } else if (bottom_button_rect.Contains(e.X, e.Y)) {
+ mouse_pressed = 2;
+ owner.DownButton();
+ }
+
+ mouse_x = e.X;
+ mouse_y = e.Y;
+ Capture = true;
+
+ tmrRepeat.Enabled = true;
+ repeat_counter = 0;
+ repeat_delay = InitialRepeatDelay;
+
+ using (Graphics g = CreateGraphics()) {
+ redraw(g);
+ }
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e) {
+ ButtonState before, after;
+
+ before = ButtonState.Normal;
+ if ((mouse_pressed == 1) && top_button_rect.Contains(mouse_x, mouse_y))
+ before = ButtonState.Pushed;
+ if ((mouse_pressed == 2) && bottom_button_rect.Contains(mouse_x, mouse_y))
+ before = ButtonState.Pushed;
+
+ mouse_x = e.X;
+ mouse_y = e.Y;
+
+ after = ButtonState.Normal;
+ if ((mouse_pressed == 1) && top_button_rect.Contains(mouse_x, mouse_y))
+ after = ButtonState.Pushed;
+ if ((mouse_pressed == 2) && bottom_button_rect.Contains(mouse_x, mouse_y))
+ after = ButtonState.Pushed;
+
+ if (before != after) {
+ if (after == ButtonState.Pushed) {
+ tmrRepeat.Enabled = true;
+ repeat_counter = 0;
+ repeat_delay = InitialRepeatDelay;
+
+ // fire off one right now too for good luck
+ if (mouse_pressed == 1)
+ owner.UpButton();
+ if (mouse_pressed == 2)
+ owner.DownButton();
+ }
+ else
+ tmrRepeat.Enabled = false;
+
+ using (Graphics g = CreateGraphics()) {
+ redraw(g);
+ }
+ }
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e) {
+ mouse_pressed = 0;
+ Capture = false;
+
+ using (Graphics g = CreateGraphics()) {
+ redraw(g);
+ }
+ }
+
+ protected override void OnMouseWheel(MouseEventArgs e) {
+ if (e.Delta > 0)
+ owner.UpButton();
+ else if (e.Delta < 0)
+ owner.DownButton();
+ }
+
+ protected override void OnPaint(PaintEventArgs e) {
+ redraw(e.Graphics);
+ }
+
+ protected override void OnResize(EventArgs e) {
+ base.OnResize(e);
+ compute_rects();
+ }
+ #endregion // Protected Instance Methods
+ }
+ #endregion // UpDownSpinner Sub-class
+
+ #region Local Variables
+ internal TextBox txtView;
+ private UpDownSpinner spnSpinner;
+ private bool _InterceptArrowKeys = true;
+ private LeftRightAlignment _UpDownAlign;
+ private bool changing_text;
+ private bool user_edit;
+ #endregion // Local Variables
+
+ #region Public Constructors
+ public UpDownBase() {
+ _UpDownAlign = LeftRightAlignment.Right;
+ border_style = BorderStyle.Fixed3D;
+
+ spnSpinner = new UpDownSpinner(this);
+
+ txtView = new FixedSizeTextBox();
+ txtView.ModifiedChanged += new EventHandler(OnChanged);
+ txtView.AcceptsReturn = true;
+ txtView.AutoSize = false;
+ txtView.BorderStyle = BorderStyle.None;
+ txtView.Location = new System.Drawing.Point(17, 17);
+ txtView.TabIndex = TabIndex;
+
+ SuspendLayout ();
+ Controls.AddImplicit (txtView);
+ Controls.AddImplicit (spnSpinner);
+ ResumeLayout ();
+
+ this.ActiveControl = txtView;
+
+ Height = PreferredHeight;
+ base.BackColor = txtView.BackColor;
+
+ GotFocus += new EventHandler (GotFocusHandler);
+ TabIndexChanged += new EventHandler (TabIndexChangedHandler);
+
+ txtView.MouseWheel += new MouseEventHandler(txtView_MouseWheel);
+ txtView.KeyDown += new KeyEventHandler(OnTextBoxKeyDown);
+ txtView.KeyPress += new KeyPressEventHandler(OnTextBoxKeyPress);
+ txtView.LostFocus += new EventHandler(OnTextBoxLostFocus);
+ txtView.Resize += new EventHandler(OnTextBoxResize);
+ txtView.TextChanged += new EventHandler(OnTextBoxTextChanged);
+
+ txtView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ this.Paint +=new PaintEventHandler(UpDownBase_Paint);
+
+ SetStyle(ControlStyles.FixedHeight, true);
+
+ UpdateEditText();
+ }
+ #endregion
+
+ #region Private Methods
+ void reseat_controls() {
+ int text_displacement = 0;
+
+ int spinner_width = 16;
+ //int spinner_width = ClientSize.Height;
+
+ if (_UpDownAlign == LeftRightAlignment.Left) {
+ spnSpinner.Bounds = new Rectangle(0, 0, spinner_width, ClientSize.Height);
+ text_displacement = spnSpinner.Width;
+
+ spnSpinner.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
+ } else {
+ spnSpinner.Bounds = new Rectangle(ClientSize.Width - spinner_width, 0, spinner_width, ClientSize.Height);
+
+ spnSpinner.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
+ }
+
+ txtView.Bounds = new Rectangle(text_displacement, 0, ClientSize.Width - spinner_width, Height);
+ }
+
+ private void txtView_MouseWheel(object sender, MouseEventArgs e) {
+ if (e.Delta > 0) {
+ UpButton();
+ } else if (e.Delta < 0) {
+ DownButton();
+ }
+ }
+
+ private void GotFocusHandler (object sender, EventArgs e)
+ {
+ txtView.Focus ();
+ }
+
+ private void TabIndexChangedHandler (object sender, EventArgs e)
+ {
+ txtView.TabIndex = TabIndex;
+ }
+
+ private void UpDownBase_Paint(object sender, PaintEventArgs e) {
+ e.Graphics.FillRectangle(ThemeEngine.Current.ResPool.GetSolidBrush(BackColor), ClientRectangle);
+ }
+ #endregion // Private Methods
+
+ #region Public Instance Properties
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool AutoScroll {
+ get {
+ return base.AutoScroll;
+ }
+
+ set {
+ base.AutoScroll = value;
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Size AutoScrollMargin {
+ get {
+ return base.AutoScrollMargin;
+ }
+
+ set {
+ base.AutoScrollMargin = value;
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Size AutoScrollMinSize {
+ get {
+ return base.AutoScrollMinSize;
+ }
+
+ set {
+ base.AutoScrollMinSize = value;
+ }
+ }
+
+ public override Color BackColor {
+ get {
+ return base.BackColor;
+ }
+
+ set {
+ base.BackColor = value;
+ txtView.BackColor = value;
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Image BackgroundImage {
+ get {
+ return base.BackgroundImage;
+ }
+ set {
+ base.BackgroundImage = value;
+ txtView.BackgroundImage = value;
+ }
+ }
+
+
+ [DefaultValue(BorderStyle.Fixed3D)]
+ [DispId(-504)]
+ public BorderStyle BorderStyle {
+ get { return InternalBorderStyle; }
+ set { InternalBorderStyle = value; }
+ }
+
+ public override ContextMenu ContextMenu {
+ get {
+ return base.ContextMenu;
+ }
+ set {
+ base.ContextMenu = value;
+ txtView.ContextMenu = value;
+ spnSpinner.ContextMenu = value;
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public DockPaddingEdges DockPadding {
+ get {
+ return base.DockPadding;
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public override bool Focused {
+ get {
+ return txtView.Focused;
+ }
+ }
+
+ public override Color ForeColor {
+ get {
+ return base.ForeColor;
+ }
+ set {
+ base.ForeColor = value;
+ txtView.ForeColor = value;
+ }
+ }
+
+ [DefaultValue(true)]
+ public bool InterceptArrowKeys {
+ get {
+ return _InterceptArrowKeys;
+ }
+ set {
+ _InterceptArrowKeys = value;
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public int PreferredHeight {
+ get {
+ // For some reason, the TextBox's PreferredHeight does not
+ // change when the Font property is assigned. Without a
+ // border, it will always be Font.Height anyway.
+ //int text_box_preferred_height = (txtView != null) ? txtView.PreferredHeight : Font.Height;
+ int text_box_preferred_height = Font.Height;
+
+ switch (border_style) {
+ case BorderStyle.FixedSingle:
+ case BorderStyle.Fixed3D:
+ text_box_preferred_height += 3; // magic number? :-)
+
+ return text_box_preferred_height + 4;
+
+ case BorderStyle.None:
+ default:
+ return text_box_preferred_height;
+ }
+ }
+ }
+
+ [DefaultValue(false)]
+ public bool ReadOnly {
+ get {
+ return txtView.ReadOnly;
+ }
+ set {
+ txtView.ReadOnly = value;
+ }
+ }
+
+ [Localizable(true)]
+ public override string Text {
+ get {
+ return txtView.Text;
+ }
+ set {
+ bool suppress_validation = changing_text;
+
+ txtView.Text = value;
+
+ if (!suppress_validation)
+ ValidateEditText();
+ }
+ }
+
+ [DefaultValue(HorizontalAlignment.Left)]
+ [Localizable(true)]
+ public HorizontalAlignment TextAlign {
+ get {
+ return txtView.TextAlign;
+ }
+ set{
+ txtView.TextAlign = value;
+ }
+ }
+
+ [DefaultValue(LeftRightAlignment.Right)]
+ [Localizable(true)]
+ public LeftRightAlignment UpDownAlign {
+ get {
+ return _UpDownAlign;
+ }
+ set {
+ _UpDownAlign = value;
+
+ reseat_controls();
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Properties
+ protected bool ChangingText {
+ get {
+ return changing_text;
+ }
+ set {
+ changing_text = value;
+ }
+ }
+
+ protected override CreateParams CreateParams {
+ get {
+ return base.CreateParams;
+ }
+ }
+
+ protected override Size DefaultSize {
+ get {
+ return new Size(120, this.PreferredHeight);
+ }
+ }
+
+ protected bool UserEdit {
+ get {
+ return user_edit;
+ }
+ set {
+ user_edit = value;
+ }
+ }
+ #endregion // Protected Instance Properties
+
+ #region Public Instance Methods
+ public abstract void DownButton();
+ public void Select(int start, int length) {
+ txtView.Select(start, length);
+ }
+
+ public abstract void UpButton();
+ #endregion // Public Instance Methods
+
+ #region Protected Instance Methods
+ protected override void Dispose(bool disposing) {
+ if (disposing) {
+ txtView.Dispose();
+ txtView = null;
+
+ spnSpinner.Dispose();
+ spnSpinner = null;
+ }
+ base.Dispose (disposing);
+ }
+
+ [MonoTODO]
+ protected virtual void OnChanged(object source, EventArgs e) {
+ // FIXME
+ }
+
+ protected override void OnFontChanged(EventArgs e) {
+ txtView.Font = this.Font;
+ Height = PreferredHeight;
+ }
+
+ protected override void OnHandleCreated(EventArgs e) {
+ base.OnHandleCreated (e);
+ }
+
+ protected override void OnLayout(LayoutEventArgs e) {
+ base.OnLayout(e);
+ }
+
+ protected override void OnMouseWheel(MouseEventArgs e) {
+ // prevent this event from firing twice for the same mouse action!
+ if (GetChildAtPoint(new Point(e.X, e.Y)) == null)
+ txtView_MouseWheel(null, e);
+ }
+
+ protected virtual void OnTextBoxKeyDown(object source, KeyEventArgs e) {
+ if (_InterceptArrowKeys) {
+ if ((e.KeyCode == Keys.Up) || (e.KeyCode == Keys.Down)) {
+ e.Handled = true;
+
+ if (e.KeyCode == Keys.Up)
+ UpButton();
+ if (e.KeyCode == Keys.Down)
+ DownButton();
+ }
+ }
+
+ OnKeyDown(e);
+ }
+
+ protected virtual void OnTextBoxKeyPress(object source, KeyPressEventArgs e) {
+ if (e.KeyChar == '\r') {
+ e.Handled = true;
+ ValidateEditText();
+ }
+ OnKeyPress(e);
+ }
+
+ protected virtual void OnTextBoxLostFocus(object source, EventArgs e) {
+ if (user_edit) {
+ ValidateEditText();
+ }
+ }
+
+ protected virtual void OnTextBoxResize(object source, EventArgs e) {
+ // compute the new height, taking the border into account
+ Height = PreferredHeight;
+
+ // let anchoring reposition the controls
+ }
+
+ protected virtual void OnTextBoxTextChanged(object source, EventArgs e) {
+ if (changing_text) {
+ ChangingText = false;
+ } else {
+ UserEdit = true;
+ }
+
+ OnTextChanged(e);
+ }
+
+ protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
+ base.SetBoundsCore(x, y, width, height, specified);
+
+ if ((specified & BoundsSpecified.Size) != BoundsSpecified.None) {
+ reseat_controls();
+ }
+ }
+
+ protected abstract void UpdateEditText();
+
+ protected virtual void ValidateEditText() {
+ // to be overridden by subclassers
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void WndProc(ref Message m) {
+ base.WndProc (ref m);
+ }
+ #endregion // Protected Instance Methods
+
+ #region Events
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler BackgroundImageChanged;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler MouseEnter;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler MouseHover;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event EventHandler MouseLeave;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new event MouseEventHandler MouseMove;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UpDownEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UpDownEventArgs.cs
new file mode 100644
index 00000000000..e0174bb11c6
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UpDownEventArgs.cs
@@ -0,0 +1,49 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public class UpDownEventArgs : EventArgs {
+ #region Local Variables
+ private int button_id;
+ #endregion // Local Variables
+
+ #region Public Constructors
+ public UpDownEventArgs(int buttonPushed) {
+ button_id = buttonPushed;
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ public int ButtonID {
+ get {
+ return button_id;
+ }
+ }
+ #endregion // Public Instance Properties
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UpDownEventHandler.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UpDownEventHandler.cs
new file mode 100644
index 00000000000..b91d9e4dea2
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UpDownEventHandler.cs
@@ -0,0 +1,31 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public delegate void UpDownEventHandler(object source, UpDownEventArgs e);
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UserControl.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UserControl.cs
new file mode 100644
index 00000000000..ee06d476007
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UserControl.cs
@@ -0,0 +1,103 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+
+// COMPLETE
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+ [DefaultEvent("Load")]
+ [DesignerCategory("UserControl")]
+ [Designer("System.Windows.Forms.Design.ControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+ [Designer("System.Windows.Forms.Design.UserControlDocumentDesigner, " + Consts.AssemblySystem_Design, typeof(IRootDesigner))]
+ public class UserControl : ContainerControl {
+ #region Public Constructors
+ public UserControl() {
+ }
+ #endregion // Public Constructors
+
+ #region Public Instance Properties
+ protected override Size DefaultSize {
+ get {
+ return new Size(150, 150);
+ }
+ }
+
+
+ [Bindable(false)]
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override string Text {
+ get {
+ return base.Text;
+ }
+
+ set {
+ base.Text = value;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Protected Instance Methods
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void OnCreateControl() {
+ base.OnCreateControl();
+
+ // The OnCreateControl isn't neccessarily raised *before* it
+ // becomes first visible, but that's the best we've got
+ OnLoad(EventArgs.Empty);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void OnLoad(EventArgs e) {
+ if (Load != null) Load(this, e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void OnMouseDown(MouseEventArgs e) {
+ base.OnMouseDown(e);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected override void WndProc(ref Message m) {
+ base.WndProc(ref m);
+ }
+ #endregion // Protected Instance Methods
+
+ #region Events
+ public event EventHandler Load;
+
+ [Browsable(false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler TextChanged;
+ #endregion // Events
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/VScrollBar.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/VScrollBar.cs
new file mode 100644
index 00000000000..ce592a11f4b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/VScrollBar.cs
@@ -0,0 +1,77 @@
+//
+// System.Windows.Forms.HScrollBar.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2005, Novell, Inc.
+//
+// Authors:
+// Jordi Mas i Hernandez jordi@ximian.com
+//
+//
+//
+
+
+using System.Drawing;
+using System.ComponentModel;
+
+namespace System.Windows.Forms
+{
+ public class VScrollBar : ScrollBar
+ {
+ #region events
+
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Browsable (false)]
+ public new event EventHandler RightToLeftChanged {
+ add { base.RightToLeftChanged += value; }
+ remove { base.RightToLeftChanged -= value; }
+ }
+
+ #endregion Events
+
+ public VScrollBar()
+ {
+ vert = true;
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Browsable (false)]
+ public override RightToLeft RightToLeft {
+ get { return base.RightToLeft; }
+ set {
+ if (RightToLeft == value)
+ return;
+
+ base.RightToLeft = value;
+
+ OnRightToLeftChanged (EventArgs.Empty);
+ }
+ }
+
+ protected override Size DefaultSize {
+ get { return ThemeEngine.Current.VScrollBarDefaultSize; }
+ }
+
+ protected override CreateParams CreateParams {
+ get { return base.CreateParams; }
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/View.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/View.cs
new file mode 100644
index 00000000000..5347823b51e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/View.cs
@@ -0,0 +1,37 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Ravindra (rkumar@novell.com)
+//
+
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public enum View
+ {
+ LargeIcon = 0,
+ Details = 1,
+ SmallIcon = 2,
+ List = 3
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Win32DnD.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Win32DnD.cs
new file mode 100644
index 00000000000..b85f172e254
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Win32DnD.cs
@@ -0,0 +1,1097 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Collections;
+using System.Drawing;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Runtime.InteropServices;
+using System.Runtime.Serialization;
+using System.Text;
+
+namespace System.Windows.Forms {
+ internal class Win32DnD {
+ #region Local Variables
+ private const uint DATADIR_GET = 1;
+ private const uint S_OK = 0x00000000;
+ private const uint S_FALSE = 0x00000001;
+ private const uint DRAGDROP_S_DROP = 0x00040100;
+ private const uint DRAGDROP_S_CANCEL = 0x00040101;
+ private const uint DRAGDROP_S_USEDEFAULTCURSORS = 0x00040102;
+ private const uint E_NOTIMPL = unchecked((uint)0x80004001);
+ private const uint E_NOINTERFACE = unchecked((uint)0x80004002);
+ private const uint E_FAIL = unchecked((uint)0x80004005);
+ private const uint OLE_E_ADVISENOTSUPPORTED = unchecked((uint)0x80040003);
+ private const uint DV_E_FORMATETC = unchecked((uint)0x80040064);
+
+ // To call function pointers
+ private static MethodInfo GetDataMethod;
+ private static object[] GetDataArgs;
+
+ // IDataObject Delegates
+ private static QueryInterfaceDelegate DOQueryInterface;
+ private static AddRefDelegate DOAddRef;
+ private static ReleaseDelegate DORelease;
+ private static GetDataDelegate GetData;
+ private static GetDataHereDelegate GetDataHere;
+ private static QueryGetDataDelegate QueryGetData;
+ private static GetCanonicalFormatEtcDelegate GetCanonicalFormatEtc;
+ private static SetDataDelegate SetData;
+ private static EnumFormatEtcDelegate EnumFormatEtc;
+ private static DAdviseDelegate DAdvise;
+ private static DUnadviseDelegate DUnadvise;
+ private static EnumDAdviseDelegate EnumDAdvise;
+
+ // IDropSource Delegates
+ private static QueryInterfaceDelegate DSQueryInterface;
+ private static AddRefDelegate DSAddRef;
+ private static ReleaseDelegate DSRelease;
+ private static QueryContinueDragDelegate QueryContinueDrag;
+ private static GiveFeedbackDelegate GiveFeedback;
+
+ // IDropTarget Delegates
+ private static QueryInterfaceDelegate DTQueryInterface;
+ private static AddRefDelegate DTAddRef;
+ private static ReleaseDelegate DTRelease;
+ private static DragEnterDelegate DragEnter;
+ private static DragOverDelegate DragOver;
+ private static DragLeaveDelegate DragLeave;
+ private static DropDelegate Drop;
+
+ private static DragEventArgs DragDropEventArgs;
+ private static GiveFeedbackEventArgs DragFeedbackEventArgs;
+ private static QueryContinueDragEventArgs DragContinueEventArgs;
+ private static ArrayList DragFormats;
+ private static FORMATETC[] DragFormatArray;
+ private static ArrayList DragMediums;
+ #endregion // Local Variables
+
+ #region Delegate Definitions
+ // IUnknown
+ internal delegate uint QueryInterfaceDelegate(IntPtr @this, ref Guid riid, IntPtr ppvObject);
+ internal delegate uint AddRefDelegate(IntPtr @this);
+ internal delegate uint ReleaseDelegate(IntPtr @this);
+
+ // IDataObject
+ internal delegate uint GetDataDelegate(IntPtr @this, ref FORMATETC pformatetcIn, IntPtr pmedium);
+ internal delegate uint GetDataHereDelegate(IntPtr @this, ref FORMATETC pformatetc, ref STGMEDIUM pmedium);
+ internal delegate uint QueryGetDataDelegate(IntPtr @this, ref FORMATETC pformatetc);
+ internal delegate uint GetCanonicalFormatEtcDelegate(IntPtr @this, ref FORMATETC pformatetcIn, IntPtr pformatetcOut);
+ internal delegate uint SetDataDelegate(IntPtr @this, ref FORMATETC pformatetc, ref STGMEDIUM pmedium, bool release);
+ internal delegate uint EnumFormatEtcDelegate(IntPtr @this, uint direction, IntPtr ppenumFormatEtc);
+ internal delegate uint DAdviseDelegate(IntPtr @this, ref FORMATETC pformatetc, uint advf, IntPtr pAdvSink, ref uint pdwConnection);
+ internal delegate uint DUnadviseDelegate(IntPtr @this, uint pdwConnection);
+ internal delegate uint EnumDAdviseDelegate(IntPtr @this, IntPtr ppenumAdvise);
+
+ // IDropSource
+ internal delegate uint QueryContinueDragDelegate(IntPtr @this, bool fEscapePressed, uint grfkeyState);
+ internal delegate uint GiveFeedbackDelegate(IntPtr @this, uint pdwEffect);
+
+ // IDropTarget
+ internal delegate uint DragEnterDelegate(IntPtr @this, IntPtr pDataObj, uint grfkeyState, IntPtr pt_x, IntPtr pt_y, IntPtr pdwEffect);
+ internal delegate uint DragOverDelegate(IntPtr @this, uint grfkeyState, IntPtr pt_x, IntPtr pt_y, IntPtr pdwEffect);
+ internal delegate uint DragLeaveDelegate(IntPtr @this);
+ internal delegate uint DropDelegate(IntPtr @this, IntPtr pDataObj, uint grfkeyState, IntPtr pt_x, IntPtr pt_y, IntPtr pdwEffect);
+ #endregion // Delegate Definitions
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct FORMATETC {
+ [MarshalAs(UnmanagedType.U2)]
+ internal ClipboardFormats cfFormat;
+ internal IntPtr ptd;
+ internal DVASPECT dwAspect;
+ internal int lindex;
+ internal TYMED tymed;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct STGMEDIUM {
+ internal TYMED tymed;
+ internal IntPtr hHandle;
+ internal IntPtr pUnkForRelease;
+ }
+
+ [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
+ internal struct DROPFILES {
+ internal uint pFiles;
+ internal uint pt_x;
+ internal uint pt_y;
+ internal bool fNC;
+ internal bool fWide;
+ internal string pText;
+ }
+
+ internal enum DVASPECT {
+ DVASPECT_CONTENT = 1,
+ DVASPECT_THUMBNAIL = 2,
+ DVASPECT_ICON = 4,
+ DVASPECT_DOCPRINT = 8
+ }
+
+ internal enum TYMED {
+ TYMED_HGLOBAL = 1,
+ TYMED_FILE = 2,
+ TYMED_ISTREAM = 4,
+ TYMED_ISTORAGE = 8,
+ TYMED_GDI = 16,
+ TYMED_MFPICT = 32,
+ TYMED_ENHMF = 64,
+ TYMED_NULL = 0
+ }
+
+ private static readonly Guid IID_IUnknown = new Guid("00000000-0000-0000-C000-000000000046");
+ private static readonly Guid IID_IDataObject = new Guid("0000010e-0000-0000-C000-000000000046");
+ private static readonly Guid IID_IDropSource = new Guid("00000121-0000-0000-C000-000000000046");
+ private static readonly Guid IID_IDropTarget = new Guid("00000122-0000-0000-C000-000000000046");
+
+ internal Win32DnD() {
+ // Required for all other OLE functions to work
+ Win32OleInitialize(IntPtr.Zero);
+
+ // We reuse those
+ DragDropEventArgs = new DragEventArgs(new DataObject(DataFormats.FileDrop, new string[0]), 0, 0, 0, DragDropEffects.None, DragDropEffects.None);
+ DragFeedbackEventArgs = new GiveFeedbackEventArgs(DragDropEffects.None, true);
+ DragContinueEventArgs = new QueryContinueDragEventArgs(0, false, DragAction.Continue);
+ DragFormats = new ArrayList();
+ DragFormatArray = new FORMATETC[0];
+ DragMediums = new ArrayList();
+
+ // Set up delegates
+ // IDataObject
+ DOQueryInterface = new QueryInterfaceDelegate(ComIDataObject.QueryInterface);
+ DOAddRef = new AddRefDelegate(ComIDataObject.AddRef);
+ DORelease = new ReleaseDelegate(ComIDataObject.Release);
+ GetData = new GetDataDelegate(ComIDataObject.GetData);
+ GetDataHere = new GetDataHereDelegate(ComIDataObject.GetDataHere);
+ QueryGetData = new QueryGetDataDelegate(ComIDataObject.QueryGetData);
+ GetCanonicalFormatEtc = new GetCanonicalFormatEtcDelegate(ComIDataObject.GetCanonicalFormatEtc);
+ SetData = new SetDataDelegate(ComIDataObject.SetData);
+ EnumFormatEtc = new EnumFormatEtcDelegate(ComIDataObject.EnumFormatEtc);
+ DAdvise = new DAdviseDelegate(ComIDataObject.DAdvise);
+ DUnadvise = new DUnadviseDelegate(ComIDataObject.DUnadvise);
+ EnumDAdvise = new EnumDAdviseDelegate(ComIDataObject.EnumDAdvise);
+
+ // IDropSource
+ DSQueryInterface = new QueryInterfaceDelegate(ComIDropSource.QueryInterface);
+ DSAddRef = new AddRefDelegate(ComIDropSource.AddRef);
+ DSRelease = new ReleaseDelegate(ComIDropSource.Release);
+ QueryContinueDrag = new QueryContinueDragDelegate(ComIDropSource.QueryContinueDrag);
+ GiveFeedback = new GiveFeedbackDelegate(ComIDropSource.GiveFeedback);
+
+ // IDropTarget
+ DTQueryInterface = new QueryInterfaceDelegate(ComIDropTarget.QueryInterface);
+ DTAddRef = new AddRefDelegate(ComIDropTarget.AddRef);
+ DTRelease = new ReleaseDelegate(ComIDropTarget.Release);
+ DragEnter = new DragEnterDelegate(ComIDropTarget.DragEnter);
+ DragOver = new DragOverDelegate(ComIDropTarget.DragOver);
+ DragLeave = new DragLeaveDelegate(ComIDropTarget.DragLeave);
+ Drop = new DropDelegate(ComIDropTarget.Drop);
+ }
+
+ internal class ComIDataObject {
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct DataObjectStruct {
+ internal IntPtr vtbl;
+ internal QueryInterfaceDelegate QueryInterface;
+ internal AddRefDelegate AddRef;
+ internal ReleaseDelegate Release;
+ internal GetDataDelegate GetData;
+ internal GetDataHereDelegate GetDataHere;
+ internal QueryGetDataDelegate QueryGetData;
+ internal GetCanonicalFormatEtcDelegate GetCanonicalFormatEtc;
+ internal SetDataDelegate SetData;
+ internal EnumFormatEtcDelegate EnumFormatEtc;
+ internal DAdviseDelegate DAdvise;
+ internal DUnadviseDelegate DUnadvise;
+ internal EnumDAdviseDelegate EnumDAdvise;
+ }
+
+ internal static IntPtr GetUnmanaged() {
+ DataObjectStruct data_object;
+ IntPtr data_object_ptr;
+ long offset;
+
+ data_object = new DataObjectStruct();
+
+ data_object.QueryInterface = Win32DnD.DOQueryInterface;
+ data_object.AddRef = Win32DnD.DOAddRef;
+ data_object.Release = Win32DnD.DORelease;
+ data_object.GetData = Win32DnD.GetData;
+ data_object.GetDataHere = Win32DnD.GetDataHere;
+ data_object.QueryGetData = Win32DnD.QueryGetData;
+ data_object.GetCanonicalFormatEtc = Win32DnD.GetCanonicalFormatEtc;
+ data_object.SetData = Win32DnD.SetData;
+ data_object.EnumFormatEtc = Win32DnD.EnumFormatEtc;
+ data_object.DAdvise = Win32DnD.DAdvise;
+ data_object.DUnadvise = Win32DnD.DUnadvise;
+ data_object.EnumDAdvise = Win32DnD.EnumDAdvise;
+
+ data_object_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DataObjectStruct)));
+ Marshal.StructureToPtr(data_object, data_object_ptr, false);
+
+ // Update vtbl pointer
+ offset = data_object_ptr.ToInt64();
+ offset += Marshal.SizeOf(typeof(IntPtr));
+ Marshal.WriteIntPtr(data_object_ptr, new IntPtr(offset));
+
+ return data_object_ptr;
+ }
+
+ internal static void ReleaseUnmanaged(IntPtr data_object_ptr) {
+ Marshal.FreeHGlobal(data_object_ptr);
+ }
+
+ internal static uint QueryInterface(IntPtr @this, ref Guid riid, IntPtr ppvObject) {
+ try {
+ if (IID_IUnknown.Equals(riid) || IID_IDataObject.Equals(riid)) {
+ Marshal.WriteIntPtr(ppvObject, @this);
+ return S_OK;
+ }
+ }
+
+ catch (Exception e) {
+ Console.WriteLine("Got exception {0}", e.Message);
+ }
+
+ Marshal.WriteIntPtr(ppvObject, IntPtr.Zero);
+ return E_NOINTERFACE;
+ }
+
+ internal static uint AddRef(IntPtr @this) {
+ // We only use this for DnD, try and fake it
+ return 1;
+ }
+
+ internal static uint Release(IntPtr @this) {
+ // We only use this for DnD, try and fake it
+ return 0;
+ }
+
+ internal static STGMEDIUM medium = new STGMEDIUM();
+ internal static uint GetData(IntPtr this_, ref FORMATETC pformatetcIn, IntPtr pmedium) {
+ int index;
+
+ index = FindFormat(pformatetcIn);
+ if (index != -1) {
+ medium.tymed = TYMED.TYMED_HGLOBAL;
+ medium.hHandle = XplatUIWin32.DupGlobalMem(((STGMEDIUM)DragMediums[index]).hHandle);
+ medium.pUnkForRelease = IntPtr.Zero;
+ try {
+ Marshal.StructureToPtr(medium, pmedium, false);
+ }
+ catch (Exception e) {
+ Console.WriteLine("Error: {0}", e.Message);
+ }
+ return S_OK;
+ }
+
+ return DV_E_FORMATETC;
+ }
+
+ internal static uint GetDataHere(IntPtr @this, ref FORMATETC pformatetc, ref STGMEDIUM pmedium) {
+ return DV_E_FORMATETC;
+ }
+
+ internal static uint QueryGetData(IntPtr @this, ref FORMATETC pformatetc) {
+ if (FindFormat(pformatetc) != -1) {
+ return S_OK;
+ }
+ return DV_E_FORMATETC;
+ }
+
+ internal static uint GetCanonicalFormatEtc(IntPtr @this, ref FORMATETC pformatetcIn, IntPtr pformatetcOut) {
+ Marshal.WriteIntPtr(pformatetcOut, Marshal.SizeOf(typeof(IntPtr)), IntPtr.Zero);
+ return E_NOTIMPL;
+ }
+
+ internal static uint SetData(IntPtr this_, ref FORMATETC pformatetc, ref STGMEDIUM pmedium, bool release) {
+ return E_NOTIMPL;
+ }
+
+ internal static uint EnumFormatEtc(IntPtr this_, uint direction, IntPtr ppenumFormatEtc) {
+ if (direction == DATADIR_GET) {
+ IntPtr ppenum_ptr;
+
+ ppenum_ptr = IntPtr.Zero;
+ DragFormatArray = new FORMATETC[DragFormats.Count];
+
+ for (int i = 0; i < DragFormats.Count; i++) {
+ DragFormatArray[i] = (FORMATETC)DragFormats[i];
+ }
+ Win32SHCreateStdEnumFmtEtc((uint)DragFormatArray.Length, DragFormatArray, ref ppenum_ptr);
+ Marshal.WriteIntPtr(ppenumFormatEtc, ppenum_ptr);
+ return S_OK;
+ }
+ return E_NOTIMPL;
+ }
+
+ internal static uint DAdvise(IntPtr this_, ref FORMATETC pformatetc, uint advf, IntPtr pAdvSink, ref uint pdwConnection) {
+ return OLE_E_ADVISENOTSUPPORTED;
+ }
+
+ internal static uint DUnadvise(IntPtr this_, uint pdwConnection) {
+ return OLE_E_ADVISENOTSUPPORTED;
+ }
+
+ internal static uint EnumDAdvise(IntPtr this_, IntPtr ppenumAdvise) {
+ return OLE_E_ADVISENOTSUPPORTED;
+ }
+ }
+
+ internal class ComIDataObjectUnmanaged {
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct IDataObjectUnmanaged {
+ internal IntPtr QueryInterface;
+ internal IntPtr AddRef;
+ internal IntPtr Release;
+ internal IntPtr GetData;
+ internal IntPtr GetDataHere;
+ internal IntPtr QueryGetData;
+ internal IntPtr GetCanonicalFormatEtc;
+ internal IntPtr SetData;
+ internal IntPtr EnumFormatEtc;
+ internal IntPtr DAdvise;
+ internal IntPtr DUnadvise;
+ internal IntPtr EnumDAdvise;
+ }
+
+ private static bool Initialized;
+ private static MethodInfo GetDataMethod;
+ private static MethodInfo GetDataHereMethod;
+ private static MethodInfo QueryGetDataMethod;
+ private static MethodInfo GetCanonicalFormatEtcMethod;
+ private static MethodInfo SetDataMethod;
+ private static MethodInfo EnumFormatEtcMethod;
+ private static MethodInfo DAdviseMethod;
+ private static MethodInfo DUnadviseMethod;
+ private static MethodInfo EnumDAdviseMethod;
+ private static object[] MethodArguments;
+
+ private IDataObjectUnmanaged vtbl;
+ private IntPtr @this;
+
+ internal ComIDataObjectUnmanaged(IntPtr data_object_ptr) {
+ if (!Initialized) {
+ Initialize();
+ }
+
+ vtbl = new IDataObjectUnmanaged();
+ @this = data_object_ptr;
+ try {
+ vtbl = (IDataObjectUnmanaged)Marshal.PtrToStructure(Marshal.ReadIntPtr(data_object_ptr), typeof(IDataObjectUnmanaged));
+ }
+
+ catch (Exception e) {
+ Console.WriteLine("Exception {0}", e.Message);
+ }
+ }
+
+ private static void Initialize() {
+ AssemblyName assembly;
+ AssemblyBuilder assembly_builder;
+
+ if (Initialized) {
+ return;
+ }
+
+ assembly = new AssemblyName();
+ assembly.Name = "XplatUIWin32.FuncPtrInterface";
+ assembly_builder = AppDomain.CurrentDomain.DefineDynamicAssembly(assembly, AssemblyBuilderAccess.Run);
+
+ MethodArguments = new object[6];
+ GetDataMethod = CreateFuncPtrInterface(assembly_builder, "GetData", typeof(uint), 3);
+ GetDataHereMethod = CreateFuncPtrInterface(assembly_builder, "GetDataHere", typeof(uint), 3);
+ QueryGetDataMethod = CreateFuncPtrInterface(assembly_builder, "QueryGetData", typeof(uint), 2);
+ GetCanonicalFormatEtcMethod = CreateFuncPtrInterface(assembly_builder, "GetCanonicalFormatEtc", typeof(uint), 3);
+ SetDataMethod = CreateFuncPtrInterface(assembly_builder, "SetData", typeof(uint), 4);
+ EnumFormatEtcMethod = CreateFuncPtrInterface(assembly_builder, "EnumFormatEtc", typeof(uint), 3);
+ DAdviseMethod = CreateFuncPtrInterface(assembly_builder, "DAdvise", typeof(uint), 5);
+ DUnadviseMethod = CreateFuncPtrInterface(assembly_builder, "DUnadvise", typeof(uint), 2);
+ EnumDAdviseMethod = CreateFuncPtrInterface(assembly_builder, "EnumDAdvise", typeof(uint), 2);
+
+ Initialized = true;
+ }
+
+ internal uint QueryInterface(Guid riid, IntPtr ppvObject) {
+ uint ret;
+ IntPtr riid_ptr;
+
+ riid_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Guid)));
+ Marshal.StructureToPtr(riid, riid_ptr, false);
+
+ MethodArguments[0] = vtbl.QueryInterface;
+ MethodArguments[1] = this.@this;
+ MethodArguments[2] = riid_ptr;
+ MethodArguments[3] = ppvObject;
+
+ try {
+ ret = (uint)GetDataMethod.Invoke(null, MethodArguments);
+ }
+
+ catch (Exception e) {
+ Console.WriteLine("Caught exception {0}", e.Message);
+ ret = E_FAIL;
+ }
+
+ Marshal.FreeHGlobal(riid_ptr);
+
+ return ret;
+ }
+
+ internal uint AddRef() {
+ // We only use this for DnD, try and fake it
+ return 1;
+ }
+
+ internal uint Release() {
+ // We only use this for DnD, try and fake it
+ return 0;
+ }
+
+ internal uint GetData(FORMATETC pformatetcIn, ref STGMEDIUM pmedium) {
+ uint ret;
+ IntPtr pformatetcIn_ptr;
+ IntPtr pmedium_ptr;
+
+ pformatetcIn_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(FORMATETC)));
+ Marshal.StructureToPtr(pformatetcIn, pformatetcIn_ptr, false);
+
+ pmedium_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(STGMEDIUM)));
+
+ MethodArguments[0] = vtbl.GetData;
+ MethodArguments[1] = this.@this;
+ MethodArguments[2] = pformatetcIn_ptr;
+ MethodArguments[3] = pmedium_ptr;
+
+ try {
+ ret = (uint)GetDataMethod.Invoke(null, MethodArguments);
+ Marshal.PtrToStructure(pmedium_ptr, pmedium);
+ }
+
+ catch (Exception e) {
+ Console.WriteLine("Caught exception {0}", e.Message);
+ ret = E_FAIL;
+ }
+
+ Marshal.FreeHGlobal(pformatetcIn_ptr);
+ Marshal.FreeHGlobal(pmedium_ptr);
+
+ return ret;
+ }
+
+ internal uint GetDataHere(FORMATETC pformatetc, ref STGMEDIUM pmedium) {
+ return E_NOTIMPL;
+ }
+
+ internal uint QueryGetData(FORMATETC pformatetc) {
+ uint ret;
+ IntPtr pformatetc_ptr;
+
+ pformatetc_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(FORMATETC)));
+ Marshal.StructureToPtr(pformatetc, pformatetc_ptr, false);
+
+ MethodArguments[0] = vtbl.GetData;
+ MethodArguments[1] = this.@this;
+ MethodArguments[2] = pformatetc_ptr;
+
+ try {
+ ret = (uint)QueryGetDataMethod.Invoke(null, MethodArguments);
+ }
+
+ catch (Exception e) {
+ Console.WriteLine("Caught exception {0}", e.Message);
+ ret = E_FAIL;
+ }
+
+ Marshal.FreeHGlobal(pformatetc_ptr);
+
+ return ret;
+ }
+
+ internal uint GetCanonicalFormatEtc(FORMATETC pformatetcIn, ref FORMATETC pformatetcOut) {
+ return E_NOTIMPL;
+ }
+
+ internal uint SetData(FORMATETC pformatetc, STGMEDIUM pmedium, bool release) {
+ return E_NOTIMPL;
+ }
+
+ internal uint EnumFormatEtc(uint direction, IntPtr ppenumFormatEtc) {
+ return E_NOTIMPL;
+ }
+
+ internal uint DAdvise(FORMATETC pformatetc, uint advf, IntPtr pAdvSink, ref uint pdwConnection) {
+ return OLE_E_ADVISENOTSUPPORTED;
+ }
+
+ internal uint DUnadvise(uint pdwConnection) {
+ return OLE_E_ADVISENOTSUPPORTED;
+ }
+
+ internal uint EnumDAdvise(IntPtr ppenumAdvise) {
+ return OLE_E_ADVISENOTSUPPORTED;
+ }
+ }
+
+
+ internal class ComIDropSource {
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct IDropSource {
+ internal IntPtr vtbl;
+ internal IntPtr Window;
+ internal QueryInterfaceDelegate QueryInterface;
+ internal AddRefDelegate AddRef;
+ internal ReleaseDelegate Release;
+ internal QueryContinueDragDelegate QueryContinueDrag;
+ internal GiveFeedbackDelegate GiveFeedback;
+ }
+
+ internal static IntPtr GetUnmanaged(IntPtr Window) {
+ IDropSource drop_source;
+ IntPtr drop_source_ptr;
+ long offset;
+
+ drop_source = new IDropSource();
+ drop_source.QueryInterface = Win32DnD.DSQueryInterface;
+ drop_source.AddRef = Win32DnD.DSAddRef;
+ drop_source.Release = Win32DnD.DSRelease;
+ drop_source.QueryContinueDrag = Win32DnD.QueryContinueDrag;
+ drop_source.GiveFeedback = Win32DnD.GiveFeedback;
+ drop_source.Window = Window;
+
+ drop_source_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(drop_source));
+ Marshal.StructureToPtr(drop_source, drop_source_ptr, false);
+
+ // Update vtbl pointer
+ offset = drop_source_ptr.ToInt64();
+ offset += 2 * Marshal.SizeOf(typeof(IntPtr));
+ Marshal.WriteIntPtr(drop_source_ptr, new IntPtr(offset));
+
+ return drop_source_ptr;
+ }
+
+ internal static void ReleaseUnmanaged(IntPtr drop_source_ptr) {
+ Marshal.FreeHGlobal(drop_source_ptr);
+ }
+
+ internal static uint QueryInterface(IntPtr @this, ref Guid riid, IntPtr ppvObject) {
+ try {
+ if (IID_IUnknown.Equals(riid) || IID_IDropSource.Equals(riid)) {
+ Marshal.WriteIntPtr(ppvObject, @this);
+ return S_OK;
+ }
+ }
+
+ catch (Exception e) {
+ Console.WriteLine("Got exception {0}", e.Message);
+ }
+
+ Marshal.WriteIntPtr(ppvObject, IntPtr.Zero);
+ return E_NOINTERFACE;
+ }
+
+ internal static uint AddRef(IntPtr @this) {
+ // We only use this for DnD, try and fake it
+ return 1;
+ }
+
+ internal static uint Release(IntPtr @this) {
+ // We only use this for DnD, try and fake it
+ return 0;
+ }
+
+ internal static uint QueryContinueDrag(IntPtr @this, bool fEscapePressed, uint grfkeyState) {
+ IntPtr window;
+
+ window = Marshal.ReadIntPtr(@this, Marshal.SizeOf(typeof(IntPtr)));
+
+ // LAMESPEC? - according to MSDN, when the any mousebutton is *pressed* it defaults to Drop.
+ // According to COM customary behaviour it's the other way round; which is what we do here
+ if (fEscapePressed) {
+ DragContinueEventArgs.drag_action = DragAction.Cancel;
+ } else if ((grfkeyState & (1+2+16)) == 0) { // Left, middle and right mouse button not pressed
+ DragContinueEventArgs.drag_action = DragAction.Drop;
+ } else {
+ DragContinueEventArgs.drag_action = DragAction.Continue;
+ }
+
+ DragContinueEventArgs.escape_pressed = fEscapePressed;
+ DragContinueEventArgs.key_state = (int)grfkeyState;
+
+ Control.FromHandle(window).DndContinueDrag(DragContinueEventArgs);
+
+ if (DragContinueEventArgs.drag_action == DragAction.Cancel) {
+ return DRAGDROP_S_CANCEL;
+ } else if (DragContinueEventArgs.drag_action == DragAction.Drop) {
+ return DRAGDROP_S_DROP;
+ }
+ return S_OK;
+ }
+
+ internal static uint GiveFeedback(IntPtr @this, uint pdwEffect) {
+ IntPtr window;
+
+ window = Marshal.ReadIntPtr(@this, Marshal.SizeOf(typeof(IntPtr)));
+
+ DragFeedbackEventArgs.effect = (DragDropEffects)pdwEffect;
+ DragFeedbackEventArgs.use_default_cursors = true;
+
+ Control.FromHandle(window).DndFeedback(DragFeedbackEventArgs);
+
+ if (DragFeedbackEventArgs.use_default_cursors) {
+ return DRAGDROP_S_USEDEFAULTCURSORS;
+ }
+ return S_OK;
+ }
+ }
+
+ internal class ComIDropTarget {
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct IDropTarget {
+ internal IntPtr vtbl;
+ internal IntPtr Window;
+ internal QueryInterfaceDelegate QueryInterface;
+ internal AddRefDelegate AddRef;
+ internal ReleaseDelegate Release;
+
+ internal DragEnterDelegate DragEnter;
+ internal DragOverDelegate DragOver;
+ internal DragLeaveDelegate DragLeave;
+ internal DropDelegate Drop;
+ }
+
+ internal static IntPtr GetUnmanaged(IntPtr Window) {
+ IDropTarget drop_target;
+ IntPtr drop_target_ptr;
+ long offset;
+
+ drop_target = new IDropTarget();
+ drop_target.QueryInterface = Win32DnD.DTQueryInterface;
+ drop_target.AddRef = Win32DnD.DTAddRef;
+ drop_target.Release = Win32DnD.DTRelease;
+ drop_target.DragEnter = Win32DnD.DragEnter;
+ drop_target.DragOver = Win32DnD.DragOver;
+ drop_target.DragLeave = Win32DnD.DragLeave;
+ drop_target.Drop = Win32DnD.Drop;
+ drop_target.Window = Window;
+
+ drop_target_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(drop_target));
+ Marshal.StructureToPtr(drop_target, drop_target_ptr, false);
+
+ // Update vtbl pointer
+ offset = drop_target_ptr.ToInt64();
+ offset += 2 * Marshal.SizeOf(typeof(IntPtr));
+ Marshal.WriteIntPtr(drop_target_ptr, new IntPtr(offset));
+
+ return drop_target_ptr;
+ }
+
+ internal static void ReleaseUnmanaged(IntPtr drop_target_ptr) {
+ Marshal.FreeHGlobal(drop_target_ptr);
+ }
+
+ internal static uint QueryInterface(IntPtr @this, ref Guid riid, IntPtr ppvObject) {
+ try {
+ if (IID_IUnknown.Equals(riid) || IID_IDropTarget.Equals(riid)) {
+ Marshal.WriteIntPtr(ppvObject, @this);
+ return S_OK;
+ }
+ }
+
+ catch (Exception e) {
+ Console.WriteLine("Got exception {0}", e.Message);
+ }
+
+ Marshal.WriteIntPtr(ppvObject, IntPtr.Zero);
+ return E_NOINTERFACE;
+ }
+
+ internal static uint AddRef(IntPtr @this) {
+ // We only use this for DnD, try and fake it
+ return 1;
+ }
+
+ internal static uint Release(IntPtr @this) {
+ // We only use this for DnD, try and fake it
+ return 0;
+ }
+
+ internal static uint DragEnter(IntPtr @this, IntPtr pDataObj, uint grfkeyState, IntPtr pt_x, IntPtr pt_y, IntPtr pdwEffect) {
+ IntPtr window;
+
+ window = Marshal.ReadIntPtr(@this, Marshal.SizeOf(typeof(IntPtr)));
+
+ DragDropEventArgs.x = pt_x.ToInt32();
+ DragDropEventArgs.y = pt_y.ToInt32();
+ DragDropEventArgs.allowed_effect = (DragDropEffects)Marshal.ReadIntPtr(pdwEffect).ToInt32();
+ DragDropEventArgs.current_effect = DragDropEventArgs.AllowedEffect;
+ DragDropEventArgs.keystate = (int)grfkeyState;
+
+ Control.FromHandle(window).DndEnter(DragDropEventArgs);
+
+ Marshal.WriteInt32(pdwEffect, (int)DragDropEventArgs.Effect);
+
+ return S_OK;
+ }
+
+ internal static uint DragOver(IntPtr @this, uint grfkeyState, IntPtr pt_x, IntPtr pt_y, IntPtr pdwEffect) {
+ IntPtr window;
+
+ window = Marshal.ReadIntPtr(@this, Marshal.SizeOf(typeof(IntPtr)));
+
+ DragDropEventArgs.x = pt_x.ToInt32();
+ DragDropEventArgs.y = pt_y.ToInt32();
+ DragDropEventArgs.allowed_effect = (DragDropEffects)Marshal.ReadIntPtr(pdwEffect).ToInt32();
+ DragDropEventArgs.current_effect = DragDropEventArgs.AllowedEffect;
+ DragDropEventArgs.keystate = (int)grfkeyState;
+
+ Control.FromHandle(window).DndOver(DragDropEventArgs);
+
+ Marshal.WriteInt32(pdwEffect, (int)DragDropEventArgs.Effect);
+
+ return S_OK;
+ }
+
+ internal static uint DragLeave(IntPtr @this) {
+ IntPtr window;
+
+ window = Marshal.ReadIntPtr(@this, Marshal.SizeOf(typeof(IntPtr)));
+
+ Control.FromHandle(window).DndLeave(EventArgs.Empty);
+
+ return S_OK;
+ }
+
+ internal static uint Drop(IntPtr @this, IntPtr pDataObj, uint grfkeyState, IntPtr pt_x, IntPtr pt_y, IntPtr pdwEffect) {
+ throw new Exception("Yeah baby, gimme a ride to WM_DROPFILES land");
+
+ #if InTheFuture
+ ComIDataObjectUnmanaged data_object;
+ FORMATETC format;
+ STGMEDIUM medium;
+ uint result;
+ IntPtr mem;
+
+
+ data_object = new ComIDataObjectUnmanaged(pDataObj);
+
+ format = new FORMATETC();
+ format.cfFormat = ClipboardFormats.CF_HDROP;
+ format.ptd = IntPtr.Zero;
+ format.dwAspect = DVASPECT.DVASPECT_CONTENT;
+ format.lindex = -1;
+ format.tymed = TYMED.TYMED_HGLOBAL;
+
+ medium = new STGMEDIUM();
+ medium.tymed = TYMED.TYMED_HGLOBAL;
+
+ //mem = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));
+ //result = data_object.QueryInterface(IID_IDataObject, mem);
+ //Marshal.FreeHGlobal(mem);
+
+ //result = data_object.AddRef();
+
+ result = data_object.QueryGetData(format);
+
+ result = data_object.GetData(format, ref medium);
+
+ return E_NOTIMPL;
+ #endif
+ }
+ }
+
+ internal static bool HandleWMDropFiles(ref MSG msg) {
+ IntPtr hDrop;
+ int count;
+ StringBuilder sb;
+ string[] dropfiles;
+
+ hDrop = msg.wParam;
+ count = Win32DragQueryFile(hDrop, -1, IntPtr.Zero, 0);
+
+ dropfiles = new string[count];
+
+ sb = new StringBuilder(256);
+ for (int i = 0; i < count; i++) {
+ Win32DragQueryFile(hDrop, i, sb, sb.Capacity);
+ dropfiles[i] = sb.ToString();
+ }
+
+ DragDropEventArgs.Data.SetData(DataFormats.FileDrop, dropfiles);
+
+ Control.FromHandle(msg.hwnd).DndDrop(DragDropEventArgs);
+
+ return true;
+ }
+
+ private static bool AddFormatAndMedium(ClipboardFormats cfFormat, object data) {
+ STGMEDIUM medium;
+ FORMATETC format;
+ IntPtr hmem;
+ IntPtr hmem_ptr;
+ byte[] b;
+
+ switch(cfFormat) {
+ case ClipboardFormats.CF_TEXT: {
+ hmem = Marshal.StringToHGlobalAnsi((string)data);
+ break;
+ }
+
+ case ClipboardFormats.CF_UNICODETEXT: {
+ hmem = Marshal.StringToHGlobalUni((string)data);
+ break;
+ }
+
+ case ClipboardFormats.CF_HDROP: {
+ IEnumerator e;
+ StringBuilder sb;
+ long hmem_string_ptr;
+ IntPtr string_buffer;
+ int string_buffer_size;
+
+ sb = new StringBuilder();
+
+ // Make sure object is enumerable; otherwise
+ if ((data is string) || !(data is IEnumerable)) {
+ sb.Append(data.ToString());
+ sb.Append('\0');
+ sb.Append('\0');
+ } else {
+ e = ((IEnumerable)data).GetEnumerator();
+ while (e.MoveNext()) {
+ sb.Append(e.Current.ToString());
+ sb.Append('\0');
+ }
+ sb.Append('\0');
+ }
+
+ string_buffer = Marshal.StringToHGlobalUni(sb.ToString());
+ string_buffer_size = (int)XplatUIWin32.Win32GlobalSize(string_buffer);
+
+ // Write DROPFILES structure
+ hmem = XplatUIWin32.Win32GlobalAlloc(XplatUIWin32.GAllocFlags.GMEM_MOVEABLE | XplatUIWin32.GAllocFlags.GMEM_DDESHARE, 0x14 + string_buffer_size);
+ hmem_ptr = XplatUIWin32.Win32GlobalLock(hmem);
+ Marshal.WriteInt32(hmem_ptr, 0x14); // pFiles
+ Marshal.WriteInt32(hmem_ptr, 1 * Marshal.SizeOf(typeof(uint)), 0); // point.x
+ Marshal.WriteInt32(hmem_ptr, 2 * Marshal.SizeOf(typeof(uint)), 0); // point.y
+ Marshal.WriteInt32(hmem_ptr, 3 * Marshal.SizeOf(typeof(uint)), 0); // fNc
+ Marshal.WriteInt32(hmem_ptr, 4 * Marshal.SizeOf(typeof(uint)), 1); // fWide
+
+ hmem_string_ptr = (long)hmem_ptr;
+ hmem_string_ptr += 0x14;
+
+ XplatUIWin32.Win32CopyMemory(new IntPtr(hmem_string_ptr), string_buffer, string_buffer_size);
+ Marshal.FreeHGlobal(string_buffer);
+ XplatUIWin32.Win32GlobalUnlock(hmem_ptr);
+
+ break;
+ }
+
+ case ClipboardFormats.CF_DIB: {
+ b = XplatUIWin32.ImageToDIB((Image)data);
+
+ hmem = XplatUIWin32.Win32GlobalAlloc(XplatUIWin32.GAllocFlags.GMEM_MOVEABLE | XplatUIWin32.GAllocFlags.GMEM_DDESHARE, b.Length);
+ hmem_ptr = XplatUIWin32.Win32GlobalLock(hmem);
+ Marshal.Copy(b, 0, hmem_ptr, b.Length);
+ XplatUIWin32.Win32GlobalUnlock(hmem);
+ break;
+ }
+
+ default: {
+ hmem = IntPtr.Zero;
+ break;
+ }
+ }
+
+ if (hmem != IntPtr.Zero) {
+ medium = new STGMEDIUM();
+ medium.tymed = TYMED.TYMED_HGLOBAL;
+ medium.hHandle = hmem;
+ medium.pUnkForRelease = IntPtr.Zero;
+ DragMediums.Add(medium);
+
+ format = new FORMATETC();
+ format.ptd = IntPtr.Zero;
+ format.dwAspect = DVASPECT.DVASPECT_CONTENT;
+ format.lindex = -1;
+ format.tymed = TYMED.TYMED_HGLOBAL;
+ format.cfFormat = cfFormat;
+ DragFormats.Add(format);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ private static int FindFormat(FORMATETC pformatetc) {
+ for (int i = 0; i < DragFormats.Count; i++) {
+ if ((((FORMATETC)DragFormats[i]).cfFormat == pformatetc.cfFormat) &&
+ (((FORMATETC)DragFormats[i]).dwAspect == pformatetc.dwAspect) &&
+ ((((FORMATETC)DragFormats[i]).tymed & pformatetc.tymed)) != 0) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ private static void BuildFormats(object data) {
+
+ DragFormats.Clear();
+ DragMediums.Clear();
+
+ // Build our formats based on object data
+ if (data is String) {
+ AddFormatAndMedium(ClipboardFormats.CF_TEXT, data);
+ AddFormatAndMedium(ClipboardFormats.CF_UNICODETEXT, data);
+ AddFormatAndMedium(ClipboardFormats.CF_HDROP, data);
+ } else if (data is Bitmap) {
+ AddFormatAndMedium(ClipboardFormats.CF_DIB, data);
+ } else if (data is ICollection) {
+ // FIXME - test with .Net and found how this is handled
+ AddFormatAndMedium(ClipboardFormats.CF_HDROP, data);
+ } else if (data is ISerializable) {
+ // FIXME - test with .Net and found how this is handled
+ }
+ }
+
+ internal static DragDropEffects StartDrag(IntPtr Window, object data, DragDropEffects allowed) {
+ IntPtr result;
+ IntPtr data_object;
+ IntPtr drop_source;
+
+ BuildFormats(data);
+
+ data_object = ComIDataObject.GetUnmanaged();
+ drop_source = ComIDropSource.GetUnmanaged(Window);
+
+ result = (IntPtr)DragDropEffects.None;
+
+ Win32DoDragDrop(data_object, drop_source, (IntPtr)allowed, ref result);
+
+ // Cleanup again
+ ComIDataObject.ReleaseUnmanaged(data_object);
+ ComIDropSource.ReleaseUnmanaged(drop_source);
+ DragFormats.Clear();
+ DragFormatArray = null;
+ DragMediums.Clear();
+
+ return (DragDropEffects)result.ToInt32();
+ }
+
+ internal static bool UnregisterDropTarget(IntPtr Window) {
+ Win32RevokeDragDrop(Window);
+ return true;
+ }
+
+ internal static bool RegisterDropTarget(IntPtr Window) {
+ Hwnd hwnd;
+ IntPtr drop_target;
+ uint result;
+
+ hwnd = Hwnd.ObjectFromWindow(Window);
+ if (hwnd == null) {
+ return false;
+ }
+
+ drop_target = ComIDropTarget.GetUnmanaged(Window);
+ hwnd.marshal_free_list.Add(drop_target);
+ result = Win32RegisterDragDrop(Window, drop_target);
+
+ if (result != S_OK) {
+ return false;
+ }
+ return true;
+ }
+
+ // Thanks, Martin
+ static MethodInfo CreateFuncPtrInterface(AssemblyBuilder assembly, string MethodName, Type ret_type, int param_count) {
+ ModuleBuilder mb;
+ TypeBuilder tb;
+ Type[] il_param_types;
+ Type[] param_types;
+
+ mb = assembly.DefineDynamicModule("XplatUIWin32.FuncInterface" + MethodName);
+ tb = mb.DefineType ("XplatUIWin32.FuncInterface" + MethodName, TypeAttributes.Public);
+
+ param_types = new Type[param_count];
+ il_param_types = new Type[param_count + 1];
+
+ il_param_types[param_count] = typeof(IntPtr);
+ for (int i = 0; i < param_count; i++) {
+ param_types[i] = typeof(IntPtr);
+ il_param_types[i] = typeof(IntPtr);
+ }
+
+ MethodBuilder method = tb.DefineMethod (
+ MethodName, MethodAttributes.Static | MethodAttributes.Public,
+ ret_type, il_param_types);
+
+ ILGenerator ig = method.GetILGenerator ();
+ if (param_count > 5) ig.Emit (OpCodes.Ldarg_S, 6);
+ if (param_count > 4) ig.Emit (OpCodes.Ldarg_S, 5);
+ if (param_count > 3) ig.Emit (OpCodes.Ldarg_S, 4);
+ if (param_count > 2) ig.Emit (OpCodes.Ldarg_3);
+ if (param_count > 1) ig.Emit (OpCodes.Ldarg_2);
+ if (param_count > 0) ig.Emit (OpCodes.Ldarg_1);
+ ig.Emit (OpCodes.Ldarg_0);
+ ig.EmitCalli (OpCodes.Calli, CallingConvention.StdCall, ret_type, param_types);
+ ig.Emit (OpCodes.Ret);
+
+ Type t = tb.CreateType ();
+ MethodInfo m = t.GetMethod (MethodName);
+
+ return m;
+ }
+
+ [DllImport ("ole32.dll", EntryPoint="RegisterDragDrop", CallingConvention=CallingConvention.StdCall)]
+ private extern static uint Win32RegisterDragDrop(IntPtr Window, IntPtr pDropTarget);
+
+ [DllImport ("ole32.dll", EntryPoint="RevokeDragDrop", CallingConvention=CallingConvention.StdCall)]
+ private extern static int Win32RevokeDragDrop(IntPtr Window);
+
+ [DllImport ("ole32.dll", EntryPoint="DoDragDrop", CallingConvention=CallingConvention.StdCall)]
+ private extern static uint Win32DoDragDrop(IntPtr pDataObject, IntPtr pDropSource, IntPtr dwOKEffect, ref IntPtr pdwEffect);
+
+ [DllImport ("shell32.dll", EntryPoint="DragAcceptFiles", CallingConvention=CallingConvention.StdCall)]
+ private extern static int Win32DragAcceptFiles(IntPtr Window, bool fAccept);
+
+ [DllImport ("ole32.dll", EntryPoint="OleInitialize", CallingConvention=CallingConvention.StdCall)]
+ private extern static int Win32OleInitialize(IntPtr pvReserved);
+
+ [DllImport ("shell32.dll", EntryPoint="DragQueryFileW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ private extern static int Win32DragQueryFile(IntPtr hDrop, int iFile, IntPtr lpszFile, int cch);
+
+ [DllImport ("shell32.dll", EntryPoint="DragQueryFileW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ private extern static int Win32DragQueryFile(IntPtr hDrop, int iFile, StringBuilder lpszFile, int cch);
+
+ [DllImport ("shell32.dll", EntryPoint="SHCreateStdEnumFmtEtc", CallingConvention=CallingConvention.StdCall)]
+ private extern static uint Win32SHCreateStdEnumFmtEtc(uint cfmt, FORMATETC[] afmt, ref IntPtr ppenumFormatEtc);
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11DesktopColors.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11DesktopColors.cs
new file mode 100644
index 00000000000..ebf79176164
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11DesktopColors.cs
@@ -0,0 +1,292 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Peter Dennis Bartok (pbartok@novell.com)
+// Alexander Olk (alex.olk@googlemail.com)
+//
+//
+
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.IO;
+
+namespace System.Windows.Forms {
+ internal class X11DesktopColors {
+ #region Structs & Enums
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct GdkColorStruct {
+ internal int pixel;
+ internal short red;
+ internal short green;
+ internal short blue;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct GObjectStruct {
+ IntPtr Instance;
+ IntPtr ref_count;
+ IntPtr data;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct GtkStyleStruct {
+ internal GObjectStruct obj;
+ [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=5)]
+ internal GdkColorStruct[] fg;
+ [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=5)]
+ internal GdkColorStruct[] bg;
+ [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=5)]
+ internal GdkColorStruct[] light;
+ [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=5)]
+ internal GdkColorStruct[] dark;
+ [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=5)]
+ internal GdkColorStruct[] mid;
+ [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=5)]
+ internal GdkColorStruct[] text;
+ [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=5)]
+ internal GdkColorStruct[] baseclr;
+ [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=5)]
+ internal GdkColorStruct[] text_aa; /* Halfway between text/base */
+
+ internal GdkColorStruct black;
+ internal GdkColorStruct white;
+
+ /* TODO: There is more stuff that we will add when we need it*/
+ }
+
+ private enum Desktop {
+ Gtk,
+ KDE,
+ Unknown
+ }
+ #endregion // Structs & Enums
+
+ #region Local Variables
+ static private Desktop desktop;
+ #endregion // Local Variables
+
+ #region Constructors
+ static X11DesktopColors() {
+ FindDesktopEnvironment();
+
+ switch(desktop) {
+ case Desktop.Gtk: {
+ //IntPtr dispmgr;
+ //IntPtr gdkdisplay;
+ IntPtr widget;
+ IntPtr style_ptr;
+ GtkStyleStruct style;
+ int argc = 0;
+ string argv = "";
+
+ try {
+ gtk_init_check (out argc, argv);
+ //dispmgr = gdk_display_manager_get ();
+ //gdkdisplay = gdk_display_manager_get_default_display (dispmgr);
+ gtk_init_check (out argc, argv);
+
+ widget = gtk_invisible_new ();
+ gtk_widget_ensure_style (widget);
+ style_ptr = gtk_widget_get_style (widget);
+
+ style = (GtkStyleStruct) Marshal.PtrToStructure (style_ptr, typeof (GtkStyleStruct));
+
+ ThemeEngine.Current.ColorControl = ColorFromGdkColor (style.bg[0]);
+ ThemeEngine.Current.ColorControlText = ColorFromGdkColor (style.fg[0]);
+ ThemeEngine.Current.ColorControlDark = ColorFromGdkColor (style.dark[0]);
+ ThemeEngine.Current.ColorControlLight = ColorFromGdkColor (style.light[0]);
+ ThemeEngine.Current.ColorControlLightLight = ControlPaint.Light(ColorFromGdkColor (style.light[0]));
+ ThemeEngine.Current.ColorControlDarkDark = ControlPaint.Dark(ColorFromGdkColor (style.dark[0]));
+
+ widget = gtk_menu_new ();
+ gtk_widget_ensure_style (widget);
+ style_ptr = gtk_widget_get_style (widget);
+
+ style = (GtkStyleStruct) Marshal.PtrToStructure (style_ptr, typeof (GtkStyleStruct));
+
+ ThemeEngine.Current.ColorMenu = ColorFromGdkColor (style.bg [0]);
+ ThemeEngine.Current.ColorMenuText = ColorFromGdkColor (style.text [0]);
+ Console.WriteLine("Gtk colorscheme read");
+ }
+
+ catch (DllNotFoundException) {
+ Console.WriteLine("Gtk not found (missing LD_LIBRARY_PATH to libgtk-x11-2.0.so?), using built-in colorscheme");
+ }
+
+ catch {
+ Console.WriteLine("Gtk colorscheme read failure, using built-in colorscheme");
+ }
+ break;
+ }
+
+ case Desktop.KDE: {
+ if ( ReadKDEColorsheme() )
+ Console.WriteLine("KDE colorscheme read");
+ else
+ Console.WriteLine("KDE colorscheme read failure, using built-in colorscheme");
+ break;
+ }
+
+ default: {
+ Console.WriteLine("Unknown desktop manager, using default colors");
+ break;
+ }
+ }
+ }
+ #endregion // Constructors
+
+ #region Properties
+ static void FindDesktopEnvironment() {
+ desktop = Desktop.Gtk;
+ string session = Environment.GetEnvironmentVariable("DESKTOP_SESSION");
+
+ if ( session != null ) {
+ session = session.ToUpper( );
+
+ if ( session == "DEFAULT" ) {
+ string helper = Environment.GetEnvironmentVariable("KDE_FULL_SESSION");
+
+ if ( helper != null )
+ desktop = Desktop.KDE;
+ } else
+ if ( session.StartsWith("KDE") )
+ desktop = Desktop.KDE;
+ }
+ }
+ #endregion // Properties
+
+ #region Methods
+ static internal void Initialize() {
+ // Do nothing; all is done in our static ctor
+ }
+
+ private static Color ColorFromGdkColor (GdkColorStruct gtkcolor) {
+ return Color.FromArgb (255,
+ (gtkcolor.red >> 8) & 0xff,
+ (gtkcolor.green >> 8) & 0xff,
+ (gtkcolor.blue >> 8) & 0xff );
+ }
+
+ private static bool ReadKDEColorsheme() {
+ string full_kdegloabals_filename = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
+ + "/"
+ + ".kde/share/config/kdeglobals";
+
+ if (!File.Exists(full_kdegloabals_filename))
+ return false;
+
+ StreamReader sr = new StreamReader(full_kdegloabals_filename);
+
+ string line = sr.ReadLine();
+
+ Color tmp_color;
+
+ while (line != null) {
+ line = line.Trim();
+
+ if (line.StartsWith( "background=")) {
+ tmp_color = GetColorFromKDEString(line);
+
+ if (tmp_color != Color.Empty) {
+ ThemeEngine.Current.ColorControl = tmp_color;
+ ThemeEngine.Current.ColorMenu = tmp_color;
+ }
+ } else
+ if (line.StartsWith( "foreground=")) {
+ tmp_color = GetColorFromKDEString(line);
+
+ if (tmp_color != Color.Empty) {
+ ThemeEngine.Current.ColorControlText = tmp_color;
+ ThemeEngine.Current.ColorMenuText = tmp_color;
+ }
+ } else
+ if (line.StartsWith("selectBackground")) {
+ tmp_color = GetColorFromKDEString(line);
+
+ if (tmp_color != Color.Empty) {
+ ThemeEngine.Current.ColorHighlight = tmp_color;
+ }
+ } else
+ if (line.StartsWith("selectForeground")) {
+ tmp_color = GetColorFromKDEString(line);
+
+ if (tmp_color != Color.Empty) {
+ ThemeEngine.Current.ColorHighlightText = tmp_color;
+ }
+ }
+
+ line = sr.ReadLine();
+ }
+
+ sr.Close();
+
+ return true;
+ }
+
+ private static Color GetColorFromKDEString(string line) {
+ string[] split = line.Split(new char[] {'='});
+
+ if (split.Length > 0) {
+ line = split[1];
+
+ split = line.Split(new char[] {','});
+
+ if (split.Length == 3) {
+ int r = System.Convert.ToInt32(split[0]);
+ int g = System.Convert.ToInt32(split[1]);
+ int b = System.Convert.ToInt32(split[2]);
+
+ return Color.FromArgb(r, g, b);
+ }
+ }
+
+ return Color.Empty;
+ }
+ #endregion // Methods
+
+ #region DllImports
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern bool gtk_init_check (out int argc, string argv);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ internal static extern IntPtr gdk_display_manager_get ();
+
+ [DllImport("libgdk-x11-2.0.so")]
+ internal static extern IntPtr gdk_display_manager_get_default_display (IntPtr display_manager);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern IntPtr gtk_invisible_new ();
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern IntPtr gtk_menu_new ();
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern IntPtr gtk_menu_item_new_with_label (string label);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern void gtk_widget_ensure_style (IntPtr raw);
+
+ [DllImport("libgtk-x11-2.0.so")]
+ static extern IntPtr gtk_widget_get_style (IntPtr raw);
+ #endregion // DllImports
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Dnd.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Dnd.cs
new file mode 100644
index 00000000000..5b21428086a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Dnd.cs
@@ -0,0 +1,1170 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+//
+//
+
+
+using System;
+using System.IO;
+using System.Text;
+using System.Drawing;
+using System.Collections;
+using System.Runtime.Serialization;
+using System.Runtime.InteropServices;
+using System.Runtime.Serialization.Formatters.Binary;
+
+namespace System.Windows.Forms {
+
+ internal class X11Dnd {
+
+ private enum State {
+ Accepting,
+ Dragging
+ }
+
+ private enum DragState {
+ None,
+ Beginning,
+ Dragging,
+ Entered
+ }
+
+ private interface IDataConverter {
+ void GetData (X11Dnd dnd, DataObject data, ref XEvent xevent);
+ void SetData (X11Dnd dnd, object data, ref XEvent xevent);
+ }
+
+ private delegate void MimeConverter (IntPtr dsp,
+ DataObject data, ref XEvent xevent);
+
+ private class MimeHandler {
+ public string Name;
+ public IntPtr Type;
+ public IntPtr NonProtocol;
+ public IDataConverter Converter;
+
+ public MimeHandler (string name, IDataConverter converter)
+ {
+ Name = name;
+ Converter = converter;
+ }
+
+ public override string ToString ()
+ {
+ return "MimeHandler {" + Name + "}";
+ }
+ }
+
+ private MimeHandler [] MimeHandlers = {
+// new MimeHandler ("WCF_DIB"),
+// new MimeHandler ("image/gif", new MimeConverter (ImageConverter)),
+// new MimeHandler ("text/rtf", new MimeConverter (RtfConverter)),
+// new MimeHandler ("text/richtext", new MimeConverter (RtfConverter)),
+
+ new MimeHandler ("text/plain", new TextConverter ()),
+ new MimeHandler ("text/html", new HtmlConverter ()),
+ new MimeHandler ("text/uri-list", new UriListConverter ()),
+ new MimeHandler ("application/x-mono-serialized-object",
+ new SerializedObjectConverter ())
+ };
+
+ private class SerializedObjectConverter : IDataConverter {
+
+ public void GetData (X11Dnd dnd, DataObject data, ref XEvent xevent)
+ {
+ MemoryStream stream = dnd.GetData (ref xevent);
+ BinaryFormatter bf = new BinaryFormatter ();
+
+ if (stream.Length == 0)
+ return;
+
+ stream.Seek (0, 0);
+ object obj = bf.Deserialize (stream);
+ data.SetData (obj);
+ }
+
+ public void SetData (X11Dnd dnd, object data, ref XEvent xevent)
+ {
+ if (data == null)
+ return;
+
+ MemoryStream stream = new MemoryStream ();
+ BinaryFormatter bf = new BinaryFormatter ();
+
+ bf.Serialize (stream, data);
+
+ IntPtr buffer = Marshal.AllocHGlobal ((int) stream.Length);
+ stream.Seek (0, 0);
+
+ for (int i = 0; i < stream.Length; i++) {
+ Marshal.WriteByte (buffer, i, (byte) stream.ReadByte ());
+ }
+
+ dnd.SetProperty (ref xevent, buffer, (int) stream.Length);
+ }
+ }
+
+ private class HtmlConverter : IDataConverter {
+
+ public void GetData (X11Dnd dnd, DataObject data, ref XEvent xevent)
+ {
+ string text = dnd.GetText (ref xevent, false);
+ if (text == null)
+ return;
+ data.SetData (DataFormats.Text, text);
+ data.SetData (DataFormats.UnicodeText, text);
+ }
+
+ public void SetData (X11Dnd dnd, object data, ref XEvent xevent)
+ {
+ IntPtr buffer;
+ int len;
+ string str = data as string;
+
+ if (str == null)
+ return;
+
+ if (xevent.SelectionRequestEvent.target == (IntPtr)Atom.XA_STRING) {
+ byte [] bytes = Encoding.ASCII.GetBytes (str);
+ buffer = Marshal.AllocHGlobal (bytes.Length);
+ len = bytes.Length;
+ for (int i = 0; i < len; i++)
+ Marshal.WriteByte (buffer, i, bytes [i]);
+ } else {
+ buffer = Marshal.StringToHGlobalAnsi (str);
+ len = 0;
+ while (Marshal.ReadByte (buffer, len) != 0)
+ len++;
+ }
+
+ dnd.SetProperty (ref xevent, buffer, len);
+
+ Marshal.FreeHGlobal (buffer);
+ }
+ }
+
+ private class TextConverter : IDataConverter {
+
+ public void GetData (X11Dnd dnd, DataObject data, ref XEvent xevent)
+ {
+ string text = dnd.GetText (ref xevent, true);
+ if (text == null)
+ return;
+ data.SetData (DataFormats.Text, text);
+ data.SetData (DataFormats.UnicodeText, text);
+ }
+
+ public void SetData (X11Dnd dnd, object data, ref XEvent xevent)
+ {
+ IntPtr buffer;
+ int len;
+ string str = data as string;
+
+ if (data == null)
+ return;
+
+ if (xevent.SelectionRequestEvent.target == (IntPtr)Atom.XA_STRING) {
+ byte [] bytes = Encoding.ASCII.GetBytes (str);
+ buffer = Marshal.AllocHGlobal (bytes.Length);
+ len = bytes.Length;
+ for (int i = 0; i < len; i++)
+ Marshal.WriteByte (buffer, i, bytes [i]);
+ } else {
+ buffer = Marshal.StringToHGlobalAnsi (str);
+ len = 0;
+ while (Marshal.ReadByte (buffer, len) != 0)
+ len++;
+ }
+
+ dnd.SetProperty (ref xevent, buffer, len);
+
+ Marshal.FreeHGlobal (buffer);
+ }
+ }
+
+ private class UriListConverter : IDataConverter {
+
+ public void GetData (X11Dnd dnd, DataObject data, ref XEvent xevent)
+ {
+ string text = dnd.GetText (ref xevent, false);
+ if (text == null)
+ return;
+
+ // TODO: Do this in a loop instead of just splitting
+ ArrayList uri_list = new ArrayList ();
+ string [] lines = text.Split (new char [] { '\r', '\n' });
+ foreach (string line in lines) {
+ // # is a comment line (see RFC 2483)
+ if (line.StartsWith ("#"))
+ continue;
+ try {
+ Uri uri = new Uri (line);
+ uri_list.Add (uri.LocalPath);
+ } catch { }
+ }
+
+ string [] l = (string []) uri_list.ToArray (typeof (string));
+ if (l.Length < 1)
+ return;
+ data.SetData (DataFormats.FileDrop, l);
+ data.SetData ("FileName", l [0]);
+ data.SetData ("FileNameW", l [0]);
+ }
+
+ public void SetData (X11Dnd dnd, object data, ref XEvent xevent)
+ {
+ string [] uri_list = data as string [];
+
+ if (uri_list == null)
+ return;
+
+ StringBuilder res = new StringBuilder ();
+ foreach (string uri_str in uri_list) {
+ Uri uri = new Uri (uri_str);
+ res.Append (uri.ToString ());
+ res.Append ("\r\n");
+ }
+
+ IntPtr buffer = Marshal.StringToHGlobalAnsi ((string) data);
+ int len = 0;
+ while (Marshal.ReadByte (buffer, len) != 0)
+ len++;
+
+ dnd.SetProperty (ref xevent, buffer, len);
+ }
+ }
+
+ private class DragData {
+ public IntPtr Window;
+ public DragState State;
+ public object Data;
+ public IntPtr Action;
+ public IntPtr [] SupportedTypes;
+ public MouseButtons MouseState;
+
+ public IntPtr LastWindow;
+ public IntPtr LastTopLevel;
+
+ public bool WillAccept;
+
+ public void Reset ()
+ {
+ State = DragState.None;
+ Data = null;
+ SupportedTypes = null;
+ WillAccept = false;
+ }
+ }
+
+ private class DropData {
+
+ }
+
+ // This version seems to be the most common
+ private static readonly IntPtr [] XdndVersion = new IntPtr [] { new IntPtr (4) };
+
+ private IntPtr display;
+ private DragData drag_data;
+
+ private IntPtr XdndAware;
+ private IntPtr XdndSelection;
+ private IntPtr XdndEnter;
+ private IntPtr XdndLeave;
+ private IntPtr XdndPosition;
+ private IntPtr XdndDrop;
+ private IntPtr XdndFinished;
+ private IntPtr XdndStatus;
+ private IntPtr XdndTypeList;
+ private IntPtr XdndActionCopy;
+ private IntPtr XdndActionMove;
+ private IntPtr XdndActionLink;
+ private IntPtr XdndActionPrivate;
+ private IntPtr XdndActionList;
+ private IntPtr XdndActionDescription;
+ private IntPtr XdndActionAsk;
+
+ private State state;
+
+ private int converts_pending;
+ private bool position_recieved;
+ private bool status_sent;
+ private IntPtr target;
+ private IntPtr source;
+ private IntPtr toplevel;
+ private DataObject data;
+
+ private IntPtr drag_action;
+ private Control control;
+ private int pos_x, pos_y;
+ private DragDropEffects allowed;
+ private DragEventArgs drag_event;
+
+ private Cursor CursorNo;
+ private Cursor CursorCopy;
+ private Cursor CursorMove;
+ private Cursor CursorLink;
+ private IntPtr CurrentCursorHandle;
+
+ public X11Dnd (IntPtr display)
+ {
+ this.display = display;
+ Init ();
+ }
+
+ public void SetAllowDrop (Hwnd hwnd, bool allow)
+ {
+ int[] atoms;
+
+ if (hwnd.allow_drop == allow)
+ return;
+
+ atoms = new int[XdndVersion.Length];
+ for (int i = 0; i < XdndVersion.Length; i++) {
+ atoms[i] = XdndVersion[i].ToInt32();
+ }
+
+ XplatUIX11.XChangeProperty (display, hwnd.whole_window, XdndAware,
+ (IntPtr) Atom.XA_ATOM, 32,
+ PropertyMode.Replace, atoms, allow ? 1 : 0);
+ hwnd.allow_drop = allow;
+ }
+
+ public DragDropEffects StartDrag (IntPtr handle, object data,
+ DragDropEffects allowed_effects)
+ {
+ drag_data = new DragData ();
+ drag_data.Window = handle;
+ drag_data.State = DragState.Beginning;
+ drag_data.MouseState = XplatUIX11.MouseState;
+ drag_data.Data = data;
+ drag_data.SupportedTypes = DetermineSupportedTypes (data);
+
+ drag_data.Action = ActionFromEffect (allowed_effects);
+
+ if (CursorNo == null) {
+ // Make sure the cursors are created
+ CursorNo = new Cursor (typeof (X11Dnd), "DnDNo.cur");
+ CursorCopy = new Cursor (typeof (X11Dnd), "DnDCopy.cur");
+ CursorMove = new Cursor (typeof (X11Dnd), "DnDMove.cur");
+ CursorLink = new Cursor (typeof (X11Dnd), "DnDLink.cur");
+ }
+
+ drag_data.LastTopLevel = IntPtr.Zero;
+ return DragDropEffects.Copy;
+ }
+
+ public void HandleButtonRelease (ref XEvent xevent)
+ {
+ if (drag_data == null)
+ return;
+
+ if (!((drag_data.MouseState == MouseButtons.Left &&
+ xevent.ButtonEvent.button == 1) ||
+ (drag_data.MouseState == MouseButtons.Right &&
+ xevent.ButtonEvent.button == 3)))
+ return;
+
+ if (drag_data.State == DragState.Beginning) {
+ state = State.Accepting;
+ } else if (drag_data.State != DragState.None) {
+
+ if (drag_data.WillAccept) {
+ SendDrop (drag_data.LastTopLevel, xevent.AnyEvent.window,
+ xevent.ButtonEvent.time);
+ }
+
+ XplatUIX11.XUngrabPointer (display, IntPtr.Zero);
+ drag_data.State = DragState.None;
+ // WE can't reset the drag data yet as it is still
+ // most likely going to be used by the SelectionRequest
+ // handlers
+ }
+ }
+
+ public bool HandleMotionNotify (ref XEvent xevent)
+ {
+ if (drag_data == null)
+ return false;
+
+ if (drag_data.State == DragState.Beginning) {
+ int suc;
+
+ drag_data.State = DragState.Dragging;
+
+ suc = XplatUIX11.XSetSelectionOwner (display, XdndSelection,
+ drag_data.Window,
+ xevent.ButtonEvent.time);
+
+ if (suc == 0) {
+ Console.Error.WriteLine ("Could not take ownership of XdndSelection aborting drag.");
+ drag_data.Reset ();
+ return false;
+ }
+
+ suc = XplatUIX11.XGrabPointer (display, xevent.AnyEvent.window,
+ false,
+ EventMask.ButtonMotionMask |
+ EventMask.PointerMotionMask |
+ EventMask.ButtonPressMask |
+ EventMask.ButtonReleaseMask,
+ GrabMode.GrabModeAsync,
+ GrabMode.GrabModeAsync,
+ IntPtr.Zero, IntPtr.Zero/*CursorCopy.Handle*/, IntPtr.Zero);
+
+ if (suc != 0) {
+ Console.Error.WriteLine ("Could not grab pointer aborting drag.");
+ drag_data.Reset ();
+ return false;
+ }
+
+ drag_data.State = DragState.Dragging;
+ } else if (drag_data.State != DragState.None) {
+ bool dnd_aware = false;
+ IntPtr toplevel = IntPtr.Zero;
+ IntPtr window = XplatUIX11.RootWindowHandle;
+
+ IntPtr root, child;
+ int x_temp, y_temp;
+ int mask_return;
+
+ while (XplatUIX11.XQueryPointer (display,
+ window,
+ out root, out child,
+ out x_temp, out y_temp,
+ out xevent.MotionEvent.x,
+ out xevent.MotionEvent.y,
+ out mask_return)) {
+
+ if (!dnd_aware) {
+ dnd_aware = IsWindowDndAware (window);
+ if (dnd_aware) {
+ toplevel = window;
+ xevent.MotionEvent.x_root = x_temp;
+ xevent.MotionEvent.y_root = y_temp;
+ }
+ }
+
+ if (child == IntPtr.Zero)
+ break;
+
+ window = child;
+ }
+
+ if (window != drag_data.LastWindow && drag_data.State == DragState.Entered) {
+ drag_data.State = DragState.Dragging;
+
+ // TODO: Send a Leave if this is an MWF window
+
+ if (toplevel != drag_data.LastTopLevel)
+ SendLeave (drag_data.LastTopLevel, xevent.MotionEvent.window);
+ }
+
+ drag_data.State = DragState.Entered;
+ if (toplevel != drag_data.LastTopLevel) {
+ // Entering a new toplevel window
+ SendEnter (toplevel, drag_data.Window, drag_data.SupportedTypes);
+ } else {
+ // Already in a toplevel window, so send a position
+ SendPosition (toplevel, drag_data.Window,
+ drag_data.Action,
+ xevent.MotionEvent.x_root,
+ xevent.MotionEvent.y_root,
+ xevent.MotionEvent.time);
+ }
+
+ drag_data.LastTopLevel = toplevel;
+ drag_data.LastWindow = window;
+ return true;
+ }
+ return false;
+ }
+
+ // DEBUG CODE REMOVE
+ private string GetText (IntPtr handle) {
+ string text = String.Empty;
+ IntPtr textptr;
+
+ textptr = IntPtr.Zero;
+
+ XplatUIX11.XFetchName (display, handle, ref textptr);
+ if (textptr != IntPtr.Zero) {
+ text = Marshal.PtrToStringAnsi(textptr);
+ XplatUIX11.XFree (textptr);
+ }
+
+ return text;
+ }
+
+
+ // return true if the event is handled here
+ public bool HandleClientMessage (ref XEvent xevent)
+ {
+ // most common so we check it first
+ if (xevent.ClientMessageEvent.message_type == XdndPosition)
+ return Accepting_HandlePositionEvent (ref xevent);
+ if (xevent.ClientMessageEvent.message_type == XdndEnter)
+ return Accepting_HandleEnterEvent (ref xevent);
+ if (xevent.ClientMessageEvent.message_type == XdndDrop)
+ return Accepting_HandleDropEvent (ref xevent);
+ if (xevent.ClientMessageEvent.message_type == XdndLeave)
+ return Accepting_HandleLeaveEvent (ref xevent);
+ if (xevent.ClientMessageEvent.message_type == XdndStatus)
+ return HandleStatusEvent (ref xevent);
+
+ return false;
+ }
+
+ public bool HandleSelectionNotifyEvent (ref XEvent xevent)
+ {
+ if (source != XplatUIX11.XGetSelectionOwner (display, XdndSelection))
+ return false;
+
+ MimeHandler handler = FindHandler ((IntPtr) xevent.SelectionEvent.target);
+ if (handler == null)
+ return false;
+ if (data == null)
+ data = new DataObject ();
+
+ handler.Converter.GetData (this, data, ref xevent);
+
+ converts_pending--;
+ if (converts_pending <= 0 && position_recieved) {
+ drag_event = new DragEventArgs (data, 0, pos_x, pos_y,
+ allowed, DragDropEffects.None);
+ control.DndEnter (drag_event);
+ SendStatus (source, drag_event.Effect);
+ status_sent = true;
+ }
+ return true;
+ }
+
+ public bool HandleSelectionRequestEvent (ref XEvent xevent)
+ {
+ if (xevent.SelectionRequestEvent.selection != XdndSelection)
+ return false;
+
+ MimeHandler handler = FindHandler (xevent.SelectionRequestEvent.target);
+ if (handler == null)
+ return false;
+
+ handler.Converter.SetData (this, drag_data.Data, ref xevent);
+
+ return true;
+ }
+
+ private void SetProperty (ref XEvent xevent, IntPtr data, int length)
+ {
+ XEvent sel = new XEvent();
+ sel.SelectionEvent.type = XEventName.SelectionNotify;
+ sel.SelectionEvent.send_event = true;
+ sel.SelectionEvent.display = display;
+ sel.SelectionEvent.selection = xevent.SelectionRequestEvent.selection;
+ sel.SelectionEvent.target = xevent.SelectionRequestEvent.target;
+ sel.SelectionEvent.requestor = xevent.SelectionRequestEvent.requestor;
+ sel.SelectionEvent.time = xevent.SelectionRequestEvent.time;
+ sel.SelectionEvent.property = IntPtr.Zero;
+
+ XplatUIX11.XChangeProperty (display, xevent.SelectionRequestEvent.requestor,
+ xevent.SelectionRequestEvent.property,
+ xevent.SelectionRequestEvent.target,
+ 8, PropertyMode.Replace, data, length);
+ sel.SelectionEvent.property = xevent.SelectionRequestEvent.property;
+
+ XplatUIX11.XSendEvent (display, xevent.SelectionRequestEvent.requestor, false,
+ (IntPtr)EventMask.NoEventMask, ref sel);
+ return;
+ }
+
+ private void Reset ()
+ {
+ ResetSourceData ();
+ ResetTargetData ();
+ }
+
+ private void ResetSourceData ()
+ {
+ converts_pending = 0;
+ data = null;
+ }
+
+ private void ResetTargetData ()
+ {
+ position_recieved = false;
+ status_sent = false;
+ }
+
+ private bool Accepting_HandleEnterEvent (ref XEvent xevent)
+ {
+ Reset ();
+
+ source = xevent.ClientMessageEvent.ptr1;
+ toplevel = xevent.AnyEvent.window;
+ target = IntPtr.Zero;
+
+ ConvertData (ref xevent);
+
+ return true;
+ }
+
+ private bool Accepting_HandlePositionEvent (ref XEvent xevent)
+ {
+ pos_x = (int) xevent.ClientMessageEvent.ptr3 >> 16;
+ pos_y = (int) xevent.ClientMessageEvent.ptr3 & 0xFFFF;
+
+ allowed = EffectFromAction (xevent.ClientMessageEvent.ptr5);
+
+ IntPtr parent, child, new_child;
+ parent = XplatUIX11.XRootWindow (display, 0);
+ child = toplevel;
+ while (true) {
+ int xd, yd;
+ new_child = IntPtr.Zero;
+
+ if (!XplatUIX11.XTranslateCoordinates (display,
+ parent, child, pos_x, pos_y,
+ out xd, out yd, out new_child))
+ break;
+ if (new_child == IntPtr.Zero)
+ break;
+ child = new_child;
+ }
+
+ if (target != child) {
+ // We have moved into a new control
+ // or into a control for the first time
+ Finish ();
+ }
+ target = child;
+ Hwnd hwnd = Hwnd.ObjectFromHandle (target);
+ Control c = Control.FromHandle (hwnd.client_window);
+
+ if (c == null)
+ return true;
+ if (!c.allow_drop) {
+ SendStatus (source, DragDropEffects.None);
+ Finish ();
+ return true;
+ }
+
+ control = c;
+ position_recieved = true;
+
+ if (converts_pending > 0)
+ return true;
+ if (!status_sent) {
+ drag_event = new DragEventArgs (data, 0, pos_x, pos_y,
+ allowed, DragDropEffects.None);
+ control.DndEnter (drag_event);
+ SendStatus (source, drag_event.Effect);
+ status_sent = true;
+ } else {
+ drag_event.x = pos_x;
+ drag_event.y = pos_y;
+ SendStatus (source, drag_event.Effect);
+ control.DndOver (drag_event);
+ }
+
+ return true;
+ }
+
+ private void Finish ()
+ {
+ if (control != null) {
+ if (drag_event == null) {
+ if (data == null)
+ data = new DataObject ();
+ drag_event = new DragEventArgs (data,
+ 0, pos_x, pos_y,
+ allowed, DragDropEffects.None);
+ }
+ control.DndLeave (drag_event);
+ }
+ ResetTargetData ();
+ }
+
+ private bool Accepting_HandleDropEvent (ref XEvent xevent)
+ {
+ if (control != null && drag_event != null) {
+ drag_event = new DragEventArgs (data,
+ 0, pos_x, pos_y,
+ allowed, DragDropEffects.None);
+ control.DndDrop (drag_event);
+ }
+ SendFinished ();
+ return true;
+ }
+
+ private bool Accepting_HandleLeaveEvent (ref XEvent xevent)
+ {
+ if (control != null && drag_event != null)
+ control.DndLeave (drag_event);
+ // Reset ();
+ return true;
+ }
+
+ private bool HandleStatusEvent (ref XEvent xevent)
+ {
+ if (drag_data != null && drag_data.State == DragState.Entered) {
+ drag_data.WillAccept = ((int) xevent.ClientMessageEvent.ptr2 & 0x1) != 0;
+ Cursor cursor = CursorNo;
+ if (drag_data.WillAccept) {
+ // Same order as on MS
+ IntPtr action = xevent.ClientMessageEvent.ptr5;
+ if (action == XdndActionCopy)
+ cursor = CursorCopy;
+ else if (action == XdndActionLink)
+ cursor = CursorLink;
+ else if (action == XdndActionMove)
+ cursor = CursorMove;
+
+ }
+
+ // TODO: Try not to set the cursor so much
+ //if (cursor.Handle != CurrentCursorHandle) {
+ XplatUIX11.XChangeActivePointerGrab (display,
+ EventMask.ButtonMotionMask |
+ EventMask.PointerMotionMask |
+ EventMask.ButtonPressMask |
+ EventMask.ButtonReleaseMask,
+ cursor.Handle, IntPtr.Zero);
+ CurrentCursorHandle = cursor.Handle;
+ //}
+ }
+ return true;
+ }
+
+ private DragDropEffects EffectFromAction (IntPtr action)
+ {
+ DragDropEffects allowed = DragDropEffects.None;
+
+ if (action == XdndActionCopy)
+ allowed = DragDropEffects.Copy;
+ else if (action == XdndActionMove)
+ allowed |= DragDropEffects.Move;
+ if (action == XdndActionLink)
+ allowed |= DragDropEffects.Link;
+ return allowed;
+ }
+
+ private IntPtr ActionFromEffect (DragDropEffects effect)
+ {
+ IntPtr action = IntPtr.Zero;
+
+ // We can't OR together actions on XDND so sadly the primary
+ // is the only one shown here
+ if ((effect & DragDropEffects.Copy) != 0)
+ action = XdndActionCopy;
+ else if ((effect & DragDropEffects.Move) != 0)
+ action = XdndActionMove;
+ else if ((effect & DragDropEffects.Link) != 0)
+ action = XdndActionLink;
+ return action;
+ }
+
+ private bool ConvertData (ref XEvent xevent)
+ {
+ bool match = false;
+
+ if (source != XplatUIX11.XGetSelectionOwner (display, XdndSelection)) {
+ return false;
+ }
+
+ Control mwfcontrol = MwfWindow (source);
+
+ if (mwfcontrol != null && drag_data != null) {
+ DataObject dragged = drag_data.Data as DataObject;
+ if (dragged != null) {
+ data = dragged;
+ } else {
+ if (data == null)
+ data = new DataObject ();
+ SetDataWithFormats (drag_data.Data);
+ }
+ return true;
+ }
+
+ foreach (IntPtr atom in SourceSupportedList (ref xevent)) {
+ MimeHandler handler = FindHandler (atom);
+ if (handler == null)
+ continue;
+ XplatUIX11.XConvertSelection (display, XdndSelection, handler.Type,
+ handler.NonProtocol, toplevel, IntPtr.Zero /* CurrentTime */);
+ converts_pending++;
+ match = true;
+ }
+ return match;
+ }
+
+ private void SetDataWithFormats (object value)
+ {
+ if (value is string) {
+ data.SetData (DataFormats.Text, value);
+ data.SetData (DataFormats.UnicodeText, value);
+ }
+
+ data.SetData (value);
+ }
+
+ private MimeHandler FindHandler (IntPtr atom)
+ {
+ if (atom == IntPtr.Zero)
+ return null;
+ foreach (MimeHandler handler in MimeHandlers) {
+ if (handler.Type == atom)
+ return handler;
+ }
+ return null;
+ }
+
+ private MimeHandler FindHandler (string name)
+ {
+ foreach (MimeHandler handler in MimeHandlers) {
+ if (handler.Name == name)
+ return handler;
+ }
+ return null;
+ }
+
+ private void SendStatus (IntPtr source, DragDropEffects effect)
+ {
+ XEvent xevent = new XEvent ();
+
+ xevent.AnyEvent.type = XEventName.ClientMessage;
+ xevent.AnyEvent.display = display;
+ xevent.ClientMessageEvent.window = source;
+ xevent.ClientMessageEvent.message_type = XdndStatus;
+ xevent.ClientMessageEvent.format = 32;
+ xevent.ClientMessageEvent.ptr1 = toplevel;
+ if (effect != DragDropEffects.None)
+ xevent.ClientMessageEvent.ptr2 = (IntPtr) 1;
+
+ xevent.ClientMessageEvent.ptr5 = ActionFromEffect (effect);
+ XplatUIX11.XSendEvent (display, source, false, IntPtr.Zero, ref xevent);
+ }
+
+ private void SendEnter (IntPtr handle, IntPtr from, IntPtr [] supported)
+ {
+ XEvent xevent = new XEvent ();
+
+ xevent.AnyEvent.type = XEventName.ClientMessage;
+ xevent.AnyEvent.display = display;
+ xevent.ClientMessageEvent.window = handle;
+ xevent.ClientMessageEvent.message_type = XdndEnter;
+ xevent.ClientMessageEvent.format = 32;
+ xevent.ClientMessageEvent.ptr1 = from;
+
+ // (int) xevent.ClientMessageEvent.ptr2 & 0x1)
+ // int ptr2 = 0x1;
+ // xevent.ClientMessageEvent.ptr2 = (IntPtr) ptr2;
+ // (e)->xclient.data.l[1] = ((e)->xclient.data.l[1] & ~(0xFF << 24)) | ((v) << 24)
+ xevent.ClientMessageEvent.ptr2 = (IntPtr) ((long)XdndVersion [0] << 24);
+
+ if (supported.Length > 0)
+ xevent.ClientMessageEvent.ptr3 = supported [0];
+ if (supported.Length > 1)
+ xevent.ClientMessageEvent.ptr4 = supported [1];
+ if (supported.Length > 2)
+ xevent.ClientMessageEvent.ptr5 = supported [2];
+
+ XplatUIX11.XSendEvent (display, handle, false, IntPtr.Zero, ref xevent);
+ }
+
+ private void SendDrop (IntPtr handle, IntPtr from, IntPtr time)
+ {
+ XEvent xevent = new XEvent ();
+
+ xevent.AnyEvent.type = XEventName.ClientMessage;
+ xevent.AnyEvent.display = display;
+ xevent.ClientMessageEvent.window = handle;
+ xevent.ClientMessageEvent.message_type = XdndDrop;
+ xevent.ClientMessageEvent.format = 32;
+ xevent.ClientMessageEvent.ptr1 = from;
+ xevent.ClientMessageEvent.ptr3 = time;
+
+ XplatUIX11.XSendEvent (display, handle, false, IntPtr.Zero, ref xevent);
+ }
+
+ private void SendPosition (IntPtr handle, IntPtr from, IntPtr action, int x, int y, IntPtr time)
+ {
+ XEvent xevent = new XEvent ();
+
+ xevent.AnyEvent.type = XEventName.ClientMessage;
+ xevent.AnyEvent.display = display;
+ xevent.ClientMessageEvent.window = handle;
+ xevent.ClientMessageEvent.message_type = XdndPosition;
+ xevent.ClientMessageEvent.format = 32;
+ xevent.ClientMessageEvent.ptr1 = from;
+ xevent.ClientMessageEvent.ptr3 = (IntPtr) ((x << 16) | (y & 0xFFFF));
+ xevent.ClientMessageEvent.ptr4 = time;
+ xevent.ClientMessageEvent.ptr5 = action;
+
+ XplatUIX11.XSendEvent (display, handle, false, IntPtr.Zero, ref xevent);
+ }
+
+ private void SendLeave (IntPtr handle, IntPtr from)
+ {
+ XEvent xevent = new XEvent ();
+
+ xevent.AnyEvent.type = XEventName.ClientMessage;
+ xevent.AnyEvent.display = display;
+ xevent.ClientMessageEvent.window = handle;
+ xevent.ClientMessageEvent.message_type = XdndLeave;
+ xevent.ClientMessageEvent.format = 32;
+ xevent.ClientMessageEvent.ptr1 = from;
+
+ XplatUIX11.XSendEvent (display, handle, false, IntPtr.Zero, ref xevent);
+ }
+
+ private void SendFinished ()
+ {
+ XEvent xevent = new XEvent ();
+
+ xevent.AnyEvent.type = XEventName.ClientMessage;
+ xevent.AnyEvent.display = display;
+ xevent.ClientMessageEvent.window = source;
+ xevent.ClientMessageEvent.message_type = XdndFinished;
+ xevent.ClientMessageEvent.format = 32;
+ xevent.ClientMessageEvent.ptr1 = toplevel;
+
+ XplatUIX11.XSendEvent (display, source, false, IntPtr.Zero, ref xevent);
+ }
+
+ // There is a somewhat decent amount of overhead
+ // involved in setting up dnd so we do it lazily
+ // as a lot of applications do not even use it.
+ private void Init ()
+ {
+ XdndAware = XplatUIX11.XInternAtom (display, "XdndAware", false);
+ XdndEnter = XplatUIX11.XInternAtom (display, "XdndEnter", false);
+ XdndLeave = XplatUIX11.XInternAtom (display, "XdndLeave", false);
+ XdndPosition = XplatUIX11.XInternAtom (display, "XdndPosition", false);
+ XdndStatus = XplatUIX11.XInternAtom (display, "XdndStatus", false);
+ XdndDrop = XplatUIX11.XInternAtom (display, "XdndDrop", false);
+ XdndSelection = XplatUIX11.XInternAtom (display, "XdndSelection", false);
+ XdndFinished = XplatUIX11.XInternAtom (display, "XdndFinished", false);
+ XdndTypeList = XplatUIX11.XInternAtom (display, "XdndTypeList", false);
+ XdndActionCopy = XplatUIX11.XInternAtom (display, "XdndActionCopy", false);
+ XdndActionMove = XplatUIX11.XInternAtom (display, "XdndActionMove", false);
+ XdndActionLink = XplatUIX11.XInternAtom (display, "XdndActionLink", false);
+ XdndActionPrivate = XplatUIX11.XInternAtom (display, "XdndActionPrivate", false);
+ XdndActionList = XplatUIX11.XInternAtom (display, "XdndActionList", false);
+ XdndActionDescription = XplatUIX11.XInternAtom (display, "XdndActionDescription", false);
+ XdndActionAsk = XplatUIX11.XInternAtom (display, "XdndActionAsk", false);
+
+ foreach (MimeHandler handler in MimeHandlers) {
+ handler.Type = XplatUIX11.XInternAtom (display, handler.Name, false);
+ handler.NonProtocol = XplatUIX11.XInternAtom (display,
+ String.Concat ("MWFNonP+", handler.Name), false);
+ }
+
+ }
+
+ private IntPtr [] SourceSupportedList (ref XEvent xevent)
+ {
+ IntPtr [] res;
+
+
+ if (((int) xevent.ClientMessageEvent.ptr2 & 0x1) == 0) {
+ res = new IntPtr [3];
+ res [0] = xevent.ClientMessageEvent.ptr3;
+ res [1] = xevent.ClientMessageEvent.ptr4;
+ res [2] = xevent.ClientMessageEvent.ptr5;
+ } else {
+ IntPtr type;
+ int format;
+ IntPtr count;
+ IntPtr remaining;
+ IntPtr data = IntPtr.Zero;
+
+ XplatUIX11.XGetWindowProperty (display, source, XdndTypeList,
+ IntPtr.Zero, new IntPtr(32), false, (IntPtr) Atom.XA_ATOM,
+ out type, out format, out count,
+ out remaining, ref data);
+
+ res = new IntPtr [count.ToInt32()];
+ for (int i = 0; i < count.ToInt32(); i++) {
+ res [i] = (IntPtr) Marshal.ReadInt32 (data, i *
+ Marshal.SizeOf (typeof (int)));
+ }
+
+ XplatUIX11.XFree (data);
+ }
+
+ return res;
+ }
+
+ private string GetText (ref XEvent xevent, bool unicode)
+ {
+ int nread = 0;
+ IntPtr nitems;
+ IntPtr bytes_after;
+
+ StringBuilder builder = new StringBuilder ();
+ do {
+ IntPtr actual_type;
+ int actual_fmt;
+ IntPtr data = IntPtr.Zero;
+
+ if (0 != XplatUIX11.XGetWindowProperty (display,
+ xevent.AnyEvent.window,
+ (IntPtr) xevent.SelectionEvent.property,
+ IntPtr.Zero, new IntPtr(0xffffff), false,
+ (IntPtr) Atom.AnyPropertyType, out actual_type,
+ out actual_fmt, out nitems, out bytes_after,
+ ref data)) {
+ XplatUIX11.XFree (data);
+ break;
+ }
+
+ if (unicode)
+ builder.Append (Marshal.PtrToStringUni (data));
+ else
+ builder.Append (Marshal.PtrToStringAnsi (data));
+ nread += nitems.ToInt32();
+
+ XplatUIX11.XFree (data);
+ } while (bytes_after.ToInt32() > 0);
+ if (nread == 0)
+ return null;
+ return builder.ToString ();
+ }
+
+ private MemoryStream GetData (ref XEvent xevent)
+ {
+ int nread = 0;
+ IntPtr nitems;
+ IntPtr bytes_after;
+
+ MemoryStream res = new MemoryStream ();
+ do {
+ IntPtr actual_type;
+ int actual_fmt;
+ IntPtr data = IntPtr.Zero;
+
+ if (0 != XplatUIX11.XGetWindowProperty (display,
+ xevent.AnyEvent.window,
+ (IntPtr) xevent.SelectionEvent.property,
+ IntPtr.Zero, new IntPtr(0xffffff), false,
+ (IntPtr) Atom.AnyPropertyType, out actual_type,
+ out actual_fmt, out nitems, out bytes_after,
+ ref data)) {
+ XplatUIX11.XFree (data);
+ break;
+ }
+
+ for (int i = 0; i < nitems.ToInt32(); i++)
+ res.WriteByte (Marshal.ReadByte (data, i));
+ nread += nitems.ToInt32();
+
+ XplatUIX11.XFree (data);
+ } while (bytes_after.ToInt32() > 0);
+ return res;
+ }
+
+ private Control MwfWindow (IntPtr window)
+ {
+ Hwnd hwnd = Hwnd.ObjectFromHandle (window);
+ if (hwnd == null)
+ return null;
+
+ Control res = Control.FromHandle (hwnd.client_window);
+ return res;
+ }
+
+ private bool IsWindowDndAware (IntPtr handle)
+ {
+ bool res = true;
+ // Check the version number, we need greater than 3
+ IntPtr actual;
+ int format;
+ IntPtr count;
+ IntPtr remaining;
+ IntPtr data = IntPtr.Zero;
+
+ XplatUIX11.XGetWindowProperty (display, handle, XdndAware, IntPtr.Zero, new IntPtr(0x8000000), false,
+ (IntPtr) Atom.XA_ATOM, out actual, out format,
+ out count, out remaining, ref data);
+
+ if (actual != (IntPtr) Atom.XA_ATOM || format != 32 ||
+ count.ToInt32() == 0 || data == IntPtr.Zero) {
+ if (data != IntPtr.Zero)
+ XplatUIX11.XFree (data);
+ return false;
+ }
+
+ int version = Marshal.ReadInt32 (data, 0);
+
+ if (version < 3) {
+ Console.Error.WriteLine ("XDND Version too old (" + version + ").");
+ XplatUIX11.XFree (data);
+ return false;
+ }
+
+ // First type is actually the XDND version
+ if (count.ToInt32() > 1) {
+ res = false;
+ for (int i = 1; i < count.ToInt32(); i++) {
+ IntPtr type = (IntPtr) Marshal.ReadInt32 (data, i *
+ Marshal.SizeOf (typeof (int)));
+ for (int j = 0; j < drag_data.SupportedTypes.Length; j++) {
+ if (drag_data.SupportedTypes [j] == type) {
+ res = true;
+ break;
+ }
+ }
+ }
+ }
+
+ XplatUIX11.XFree (data);
+ return res;
+ }
+
+ private IntPtr [] DetermineSupportedTypes (object data)
+ {
+ ArrayList res = new ArrayList ();
+
+ if (data is string) {
+ MimeHandler handler = FindHandler ("text/plain");
+ if (handler != null)
+ res.Add (handler.Type);
+ }/* else if (data is Bitmap)
+ res.Add (data);
+
+ */
+
+ if (data is IDataObject) {
+
+
+ }
+
+ if (data is ISerializable) {
+ MimeHandler handler = FindHandler ("application/x-mono-serialized-object");
+ if (handler != null)
+ res.Add (handler.Type);
+ }
+
+ return (IntPtr []) res.ToArray (typeof (IntPtr));
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Keyboard.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Keyboard.cs
new file mode 100644
index 00000000000..f42d85061b6
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Keyboard.cs
@@ -0,0 +1,838 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+//
+//
+
+
+//
+// TODO:
+// - dead chars are not translated properly
+// - There is a lot of potential for optimmization in here
+//
+using System;
+using System.Collections;
+using System.Text;
+using System.Globalization;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+
+ internal class X11Keyboard {
+
+ private IntPtr display;
+ private IntPtr xim;
+ private IntPtr xic;
+ private StringBuilder lookup_buffer;
+ private int min_keycode, max_keycode, keysyms_per_keycode, syms;
+ private int [] keyc2vkey = new int [256];
+ private int [] keyc2scan = new int [256];
+ private byte [] key_state_table = new byte [256];
+ private bool num_state, cap_state;
+ private KeyboardLayout layout;
+
+ // TODO
+ private int NumLockMask;
+ private int AltGrMask;
+
+ public X11Keyboard (IntPtr display, IntPtr window)
+ {
+ this.display = display;
+ lookup_buffer = new StringBuilder (24);
+
+ KeyboardLayouts layouts = new KeyboardLayouts ();
+ layout = layouts.Layouts [0];
+ DetectLayout (layouts);
+ CreateConversionArray (layouts, layout);
+
+ if (!XSupportsLocale ()) {
+ Console.Error.WriteLine ("X does not support your locale");
+ }
+
+ if (!XSetLocaleModifiers (String.Empty)) {
+ Console.Error.WriteLine ("Could not set X locale modifiers");
+ }
+
+ xim = XOpenIM (display, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
+ if (xim == IntPtr.Zero) {
+ Console.Error.WriteLine ("Could not get XIM");
+ }
+
+ xic = CreateXic (window);
+ }
+
+ public Keys ModifierKeys {
+ get {
+ Keys keys = Keys.None;
+ if ((key_state_table [(int) VirtualKeys.VK_SHIFT] & 0x80) != 0)
+ keys |= Keys.Shift;
+ if ((key_state_table [(int) VirtualKeys.VK_CONTROL] & 0x80) != 0)
+ keys |= Keys.Control;
+ if ((key_state_table [(int) VirtualKeys.VK_MENU] & 0x80) != 0)
+ keys |= Keys.Alt;
+ return keys;
+ }
+ }
+
+ public void FocusIn (IntPtr focus_window)
+ {
+ if (xic != IntPtr.Zero)
+ XSetICFocus (xic);
+ }
+
+ public void FocusOut (IntPtr focus_window)
+ {
+ if (xic != IntPtr.Zero)
+ XUnsetICFocus (xic);
+ }
+
+ public bool ResetKeyState(IntPtr hwnd, ref MSG msg) {
+ // FIXME - keep defining events/msg and return true until we've 'restored' all
+ // pending keypresses
+ if ((key_state_table [(int) VirtualKeys.VK_SHIFT] & 0x80) != 0) {
+ key_state_table [(int) VirtualKeys.VK_SHIFT] &= unchecked((byte)~0x80);
+ }
+
+ if ((key_state_table [(int) VirtualKeys.VK_CONTROL] & 0x80) != 0) {
+ key_state_table [(int) VirtualKeys.VK_CONTROL] &= unchecked((byte)~0x80);
+ }
+
+ if ((key_state_table [(int) VirtualKeys.VK_MENU] & 0x80) != 0) {
+ key_state_table [(int) VirtualKeys.VK_MENU] &= unchecked((byte)~0x80);
+ }
+ return false;
+ }
+
+ public void KeyEvent (IntPtr hwnd, XEvent xevent, ref MSG msg)
+ {
+ XKeySym keysym;
+ int ascii_chars;
+
+ IntPtr status = IntPtr.Zero;
+ ascii_chars = LookupString (ref xevent, 24, out keysym, out status);
+
+ if (((int) keysym >= (int) MiscKeys.XK_ISO_Lock &&
+ (int) keysym <= (int) MiscKeys.XK_ISO_Last_Group_Lock) ||
+ (int) keysym == (int) MiscKeys.XK_Mode_switch) {
+ UpdateKeyState (xevent);
+ return;
+ }
+
+ if ((xevent.KeyEvent.keycode >> 8) == 0x10)
+ xevent.KeyEvent.keycode = xevent.KeyEvent.keycode & 0xFF;
+
+ int event_time = (int)xevent.KeyEvent.time;
+
+ if (status == (IntPtr) 2) {
+ // Copy chars into a globally accessible var, i don't think
+ // this var is exposed anywhere though, so we can just ignore this
+ return;
+ }
+
+ AltGrMask = xevent.KeyEvent.state & (0x6000 | (int) KeyMasks.ModMasks);
+ int vkey = EventToVkey (xevent);
+ if (vkey == 0 && ascii_chars != 0) {
+ vkey = (int) VirtualKeys.VK_NONAME;
+ }
+
+ switch ((VirtualKeys) (vkey & 0xFF)) {
+ case VirtualKeys.VK_NUMLOCK:
+ GenerateMessage (VirtualKeys.VK_NUMLOCK, 0x45, xevent.type, event_time);
+ break;
+ case VirtualKeys.VK_CAPITAL:
+ GenerateMessage (VirtualKeys.VK_CAPITAL, 0x3A, xevent.type, event_time);
+ break;
+ default:
+ if (((key_state_table [(int) VirtualKeys.VK_NUMLOCK] & 0x01) == 0) != ((xevent.KeyEvent.state & NumLockMask) == 0)) {
+ GenerateMessage (VirtualKeys.VK_NUMLOCK, 0x45, XEventName.KeyPress, event_time);
+ GenerateMessage (VirtualKeys.VK_NUMLOCK, 0x45, XEventName.KeyRelease, event_time);
+ }
+
+ if (((key_state_table [(int) VirtualKeys.VK_CAPITAL] & 0x01) == 0) != ((xevent.KeyEvent.state & (int) KeyMasks.LockMask) == 0)) {
+ GenerateMessage (VirtualKeys.VK_CAPITAL, 0x3A, XEventName.KeyPress, event_time);
+ GenerateMessage (VirtualKeys.VK_CAPITAL, 0x3A, XEventName.KeyRelease, event_time);
+ }
+
+ num_state = false;
+ cap_state = false;
+
+ int bscan = (keyc2scan [xevent.KeyEvent.keycode] & 0xFF);
+ KeybdEventFlags dw_flags = KeybdEventFlags.None;
+ if (xevent.type == XEventName.KeyRelease)
+ dw_flags |= KeybdEventFlags.KeyUp;
+ if ((vkey & 0x100) != 0)
+ dw_flags |= KeybdEventFlags.ExtendedKey;
+ msg = SendKeyboardInput ((VirtualKeys) (vkey & 0xFF), bscan, dw_flags, event_time);
+ msg.hwnd = hwnd;
+ break;
+ }
+ }
+
+ public bool TranslateMessage (ref MSG msg)
+ {
+ bool res = false;
+
+ if (msg.message >= Msg.WM_KEYFIRST && msg.message <= Msg.WM_KEYLAST)
+ res = true;
+
+ if (msg.message != Msg.WM_KEYDOWN && msg.message != Msg.WM_SYSKEYDOWN)
+ return res;
+
+ string buffer;
+ Msg message;
+ int tu = ToUnicode ((int) msg.wParam, Control.HighOrder ((int) msg.lParam), out buffer);
+ switch (tu) {
+ case 1:
+ message = (msg.message == Msg.WM_KEYDOWN ? Msg.WM_CHAR : Msg.WM_SYSCHAR);
+ XplatUI.PostMessage (msg.hwnd, message, (IntPtr) buffer [0], msg.lParam);
+ break;
+ case -1:
+ message = (msg.message == Msg.WM_KEYDOWN ? Msg.WM_DEADCHAR : Msg.WM_SYSDEADCHAR);
+ XplatUI.PostMessage (msg.hwnd, message, (IntPtr) buffer [0], msg.lParam);
+ return true;
+ }
+
+ return res;
+ }
+
+ private int ToUnicode (int vkey, int scan, out string buffer)
+ {
+ if ((scan & 0x8000) != 0) {
+ buffer = String.Empty;
+ return 0;
+ }
+
+ XEvent e = new XEvent ();
+ e.AnyEvent.type = XEventName.KeyPress;
+ e.KeyEvent.display = display;
+ e.KeyEvent.keycode = 0;
+ e.KeyEvent.state = 0;
+
+ if ((key_state_table [(int) VirtualKeys.VK_SHIFT] & 0x80) != 0) {
+ e.KeyEvent.state |= (int) KeyMasks.ShiftMask;
+ }
+
+ if ((key_state_table [(int) VirtualKeys.VK_CAPITAL] & 0x01) != 0) {
+ e.KeyEvent.state |= (int) KeyMasks.LockMask;
+ }
+
+ if ((key_state_table [(int) VirtualKeys.VK_CONTROL] & 0x80) != 0) {
+ e.KeyEvent.state |= (int) KeyMasks.ControlMask;
+ }
+
+ if ((key_state_table [(int) VirtualKeys.VK_NUMLOCK] & 0x01) != 0) {
+ e.KeyEvent.state |= NumLockMask;
+ }
+
+ e.KeyEvent.state |= AltGrMask;
+
+ for (int keyc = min_keycode; (keyc <= max_keycode) && (e.KeyEvent.keycode == 0); keyc++) {
+ // find keycode that could have generated this vkey
+ if ((keyc2vkey [keyc] & 0xFF) == vkey) {
+ // filter extended bit because it is not known
+ e.KeyEvent.keycode = keyc;
+ if ((EventToVkey (e) & 0xFF) != vkey) {
+ // Wrong one (ex: because of num,lock state)
+ e.KeyEvent.keycode = 0;
+ }
+ }
+ }
+
+ if ((vkey >= (int) VirtualKeys.VK_NUMPAD0) && (vkey <= (int) VirtualKeys.VK_NUMPAD9))
+ e.KeyEvent.keycode = XKeysymToKeycode (display, vkey - (int) VirtualKeys.VK_NUMPAD0 + (int) KeypadKeys.XK_KP_0);
+
+ if (vkey == (int) VirtualKeys.VK_DECIMAL)
+ e.KeyEvent.keycode = XKeysymToKeycode (display, (int) KeypadKeys.XK_KP_Decimal);
+
+ if (e.KeyEvent.keycode == 0 && vkey != (int) VirtualKeys.VK_NONAME) {
+ // And I couldn't find the keycode so i returned the vkey and was like whatever
+ Console.Error.WriteLine ("unknown virtual key {0:X}", vkey);
+ buffer = String.Empty;
+ return vkey;
+ }
+
+ XKeySym t;
+ IntPtr status;
+ int res = LookupString (ref e, 24, out t, out status);
+ int keysym = (int) t;
+
+ buffer = String.Empty;
+ if (res == 0) {
+ int dead_char = MapDeadKeySym (keysym);
+ if (dead_char != 0) {
+ byte [] bytes = new byte [1];
+ bytes [0] = (byte) dead_char;
+ Encoding encoding = Encoding.GetEncoding (new CultureInfo (layout.Lcid).TextInfo.ANSICodePage);
+ buffer = new string (encoding.GetChars (bytes));
+ res = -1;
+ }
+ } else {
+ // Shift + arrow, shift + home, ....
+ // X returns a char for it, but windows doesn't
+ if (((e.KeyEvent.state & NumLockMask) == 0) && ((e.KeyEvent.state & (int) KeyMasks.ShiftMask) != 0) &&
+ (keysym >= (int) KeypadKeys.XK_KP_0) && (keysym <= (int) KeypadKeys.XK_KP_9)) {
+ buffer = String.Empty;
+ res = 0;
+ }
+
+ // CTRL + number, X returns chars, windows does not
+ if ((e.KeyEvent.state & (int) KeyMasks.ControlMask) != 0) {
+ if (((keysym >= 33) && (keysym < 'A')) || ((keysym > 'Z') && (keysym < 'a'))) {
+ buffer = String.Empty;
+ res = 0;
+ }
+ }
+
+ // X returns a char for delete key on extended keyboards, windows does not
+ if (keysym == (int) TtyKeys.XK_Delete) {
+ buffer = String.Empty;
+ res = 0;
+ }
+
+ if (res != 0) {
+ buffer = lookup_buffer.ToString ();
+ res = buffer.Length;
+ }
+ }
+
+ return res;
+ }
+
+ private MSG SendKeyboardInput (VirtualKeys vkey, int scan, KeybdEventFlags dw_flags, int time)
+ {
+ Msg message;
+
+ if ((dw_flags & KeybdEventFlags.KeyUp) != 0) {
+ bool sys_key = (key_state_table [(int) VirtualKeys.VK_MENU] & 0x80) != 0 &&
+ ((key_state_table [(int) VirtualKeys.VK_CONTROL] & 0x80) == 0);
+ key_state_table [(int) vkey] &= unchecked ((byte) ~0x80);
+ message = (sys_key ? Msg.WM_SYSKEYUP : Msg.WM_KEYUP);
+ } else {
+ if ((key_state_table [(int) vkey] & 0x80) == 0) {
+ key_state_table [(int) vkey] ^= 0x01;
+ }
+ key_state_table [(int) vkey] |= 0x80;
+ bool sys_key = (key_state_table [(int) VirtualKeys.VK_MENU] & 0x80) != 0 &&
+ ((key_state_table [(int) VirtualKeys.VK_CONTROL] & 0x80) == 0);
+ message = (sys_key ? Msg.WM_SYSKEYDOWN : Msg.WM_KEYDOWN);
+ }
+
+ MSG msg = new MSG ();
+ msg.message = message;
+ msg.wParam = (IntPtr) vkey;
+ if ((key_state_table [(int) VirtualKeys.VK_MENU] & 0x80) != 0)
+ msg.lParam = new IntPtr (0x20000000);
+ else
+ msg.lParam = IntPtr.Zero;
+
+ return msg;
+ }
+
+ private void GenerateMessage (VirtualKeys vkey, int scan, XEventName type, int event_time)
+ {
+ bool state = (vkey == VirtualKeys.VK_NUMLOCK ? num_state : cap_state);
+ KeybdEventFlags up, down;
+
+ if (state) {
+ // The INTERMEDIARY state means : just after a 'press' event, if a 'release' event comes,
+ // don't treat it. It's from the same key press. Then the state goes to ON.
+ // And from there, a 'release' event will switch off the toggle key.
+ SetState (vkey, false);
+ } else {
+ down = (vkey == VirtualKeys.VK_NUMLOCK ? KeybdEventFlags.ExtendedKey : KeybdEventFlags.None);
+ up = (vkey == VirtualKeys.VK_NUMLOCK ? KeybdEventFlags.ExtendedKey :
+ KeybdEventFlags.None) | KeybdEventFlags.KeyUp;
+ if ((key_state_table [(int) vkey] & 0x1) != 0) { // it was on
+ if (type != XEventName.KeyPress) {
+ SendKeyboardInput (vkey, scan, down, event_time);
+ SendKeyboardInput (vkey, scan, up, event_time);
+ SetState (vkey, false);
+ key_state_table [(int) vkey] &= unchecked ((byte) ~0x01);
+ }
+ } else {
+ if (type == XEventName.KeyPress) {
+ SendKeyboardInput (vkey, scan, down, event_time);
+ SendKeyboardInput (vkey, scan, up, event_time);
+ SetState (vkey, true);
+ key_state_table [(int) vkey] |= 0x01;
+ }
+ }
+ }
+ }
+
+ private void UpdateKeyState (XEvent xevent)
+ {
+ int vkey = EventToVkey (xevent);
+
+ switch (xevent.type) {
+ case XEventName.KeyRelease:
+ key_state_table [(int) vkey] &= unchecked ((byte) ~0x80);
+ break;
+ case XEventName.KeyPress:
+ if ((key_state_table [(int) vkey] & 0x80) == 0) {
+ key_state_table [(int) vkey] ^= 0x01;
+ }
+ key_state_table [(int) vkey] |= 0x80;
+ break;
+ }
+ }
+
+ private void SetState (VirtualKeys key, bool state)
+ {
+ if (VirtualKeys.VK_NUMLOCK == key)
+ num_state = state;
+ else
+ cap_state = state;
+ }
+
+ public int EventToVkey (XEvent e)
+ {
+ IntPtr status;
+ XKeySym ks;
+
+ LookupString (ref e, 0, out ks, out status);
+ int keysym = (int) ks;
+
+ if ((keysym >= 0xFFAE) && (keysym <= 0xFFB9) && (keysym != 0xFFAF)
+ && ((e.KeyEvent.state & NumLockMask) !=0)) {
+ // Only the Keypad keys 0-9 and . send different keysyms
+ // depending on the NumLock state
+ return nonchar_key_vkey [keysym & 0xFF];
+ }
+
+ return keyc2vkey [e.KeyEvent.keycode];
+ }
+
+ public void CreateConversionArray (KeyboardLayouts layouts, KeyboardLayout layout)
+ {
+ XEvent e2 = new XEvent ();
+ uint keysym = 0;
+ int [] ckey = new int [] { 0, 0, 0, 0 };
+
+ e2.KeyEvent.display = display;
+ e2.KeyEvent.state = 0;
+
+ for (int keyc = min_keycode; keyc <= max_keycode; keyc++) {
+ int vkey = 0;
+ int scan = 0;
+
+ e2.KeyEvent.keycode = keyc;
+ XKeySym t;
+
+ IntPtr status;
+ LookupString (ref e2, 0, out t, out status);
+
+ keysym = (uint) t;
+ if (keysym != 0) {
+ if ((keysym >> 8) == 0xFF) {
+ vkey = nonchar_key_vkey [keysym & 0xFF];
+ scan = nonchar_key_scan [keysym & 0xFF];
+ // Set extended bit
+ if ((scan & 0x100) != 0)
+ vkey |= 0x100;
+ } else if (keysym == 0x20) { // spacebar
+ vkey = (int) VirtualKeys.VK_SPACE;
+ scan = 0x39;
+ } else {
+ // Search layout dependent scancodes
+ int maxlen = 0;
+ int maxval = -1;;
+
+ for (int i = 0; i < syms; i++) {
+ keysym = XKeycodeToKeysym (display, keyc, i);
+ if ((keysym < 0x800) && (keysym != ' '))
+ ckey [i] = (sbyte) (keysym & 0xFF);
+ else
+ ckey [i] = (sbyte) MapDeadKeySym ((int) keysym);
+ }
+
+ for (int keyn = 0; keyn < layout.Keys.Length; keyn++) {
+ int ml = Math.Min (layout.Keys [keyn].Length, 4);
+ int ok = -1;
+ for (int i = 0; (ok != 0) && (i < ml); i++) {
+ sbyte ck = (sbyte) layout.Keys [keyn][i];
+ if (ck != ckey [i])
+ ok = 0;
+ if ((ok != 0) || (i > maxlen)) {
+ maxlen = i;
+ maxval = keyn;
+ }
+ if (ok != 0)
+ break;
+ }
+ }
+ if (maxval >= 0) {
+ /// XXX
+ scan = layouts.scan_table [(int) layout.ScanIndex][maxval];
+ vkey = layouts.vkey_table [(int) layout.VKeyIndex][maxval];
+ }
+
+ }
+ }
+ keyc2vkey [e2.KeyEvent.keycode] = vkey;
+ keyc2scan [e2.KeyEvent.keycode] = scan;
+ }
+
+
+ }
+
+ public void DetectLayout (KeyboardLayouts layouts)
+ {
+ XDisplayKeycodes (display, out min_keycode, out max_keycode);
+ IntPtr ksp = XGetKeyboardMapping (display, (byte) min_keycode,
+ max_keycode + 1 - min_keycode, out keysyms_per_keycode);
+ XplatUIX11.XFree (ksp);
+
+ syms = keysyms_per_keycode;
+ if (syms > 4) {
+ //Console.Error.WriteLine ("{0} keysymbols per a keycode is not supported, setting to 4", syms);
+ syms = 2;
+ }
+
+ IntPtr modmap_unmanaged;
+ XModifierKeymap xmk = new XModifierKeymap ();
+
+ modmap_unmanaged = XGetModifierMapping (display);
+ xmk = (XModifierKeymap) Marshal.PtrToStructure (modmap_unmanaged, typeof (XModifierKeymap));
+
+ int mmp = 0;
+ for (int i = 0; i < 8; i++) {
+ for (int j = 0; j < xmk.max_keypermod; j++, mmp++) {
+ byte b = Marshal.ReadByte (xmk.modifiermap, mmp);
+ if (b != 0) {
+ for (int k = 0; k < keysyms_per_keycode; k++) {
+ if ((int) XKeycodeToKeysym (display, b, k) == (int) MiscKeys.XK_Num_Lock)
+ NumLockMask = 1 << i;
+ }
+ }
+ }
+ }
+ XFreeModifiermap (modmap_unmanaged);
+
+ int [] ckey = new int [4];
+ KeyboardLayout layout = null;
+ int max_score = 0;
+ int max_seq = 0;
+
+ foreach (KeyboardLayout current in layouts.Layouts) {
+ int ok = 0;
+ int score = 0;
+ int match = 0;
+ int mismatch = 0;
+ int seq = 0;
+ int pkey = -1;
+ int key = min_keycode;
+ int i;
+
+ for (int keyc = min_keycode; keyc <= max_keycode; keyc++) {
+ for (i = 0; i < syms; i++) {
+ uint keysym = XKeycodeToKeysym (display, keyc, i);
+
+ if ((keysym < 0x800) && (keysym != ' ')) {
+ ckey [i] = (sbyte) (keysym & 0xFF);
+ } else {
+ ckey [i] = (sbyte) MapDeadKeySym ((int) keysym);
+ }
+ }
+ if (ckey [0] != 0) {
+ for (key = 0; key < current.Keys.Length; key++) {
+ int ml = Math.Min (syms, current.Keys [key].Length);
+ for (ok = 0, i = 0; (ok >= 0) && (i < ml); i++) {
+ sbyte ck = (sbyte) current.Keys [key][i];
+ if (ck != 0 && ck == ckey[i])
+ ok++;
+ if (ck != 0 && ck != ckey[i])
+ ok = -1;
+ }
+ if (ok > 0) {
+ score += ok;
+ break;
+ }
+ }
+ if (ok > 0) {
+ match++;
+ /* and how much the keycode order matches */
+ if (key > pkey)
+ seq++;
+ pkey = key;
+ } else {
+ /* print spaces instead of \0's */
+ mismatch++;
+ score -= syms;
+ }
+ }
+ }
+
+ if ((score > max_score) || ((score == max_score) && (seq > max_seq))) {
+ // best match so far
+ layout = current;
+ max_score = score;
+ max_seq = seq;
+ }
+ }
+
+ if (layout != null) {
+ this.layout = layout;
+ Console.WriteLine (Locale.GetText("Keyboard") + ": " + layout.Name);
+ } else {
+ Console.WriteLine (Locale.GetText("Keyboard layout not recognized, using default layout: " + this.layout.Name));
+ }
+ }
+
+ // TODO
+ private int MapDeadKeySym (int val)
+ {
+ switch (val) {
+ case (int) DeadKeys.XK_dead_tilde :
+ case 0x1000FE7E : // Xfree's Dtilde
+ return '~';
+ case (int) DeadKeys.XK_dead_acute :
+ case 0x1000FE27 : // Xfree's XK_Dacute_accent
+ return 0xb4;
+ case (int) DeadKeys.XK_dead_circumflex:
+ case 0x1000FE5E : // Xfree's XK_.Dcircumflex_accent
+ return '^';
+ case (int) DeadKeys.XK_dead_grave :
+ case 0x1000FE60 : // Xfree's XK_.Dgrave_accent
+ return '`';
+ case (int) DeadKeys.XK_dead_diaeresis :
+ case 0x1000FE22 : // Xfree's XK_.Ddiaeresis
+ return 0xa8;
+ case (int) DeadKeys.XK_dead_cedilla :
+ return 0xb8;
+ case (int) DeadKeys.XK_dead_macron :
+ return '-';
+ case (int) DeadKeys.XK_dead_breve :
+ return 0xa2;
+ case (int) DeadKeys.XK_dead_abovedot :
+ return 0xff;
+ case (int) DeadKeys.XK_dead_abovering :
+ return '0';
+ case (int) DeadKeys.XK_dead_doubleacute :
+ return 0xbd;
+ case (int) DeadKeys.XK_dead_caron :
+ return 0xb7;
+ case (int) DeadKeys.XK_dead_ogonek :
+ return 0xb2;
+ }
+
+ return 0;
+ }
+
+ internal IntPtr CreateXic (IntPtr window)
+ {
+ xic = XCreateIC (xim,
+ "inputStyle", XIMProperties.XIMPreeditNothing | XIMProperties.XIMStatusNothing,
+ "clientWindow", window,
+ "focusWindow", window,
+ IntPtr.Zero);
+ return xic;
+ }
+
+ private int LookupString (ref XEvent xevent, int len, out XKeySym keysym, out IntPtr status)
+ {
+ IntPtr keysym_res;
+ int res;
+
+ status = IntPtr.Zero;
+ lookup_buffer.Length = 0;
+ if (xic != IntPtr.Zero)
+ res = XmbLookupString (xic, ref xevent, lookup_buffer, len, out keysym_res, out status);
+ else
+ res = XLookupString (ref xevent, lookup_buffer, len, out keysym_res, IntPtr.Zero);
+
+ keysym = (XKeySym) keysym_res.ToInt32 ();
+ return res;
+ }
+
+ [DllImport ("libX11")]
+ private static extern IntPtr XOpenIM (IntPtr display, IntPtr rdb, IntPtr res_name, IntPtr res_class);
+
+ [DllImport ("libX11")]
+ private static extern IntPtr XCreateIC (IntPtr xim, string name, XIMProperties im_style, string name2, IntPtr value2, string name3, IntPtr value3, IntPtr terminator);
+
+ [DllImport ("libX11")]
+ private static extern void XSetICFocus (IntPtr xic);
+
+ [DllImport ("libX11")]
+ private static extern void XUnsetICFocus (IntPtr xic);
+
+ [DllImport ("libX11")]
+ private static extern bool XSupportsLocale ();
+
+ [DllImport ("libX11")]
+ private static extern bool XSetLocaleModifiers (string mods);
+
+ [DllImport ("libX11")]
+ internal extern static int XLookupString(ref XEvent xevent, StringBuilder buffer, int num_bytes, out IntPtr keysym, IntPtr status);
+ [DllImport ("libX11")]
+ internal extern static int XmbLookupString(IntPtr xic, ref XEvent xevent, StringBuilder buffer, int num_bytes, out IntPtr keysym, out IntPtr status);
+
+ internal static int XmbLookupString (IntPtr xic, ref XEvent xevent, StringBuilder buffer, int num_bytes, out XKeySym keysym, out IntPtr status) {
+ IntPtr keysym_ret;
+ int ret;
+
+ ret = XmbLookupString (xic, ref xevent, buffer, num_bytes, out keysym_ret, out status);
+
+ keysym = (XKeySym)keysym_ret.ToInt32();
+
+ return ret;
+ }
+
+ internal static int XLookupString (ref XEvent xevent, StringBuilder buffer, int num_bytes, out XKeySym keysym, IntPtr status) {
+ IntPtr keysym_ret;
+ int ret;
+
+ ret = XLookupString (ref xevent, buffer, num_bytes, out keysym_ret, status);
+ keysym = (XKeySym)keysym_ret.ToInt32();
+
+ return ret;
+ }
+
+ [DllImport ("libX11", EntryPoint="XLookupKeysym")]
+ private static extern IntPtr XLookupKeysymX11(ref XEvent xevent, int index);
+ private static XKeySym XLookupKeysym(ref XEvent xevent, int index) {
+ return (XKeySym)XLookupKeysymX11(ref xevent, index).ToInt32();
+ }
+
+ [DllImport ("libX11")]
+ private static extern IntPtr XGetKeyboardMapping (IntPtr display, byte first_keycode, int keycode_count,
+ out int keysyms_per_keycode_return);
+
+ [DllImport ("libX11")]
+ private static extern void XDisplayKeycodes (IntPtr display, out int min, out int max);
+
+ [DllImport ("libX11", EntryPoint="XKeycodeToKeysym")]
+ private static extern uint XKeycodeToKeysym (IntPtr display, int keycode, int index);
+
+ [DllImport ("libX11")]
+ private static extern int XKeysymToKeycode (IntPtr display, IntPtr keysym);
+ private static int XKeysymToKeycode (IntPtr display, int keysym) {
+ return XKeysymToKeycode(display, (IntPtr)keysym);
+ }
+
+ [DllImport ("libX11")]
+ internal extern static IntPtr XGetModifierMapping (IntPtr display);
+
+ [DllImport ("libX11")]
+ internal extern static int XFreeModifiermap (IntPtr modmap);
+
+
+ public readonly static int [] nonchar_key_vkey = new int []
+ {
+ /* unused */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* FF00 */
+ /* special keys */
+ (int) VirtualKeys.VK_BACK, (int) VirtualKeys.VK_TAB, 0, (int) VirtualKeys.VK_CLEAR, 0, (int) VirtualKeys.VK_RETURN, 0, 0, /* FF08 */
+ 0, 0, 0, (int) VirtualKeys.VK_PAUSE, (int) VirtualKeys.VK_SCROLL, 0, 0, 0, /* FF10 */
+ 0, 0, 0, (int) VirtualKeys.VK_ESCAPE, 0, 0, 0, 0, /* FF18 */
+ /* unused */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* FF20 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* FF28 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* FF30 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* FF38 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* FF40 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* FF48 */
+ /* cursor keys */
+ (int) VirtualKeys.VK_HOME, (int) VirtualKeys.VK_LEFT, (int) VirtualKeys.VK_UP, (int) VirtualKeys.VK_RIGHT, /* FF50 */
+ (int) VirtualKeys.VK_DOWN, (int) VirtualKeys.VK_PRIOR, (int) VirtualKeys.VK_NEXT, (int) VirtualKeys.VK_END,
+ 0, 0, 0, 0, 0, 0, 0, 0, /* FF58 */
+ /* misc keys */
+ (int) VirtualKeys.VK_SELECT, (int) VirtualKeys.VK_SNAPSHOT, (int) VirtualKeys.VK_EXECUTE, (int) VirtualKeys.VK_INSERT, 0, 0, 0, 0, /* FF60 */
+ (int) VirtualKeys.VK_CANCEL, (int) VirtualKeys.VK_HELP, (int) VirtualKeys.VK_CANCEL, (int) VirtualKeys.VK_CANCEL, 0, 0, 0, 0, /* FF68 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* FF70 */
+ /* keypad keys */
+ 0, 0, 0, 0, 0, 0, 0, (int) VirtualKeys.VK_NUMLOCK, /* FF78 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* FF80 */
+ 0, 0, 0, 0, 0, (int) VirtualKeys.VK_RETURN, 0, 0, /* FF88 */
+ 0, 0, 0, 0, 0, (int) VirtualKeys.VK_HOME, (int) VirtualKeys.VK_LEFT, (int) VirtualKeys.VK_UP, /* FF90 */
+ (int) VirtualKeys.VK_RIGHT, (int) VirtualKeys.VK_DOWN, (int) VirtualKeys.VK_PRIOR, (int) VirtualKeys.VK_NEXT, /* FF98 */
+ (int) VirtualKeys.VK_END, 0, (int) VirtualKeys.VK_INSERT, (int) VirtualKeys.VK_DELETE,
+ 0, 0, 0, 0, 0, 0, 0, 0, /* FFA0 */
+ 0, 0, (int) VirtualKeys.VK_MULTIPLY, (int) VirtualKeys.VK_ADD, /* FFA8 */
+ (int) VirtualKeys.VK_SEPARATOR, (int) VirtualKeys.VK_SUBTRACT, (int) VirtualKeys.VK_DECIMAL, (int) VirtualKeys.VK_DIVIDE,
+ (int) VirtualKeys.VK_NUMPAD0, (int) VirtualKeys.VK_NUMPAD1, (int) VirtualKeys.VK_NUMPAD2, (int) VirtualKeys.VK_NUMPAD3, /* FFB0 */
+ (int) VirtualKeys.VK_NUMPAD4, (int) VirtualKeys.VK_NUMPAD5, (int) VirtualKeys.VK_NUMPAD6, (int) VirtualKeys.VK_NUMPAD7,
+ (int) VirtualKeys.VK_NUMPAD8, (int) VirtualKeys.VK_NUMPAD9, 0, 0, 0, 0, /* FFB8 */
+ /* function keys */
+ (int) VirtualKeys.VK_F1, (int) VirtualKeys.VK_F2,
+ (int) VirtualKeys.VK_F3, (int) VirtualKeys.VK_F4, (int) VirtualKeys.VK_F5, (int) VirtualKeys.VK_F6, (int) VirtualKeys.VK_F7, (int) VirtualKeys.VK_F8, (int) VirtualKeys.VK_F9, (int) VirtualKeys.VK_F10, /* FFC0 */
+ (int) VirtualKeys.VK_F11, (int) VirtualKeys.VK_F12, (int) VirtualKeys.VK_F13, (int) VirtualKeys.VK_F14, (int) VirtualKeys.VK_F15, (int) VirtualKeys.VK_F16, 0, 0, /* FFC8 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* FFD0 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* FFD8 */
+ /* modifier keys */
+ 0, (int) VirtualKeys.VK_SHIFT, (int) VirtualKeys.VK_SHIFT, (int) VirtualKeys.VK_CONTROL, /* FFE0 */
+ (int) VirtualKeys.VK_CONTROL, (int) VirtualKeys.VK_CAPITAL, 0, (int) VirtualKeys.VK_MENU,
+ (int) VirtualKeys.VK_MENU, (int) VirtualKeys.VK_MENU, (int) VirtualKeys.VK_MENU, 0, 0, 0, 0, 0, /* FFE8 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* FFF0 */
+ 0, 0, 0, 0, 0, 0, 0, (int) VirtualKeys.VK_DELETE /* FFF8 */
+ };
+
+ public static readonly int [] nonchar_key_scan = new int []
+ {
+ /* unused */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* FF00 */
+ /* special keys */
+ 0x0E, 0x0F, 0x00, /*?*/ 0, 0x00, 0x1C, 0x00, 0x00, /* FF08 */
+ 0x00, 0x00, 0x00, 0x45, 0x46, 0x00, 0x00, 0x00, /* FF10 */
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, /* FF18 */
+ /* unused */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* FF20 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* FF28 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* FF30 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* FF38 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* FF40 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* FF48 */
+ /* cursor keys */
+ 0x147, 0x14B, 0x148, 0x14D, 0x150, 0x149, 0x151, 0x14F, /* FF50 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* FF58 */
+ /* misc keys */
+ /*?*/ 0, 0x137, /*?*/ 0, 0x152, 0x00, 0x00, 0x00, 0x00, /* FF60 */
+ /*?*/ 0, /*?*/ 0, 0x38, 0x146, 0x00, 0x00, 0x00, 0x00, /* FF68 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* FF70 */
+ /* keypad keys */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x138, 0x145, /* FF78 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* FF80 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x11C, 0x00, 0x00, /* FF88 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x4B, 0x48, /* FF90 */
+ 0x4D, 0x50, 0x49, 0x51, 0x4F, 0x4C, 0x52, 0x53, /* FF98 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* FFA0 */
+ 0x00, 0x00, 0x37, 0x4E, /*?*/ 0, 0x4A, 0x53, 0x135, /* FFA8 */
+ 0x52, 0x4F, 0x50, 0x51, 0x4B, 0x4C, 0x4D, 0x47, /* FFB0 */
+ 0x48, 0x49, 0x00, 0x00, 0x00, 0x00, /* FFB8 */
+ /* function keys */
+ 0x3B, 0x3C,
+ 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, /* FFC0 */
+ 0x57, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* FFC8 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* FFD0 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* FFD8 */
+ /* modifier keys */
+ 0x00, 0x2A, 0x36, 0x1D, 0x11D, 0x3A, 0x00, 0x38, /* FFE0 */
+ 0x138, 0x38, 0x138, 0x00, 0x00, 0x00, 0x00, 0x00, /* FFE8 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* FFF0 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x153 /* FFF8 */
+ };
+ }
+
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Structs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Structs.cs
new file mode 100644
index 00000000000..75cfb8f85b3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Structs.cs
@@ -0,0 +1,1602 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software",, to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// NOT COMPLETE
+
+using System;
+using System.ComponentModel;
+using System.Collections;
+using System.Drawing;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+
+/// X11 Version
+namespace System.Windows.Forms {
+ //
+ // In the structures below, fields of type long are mapped to IntPtr.
+ // This will work on all platforms where sizeof(long)==sizeof(void*), which
+ // is almost all platforms except WIN64.
+ //
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XAnyEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr window;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XKeyEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr window;
+ internal IntPtr root;
+ internal IntPtr subwindow;
+ internal IntPtr time;
+ internal int x;
+ internal int y;
+ internal int x_root;
+ internal int y_root;
+ internal int state;
+ internal int keycode;
+ internal bool same_screen;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XButtonEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr window;
+ internal IntPtr root;
+ internal IntPtr subwindow;
+ internal IntPtr time;
+ internal int x;
+ internal int y;
+ internal int x_root;
+ internal int y_root;
+ internal int state;
+ internal int button;
+ internal bool same_screen;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XMotionEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr window;
+ internal IntPtr root;
+ internal IntPtr subwindow;
+ internal IntPtr time;
+ internal int x;
+ internal int y;
+ internal int x_root;
+ internal int y_root;
+ internal int state;
+ internal byte is_hint;
+ internal bool same_screen;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XCrossingEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr window;
+ internal IntPtr root;
+ internal IntPtr subwindow;
+ internal IntPtr time;
+ internal int x;
+ internal int y;
+ internal int x_root;
+ internal int y_root;
+ internal NotifyMode mode;
+ internal NotifyDetail detail;
+ internal bool same_screen;
+ internal bool focus;
+ internal int state;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XFocusChangeEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr window;
+ internal int mode;
+ internal NotifyDetail detail;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XKeymapEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr window;
+ internal byte key_vector0;
+ internal byte key_vector1;
+ internal byte key_vector2;
+ internal byte key_vector3;
+ internal byte key_vector4;
+ internal byte key_vector5;
+ internal byte key_vector6;
+ internal byte key_vector7;
+ internal byte key_vector8;
+ internal byte key_vector9;
+ internal byte key_vector10;
+ internal byte key_vector11;
+ internal byte key_vector12;
+ internal byte key_vector13;
+ internal byte key_vector14;
+ internal byte key_vector15;
+ internal byte key_vector16;
+ internal byte key_vector17;
+ internal byte key_vector18;
+ internal byte key_vector19;
+ internal byte key_vector20;
+ internal byte key_vector21;
+ internal byte key_vector22;
+ internal byte key_vector23;
+ internal byte key_vector24;
+ internal byte key_vector25;
+ internal byte key_vector26;
+ internal byte key_vector27;
+ internal byte key_vector28;
+ internal byte key_vector29;
+ internal byte key_vector30;
+ internal byte key_vector31;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XExposeEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr window;
+ internal int x;
+ internal int y;
+ internal int width;
+ internal int height;
+ internal int count;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XGraphicsExposeEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr drawable;
+ internal int x;
+ internal int y;
+ internal int width;
+ internal int height;
+ internal int count;
+ internal int major_code;
+ internal int minor_code;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XNoExposeEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr drawable;
+ internal int major_code;
+ internal int minor_code;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XVisibilityEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr window;
+ internal int state;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XCreateWindowEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr parent;
+ internal IntPtr window;
+ internal int x;
+ internal int y;
+ internal int width;
+ internal int height;
+ internal int border_width;
+ internal bool override_redirect;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XDestroyWindowEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr xevent;
+ internal IntPtr window;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XUnmapEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr xevent;
+ internal IntPtr window;
+ internal bool from_configure;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XMapEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr xevent;
+ internal IntPtr window;
+ internal bool override_redirect;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XMapRequestEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr parent;
+ internal IntPtr window;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XReparentEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr xevent;
+ internal IntPtr window;
+ internal IntPtr parent;
+ internal int x;
+ internal int y;
+ internal bool override_redirect;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XConfigureEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr xevent;
+ internal IntPtr window;
+ internal int x;
+ internal int y;
+ internal int width;
+ internal int height;
+ internal int border_width;
+ internal IntPtr above;
+ internal bool override_redirect;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XGravityEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr xevent;
+ internal IntPtr window;
+ internal int x;
+ internal int y;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XResizeRequestEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr window;
+ internal int width;
+ internal int height;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XConfigureRequestEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr parent;
+ internal IntPtr window;
+ internal int x;
+ internal int y;
+ internal int width;
+ internal int height;
+ internal int border_width;
+ internal IntPtr above;
+ internal int detail;
+ internal IntPtr value_mask;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XCirculateEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr xevent;
+ internal IntPtr window;
+ internal int place;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XCirculateRequestEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr parent;
+ internal IntPtr window;
+ internal int place;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XPropertyEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr window;
+ internal IntPtr atom;
+ internal IntPtr time;
+ internal int state;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XSelectionClearEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr window;
+ internal IntPtr selection;
+ internal IntPtr time;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XSelectionRequestEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr owner;
+ internal IntPtr requestor;
+ internal IntPtr selection;
+ internal IntPtr target;
+ internal IntPtr property;
+ internal IntPtr time;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XSelectionEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr requestor;
+ internal IntPtr selection;
+ internal IntPtr target;
+ internal IntPtr property;
+ internal IntPtr time;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XColormapEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr window;
+ internal IntPtr colormap;
+ internal bool c_new;
+ internal int state;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XClientMessageEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr window;
+ internal IntPtr message_type;
+ internal int format;
+ internal IntPtr ptr1;
+ internal IntPtr ptr2;
+ internal IntPtr ptr3;
+ internal IntPtr ptr4;
+ internal IntPtr ptr5;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XMappingEvent {
+ internal XEventName type;
+ internal IntPtr serial;
+ internal bool send_event;
+ internal IntPtr display;
+ internal IntPtr window;
+ internal int request;
+ internal int first_keycode;
+ internal int count;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XErrorEvent {
+ internal XEventName type;
+ internal IntPtr display;
+ internal IntPtr resourceid;
+ internal IntPtr serial;
+ internal byte error_code;
+ internal XRequest request_code;
+ internal byte minor_code;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XTimerNotifyEvent {
+ internal XEventName type;
+ internal EventHandler handler;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XEventPad {
+ internal IntPtr pad0;
+ internal IntPtr pad1;
+ internal IntPtr pad2;
+ internal IntPtr pad3;
+ internal IntPtr pad4;
+ internal IntPtr pad5;
+ internal IntPtr pad6;
+ internal IntPtr pad7;
+ internal IntPtr pad8;
+ internal IntPtr pad9;
+ internal IntPtr pad10;
+ internal IntPtr pad11;
+ internal IntPtr pad12;
+ internal IntPtr pad13;
+ internal IntPtr pad14;
+ internal IntPtr pad15;
+ internal IntPtr pad16;
+ internal IntPtr pad17;
+ internal IntPtr pad18;
+ internal IntPtr pad19;
+ internal IntPtr pad20;
+ internal IntPtr pad21;
+ internal IntPtr pad22;
+ internal IntPtr pad23;
+ }
+
+ [StructLayout(LayoutKind.Explicit)]
+ internal struct XEvent {
+ [ FieldOffset(0) ] internal XEventName type;
+ [ FieldOffset(0) ] internal XAnyEvent AnyEvent;
+ [ FieldOffset(0) ] internal XKeyEvent KeyEvent;
+ [ FieldOffset(0) ] internal XButtonEvent ButtonEvent;
+ [ FieldOffset(0) ] internal XMotionEvent MotionEvent;
+ [ FieldOffset(0) ] internal XCrossingEvent CrossingEvent;
+ [ FieldOffset(0) ] internal XFocusChangeEvent FocusChangeEvent;
+ [ FieldOffset(0) ] internal XExposeEvent ExposeEvent;
+ [ FieldOffset(0) ] internal XGraphicsExposeEvent GraphicsExposeEvent;
+ [ FieldOffset(0) ] internal XNoExposeEvent NoExposeEvent;
+ [ FieldOffset(0) ] internal XVisibilityEvent VisibilityEvent;
+ [ FieldOffset(0) ] internal XCreateWindowEvent CreateWindowEvent;
+ [ FieldOffset(0) ] internal XDestroyWindowEvent DestroyWindowEvent;
+ [ FieldOffset(0) ] internal XUnmapEvent UnmapEvent;
+ [ FieldOffset(0) ] internal XMapEvent MapEvent;
+ [ FieldOffset(0) ] internal XMapRequestEvent MapRequestEvent;
+ [ FieldOffset(0) ] internal XReparentEvent ReparentEvent;
+ [ FieldOffset(0) ] internal XConfigureEvent ConfigureEvent;
+ [ FieldOffset(0) ] internal XGravityEvent GravityEvent;
+ [ FieldOffset(0) ] internal XResizeRequestEvent ResizeRequestEvent;
+ [ FieldOffset(0) ] internal XConfigureRequestEvent ConfigureRequestEvent;
+ [ FieldOffset(0) ] internal XCirculateEvent CirculateEvent;
+ [ FieldOffset(0) ] internal XCirculateRequestEvent CirculateRequestEvent;
+ [ FieldOffset(0) ] internal XPropertyEvent PropertyEvent;
+ [ FieldOffset(0) ] internal XSelectionClearEvent SelectionClearEvent;
+ [ FieldOffset(0) ] internal XSelectionRequestEvent SelectionRequestEvent;
+ [ FieldOffset(0) ] internal XSelectionEvent SelectionEvent;
+ [ FieldOffset(0) ] internal XColormapEvent ColormapEvent;
+ [ FieldOffset(0) ] internal XClientMessageEvent ClientMessageEvent;
+ [ FieldOffset(0) ] internal XMappingEvent MappingEvent;
+ [ FieldOffset(0) ] internal XErrorEvent ErrorEvent;
+ [ FieldOffset(0) ] internal XKeymapEvent KeymapEvent;
+ [ FieldOffset(0) ] internal XTimerNotifyEvent TimerNotifyEvent;
+
+ //[MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=24)]
+ //[ FieldOffset(0) ] internal int[] pad;
+ [ FieldOffset(0) ] internal XEventPad Pad;
+ public override string ToString() {
+ return type.ToString();
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XSetWindowAttributes {
+ internal IntPtr background_pixmap;
+ internal IntPtr background_pixel;
+ internal IntPtr border_pixmap;
+ internal IntPtr border_pixel;
+ internal Gravity bit_gravity;
+ internal Gravity win_gravity;
+ internal int backing_store;
+ internal IntPtr backing_planes;
+ internal IntPtr backing_pixel;
+ internal bool save_under;
+ internal IntPtr event_mask;
+ internal IntPtr do_not_propagate_mask;
+ internal bool override_redirect;
+ internal IntPtr colormap;
+ internal IntPtr cursor;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XWindowAttributes {
+ internal int x;
+ internal int y;
+ internal int width;
+ internal int height;
+ internal int border_width;
+ internal int depth;
+ internal IntPtr visual;
+ internal IntPtr root;
+ internal int c_class;
+ internal Gravity bit_gravity;
+ internal Gravity win_gravity;
+ internal int backing_store;
+ internal IntPtr backing_planes;
+ internal IntPtr backing_pixel;
+ internal bool save_under;
+ internal IntPtr colormap;
+ internal bool map_installed;
+ internal MapState map_state;
+ internal IntPtr all_event_masks;
+ internal IntPtr your_event_mask;
+ internal IntPtr do_not_propagate_mask;
+ internal bool override_direct;
+ internal IntPtr screen;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XTextProperty {
+ internal string value;
+ internal IntPtr encoding;
+ internal int format;
+ internal IntPtr nitems;
+ }
+
+ internal enum XWindowClass {
+ InputOutput = 1,
+ InputOnly = 2
+ }
+
+ internal enum XEventName {
+ KeyPress = 2,
+ KeyRelease = 3,
+ ButtonPress = 4,
+ ButtonRelease = 5,
+ MotionNotify = 6,
+ EnterNotify = 7,
+ LeaveNotify = 8,
+ FocusIn = 9,
+ FocusOut = 10,
+ KeymapNotify = 11,
+ Expose = 12,
+ GraphicsExpose = 13,
+ NoExpose = 14,
+ VisibilityNotify = 15,
+ CreateNotify = 16,
+ DestroyNotify = 17,
+ UnmapNotify = 18,
+ MapNotify = 19,
+ MapRequest = 20,
+ ReparentNotify = 21,
+ ConfigureNotify = 22,
+ ConfigureRequest = 23,
+ GravityNotify = 24,
+ ResizeRequest = 25,
+ CirculateNotify = 26,
+ CirculateRequest = 27,
+ PropertyNotify = 28,
+ SelectionClear = 29,
+ SelectionRequest = 30,
+ SelectionNotify = 31,
+ ColormapNotify = 32,
+ ClientMessage = 33,
+ MappingNotify = 34,
+ TimerNotify = 100,
+
+ LASTEvent
+ }
+
+ [Flags]
+ internal enum SetWindowValuemask {
+ Nothing = 0,
+ BackPixmap = 1,
+ BackPixel = 2,
+ BorderPixmap = 4,
+ BorderPixel = 8,
+ BitGravity = 16,
+ WinGravity = 32,
+ BackingStore = 64,
+ BackingPlanes = 128,
+ BackingPixel = 256,
+ OverrideRedirect = 512,
+ SaveUnder = 1024,
+ EventMask = 2048,
+ DontPropagate = 4096,
+ ColorMap = 8192,
+ Cursor = 16384
+ }
+
+ internal enum CreateWindowArgs {
+ CopyFromParent = 0,
+ ParentRelative = 1,
+ InputOutput = 1,
+ InputOnly = 2
+ }
+
+ internal enum Gravity {
+ ForgetGravity = 0,
+ NorthWestGravity= 1,
+ NorthGravity = 2,
+ NorthEastGravity= 3,
+ WestGravity = 4,
+ CenterGravity = 5,
+ EastGravity = 6,
+ SouthWestGravity= 7,
+ SouthGravity = 8,
+ SouthEastGravity= 9,
+ StaticGravity = 10
+ }
+
+ internal enum XKeySym : uint {
+ XK_BackSpace = 0xFF08,
+ XK_Tab = 0xFF09,
+ XK_Clear = 0xFF0B,
+ XK_Return = 0xFF0D,
+ XK_Home = 0xFF50,
+ XK_Left = 0xFF51,
+ XK_Up = 0xFF52,
+ XK_Right = 0xFF53,
+ XK_Down = 0xFF54,
+ XK_Page_Up = 0xFF55,
+ XK_Page_Down = 0xFF56,
+ XK_End = 0xFF57,
+ XK_Begin = 0xFF58,
+ XK_Menu = 0xFF67,
+ XK_Shift_L = 0xFFE1,
+ XK_Shift_R = 0xFFE2,
+ XK_Control_L = 0xFFE3,
+ XK_Control_R = 0xFFE4,
+ XK_Caps_Lock = 0xFFE5,
+ XK_Shift_Lock = 0xFFE6,
+ XK_Meta_L = 0xFFE7,
+ XK_Meta_R = 0xFFE8,
+ XK_Alt_L = 0xFFE9,
+ XK_Alt_R = 0xFFEA,
+ XK_Super_L = 0xFFEB,
+ XK_Super_R = 0xFFEC,
+ XK_Hyper_L = 0xFFED,
+ XK_Hyper_R = 0xFFEE,
+ }
+
+ [Flags]
+ internal enum EventMask {
+ NoEventMask = 0,
+ KeyPressMask = 1<<0,
+ KeyReleaseMask = 1<<1,
+ ButtonPressMask = 1<<2,
+ ButtonReleaseMask = 1<<3,
+ EnterWindowMask = 1<<4,
+ LeaveWindowMask = 1<<5,
+ PointerMotionMask = 1<<6,
+ PointerMotionHintMask = 1<<7,
+ Button1MotionMask = 1<<8,
+ Button2MotionMask = 1<<9,
+ Button3MotionMask = 1<<10,
+ Button4MotionMask = 1<<11,
+ Button5MotionMask = 1<<12,
+ ButtonMotionMask = 1<<13,
+ KeymapStateMask = 1<<14,
+ ExposureMask = 1<<15,
+ VisibilityChangeMask = 1<<16,
+ StructureNotifyMask = 1<<17,
+ ResizeRedirectMask = 1<<18,
+ SubstructureNotifyMask = 1<<19,
+ SubstructureRedirectMask= 1<<20,
+ FocusChangeMask = 1<<21,
+ PropertyChangeMask = 1<<22,
+ ColormapChangeMask = 1<<23,
+ OwnerGrabButtonMask = 1<<24
+ }
+
+ internal enum GrabMode {
+ GrabModeSync = 0,
+ GrabModeAsync = 1
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XStandardColormap {
+ internal IntPtr colormap;
+ internal IntPtr red_max;
+ internal IntPtr red_mult;
+ internal IntPtr green_max;
+ internal IntPtr green_mult;
+ internal IntPtr blue_max;
+ internal IntPtr blue_mult;
+ internal IntPtr base_pixel;
+ internal IntPtr visualid;
+ internal IntPtr killid;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack=2)]
+ internal struct XColor {
+ internal IntPtr pixel;
+ internal ushort red;
+ internal ushort green;
+ internal ushort blue;
+ internal byte flags;
+ internal byte pad;
+ }
+
+ internal enum Atom {
+ AnyPropertyType = 0,
+ XA_PRIMARY = 1,
+ XA_SECONDARY = 2,
+ XA_ARC = 3,
+ XA_ATOM = 4,
+ XA_BITMAP = 5,
+ XA_CARDINAL = 6,
+ XA_COLORMAP = 7,
+ XA_CURSOR = 8,
+ XA_CUT_BUFFER0 = 9,
+ XA_CUT_BUFFER1 = 10,
+ XA_CUT_BUFFER2 = 11,
+ XA_CUT_BUFFER3 = 12,
+ XA_CUT_BUFFER4 = 13,
+ XA_CUT_BUFFER5 = 14,
+ XA_CUT_BUFFER6 = 15,
+ XA_CUT_BUFFER7 = 16,
+ XA_DRAWABLE = 17,
+ XA_FONT = 18,
+ XA_INTEGER = 19,
+ XA_PIXMAP = 20,
+ XA_POINT = 21,
+ XA_RECTANGLE = 22,
+ XA_RESOURCE_MANAGER = 23,
+ XA_RGB_COLOR_MAP = 24,
+ XA_RGB_BEST_MAP = 25,
+ XA_RGB_BLUE_MAP = 26,
+ XA_RGB_DEFAULT_MAP = 27,
+ XA_RGB_GRAY_MAP = 28,
+ XA_RGB_GREEN_MAP = 29,
+ XA_RGB_RED_MAP = 30,
+ XA_STRING = 31,
+ XA_VISUALID = 32,
+ XA_WINDOW = 33,
+ XA_WM_COMMAND = 34,
+ XA_WM_HINTS = 35,
+ XA_WM_CLIENT_MACHINE = 36,
+ XA_WM_ICON_NAME = 37,
+ XA_WM_ICON_SIZE = 38,
+ XA_WM_NAME = 39,
+ XA_WM_NORMAL_HINTS = 40,
+ XA_WM_SIZE_HINTS = 41,
+ XA_WM_ZOOM_HINTS = 42,
+ XA_MIN_SPACE = 43,
+ XA_NORM_SPACE = 44,
+ XA_MAX_SPACE = 45,
+ XA_END_SPACE = 46,
+ XA_SUPERSCRIPT_X = 47,
+ XA_SUPERSCRIPT_Y = 48,
+ XA_SUBSCRIPT_X = 49,
+ XA_SUBSCRIPT_Y = 50,
+ XA_UNDERLINE_POSITION = 51,
+ XA_UNDERLINE_THICKNESS = 52,
+ XA_STRIKEOUT_ASCENT = 53,
+ XA_STRIKEOUT_DESCENT = 54,
+ XA_ITALIC_ANGLE = 55,
+ XA_X_HEIGHT = 56,
+ XA_QUAD_WIDTH = 57,
+ XA_WEIGHT = 58,
+ XA_POINT_SIZE = 59,
+ XA_RESOLUTION = 60,
+ XA_COPYRIGHT = 61,
+ XA_NOTICE = 62,
+ XA_FONT_NAME = 63,
+ XA_FAMILY_NAME = 64,
+ XA_FULL_NAME = 65,
+ XA_CAP_HEIGHT = 66,
+ XA_WM_CLASS = 67,
+ XA_WM_TRANSIENT_FOR = 68,
+
+ XA_LAST_PREDEFINED = 68
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XScreen {
+ internal IntPtr ext_data;
+ internal IntPtr display;
+ internal IntPtr root;
+ internal int width;
+ internal int height;
+ internal int mwidth;
+ internal int mheight;
+ internal int ndepths;
+ internal IntPtr depths;
+ internal int root_depth;
+ internal IntPtr root_visual;
+ internal IntPtr default_gc;
+ internal IntPtr cmap;
+ internal IntPtr white_pixel;
+ internal IntPtr black_pixel;
+ internal int max_maps;
+ internal int min_maps;
+ internal int backing_store;
+ internal bool save_unders;
+ internal IntPtr root_input_mask;
+ }
+
+ [Flags]
+ internal enum ChangeWindowFlags {
+ CWX = 1<<0,
+ CWY = 1<<1,
+ CWWidth = 1<<2,
+ CWHeight = 1<<3,
+ CWBorderWidth = 1<<4,
+ CWSibling = 1<<5,
+ CWStackMode = 1<<6
+ }
+
+ internal enum StackMode {
+ Above = 0,
+ Below = 1,
+ TopIf = 2,
+ BottomIf = 3,
+ Opposite = 4
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XWindowChanges {
+ internal int x;
+ internal int y;
+ internal int width;
+ internal int height;
+ internal int border_width;
+ internal IntPtr sibling;
+ internal StackMode stack_mode;
+ }
+
+ [Flags]
+ internal enum ColorFlags {
+ DoRed = 1<<0,
+ DoGreen = 1<<1,
+ DoBlue = 1<<2
+ }
+
+ internal enum NotifyMode {
+ NotifyNormal = 0,
+ NotifyGrab = 1,
+ NotifyUngrab = 2
+ }
+
+ internal enum NotifyDetail {
+ NotifyAncestor = 0,
+ NotifyVirtual = 1,
+ NotifyInferior = 2,
+ NotifyNonlinear = 3,
+ NotifyNonlinearVirtual = 4,
+ NotifyPointer = 5,
+ NotifyPointerRoot = 6,
+ NotifyDetailNone = 7
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct MotifWmHints {
+ internal IntPtr flags;
+ internal IntPtr functions;
+ internal IntPtr decorations;
+ internal IntPtr input_mode;
+ internal IntPtr status;
+ }
+
+ [Flags]
+ internal enum MotifFlags {
+ Functions = 1,
+ Decorations = 2,
+ InputMode = 4,
+ Status = 8
+ }
+
+ [Flags]
+ internal enum MotifFunctions {
+ All = 0x01,
+ Resize = 0x02,
+ Move = 0x04,
+ Minimize = 0x08,
+ Maximize = 0x10,
+ Close = 0x20
+ }
+
+ [Flags]
+ internal enum MotifDecorations {
+ All = 0x01,
+ Border = 0x02,
+ ResizeH = 0x04,
+ Title = 0x08,
+ Menu = 0x10,
+ Minimize = 0x20,
+ Maximize = 0x40,
+
+ }
+
+ [Flags]
+ internal enum MotifInputMode {
+ Modeless = 0,
+ ApplicationModal = 1,
+ SystemModal = 2,
+ FullApplicationMondal = 3
+ }
+
+ [Flags]
+ internal enum KeyMasks {
+ ShiftMask = (1 << 0),
+ LockMask = (1 << 1),
+ ControlMask = (1 << 2),
+ Mod1Mask = (1 << 3),
+ Mod2Mask = (1 << 4),
+ Mod3Mask = (1 << 5),
+ Mod4Mask = (1 << 6),
+ Mod5Mask = (1 << 7),
+
+ ModMasks = Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask
+ }
+
+ [StructLayout (LayoutKind.Sequential)]
+ internal struct XModifierKeymap {
+ public int max_keypermod;
+ public IntPtr modifiermap;
+ }
+
+ internal enum PropertyMode {
+ Replace = 0,
+ Prepend = 1,
+ Append = 2
+ }
+
+ [StructLayout (LayoutKind.Sequential)]
+ internal struct XKeyBoardState {
+ int key_click_percent;
+ int bell_percent;
+ uint bell_pitch, bell_duration;
+ IntPtr led_mask;
+ int global_auto_repeat;
+ AutoRepeats auto_repeats;
+
+ [StructLayout (LayoutKind.Explicit)]
+ struct AutoRepeats {
+ [FieldOffset (0)]
+ byte first;
+
+ [FieldOffset (31)]
+ byte last;
+ }
+ }
+
+ [Flags]
+ internal enum GCFunction {
+ GCFunction = 1<<0,
+ GCPlaneMask = 1<<1,
+ GCForeground = 1<<2,
+ GCBackground = 1<<3,
+ GCLineWidth = 1<<4,
+ GCLineStyle = 1<<5,
+ GCCapStyle = 1<<6,
+ GCJoinStyle = 1<<7,
+ GCFillStyle = 1<<8,
+ GCFillRule = 1<<9,
+ GCTile = 1<<10,
+ GCStipple = 1<<11,
+ GCTileStipXOrigin = 1<<12,
+ GCTileStipYOrigin = 1<<13,
+ GCFont = 1<<14,
+ GCSubwindowMode = 1<<15,
+ GCGraphicsExposures = 1<<16,
+ GCClipXOrigin = 1<<17,
+ GCClipYOrigin = 1<<18,
+ GCClipMask = 1<<19,
+ GCDashOffset = 1<<20,
+ GCDashList = 1<<21,
+ GCArcMode = 1<<22
+ }
+
+ internal enum GCJoinStyle {
+ JoinMiter = 0,
+ JoinRound = 1,
+ JoinBevel = 2
+ }
+
+ internal enum GCLineStyle {
+ LineSolid = 0,
+ LineOnOffDash = 1,
+ LineDoubleDash = 2
+ }
+
+ internal enum GCCapStyle {
+ CapNotLast = 0,
+ CapButt = 1,
+ CapRound = 2,
+ CapProjecting = 3
+ }
+
+ internal enum GCFillStyle {
+ FillSolid = 0,
+ FillTiled = 1,
+ FillStippled = 2,
+ FillOpaqueStppled = 3
+ }
+
+ internal enum GCFillRule {
+ EvenOddRule = 0,
+ WindingRule = 1
+ }
+
+ internal enum GCArcMode {
+ ArcChord = 0,
+ ArcPieSlice = 1
+ }
+
+ internal enum GCSubwindowMode {
+ ClipByChildren = 0,
+ IncludeInferiors = 1
+ }
+
+ [StructLayout (LayoutKind.Sequential)]
+ internal struct XGCValues {
+ internal GXFunction function;
+ internal IntPtr plane_mask;
+ internal IntPtr foreground;
+ internal IntPtr background;
+ internal int line_width;
+ internal GCLineStyle line_style;
+ internal GCCapStyle cap_style;
+ internal GCJoinStyle join_style;
+ internal GCFillStyle fill_style;
+ internal GCFillRule fill_rule;
+ internal GCArcMode arc_mode;
+ internal IntPtr tile;
+ internal IntPtr stipple;
+ internal int ts_x_origin;
+ internal int ts_y_origin;
+ internal IntPtr font;
+ internal GCSubwindowMode subwindow_mode;
+ internal bool graphics_exposures;
+ internal int clip_x_origin;
+ internal int clib_y_origin;
+ internal IntPtr clip_mask;
+ internal int dash_offset;
+ internal byte dashes;
+ }
+
+ internal enum GXFunction {
+ GXclear = 0x0, /* 0 */
+ GXand = 0x1, /* src AND dst */
+ GXandReverse = 0x2, /* src AND NOT dst */
+ GXcopy = 0x3, /* src */
+ GXandInverted = 0x4, /* NOT src AND dst */
+ GXnoop = 0x5, /* dst */
+ GXxor = 0x6, /* src XOR dst */
+ GXor = 0x7, /* src OR dst */
+ GXnor = 0x8, /* NOT src AND NOT dst */
+ GXequiv = 0x9, /* NOT src XOR dst */
+ GXinvert = 0xa, /* NOT dst */
+ GXorReverse = 0xb, /* src OR NOT dst */
+ GXcopyInverted = 0xc, /* NOT src */
+ GXorInverted = 0xd, /* NOT src OR dst */
+ GXnand = 0xe, /* NOT src OR NOT dst */
+ GXset = 0xf /* 1 */
+ }
+
+ internal enum NetWindowManagerState {
+ Remove = 0,
+ Add = 1,
+ Toggle = 2
+ }
+
+ internal enum RevertTo {
+ None = 0,
+ PointerRoot = 1,
+ Parent = 2
+ }
+
+ internal enum MapState {
+ IsUnmapped = 0,
+ IsUnviewable = 1,
+ IsViewable = 2
+ }
+
+ internal enum CursorFontShape {
+ XC_X_cursor = 0,
+ XC_arrow = 2,
+ XC_based_arrow_down = 4,
+ XC_based_arrow_up = 6,
+ XC_boat = 8,
+ XC_bogosity = 10,
+ XC_bottom_left_corner = 12,
+ XC_bottom_right_corner = 14,
+ XC_bottom_side = 16,
+ XC_bottom_tee = 18,
+ XC_box_spiral = 20,
+ XC_center_ptr = 22,
+
+ XC_circle = 24,
+ XC_clock = 26,
+ XC_coffee_mug = 28,
+ XC_cross = 30,
+ XC_cross_reverse = 32,
+ XC_crosshair = 34,
+ XC_diamond_cross = 36,
+ XC_dot = 38,
+ XC_dotbox = 40,
+ XC_double_arrow = 42,
+ XC_draft_large = 44,
+ XC_draft_small = 46,
+
+ XC_draped_box = 48,
+ XC_exchange = 50,
+ XC_fleur = 52,
+ XC_gobbler = 54,
+ XC_gumby = 56,
+ XC_hand1 = 58,
+ XC_hand2 = 60,
+ XC_heart = 62,
+ XC_icon = 64,
+ XC_iron_cross = 66,
+ XC_left_ptr = 68,
+ XC_left_side = 70,
+
+ XC_left_tee = 72,
+ XC_left_button = 74,
+ XC_ll_angle = 76,
+ XC_lr_angle = 78,
+ XC_man = 80,
+ XC_middlebutton = 82,
+ XC_mouse = 84,
+ XC_pencil = 86,
+ XC_pirate = 88,
+ XC_plus = 90,
+ XC_question_arrow = 92,
+ XC_right_ptr = 94,
+
+ XC_right_side = 96,
+ XC_right_tee = 98,
+ XC_rightbutton = 100,
+ XC_rtl_logo = 102,
+ XC_sailboat = 104,
+ XC_sb_down_arrow = 106,
+ XC_sb_h_double_arrow = 108,
+ XC_sb_left_arrow = 110,
+ XC_sb_right_arrow = 112,
+ XC_sb_up_arrow = 114,
+ XC_sb_v_double_arrow = 116,
+ XC_sb_shuttle = 118,
+
+ XC_sizing = 120,
+ XC_spider = 122,
+ XC_spraycan = 124,
+ XC_star = 126,
+ XC_target = 128,
+ XC_tcross = 130,
+ XC_top_left_arrow = 132,
+ XC_top_left_corner = 134,
+ XC_top_right_corner = 136,
+ XC_top_side = 138,
+ XC_top_tee = 140,
+ XC_trek = 142,
+
+ XC_ul_angle = 144,
+ XC_umbrella = 146,
+ XC_ur_angle = 148,
+ XC_watch = 150,
+ XC_xterm = 152,
+ XC_num_glyphs = 154
+ }
+
+ internal enum SystrayRequest {
+ SYSTEM_TRAY_REQUEST_DOCK = 0,
+ SYSTEM_TRAY_BEGIN_MESSAGE = 1,
+ SYSTEM_TRAY_CANCEL_MESSAGE = 2
+ }
+
+ [Flags]
+ internal enum XSizeHintsFlags {
+ USPosition = (1 << 0),
+ USSize = (1 << 1),
+ PPosition = (1 << 2),
+ PSize = (1 << 3),
+ PMinSize = (1 << 4),
+ PMaxSize = (1 << 5),
+ PResizeInc = (1 << 6),
+ PAspect = (1 << 7),
+ PAllHints = (PPosition | PSize | PMinSize | PMaxSize | PResizeInc | PAspect),
+ PBaseSize = (1 << 8),
+ PWinGravity = (1 << 9),
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XSizeHints {
+ internal IntPtr flags;
+ internal int x;
+ internal int y;
+ internal int width;
+ internal int height;
+ internal int min_width;
+ internal int min_height;
+ internal int max_width;
+ internal int max_height;
+ internal int width_inc;
+ internal int height_inc;
+ internal int min_aspect_x;
+ internal int min_aspect_y;
+ internal int max_aspect_x;
+ internal int max_aspect_y;
+ internal int base_width;
+ internal int base_height;
+ internal int win_gravity;
+ }
+
+ [Flags]
+ internal enum XWMHintsFlags {
+ InputHint = (1 << 0),
+ StateHint = (1 << 1),
+ IconPixmapHint = (1 << 2),
+ IconWindowHint = (1 << 3),
+ IconPositionHint = (1 << 4),
+ IconMaskHint = (1 << 5),
+ WindowGroupHint = (1 << 6),
+ AllHints = (InputHint | StateHint | IconPixmapHint | IconWindowHint | IconPositionHint | IconMaskHint | WindowGroupHint)
+ }
+
+ internal enum XInitialState {
+ DontCareState = 0,
+ NormalState = 1,
+ ZoomState = 2,
+ IconicState = 3,
+ InactiveState = 4
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XWMHints {
+ internal IntPtr flags;
+ internal bool input;
+ internal XInitialState initial_state;
+ internal IntPtr icon_pixmap;
+ internal IntPtr icon_window;
+ internal int icon_x;
+ internal int icon_y;
+ internal IntPtr icon_mask;
+ internal IntPtr window_group;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XIconSize {
+ internal int min_width;
+ internal int min_height;
+ internal int max_width;
+ internal int max_height;
+ internal int width_inc;
+ internal int height_inc;
+ }
+
+ internal enum NA {
+ WM_PROTOCOLS,
+ WM_DELETE_WINDOW,
+ WM_TAKE_FOCUS,
+
+ _NET_SUPPORTED,
+ _NET_CLIENT_LIST,
+ _NET_NUMBER_OF_DESKTOPS,
+ _NET_DESKTOP_GEOMETRY,
+ _NET_DESKTOP_VIEWPORT,
+ _NET_CURRENT_DESKTOP,
+ _NET_DESKTOP_NAMES,
+ _NET_ACTIVE_WINDOW,
+ _NET_WORKAREA,
+ _NET_SUPPORTING_WM_CHECK,
+ _NET_VIRTUAL_ROOTS,
+ _NET_DESKTOP_LAYOUT,
+ _NET_SHOWING_DESKTOP,
+
+ _NET_CLOSE_WINDOW,
+ _NET_MOVERESIZE_WINDOW,
+ _NET_WM_MOVERESIZE,
+ _NET_RESTACK_WINDOW,
+ _NET_REQUEST_FRAME_EXTENTS,
+
+ _NET_WM_NAME,
+ _NET_WM_VISIBLE_NAME,
+ _NET_WM_ICON_NAME,
+ _NET_WM_VISIBLE_ICON_NAME,
+ _NET_WM_DESKTOP,
+ _NET_WM_WINDOW_TYPE,
+ _NET_WM_STATE,
+ _NET_WM_ALLOWED_ACTIONS,
+ _NET_WM_STRUT,
+ _NET_WM_STRUT_PARTIAL,
+ _NET_WM_ICON_GEOMETRY,
+ _NET_WM_ICON,
+ _NET_WM_PID,
+ _NET_WM_HANDLED_ICONS,
+ _NET_WM_USER_TIME,
+ _NET_FRAME_EXTENTS,
+
+ _NET_WM_PING,
+ _NET_WM_SYNC_REQUEST,
+
+ _NET_SYSTEM_TRAY_S,
+ _NET_SYSTEM_TRAY_ORIENTATION,
+ _NET_SYSTEM_TRAY_OPCODE,
+
+ _NET_WM_STATE_MAXIMIZED_HORZ,
+ _NET_WM_STATE_MAXIMIZED_VERT,
+
+ _XEMBED,
+ _XEMBED_INFO,
+
+ _MOTIF_WM_HINTS,
+
+ _NET_WM_STATE_NO_TASKBAR,
+ _NET_WM_STATE_ABOVE,
+ _NET_WM_STATE_MODAL,
+ _NET_WM_STATE_HIDDEN,
+ _NET_WM_CONTEXT_HELP,
+
+ _NET_WM_WINDOW_OPACITY,
+
+ CLIPBOARD,
+ DIB,
+ OEMTEXT,
+ UNICODETEXT,
+ TARGETS,
+
+ LAST_NET_ATOM
+ }
+
+ internal struct CaretStruct {
+ internal Timer Timer; // Blink interval
+ internal IntPtr Hwnd; // Window owning the caret
+ internal IntPtr Window; // Actual X11 handle of the window
+ internal int X; // X position of the caret
+ internal int Y; // Y position of the caret
+ internal int Width; // Width of the caret; if no image used
+ internal int Height; // Height of the caret, if no image used
+ internal bool Visible; // Is caret visible?
+ internal bool On; // Caret blink display state: On/Off
+ internal IntPtr gc; // Graphics context
+ internal bool Paused; // Don't update right now
+ }
+
+ internal struct HoverStruct {
+ internal Timer Timer; // for hovering
+ internal IntPtr Window; // Last window we entered; used to generate WM_MOUSEHOVER (handle is X11 handle)
+ internal int X; // Last MouseMove X coordinate; used to generate WM_MOUSEHOVER
+ internal int Y; // Last MouseMove Y coordinate; used to generate WM_MOUSEHOVER
+ internal Size Size; // Size of the rectangle the mouse has to stay in to generate hover
+ internal int Interval; // in milliseconds, how long to hold before hover is generated
+ internal IntPtr Atom; // X Atom
+ }
+
+ internal struct ClickStruct {
+ internal IntPtr Hwnd; //
+ internal Msg Message; //
+ internal IntPtr wParam; //
+ internal IntPtr lParam; //
+ internal long Time; // Last time we received a mouse click
+ internal bool Pending; // True if we haven't sent the last mouse click
+ }
+
+ internal struct GrabStruct {
+ internal bool Confined; // Is the current grab (if any) confined to grab_area?
+ internal IntPtr Hwnd; // The window that is grabbed
+ internal Rectangle Area; // The area the current grab is confined to
+ }
+
+ internal struct ClipboardStruct {
+ internal object Item; // Object on the clipboard
+ internal object Type; // Type if object on the clipboard
+ internal ArrayList Formats; // list of formats available in the clipboard
+ internal bool Retrieving; // true if we are requesting an item
+ internal bool Enumerating; // true if we are enumerating through all known types
+ internal XplatUI.ObjectToClipboard Converter;
+ }
+
+ internal delegate int XErrorHandler(IntPtr DisplayHandle, ref XErrorEvent error_event);
+
+ internal enum XRequest : byte {
+ X_CreateWindow = 1,
+ X_ChangeWindowAttributes = 2,
+ X_GetWindowAttributes = 3,
+ X_DestroyWindow = 4,
+ X_DestroySubwindows = 5,
+ X_ChangeSaveSet = 6,
+ X_ReparentWindow = 7,
+ X_MapWindow = 8,
+ X_MapSubwindows = 9,
+ X_UnmapWindow = 10,
+ X_UnmapSubwindows = 11,
+ X_ConfigureWindow = 12,
+ X_CirculateWindow = 13,
+ X_GetGeometry = 14,
+ X_QueryTree = 15,
+ X_InternAtom = 16,
+ X_GetAtomName = 17,
+ X_ChangeProperty = 18,
+ X_DeleteProperty = 19,
+ X_GetProperty = 20,
+ X_ListProperties = 21,
+ X_SetSelectionOwner = 22,
+ X_GetSelectionOwner = 23,
+ X_ConvertSelection = 24,
+ X_SendEvent = 25,
+ X_GrabPointer = 26,
+ X_UngrabPointer = 27,
+ X_GrabButton = 28,
+ X_UngrabButton = 29,
+ X_ChangeActivePointerGrab = 30,
+ X_GrabKeyboard = 31,
+ X_UngrabKeyboard = 32,
+ X_GrabKey = 33,
+ X_UngrabKey = 34,
+ X_AllowEvents = 35,
+ X_GrabServer = 36,
+ X_UngrabServer = 37,
+ X_QueryPointer = 38,
+ X_GetMotionEvents = 39,
+ X_TranslateCoords = 40,
+ X_WarpPointer = 41,
+ X_SetInputFocus = 42,
+ X_GetInputFocus = 43,
+ X_QueryKeymap = 44,
+ X_OpenFont = 45,
+ X_CloseFont = 46,
+ X_QueryFont = 47,
+ X_QueryTextExtents = 48,
+ X_ListFonts = 49,
+ X_ListFontsWithInfo = 50,
+ X_SetFontPath = 51,
+ X_GetFontPath = 52,
+ X_CreatePixmap = 53,
+ X_FreePixmap = 54,
+ X_CreateGC = 55,
+ X_ChangeGC = 56,
+ X_CopyGC = 57,
+ X_SetDashes = 58,
+ X_SetClipRectangles = 59,
+ X_FreeGC = 60,
+ X_ClearArea = 61,
+ X_CopyArea = 62,
+ X_CopyPlane = 63,
+ X_PolyPoint = 64,
+ X_PolyLine = 65,
+ X_PolySegment = 66,
+ X_PolyRectangle = 67,
+ X_PolyArc = 68,
+ X_FillPoly = 69,
+ X_PolyFillRectangle = 70,
+ X_PolyFillArc = 71,
+ X_PutImage = 72,
+ X_GetImage = 73,
+ X_PolyText8 = 74,
+ X_PolyText16 = 75,
+ X_ImageText8 = 76,
+ X_ImageText16 = 77,
+ X_CreateColormap = 78,
+ X_FreeColormap = 79,
+ X_CopyColormapAndFree = 80,
+ X_InstallColormap = 81,
+ X_UninstallColormap = 82,
+ X_ListInstalledColormaps = 83,
+ X_AllocColor = 84,
+ X_AllocNamedColor = 85,
+ X_AllocColorCells = 86,
+ X_AllocColorPlanes = 87,
+ X_FreeColors = 88,
+ X_StoreColors = 89,
+ X_StoreNamedColor = 90,
+ X_QueryColors = 91,
+ X_LookupColor = 92,
+ X_CreateCursor = 93,
+ X_CreateGlyphCursor = 94,
+ X_FreeCursor = 95,
+ X_RecolorCursor = 96,
+ X_QueryBestSize = 97,
+ X_QueryExtension = 98,
+ X_ListExtensions = 99,
+ X_ChangeKeyboardMapping = 100,
+ X_GetKeyboardMapping = 101,
+ X_ChangeKeyboardControl = 102,
+ X_GetKeyboardControl = 103,
+ X_Bell = 104,
+ X_ChangePointerControl = 105,
+ X_GetPointerControl = 106,
+ X_SetScreenSaver = 107,
+ X_GetScreenSaver = 108,
+ X_ChangeHosts = 109,
+ X_ListHosts = 110,
+ X_SetAccessControl = 111,
+ X_SetCloseDownMode = 112,
+ X_KillClient = 113,
+ X_RotateProperties = 114,
+ X_ForceScreenSaver = 115,
+ X_SetPointerMapping = 116,
+ X_GetPointerMapping = 117,
+ X_SetModifierMapping = 118,
+ X_GetModifierMapping = 119,
+ X_NoOperation = 127
+ }
+
+ [Flags]
+ internal enum XIMProperties {
+ XIMPreeditArea = 0x0001,
+ XIMPreeditCallbacks = 0x0002,
+ XIMPreeditPosition = 0x0004,
+ XIMPreeditNothing = 0x0008,
+ XIMPreeditNone = 0x0010,
+ XIMStatusArea = 0x0100,
+ XIMStatusCallbacks = 0x0200,
+ XIMStatusNothing = 0x0400,
+ XIMStatusNone = 0x0800,
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XEventQueue.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XEventQueue.cs
new file mode 100644
index 00000000000..313bafd8b05
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XEventQueue.cs
@@ -0,0 +1,109 @@
+//
+// System.Windows.Forms.XEventQueue
+//
+// Author(s):
+// Jackson Harper (jackson@ximian.com)
+//
+// Copyright (C) Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using System.Threading;
+using System.Collections;
+
+
+namespace System.Windows.Forms {
+
+ internal class XEventQueue {
+
+ private XQueue xqueue;
+ private XQueue lqueue; // Events inserted from threads other then the main X thread
+
+ private static readonly int InitialXEventSize = 100;
+ private static readonly int InitialLXEventSize = 10;
+
+ public XEventQueue ()
+ {
+ xqueue = new XQueue (InitialXEventSize);
+ lqueue = new XQueue (InitialLXEventSize);
+ }
+
+ public int Count {
+ get {
+ lock (lqueue) {
+ return xqueue.Count + lqueue.Count;
+ }
+ }
+ }
+
+ public void Enqueue (XEvent xevent)
+ {
+ xqueue.Enqueue (xevent);
+ }
+
+ public void EnqueueLocked (XEvent xevent)
+ {
+ lock (lqueue) {
+ lqueue.Enqueue (xevent);
+ }
+ }
+
+ public XEvent Dequeue ()
+ {
+ if (xqueue.Count == 0) {
+ lock (lqueue) {
+ return lqueue.Dequeue ();
+ }
+ }
+ return xqueue.Dequeue ();
+ }
+
+ private class XQueue {
+
+ private XEvent [] xevents;
+ private int head;
+ private int tail;
+ private int size;
+
+ public XQueue (int size)
+ {
+ xevents = new XEvent [size];
+ }
+
+ public int Count {
+ get { return size; }
+ }
+
+ public void Enqueue (XEvent xevent)
+ {
+ if (size == xevents.Length)
+ Grow ();
+
+ xevents [tail] = xevent;
+ tail = (tail + 1) % xevents.Length;
+ size++;
+ }
+
+ public XEvent Dequeue ()
+ {
+ if (size < 1)
+ throw new Exception ("Attempt to dequeue empty queue.");
+ XEvent res = xevents [head];
+ head = (head + 1) % xevents.Length;
+ size--;
+ return res;
+ }
+
+ private void Grow ()
+ {
+ int newcap = (xevents.Length * 2);
+ XEvent [] na = new XEvent [newcap];
+ xevents.CopyTo (na, 0);
+ xevents = na;
+ head = 0;
+ tail = head + size;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs
new file mode 100644
index 00000000000..2aa6e623a07
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs
@@ -0,0 +1,897 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+
+// NOT COMPLETE
+
+// define to log API calls to stdout
+#undef DriverDebug
+#undef DriverDebugPaint
+#undef DriverDebugCreate
+#undef DriverDebugDestroy
+#undef DriverDebugState
+
+using System;
+using System.Drawing;
+using System.ComponentModel;
+using System.Collections;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+using System.Threading;
+
+namespace System.Windows.Forms {
+ internal class XplatUI {
+ #region Local Variables
+ static XplatUIDriver driver;
+ static String default_class_name;
+ #endregion // Local Variables
+
+ #region Private Methods
+ internal static string Window(IntPtr handle) {
+ return String.Format("'{0}' ({1:X})", Control.FromHandle(handle), handle.ToInt32());
+ }
+ #endregion // Private Methods
+
+ #region Subclasses
+ public class State {
+ static public Keys ModifierKeys {
+ get {
+ return driver.ModifierKeys;
+ }
+ }
+
+ static public MouseButtons MouseButtons {
+ get {
+ return driver.MouseButtons;
+ }
+ }
+
+ static public Point MousePosition {
+ get {
+ return driver.MousePosition;
+ }
+ }
+
+ }
+ #endregion // Subclasses
+
+ #region Constructor & Destructor
+ static XplatUI() {
+ Console.WriteLine("Mono System.Windows.Forms Assembly [$auto_build_revision$]");
+
+ default_class_name="SWFClass";
+
+ // 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)) {
+ if (Environment.GetEnvironmentVariable ("MONO_MWF_USE_QUARTZ_BACKEND") != null)
+ driver=XplatUIOSX.GetInstance();
+ else
+ driver=XplatUIX11.GetInstance();
+ } else {
+ driver=XplatUIWin32.GetInstance();
+ }
+
+ driver.InitializeDriver();
+
+ // Initialize things that need to be done after the driver is ready
+ DataFormats.GetFormat(0);
+ }
+ #endregion // Constructor & Destructor
+
+ #region Public Static Properties
+ internal static string DefaultClassName {
+ get {
+ return default_class_name;
+ }
+
+ set {
+ default_class_name=value;
+ }
+ }
+
+ static public int CaptionHeight {
+ get {
+ return driver.Caption;
+ }
+ }
+
+ static public Size CursorSize {
+ get {
+ return driver.CursorSize;
+ }
+ }
+
+ static public bool DragFullWindows {
+ get {
+ return driver.DragFullWindows;
+ }
+ }
+
+ static public Size DragSize {
+ get {
+ return driver.DragSize;
+ }
+ }
+
+ public static Size FrameBorderSize {
+ get {
+ return driver.FrameBorderSize;
+ }
+ }
+
+ static public Size IconSize {
+ get {
+ return driver.IconSize;
+ }
+ }
+
+ static public int KeyboardSpeed {
+ get {
+ return driver.KeyboardSpeed;
+ }
+ }
+
+ static public int KeyboardDelay {
+ get {
+ return driver.KeyboardSpeed;
+ }
+ }
+
+ static public Size MaxWindowTrackSize {
+ get {
+ return driver.MaxWindowTrackSize;
+ }
+ }
+
+ static public Size MinimizedWindowSize {
+ get {
+ return driver.MinimizedWindowSize;
+ }
+ }
+
+ static public Size MinimizedWindowSpacingSize {
+ get {
+ return driver.MinimizedWindowSpacingSize;
+ }
+ }
+
+ static public Size MinimumWindowSize {
+ get {
+ return driver.MinimumWindowSize;
+ }
+ }
+
+ static public Size MinWindowTrackSize {
+ get {
+ return driver.MinWindowTrackSize;
+ }
+ }
+
+ static public Size SmallIconSize {
+ get {
+ return driver.SmallIconSize;
+ }
+ }
+
+ static public int MouseButtonCount {
+ get {
+ return driver.MouseButtonCount;
+ }
+ }
+
+ static public bool MouseButtonsSwapped {
+ get {
+ return driver.MouseButtonsSwapped;
+ }
+ }
+
+ static public Size MouseHoverSize {
+ get {
+ return driver.MouseHoverSize;
+ }
+ }
+
+ static public int MouseHoverTime {
+ get {
+ return driver.MouseHoverTime;
+ }
+ }
+
+ static public bool MouseWheelPresent {
+ get {
+ return driver.MouseWheelPresent;
+ }
+ }
+
+ static public Rectangle VirtualScreen {
+ get {
+ return driver.VirtualScreen;
+ }
+ }
+
+ static public Rectangle WorkingArea {
+ get {
+ return driver.WorkingArea;
+ }
+ }
+ #endregion // Public Static Properties
+
+ #region Events
+ internal static event EventHandler Idle {
+ add {
+ driver.Idle += value;
+ }
+ remove {
+ driver.Idle -= value;
+ }
+ }
+
+ #endregion // Events
+
+ #region Public Static Methods
+ internal static void Activate(IntPtr handle) {
+ #if DriverDebug
+ Console.WriteLine("Activate({0}): Called", Window(handle));
+ #endif
+ driver.Activate(handle);
+ }
+
+ internal static void AudibleAlert() {
+ #if DriverDebug
+ Console.WriteLine("AudibleAlert(): Called");
+ #endif
+ driver.AudibleAlert();
+ }
+
+ internal static bool CalculateWindowRect(ref Rectangle ClientRect, int Style, int ExStyle, Menu menu, out Rectangle WindowRect) {
+ #if DriverDebug
+ Console.WriteLine("CalculateWindowRect({0}, {1}, {2}, {3}): Called", ClientRect, Style, ExStyle, menu);
+ #endif
+ return driver.CalculateWindowRect(ref ClientRect, Style, ExStyle, menu, out WindowRect);
+ }
+
+ internal static void CaretVisible(IntPtr handle, bool visible) {
+ #if DriverDebug
+ Console.WriteLine("CaretVisible({0:X}, {1}): Called", handle.ToInt32(), visible);
+ #endif
+ driver.CaretVisible(handle, visible);
+ }
+
+ internal static void CreateCaret(IntPtr handle, int width, int height) {
+ #if DriverDebug
+ Console.WriteLine("CreateCaret({0:X}), {1}, {2}: Called", handle.ToInt32(), width, height);
+ #endif
+ driver.CreateCaret(handle, width, height);
+ }
+
+ internal static IntPtr CreateWindow(CreateParams cp) {
+ #if DriverDebug || DriverDebugCreate
+ IntPtr handle;
+
+ handle = driver.CreateWindow(cp);
+
+ Console.WriteLine("CreateWindow(): Called, returning {0:X}", handle.ToInt32());
+ return handle;
+ #else
+ return driver.CreateWindow(cp);
+ #endif
+ }
+
+ internal static IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
+ #if DriverDebug || DriverDebugCreate
+ Console.WriteLine("CreateWindow(): Called");
+ #endif
+ return driver.CreateWindow(Parent, X, Y, Width, Height);
+ }
+
+ internal static void ClientToScreen(IntPtr handle, ref int x, ref int y) {
+ #if DriverDebug
+ Console.WriteLine("ClientToScreen({0}, {1}, {2}): Called", Window(handle), x, y);
+ #endif
+ driver.ClientToScreen(handle, ref x, ref y);
+ }
+
+ internal static int[] ClipboardAvailableFormats(IntPtr handle) {
+ #if DriverDebug
+ Console.WriteLine("ClipboardAvailableTypes({0:X}): Called", handle.ToInt32());
+ #endif
+ return driver.ClipboardAvailableFormats(handle);
+ }
+
+ internal static void ClipboardClose(IntPtr handle) {
+ #if DriverDebug
+ Console.WriteLine("ClipboardClose({0:X}): Called", handle.ToInt32());
+ #endif
+ driver.ClipboardClose(handle);
+ }
+
+ internal static int ClipboardGetID(IntPtr handle, string format) {
+ #if DriverDebug
+ Console.WriteLine("ClipboardGetID({0:X}, {1}): Called", handle.ToInt32(), format);
+ #endif
+ return driver.ClipboardGetID(handle, format);
+ }
+
+ internal static IntPtr ClipboardOpen() {
+ #if DriverDebug
+ Console.WriteLine("ClipboardOpen(): Called");
+ #endif
+ return driver.ClipboardOpen();
+ }
+
+ internal static void ClipboardStore(IntPtr handle, object obj, int type, XplatUI.ObjectToClipboard converter) {
+ #if DriverDebug
+ Console.WriteLine("ClipboardStore({0:X}, {1}, {2}): Called", handle.ToInt32(), obj, type, converter);
+ #endif
+ driver.ClipboardStore(handle, obj, type, converter);
+ }
+
+ internal static object ClipboardRetrieve(IntPtr handle, int type, XplatUI.ClipboardToObject converter) {
+ #if DriverDebug
+ Console.WriteLine("ClipboardRetrieve({0:X}, type, {1}): Called", handle.ToInt32(), converter);
+ #endif
+ return driver.ClipboardRetrieve(handle, type, converter);
+ }
+
+ internal static IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
+ #if DriverDebug
+ Console.WriteLine("DefineCursor(...): Called");
+ #endif
+ return driver.DefineCursor(bitmap, mask, cursor_pixel, mask_pixel, xHotSpot, yHotSpot);
+ }
+
+ internal static IntPtr DefineStdCursor(StdCursor id) {
+ return driver.DefineStdCursor(id);
+ }
+
+ internal static IntPtr DefWndProc(ref Message msg) {
+ return driver.DefWndProc(ref msg);
+ }
+
+ internal static void DestroyCaret(IntPtr handle) {
+ #if DriverDebug
+ Console.WriteLine("DestroyCaret({0:X}): Called", handle.ToInt32());
+ #endif
+ driver.DestroyCaret(handle);
+ }
+
+ internal static void DestroyCursor(IntPtr cursor) {
+ #if DriverDebug
+ Console.WriteLine("DestroyCursor({0:X}): Called", cursor.ToInt32());
+ #endif
+ driver.DestroyCursor(cursor);
+ }
+
+ internal static void DestroyWindow(IntPtr handle) {
+ #if DriverDebug || DriverDebugDestroy
+ Console.WriteLine("DestroyWindow({0}): Called", Window(handle));
+ #endif
+ driver.DestroyWindow(handle);
+ }
+
+ internal static IntPtr DispatchMessage(ref MSG msg) {
+ return driver.DispatchMessage(ref msg);
+ }
+
+ internal static void DoEvents() {
+ driver.DoEvents();
+ }
+
+ internal static void DrawReversibleRectangle(IntPtr handle, Rectangle rect, int line_width) {
+ #if DriverDebug
+ Console.WriteLine("DrawReversibleRectangle({0}, {1}, {2}): Called", Window(handle), rect, line_width);
+ #endif
+ driver.DrawReversibleRectangle(handle, rect, line_width);
+ }
+
+ internal static void EnableThemes() {
+ driver.EnableThemes();
+ }
+
+ internal static void EnableWindow(IntPtr handle, bool Enable) {
+ #if DriverDebug || DriverDebugState
+ Console.WriteLine("EnableWindow({0}, {1}): Called", Window(handle), Enable);
+ #endif
+ driver.EnableWindow(handle, Enable);
+ }
+
+ internal static void EndLoop(Thread thread) {
+ #if DriverDebug
+ Console.WriteLine("EndLoop({0:X}): Called", thread.GetHashCode());
+ #endif
+ driver.EndLoop(thread);
+ }
+
+ internal static IntPtr GetActive() {
+ #if DriverDebug
+ Console.WriteLine("GetActive(): Called");
+ #endif
+ return driver.GetActive();
+ }
+
+ internal static SizeF GetAutoScaleSize(Font font) {
+ #if DriverDebug
+ Console.WriteLine("GetAutoScaleSize({0}): Called", font);
+ #endif
+ return driver.GetAutoScaleSize(font);
+ }
+
+ internal static void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
+ #if DriverDebug
+ Console.WriteLine("GetCursorInfo({0}): Called", cursor.ToInt32());
+ #endif
+ driver.GetCursorInfo(cursor, out width, out height, out hotspot_x, out hotspot_y);
+ }
+
+ internal static void GetCursorPos(IntPtr handle, out int x, out int y) {
+ #if DriverDebug
+ Console.WriteLine("GetCursorPos({0}): Called", Window(handle));
+ #endif
+ driver.GetCursorPos(handle, out x, out y);
+ }
+
+ internal static void GetDisplaySize(out Size size) {
+ #if DriverDebug
+ Console.WriteLine("GetDisplaySize(): Called");
+ #endif
+ driver.GetDisplaySize(out size);
+ }
+
+ internal static bool GetFontMetrics(Graphics g, Font font, out int ascent, out int descent) {
+ #if DriverDebug
+ Console.WriteLine("GetFontMetrics(): Called");
+ #endif
+ return driver.GetFontMetrics(g, font, out ascent, out descent);
+ }
+
+ internal static Point GetMenuOrigin(IntPtr handle) {
+ #if DriverDebug
+ Console.WriteLine("GetMenuOrigin({0}): Called", Window(handle));
+ #endif
+ return driver.GetMenuOrigin(handle);
+ }
+
+ internal static bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
+ return driver.GetMessage(ref msg, hWnd, wFilterMin, wFilterMax);
+ }
+
+ internal static IntPtr GetParent(IntPtr handle) {
+ #if DriverDebug
+ Console.WriteLine("GetParent({0}): Called", Window(handle));
+ #endif
+ return driver.GetParent(handle);
+ }
+
+ internal static bool GetText(IntPtr handle, out string text) {
+ #if DriverDebug
+ Console.WriteLine("GetText({0}): Called", Window(handle));
+ #endif
+ return driver.GetText(handle, out text);
+ }
+
+ internal static void GetWindowPos(IntPtr handle, bool is_toplevel, out int x, out int y, out int width, out int height, out int client_width, out int client_height) {
+ #if DriverDebug
+ Console.WriteLine("GetWindowPos({0}): Called", Window(handle));
+ #endif
+ driver.GetWindowPos(handle, is_toplevel, out x, out y, out width, out height, out client_width, out client_height);
+ }
+
+ internal static FormWindowState GetWindowState(IntPtr handle) {
+ #if DriverDebug
+ Console.WriteLine("GetWindowState({0}): Called", Window(handle));
+ #endif
+ return driver.GetWindowState(handle);
+ }
+
+ internal static void GrabInfo(out IntPtr handle, out bool GrabConfined, out Rectangle GrabArea) {
+ #if DriverDebug
+ Console.WriteLine("GrabInfo(): Called");
+ #endif
+ driver.GrabInfo(out handle, out GrabConfined, out GrabArea);
+ }
+
+ internal static void GrabWindow(IntPtr handle, IntPtr ConfineToHwnd) {
+ #if DriverDebug
+ Console.WriteLine("GrabWindow({0}, {1}): Called", Window(handle), Window(ConfineToHwnd));
+ #endif
+ driver.GrabWindow(handle, ConfineToHwnd);
+ }
+
+ internal static void HandleException(Exception e) {
+ driver.HandleException(e);
+ }
+
+ internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
+ #if DriverDebug
+ Console.WriteLine("Invalidate({0}, {1}, {2}): Called", Window(handle), rc, clear);
+ #endif
+ driver.Invalidate(handle, rc, clear);
+ }
+
+ internal static bool IsEnabled(IntPtr handle) {
+ #if DriverDebug || DriverDebugState
+ Console.WriteLine("IsEnabled({0}): Called, Result={1}", Window(handle), driver.IsEnabled(handle));
+ #endif
+ return driver.IsEnabled(handle);
+ }
+
+ internal static bool IsVisible(IntPtr handle) {
+ #if DriverDebug || DriverDebugState
+ Console.WriteLine("IsVisible({0}): Called, Result={1}", Window(handle), driver.IsVisible(handle));
+ #endif
+ return driver.IsVisible(handle);
+ }
+
+ internal static void KillTimer (Timer timer)
+ {
+ #if DriverDebug
+ Console.WriteLine("KillTimer({0}): Called", timer);
+ #endif
+ driver.KillTimer (timer);
+ }
+
+ internal static void MenuToScreen(IntPtr handle, ref int x, ref int y) {
+ #if DriverDebug
+ Console.WriteLine("MenuToScreen({0}, {1}, {2}): Called", Window(handle), x, y);
+ #endif
+ driver.MenuToScreen(handle, ref x, ref y);
+ }
+
+ internal static void OverrideCursor(IntPtr cursor) {
+ #if DriverDebug
+ Console.WriteLine("OverrideCursor({0:X}): Called", cursor.ToInt32());
+ #endif
+ driver.OverrideCursor(cursor);
+ }
+
+ internal static void PaintEventEnd(IntPtr handle, bool client) {
+ #if DriverDebug || DriverDebugPaint
+ Console.WriteLine("PaintEventEnd({0}, {1}): Called from thread {2}", Window(handle), client, Thread.CurrentThread.GetHashCode());
+ #endif
+ driver.PaintEventEnd(handle, client);
+ }
+
+ internal static PaintEventArgs PaintEventStart(IntPtr handle, bool client) {
+ #if DriverDebug || DriverDebugPaint
+ Console.WriteLine("PaintEventStart({0}, {1}): Called from thread {2}", Window(handle), client, Thread.CurrentThread.GetHashCode());
+ #endif
+ return driver.PaintEventStart(handle, client);
+ }
+
+ internal static bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
+ return driver.PeekMessage(ref msg, hWnd, wFilterMin, wFilterMax, flags);
+ }
+
+ internal static bool PostMessage(IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) {
+ #if DriverDebug
+ Console.WriteLine("PostMessage({0}, {1}, {2:X}, {3:X}): Called", Window(hwnd), message, wParam.ToInt32(), lParam.ToInt32());
+ #endif
+ return driver.PostMessage(hwnd, message, wParam, lParam);
+ }
+
+ internal static bool PostMessage(ref MSG msg) {
+ #if DriverDebug
+ Console.WriteLine("PostMessage({0}): Called", msg);
+ #endif
+ return driver.PostMessage(msg.hwnd, msg.message, msg.wParam, msg.lParam);
+ }
+
+ internal static void PostQuitMessage(int exitCode) {
+ #if DriverDebug
+ Console.WriteLine("PostQuitMessage({0}): Called", exitCode);
+ #endif
+ driver.PostQuitMessage(exitCode);
+ }
+
+ internal static void RequestNCRecalc(IntPtr handle) {
+ #if DriverDebug
+ Console.WriteLine("RequestNCRecalc({0}): Called", Window(handle));
+ #endif
+ driver.RequestNCRecalc(handle);
+ }
+
+ internal static void ResetMouseHover(IntPtr handle) {
+ #if DriverDebug
+ Console.WriteLine("ResetMouseHover({0}): Called", Window(handle));
+ #endif
+ driver.ResetMouseHover(handle);
+ }
+
+ internal static void ScreenToClient(IntPtr handle, ref int x, ref int y) {
+ #if DriverDebug
+ Console.WriteLine("ScreenToClient({0}, {1}, {2}): Called", Window(handle), x, y);
+ #endif
+ driver.ScreenToClient (handle, ref x, ref y);
+ }
+
+ internal static void ScreenToMenu(IntPtr handle, ref int x, ref int y) {
+ #if DriverDebug
+ Console.WriteLine("ScreenToMenu({0}, {1}, {2}): Called", Window(handle), x, y);
+ #endif
+ driver.ScreenToMenu(handle, ref x, ref y);
+ }
+
+ internal static void ScrollWindow(IntPtr handle, Rectangle rectangle, int XAmount, int YAmount, bool with_children) {
+ #if DriverDebug
+ Console.WriteLine("ScrollWindow({0}, {1}, {2}, {3}, {4}): Called", Window(handle), rectangle, XAmount, YAmount, with_children);
+ #endif
+ driver.ScrollWindow(handle, rectangle, XAmount, YAmount, with_children);
+ }
+
+ internal static void ScrollWindow(IntPtr handle, int XAmount, int YAmount, bool with_children) {
+ #if DriverDebug
+ Console.WriteLine("ScrollWindow({0}, {2}, {3}, {4}): Called", Window(handle), XAmount, YAmount, with_children);
+ #endif
+ driver.ScrollWindow(handle, XAmount, YAmount, with_children);
+ }
+
+ internal static void SendAsyncMethod (AsyncMethodData data) {
+ #if DriverDebug
+ Console.WriteLine("SendAsyncMethod({0}): Called", data);
+ #endif
+ driver.SendAsyncMethod (data);
+ }
+
+ internal static IntPtr SendMessage (IntPtr handle, Msg message, IntPtr wParam, IntPtr lParam) {
+ #if DriverDebug
+ Console.WriteLine("SendMessage ({0}, {1}, {2:X}, {3:X}): Called", Window(handle), message, wParam.ToInt32(), lParam.ToInt32());
+ #endif
+ return driver.SendMessage (handle, message, wParam, lParam);
+ }
+
+ internal static void SendMessage (ref Message m) {
+ #if DriverDebug
+ Console.WriteLine("SendMessage ({0}): Called", m);
+ #endif
+ m.Result = driver.SendMessage(m.HWnd, (Msg)m.Msg, m.WParam, m.LParam);
+ }
+
+ internal static void SetAllowDrop (IntPtr handle, bool value)
+ {
+ #if DriverDebug
+ Console.WriteLine ("SetAllowDrop({0}, {1}): Called", handle, value);
+ #endif
+ driver.SetAllowDrop (handle, value);
+ }
+
+ internal static void SetBorderStyle(IntPtr handle, FormBorderStyle border_style) {
+ #if DriverDebug
+ Console.WriteLine("SetBorderStyle({0}, {1}): Called", Window(handle), border_style);
+ #endif
+ driver.SetBorderStyle(handle, border_style);
+ }
+
+ internal static void SetCaretPos(IntPtr handle, int x, int y) {
+ #if DriverDebug
+ Console.WriteLine("SetCaretPos({0}, {1}, {2}): Called", Window(handle), x, y);
+ #endif
+ driver.SetCaretPos(handle, x, y);
+ }
+
+ internal static void SetCursor(IntPtr handle, IntPtr cursor) {
+ #if DriverDebug
+ Console.WriteLine("SetCursor({0}, {1:X}): Called", Window(handle), cursor.ToInt32());
+ #endif
+ driver.SetCursor(handle, cursor);
+ }
+
+ internal static void SetCursorPos(IntPtr handle, int x, int y) {
+ #if DriverDebug
+ Console.WriteLine("SetCursorPos({0}, {1}, {2}): Called", Window(handle), x, y);
+ #endif
+ driver.SetCursorPos(handle, x, y);
+ }
+
+ internal static void SetFocus(IntPtr handle) {
+ #if DriverDebug
+ Console.WriteLine("SetFocus({0}): Called", Window(handle));
+ #endif
+ driver.SetFocus(handle);
+ }
+
+ internal static void SetIcon(IntPtr handle, Icon icon) {
+ #if DriverDebug
+ Console.WriteLine("SetIcon({0}, {1}): Called", Window(handle), icon);
+ #endif
+ driver.SetIcon(handle, icon);
+ }
+
+ internal static void SetMenu(IntPtr handle, Menu menu) {
+ #if DriverDebug
+ Console.WriteLine("SetMenu({0}, {1}): Called", Window(handle), menu);
+ #endif
+ driver.SetMenu(handle, menu);
+ }
+
+ internal static void SetModal(IntPtr handle, bool Modal) {
+ #if DriverDebug || DriverDebugState
+ Console.WriteLine("SetModal({0}, {1}): Called", Window(handle), Modal);
+ #endif
+ driver.SetModal(handle, Modal);
+ }
+
+ internal static IntPtr SetParent(IntPtr handle, IntPtr hParent) {
+ #if DriverDebug
+ Console.WriteLine("SetParent({0}, {1:X}): Called", Window(handle), Window(hParent));
+ #endif
+ return driver.SetParent(handle, hParent);
+ }
+
+ internal static void SetTimer (Timer timer)
+ {
+ #if DriverDebug
+ Console.WriteLine("SetTimer({0}): Called", timer);
+ #endif
+ driver.SetTimer (timer);
+ }
+
+ internal static bool SetTopmost(IntPtr handle, IntPtr hWndOwner, bool Enabled) {
+ #if DriverDebug
+ Console.WriteLine("SetTopMost({0}, {1}, {2}): Called", Window(handle), Window(hWndOwner), Enabled);
+ #endif
+ return driver.SetTopmost(handle, hWndOwner, Enabled);
+ }
+
+ internal static bool SetVisible(IntPtr handle, bool visible) {
+ #if DriverDebug || DriverDebugState
+ Console.WriteLine("SetVisible({0}, {1}): Called", Window(handle), visible);
+ #endif
+ return driver.SetVisible(handle, visible);
+ }
+
+ internal static void SetWindowMinMax(IntPtr handle, Rectangle maximized, Size min, Size max) {
+ #if DriverDebug || DriverDebugState
+ Console.WriteLine("SetWindowMinMax({0}, {1}, {2}, {3}): Called", Window(handle), maximized, min, max);
+ #endif
+ driver.SetWindowMinMax(handle, maximized, min, max);
+ }
+
+ internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
+ #if DriverDebug
+ Console.WriteLine("SetWindowPos({0}, {1}, {2}, {3}, {4}): Called", Window(handle), x, y, width, height);
+ #endif
+ driver.SetWindowPos(handle, x, y, width, height);
+ }
+
+ internal static void SetWindowState(IntPtr handle, FormWindowState state) {
+ #if DriverDebug || DriverDebugState
+ Console.WriteLine("SetWindowState({0} {1}): Called", Window(handle), state);
+ #endif
+ driver.SetWindowState(handle, state);
+ }
+
+ internal static void SetWindowStyle(IntPtr handle, CreateParams cp) {
+ #if DriverDebug
+ Console.WriteLine("SetWindowStyle({0}): Called", Window(handle));
+ #endif
+ driver.SetWindowStyle(handle, cp);
+ }
+
+ internal static void SetWindowTransparency(IntPtr handle, double transparency, Color key)
+ {
+ #if DriverDebug
+ Console.WriteLine("SetWindowTransparency({0}): Called", Window(handle));
+ #endif
+ driver.SetWindowTransparency(handle, transparency, key);
+ }
+
+ internal static bool SetZOrder(IntPtr handle, IntPtr AfterhWnd, bool Top, bool Bottom) {
+ #if DriverDebug
+ Console.WriteLine("SetZOrder({0}, {1:X}, {2}, {3}): Called", Window(handle), Window(AfterhWnd), Top, Bottom);
+ #endif
+ return driver.SetZOrder(handle, AfterhWnd, Top, Bottom);
+ }
+
+ internal static void ShowCursor(bool show) {
+ #if DriverDebug
+ Console.WriteLine("ShowCursor({0}): Called", show);
+ #endif
+ driver.ShowCursor(show);
+ }
+
+ internal static DragDropEffects StartDrag(IntPtr handle, object data, DragDropEffects allowedEffects) {
+ #if DriverDebug
+ Console.WriteLine ("StartDrag({0}, {1}, {2}): Called", Window(handle), data, allowedEffects);
+ #endif
+ return driver.StartDrag (handle, data, allowedEffects);
+ }
+
+ internal static void StartLoop(Thread thread) {
+ #if DriverDebug
+ Console.WriteLine("StartLoop({0:X}): Called", thread.GetHashCode());
+ #endif
+ driver.StartLoop(thread);
+ }
+
+ internal static bool SupportsTransparency() {
+ #if DriverDebug
+ Console.WriteLine("SupportsTransparency(): Called, result={1}", driver.SupportsTransparency());
+ #endif
+ return driver.SupportsTransparency();
+ }
+
+ internal static bool SystrayAdd(IntPtr handle, string tip, Icon icon, out ToolTip tt) {
+ #if DriverDebug
+ Console.WriteLine("SystrayAdd({0}, {1}): Called", Window(handle), tip);
+ #endif
+ return driver.SystrayAdd(handle, tip, icon, out tt);
+ }
+
+ internal static void SystrayChange(IntPtr handle, string tip, Icon icon, ref ToolTip tt) {
+ #if DriverDebug
+ Console.WriteLine("SystrayChange({0}, {1}): Called", Window(handle), tip);
+ #endif
+ driver.SystrayChange(handle, tip, icon, ref tt);
+ }
+
+ internal static void SystrayRemove(IntPtr handle, ref ToolTip tt) {
+ #if DriverDebug
+ Console.WriteLine("SystrayRemove({0}): Called", Window(handle));
+ #endif
+ driver.SystrayRemove(handle, ref tt);
+ }
+
+ internal static bool Text(IntPtr handle, string text) {
+ #if DriverDebug
+ Console.WriteLine("Text({0}, {1}): Called", Window(handle), text);
+ #endif
+ return driver.Text(handle, text);
+ }
+
+ internal static bool TranslateMessage(ref MSG msg) {
+ return driver.TranslateMessage(ref msg);
+ }
+
+ internal static void UngrabWindow(IntPtr handle) {
+ #if DriverDebug
+ Console.WriteLine("UngrabWindow({0}): Called", Window(handle));
+ #endif
+ driver.UngrabWindow(handle);
+ }
+
+ internal static void UpdateWindow(IntPtr handle) {
+ #if DriverDebug
+ Console.WriteLine("UpdateWindow({0}): Called", Window(handle));
+ #endif
+ driver.UpdateWindow(handle);
+ }
+
+ // Santa's little helper
+ internal static void Version() {
+ Console.WriteLine("Xplat version $Revision: $");
+ }
+
+ internal static void Where() {
+ XplatUIX11.Where();
+ }
+ #endregion // Public Static Methods
+
+ #region Delegates
+ public delegate bool ClipboardToObject(int type, IntPtr data, out object obj);
+ public delegate bool ObjectToClipboard(ref int type, object obj, out byte[] data);
+ #endregion // Delegates
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs
new file mode 100644
index 00000000000..4ae04fab6f9
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs
@@ -0,0 +1,320 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+// Sebastien Pouliot sebastien@ximian.com
+//
+
+// COMPLETE
+
+using System.Drawing;
+using System.Threading;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ internal abstract class XplatUIDriver {
+ internal abstract IntPtr InitializeDriver();
+ internal abstract void ShutdownDriver(IntPtr token);
+ internal delegate IntPtr WndProc(IntPtr hwnd, Msg msg, IntPtr wParam, IntPtr lParam);
+
+
+ #region XplatUI Driver Properties
+ internal virtual Color ForeColor {
+ get {
+ return ThemeEngine.Current.DefaultWindowForeColor;
+ }
+ }
+
+ internal virtual Color BackColor {
+ get {
+ return ThemeEngine.Current.DefaultWindowBackColor;
+ }
+ }
+
+ internal virtual Font Font {
+ get {
+ return ThemeEngine.Current.DefaultFont;
+ }
+ }
+
+ internal virtual Keys ModifierKeys {
+ get {
+ return Keys.None;
+ }
+ }
+
+ internal virtual MouseButtons MouseButtons {
+ get {
+ return MouseButtons.None;
+ }
+ }
+
+ internal virtual Size MouseHoverSize {
+ get {
+ return new Size (1, 1);
+ }
+ }
+
+ internal virtual int MouseHoverTime {
+ get {
+ return 500;
+ }
+ }
+
+ internal virtual Point MousePosition {
+ get {
+ return Point.Empty;
+ }
+ }
+
+ internal virtual bool DropTarget {
+ get {
+ return false;
+ }
+
+ set {
+ }
+ }
+
+ internal abstract int Caption { get; }
+ internal abstract Size CursorSize { get; }
+ internal abstract bool DragFullWindows { get; }
+ internal abstract Size DragSize { get; }
+ internal abstract Size FrameBorderSize { get; }
+ internal abstract Size IconSize { get; }
+ internal abstract Size MaxWindowTrackSize { get; }
+ internal abstract Size MinimizedWindowSize { get; }
+ internal abstract Size MinimizedWindowSpacingSize { get; }
+ internal abstract Size MinimumWindowSize { get; }
+ internal abstract Size MinWindowTrackSize { get; }
+ internal abstract Size SmallIconSize { get; }
+ internal abstract int MouseButtonCount { get; }
+ internal abstract bool MouseButtonsSwapped { get; }
+ internal abstract bool MouseWheelPresent { get; }
+ internal abstract Rectangle VirtualScreen { get; }
+ internal abstract Rectangle WorkingArea { get; }
+ #endregion // XplatUI Driver Properties
+
+ internal abstract event EventHandler Idle;
+
+ #region XplatUI Driver Methods
+ internal abstract void AudibleAlert();
+
+ internal abstract void EnableThemes();
+
+ internal abstract void GetDisplaySize(out Size size);
+
+ internal abstract IntPtr CreateWindow(CreateParams cp);
+ internal abstract IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height);
+ internal abstract void DestroyWindow(IntPtr handle);
+
+ internal abstract FormWindowState GetWindowState(IntPtr handle);
+ internal abstract void SetWindowState(IntPtr handle, FormWindowState state);
+ internal abstract void SetWindowMinMax(IntPtr handle, Rectangle maximized, Size min, Size max);
+
+ internal abstract void SetWindowStyle(IntPtr handle, CreateParams cp);
+
+ internal abstract void SetWindowTransparency(IntPtr handle, double transparency, Color key);
+ internal abstract bool SupportsTransparency();
+
+ internal virtual void SetAllowDrop (IntPtr handle, bool value)
+ {
+ Console.Error.WriteLine ("Drag and Drop is currently " +
+ "not supported on this platform");
+ }
+
+ internal virtual DragDropEffects StartDrag(IntPtr handle, object data, DragDropEffects allowedEffects) {
+ Console.Error.WriteLine ("Drag and Drop is currently " +
+ "not supported on this platform");
+ return DragDropEffects.None;
+ }
+
+ internal abstract void SetBorderStyle(IntPtr handle, FormBorderStyle border_style);
+ internal abstract void SetMenu(IntPtr handle, Menu menu);
+
+ internal abstract bool GetText(IntPtr handle, out string text);
+ internal abstract bool Text(IntPtr handle, string text);
+ internal abstract bool SetVisible(IntPtr handle, bool visible);
+ internal abstract bool IsVisible(IntPtr handle);
+ internal abstract bool IsEnabled(IntPtr handle);
+ internal abstract IntPtr SetParent(IntPtr handle, IntPtr parent);
+ internal abstract IntPtr GetParent(IntPtr handle);
+
+ internal abstract void UpdateWindow(IntPtr handle);
+ internal abstract PaintEventArgs PaintEventStart(IntPtr handle, bool client);
+ internal abstract void PaintEventEnd(IntPtr handle, bool client);
+
+ internal abstract void SetWindowPos(IntPtr handle, int x, int y, int width, int height);
+ internal abstract void GetWindowPos(IntPtr handle, bool is_toplevel, out int x, out int y, out int width, out int height, out int client_width, out int client_height);
+ internal abstract void Activate(IntPtr handle);
+ internal abstract void EnableWindow(IntPtr handle, bool Enable);
+ internal abstract void SetModal(IntPtr handle, bool Modal);
+ internal abstract void Invalidate(IntPtr handle, Rectangle rc, bool clear);
+ internal abstract IntPtr DefWndProc(ref Message msg);
+ internal abstract void HandleException(Exception e);
+ internal abstract void DoEvents();
+ internal abstract bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags);
+ internal abstract void PostQuitMessage(int exitCode);
+ internal abstract bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax);
+ internal abstract bool TranslateMessage(ref MSG msg);
+ internal abstract IntPtr DispatchMessage(ref MSG msg);
+
+ internal abstract bool SetZOrder(IntPtr hWnd, IntPtr AfterhWnd, bool Top, bool Bottom);
+ internal abstract bool SetTopmost(IntPtr hWnd, IntPtr hWndOwner, bool Enabled);
+
+ internal abstract bool CalculateWindowRect(ref Rectangle ClientRect, int Style, int ExStyle, Menu menu, out Rectangle WindowRect);
+
+ internal abstract void SetCursor(IntPtr hwnd, IntPtr cursor);
+ internal abstract void ShowCursor(bool show);
+ internal abstract void OverrideCursor(IntPtr cursor);
+ internal abstract IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot);
+ internal abstract IntPtr DefineStdCursor(StdCursor id);
+ internal abstract void DestroyCursor(IntPtr cursor);
+ internal abstract void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y);
+
+ internal abstract void GetCursorPos(IntPtr hwnd, out int x, out int y);
+ internal abstract void SetCursorPos(IntPtr hwnd, int x, int y);
+
+ internal abstract void ScreenToClient(IntPtr hwnd, ref int x, ref int y);
+ internal abstract void ClientToScreen(IntPtr hwnd, ref int x, ref int y);
+
+ internal abstract void GrabWindow(IntPtr hwnd, IntPtr ConfineToHwnd);
+ internal abstract void GrabInfo(out IntPtr hwnd, out bool GrabConfined, out Rectangle GrabArea);
+ internal abstract void UngrabWindow(IntPtr hwnd);
+
+ internal abstract void SendAsyncMethod (AsyncMethodData method);
+ internal abstract void SetTimer (Timer timer);
+ internal abstract void KillTimer (Timer timer);
+
+ internal abstract void CreateCaret(IntPtr hwnd, int width, int height);
+ internal abstract void DestroyCaret(IntPtr hwnd);
+ internal abstract void SetCaretPos(IntPtr hwnd, int x, int y);
+ internal abstract void CaretVisible(IntPtr hwnd, bool visible);
+
+ internal abstract void SetFocus(IntPtr hwnd);
+ internal abstract IntPtr GetActive();
+
+ internal abstract void ScrollWindow(IntPtr hwnd, Rectangle rectangle, int XAmount, int YAmount, bool with_children);
+ internal abstract void ScrollWindow(IntPtr hwnd, int XAmount, int YAmount, bool with_children);
+
+ internal abstract bool GetFontMetrics(Graphics g, Font font, out int ascent, out int descent);
+
+ internal abstract bool SystrayAdd(IntPtr hwnd, string tip, Icon icon, out ToolTip tt);
+ internal abstract bool SystrayChange(IntPtr hwnd, string tip, Icon icon, ref ToolTip tt);
+ internal abstract void SystrayRemove(IntPtr hwnd, ref ToolTip tt);
+
+ internal abstract Point GetMenuOrigin(IntPtr hwnd);
+ internal abstract void MenuToScreen(IntPtr hwnd, ref int x, ref int y);
+ internal abstract void ScreenToMenu(IntPtr hwnd, ref int x, ref int y);
+
+ internal abstract void SetIcon(IntPtr handle, Icon icon);
+
+ internal abstract void ClipboardClose(IntPtr handle);
+ internal abstract IntPtr ClipboardOpen();
+ internal abstract int ClipboardGetID(IntPtr handle, string format);
+ internal abstract void ClipboardStore(IntPtr handle, object obj, int id, XplatUI.ObjectToClipboard converter);
+ internal abstract int[] ClipboardAvailableFormats(IntPtr handle);
+ internal abstract object ClipboardRetrieve(IntPtr handle, int id, XplatUI.ClipboardToObject converter);
+
+ internal abstract void DrawReversibleRectangle(IntPtr handle, Rectangle rect, int line_width);
+
+ internal abstract SizeF GetAutoScaleSize(Font font);
+
+ internal abstract IntPtr SendMessage(IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam);
+ internal abstract bool PostMessage(IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam);
+
+ internal abstract void StartLoop(Thread thread);
+ internal abstract void EndLoop(Thread thread);
+
+ internal abstract void RequestNCRecalc(IntPtr hwnd);
+ internal abstract void ResetMouseHover(IntPtr hwnd);
+
+ // System information
+ internal abstract int KeyboardSpeed { get; }
+ internal abstract int KeyboardDelay { get; }
+
+#endregion // XplatUI Driver Methods
+ }
+
+ internal class XplatUIDriverSupport {
+ #region XplatUI Driver Support Methods
+#if NET_2_0
+ internal static void ExecutionCallback (object state)
+ {
+ AsyncMethodData data = (AsyncMethodData) state;
+ AsyncMethodResult result = data.Result;
+ object ret = data.Method.DynamicInvoke (data.Args);
+ if (result != null) {
+ result.Complete (ret);
+ }
+ }
+
+ internal static void ExecuteClientMessage (GCHandle gchandle)
+ {
+ AsyncMethodData data = (AsyncMethodData) gchandle.Target;
+ try {
+ if (data.Context == null) {
+ ExecutionCallback (data);
+ } else {
+ ExecutionContext.Run (data.Context, new ContextCallback (ExecutionCallback), data);
+ }
+ }
+ finally {
+ gchandle.Free ();
+ }
+ }
+#else
+ // for NET_1_0 and NET_1_1 no (public) ExecutionContext exists
+ // so we must use the System.Threading.CompressedStack class
+ internal static void ExecuteClientMessage (GCHandle gchandle) {
+ AsyncMethodData data = (AsyncMethodData) gchandle.Target;
+ CompressedStack original = null;
+
+#if !MWF_ON_MSRUNTIME
+ // Stack is non-null only if the security manager is active
+ if (data.Stack != null) {
+ original = Thread.CurrentThread.GetCompressedStack ();
+ Thread.CurrentThread.SetCompressedStack (data.Stack);
+ }
+#endif
+
+ try {
+ AsyncMethodResult result = data.Result;
+ object ret = data.Method.DynamicInvoke (data.Args);
+ result.Complete (ret);
+ }
+ finally {
+#if !MWF_ON_MSRUNTIME
+ if (data.Stack != null) {
+ // whatever occurs we must revert to the original compressed
+ // stack (null being a valid, empty, value in this case).
+ Thread.CurrentThread.SetCompressedStack (original);
+ }
+#endif
+ gchandle.Free ();
+ }
+ }
+#endif
+
+ #endregion // XplatUI Driver Support Methods
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs
new file mode 100644
index 00000000000..e638493cebc
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs
@@ -0,0 +1,2071 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc.
+//
+// Authors:
+// Geoff Norton <gnorton@customerdna.com>
+//
+//
+
+// This really doesn't work at all; please dont file bugs on it yet.
+
+// MAJOR TODO:
+// Fix clipping of children
+// Wire up keyboard
+
+using System;
+using System.Threading;
+using System.Drawing;
+using System.ComponentModel;
+using System.Collections;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+
+/// OSX Version
+namespace System.Windows.Forms {
+
+ // The Carbon Event callback delegate
+ delegate int CarbonEventDelegate (IntPtr inCallRef, IntPtr inEvent, IntPtr userData);
+
+ internal class XplatUIOSX : XplatUIDriver {
+
+ #region Local Variables
+
+ // General driver variables
+ private static XplatUIOSX Instance;
+ private static int RefCount;
+ private static bool ThemesEnabled;
+ private static IntPtr FocusWindow;
+
+ // Mouse
+ private static MouseButtons MouseState;
+ private static Point MousePosition;
+ private static Hwnd MouseWindow;
+
+ // OSX Specific
+ private static GrabStruct Grab;
+ private static OSXCaret Caret;
+ private static OSXHover Hover;
+ private CarbonEventDelegate CarbonEventHandler;
+ private static Hashtable WindowMapping;
+ private static Hashtable WindowBackgrounds;
+ private static Hwnd GrabWindowHwnd;
+ private static IntPtr FosterParent;
+ private static int TitleBarHeight;
+ private static int MenuBarHeight;
+ private static EventTypeSpec [] viewEvents = new EventTypeSpec [] {
+ new EventTypeSpec (OSXConstants.kEventClassControl, OSXConstants.kEventControlSetFocusPart),
+ new EventTypeSpec (OSXConstants.kEventClassControl, OSXConstants.kEventControlClick),
+ new EventTypeSpec (OSXConstants.kEventClassControl, OSXConstants.kEventControlContextualMenuClick),
+ new EventTypeSpec (OSXConstants.kEventClassControl, OSXConstants.kEventControlTrack),
+ new EventTypeSpec (OSXConstants.kEventClassControl, OSXConstants.kEventControlSimulateHit),
+ new EventTypeSpec (OSXConstants.kEventClassControl, OSXConstants.kEventControlBoundsChanged),
+ new EventTypeSpec (OSXConstants.kEventClassControl, OSXConstants.kEventControlDraw)
+ };
+ private static EventTypeSpec [] windowEvents = new EventTypeSpec[] {
+ //new EventTypeSpec (OSXConstants.kEventClassMouse, OSXConstants.kEventMouseEntered),
+ //new EventTypeSpec (OSXConstants.kEventClassMouse, OSXConstants.kEventMouseExited),
+ new EventTypeSpec (OSXConstants.kEventClassMouse, OSXConstants.kEventMouseMoved),
+ //new EventTypeSpec (OSXConstants.kEventClassMouse, OSXConstants.kEventMouseDragged),
+ //new EventTypeSpec (OSXConstants.kEventClassMouse, OSXConstants.kEventMouseWheelMoved),
+ new EventTypeSpec (OSXConstants.kEventClassWindow, OSXConstants.kEventWindowBoundsChanged),
+ new EventTypeSpec (OSXConstants.kEventClassWindow, OSXConstants.kEventWindowClose),
+ new EventTypeSpec (OSXConstants.kEventClassKeyboard, OSXConstants.kEventRawKeyDown),
+ new EventTypeSpec (OSXConstants.kEventClassKeyboard, OSXConstants.kEventRawKeyRepeat),
+ new EventTypeSpec (OSXConstants.kEventClassKeyboard, OSXConstants.kEventRawKeyUp)
+ };
+
+
+ // Message loop
+ private static Queue MessageQueue;
+ private static bool GetMessageResult;
+
+ // Timers
+ private ArrayList TimerList;
+
+ static readonly object lockobj = new object ();
+
+ // Event Handlers
+ internal override event EventHandler Idle;
+
+ #endregion
+
+ #region Constructors
+ private XplatUIOSX() {
+
+ RefCount = 0;
+ TimerList = new ArrayList ();
+ MessageQueue = new Queue ();
+
+ Initialize ();
+ }
+
+ ~XplatUIOSX() {
+ // FIXME: Clean up the FosterParent here.
+ }
+
+ #endregion
+
+ #region Singleton specific code
+
+ public static XplatUIOSX GetInstance() {
+ lock (lockobj) {
+ if (Instance == null) {
+ Instance = new XplatUIOSX ();
+ }
+ RefCount++;
+ }
+ return Instance;
+ }
+
+ public int Reference {
+ get {
+ return RefCount;
+ }
+ }
+
+ #endregion
+
+ #region Internal methods
+
+ internal void Initialize () {
+
+ // Initialize the Event Handler delegate
+ CarbonEventHandler = new CarbonEventDelegate (EventCallback);
+
+ // Initilize the mouse controls
+ Hover.Interval = 500;
+ Hover.Timer = new Timer ();
+ Hover.Timer.Enabled = false;
+ Hover.Timer.Interval = Hover.Interval;
+ Hover.Timer.Tick += new EventHandler (HoverCallback);
+ Hover.X = -1;
+ Hover.Y = -1;
+ MouseState = MouseButtons.None;
+ MousePosition = Point.Empty;
+
+ // Initialize the Caret
+ Caret.Timer = new Timer ();
+ Caret.Timer.Interval = 500;
+ Caret.Timer.Tick += new EventHandler (CaretCallback);
+
+ // Initialize the OSX Specific stuff
+ WindowMapping = new Hashtable ();
+ WindowBackgrounds = new Hashtable ();
+
+ // Initialize the FosterParent
+ IntPtr rect = IntPtr.Zero;
+ SetRect (ref rect, (short)0, (short)0, (short)0, (short)0);
+ CheckError (CreateNewWindow (WindowClass.kDocumentWindowClass, WindowAttributes.kWindowStandardHandlerAttribute | WindowAttributes.kWindowCloseBoxAttribute | WindowAttributes.kWindowFullZoomAttribute | WindowAttributes.kWindowCollapseBoxAttribute | WindowAttributes.kWindowResizableAttribute | WindowAttributes.kWindowCompositingAttribute, ref rect, ref FosterParent), "CreateFosterParent ()");
+
+ // Get some values about bar heights
+ Rect structRect = new Rect ();
+ Rect contentRect = new Rect ();
+ CheckError (GetWindowBounds (FosterParent, 32, ref structRect), "GetWindowBounds ()");
+ CheckError (GetWindowBounds (FosterParent, 33, ref contentRect), "GetWindowBounds ()");
+
+ TitleBarHeight = Math.Abs(structRect.top - contentRect.top);
+ MenuBarHeight = GetMBarHeight ();
+
+ // Focus
+ FocusWindow = IntPtr.Zero;
+
+ // Message loop
+ GetMessageResult = true;
+ }
+
+ #endregion
+
+ #region Private methods
+ #endregion
+
+ #region Callbacks
+
+ private void CaretCallback (object sender, EventArgs e) {
+ if (Caret.Paused) {
+ return;
+ }
+
+ if (!Caret.On) {
+ ShowCaret ();
+ } else {
+ HideCaret ();
+ }
+ }
+
+ private void HoverCallback (object sender, EventArgs e) {
+ if ((Hover.X == MousePosition.X) && (Hover.Y == MousePosition.Y)) {
+ MSG msg = new MSG ();
+ msg.hwnd = Hover.Hwnd;
+ msg.message = Msg.WM_MOUSEHOVER;
+ msg.wParam = GetMousewParam (0);
+ msg.lParam = (IntPtr)((ushort)Hover.X << 16 | (ushort)Hover.X);
+ MessageQueue.Enqueue (msg);
+ }
+ }
+
+ internal int EventCallback (IntPtr inCallRef, IntPtr inEvent, IntPtr handle) {
+ uint eventClass = GetEventClass (inEvent);
+ uint eventKind = GetEventKind (inEvent);
+ int retVal = 0;
+ lock (MessageQueue) {
+ switch (eventClass) {
+ // keyboard
+ case OSXConstants.kEventClassKeyboard: {
+ retVal = ProcessKeyboardEvent (inEvent, eventKind, handle);
+ break;
+ }
+ //window
+ case OSXConstants.kEventClassWindow: {
+ retVal = ProcessWindowEvent (inEvent, eventKind, handle);
+ break;
+ }
+ // mouse
+ case OSXConstants.kEventClassMouse: {
+ retVal = ProcessMouseEvent (inEvent, eventKind, handle);
+ break;
+ }
+ // control
+ case OSXConstants.kEventClassControl: {
+ retVal = ProcessControlEvent (inEvent, eventKind, handle);
+ break;
+ }
+ default: {
+ Console.WriteLine ("WARNING: Unhandled eventClass {0}", eventClass);
+ break;
+ }
+ }
+ }
+
+ return retVal;
+ }
+
+ #endregion
+
+ #region Private Methods
+
+ // This sucks write a real driver
+ private int ProcessKeyboardEvent (IntPtr inEvent, uint eventKind, IntPtr handle) {
+ MSG msg = new MSG ();
+ byte charCode = 0x00;
+ GetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamKeyMacCharCodes, OSXConstants.EventParamType.typeChar, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (byte)), IntPtr.Zero, ref charCode);
+ IntPtr cntrl = IntPtr.Zero;
+ CheckError (GetKeyboardFocus (handle, ref cntrl), "GetKeyboardFocus()");
+ msg.hwnd = cntrl;
+ msg.lParam = IntPtr.Zero;
+ switch (charCode) {
+ case 28:
+ charCode = 0x25;
+ break;
+ case 29:
+ charCode = 0x27;
+ break;
+ case 30:
+ charCode = 0x26;
+ break;
+ case 31:
+ charCode = 0x28;
+ break;
+ }
+ msg.wParam = (IntPtr)charCode;
+ switch (eventKind) {
+ // keydown
+ case OSXConstants.kEventRawKeyDown: {
+ msg.message = Msg.WM_KEYDOWN;
+ break;
+ }
+ // repeat
+ case OSXConstants.kEventRawKeyRepeat: {
+ msg.message = Msg.WM_KEYDOWN;
+ break;
+ }
+ // keyup
+ case OSXConstants.kEventRawKeyUp: {
+ msg.message = Msg.WM_KEYUP;
+ break;
+ }
+ }
+ MessageQueue.Enqueue (msg);
+ return -9874;
+ }
+
+ private int ProcessWindowEvent (IntPtr inEvent, uint eventKind, IntPtr handle) {
+ MSG msg = new MSG ();
+ switch (eventKind) {
+ // Someone closed a window
+ case OSXConstants.kEventWindowClose: {
+ // This is our real window; so we have to post to the corresponding view
+ // FIXME: Should we doublehash the table to get the real window handle without this loop?
+ IDictionaryEnumerator e = WindowMapping.GetEnumerator ();
+ while (e.MoveNext ()) {
+ if ((IntPtr)e.Value == handle) {
+ NativeWindow.WndProc((IntPtr)e.Key, Msg.WM_DESTROY, IntPtr.Zero, IntPtr.Zero);
+ }
+ }
+ return 0;
+ }
+ case OSXConstants.kEventWindowBoundsChanged: {
+ // This is our real window; so we have to resize the corresponding view as well
+ // FIXME: Should we doublehash the table to get the real window handle without this loop?
+
+ IDictionaryEnumerator e = WindowMapping.GetEnumerator ();
+ while (e.MoveNext ()) {
+ if ((IntPtr)e.Value == handle) {
+ Hwnd hwnd = Hwnd.ObjectFromHandle ((IntPtr) e.Key);
+ // Get the bounds of the window
+ Rect bounds = new Rect ();
+ CheckError (GetWindowBounds (handle, 33, ref bounds), "GetWindowBounds ()");
+ HIRect r = new HIRect ();
+
+ // Get our frame for the Handle
+ CheckError (HIViewGetFrame (hwnd.Handle, ref r), "HIViewGetFrame ()");
+ r.size.width = bounds.right-bounds.left;
+ r.size.height = bounds.bottom-bounds.top;
+ // Set the view to the new size
+ CheckError (HIViewSetFrame (hwnd.WholeWindow, ref r), "HIViewSetFrame ()");
+
+ // Update the hwnd internal size representation
+ hwnd.x = (int)r.origin.x;
+ hwnd.y = (int)r.origin.y;
+ hwnd.width = (int)r.size.width;
+ hwnd.height = (int)r.size.height;
+ Rectangle client_rect = hwnd.ClientRect;
+
+ r.size.width = client_rect.Width;
+ r.size.height = client_rect.Height;
+ r.origin.x = client_rect.X;
+ r.origin.y = client_rect.Y;
+
+ // Update the client area too
+ CheckError (HIViewSetFrame (hwnd.ClientWindow, ref r));
+
+ // Add the message to the queue
+ msg.message = Msg.WM_WINDOWPOSCHANGED;
+ msg.hwnd = hwnd.Handle;
+ msg.wParam = IntPtr.Zero;
+ msg.lParam = IntPtr.Zero;
+ MessageQueue.Enqueue (msg);
+
+ return 0;
+ }
+ }
+ break;
+ }
+ }
+ return -9874;
+ }
+
+ private int ProcessMouseEvent (IntPtr inEvent, uint eventKind, IntPtr handle) {
+ MSG msg = new MSG ();
+
+ switch (eventKind) {
+ case OSXConstants.kEventMouseMoved: {
+ // Where is the mouse in global coordinates
+ QDPoint pt = new QDPoint ();
+ GetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamMouseLocation, OSXConstants.EventParamType.typeQDPoint, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (QDPoint)), IntPtr.Zero, ref pt);
+
+ // Where is the mouse in the window
+ Rect window_bounds = new Rect ();
+ GetWindowBounds (handle, 33, ref window_bounds);
+ CGPoint window_pt = new CGPoint ((short) (pt.x - window_bounds.left), (short) (pt.y - window_bounds.top));
+
+ IntPtr window_handle = IntPtr.Zero;
+ HIViewFindByID (HIViewGetRoot (handle), new HIViewID (OSXConstants.kEventClassWindow, 1), ref window_handle);
+
+ // Determine which control was hit
+ IntPtr view_handle = IntPtr.Zero;
+ HIViewGetSubviewHit (window_handle, ref window_pt, true, ref view_handle);
+
+ // Convert the point to view local coordinates
+ HIViewConvertPoint (ref window_pt, window_handle, view_handle);
+
+ Hwnd hwnd = Hwnd.ObjectFromHandle (view_handle);
+
+ if (hwnd == null)
+ return -9874;
+
+ // Generate the message
+ msg.hwnd = hwnd.Handle;
+ msg.message = Msg.WM_MOUSEMOVE;
+ msg.lParam = (IntPtr) ((ushort)window_pt.y << 16 | (ushort)window_pt.x);
+ msg.wParam = GetMousewParam (0);
+ MousePosition.X = (int)window_pt.x;
+ MousePosition.Y = (int)window_pt.y;
+
+ Hover.Hwnd = msg.hwnd;
+ Hover.Timer.Enabled = true;
+ MessageQueue.Enqueue (msg);
+ return -9874;
+ }
+ }
+ return -9874;
+ }
+
+ private int ProcessControlEvent (IntPtr inEvent, uint eventKind, IntPtr handle) {
+ GetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamDirectObject, OSXConstants.EventParamType.typeControlRef, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (IntPtr)), IntPtr.Zero, ref handle);
+ Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
+ MSG msg = new MSG ();
+
+ switch (eventKind) {
+ case OSXConstants.kEventControlDraw: {
+
+ if(!hwnd.visible || !HIViewIsVisible (handle))
+ return 0;
+
+ /*
+ IntPtr rgnhandle = IntPtr.Zero;
+ GetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamRgnHandle, OSXConstants.EventParamType.typeQDRgnHandle, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (IntPtr)), IntPtr.Zero, ref rgnhandle);
+ IntPtr duprgn = NewRgn ();
+ CopyRgn (rgnhandle, duprgn);
+ ClipRegions [hwnd.Handle] = duprgn;
+ */
+
+ // Get the dirty area
+ HIRect bounds = new HIRect ();
+ HIViewGetBounds (handle, ref bounds);
+
+ bool client = (hwnd.ClientWindow == handle ? true : false);
+
+ if (!client && bounds.origin.x >= hwnd.ClientRect.X && bounds.origin.y >= hwnd.ClientRect.Y) {
+ // This is a paint on WholeWindow inside the clientRect; we can safely discard this
+ return 0;
+ }
+
+ hwnd.AddInvalidArea ((int)bounds.origin.x, (int)bounds.origin.y, (int)bounds.size.width, (int)bounds.size.height);
+ if (WindowBackgrounds [hwnd] != null) {
+ Color c = (Color)WindowBackgrounds [hwnd];
+ IntPtr contextref = IntPtr.Zero;
+ GetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamCGContextRef, OSXConstants.EventParamType.typeCGContextRef, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (IntPtr)), IntPtr.Zero, ref contextref);
+ CGContextSetRGBFillColor (contextref, (float)c.R/255, (float)c.G/255, (float)c.B/255, (float)c.A/255);
+ CGContextFillRect (contextref, bounds);
+ }
+
+ // Add a paint to the queue
+ msg.hwnd = hwnd.Handle;
+ msg.message = Msg.WM_PAINT;
+ msg.wParam = IntPtr.Zero;
+ msg.lParam = IntPtr.Zero;
+ MessageQueue.Enqueue (msg);
+
+ return 0;
+ }
+ case OSXConstants.kEventControlBoundsChanged: {
+ // This can happen before our HWND is created so we need to check to make sure its not null
+ if (hwnd != null) {
+ // Get the bounds
+ HIRect bounds = new HIRect ();
+ HIViewGetFrame (handle, ref bounds);
+ // Update the hwnd size
+ hwnd.x = (int)bounds.origin.x;
+ hwnd.y = (int)bounds.origin.y;
+ hwnd.width = (int)bounds.size.width;
+ hwnd.height = (int)bounds.size.height;
+
+ // TODO: Do we need to send a paint here or does BoundsChanged make a ControlDraw for the exposed area?
+ }
+ return 0;
+ }
+ case OSXConstants.kEventControlTrack: {
+ // get the point that was hit
+ QDPoint point = new QDPoint ();
+ CheckError (GetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamMouseLocation, OSXConstants.EventParamType.typeQDPoint, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (QDPoint)), IntPtr.Zero, ref point), "GetEventParameter() MouseLocation");
+ MouseTrackingResult mousestatus = MouseTrackingResult.kMouseTrackingMouseDown;
+ IntPtr modifiers = IntPtr.Zero;
+
+ while (mousestatus != MouseTrackingResult.kMouseTrackingMouseUp) {
+ CheckTimers (DateTime.Now);
+ if (mousestatus == MouseTrackingResult.kMouseTrackingMouseDragged) {
+ QDPoint realpoint = point;
+ int x = point.x;
+ int y = point.y;
+ ScreenToClient (hwnd.Handle, ref x, ref y);
+ realpoint.x = (short)x;
+ realpoint.y = (short)y;
+ NativeWindow.WndProc (hwnd.Handle, Msg.WM_MOUSEMOVE, GetMousewParam (0), (IntPtr) ((ushort)realpoint.y << 16 | (ushort)realpoint.x));
+ }
+ // Process the rest of the event queue
+ while (MessageQueue.Count > 0) {
+ msg = (MSG)MessageQueue.Dequeue ();
+ NativeWindow.WndProc (msg.hwnd, msg.message, msg.wParam, msg.lParam);
+ }
+ TrackMouseLocationWithOptions ((IntPtr)(-1), 0, 0.01, ref point, ref modifiers, ref mousestatus);
+ }
+
+ msg.hwnd = hwnd.Handle;
+
+ bool client = (hwnd.ClientWindow == handle ? true : false);
+
+ int wparam = (int)GetMousewParam (0);
+ switch (MouseState) {
+ case MouseButtons.Left:
+ MouseState &= ~MouseButtons.Left;
+ msg.message = (client ? Msg.WM_LBUTTONUP : Msg.WM_NCLBUTTONUP);
+ wparam &= (int)MsgButtons.MK_LBUTTON;
+ break;
+ case MouseButtons.Middle:
+ MouseState &= ~MouseButtons.Middle;
+ msg.message = (client ? Msg.WM_MBUTTONUP : Msg.WM_NCMBUTTONUP);
+ wparam &= (int)MsgButtons.MK_MBUTTON;
+ break;
+ case MouseButtons.Right:
+ MouseState &= ~MouseButtons.Right;
+ msg.message = (client ? Msg.WM_RBUTTONUP : Msg.WM_NCRBUTTONUP);
+ wparam &= (int)MsgButtons.MK_RBUTTON;
+ break;
+ }
+ int x2 = point.x;
+ int y2 = point.y;
+ ScreenToClient (hwnd.Handle, ref x2, ref y2);
+ point.x = (short)x2;
+ point.y = (short)y2;
+
+ msg.wParam = (IntPtr)wparam;
+
+ msg.lParam = (IntPtr) ((ushort)point.y << 16 | (ushort)point.x);
+ MousePosition.X = (int)point.x;
+ MousePosition.Y = (int)point.y;
+ //NativeWindow.WndProc (msg.hwnd, msg.message, msg.lParam, msg.wParam);
+ MessageQueue.Enqueue (msg);
+
+ IntPtr window = GetControlOwner (hwnd.Handle);
+ SetKeyboardFocus (window, hwnd.Handle, 1);
+
+ return 0;
+ }
+ case OSXConstants.kEventControlContextualMenuClick:
+ case OSXConstants.kEventControlClick: {
+ // get the point that was hit
+ QDPoint point = new QDPoint ();
+ CheckError (GetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamMouseLocation, OSXConstants.EventParamType.typeQDPoint, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (QDPoint)), IntPtr.Zero, ref point), "GetEventParameter() MouseLocation");
+ QDPoint trackpoint = point;
+ int x = point.x;
+ int y = point.y;
+ ScreenToClient (hwnd.Handle, ref x, ref y);
+ point.x = (short)x;
+ point.y = (short)y;
+
+ // which button was pressed?
+ ushort button = 0;
+ GetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamMouseButton, OSXConstants.EventParamType.typeMouseButton, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (ushort)), IntPtr.Zero, ref button);
+ if (button == 2) {
+ point.x = (short)MousePosition.X;
+ point.y = (short)MousePosition.Y;
+ }
+
+ msg.hwnd = hwnd.Handle;
+
+ bool client = (hwnd.ClientWindow == handle ? true : false);
+
+ int wparam = (int)GetMousewParam (0);
+ switch (button) {
+ case 1:
+ MouseState |= MouseButtons.Left;
+ msg.message = (client ? Msg.WM_LBUTTONDOWN : Msg.WM_NCLBUTTONDOWN);
+ wparam |= (int)MsgButtons.MK_LBUTTON;
+ break;
+ case 2:
+ MouseState |= MouseButtons.Right;
+ msg.message = (client ? Msg.WM_RBUTTONDOWN : Msg.WM_NCRBUTTONDOWN);
+ wparam |= (int)MsgButtons.MK_RBUTTON;
+ break;
+ case 3:
+ MouseState |= MouseButtons.Middle;
+ msg.message = (client ? Msg.WM_MBUTTONDOWN : Msg.WM_NCMBUTTONDOWN);
+ wparam |= (int)MsgButtons.MK_MBUTTON;
+ break;
+ }
+ msg.wParam = (IntPtr)wparam;
+
+ msg.lParam = (IntPtr) ((ushort)point.y << 16 | (ushort)point.x);
+ MousePosition.X = (int)point.x;
+ MousePosition.Y = (int)point.y;
+ NativeWindow.WndProc (msg.hwnd, msg.message, msg.wParam, msg.lParam);
+
+ TrackControl (handle, trackpoint, IntPtr.Zero);
+ return 0;
+ }
+ case OSXConstants.kEventControlSetFocusPart: {
+ // This handles setting focus
+ short pcode = 1;
+ GetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamControlPart, OSXConstants.EventParamType.typeControlPartCode, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (short)), IntPtr.Zero, ref pcode);
+ switch (pcode) {
+ case 0:
+ case -1:
+ case -2:
+ pcode = 0;
+ break;
+ }
+ SetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamControlPart, OSXConstants.EventParamType.typeControlPartCode, (uint)Marshal.SizeOf (typeof (short)), ref pcode);
+ return 0;
+ }
+ }
+ return -9874;
+ }
+ private IntPtr GetMousewParam(int Delta) {
+ int result = 0;
+
+ if ((MouseState & MouseButtons.Left) != 0) {
+ result |= (int)MsgButtons.MK_LBUTTON;
+ }
+
+ if ((MouseState & MouseButtons.Middle) != 0) {
+ result |= (int)MsgButtons.MK_MBUTTON;
+ }
+
+ if ((MouseState & MouseButtons.Right) != 0) {
+ result |= (int)MsgButtons.MK_RBUTTON;
+ }
+
+ return (IntPtr)result;
+ }
+
+ private double NextTimeout ()
+ {
+ DateTime now = DateTime.Now;
+ int timeout = 0x7FFFFFF;
+ lock (TimerList) {
+ foreach (Timer timer in TimerList) {
+ int next = (int) (timer.Expires - now).TotalMilliseconds;
+ if (next < 0)
+ return 0;
+ if (next < timeout)
+ timeout = next;
+ }
+ }
+ if (timeout < Timer.Minimum)
+ timeout = Timer.Minimum;
+
+ return (double)((double)timeout/1000);
+ }
+
+ private void CheckTimers (DateTime now)
+ {
+ lock (TimerList) {
+ int count = TimerList.Count;
+ if (count == 0)
+ return;
+ for (int i = 0; i < TimerList.Count; i++) {
+ Timer timer = (Timer) TimerList [i];
+ if (timer.Enabled && timer.Expires <= now) {
+ timer.FireTick ();
+ timer.Update (now);
+ }
+ }
+ }
+ }
+
+ internal void InvertCaret () {
+ IntPtr window = GetControlOwner (Caret.Hwnd);
+ SetPortWindowPort (window);
+ Rect r = new Rect ();
+ GetWindowPortBounds (window, ref r);
+ r.top += (short)Caret.Y;
+ r.left += (short)Caret.X;
+ r.bottom = (short)(r.top + Caret.Height);
+ r.right = (short)(r.left + Caret.Width);
+ InvertRect (ref r);
+ }
+
+ private void SetHwndStyles(Hwnd hwnd, CreateParams cp) {
+ throw new NotImplementedException();
+ }
+
+ internal void ShowCaret () {
+ if (Caret.On)
+ return;
+ Caret.On = true;
+ InvertCaret ();
+ }
+
+ internal void HideCaret () {
+ if (!Caret.On)
+ return;
+ Caret.On = false;
+ InvertCaret ();
+ }
+
+ internal void InstallTracking (Hwnd hwnd) {
+ // This is currently not used
+
+ /*
+ if (hwnd.client_region_ptr != IntPtr.Zero) {
+ ReleaseMouseTrackingRegion (hwnd.client_region_ptr);
+ hwnd.client_region_ptr = IntPtr.Zero;
+ }
+ if (hwnd.whole_region_ptr != IntPtr.Zero) {
+ ReleaseMouseTrackingRegion (hwnd.whole_region_ptr);
+ hwnd.whole_region_ptr = IntPtr.Zero;
+ }
+ // Setup the new track region
+ if (hwnd.visible) {
+ HIRect client_bounds = new HIRect ();
+ HIViewGetBounds (hwnd.client_window, ref client_bounds);
+ HIViewConvertRect (ref client_bounds, hwnd.client_window, IntPtr.Zero);
+
+ IntPtr rgn = NewRgn ();
+ SetRectRgn (rgn, (short)client_bounds.origin.x, (short)client_bounds.origin.y, (short)(client_bounds.origin.x+hwnd.ClientRect.Width), (short)(client_bounds.origin.y+hwnd.ClientRect.Height));
+ CreateMouseTrackingRegion (GetControlOwner (hwnd.client_window), rgn, IntPtr.Zero, 0, hwnd.client_region_id, hwnd.client_window, IntPtr.Zero, ref hwnd.client_region_ptr);
+ Console.WriteLine (hwnd.ClientRect);
+ Console.WriteLine ("Created a mouse trcaking region on the client window @ {0}x{1} {2}x{3}", (short)client_bounds.origin.x, (short)client_bounds.origin.y, (short)(client_bounds.origin.x+hwnd.ClientRect.Width), (short)(client_bounds.origin.y+hwnd.ClientRect.Height));
+ if (hwnd.ClientRect.X > 0 && hwnd.ClientRect.Y > 0) {
+ HIRect window_bounds = new HIRect ();
+ HIViewGetBounds (hwnd.whole_window, ref window_bounds);
+ HIViewConvertRect (ref window_bounds, hwnd.whole_window, IntPtr.Zero);
+ rgn = NewRgn ();
+ SetRectRgn (rgn, (short)window_bounds.origin.x, (short)window_bounds.origin.y, (short)(window_bounds.origin.x+hwnd.ClientRect.X), (short)(window_bounds.origin.y+hwnd.ClientRect.Y));
+ CreateMouseTrackingRegion (GetControlOwner (hwnd.whole_window), rgn, IntPtr.Zero, 0, hwnd.whole_region_id, hwnd.whole_window, IntPtr.Zero, ref hwnd.whole_region_ptr);
+ Console.WriteLine ("Created a mouse trcaking region on the whole window @ {0}x{1} {2}x{3}", (short)window_bounds.origin.x, (short)window_bounds.origin.y, (short)(window_bounds.origin.x+hwnd.ClientRect.X), (short)(window_bounds.origin.y+hwnd.ClientRect.Y));
+ }
+ }
+ */
+ }
+
+ internal void CheckError (int result, string error) {
+ if (result != 0)
+ throw new Exception ("XplatUIOSX.cs::" + error + "() Carbon subsystem threw an error: " + result);
+ }
+
+ internal void CheckError (int result) {
+ if (result != 0)
+ throw new Exception ("XplatUIOSX.cs::Carbon subsystem threw an error: " + result);
+ }
+
+ #endregion
+
+ #region Public Methods
+
+ internal override IntPtr InitializeDriver() {
+ return IntPtr.Zero;
+ }
+
+ internal override void ShutdownDriver(IntPtr token) {
+ }
+
+ internal override void EnableThemes() {
+ ThemesEnabled = true;
+ }
+
+ internal override void Activate(IntPtr handle) {
+ ActivateWindow (GetControlOwner (handle), true);
+ }
+
+ internal override void AudibleAlert() {
+ throw new NotImplementedException();
+ }
+
+ internal override void CaretVisible (IntPtr hwnd, bool visible) {
+ if (Caret.Hwnd == hwnd) {
+ if (visible) {
+ if (Caret.Visible < 1) {
+ Caret.Visible++;
+ Caret.On = false;
+ if (Caret.Visible == 1) {
+ ShowCaret ();
+ Caret.Timer.Start ();
+ }
+ }
+ } else {
+ Caret.Visible--;
+ if (Caret.Visible == 0) {
+ Caret.Timer.Stop ();
+ HideCaret ();
+ }
+ }
+ }
+ }
+
+ internal override bool CalculateWindowRect(ref Rectangle ClientRect, int Style, int ExStyle, Menu menu, out Rectangle WindowRect) {
+ FormBorderStyle border_style;
+ TitleStyle title_style;
+
+ title_style = TitleStyle.None;
+ if ((Style & (int)WindowStyles.WS_CAPTION) != 0) {
+ if ((ExStyle & (int)WindowExStyles.WS_EX_TOOLWINDOW) != 0) {
+ title_style = TitleStyle.Tool;
+ } else {
+ title_style = TitleStyle.Normal;
+ }
+ }
+
+ border_style = FormBorderStyle.None;
+ if ((ExStyle & (int)WindowExStyles.WS_EX_WINDOWEDGE) != 0) {
+ if ((ExStyle & (int)WindowExStyles.WS_EX_TOOLWINDOW) != 0) {
+ if ((Style & (int)WindowStyles.WS_THICKFRAME) != 0) {
+ border_style = FormBorderStyle.SizableToolWindow;
+ } else {
+ border_style = FormBorderStyle.FixedToolWindow;
+ }
+ } else if ((ExStyle & (int)WindowExStyles.WS_EX_DLGMODALFRAME) != 0) {
+ border_style = FormBorderStyle.FixedDialog;
+ } else if ((ExStyle & (int)WindowStyles.WS_THICKFRAME) != 0) {
+ border_style = FormBorderStyle.Sizable;
+ } else {
+ border_style = FormBorderStyle.FixedSingle;
+ }
+ } else {
+ border_style = FormBorderStyle.Fixed3D;
+ }
+
+ WindowRect = Hwnd.GetWindowRectangle(border_style, menu, title_style,
+ SystemInformation.CaptionHeight,
+ SystemInformation.ToolWindowCaptionHeight, ClientRect);
+
+ return true;
+ }
+
+ internal override void ClientToScreen(IntPtr handle, ref int x, ref int y) {
+ CGPoint pt = new CGPoint ();
+ Rect wBounds = new Rect ();
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ pt.x = x;
+ pt.y = y;
+
+ GetWindowBounds (GetControlOwner (hwnd.client_window), 32, ref wBounds);
+ HIViewConvertPoint (ref pt, handle, IntPtr.Zero);
+
+ x = (int)(pt.x+wBounds.left);
+ y = (int)(pt.y+wBounds.top);
+ }
+
+ internal override int[] ClipboardAvailableFormats(IntPtr handle) {
+ return null;
+ }
+
+ internal override void ClipboardClose(IntPtr handle) {
+ throw new NotImplementedException();
+ }
+
+ internal override int ClipboardGetID(IntPtr handle, string format) {
+ return 0;
+ }
+
+ internal override IntPtr ClipboardOpen() {
+ throw new NotImplementedException();
+ }
+
+ internal override object ClipboardRetrieve(IntPtr handle, int id, XplatUI.ClipboardToObject converter) {
+ throw new NotImplementedException();
+ }
+
+ internal override void ClipboardStore(IntPtr handle, object obj, int type, XplatUI.ObjectToClipboard converter) {
+ throw new NotImplementedException();
+ }
+
+ internal override void CreateCaret (IntPtr hwnd, int width, int height) {
+ if (Caret.Hwnd != IntPtr.Zero)
+ DestroyCaret (Caret.Hwnd);
+
+ Caret.Hwnd = hwnd;
+ Caret.Width = width;
+ Caret.Height = height;
+ Caret.Visible = 0;
+ Caret.On = false;
+ }
+
+ internal override IntPtr CreateWindow(CreateParams cp) {
+ IntPtr windowHnd = IntPtr.Zero;
+ IntPtr parentHnd = cp.Parent;
+ bool realWindow = false;
+ Rectangle clientRect;
+ Hwnd hwnd = new Hwnd ();
+
+ SetHwndStyles (hwnd, cp);
+
+ if (parentHnd == IntPtr.Zero) {
+ if ((cp.Style & (int)(WindowStyles.WS_CHILD))!=0) {
+ // This is a child view that is going to be parentless;
+ realWindow = false;
+ CheckError (HIViewFindByID (HIViewGetRoot (FosterParent), new HIViewID (OSXConstants.kEventClassWindow, 1), ref parentHnd), "HIViewFindByID ()");
+ } else if ((cp.Style & (int)(WindowStyles.WS_POPUP))!=0) {
+ // This is a popup window that will be real.
+ if (cp.X < 1) cp.X = 0;
+ if (cp.Y < 1) cp.Y = 0;
+ realWindow = true;
+ } else {
+ // This is a real root window too
+ if (cp.X < 1) cp.X = 0;
+ if (cp.Y < 1) cp.Y = 0;
+ realWindow = true;
+ }
+ } else {
+ realWindow = false;
+ }
+
+ if (realWindow) {
+ WindowClass windowklass = WindowClass.kOverlayWindowClass;
+ WindowAttributes attributes = WindowAttributes.kWindowCompositingAttribute | WindowAttributes.kWindowStandardHandlerAttribute;
+ if ((cp.Style & ((int)WindowStyles.WS_MINIMIZEBOX)) != 0) {
+ attributes |= WindowAttributes.kWindowCollapseBoxAttribute;
+ }
+ if ((cp.Style & ((int)WindowStyles.WS_MAXIMIZEBOX)) != 0) {
+ attributes |= WindowAttributes.kWindowResizableAttribute | WindowAttributes.kWindowHorizontalZoomAttribute | WindowAttributes.kWindowVerticalZoomAttribute;
+ }
+ if ((cp.Style & ((int)WindowStyles.WS_SYSMENU)) != 0) {
+ attributes |= WindowAttributes.kWindowCloseBoxAttribute;
+ }
+ if ((cp.ExStyle & ((int)WindowExStyles.WS_EX_TOOLWINDOW)) != 0) {
+ attributes = WindowAttributes.kWindowStandardHandlerAttribute | WindowAttributes.kWindowCompositingAttribute;
+ }
+ if ((cp.Style & ((int)WindowStyles.WS_CAPTION)) != 0) {
+ windowklass = WindowClass.kDocumentWindowClass;
+ }
+
+ IntPtr rect = IntPtr.Zero;
+ IntPtr viewHnd = IntPtr.Zero;
+ SetRect (ref rect, (short)cp.X, (short)(cp.Y + MenuBarHeight + TitleBarHeight), (short)(cp.Width+cp.X), (short)(cp.Height+cp.Y+MenuBarHeight+TitleBarHeight));
+ CheckError (CreateNewWindow (windowklass, attributes, ref rect, ref windowHnd), "CreateNewWindow ()");
+
+ CheckError (InstallEventHandler (GetWindowEventTarget (windowHnd), CarbonEventHandler, (uint)windowEvents.Length, windowEvents, windowHnd, IntPtr.Zero), "InstallEventHandler ()");
+ CheckError (HIViewFindByID (HIViewGetRoot (windowHnd), new HIViewID (OSXConstants.kEventClassWindow, 1), ref viewHnd), "HIViewFindByID ()");
+ parentHnd = viewHnd;
+ }
+ hwnd.X = cp.X;
+ hwnd.Y = cp.Y;
+ hwnd.Width = cp.Width;
+ hwnd.Height = cp.Height;
+ hwnd.Parent = Hwnd.ObjectFromHandle (cp.Parent);
+ hwnd.visible = false;
+ clientRect = hwnd.ClientRect;
+
+ HIRect r = new HIRect (0, 0, cp.Width, cp.Height);
+ CheckError (HIObjectCreate (__CFStringMakeConstantString ("com.apple.hiview"), 0, ref hwnd.whole_window), "HIObjectCreate ()");
+ CheckError (InstallEventHandler (GetControlEventTarget (hwnd.whole_window), CarbonEventHandler, (uint)viewEvents.Length, viewEvents, hwnd.whole_window, IntPtr.Zero), "InstallEventHandler ()");
+ CheckError (HIViewChangeFeatures (hwnd.whole_window, 1 << 1, 0), "HIViewChangeFeatures ()");
+ CheckError (HIViewSetFrame (hwnd.whole_window, ref r), "HIViewSetFrame ()");
+ hwnd.WholeWindow = hwnd.whole_window;
+
+ r = new HIRect (0, 0, clientRect.Width, clientRect.Height);
+ CheckError (HIObjectCreate (__CFStringMakeConstantString ("com.apple.hiview"), 0, ref hwnd.client_window), "HIObjectCreate ()");
+ CheckError (InstallEventHandler (GetControlEventTarget (hwnd.client_window), CarbonEventHandler, (uint)viewEvents.Length, viewEvents, hwnd.client_window, IntPtr.Zero), "InstallEventHandler ()");
+ CheckError (HIViewChangeFeatures (hwnd.client_window, 1 << 1, 0), "HIViewChangeFeatures ()");
+ CheckError (HIViewSetFrame (hwnd.client_window, ref r), "HIViewSetFrame ()");
+ hwnd.ClientWindow = hwnd.client_window;
+
+ CheckError (HIViewAddSubview (hwnd.whole_window, hwnd.client_window));
+ CheckError (HIViewPlaceInSuperviewAt (hwnd.client_window, clientRect.X, clientRect.Y));
+
+ if (parentHnd != IntPtr.Zero && parentHnd != hwnd.WholeWindow) {
+ CheckError (HIViewAddSubview (parentHnd, hwnd.whole_window), "HIViewAddSubview ()");
+ CheckError (HIViewPlaceInSuperviewAt (hwnd.whole_window, cp.X, cp.Y), "HIPlaceInSuperviewAt ()");
+ if ((cp.Style & (int)(WindowStyles.WS_VISIBLE))!=0) {
+ CheckError (HIViewSetVisible (hwnd.whole_window, true), "HIViewSetVisible ()");
+ CheckError (HIViewSetVisible (hwnd.client_window, true), "HIViewSetVisible ()");
+ hwnd.visible = true;
+ } else {
+ CheckError (HIViewSetVisible (hwnd.whole_window, false), "HIViewSetVisible ()");
+ CheckError (HIViewSetVisible (hwnd.client_window, false), "HIViewSetVisible ()");
+ hwnd.visible = false;
+ }
+ }
+ if (realWindow) {
+ WindowMapping [hwnd.Handle] = windowHnd;
+ if ((cp.Style & (int)(WindowStyles.WS_VISIBLE))!=0) {
+ CheckError (ShowWindow (windowHnd));
+ CheckError (HIViewSetVisible (hwnd.whole_window, true), "HIViewSetVisible ()");
+ CheckError (HIViewSetVisible (hwnd.client_window, true), "HIViewSetVisible ()");
+ hwnd.visible = true;
+ }
+ if ((cp.Style & (int)(WindowStyles.WS_POPUP))!=0) {
+ CheckError (HIViewSetVisible (hwnd.whole_window, true), "HIViewSetVisible ()");
+ CheckError (HIViewSetVisible (hwnd.client_window, true), "HIViewSetVisible ()");
+ hwnd.visible = true;
+ }
+ }
+
+ return hwnd.Handle;
+ }
+
+ internal override IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
+ CreateParams create_params = new CreateParams();
+
+ create_params.Caption = "";
+ create_params.X = X;
+ create_params.Y = Y;
+ create_params.Width = Width;
+ create_params.Height = Height;
+
+ create_params.ClassName=XplatUI.DefaultClassName;
+ create_params.ClassStyle = 0;
+ create_params.ExStyle=0;
+ create_params.Parent=IntPtr.Zero;
+ create_params.Param=0;
+
+ return CreateWindow(create_params);
+ }
+
+ [MonoTODO]
+ internal override IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ internal override IntPtr DefineStdCursor(StdCursor id) {
+ switch (id) {
+ case StdCursor.AppStarting:
+ return (IntPtr)ThemeCursor.kThemeSpinningCursor;
+ case StdCursor.Arrow:
+ return (IntPtr)ThemeCursor.kThemeArrowCursor;
+ case StdCursor.Cross:
+ return (IntPtr)ThemeCursor.kThemeCrossCursor;
+ case StdCursor.Default:
+ return (IntPtr)ThemeCursor.kThemeArrowCursor;
+ case StdCursor.Hand:
+ return (IntPtr)ThemeCursor.kThemeOpenHandCursor;
+ case StdCursor.Help:
+ return (IntPtr)ThemeCursor.kThemeArrowCursor;
+ case StdCursor.HSplit:
+ return (IntPtr)ThemeCursor.kThemeResizeLeftRightCursor;
+ case StdCursor.IBeam:
+ return (IntPtr)ThemeCursor.kThemeIBeamCursor;
+ case StdCursor.No:
+ return (IntPtr)ThemeCursor.kThemeNotAllowedCursor;
+ case StdCursor.NoMove2D:
+ return (IntPtr)ThemeCursor.kThemeNotAllowedCursor;
+ case StdCursor.NoMoveHoriz:
+ return (IntPtr)ThemeCursor.kThemeNotAllowedCursor;
+ case StdCursor.NoMoveVert:
+ return (IntPtr)ThemeCursor.kThemeNotAllowedCursor;
+ case StdCursor.PanEast:
+ return (IntPtr)ThemeCursor.kThemeResizeRightCursor;
+ case StdCursor.PanNE:
+ return (IntPtr)ThemeCursor.kThemeArrowCursor;
+ case StdCursor.PanNorth:
+ return (IntPtr)ThemeCursor.kThemeArrowCursor;
+ case StdCursor.PanNW:
+ return (IntPtr)ThemeCursor.kThemeArrowCursor;
+ case StdCursor.PanSE:
+ return (IntPtr)ThemeCursor.kThemeArrowCursor;
+ case StdCursor.PanSouth:
+ return (IntPtr)ThemeCursor.kThemeArrowCursor;
+ case StdCursor.PanSW:
+ return (IntPtr)ThemeCursor.kThemeArrowCursor;
+ case StdCursor.PanWest:
+ return (IntPtr)ThemeCursor.kThemeResizeLeftCursor;
+ case StdCursor.SizeAll:
+ return (IntPtr)ThemeCursor.kThemeResizeLeftRightCursor;
+ case StdCursor.SizeNESW:
+ return (IntPtr)ThemeCursor.kThemeArrowCursor;
+ case StdCursor.SizeNS:
+ return (IntPtr)ThemeCursor.kThemeArrowCursor;
+ case StdCursor.SizeNWSE:
+ return (IntPtr)ThemeCursor.kThemeArrowCursor;
+ case StdCursor.SizeWE:
+ return (IntPtr)ThemeCursor.kThemeArrowCursor;
+ case StdCursor.UpArrow:
+ return (IntPtr)ThemeCursor.kThemeArrowCursor;
+ case StdCursor.VSplit:
+ return (IntPtr)ThemeCursor.kThemeArrowCursor;
+ case StdCursor.WaitCursor:
+ return (IntPtr)ThemeCursor.kThemeSpinningCursor;
+ default:
+ return (IntPtr)ThemeCursor.kThemeArrowCursor;
+ }
+ }
+
+ internal override IntPtr DefWndProc(ref Message msg) {
+ Hwnd hwnd = Hwnd.ObjectFromHandle (msg.HWnd);
+ switch ((Msg)msg.Msg) {
+ case Msg.WM_DESTROY: {
+ if (WindowMapping [hwnd.Handle] != null)
+
+ Exit ();
+ break;
+ }
+ }
+ return IntPtr.Zero;
+ }
+
+ internal override void DestroyCaret (IntPtr hwnd) {
+ if (Caret.Hwnd == hwnd) {
+ if (Caret.Visible == 1) {
+ Caret.Timer.Stop ();
+ HideCaret ();
+ }
+ Caret.Hwnd = IntPtr.Zero;
+ Caret.Visible = 0;
+ Caret.On = false;
+ }
+ }
+
+ [MonoTODO]
+ internal override void DestroyCursor(IntPtr cursor) {
+ throw new NotImplementedException ();
+ }
+
+ internal override void DestroyWindow(IntPtr handle) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ if ((hwnd.whole_window != IntPtr.Zero) && HIViewGetSuperview (hwnd.whole_window) != IntPtr.Zero)
+ CheckError (HIViewRemoveFromSuperview (handle), "HIViewRemoveFromSuperview ()");
+
+ if (WindowMapping [hwnd.Handle] != null) {
+ DisposeWindow ((IntPtr)(WindowMapping [hwnd.Handle]));
+ }
+ CFRelease (hwnd.ClientWindow);
+ CFRelease (hwnd.WholeWindow);
+ }
+
+ internal override IntPtr DispatchMessage(ref MSG msg) {
+ return NativeWindow.WndProc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
+ }
+
+ internal override void DoEvents() {
+ }
+
+ internal override void EnableWindow(IntPtr handle, bool Enable) {
+ //Like X11 we need not do anything here
+ }
+
+ internal override void EndLoop(Thread thread) {
+ throw new NotImplementedException();
+ }
+
+ internal void Exit() {
+ GetMessageResult = false;
+ ExitToShell ();
+ }
+
+ internal override IntPtr GetActive() {
+ foreach (DictionaryEntry entry in WindowMapping)
+ if (IsWindowActive ((IntPtr)(entry.Value)))
+ return (IntPtr)(entry.Key);
+
+ return IntPtr.Zero;
+ }
+
+ [MonoTODO]
+ internal override void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
+ throw new NotImplementedException ();
+ }
+
+ internal override void GetDisplaySize(out Size size) {
+ HIRect bounds = CGDisplayBounds (CGMainDisplayID ());
+ size = new Size ((int)bounds.size.width, (int)bounds.size.height);
+ }
+
+ internal override IntPtr GetParent(IntPtr handle) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+ if (hwnd != null && hwnd.parent != null) {
+ return hwnd.parent.Handle;
+ }
+ return IntPtr.Zero;
+ }
+
+ internal override void GetCursorPos(IntPtr handle, out int x, out int y) {
+ QDPoint pt = new QDPoint ();
+ GetGlobalMouse (ref pt);
+ x = pt.x;
+ y = pt.y;
+ }
+
+ internal override bool GetFontMetrics(Graphics g, Font font, out int ascent, out int descent) {
+ return GetFontMetrics(g.GetHdc(), font.ToHfont(), out ascent, out descent);
+ }
+
+ [MonoTODO]
+ internal override Point GetMenuOrigin(IntPtr hwnd) {
+ throw new NotImplementedException();
+ }
+
+ internal override bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
+ IntPtr evtRef = IntPtr.Zero;
+ IntPtr target = GetEventDispatcherTarget();
+ CheckTimers (DateTime.Now);
+ ReceiveNextEvent (0, IntPtr.Zero, 0, true, ref evtRef);
+ if (evtRef != IntPtr.Zero && target != IntPtr.Zero) {
+ SendEventToEventTarget (evtRef, target);
+ ReleaseEvent (evtRef);
+ }
+
+ lock (MessageQueue) {
+ if (MessageQueue.Count <= 0) {
+ if (Idle != null)
+ Idle (this, EventArgs.Empty);
+ else if (TimerList.Count == 0) {
+ ReceiveNextEvent (0, IntPtr.Zero, Convert.ToDouble ("0." + Timer.Minimum), true, ref evtRef);
+ if (evtRef != IntPtr.Zero && target != IntPtr.Zero) {
+ SendEventToEventTarget (evtRef, target);
+ ReleaseEvent (evtRef);
+ }
+ } else {
+ ReceiveNextEvent (0, IntPtr.Zero, NextTimeout (), true, ref evtRef);
+ if (evtRef != IntPtr.Zero && target != IntPtr.Zero) {
+ SendEventToEventTarget (evtRef, target);
+ ReleaseEvent (evtRef);
+ }
+ }
+ msg.hwnd = IntPtr.Zero;
+ msg.message = Msg.WM_ENTERIDLE;
+ return GetMessageResult;
+ }
+ msg = (MSG) MessageQueue.Dequeue ();
+ }
+ return GetMessageResult;
+ }
+
+ [MonoTODO]
+ internal override bool GetText(IntPtr handle, out string text) {
+ throw new NotImplementedException ();
+ }
+
+ internal override void GetWindowPos(IntPtr handle, bool is_toplevel, out int x, out int y, out int width, out int height, out int client_width, out int client_height) {
+ Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
+ Rectangle rect = hwnd.ClientRect;
+
+ x = hwnd.x;
+ y = hwnd.y;
+ width = hwnd.width;
+ height = hwnd.height;
+
+ client_width = rect.Width;
+ client_height = rect.Height;
+ }
+
+ internal override FormWindowState GetWindowState(IntPtr hwnd) {
+ IntPtr window = GetControlOwner (hwnd);
+
+ if (IsWindowCollapsed (window))
+ return FormWindowState.Minimized;
+ if (IsWindowInStandardState (window, IntPtr.Zero, IntPtr.Zero))
+ return FormWindowState.Maximized;
+
+ return FormWindowState.Normal;
+ }
+
+ internal override void GrabInfo(out IntPtr handle, out bool GrabConfined, out Rectangle GrabArea) {
+ handle = Grab.Hwnd;
+ GrabConfined = Grab.Confined;
+ GrabArea = Grab.Area;
+ }
+
+ internal override void GrabWindow(IntPtr handle, IntPtr confine_to_handle) {
+ GrabWindowHwnd = Hwnd.ObjectFromHandle (handle);
+ }
+
+ internal override void UngrabWindow(IntPtr hwnd) {
+ GrabWindowHwnd = null;
+ Grab.Hwnd = IntPtr.Zero;
+ Grab.Confined = false;
+ }
+
+ internal override void HandleException(Exception e) {
+ StackTrace st = new StackTrace(e);
+ Console.WriteLine("Exception '{0}'", e.Message+st.ToString());
+ Console.WriteLine("{0}{1}", e.Message, st.ToString());
+ }
+
+ internal override void Invalidate (IntPtr handle, Rectangle rc, bool clear) {
+ Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
+
+ if (hwnd.visible && HIViewIsVisible (handle)) {
+ MSG msg = new MSG ();
+ msg.hwnd = hwnd.Handle;
+ msg.wParam = IntPtr.Zero;
+ msg.lParam = IntPtr.Zero;
+ msg.message = Msg.WM_PAINT;
+ MessageQueue.Enqueue (msg);
+ // This is currently causing some graphics corruption
+ //hwnd.AddInvalidArea (rc.X, rc.Y, rc.Width, rc.Height);
+ hwnd.AddInvalidArea (0, 0, hwnd.ClientRect.Width, hwnd.ClientRect.Height);
+ hwnd.expose_pending = true;
+ }
+ }
+
+ internal override bool IsEnabled(IntPtr handle) {
+ return Hwnd.ObjectFromHandle(handle).Enabled;
+ }
+
+ internal override bool IsVisible(IntPtr handle) {
+ return Hwnd.ObjectFromHandle(handle).visible;
+ }
+
+ internal override void KillTimer(Timer timer) {
+ lock (TimerList) {
+ TimerList.Remove(timer);
+ }
+ }
+
+ internal override void MenuToScreen(IntPtr handle, ref int x, ref int y) {
+ CGPoint pt = new CGPoint ();
+ Rect wBounds = new Rect ();
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ pt.x = x;
+ pt.y = y;
+
+ GetWindowBounds (GetControlOwner (hwnd.whole_window), 32, ref wBounds);
+ HIViewConvertPoint (ref pt, handle, IntPtr.Zero);
+
+ x = (int)(pt.x+wBounds.left);
+ y = (int)(pt.y+wBounds.top);
+ }
+
+ [MonoTODO]
+ internal override void OverrideCursor(IntPtr cursor) {
+ throw new NotImplementedException ();
+ }
+
+ internal override PaintEventArgs PaintEventStart(IntPtr handle, bool client) {
+ PaintEventArgs paint_event;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ if (Caret.Visible == 1) {
+ Caret.Paused = true;
+ HideCaret();
+ }
+
+ hwnd.client_dc = Graphics.FromHwnd (hwnd.client_window);
+ paint_event = new PaintEventArgs(hwnd.client_dc, hwnd.invalid);
+
+ return paint_event;
+ }
+
+ internal override void PaintEventEnd(IntPtr handle, bool client) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ hwnd.ClearInvalidArea();
+
+ hwnd.client_dc.Flush();
+ hwnd.client_dc.Dispose();
+ hwnd.client_dc = null;
+ hwnd.expose_pending = false;
+
+ if (Caret.Visible == 1) {
+ ShowCaret();
+ Caret.Paused = false;
+ }
+ }
+
+ internal override bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
+ Console.WriteLine("XplatUIOSX.PeekMessage");
+ return true;
+ }
+
+ internal override bool PostMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) {
+ MSG msg = new MSG();
+ msg.hwnd = hwnd;
+ msg.message = message;
+ msg.wParam = wParam;
+ msg.lParam = lParam;
+ MessageQueue.Enqueue (msg);
+ return true;
+ }
+
+ [MonoTODO]
+ internal override void PostQuitMessage(int exitCode) {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ internal override void RequestNCRecalc(IntPtr handle) {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ internal override void ResetMouseHover(IntPtr handle) {
+ throw new NotImplementedException();
+ }
+
+ internal override void ScreenToClient(IntPtr handle, ref int x, ref int y) {
+ CGPoint pt = new CGPoint ();
+ Rect wBounds = new Rect ();
+
+ GetWindowBounds (GetControlOwner (handle), 32, ref wBounds);
+ pt.x = (x-wBounds.left);
+ pt.y = (y-wBounds.top);
+ HIViewConvertPoint (ref pt, IntPtr.Zero, handle);
+
+ x = (int)pt.x;
+ y = (int)pt.y;
+ }
+
+ [MonoTODO]
+ internal override void ScreenToMenu(IntPtr handle, ref int x, ref int y) {
+ CGPoint pt = new CGPoint ();
+ Rect wBounds = new Rect ();
+
+ GetWindowBounds (GetControlOwner (handle), 32, ref wBounds);
+ pt.x = (x-wBounds.left);
+ pt.y = (y-wBounds.top);
+ HIViewConvertPoint (ref pt, IntPtr.Zero, handle);
+
+ x = (int)pt.x;
+ y = (int)pt.y;
+ }
+
+ internal override void ScrollWindow(IntPtr handle, Rectangle area, int XAmount, int YAmount, bool clear) {
+ //IntPtr rect = IntPtr.Zero;
+ //HIRect vBounds = new HIRect ();
+
+ Hwnd hwnd = Hwnd.ObjectFromHandle(handle);
+
+ /*
+ if (hwnd.invalid != Rectangle.Empty) {
+ // BIG FAT WARNING. This only works with how we use this function right now
+ // where we basically still scroll the whole window, but work around areas
+ // that are covered by our children
+
+ hwnd.invalid.X += XAmount;
+ hwnd.invalid.Y += YAmount;
+
+ if (hwnd.invalid.X < 0) {
+ hwnd.invalid.Width += hwnd.invalid.X;
+ hwnd.invalid.X =0;
+ }
+
+ if (hwnd.invalid.Y < 0) {
+ hwnd.invalid.Height += hwnd.invalid.Y;
+ hwnd.invalid.Y =0;
+ }
+ }*/
+
+ HIRect scrollrect = new HIRect ();
+ scrollrect.origin.x = area.X;
+ scrollrect.origin.y = area.Y;
+ scrollrect.size.width = area.Width;
+ scrollrect.size.height = area.Height;
+ HIViewScrollRect (hwnd.Handle, ref scrollrect, (float)XAmount, (float)-YAmount);
+ /*
+ HIViewGetBounds (hwnd.client_window, ref vBounds);
+ HIViewConvertRect (ref vBounds, hwnd.client_window, IntPtr.Zero);
+ SetRect (ref rect, (short)(vBounds.origin.x+area.X), (short)(vBounds.origin.y-TitleBarHeight+area.Y), (short)(vBounds.origin.x+area.Width), (short)(vBounds.origin.y+area.Height-TitleBarHeight));
+ ScrollRect (ref rect, (short)XAmount, (short)-YAmount, IntPtr.Zero);
+ */
+ // Generate an expose for the area exposed by the horizontal scroll
+ /*
+ if (XAmount > 0) {
+ hwnd.AddInvalidArea (area.X, area.Y, XAmount, area.Height);
+ } else if (XAmount < 0) {
+ hwnd.AddInvalidArea (XAmount + area.X + area.Width, area.Y, -XAmount, area.Height);
+ }
+
+ // Generate an expose for the area exposed by the vertical scroll
+ if (YAmount > 0) {
+ hwnd.AddInvalidArea (area.X, area.Y, area.Width, YAmount);
+ } else if (YAmount < 0) {
+ hwnd.AddInvalidArea (area.X, YAmount + area.Y + area.Height, area.Width, -YAmount);
+ }
+
+ UpdateWindow (handle);
+ */
+ }
+
+
+ internal override void ScrollWindow(IntPtr hwnd, int XAmount, int YAmount, bool clear) {
+ throw new NotImplementedException("");
+ }
+
+ [MonoTODO]
+ internal override void SendAsyncMethod (AsyncMethodData method) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ internal override IntPtr SendMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) {
+ throw new NotImplementedException ();
+ }
+
+ internal override void SetCaretPos (IntPtr hwnd, int x, int y) {
+ if (Caret.Hwnd == hwnd) {
+ CGPoint cpt = new CGPoint ();
+ cpt.x = x;
+ cpt.y = y;
+ HIViewConvertPoint (ref cpt, hwnd, IntPtr.Zero);
+ Caret.Timer.Stop ();
+ HideCaret ();
+ Caret.X = (int)cpt.x;
+ Caret.Y = (int)cpt.y-23;
+ if (Caret.Visible == 1) {
+ ShowCaret ();
+ Caret.Timer.Start ();
+ }
+ }
+ }
+
+ internal override void SetCursor(IntPtr window, IntPtr cursor) {
+ SetThemeCursor ((uint) cursor);
+ }
+
+ internal override void SetCursorPos(IntPtr handle, int x, int y) {
+ CGDisplayMoveCursorToPoint (CGMainDisplayID (), new CGPoint (x, y));
+ }
+
+ internal override void SetFocus(IntPtr handle) {
+ if (FocusWindow != IntPtr.Zero) {
+ PostMessage(FocusWindow, Msg.WM_KILLFOCUS, handle, IntPtr.Zero);
+ }
+ PostMessage(handle, Msg.WM_SETFOCUS, FocusWindow, IntPtr.Zero);
+ FocusWindow = handle;
+ }
+
+ [MonoTODO]
+ internal override void SetIcon(IntPtr handle, Icon icon) {
+ throw new NotImplementedException();
+ }
+
+
+ internal override void SetModal(IntPtr handle, bool Modal) {
+ IntPtr hWnd = GetControlOwner (Hwnd.ObjectFromHandle (handle).WholeWindow);
+ if (Modal)
+ BeginAppModalStateForWindow (hWnd);
+ else
+ EndAppModalStateForWindow (hWnd);
+ return;
+ }
+
+ internal override IntPtr SetParent(IntPtr handle, IntPtr parent) {
+ Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
+
+ hwnd.parent = Hwnd.ObjectFromHandle (parent);
+ if (HIViewGetSuperview (hwnd.whole_window) != IntPtr.Zero) {
+ CheckError (HIViewRemoveFromSuperview (hwnd.whole_window), "HIViewRemoveFromSuperview ()");
+ }
+ CheckError (HIViewAddSubview (hwnd.parent.client_window, hwnd.whole_window));
+ CheckError (HIViewAddSubview (hwnd.whole_window, hwnd.client_window));
+ HIViewPlaceInSuperviewAt (hwnd.client_window, hwnd.ClientRect.X, hwnd.ClientRect.Y);
+
+ return IntPtr.Zero;
+ }
+
+ internal override void SetTimer (Timer timer) {
+ lock (TimerList) {
+ TimerList.Add (timer);
+ }
+ }
+
+ internal override bool SetTopmost(IntPtr hWnd, IntPtr hWndOwner, bool Enabled) {
+ HIViewSetZOrder (hWnd, 1, IntPtr.Zero);
+ return true;
+ }
+
+
+ internal override bool SetVisible(IntPtr handle, bool visible) {
+ Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
+ object window = WindowMapping [hwnd.Handle];
+ if (window != null)
+ if (visible)
+ ShowWindow ((IntPtr)window);
+ else
+ HideWindow ((IntPtr)window);
+
+ HIViewSetVisible (hwnd.whole_window, visible);
+ HIViewSetVisible (hwnd.client_window, visible);
+ hwnd.visible = visible;
+ return true;
+ }
+
+ internal override void SetBorderStyle(IntPtr handle, FormBorderStyle border_style) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+ hwnd.border_style = border_style;
+
+ // FIXME - do we need to trigger some resize?
+ }
+
+ internal override void SetMenu(IntPtr handle, Menu menu) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+ hwnd.menu = menu;
+
+ // FIXME - do we need to trigger some resize?
+ }
+
+ internal override void SetWindowMinMax(IntPtr handle, Rectangle maximized, Size min, Size max) {
+ throw new NotImplementedException();
+ }
+
+ internal override void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
+ Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
+ Rectangle client_rect = Hwnd.GetClientRectangle(hwnd.border_style, hwnd.menu,
+ hwnd.title_style, SystemInformation.CaptionHeight,
+ SystemInformation.ToolWindowCaptionHeight, width, height);
+
+ // Save a server roundtrip (and prevent a feedback loop)
+ if ((hwnd.x == x) && (hwnd.y == y) && (hwnd.width == width) && (hwnd.height == height)) {
+ return;
+ }
+
+
+ if (WindowMapping [hwnd.Handle] != null) {
+ if (y <= MenuBarHeight+TitleBarHeight) {
+ y+=MenuBarHeight+TitleBarHeight;
+ }
+ IntPtr rect = IntPtr.Zero;
+ SetRect (ref rect, (short)x, (short)y, (short)(x+width), (short)(y+height));
+ CheckError (SetWindowBounds ((IntPtr) WindowMapping [hwnd.Handle], 33, ref rect), "SetWindowBounds ()");
+ HIRect r = new HIRect (0, 0, width, height);
+ CheckError (HIViewSetFrame (hwnd.whole_window, ref r), "HIViewSetFrame ()");
+ r = new HIRect (client_rect.X, client_rect.Y, client_rect.X+client_rect.Width, client_rect.Y+client_rect.Height);
+ CheckError (HIViewSetFrame (hwnd.client_window, ref r), "HIViewSetFrame ()");
+ } else {
+ HIRect r = new HIRect (x, y, width, height);
+ CheckError (HIViewSetFrame (hwnd.whole_window, ref r), "HIViewSetFrame ()");
+ r = new HIRect (client_rect.X, client_rect.Y, client_rect.X+client_rect.Width, client_rect.Y+client_rect.Height);
+ CheckError (HIViewSetFrame (hwnd.client_window, ref r), "HIViewSetFrame ()");
+ }
+ }
+
+ internal override void SetWindowState(IntPtr hwnd, FormWindowState state) {
+ IntPtr window = GetControlOwner (hwnd);
+
+ switch (state) {
+ case FormWindowState.Minimized: {
+ CollapseWindow (window, true);
+ break;
+ }
+ case FormWindowState.Normal: {
+ ZoomWindow (window, 7, false);
+ break;
+ }
+ case FormWindowState.Maximized: {
+ ZoomWindow (window, 8, false);
+ break;
+ }
+ }
+ }
+
+ internal override void SetWindowStyle(IntPtr handle, CreateParams cp) {
+ Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
+ SetHwndStyles(hwnd, cp);
+
+ if (WindowMapping [hwnd.Handle] != null) {
+ WindowAttributes attributes = WindowAttributes.kWindowCompositingAttribute | WindowAttributes.kWindowStandardHandlerAttribute;
+ if ((cp.Style & ((int)WindowStyles.WS_MINIMIZEBOX)) != 0) {
+ attributes |= WindowAttributes.kWindowCollapseBoxAttribute;
+ }
+ if ((cp.Style & ((int)WindowStyles.WS_MAXIMIZEBOX)) != 0) {
+ attributes |= WindowAttributes.kWindowResizableAttribute | WindowAttributes.kWindowHorizontalZoomAttribute | WindowAttributes.kWindowVerticalZoomAttribute;
+ }
+ if ((cp.Style & ((int)WindowStyles.WS_SYSMENU)) != 0) {
+ attributes |= WindowAttributes.kWindowCloseBoxAttribute;
+ }
+ if ((cp.ExStyle & ((int)WindowExStyles.WS_EX_TOOLWINDOW)) != 0) {
+ attributes = WindowAttributes.kWindowStandardHandlerAttribute | WindowAttributes.kWindowCompositingAttribute;
+ }
+
+ WindowAttributes outAttributes = WindowAttributes.kWindowNoAttributes;
+ GetWindowAttributes ((IntPtr)WindowMapping [hwnd.Handle], ref outAttributes);
+ ChangeWindowAttributes ((IntPtr)WindowMapping [hwnd.Handle], attributes, outAttributes);
+ }
+ }
+
+ internal override void SetWindowTransparency(IntPtr handle, double transparency, Color key) {
+ }
+
+ internal override bool SupportsTransparency() {
+ return false;
+ }
+
+ internal override bool SetZOrder(IntPtr handle, IntPtr after_handle, bool Top, bool Bottom) {
+ Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
+
+ if (Top) {
+ HIViewSetZOrder (hwnd.whole_window, 2, IntPtr.Zero);
+ return true;
+ } else if (!Bottom) {
+ Hwnd after_hwnd = Hwnd.ObjectFromHandle (after_handle);
+ HIViewSetZOrder (hwnd.whole_window, 2, after_hwnd.whole_window);
+ } else {
+ HIViewSetZOrder (hwnd.whole_window, 1, IntPtr.Zero);
+ return true;
+ }
+ return false;
+ }
+
+ internal override void ShowCursor(bool show) {
+ if (show)
+ CGDisplayShowCursor (CGMainDisplayID ());
+ else
+ CGDisplayHideCursor (CGMainDisplayID ());
+ }
+
+ internal override void StartLoop(Thread thread) {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ internal override bool SystrayAdd(IntPtr hwnd, string tip, Icon icon, out ToolTip tt) {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ internal override bool SystrayChange(IntPtr hwnd, string tip, Icon icon, ref ToolTip tt) {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ internal override void SystrayRemove(IntPtr hwnd, ref ToolTip tt) {
+ throw new NotImplementedException();
+ }
+
+ internal override bool Text(IntPtr handle, string text) {
+ Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
+ if (WindowMapping [hwnd.Handle] != null) {
+ CheckError (SetWindowTitleWithCFString ((IntPtr)(WindowMapping [hwnd.Handle]), __CFStringMakeConstantString (text)));
+ }
+ CheckError (SetControlTitleWithCFString (hwnd.whole_window, __CFStringMakeConstantString (text)));
+ CheckError (SetControlTitleWithCFString (hwnd.client_window, __CFStringMakeConstantString (text)));
+ return true;
+ }
+
+ internal override void UpdateWindow(IntPtr handle) {
+ Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
+
+ if (hwnd.visible && HIViewIsVisible (handle) && !hwnd.expose_pending) {
+ MSG msg = new MSG ();
+ msg.message = Msg.WM_PAINT;
+ msg.hwnd = hwnd.Handle;
+ msg.lParam = IntPtr.Zero;
+ msg.wParam = IntPtr.Zero;
+ MessageQueue.Enqueue (msg);
+ }
+ }
+
+ internal override bool TranslateMessage(ref MSG msg) {
+ bool res = false;
+ Hwnd hwnd = Hwnd.ObjectFromHandle (msg.hwnd);
+
+ switch (msg.message) {
+ case Msg.WM_MOUSEMOVE: {
+ // We're grabbed
+ if (GrabWindowHwnd != null) {
+ if (GrabWindowHwnd.Handle != hwnd.Handle) {
+ return false;
+ }
+ } else {
+ if (MouseWindow != null) {
+ if (MouseWindow.Handle != hwnd.Handle) {
+ PostMessage (MouseWindow.Handle, Msg.WM_MOUSE_LEAVE, IntPtr.Zero, IntPtr.Zero);
+ PostMessage (hwnd.Handle, Msg.WM_MOUSE_ENTER, IntPtr.Zero, IntPtr.Zero);
+ MouseWindow = hwnd;
+ }
+ } else {
+ MouseWindow = hwnd;
+ }
+ }
+ break;
+ }
+ case Msg.WM_SETFOCUS: {
+ break;
+ }
+
+ }
+
+ // This is a hideous temporary keyboard hack to bind some keys
+ if (msg.message >= Msg.WM_KEYFIRST && msg.message <= Msg.WM_KEYLAST)
+ res = true;
+
+ if (msg.message != Msg.WM_KEYDOWN && msg.message != Msg.WM_SYSKEYDOWN)
+ return res;
+
+ if ((int)msg.wParam >= (int)'0' && (int)msg.wParam <= (int)'z') {
+ Msg message;
+ message = Msg.WM_CHAR;
+ PostMessage (msg.hwnd, message, msg.wParam, msg.lParam);
+ }
+ return true;
+ }
+
+ internal override void DrawReversibleRectangle(IntPtr handle, Rectangle rect, int line_width) {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ internal override SizeF GetAutoScaleSize(Font font) {
+ throw new NotImplementedException();
+ }
+ #endregion
+
+ #region System information
+ internal override int KeyboardSpeed { get{ throw new NotImplementedException(); } }
+ internal override int KeyboardDelay { get{ throw new NotImplementedException(); } }
+
+ internal override int Caption { get{ throw new NotImplementedException(); } }
+ internal override Size CursorSize { get{ throw new NotImplementedException(); } }
+ internal override bool DragFullWindows { get{ throw new NotImplementedException(); } }
+ internal override Size DragSize { get{ throw new NotImplementedException(); } }
+ internal override Size FrameBorderSize { get{ throw new NotImplementedException(); } }
+ internal override Size IconSize { get{ throw new NotImplementedException(); } }
+ internal override Size MaxWindowTrackSize { get{ throw new NotImplementedException(); } }
+ internal override Size MinimizedWindowSize { get{ throw new NotImplementedException(); } }
+ internal override Size MinimizedWindowSpacingSize { get{ throw new NotImplementedException(); } }
+ internal override Size MinimumWindowSize { get{ throw new NotImplementedException(); } }
+ internal override Size MinWindowTrackSize { get{ throw new NotImplementedException(); } }
+ internal override Size SmallIconSize { get{ throw new NotImplementedException(); } }
+ internal override int MouseButtonCount { get{ throw new NotImplementedException(); } }
+ internal override bool MouseButtonsSwapped { get{ throw new NotImplementedException(); } }
+ internal override bool MouseWheelPresent { get{ throw new NotImplementedException(); } }
+ internal override Rectangle VirtualScreen { get{ throw new NotImplementedException(); } }
+ internal override Rectangle WorkingArea {
+ get {
+ HIRect bounds = CGDisplayBounds (CGMainDisplayID ());
+ return new Rectangle ((int)bounds.origin.x, (int)bounds.origin.y, (int)bounds.size.width, (int)bounds.size.height);
+ }
+ }
+ #endregion
+
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HIViewSetNeedsDisplayInRegion (IntPtr view, IntPtr rgn, bool needsDisplay);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HIViewGetSubviewHit (IntPtr contentView, ref CGPoint point, bool tval, ref IntPtr outPtr);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HIViewGetViewForMouseEvent (IntPtr inView, IntPtr inEvent, ref IntPtr outView);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HIViewConvertPoint (ref CGPoint point, IntPtr pView, IntPtr cView);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HIViewChangeFeatures (IntPtr aView, ulong bitsin, ulong bitsout);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HIViewFindByID (IntPtr rootWnd, HIViewID id, ref IntPtr outPtr);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern IntPtr HIViewGetRoot (IntPtr hWnd);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HIObjectCreate (IntPtr cfStr, uint what, ref IntPtr hwnd);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HIViewSetNeedsDisplay (IntPtr viewHnd, bool update);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HIViewGetFrame (IntPtr viewHnd, ref HIRect rect);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HIViewSetFrame (IntPtr viewHnd, ref HIRect rect);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HIViewPlaceInSuperviewAt (IntPtr view, float x, float y);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HIViewAddSubview (IntPtr parentHnd, IntPtr childHnd);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern IntPtr HIViewGetNextView (IntPtr aView);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern IntPtr HIViewGetPreviousView (IntPtr aView);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern IntPtr HIViewGetFirstSubview (IntPtr aView);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern IntPtr HIViewGetSuperview (IntPtr aView);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HIViewRemoveFromSuperview (IntPtr aView);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HIViewSetVisible (IntPtr vHnd, bool visible);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern bool HIViewIsVisible (IntPtr vHnd);
+ [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 HIViewScrollRect (IntPtr vHnd, ref HIRect rect, float x, float y);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HIViewScrollRect (IntPtr vHnd, IntPtr rect, float x, float y);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HIViewSetZOrder (IntPtr hWnd, int cmd, IntPtr oHnd);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HIViewSetBoundsOrigin (IntPtr vHnd, float x, float y);
+ [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 void ScrollRect (ref IntPtr r, short dh, short dv, IntPtr rgnHandle);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern void SetRect (ref IntPtr r, short left, short top, short right, short bottom);
+
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int CreateEvent (IntPtr allocator, uint classid, uint kind, double when, uint attributes, ref IntPtr outEvent);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int InstallEventHandler (IntPtr window, CarbonEventDelegate handlerProc, uint numtypes, EventTypeSpec [] typeList, IntPtr userData, IntPtr handlerRef);
+ [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")]
+ static extern int ActivateWindow (IntPtr windowHnd, bool inActivate);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern bool IsWindowActive (IntPtr windowHnd);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int SetKeyboardFocus (IntPtr windowHdn, IntPtr cntrlHnd, short partcode);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int GetKeyboardFocus (IntPtr handle, ref IntPtr cntrl);
+
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern IntPtr GetWindowEventTarget (IntPtr window);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern IntPtr GetControlEventTarget (IntPtr aControl);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern IntPtr GetEventDispatcherTarget ();
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int SendEventToEventTarget (IntPtr evt, IntPtr target);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int ReleaseEvent (IntPtr evt);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int ReceiveNextEvent (uint evtCount, IntPtr evtTypes, double timeout, bool processEvt, ref IntPtr evt);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern uint GetEventClass (IntPtr eventRef);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern uint GetEventKind (IntPtr eventRef);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int GetEventParameter (IntPtr evt, OSXConstants.EventParamName inName, OSXConstants.EventParamType inType, IntPtr outActualType, uint bufSize, IntPtr outActualSize, ref byte outData);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int GetEventParameter (IntPtr evt, OSXConstants.EventParamName inName, OSXConstants.EventParamType inType, IntPtr outActualType, uint bufSize, IntPtr outActualSize, ref IntPtr outData);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int GetEventParameter (IntPtr evt, OSXConstants.EventParamName inName, OSXConstants.EventParamType inType, IntPtr outActualType, uint bufSize, IntPtr outActualSize, ref ushort outData);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int GetEventParameter (IntPtr evt, OSXConstants.EventParamName inName, OSXConstants.EventParamType inType, IntPtr outActualType, uint bufSize, IntPtr outActualSize, ref short outData);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int GetEventParameter (IntPtr evt, OSXConstants.EventParamName inName, OSXConstants.EventParamType inType, IntPtr outActualType, uint bufSize, IntPtr outActualSize, ref QDPoint outData);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int SetEventParameter (IntPtr evt, OSXConstants.EventParamName inName, OSXConstants.EventParamType inType, uint bufSize, ref short outData);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int SetEventParameter (IntPtr evt, OSXConstants.EventParamName inName, OSXConstants.EventParamType inType, uint bufSize, ref IntPtr outData);
+
+ [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 int CGContextFillRect (IntPtr cgc, HIRect r);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern CGAffineTransform CGContextGetTextMatrix (IntPtr cgContext);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int CGContextSetTextMatrix (IntPtr cgContext, CGAffineTransform ctm);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int CGContextSetRGBFillColor (IntPtr cgContext, float r, float g, float b, float alpha);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int CGContextSetRGBStrokeColor (IntPtr cgContext, float r, float g, float b, float alpha);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int CGContextSetTextDrawingMode (IntPtr cgContext, int drawingMode);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int CGContextSelectFont (IntPtr cgContext, string fontName, float size, int textEncoding);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int CGContextShowTextAtPoint (IntPtr cgContext, float x, float y, string text, int length);
+ [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 bool IsWindowCollapsed (IntPtr hWnd);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern bool IsWindowInStandardState (IntPtr hWnd, IntPtr a, IntPtr b);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern void CollapseWindow (IntPtr hWnd, bool collapse);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern void ZoomWindow (IntPtr hWnd, short partCode, bool front);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int GetWindowAttributes (IntPtr hWnd, ref WindowAttributes outAttributes);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int ChangeWindowAttributes (IntPtr hWnd, WindowAttributes inAttributes, WindowAttributes outAttributes);
+ [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")]
+ static extern int SetPortWindowPort (IntPtr hWnd);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int GetGlobalMouse (ref QDPoint outData);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int GlobalToLocal (ref QDPoint outData);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int LocalToGlobal (ref QDPoint outData);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int TrackControl (IntPtr handle, QDPoint point, IntPtr data);
+
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int BeginAppModalStateForWindow (IntPtr window);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int EndAppModalStateForWindow (IntPtr window);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int CreateNewWindow (WindowClass klass, WindowAttributes attributes, ref IntPtr r, ref IntPtr window);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int DisposeWindow (IntPtr wHnd);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int ShowWindow (IntPtr wHnd);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HideWindow (IntPtr wHnd);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int SetWindowBounds (IntPtr wHnd, uint reg, ref IntPtr rect);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int GetWindowPortBounds (IntPtr wHnd, ref Rect rect);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int GetWindowBounds (IntPtr wHnd, uint reg, ref Rect rect);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int InvertRect (ref Rect r);
+
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int SetControlTitleWithCFString (IntPtr hWnd, IntPtr titleCFStr);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int SetWindowTitleWithCFString (IntPtr hWnd, IntPtr titleCFStr);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern IntPtr __CFStringMakeConstantString (string cString);
+
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern void CGContextRestoreGState (IntPtr ctx);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern void CGContextSaveGState (IntPtr ctx);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern void CGContextTranslateCTM (IntPtr ctx, double tx, double ty);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern void CGContextScaleCTM (IntPtr ctx, double tx, double ty);
+
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int SetWindowContentColor (IntPtr hWnd, ref RGBColor backColor);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int TrackMouseLocationWithOptions (IntPtr port, int options, double eventtimeout, ref QDPoint point, ref IntPtr modifier, ref MouseTrackingResult status);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int CreateMouseTrackingRegion (IntPtr windowref, IntPtr rgn, IntPtr clip, int options, MouseTrackingRegionID rid, IntPtr refcon, IntPtr evttargetref, ref IntPtr mousetrackref);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int ReleaseMouseTrackingRegion (IntPtr region_handle);
+
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int CFRelease (IntPtr wHnd);
+
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal extern static IntPtr NewRgn ();
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal extern static void CopyRgn (IntPtr srcrgn, IntPtr destrgn);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal extern static void SetRectRgn (IntPtr rgn, short left, short top, short right, short bottom);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal extern static void DisposeRgn (IntPtr rgn);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal extern static void ExitToShell ();
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal extern static short GetMBarHeight ();
+
+ #region Cursor imports
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal extern static HIRect CGDisplayBounds (IntPtr displayID);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal extern static IntPtr CGMainDisplayID ();
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal extern static void CGDisplayShowCursor (IntPtr display);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal extern static void CGDisplayHideCursor (IntPtr display);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal extern static void CGDisplayMoveCursorToPoint (IntPtr display, CGPoint point);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal extern static void SetThemeCursor (uint inCursor);
+ #endregion
+
+ [DllImport ("gdiplus", EntryPoint="GetFontMetrics")]
+ internal extern static bool GetFontMetrics(IntPtr graphicsObject, IntPtr nativeObject, out int ascent, out int descent);
+ }
+
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIStructs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIStructs.cs
new file mode 100644
index 00000000000..46b37397546
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIStructs.cs
@@ -0,0 +1,812 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+
+
+// NOT COMPLETE
+
+using System;
+using System.Drawing;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+ [Flags]
+ internal enum WindowStyles : int {
+ WS_OVERLAPPED = 0x00000000,
+ WS_POPUP = unchecked((int)0x80000000),
+ WS_CHILD = 0x40000000,
+ WS_MINIMIZE = 0x20000000,
+ WS_VISIBLE = 0x10000000,
+ WS_DISABLED = 0x08000000,
+ WS_CLIPSIBLINGS = 0x04000000,
+ WS_CLIPCHILDREN = 0x02000000,
+ WS_MAXIMIZE = 0x01000000,
+ WS_CAPTION = 0x00C00000,
+ WS_BORDER = 0x00800000,
+ WS_DLGFRAME = 0x00400000,
+ WS_VSCROLL = 0x00200000,
+ WS_HSCROLL = 0x00100000,
+ WS_SYSMENU = 0x00080000,
+ WS_THICKFRAME = 0x00040000,
+ WS_GROUP = 0x00020000,
+ WS_TABSTOP = 0x00010000,
+ WS_MINIMIZEBOX = 0x00020000,
+ WS_MAXIMIZEBOX = 0x00010000,
+ WS_TILED = 0x00000000,
+ WS_ICONIC = 0x20000000,
+ WS_SIZEBOX = 0x00040000,
+ WS_POPUPWINDOW = unchecked((int)0x80880000),
+ WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
+ WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW,
+ WS_CHILDWINDOW = WS_CHILD,
+ }
+
+ [Flags]
+ internal enum WindowExStyles : int {
+ // Extended Styles
+ WS_EX_DLGMODALFRAME = 0x00000001,
+ WS_EX_DRAGDETECT = 0x00000002,
+ WS_EX_NOPARENTNOTIFY = 0x00000004,
+ WS_EX_TOPMOST = 0x00000008,
+ WS_EX_ACCEPTFILES = 0x00000010,
+ WS_EX_TRANSPARENT = 0x00000020,
+
+ WS_EX_MDICHILD = 0x00000040,
+ WS_EX_TOOLWINDOW = 0x00000080,
+ WS_EX_WINDOWEDGE = 0x00000100,
+ WS_EX_CLIENTEDGE = 0x00000200,
+ WS_EX_CONTEXTHELP = 0x00000400,
+
+ WS_EX_RIGHT = 0x00001000,
+ WS_EX_LEFT = 0x00000000,
+ WS_EX_RTLREADING = 0x00002000,
+ WS_EX_LTRREADING = 0x00000000,
+ WS_EX_LEFTSCROLLBAR = 0x00004000,
+ WS_EX_LAYERED = 0x00080000,
+ WS_EX_RIGHTSCROLLBAR = 0x00000000,
+
+ WS_EX_CONTROLPARENT = 0x00010000,
+ WS_EX_STATICEDGE = 0x00020000,
+ WS_EX_APPWINDOW = 0x00040000,
+ WS_EX_NOINHERITLAYOUT = 0x00100000,
+ WS_EX_LAYOUTRTL = 0x00400000,
+ WS_EX_COMPOSITED = 0x02000000,
+ WS_EX_NOACTIVATE = 0x08000000,
+
+ WS_EX_OVERLAPPEDWINDOW = WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
+ WS_EX_PALETTEWINDOW = WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST
+ }
+
+ internal enum Msg {
+ WM_NULL = 0x0000,
+ WM_CREATE = 0x0001,
+ WM_DESTROY = 0x0002,
+ WM_MOVE = 0x0003,
+ WM_SIZE = 0x0005,
+ WM_ACTIVATE = 0x0006,
+ WM_SETFOCUS = 0x0007,
+ WM_KILLFOCUS = 0x0008,
+ // public const uint WM_SETVISIBLE = 0x0009;
+ WM_ENABLE = 0x000A,
+ WM_SETREDRAW = 0x000B,
+ WM_SETTEXT = 0x000C,
+ WM_GETTEXT = 0x000D,
+ WM_GETTEXTLENGTH = 0x000E,
+ WM_PAINT = 0x000F,
+ WM_CLOSE = 0x0010,
+ WM_QUERYENDSESSION = 0x0011,
+ WM_QUIT = 0x0012,
+ WM_QUERYOPEN = 0x0013,
+ WM_ERASEBKGND = 0x0014,
+ WM_SYSCOLORCHANGE = 0x0015,
+ WM_ENDSESSION = 0x0016,
+ // public const uint WM_SYSTEMERROR = 0x0017;
+ WM_SHOWWINDOW = 0x0018,
+ WM_CTLCOLOR = 0x0019,
+ WM_WININICHANGE = 0x001A,
+ WM_SETTINGCHANGE = 0x001A,
+ WM_DEVMODECHANGE = 0x001B,
+ WM_ACTIVATEAPP = 0x001C,
+ WM_FONTCHANGE = 0x001D,
+ WM_TIMECHANGE = 0x001E,
+ WM_CANCELMODE = 0x001F,
+ WM_SETCURSOR = 0x0020,
+ WM_MOUSEACTIVATE = 0x0021,
+ WM_CHILDACTIVATE = 0x0022,
+ WM_QUEUESYNC = 0x0023,
+ WM_GETMINMAXINFO = 0x0024,
+ WM_PAINTICON = 0x0026,
+ WM_ICONERASEBKGND = 0x0027,
+ WM_NEXTDLGCTL = 0x0028,
+ // public const uint WM_ALTTABACTIVE = 0x0029;
+ WM_SPOOLERSTATUS = 0x002A,
+ WM_DRAWITEM = 0x002B,
+ WM_MEASUREITEM = 0x002C,
+ WM_DELETEITEM = 0x002D,
+ WM_VKEYTOITEM = 0x002E,
+ WM_CHARTOITEM = 0x002F,
+ WM_SETFONT = 0x0030,
+ WM_GETFONT = 0x0031,
+ WM_SETHOTKEY = 0x0032,
+ WM_GETHOTKEY = 0x0033,
+ // public const uint WM_FILESYSCHANGE = 0x0034;
+ // public const uint WM_ISACTIVEICON = 0x0035;
+ // public const uint WM_QUERYPARKICON = 0x0036;
+ WM_QUERYDRAGICON = 0x0037,
+ WM_COMPAREITEM = 0x0039,
+ // public const uint WM_TESTING = 0x003a;
+ // public const uint WM_OTHERWINDOWCREATED = 0x003c;
+ WM_GETOBJECT = 0x003D,
+ // public const uint WM_ACTIVATESHELLWINDOW = 0x003e;
+ WM_COMPACTING = 0x0041,
+ WM_COMMNOTIFY = 0x0044 ,
+ WM_WINDOWPOSCHANGING = 0x0046,
+ WM_WINDOWPOSCHANGED = 0x0047,
+ WM_POWER = 0x0048,
+ WM_COPYDATA = 0x004A,
+ WM_CANCELJOURNAL = 0x004B,
+ WM_NOTIFY = 0x004E,
+ WM_INPUTLANGCHANGEREQUEST = 0x0050,
+ WM_INPUTLANGCHANGE = 0x0051,
+ WM_TCARD = 0x0052,
+ WM_HELP = 0x0053,
+ WM_USERCHANGED = 0x0054,
+ WM_NOTIFYFORMAT = 0x0055,
+ WM_CONTEXTMENU = 0x007B,
+ WM_STYLECHANGING = 0x007C,
+ WM_STYLECHANGED = 0x007D,
+ WM_DISPLAYCHANGE = 0x007E,
+ WM_GETICON = 0x007F,
+
+ // Non-Client messages
+ WM_SETICON = 0x0080,
+ WM_NCCREATE = 0x0081,
+ WM_NCDESTROY = 0x0082,
+ WM_NCCALCSIZE = 0x0083,
+ WM_NCHITTEST = 0x0084,
+ WM_NCPAINT = 0x0085,
+ WM_NCACTIVATE = 0x0086,
+ WM_GETDLGCODE = 0x0087,
+ WM_SYNCPAINT = 0x0088,
+ // public const uint WM_SYNCTASK = 0x0089;
+ WM_NCMOUSEMOVE = 0x00A0,
+ WM_NCLBUTTONDOWN = 0x00A1,
+ WM_NCLBUTTONUP = 0x00A2,
+ WM_NCLBUTTONDBLCLK = 0x00A3,
+ WM_NCRBUTTONDOWN = 0x00A4,
+ WM_NCRBUTTONUP = 0x00A5,
+ WM_NCRBUTTONDBLCLK = 0x00A6,
+ WM_NCMBUTTONDOWN = 0x00A7,
+ WM_NCMBUTTONUP = 0x00A8,
+ WM_NCMBUTTONDBLCLK = 0x00A9,
+ // public const uint WM_NCXBUTTONDOWN = 0x00ab;
+ // public const uint WM_NCXBUTTONUP = 0x00ac;
+ // public const uint WM_NCXBUTTONDBLCLK = 0x00ad;
+ WM_KEYDOWN = 0x0100,
+ WM_KEYFIRST = 0x0100,
+ WM_KEYUP = 0x0101,
+ WM_CHAR = 0x0102,
+ WM_DEADCHAR = 0x0103,
+ WM_SYSKEYDOWN = 0x0104,
+ WM_SYSKEYUP = 0x0105,
+ WM_SYSCHAR = 0x0106,
+ WM_SYSDEADCHAR = 0x0107,
+ WM_KEYLAST = 0x0108,
+ WM_IME_STARTCOMPOSITION = 0x010D,
+ WM_IME_ENDCOMPOSITION = 0x010E,
+ WM_IME_COMPOSITION = 0x010F,
+ WM_IME_KEYLAST = 0x010F,
+ WM_INITDIALOG = 0x0110,
+ WM_COMMAND = 0x0111,
+ WM_SYSCOMMAND = 0x0112,
+ WM_TIMER = 0x0113,
+ WM_HSCROLL = 0x0114,
+ WM_VSCROLL = 0x0115,
+ WM_INITMENU = 0x0116,
+ WM_INITMENUPOPUP = 0x0117,
+ // public const uint WM_SYSTIMER = 0x0118;
+ WM_MENUSELECT = 0x011F,
+ WM_MENUCHAR = 0x0120,
+ WM_ENTERIDLE = 0x0121,
+ WM_MENURBUTTONUP = 0x0122,
+ WM_MENUDRAG = 0x0123,
+ WM_MENUGETOBJECT = 0x0124,
+ WM_UNINITMENUPOPUP = 0x0125,
+ WM_MENUCOMMAND = 0x0126,
+ // public const uint WM_CHANGEUISTATE = 0x0127;
+ // public const uint WM_UPDATEUISTATE = 0x0128;
+ // public const uint WM_QUERYUISTATE = 0x0129;
+
+ // public const uint WM_LBTRACKPOINT = 0x0131;
+ WM_CTLCOLORMSGBOX = 0x0132,
+ WM_CTLCOLOREDIT = 0x0133,
+ WM_CTLCOLORLISTBOX = 0x0134,
+ WM_CTLCOLORBTN = 0x0135,
+ WM_CTLCOLORDLG = 0x0136,
+ WM_CTLCOLORSCROLLBAR = 0x0137,
+ WM_CTLCOLORSTATIC = 0x0138,
+ WM_MOUSEMOVE = 0x0200,
+ WM_MOUSEFIRST = 0x0200,
+ WM_LBUTTONDOWN = 0x0201,
+ WM_LBUTTONUP = 0x0202,
+ WM_LBUTTONDBLCLK = 0x0203,
+ WM_RBUTTONDOWN = 0x0204,
+ WM_RBUTTONUP = 0x0205,
+ WM_RBUTTONDBLCLK = 0x0206,
+ WM_MBUTTONDOWN = 0x0207,
+ WM_MBUTTONUP = 0x0208,
+ WM_MBUTTONDBLCLK = 0x0209,
+ WM_MOUSEWHEEL = 0x020A,
+ WM_MOUSELAST = 0x020D,
+ // public const uint WM_XBUTTONDOWN = 0x020B;
+ // public const uint WM_XBUTTONUP = 0x020C;
+ // public const uint WM_XBUTTONDBLCLK = 0x020D;
+ WM_PARENTNOTIFY = 0x0210,
+ WM_ENTERMENULOOP = 0x0211,
+ WM_EXITMENULOOP = 0x0212,
+ WM_NEXTMENU = 0x0213,
+ WM_SIZING = 0x0214,
+ WM_CAPTURECHANGED = 0x0215,
+ WM_MOVING = 0x0216,
+ // public const uint WM_POWERBROADCAST = 0x0218;
+ WM_DEVICECHANGE = 0x0219,
+ WM_MDICREATE = 0x0220,
+ WM_MDIDESTROY = 0x0221,
+ WM_MDIACTIVATE = 0x0222,
+ WM_MDIRESTORE = 0x0223,
+ WM_MDINEXT = 0x0224,
+ WM_MDIMAXIMIZE = 0x0225,
+ WM_MDITILE = 0x0226,
+ WM_MDICASCADE = 0x0227,
+ WM_MDIICONARRANGE = 0x0228,
+ WM_MDIGETACTIVE = 0x0229,
+ /* D&D messages */
+ // public const uint WM_DROPOBJECT = 0x022A;
+ // public const uint WM_QUERYDROPOBJECT = 0x022B;
+ // public const uint WM_BEGINDRAG = 0x022C;
+ // public const uint WM_DRAGLOOP = 0x022D;
+ // public const uint WM_DRAGSELECT = 0x022E;
+ // public const uint WM_DRAGMOVE = 0x022F;
+ WM_MDISETMENU = 0x0230,
+ WM_ENTERSIZEMOVE = 0x0231,
+ WM_EXITSIZEMOVE = 0x0232,
+ WM_DROPFILES = 0x0233,
+ WM_MDIREFRESHMENU = 0x0234,
+ WM_IME_SETCONTEXT = 0x0281,
+ WM_IME_NOTIFY = 0x0282,
+ WM_IME_CONTROL = 0x0283,
+ WM_IME_COMPOSITIONFULL = 0x0284,
+ WM_IME_SELECT = 0x0285,
+ WM_IME_CHAR = 0x0286,
+ WM_IME_REQUEST = 0x0288,
+ WM_IME_KEYDOWN = 0x0290,
+ WM_IME_KEYUP = 0x0291,
+ WM_MOUSEHOVER = 0x02A1,
+ WM_MOUSELEAVE = 0x02A3,
+ WM_CUT = 0x0300,
+ WM_COPY = 0x0301,
+ WM_PASTE = 0x0302,
+ WM_CLEAR = 0x0303,
+ WM_UNDO = 0x0304,
+ WM_RENDERFORMAT = 0x0305,
+ WM_RENDERALLFORMATS = 0x0306,
+ WM_DESTROYCLIPBOARD = 0x0307,
+ WM_DRAWCLIPBOARD = 0x0308,
+ WM_PAINTCLIPBOARD = 0x0309,
+ WM_VSCROLLCLIPBOARD = 0x030A,
+ WM_SIZECLIPBOARD = 0x030B,
+ WM_ASKCBFORMATNAME = 0x030C,
+ WM_CHANGECBCHAIN = 0x030D,
+ WM_HSCROLLCLIPBOARD = 0x030E,
+ WM_QUERYNEWPALETTE = 0x030F,
+ WM_PALETTEISCHANGING = 0x0310,
+ WM_PALETTECHANGED = 0x0311,
+ WM_HOTKEY = 0x0312,
+ WM_PRINT = 0x0317,
+ WM_PRINTCLIENT = 0x0318,
+ WM_HANDHELDFIRST = 0x0358,
+ WM_HANDHELDLAST = 0x035F,
+ WM_AFXFIRST = 0x0360,
+ WM_AFXLAST = 0x037F,
+ WM_PENWINFIRST = 0x0380,
+ WM_PENWINLAST = 0x038F,
+ WM_APP = 0x8000,
+ WM_USER = 0x0400,
+
+ // Our "private" ones
+ WM_MOUSE_ENTER = 0x0401,
+ WM_MOUSE_LEAVE = 0x0402,
+ WM_ASYNC_MESSAGE = 0x0403,
+ WM_REFLECT = WM_USER + 0x1c00,
+ WM_CLOSE_INTERNAL = WM_USER + 0x1c01
+ }
+
+#if notdef
+ internal enum Msg {
+ WM_NULL = 0x0000,
+ WM_CREATE = 0x0001,
+ WM_DESTROY = 0x0002,
+ WM_MOVE = 0x0003,
+ WM_SIZE = 0x0005,
+ WM_ACTIVATE = 0x0006,
+ WM_SETFOCUS = 0x0007,
+ WM_KILLFOCUS = 0x0008,
+ WM_SETVISIBLE = 0x0009,
+ WM_ENABLE = 0x000A,
+ // ...
+ WM_PAINT = 0x000F,
+ WM_CLOSE = 0x0010,
+ WM_QUERYENDSESSION = 0x0011,
+ WM_QUIT = 0x0012,
+ WM_QUERYOPEN = 0x0013,
+ WM_ERASEBKGND = 0x0014,
+ WM_SYSCOLORCHANGE = 0x0015,
+
+ // ...
+ WM_WINDOWPOSCHANGED = 0x0046,
+
+ // ...
+ WM_KEYFIRST = 0x0100,
+ WM_KEYDOWN = 0x0100,
+ WM_KEYUP = 0x0101,
+ WM_CHAR = 0x0102,
+ WM_DEADCHAR = 0x0103,
+ WM_SYSKEYDOWN = 0x0104,
+ WM_SYSKEYUP = 0x0105,
+ WM_SYS1CHAR = 0x0106,
+ WM_SYSDEADCHAR = 0x0107,
+ WM_KEYLAST = 0x0108,
+
+ // ...
+ WM_MOUSEFIRST = 0x0200,
+ WM_MOUSEMOVE = 0x0200,
+ WM_LBUTTONDOWN = 0x0201,
+ WM_LBUTTONUP = 0x0202,
+ WM_LBUTTONDBLCLK = 0x0203,
+ WM_RBUTTONDOWN = 0x0204,
+ WM_RBUTTONUP = 0x0205,
+ WM_RBUTTONDBLCLK = 0x0206,
+ WM_MBUTTONDOWN = 0x0207,
+ WM_MBUTTONUP = 0x0208,
+ WM_MBUTTONDBLCLK = 0x0209,
+ WM_MOUSEWHEEL = 0x020A,
+ WM_MOUSELAST = 0x020D,
+ // ...
+ WM_MOUSEHOVER = 0x02A1,
+ WM_MOUSELEAVE = 0x02A3,
+ }
+#endif
+
+ internal enum MsgButtons {
+ MK_LBUTTON = 0x0001,
+ MK_RBUTTON = 0x0002,
+ MK_SHIFT = 0x0004,
+ MK_CONTROL = 0x0008,
+ MK_MBUTTON = 0x0010,
+ MK_XBUTTON1 = 0x0020,
+ MK_XBUTTON2 = 0x0040,
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct POINT {
+ internal int x;
+ internal int y;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct MSG {
+ internal IntPtr hwnd;
+ internal Msg message;
+ internal IntPtr wParam;
+ internal IntPtr lParam;
+ internal uint time;
+ internal POINT pt;
+ }
+
+ internal enum WindowActiveFlags {
+ WA_INACTIVE = 0,
+ WA_ACTIVE = 1,
+ WA_CLICKACTIVE = 2
+ }
+
+ internal enum KeybdEventFlags {
+ None = 0,
+ ExtendedKey = 0x0001,
+ KeyUp = 0x0002
+ }
+
+ internal enum VirtualKeys {
+ VK_LBUTTON = 0x01,
+ VK_RBUTTON = 0x02,
+ VK_CANCEL = 0x03,
+ VK_MBUTTON = 0x04,
+ VK_XBUTTON1 = 0x05,
+ VK_XBUTTON2 = 0x06,
+ VK_BACK = 0x08,
+ VK_TAB = 0x09,
+ VK_CLEAR = 0x0C,
+ VK_RETURN = 0x0D,
+ VK_SHIFT = 0x10,
+ VK_CONTROL = 0x11,
+ VK_MENU = 0x12,
+ VK_PAUSE = 0x13,
+ VK_CAPITAL = 0x14,
+ VK_ESCAPE = 0x1B,
+ VK_SPACE = 0x20,
+ VK_PRIOR = 0x21,
+ VK_NEXT = 0x22,
+ VK_END = 0x23,
+ VK_HOME = 0x24,
+ VK_LEFT = 0x25,
+ VK_UP = 0x26,
+ VK_RIGHT = 0x27,
+ VK_DOWN = 0x28,
+ VK_SELECT = 0x29,
+ VK_PRINT = 0x2A,
+ VK_EXECUTE = 0x2B,
+ VK_SNAPSHOT = 0x2C,
+ VK_INSERT = 0x2D,
+ VK_DELETE = 0x2E,
+ VK_HELP = 0x2F,
+ VK_0 = 0x30,
+ VK_1 = 0x31,
+ VK_2 = 0x32,
+ VK_3 = 0x33,
+ VK_4 = 0x34,
+ VK_5 = 0x35,
+ VK_6 = 0x36,
+ VK_7 = 0x37,
+ VK_8 = 0x38,
+ VK_9 = 0x39,
+ VK_A = 0x41,
+ VK_B = 0x42,
+ VK_C = 0x43,
+ VK_D = 0x44,
+ VK_E = 0x45,
+ VK_F = 0x46,
+ VK_G = 0x47,
+ VK_H = 0x48,
+ VK_I = 0x49,
+ VK_J = 0x4A,
+ VK_K = 0x4B,
+ VK_L = 0x4C,
+ VK_M = 0x4D,
+ VK_N = 0x4E,
+ VK_O = 0x4F,
+ VK_P = 0x50,
+ VK_Q = 0x51,
+ VK_R = 0x52,
+ VK_S = 0x53,
+ VK_T = 0x54,
+ VK_U = 0x55,
+ VK_V = 0x56,
+ VK_W = 0x57,
+ VK_X = 0x58,
+ VK_Y = 0x59,
+ VK_Z = 0x5A,
+ VK_LWIN = 0x5B,
+ VK_RWIN = 0x5C,
+ VK_APPS = 0x5D,
+ VK_NUMPAD0 = 0x60,
+ VK_NUMPAD1 = 0x61,
+ VK_NUMPAD2 = 0x62,
+ VK_NUMPAD3 = 0x63,
+ VK_NUMPAD4 = 0x64,
+ VK_NUMPAD5 = 0x65,
+ VK_NUMPAD6 = 0x66,
+ VK_NUMPAD7 = 0x67,
+ VK_NUMPAD8 = 0x68,
+ VK_NUMPAD9 = 0x69,
+ VK_MULTIPLY = 0x6A,
+ VK_ADD = 0x6B,
+ VK_SEPARATOR = 0x6C,
+ VK_SUBTRACT = 0x6D,
+ VK_DECIMAL = 0x6E,
+ VK_DIVIDE = 0x6F,
+ VK_F1 = 0x70,
+ VK_F2 = 0x71,
+ VK_F3 = 0x72,
+ VK_F4 = 0x73,
+ VK_F5 = 0x74,
+ VK_F6 = 0x75,
+ VK_F7 = 0x76,
+ VK_F8 = 0x77,
+ VK_F9 = 0x78,
+ VK_F10 = 0x79,
+ VK_F11 = 0x7A,
+ VK_F12 = 0x7B,
+ VK_F13 = 0x7C,
+ VK_F14 = 0x7D,
+ VK_F15 = 0x7E,
+ VK_F16 = 0x7F,
+ VK_F17 = 0x80,
+ VK_F18 = 0x81,
+ VK_F19 = 0x82,
+ VK_F20 = 0x83,
+ VK_F21 = 0x84,
+ VK_F22 = 0x85,
+ VK_F23 = 0x86,
+ VK_F24 = 0x87,
+ VK_NUMLOCK = 0x90,
+ VK_SCROLL = 0x91,
+ VK_LSHIFT = 0xA0,
+ VK_RSHIFT = 0xA1,
+ VK_LCONTROL = 0xA2,
+ VK_RCONTROL = 0xA3,
+ VK_LMENU = 0xA4,
+ VK_RMENU = 0xA5,
+ VK_OEM_1 = 0xBA,
+ VK_OEM_PLUS = 0xBB,
+ VK_OEM_COMMA = 0xBC,
+ VK_OEM_MINUS = 0xBD,
+ VK_OEM_PERIOD = 0xBE,
+ VK_OEM_2 = 0xBF,
+ VK_OEM_3 = 0xC0,
+ VK_OEM_4 = 0xDB,
+ VK_OEM_5 = 0xDC,
+ VK_OEM_6 = 0xDD,
+ VK_OEM_7 = 0xDE,
+ VK_OEM_8 = 0xDF,
+ VK_OEM_AX = 0xE1,
+ VK_OEM_102 = 0xE2,
+ VK_ICO_HELP = 0xE3,
+ VK_ICO_00 = 0xE4,
+ VK_PROCESSKEY = 0xE5,
+ VK_ATTN = 0xF6,
+ VK_CRSEL = 0xF7,
+ VK_EXSEL = 0xF8,
+ VK_EREOF = 0xF9,
+ VK_PLAY = 0xFA,
+ VK_ZOOM = 0xFB,
+ VK_NONAME = 0xFC,
+ VK_PA1 = 0xFD,
+ VK_OEM_CLEAR = 0xFE,
+ }
+
+ internal enum TtyKeys {
+ XK_BackSpace = 0xff08, /* Back space, back char */
+ XK_Tab = 0xff09,
+ XK_Linefeed = 0xff0a, /* Linefeed, LF */
+ XK_Clear = 0xff0b,
+ XK_Return = 0xff0d, /* Return, enter */
+ XK_Pause = 0xff13, /* Pause, hold */
+ XK_Scroll_Lock = 0xff14,
+ XK_Sys_Req = 0xff15,
+ XK_Escape = 0xff1b,
+ XK_Delete = 0xffff /* Delete, rubout */
+ }
+
+ internal enum MiscKeys {
+ XK_ISO_Lock = 0xfe01,
+ XK_ISO_Last_Group_Lock = 0xfe0f,
+ XK_Select = 0xff60,
+ XK_Print = 0xff61,
+ XK_Execute = 0xff62,
+ XK_Insert = 0xff63,
+ XK_Undo = 0xff65,
+ XK_Redo = 0xff66,
+ XK_Menu = 0xff67,
+ XK_Find = 0xff68,
+ XK_Cancel = 0xff69,
+ XK_Help = 0xff6a,
+ XK_Break = 0xff6b,
+ XK_Mode_switch = 0xff7e,
+ XK_script_switch = 0xff7e,
+ XK_Num_Lock = 0xff7f
+ }
+
+ internal enum KeypadKeys {
+ XK_KP_Space = 0xff80,
+ XK_KP_Tab = 0xff89,
+ XK_KP_Enter = 0xff8d, /* Enter */
+ XK_KP_F1 = 0xff91, /* PF1, KP_A, ... */
+ XK_KP_F2 = 0xff92,
+ XK_KP_F3 = 0xff93,
+ XK_KP_F4 = 0xff94,
+ XK_KP_Home = 0xff95,
+ XK_KP_Left = 0xff96,
+ XK_KP_Up = 0xff97,
+ XK_KP_Right = 0xff98,
+ XK_KP_Down = 0xff99,
+ XK_KP_Prior = 0xff9a,
+ XK_KP_Page_Up = 0xff9a,
+ XK_KP_Next = 0xff9b,
+ XK_KP_Page_Down = 0xff9b,
+ XK_KP_End = 0xff9c,
+ XK_KP_Begin = 0xff9d,
+ XK_KP_Insert = 0xff9e,
+ XK_KP_Delete = 0xff9f,
+ XK_KP_Equal = 0xffbd, /* Equals */
+ XK_KP_Multiply = 0xffaa,
+ XK_KP_Add = 0xffab,
+ XK_KP_Separator = 0xffac, /* Separator, often comma */
+ XK_KP_Subtract = 0xffad,
+ XK_KP_Decimal = 0xffae,
+ XK_KP_Divide = 0xffaf,
+
+ XK_KP_0 = 0xffb0,
+ XK_KP_1 = 0xffb1,
+ XK_KP_2 = 0xffb2,
+ XK_KP_3 = 0xffb3,
+ XK_KP_4 = 0xffb4,
+ XK_KP_5 = 0xffb5,
+ XK_KP_6 = 0xffb6,
+ XK_KP_7 = 0xffb7,
+ XK_KP_8 = 0xffb8,
+ XK_KP_9 = 0xffb9
+ }
+
+ internal enum DeadKeys {
+ XK_dead_grave = 0xfe50,
+ XK_dead_acute = 0xfe51,
+ XK_dead_circumflex = 0xfe52,
+ XK_dead_tilde = 0xfe53,
+ XK_dead_macron = 0xfe54,
+ XK_dead_breve = 0xfe55,
+ XK_dead_abovedot = 0xfe56,
+ XK_dead_diaeresis = 0xfe57,
+ XK_dead_abovering = 0xfe58,
+ XK_dead_doubleacute = 0xfe59,
+ XK_dead_caron = 0xfe5a,
+ XK_dead_cedilla = 0xfe5b,
+ XK_dead_ogonek = 0xfe5c,
+ XK_dead_iota = 0xfe5d,
+ XK_dead_voiced_sound = 0xfe5e,
+ XK_dead_semivoiced_sound = 0xfe5f,
+ XK_dead_belowdot = 0xfe60,
+ XK_dead_hook = 0xfe61,
+ XK_dead_horn = 0xfe62
+
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct HELPINFO {
+ internal uint cbSize;
+ internal int iContextType;
+ internal int iCtrlId;
+ internal IntPtr hItemHandle;
+ internal uint dwContextId;
+ internal POINT MousePos;
+ }
+
+ internal enum PeekMessageFlags {
+ PM_NOREMOVE = 0x00000000,
+ PM_REMOVE = 0x00000001,
+ PM_NOYIELD = 0x00000002
+ }
+
+ internal enum StdCursor {
+ Default = 0,
+ AppStarting = 1,
+ Arrow = 2,
+ Cross = 3,
+ Hand = 4,
+ Help = 5,
+ HSplit = 6,
+ IBeam = 7,
+ No = 8,
+ NoMove2D = 9,
+ NoMoveHoriz = 10,
+ NoMoveVert = 11,
+ PanEast = 12,
+ PanNE = 13,
+ PanNorth = 14,
+ PanNW = 15,
+ PanSE = 16,
+ PanSouth = 17,
+ PanSW = 18,
+ PanWest = 19,
+ SizeAll = 20,
+ SizeNESW = 21,
+ SizeNS = 22,
+ SizeNWSE = 23,
+ SizeWE = 24,
+ UpArrow = 25,
+ VSplit = 26,
+ WaitCursor = 27
+ }
+
+ internal enum HitTest {
+ HTERROR = -2,
+ HTTRANSPARENT = -1,
+ HTNOWHERE = 0,
+ HTCLIENT = 1,
+ HTCAPTION = 2,
+ HTSYSMENU = 3,
+ HTGROWBOX = 4,
+ HTSIZE = HTGROWBOX,
+ HTMENU = 5,
+ HTHSCROLL = 6,
+ HTVSCROLL = 7,
+ HTMINBUTTON = 8,
+ HTMAXBUTTON = 9,
+ HTLEFT = 10,
+ HTRIGHT = 11,
+ HTTOP = 12,
+ HTTOPLEFT = 13,
+ HTTOPRIGHT = 14,
+ HTBOTTOM = 15,
+ HTBOTTOMLEFT = 16,
+ HTBOTTOMRIGHT = 17,
+ HTBORDER = 18,
+ HTREDUCE = HTMINBUTTON,
+ HTZOOM = HTMAXBUTTON,
+ HTSIZEFIRST = HTLEFT,
+ HTSIZELAST = HTBOTTOMRIGHT,
+ HTOBJECT = 19,
+ HTCLOSE = 20,
+ HTHELP = 21
+ }
+
+ internal enum TitleStyle {
+ None = 0,
+ Normal = 1,
+ Tool = 2
+ }
+
+ [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;
+ }
+
+ internal enum ClipboardFormats : ushort {
+ CF_TEXT = 1,
+ CF_BITMAP = 2,
+ CF_METAFILEPICT = 3,
+ CF_SYLK = 4,
+ CF_DIF = 5,
+ CF_TIFF = 6,
+ CF_OEMTEXT = 7,
+ CF_DIB = 8,
+ CF_PALETTE = 9,
+ CF_PENDATA = 10,
+ CF_RIFF = 11,
+ CF_WAVE = 12,
+ CF_UNICODETEXT = 13,
+ CF_ENHMETAFILE = 14,
+ CF_HDROP = 15,
+ CF_LOCALE = 16,
+ CF_DIBV5 = 17
+ }
+
+ [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
+ internal struct MINMAXINFO {
+ internal POINT ptReserved;
+ internal POINT ptMaxSize;
+ internal POINT ptMaxPosition;
+ internal POINT ptMinTrackSize;
+ internal POINT ptMaxTrackSize;
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
new file mode 100644
index 00000000000..f900f46ad60
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
@@ -0,0 +1,2599 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.ComponentModel;
+using System.Collections;
+using System.Diagnostics;
+using System.IO;
+using System.Runtime.InteropServices;
+using System.Text;
+
+
+/// Win32 Version
+namespace System.Windows.Forms {
+ internal class XplatUIWin32 : XplatUIDriver {
+ #region Local Variables
+ private static XplatUIWin32 instance;
+ private static int ref_count;
+ private static IntPtr FosterParent;
+
+ internal static MouseButtons mouse_state;
+ internal static Point mouse_position;
+ internal static bool grab_confined;
+ internal static IntPtr grab_hwnd;
+ internal static Rectangle grab_area;
+ internal static WndProc wnd_proc;
+ internal static IntPtr prev_mouse_hwnd;
+ internal static IntPtr override_cursor;
+ internal static bool caret_visible;
+
+ internal static bool themes_enabled;
+ private Hashtable timer_list;
+ private static Queue message_queue;
+ private static IntPtr clip_magic = new IntPtr(27051977);
+
+ private static Win32DnD DnD;
+ #endregion // Local Variables
+
+ #region Private Structs
+ [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
+ private struct WNDCLASS {
+ internal int style;
+ internal WndProc lpfnWndProc;
+ internal int cbClsExtra;
+ internal int cbWndExtra;
+ internal IntPtr hInstance;
+ internal IntPtr hIcon;
+ internal IntPtr hCursor;
+ internal IntPtr hbrBackground;
+ [MarshalAs(UnmanagedType.LPWStr)]
+ internal string lpszMenuName;
+ [MarshalAs(UnmanagedType.LPWStr)]
+ internal string lpszClassName;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct RECT {
+ internal int left;
+ internal int top;
+ internal int right;
+ internal int bottom;
+ public override string ToString() {
+ return String.Format("RECT left={0}, top={1}, right={2}, bottom={3}, width={4}, height={5}", left, top, right, bottom, right-left, bottom-top);
+ }
+
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct POINT {
+ internal int x;
+ internal int y;
+ }
+
+ internal enum SPIAction {
+ SPI_GETWORKAREA = 0x0030,
+ SPI_GETMOUSEHOVERWIDTH = 0x0062,
+ SPI_GETMOUSEHOVERHEIGHT = 0x0064,
+ SPI_GETMOUSEHOVERTIME = 0x0066,
+ }
+
+ internal enum WindowPlacementFlags {
+ SW_HIDE = 0,
+ SW_SHOWNORMAL = 1,
+ SW_NORMAL = 1,
+ SW_SHOWMINIMIZED = 2,
+ SW_SHOWMAXIMIZED = 3,
+ SW_MAXIMIZE = 3,
+ SW_SHOWNOACTIVATE = 4,
+ SW_SHOW = 5,
+ SW_MINIMIZE = 6,
+ SW_SHOWMINNOACTIVE = 7,
+ SW_SHOWNA = 8,
+ SW_RESTORE = 9,
+ SW_SHOWDEFAULT = 10,
+ SW_FORCEMINIMIZE = 11,
+ SW_MAX = 11
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ private struct WINDOWPLACEMENT {
+ internal uint length;
+ internal uint flags;
+ internal WindowPlacementFlags showCmd;
+ internal POINT ptMinPosition;
+ internal POINT ptMaxPosition;
+ internal RECT rcNormalPosition;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct NCCALCSIZE_PARAMS {
+ internal RECT rgrc1;
+ internal RECT rgrc2;
+ internal RECT rgrc3;
+ internal IntPtr lppos;
+ }
+
+ [Flags]
+ private enum TMEFlags {
+ TME_HOVER = 0x00000001,
+ TME_LEAVE = 0x00000002,
+ TME_QUERY = unchecked((int)0x40000000),
+ TME_CANCEL = unchecked((int)0x80000000)
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ private struct TRACKMOUSEEVENT {
+ internal int size;
+ internal TMEFlags dwFlags;
+ internal IntPtr hWnd;
+ internal int dwHoverTime;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ private struct PAINTSTRUCT {
+ internal IntPtr hdc;
+ internal int fErase;
+ internal RECT rcPaint;
+ internal int fRestore;
+ internal int fIncUpdate;
+ internal int Reserved1;
+ internal int Reserved2;
+ internal int Reserved3;
+ internal int Reserved4;
+ internal int Reserved5;
+ internal int Reserved6;
+ internal int Reserved7;
+ internal int Reserved8;
+ }
+
+ internal enum ClassStyle {
+ CS_VREDRAW = 0x00000001,
+ CS_HREDRAW = 0x00000002,
+ CS_KEYCVTWINDOW = 0x00000004,
+ CS_DBLCLKS = 0x00000008,
+ CS_OWNDC = 0x00000020,
+ CS_CLASSDC = 0x00000040,
+ CS_PARENTDC = 0x00000080,
+ CS_NOKEYCVT = 0x00000100,
+ CS_NOCLOSE = 0x00000200,
+ CS_SAVEBITS = 0x00000800,
+ CS_BYTEALIGNCLIENT = 0x00001000,
+ CS_BYTEALIGNWINDOW = 0x00002000,
+ CS_GLOBALCLASS = 0x00004000,
+ CS_IME = 0x00010000
+ }
+
+ internal enum SetWindowPosZOrder {
+ HWND_TOP = 0,
+ HWND_BOTTOM = 1,
+ HWND_TOPMOST = -1,
+ HWND_NOTOPMOST = -2
+ }
+
+ [Flags]
+ internal enum SetWindowPosFlags {
+ SWP_ASYNCWINDOWPOS = 0x4000,
+ SWP_DEFERERASE = 0x2000,
+ SWP_DRAWFRAME = 0x0020,
+ SWP_FRAMECHANGED = 0x0020,
+ SWP_HIDEWINDOW = 0x0080,
+ SWP_NOACTIVATE = 0x0010,
+ SWP_NOCOPYBITS = 0x0100,
+ SWP_NOMOVE = 0x0002,
+ SWP_NOOWNERZORDER = 0x0200,
+ SWP_NOREDRAW = 0x0008,
+ SWP_NOREPOSITION = 0x0200,
+ SWP_NOENDSCHANGING = 0x0400,
+ SWP_NOSIZE = 0x0001,
+ SWP_NOZORDER = 0x0004,
+ SWP_SHOWWINDOW = 0x0040
+ }
+
+ internal 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 = 24,/* Maximum value */
+ }
+
+ private enum LoadCursorType {
+ First = 32512,
+ IDC_ARROW = 32512,
+ IDC_IBEAM = 32513,
+ IDC_WAIT = 32514,
+ IDC_CROSS = 32515,
+ IDC_UPARROW = 32516,
+ IDC_SIZE = 32640,
+ IDC_ICON = 32641,
+ IDC_SIZENWSE = 32642,
+ IDC_SIZENESW = 32643,
+ IDC_SIZEWE = 32644,
+ IDC_SIZENS = 32645,
+ IDC_SIZEALL = 32646,
+ IDC_NO = 32648,
+ IDC_HAND = 32649,
+ IDC_APPSTARTING = 32650,
+ IDC_HELP = 32651,
+ Last = 32651
+ }
+
+ [Flags]
+ private enum WindowLong {
+ GWL_WNDPROC = -4,
+ GWL_HINSTANCE = -6,
+ GWL_HWNDPARENT = -8,
+ GWL_STYLE = -16,
+ GWL_EXSTYLE = -20,
+ GWL_USERDATA = -21,
+ GWL_ID = -12
+ }
+
+ [Flags]
+ private enum LogBrushStyle {
+ BS_SOLID = 0,
+ BS_NULL = 1,
+ BS_HATCHED = 2,
+ BS_PATTERN = 3,
+ BS_INDEXED = 4,
+ BS_DIBPATTERN = 5,
+ BS_DIBPATTERNPT = 6,
+ BS_PATTERN8X8 = 7,
+ BS_DIBPATTERN8X8 = 8,
+ BS_MONOPATTERN = 9
+ }
+
+ [Flags]
+ private enum LogBrushHatch {
+ HS_HORIZONTAL = 0, /* ----- */
+ HS_VERTICAL = 1, /* ||||| */
+ HS_FDIAGONAL = 2, /* \\\\\ */
+ HS_BDIAGONAL = 3, /* ///// */
+ HS_CROSS = 4, /* +++++ */
+ HS_DIAGCROSS = 5, /* xxxxx */
+ }
+
+ internal struct COLORREF {
+ internal byte R;
+ internal byte G;
+ internal byte B;
+ internal byte A;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ private struct LOGBRUSH {
+ internal LogBrushStyle lbStyle;
+ internal COLORREF lbColor;
+ internal LogBrushHatch lbHatch;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct TEXTMETRIC {
+ internal int tmHeight;
+ internal int tmAscent;
+ internal int tmDescent;
+ internal int tmInternalLeading;
+ internal int tmExternalLeading;
+ internal int tmAveCharWidth;
+ internal int tmMaxCharWidth;
+ internal int tmWeight;
+ internal int tmOverhang;
+ internal int tmDigitizedAspectX;
+ internal int tmDigitizedAspectY;
+ internal short tmFirstChar;
+ internal short tmLastChar;
+ internal short tmDefaultChar;
+ internal short tmBreakChar;
+ internal byte tmItalic;
+ internal byte tmUnderlined;
+ internal byte tmStruckOut;
+ internal byte tmPitchAndFamily;
+ internal byte tmCharSet;
+ }
+
+ [Flags]
+ private enum ScrollWindowExFlags {
+ SW_NONE = 0x0000,
+ SW_SCROLLCHILDREN = 0x0001,
+ SW_INVALIDATE = 0x0002,
+ SW_ERASE = 0x0004,
+ SW_SMOOTHSCROLL = 0x0010
+ }
+
+ internal enum SystemMetrics {
+ SM_CXSCREEN = 0,
+ SM_CYSCREEN = 1,
+ SM_CXVSCROLL = 2,
+ SM_CYHSCROLL = 3,
+ SM_CYCAPTION = 4,
+ SM_CXBORDER = 5,
+ SM_CYBORDER = 6,
+ SM_CXDLGFRAME = 7,
+ SM_CYDLGFRAME = 8,
+ SM_CYVTHUMB = 9,
+ SM_CXHTHUMB = 10,
+ SM_CXICON = 11,
+ SM_CYICON = 12,
+ SM_CXCURSOR = 13,
+ SM_CYCURSOR = 14,
+ SM_CYMENU = 15,
+ SM_CXFULLSCREEN = 16,
+ SM_CYFULLSCREEN = 17,
+ SM_CYKANJIWINDOW = 18,
+ SM_MOUSEPRESENT = 19,
+ SM_CYVSCROLL = 20,
+ SM_CXHSCROLL = 21,
+ SM_DEBUG = 22,
+ SM_SWAPBUTTON = 23,
+ SM_RESERVED1 = 24,
+ SM_RESERVED2 = 25,
+ SM_RESERVED3 = 26,
+ SM_RESERVED4 = 27,
+ SM_CXMIN = 28,
+ SM_CYMIN = 29,
+ SM_CXSIZE = 30,
+ SM_CYSIZE = 31,
+ SM_CXFRAME = 32,
+ SM_CYFRAME = 33,
+ SM_CXMINTRACK = 34,
+ SM_CYMINTRACK = 35,
+ SM_CXDOUBLECLK = 36,
+ SM_CYDOUBLECLK = 37,
+ SM_CXICONSPACING = 38,
+ SM_CYICONSPACING = 39,
+ SM_MENUDROPALIGNMENT = 40,
+ SM_PENWINDOWS = 41,
+ SM_DBCSENABLED = 42,
+ SM_CMOUSEBUTTONS = 43,
+ SM_CXFIXEDFRAME = SM_CXDLGFRAME,
+ SM_CYFIXEDFRAME = SM_CYDLGFRAME,
+ SM_CXSIZEFRAME = SM_CXFRAME,
+ SM_CYSIZEFRAME = SM_CYFRAME,
+ SM_SECURE = 44,
+ SM_CXEDGE = 45,
+ SM_CYEDGE = 46,
+ SM_CXMINSPACING = 47,
+ SM_CYMINSPACING = 48,
+ SM_CXSMICON = 49,
+ SM_CYSMICON = 50,
+ SM_CYSMCAPTION = 51,
+ SM_CXSMSIZE = 52,
+ SM_CYSMSIZE = 53,
+ SM_CXMENUSIZE = 54,
+ SM_CYMENUSIZE = 55,
+ SM_ARRANGE = 56,
+ SM_CXMINIMIZED = 57,
+ SM_CYMINIMIZED = 58,
+ SM_CXMAXTRACK = 59,
+ SM_CYMAXTRACK = 60,
+ SM_CXMAXIMIZED = 61,
+ SM_CYMAXIMIZED = 62,
+ SM_NETWORK = 63,
+ SM_CLEANBOOT = 67,
+ SM_CXDRAG = 68,
+ SM_CYDRAG = 69,
+ SM_SHOWSOUNDS = 70,
+ SM_CXMENUCHECK = 71,
+ SM_CYMENUCHECK = 72,
+ SM_SLOWMACHINE = 73,
+ SM_MIDEASTENABLED = 74,
+ SM_MOUSEWHEELPRESENT = 75,
+ SM_XVIRTUALSCREEN = 76,
+ SM_YVIRTUALSCREEN = 77,
+ SM_CXVIRTUALSCREEN = 78,
+ SM_CYVIRTUALSCREEN = 79,
+ SM_CMONITORS = 80,
+ SM_SAMEDISPLAYFORMAT = 81,
+ SM_IMMENABLED = 82,
+ SM_CXFOCUSBORDER = 83,
+ SM_CYFOCUSBORDER = 84,
+ SM_TABLETPC = 86,
+ SM_MEDIACENTER = 87,
+ SM_CMETRICS = 88
+ }
+
+ // We'll only support _WIN32_IE < 0x0500 for now
+ internal enum NotifyIconMessage {
+ NIM_ADD = 0x00000000,
+ NIM_MODIFY = 0x00000001,
+ NIM_DELETE = 0x00000002,
+ }
+
+ [Flags]
+ internal enum NotifyIconFlags {
+ NIF_MESSAGE = 0x00000001,
+ NIF_ICON = 0x00000002,
+ NIF_TIP = 0x00000004,
+ }
+
+ [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
+ internal struct NOTIFYICONDATA {
+ internal uint cbSize;
+ internal IntPtr hWnd;
+ internal uint uID;
+ internal NotifyIconFlags uFlags;
+ internal uint uCallbackMessage;
+ internal IntPtr hIcon;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst=64)]
+ internal string szTip;
+ }
+
+ [Flags]
+ internal enum DCExFlags {
+ DCX_WINDOW = 0x00000001,
+ DCX_CACHE = 0x00000002,
+ DCX_NORESETATTRS = 0x00000004,
+ DCX_CLIPCHILDREN = 0x00000008,
+ DCX_CLIPSIBLINGS = 0x00000010,
+ DCX_PARENTCLIP = 0x00000020,
+ DCX_EXCLUDERGN = 0x00000040,
+ DCX_INTERSECTRGN = 0x00000080,
+ DCX_EXCLUDEUPDATE = 0x00000100,
+ DCX_INTERSECTUPDATE = 0x00000200,
+ DCX_LOCKWINDOWUPDATE = 0x00000400,
+ DCX_USESTYLE = 0x00010000,
+ DCX_VALIDATE = 0x00200000
+ }
+
+ [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
+ internal struct CLIENTCREATESTRUCT {
+ internal IntPtr hWindowMenu;
+ internal uint idFirstChild;
+ }
+
+ private enum ClassLong : int {
+ GCL_MENUNAME = -8,
+ GCL_HBRBACKGROUND = -10,
+ GCL_HCURSOR = -12,
+ GCL_HICON = -14,
+ GCL_HMODULE = -16,
+ GCL_CBWNDEXTRA = -18,
+ GCL_CBCLSEXTRA = -20,
+ GCL_WNDPROC = -24,
+ GCL_STYLE = -26,
+ GCW_ATOM = -32,
+ GCL_HICONSM = -34
+ }
+
+ [Flags]
+ internal enum GAllocFlags : uint {
+ GMEM_FIXED = 0x0000,
+ GMEM_MOVEABLE = 0x0002,
+ GMEM_NOCOMPACT = 0x0010,
+ GMEM_NODISCARD = 0x0020,
+ GMEM_ZEROINIT = 0x0040,
+ GMEM_MODIFY = 0x0080,
+ GMEM_DISCARDABLE = 0x0100,
+ GMEM_NOT_BANKED = 0x1000,
+ GMEM_SHARE = 0x2000,
+ GMEM_DDESHARE = 0x2000,
+ GMEM_NOTIFY = 0x4000,
+ GMEM_LOWER = GMEM_NOT_BANKED,
+ GMEM_VALID_FLAGS = 0x7F72,
+ GMEM_INVALID_HANDLE = 0x8000,
+ GHND = (GMEM_MOVEABLE | GMEM_ZEROINIT),
+ GPTR = (GMEM_FIXED | GMEM_ZEROINIT)
+ }
+
+ internal enum ROP2DrawMode : int {
+ R2_BLACK = 1,
+ R2_NOTMERGEPEN = 2,
+ R2_MASKNOTPEN = 3,
+ R2_NOTCOPYPEN = 4,
+ R2_MASKPENNOT = 5,
+ R2_NOT = 6,
+ R2_XORPEN = 7,
+ R2_NOTMASKPEN = 8,
+ R2_MASKPEN = 9,
+ R2_NOTXORPEN = 10,
+ R2_NOP = 11,
+ R2_MERGENOTPEN = 12,
+ R2_COPYPEN = 13,
+ R2_MERGEPENNOT = 14,
+ R2_MERGEPEN = 15,
+ R2_WHITE = 16,
+ R2_LAST = 16
+ }
+
+ internal enum PenStyle : int {
+ PS_SOLID = 0,
+ PS_DASH = 1,
+ PS_DOT = 2,
+ PS_DASHDOT = 3,
+ PS_DASHDOTDOT = 4,
+ PS_NULL = 5,
+ PS_INSIDEFRAME = 6,
+ PS_USERSTYLE = 7,
+ PS_ALTERNATE = 8
+ }
+
+ internal enum StockObject : int {
+ WHITE_BRUSH = 0,
+ LTGRAY_BRUSH = 1,
+ GRAY_BRUSH = 2,
+ DKGRAY_BRUSH = 3,
+ BLACK_BRUSH = 4,
+ NULL_BRUSH = 5,
+ HOLLOW_BRUSH = NULL_BRUSH,
+ WHITE_PEN = 6,
+ BLACK_PEN = 7,
+ NULL_PEN = 8,
+ OEM_FIXED_FONT = 10,
+ ANSI_FIXED_FONT = 11,
+ ANSI_VAR_FONT = 12,
+ SYSTEM_FONT = 13,
+ DEVICE_DEFAULT_FONT = 14,
+ DEFAULT_PALETTE = 15,
+ SYSTEM_FIXED_FONT = 16
+ }
+
+ internal enum HatchStyle : int {
+ HS_HORIZONTAL = 0,
+ HS_VERTICAL = 1,
+ HS_FDIAGONAL = 2,
+ HS_BDIAGONAL = 3,
+ HS_CROSS = 4,
+ HS_DIAGCROSS = 5
+ }
+
+ [Flags]
+ internal enum SndFlags : int {
+ SND_SYNC = 0x0000,
+ SND_ASYNC = 0x0001,
+ SND_NODEFAULT = 0x0002,
+ SND_MEMORY = 0x0004,
+ SND_LOOP = 0x0008,
+ SND_NOSTOP = 0x0010,
+ SND_NOWAIT = 0x00002000,
+ SND_ALIAS = 0x00010000,
+ SND_ALIAS_ID = 0x00110000,
+ SND_FILENAME = 0x00020000,
+ SND_RESOURCE = 0x00040004,
+ SND_PURGE = 0x0040,
+ SND_APPLICATION = 0x0080,
+ }
+
+ [Flags]
+ internal enum LayeredWindowAttributes : int {
+ LWA_COLORKEY = 0x1,
+ LWA_ALPHA = 0x2,
+ }
+
+
+ #endregion
+
+ #region Constructor & Destructor
+ private XplatUIWin32() {
+ WNDCLASS wndClass;
+ bool result;
+
+ // Handle singleton stuff first
+ ref_count=0;
+
+ DnD = new Win32DnD();
+
+ mouse_state = MouseButtons.None;
+ mouse_position = Point.Empty;
+
+ message_queue = new Queue();
+
+ themes_enabled = false;
+
+ // Prepare 'our' window class
+ wnd_proc = new WndProc(NativeWindow.WndProc);
+ wndClass.style = (int)(ClassStyle.CS_OWNDC | ClassStyle.CS_DBLCLKS);
+ wndClass.lpfnWndProc = wnd_proc;
+ wndClass.cbClsExtra = 0;
+ wndClass.cbWndExtra = 0;
+ wndClass.hbrBackground = IntPtr.Zero;
+ wndClass.hCursor = Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW);
+ wndClass.hIcon = IntPtr.Zero;
+ wndClass.hInstance = IntPtr.Zero;
+ wndClass.lpszClassName = XplatUI.DefaultClassName;
+ wndClass.lpszMenuName = "";
+
+ result=Win32RegisterClass(ref wndClass);
+ if (result==false) {
+ Win32MessageBox(IntPtr.Zero, "Could not register the "+XplatUI.DefaultClassName+" window class, win32 error " + Win32GetLastError().ToString(), "Oops", 0);
+ }
+
+ FosterParent=Win32CreateWindow((int)WindowExStyles.WS_EX_TOOLWINDOW, "static", "Foster Parent Window", (int)WindowStyles.WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
+
+ if (FosterParent==IntPtr.Zero) {
+ Win32MessageBox(IntPtr.Zero, "Could not create foster window, win32 error " + Win32GetLastError().ToString(), "Oops", 0);
+ }
+
+ timer_list = new Hashtable ();
+ }
+ #endregion // Constructor & Destructor
+
+ #region Private Support Methods
+ private static IntPtr DefWndProc(IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) {
+ return Win32DefWindowProc(hWnd, msg, wParam, lParam);
+ }
+
+ private static bool MessageWaiting {
+ get {
+ if (message_queue.Count == 0) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ private static bool RetrieveMessage(ref MSG msg) {
+ MSG message;
+
+ if (message_queue.Count == 0) {
+ return false;
+ }
+
+ message = (MSG)message_queue.Dequeue();
+ msg = message;
+
+ return true;
+ }
+
+ private static bool StoreMessage(ref MSG msg) {
+ MSG message = new MSG();
+
+ message = msg;
+ message_queue.Enqueue(message);
+
+ return true;
+ }
+
+ internal static String AnsiToString(IntPtr ansi_data) {
+ return (string)Marshal.PtrToStringAnsi(ansi_data);
+ }
+
+ internal static String UnicodeToString(IntPtr unicode_data) {
+ return (string)Marshal.PtrToStringUni(unicode_data);
+ }
+
+ internal static Image DIBtoImage(IntPtr dib_data) {
+ BITMAPINFOHEADER bmi;
+ int ncolors;
+ int imagesize;
+ int palettesize;
+ Bitmap bmp;
+ BitmapData bits;
+ ColorPalette pal;
+ int[] palette;
+ byte[] imagebits;
+ int bytesPerLine;
+
+ bmi = (BITMAPINFOHEADER)Marshal.PtrToStructure(dib_data, typeof(BITMAPINFOHEADER));
+
+ ncolors = (int)bmi.biClrUsed;
+ if (ncolors == 0) {
+ if (bmi.biBitCount < 24) {
+ ncolors = (int)(1 << bmi.biBitCount);
+ }
+ }
+ palettesize = ncolors * 4;
+
+ imagesize = (int)bmi.biSizeImage;
+ if (imagesize == 0) {
+ imagesize = (int)(((((bmi.biWidth * bmi.biBitCount) + 31) & ~31) >> 3) * bmi.biHeight);
+ }
+
+ switch(bmi.biBitCount) {
+ case 1: { // Monochrome
+ bmp = new Bitmap(bmi.biWidth, bmi.biHeight, PixelFormat.Format1bppIndexed);
+ palette = new int[2];
+ break;
+ }
+
+ case 4: { // 4bpp
+ bmp = new Bitmap(bmi.biWidth, bmi.biHeight, PixelFormat.Format4bppIndexed);
+ palette = new int[16];
+ break;
+ }
+
+ case 8: { // 8bpp
+ bmp = new Bitmap(bmi.biWidth, bmi.biHeight, PixelFormat.Format8bppIndexed);
+ palette = new int[256];
+ break;
+ }
+
+ case 24:
+ case 32: { // 32bpp
+ bmp = new Bitmap(bmi.biWidth, bmi.biHeight, PixelFormat.Format32bppArgb);
+ palette = new int[0];
+ break;
+ }
+
+ default: {
+ throw new Exception("Unexpected number of bits:" + bmi.biBitCount.ToString());
+ }
+ }
+
+ if (bmi.biBitCount < 24) {
+ pal = bmp.Palette; // Managed palette
+ Marshal.Copy((IntPtr)((int)dib_data + Marshal.SizeOf(typeof(BITMAPINFOHEADER))), palette, 0, palette.Length);
+
+ for (int i = 0; i < ncolors; i++) {
+ pal.Entries[i] = Color.FromArgb(palette[i] & unchecked((int)0xff000000));
+ }
+ }
+
+ bytesPerLine = (int)((((bmi.biWidth * bmi.biBitCount) + 31) & ~31) >> 3);
+ bits = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, bmp.PixelFormat);
+
+ imagebits = new byte[bytesPerLine];
+
+ for (int y = 0; y < bmi.biHeight; y++) {
+ // Copy from source to managed
+ Marshal.Copy((IntPtr)((int)dib_data + Marshal.SizeOf(typeof(BITMAPINFOHEADER)) + palette.Length * 4 + bytesPerLine * y), imagebits, 0, bytesPerLine);
+
+ // Copy from managed to dest
+ Marshal.Copy(imagebits, 0, (IntPtr)((int)bits.Scan0 + bits.Stride * (bmi.biHeight - 1 - y)), imagebits.Length);
+ }
+
+ bmp.UnlockBits(bits);
+
+ return bmp;
+ }
+
+ internal static byte[] ImageToDIB(Image image) {
+ MemoryStream ms;
+ byte[] buffer;
+ byte[] retbuf;
+
+ ms = new MemoryStream();
+ image.Save(ms, ImageFormat.Bmp);
+ buffer = ms.GetBuffer();
+
+ // Filter out the file header
+ retbuf = new byte[buffer.Length];
+ Array.Copy(buffer, 14, retbuf, 0, buffer.Length - 14);
+ return retbuf;
+ }
+
+ internal static IntPtr DupGlobalMem(IntPtr mem) {
+ IntPtr dup;
+ IntPtr dup_ptr;
+ IntPtr mem_ptr;
+ uint len;
+
+ len = Win32GlobalSize(mem);
+ mem_ptr = Win32GlobalLock(mem);
+
+ dup = Win32GlobalAlloc(GAllocFlags.GMEM_MOVEABLE, (int)len);
+ dup_ptr = Win32GlobalLock(dup);
+
+ Win32CopyMemory(dup_ptr, mem_ptr, (int)len);
+
+ Win32GlobalUnlock(mem);
+ Win32GlobalUnlock(dup);
+
+ return dup;
+ }
+ #endregion // Private Support Methods
+
+ #region Static Properties
+ internal override Keys ModifierKeys {
+ get {
+ short state;
+ Keys key_state;
+
+ key_state = Keys.None;
+
+ state = Win32GetKeyState(VirtualKeys.VK_SHIFT);
+ if ((state & 0x8000) != 0) {
+ key_state |= Keys.Shift;
+ }
+ state = Win32GetKeyState(VirtualKeys.VK_CONTROL);
+ if ((state & 0x8000) != 0) {
+ key_state |= Keys.Control;
+ }
+
+ state = Win32GetKeyState(VirtualKeys.VK_MENU);
+ if ((state & 0x8000) != 0) {
+ key_state |= Keys.Alt;
+ }
+
+ return key_state;
+ }
+ }
+
+ internal override MouseButtons MouseButtons {
+ get {
+ return mouse_state;
+ }
+ }
+
+ internal override Point MousePosition {
+ get {
+ return mouse_position;
+ }
+ }
+
+ internal override Size MouseHoverSize {
+ get {
+ int width = 4;
+ int height = 4;
+
+ Win32SystemParametersInfo(SPIAction.SPI_GETMOUSEHOVERWIDTH, 0, ref width, 0);
+ Win32SystemParametersInfo(SPIAction.SPI_GETMOUSEHOVERWIDTH, 0, ref height, 0);
+ return new Size(width, height);
+ }
+ }
+
+ internal override int MouseHoverTime {
+ get {
+ int time = 500;
+
+ Win32SystemParametersInfo(SPIAction.SPI_GETMOUSEHOVERTIME, 0, ref time, 0);
+ return time;
+ }
+ }
+
+
+ internal override bool DropTarget {
+ get {
+ return false;
+ }
+
+ set {
+ if (value) {
+ //throw new NotImplementedException("Need to figure out D'n'D for Win32");
+ }
+ }
+ }
+
+ internal override int Caption {
+ get {
+ return Win32GetSystemMetrics(SystemMetrics.SM_CYCAPTION);
+ }
+ }
+
+ internal override Size CursorSize {
+ get {
+ return new Size(Win32GetSystemMetrics(SystemMetrics.SM_CXCURSOR), Win32GetSystemMetrics(SystemMetrics.SM_CYCURSOR));
+ }
+ }
+
+ internal override bool DragFullWindows {
+ get {
+ return true;
+ }
+ }
+
+ internal override Size DragSize {
+ get {
+ return new Size(Win32GetSystemMetrics(SystemMetrics.SM_CXDRAG), Win32GetSystemMetrics(SystemMetrics.SM_CYDRAG));
+ }
+ }
+
+ internal override Size FrameBorderSize {
+ get {
+ return new Size(Win32GetSystemMetrics(SystemMetrics.SM_CXFRAME), Win32GetSystemMetrics(SystemMetrics.SM_CYFRAME));
+ }
+ }
+
+ internal override Size IconSize {
+ get {
+ return new Size(Win32GetSystemMetrics(SystemMetrics.SM_CXICON), Win32GetSystemMetrics(SystemMetrics.SM_CYICON));
+ }
+ }
+
+ internal override Size MaxWindowTrackSize {
+ get {
+ return new Size(Win32GetSystemMetrics(SystemMetrics.SM_CXMAXTRACK), Win32GetSystemMetrics(SystemMetrics.SM_CYMAXTRACK));
+ }
+ }
+
+ internal override Size MinimizedWindowSize {
+ get {
+ return new Size(Win32GetSystemMetrics(SystemMetrics.SM_CXMINIMIZED), Win32GetSystemMetrics(SystemMetrics.SM_CYMINIMIZED));
+ }
+ }
+
+ internal override Size MinimizedWindowSpacingSize {
+ get {
+ return new Size(Win32GetSystemMetrics(SystemMetrics.SM_CXMINSPACING), Win32GetSystemMetrics(SystemMetrics.SM_CYMINSPACING));
+ }
+ }
+
+ internal override Size MinimumWindowSize {
+ get {
+ return new Size(Win32GetSystemMetrics(SystemMetrics.SM_CXMIN), Win32GetSystemMetrics(SystemMetrics.SM_CYMIN));
+ }
+ }
+
+ internal override Size MinWindowTrackSize {
+ get {
+ return new Size(Win32GetSystemMetrics(SystemMetrics.SM_CXMINTRACK), Win32GetSystemMetrics(SystemMetrics.SM_CYMINTRACK));
+ }
+ }
+
+ internal override Size SmallIconSize {
+ get {
+ return new Size(Win32GetSystemMetrics(SystemMetrics.SM_CXSMICON), Win32GetSystemMetrics(SystemMetrics.SM_CYSMICON));
+ }
+ }
+
+ internal override int MouseButtonCount {
+ get {
+ return Win32GetSystemMetrics(SystemMetrics.SM_CMOUSEBUTTONS);
+ }
+ }
+
+ internal override bool MouseButtonsSwapped {
+ get {
+ return Win32GetSystemMetrics(SystemMetrics.SM_SWAPBUTTON) != 0;
+ }
+ }
+
+ internal override bool MouseWheelPresent {
+ get {
+ return Win32GetSystemMetrics(SystemMetrics.SM_MOUSEWHEELPRESENT) != 0;
+ }
+ }
+
+ internal override Rectangle VirtualScreen {
+ get {
+ return new Rectangle( Win32GetSystemMetrics(SystemMetrics.SM_XVIRTUALSCREEN), Win32GetSystemMetrics(SystemMetrics.SM_YVIRTUALSCREEN),
+ Win32GetSystemMetrics(SystemMetrics.SM_CXVIRTUALSCREEN), Win32GetSystemMetrics(SystemMetrics.SM_CYVIRTUALSCREEN));
+ }
+ }
+
+ internal override Rectangle WorkingArea {
+ get {
+ RECT rect;
+
+ rect = new RECT();
+ Win32SystemParametersInfo(SPIAction.SPI_GETWORKAREA, 0, ref rect, 0);
+ return new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
+ //return new Rectangle(0, 0, Win32GetSystemMetrics(SystemMetrics.SM.SM_CXSCREEN), Win32GetSystemMetrics(SystemMetrics.SM_CYSCREEN));
+ }
+ }
+ #endregion // Static Properties
+
+ #region Singleton Specific Code
+ public static XplatUIWin32 GetInstance() {
+ if (instance==null) {
+ instance=new XplatUIWin32();
+ }
+ ref_count++;
+ return instance;
+ }
+
+ public int Reference {
+ get {
+ return ref_count;
+ }
+ }
+ #endregion
+
+ #region Public Static Methods
+ internal override IntPtr InitializeDriver() {
+ return IntPtr.Zero;
+ }
+
+ internal override void ShutdownDriver(IntPtr token) {
+ Console.WriteLine("XplatUIWin32 ShutdownDriver called");
+ }
+
+
+ internal void Version() {
+ Console.WriteLine("Xplat version $revision: $");
+ }
+
+ internal override void AudibleAlert() {
+ Win32PlaySound("Default", IntPtr.Zero, SndFlags.SND_ALIAS | SndFlags.SND_ASYNC | SndFlags.SND_NOSTOP | SndFlags.SND_NOWAIT);
+ }
+
+ internal override void GetDisplaySize(out Size size) {
+ RECT rect;
+
+ Win32GetWindowRect(Win32GetDesktopWindow(), out rect);
+
+ size = new Size(rect.right - rect.left, rect.bottom - rect.top);
+ }
+
+ internal override void EnableThemes() {
+ themes_enabled=true;
+ }
+
+ internal override IntPtr CreateWindow(CreateParams cp) {
+ IntPtr WindowHandle;
+ IntPtr ParentHandle;
+ Hwnd hwnd;
+
+ hwnd = new Hwnd();
+
+ ParentHandle=cp.Parent;
+
+ if ((ParentHandle==IntPtr.Zero) && (cp.Style & (int)(WindowStyles.WS_CHILD))!=0) {
+ // We need to use our foster parent window until this poor child gets it's parent assigned
+ ParentHandle = FosterParent;
+ }
+
+ if ( ((cp.Style & (int)(WindowStyles.WS_CHILD | WindowStyles.WS_POPUP))==0) && ((cp.ExStyle & (int)WindowExStyles.WS_EX_APPWINDOW) == 0)) {
+ // If we want to be hidden from the taskbar we need to be 'owned' by
+ // something not on the taskbar. FosterParent is just that
+ ParentHandle = FosterParent;
+ }
+
+ // Since we fake MDI dont tell Windows that this is a real MDI window
+ if ((cp.ExStyle & (int) WindowExStyles.WS_EX_MDICHILD) != 0) {
+ SetMdiStyles (cp);
+ }
+
+ WindowHandle = Win32CreateWindow((uint)cp.ExStyle, cp.ClassName, cp.Caption, (uint)cp.Style, cp.X, cp.Y, cp.Width, cp.Height, ParentHandle, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
+
+ if (WindowHandle==IntPtr.Zero) {
+ uint error = Win32GetLastError();
+
+ Win32MessageBox(IntPtr.Zero, "Error : " + error.ToString(), "Failed to create window, class '"+cp.ClassName+"'", 0);
+ }
+
+ hwnd.ClientWindow = WindowHandle;
+
+ Win32SetWindowLong(WindowHandle, WindowLong.GWL_USERDATA, (uint)ThemeEngine.Current.DefaultControlBackColor.ToArgb());
+
+ return WindowHandle;
+ }
+
+ internal override IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
+ CreateParams create_params = new CreateParams();
+
+ create_params.Caption = "";
+ create_params.X = X;
+ create_params.Y = Y;
+ create_params.Width = Width;
+ create_params.Height = Height;
+
+ create_params.ClassName=XplatUI.DefaultClassName;
+ create_params.ClassStyle = 0;
+ create_params.ExStyle=0;
+ create_params.Parent=IntPtr.Zero;
+ create_params.Param=0;
+
+ return CreateWindow(create_params);
+ }
+
+ internal override void DestroyWindow(IntPtr handle) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+ Win32DestroyWindow(handle);
+ hwnd.Dispose();
+ return;
+ }
+
+ internal override void SetWindowMinMax(IntPtr handle, Rectangle maximized, Size min, Size max) {
+ // We do nothing, Form has to handle WM_GETMINMAXINFO
+ }
+
+
+ internal override FormWindowState GetWindowState(IntPtr handle) {
+ uint style;
+
+ style = Win32GetWindowLong(handle, WindowLong.GWL_STYLE);
+ if ((style & (uint)WindowStyles.WS_MAXIMIZE) != 0) {
+ return FormWindowState.Maximized;
+ } else if ((style & (uint)WindowStyles.WS_MINIMIZE) != 0) {
+ return FormWindowState.Minimized;
+ }
+ return FormWindowState.Normal;
+ }
+
+ internal override void SetWindowState(IntPtr hwnd, FormWindowState state) {
+ switch(state) {
+ case FormWindowState.Normal: {
+ Win32ShowWindow(hwnd, WindowPlacementFlags.SW_RESTORE);
+ return;
+ }
+
+ case FormWindowState.Minimized: {
+ Win32ShowWindow(hwnd, WindowPlacementFlags.SW_MINIMIZE);
+ return;
+ }
+
+ case FormWindowState.Maximized: {
+ Win32ShowWindow(hwnd, WindowPlacementFlags.SW_MAXIMIZE);
+ return;
+ }
+ }
+ }
+
+ internal override void SetWindowStyle(IntPtr handle, CreateParams cp) {
+
+ if ((cp.ExStyle & (int) WindowExStyles.WS_EX_MDICHILD) != 0) {
+ SetMdiStyles (cp);
+ }
+
+ Win32SetWindowLong(handle, WindowLong.GWL_STYLE, (uint)cp.Style);
+ Win32SetWindowLong(handle, WindowLong.GWL_EXSTYLE, (uint)cp.ExStyle);
+ }
+
+
+ internal override void SetWindowTransparency(IntPtr handle, double transparency, Color key) {
+ LayeredWindowAttributes lwa = LayeredWindowAttributes.LWA_ALPHA;
+ byte opacity = (byte)(transparency*255);
+ COLORREF clrRef = new COLORREF();
+ if (key != Color.Empty) {
+ clrRef.R = key.R;
+ clrRef.G = key.G;
+ clrRef.B = key.B;
+ lwa = (LayeredWindowAttributes)( (int)lwa | (int)LayeredWindowAttributes.LWA_COLORKEY );
+ }
+ RECT rc;
+ rc.right = 1000;
+ rc.bottom = 1000;
+ Win32SetLayeredWindowAttributes(handle, clrRef, opacity, lwa);
+ }
+
+ internal override bool SupportsTransparency() {
+ // We might check with the OS, but I think we're only >=W2k
+ return true;
+ }
+
+ internal override void UpdateWindow(IntPtr handle) {
+ Win32UpdateWindow(handle);
+ }
+
+ [MonoTODO("FIXME - Add support for internal table of windows/DCs for cleanup; handle client=false to draw in NC area")]
+ internal override PaintEventArgs PaintEventStart(IntPtr handle, bool client) {
+ IntPtr hdc;
+ PAINTSTRUCT ps;
+ PaintEventArgs paint_event;
+ RECT rect;
+ Rectangle clip_rect;
+ Hwnd hwnd;
+
+ clip_rect = new Rectangle();
+ rect = new RECT();
+ ps = new PAINTSTRUCT();
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ if (client) {
+ if (Win32GetUpdateRect(handle, ref rect, false)) {
+ hdc = Win32BeginPaint(handle, ref ps);
+
+ hwnd.user_data = (object)ps;
+
+ clip_rect = new Rectangle(ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right-ps.rcPaint.left, ps.rcPaint.bottom-ps.rcPaint.top);
+ } else {
+ hdc = Win32GetDC(handle);
+ // FIXME: Add the DC to internal list
+ clip_rect = new Rectangle(rect.top, rect.left, rect.right-rect.left, rect.bottom-rect.top);
+ }
+ } else {
+ hdc = Win32GetWindowDC (handle);
+ hwnd.user_data = (object)hdc;
+
+ // HACK this in for now
+ Win32GetWindowRect (handle, out rect);
+ clip_rect = new Rectangle(0, 0, rect.right-rect.left, rect.bottom-rect.top);
+ }
+
+ hwnd.client_dc = Graphics.FromHdc(hdc);
+ paint_event = new PaintEventArgs(hwnd.client_dc, clip_rect);
+
+ return paint_event;
+ }
+
+ internal override void PaintEventEnd(IntPtr handle, bool client) {
+ Hwnd hwnd;
+ PAINTSTRUCT ps;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+ hwnd.client_dc.Dispose();
+
+ if (client) {
+ if (hwnd.user_data != null) {
+ ps = (PAINTSTRUCT)hwnd.user_data;
+ Win32EndPaint(handle, ref ps);
+ hwnd.user_data = null;
+ }
+ } else {
+ if (hwnd.user_data != null) {
+ Win32ReleaseDC(handle, (IntPtr)hwnd.user_data);
+ hwnd.user_data = null;
+ }
+ }
+ }
+
+
+ internal override void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
+ Win32MoveWindow(handle, x, y, width, height, true);
+ return;
+ }
+
+ internal override void GetWindowPos(IntPtr handle, bool is_toplevel, out int x, out int y, out int width, out int height, out int client_width, out int client_height) {
+ IntPtr parent;
+ RECT rect;
+ POINT pt;
+
+ Win32GetWindowRect(handle, out rect);
+ width = rect.right - rect.left;
+ height = rect.bottom - rect.top;
+
+ pt.x=rect.left;
+ pt.y=rect.top;
+
+ parent = Win32GetParent(handle);
+ if (parent == FosterParent) {
+ Win32ScreenToClient(IntPtr.Zero, ref pt);
+ } else {
+ Win32ScreenToClient(parent, ref pt);
+ }
+
+ x = pt.x;
+ y = pt.y;
+
+ Win32GetClientRect(handle, out rect);
+ client_width = rect.right - rect.left;
+ client_height = rect.bottom - rect.top;
+ return;
+ }
+
+ internal override void Activate(IntPtr handle) {
+ Win32SetActiveWindow(handle);
+ }
+
+ internal override void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
+ RECT rect;
+
+ rect.left=rc.Left;
+ rect.top=rc.Top;
+ rect.right=rc.Right;
+ rect.bottom=rc.Bottom;
+ Win32InvalidateRect(handle, ref rect, clear);
+ }
+
+ internal override IntPtr DefWndProc(ref Message msg) {
+ msg.Result=Win32DefWindowProc(msg.HWnd, (Msg)msg.Msg, msg.WParam, msg.LParam);
+ return msg.Result;
+ }
+
+ internal override void HandleException(Exception e) {
+ StackTrace st = new StackTrace(e);
+ Win32MessageBox(IntPtr.Zero, e.Message+st.ToString(), "Exception", 0);
+ Console.WriteLine("{0}{1}", e.Message, st.ToString());
+ }
+
+ internal override void DoEvents() {
+ MSG msg = new MSG();
+
+ if (override_cursor != IntPtr.Zero) {
+ Cursor.Current = null;
+ }
+
+ while (GetMessage(ref msg, IntPtr.Zero, 0, 0, false)) {
+ XplatUI.TranslateMessage(ref msg);
+ XplatUI.DispatchMessage(ref msg);
+ }
+ }
+
+ internal override bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
+ return Win32PeekMessage(ref msg, hWnd, wFilterMin, wFilterMax, flags);
+ }
+
+ internal override void PostQuitMessage(int exitCode) {
+ Win32PostQuitMessage(exitCode);
+ }
+
+ internal override void RequestNCRecalc(IntPtr handle) {
+ Win32SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0, SetWindowPosFlags.SWP_FRAMECHANGED | SetWindowPosFlags.SWP_NOOWNERZORDER | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOMOVE);
+ }
+
+ internal override void ResetMouseHover(IntPtr handle) {
+ TRACKMOUSEEVENT tme;
+
+ tme = new TRACKMOUSEEVENT();
+ tme.size = Marshal.SizeOf(tme);
+ tme.hWnd = handle;
+ tme.dwFlags = TMEFlags.TME_LEAVE | TMEFlags.TME_HOVER;
+ Win32TrackMouseEvent(ref tme);
+ }
+
+
+ internal override bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
+ return GetMessage(ref msg, hWnd, wFilterMin, wFilterMax, true);
+ }
+
+ private bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, bool blocking) {
+ bool result;
+
+ if (RetrieveMessage(ref msg)) {
+ return true;
+ }
+
+ if (blocking) {
+ result = Win32GetMessage(ref msg, hWnd, wFilterMin, wFilterMax);
+ } else {
+ result = Win32PeekMessage(ref msg, hWnd, wFilterMin, wFilterMax, (uint)PeekMessageFlags.PM_REMOVE);
+ if (!result) {
+ return false;
+ }
+ }
+
+ // We need to fake WM_MOUSE_ENTER/WM_MOUSE_LEAVE
+ switch (msg.message) {
+ case Msg.WM_LBUTTONDOWN: {
+ mouse_state |= MouseButtons.Left;
+ break;
+ }
+
+ case Msg.WM_MBUTTONDOWN: {
+ mouse_state |= MouseButtons.Middle;
+ break;
+ }
+
+ case Msg.WM_RBUTTONDOWN: {
+ mouse_state |= MouseButtons.Right;
+ break;
+ }
+
+ case Msg.WM_LBUTTONUP: {
+ mouse_state &= ~MouseButtons.Left;
+ break;
+ }
+
+ case Msg.WM_MBUTTONUP: {
+ mouse_state &= ~MouseButtons.Middle;
+ break;
+ }
+
+ case Msg.WM_RBUTTONUP: {
+ mouse_state &= ~MouseButtons.Right;
+ break;
+ }
+
+ case Msg.WM_ASYNC_MESSAGE: {
+ XplatUIDriverSupport.ExecuteClientMessage((GCHandle)msg.lParam);
+ break;
+ }
+
+ case Msg.WM_MOUSEMOVE: {
+ if (msg.hwnd != prev_mouse_hwnd) {
+ TRACKMOUSEEVENT tme;
+
+ // The current message will be sent out next time around
+ StoreMessage(ref msg);
+
+ // This is the message we want to send at this point
+ msg.message = Msg.WM_MOUSE_ENTER;
+
+ prev_mouse_hwnd = msg.hwnd;
+
+ tme = new TRACKMOUSEEVENT();
+ tme.size = Marshal.SizeOf(tme);
+ tme.hWnd = msg.hwnd;
+ tme.dwFlags = TMEFlags.TME_LEAVE | TMEFlags.TME_HOVER;
+ Win32TrackMouseEvent(ref tme);
+ return result;
+ }
+ break;
+ }
+
+ case Msg.WM_DROPFILES: {
+ return Win32DnD.HandleWMDropFiles(ref msg);
+ }
+
+ case Msg.WM_MOUSELEAVE: {
+ prev_mouse_hwnd = IntPtr.Zero;
+ msg.message=Msg.WM_MOUSE_LEAVE;
+ break;
+ }
+
+ case Msg.WM_TIMER: {
+ Timer timer=(Timer)timer_list[(int)msg.wParam];
+
+ if (timer != null) {
+ timer.FireTick();
+ }
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ internal override bool TranslateMessage(ref MSG msg) {
+ return Win32TranslateMessage(ref msg);
+ }
+
+ internal override IntPtr DispatchMessage(ref MSG msg) {
+ return Win32DispatchMessage(ref msg);
+ }
+
+ internal override bool SetZOrder(IntPtr hWnd, IntPtr AfterhWnd, bool Top, bool Bottom) {
+ if (Top) {
+ Win32SetWindowPos(hWnd, SetWindowPosZOrder.HWND_TOP, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE);
+ return true;
+ } else if (!Bottom) {
+ Win32SetWindowPos(hWnd, AfterhWnd, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE);
+ } else {
+ Win32SetWindowPos(hWnd, (IntPtr)SetWindowPosZOrder.HWND_BOTTOM, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE);
+ return true;
+ }
+ return false;
+ }
+
+ internal override bool SetTopmost(IntPtr hWnd, IntPtr hWndOwner, bool Enabled) {
+ if (Enabled) {
+ Win32SetWindowPos(hWnd, SetWindowPosZOrder.HWND_TOPMOST, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE);
+ return true;
+ } else {
+ Win32SetWindowPos(hWnd, SetWindowPosZOrder.HWND_NOTOPMOST, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE);
+ return true;
+ }
+ }
+
+ internal override bool Text(IntPtr handle, string text) {
+ Win32SetWindowText(handle, text);
+ return true;
+ }
+
+ internal override bool GetText(IntPtr handle, out string text) {
+ StringBuilder sb;
+
+ sb = new StringBuilder(256);
+ Win32GetWindowText(handle, sb, sb.Capacity);
+ text = sb.ToString();
+ return true;
+ }
+
+ internal override bool SetVisible(IntPtr handle, bool visible) {
+ if (visible) {
+ if (Control.FromHandle(handle) is Form) {
+ Form f;
+
+ f = (Form)Control.FromHandle(handle);
+ switch (f.WindowState) {
+ case FormWindowState.Normal: Win32ShowWindow(handle, WindowPlacementFlags.SW_SHOWNORMAL); break;
+ case FormWindowState.Minimized: Win32ShowWindow(handle, WindowPlacementFlags.SW_MINIMIZE); break;
+ case FormWindowState.Maximized: Win32ShowWindow(handle, WindowPlacementFlags.SW_MAXIMIZE); break;
+ }
+ } else {
+ Win32ShowWindow(handle, WindowPlacementFlags.SW_SHOWNORMAL);
+ }
+ } else {
+ Win32ShowWindow(handle, WindowPlacementFlags.SW_HIDE);
+ }
+ return true;
+ }
+
+ internal override bool IsEnabled(IntPtr handle) {
+ return IsWindowEnabled (handle);
+ }
+
+ internal override bool IsVisible(IntPtr handle) {
+ return IsWindowVisible (handle);
+ }
+
+ internal override IntPtr SetParent(IntPtr handle, IntPtr parent) {
+ return Win32SetParent(handle, parent);
+ }
+
+ internal override IntPtr GetParent(IntPtr handle) {
+ return Win32GetParent(handle);
+ }
+
+ internal override void GrabWindow(IntPtr hWnd, IntPtr ConfineToHwnd) {
+ grab_hwnd = hWnd;
+ Win32SetCapture(hWnd);
+ }
+
+ internal override void GrabInfo(out IntPtr hWnd, out bool GrabConfined, out Rectangle GrabArea) {
+ hWnd = grab_hwnd;
+ GrabConfined = grab_confined;
+ GrabArea = grab_area;
+ }
+
+ internal override void UngrabWindow(IntPtr hWnd) {
+ Win32ReleaseCapture();
+ grab_hwnd = IntPtr.Zero;
+ }
+
+ internal override bool CalculateWindowRect(ref Rectangle ClientRect, int Style, int ExStyle, Menu menu, out Rectangle WindowRect) {
+ RECT rect;
+
+ rect.left=ClientRect.Left;
+ rect.top=ClientRect.Top;
+ rect.right=ClientRect.Right;
+ rect.bottom=ClientRect.Bottom;
+
+ if (!Win32AdjustWindowRectEx(ref rect, Style, menu != null, ExStyle)) {
+ WindowRect = new Rectangle(ClientRect.Left, ClientRect.Top, ClientRect.Width, ClientRect.Height);
+ return false;
+ }
+
+ WindowRect = new Rectangle(rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top);
+ return true;
+ }
+
+ internal override void SetCursor(IntPtr window, IntPtr cursor) {
+ Win32SetCursor(cursor);
+ return;
+ }
+
+ internal override void ShowCursor(bool show) {
+ Win32ShowCursor(show);
+ }
+
+ internal override void OverrideCursor(IntPtr cursor) {
+ Win32SetCursor(cursor);
+ }
+
+ internal override IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
+ IntPtr cursor;
+ Bitmap cursor_bitmap;
+ Bitmap cursor_mask;
+ Byte[] cursor_bits;
+ Byte[] mask_bits;
+ Color pixel;
+ int width;
+ int height;
+
+ // Win32 only allows creation cursors of a certain size
+ if ((bitmap.Width != Win32GetSystemMetrics(SystemMetrics.SM_CXCURSOR)) || (bitmap.Width != Win32GetSystemMetrics(SystemMetrics.SM_CXCURSOR))) {
+ cursor_bitmap = new Bitmap(bitmap, new Size(Win32GetSystemMetrics(SystemMetrics.SM_CXCURSOR), Win32GetSystemMetrics(SystemMetrics.SM_CXCURSOR)));
+ cursor_mask = new Bitmap(mask, new Size(Win32GetSystemMetrics(SystemMetrics.SM_CXCURSOR), Win32GetSystemMetrics(SystemMetrics.SM_CXCURSOR)));
+ } else {
+ cursor_bitmap = bitmap;
+ cursor_mask = mask;
+ }
+
+ width = cursor_bitmap.Width;
+ height = cursor_bitmap.Height;
+
+ cursor_bits = new Byte[(width / 8) * height];
+ mask_bits = new Byte[(width / 8) * height];
+
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ pixel = cursor_bitmap.GetPixel(x, y);
+
+ if (pixel == cursor_pixel) {
+ cursor_bits[y * width / 8 + x / 8] |= (byte)(0x80 >> (x % 8));
+ }
+
+ pixel = cursor_mask.GetPixel(x, y);
+
+ if (pixel == mask_pixel) {
+ mask_bits[y * width / 8 + x / 8] |= (byte)(0x80 >> (x % 8));
+ }
+ }
+ }
+
+ cursor = Win32CreateCursor(IntPtr.Zero, xHotSpot, yHotSpot, width, height, mask_bits, cursor_bits);
+
+ return cursor;
+ }
+
+ [MonoTODO("Define the missing cursors")]
+ internal override IntPtr DefineStdCursor(StdCursor id) {
+ switch(id) {
+ case StdCursor.AppStarting: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_APPSTARTING);
+ case StdCursor.Arrow: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW);
+ case StdCursor.Cross: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_CROSS);
+ case StdCursor.Default: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW);
+ case StdCursor.Hand: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_HAND);
+ case StdCursor.Help: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_HELP);
+ case StdCursor.HSplit: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.IBeam: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_IBEAM);
+ case StdCursor.No: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_NO);
+ case StdCursor.NoMove2D: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.NoMoveHoriz: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.NoMoveVert: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.PanEast: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.PanNE: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.PanNorth: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.PanNW: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.PanSE: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.PanSouth: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.PanSW: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.PanWest: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.SizeAll: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_SIZEALL);
+ case StdCursor.SizeNESW: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_SIZENESW);
+ case StdCursor.SizeNS: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_SIZENS);
+ case StdCursor.SizeNWSE: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_SIZENWSE);
+ case StdCursor.SizeWE: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_SIZEWE);
+ case StdCursor.UpArrow: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_UPARROW);
+ case StdCursor.VSplit: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.WaitCursor: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_WAIT);
+ }
+ throw new NotImplementedException ();
+ }
+
+ internal override void DestroyCursor(IntPtr cursor) {
+ if ((cursor.ToInt32() < (int)LoadCursorType.First) || (cursor.ToInt32() > (int)LoadCursorType.Last)) {
+ Win32DestroyCursor(cursor);
+ }
+ }
+
+ [MonoTODO]
+ internal override void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
+ throw new NotImplementedException ();
+ }
+
+ internal override void SetCursorPos(IntPtr handle, int x, int y) {
+ Win32SetCursorPos(x, y);
+ }
+
+ internal override void EnableWindow(IntPtr handle, bool Enable) {
+ Win32EnableWindow(handle, Enable);
+ }
+
+ internal override void EndLoop(System.Threading.Thread thread) {
+ // Nothing to do
+ }
+
+ internal override void StartLoop(System.Threading.Thread thread) {
+ // Nothing to do
+ }
+
+ internal override void SetModal(IntPtr handle, bool Modal) {
+ // we do nothing on Win32
+ }
+
+ internal override void GetCursorPos(IntPtr handle, out int x, out int y) {
+ POINT pt;
+
+ Win32GetCursorPos(out pt);
+
+ if (handle!=IntPtr.Zero) {
+ Win32ScreenToClient(handle, ref pt);
+ }
+
+ x=pt.x;
+ y=pt.y;
+ }
+
+ internal override void ScreenToClient(IntPtr handle, ref int x, ref int y)
+ {
+ POINT pnt = new POINT();
+
+ pnt.x = x;
+ pnt.y = y;
+ Win32ScreenToClient (handle, ref pnt);
+
+ x = pnt.x;
+ y = pnt.y;
+ }
+
+ internal override void ClientToScreen(IntPtr handle, ref int x, ref int y) {
+ POINT pnt = new POINT();
+
+ pnt.x = x;
+ pnt.y = y;
+
+ Win32ClientToScreen(handle, ref pnt);
+
+ x = pnt.x;
+ y = pnt.y;
+ }
+
+ internal override void ScreenToMenu(IntPtr handle, ref int x, ref int y) {
+ RECT rect;
+
+ Win32GetWindowRect(handle, out rect);
+ x -= rect.left + SystemInformation.FrameBorderSize.Width;
+ y -= rect.top + SystemInformation.FrameBorderSize.Height + ThemeEngine.Current.CaptionHeight;
+ return;
+ }
+
+ internal override void MenuToScreen(IntPtr handle, ref int x, ref int y) {
+ RECT rect;
+
+ Win32GetWindowRect(handle, out rect);
+ x += rect.left + SystemInformation.FrameBorderSize.Width;
+ y += rect.top + SystemInformation.FrameBorderSize.Height + ThemeEngine.Current.CaptionHeight;
+ return;
+ }
+
+ internal override void SendAsyncMethod (AsyncMethodData method)
+ {
+ Win32PostMessage(FosterParent, Msg.WM_ASYNC_MESSAGE, IntPtr.Zero, (IntPtr)GCHandle.Alloc (method));
+ }
+
+ internal override void SetTimer (Timer timer)
+ {
+ int index;
+
+ index = timer.GetHashCode();
+
+ lock (timer_list) {
+ timer_list[index]=timer;
+ }
+
+ Win32SetTimer(FosterParent, index, (uint)timer.Interval, IntPtr.Zero);
+ }
+
+ internal override void KillTimer (Timer timer)
+ {
+ int index;
+
+ index = timer.GetHashCode();
+
+ Win32KillTimer(FosterParent, index);
+
+ lock (timer_list) {
+ timer_list.Remove(index);
+ }
+ }
+
+
+ private void CaretCallback(object sender, EventArgs e) {
+ Console.WriteLine("CaretCallback hit");
+ }
+
+ private void SetMdiStyles (CreateParams cp)
+ {
+ cp.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
+ cp.ExStyle = 0;
+ }
+
+ internal override void CreateCaret(IntPtr hwnd, int width, int height) {
+ Win32CreateCaret(hwnd, IntPtr.Zero, width, height);
+ caret_visible = false;
+ }
+
+ internal override void DestroyCaret(IntPtr hwnd) {
+ Win32DestroyCaret();
+ }
+
+ internal override void SetCaretPos(IntPtr hwnd, int x, int y) {
+ Win32SetCaretPos(x, y);
+ }
+
+ internal override void CaretVisible(IntPtr hwnd, bool visible) {
+ if (visible) {
+ if (!caret_visible) {
+ Win32ShowCaret(hwnd);
+ caret_visible = true;
+ }
+ } else {
+ if (caret_visible) {
+ Win32HideCaret(hwnd);
+ caret_visible = false;
+ }
+ }
+ }
+
+ internal override void SetFocus(IntPtr hwnd) {
+ Win32SetFocus(hwnd);
+ }
+
+ internal override IntPtr GetActive() {
+ return Win32GetActiveWindow();
+ }
+
+ internal override bool GetFontMetrics(Graphics g, Font font, out int ascent, out int descent) {
+ IntPtr dc;
+ TEXTMETRIC tm;
+
+ tm = new TEXTMETRIC();
+
+ dc = Win32GetDC(IntPtr.Zero);
+ Win32SelectObject(dc, font.ToHfont());
+ if (Win32GetTextMetrics(dc, ref tm) == false) {
+ Win32ReleaseDC(IntPtr.Zero, dc);
+ ascent = 0;
+ descent = 0;
+ return false;
+ }
+ Win32ReleaseDC(IntPtr.Zero, dc);
+
+ ascent = tm.tmAscent;
+ descent = tm.tmDescent;
+
+ return true;
+ }
+
+ internal override void ScrollWindow(IntPtr hwnd, Rectangle rectangle, int XAmount, int YAmount, bool with_children) {
+ RECT rect;
+
+ rect = new RECT();
+ rect.left = rectangle.X;
+ rect.top = rectangle.Y;
+ rect.right = rectangle.Right;
+ rect.bottom = rectangle.Bottom;
+
+ Win32ScrollWindowEx(hwnd, XAmount, YAmount, ref rect, ref rect, IntPtr.Zero, IntPtr.Zero, ScrollWindowExFlags.SW_INVALIDATE | ScrollWindowExFlags.SW_ERASE | (with_children ? ScrollWindowExFlags.SW_SCROLLCHILDREN : ScrollWindowExFlags.SW_NONE));
+ Win32UpdateWindow(hwnd);
+ }
+
+ internal override void ScrollWindow(IntPtr hwnd, int XAmount, int YAmount, bool with_children) {
+ Win32ScrollWindowEx(hwnd, XAmount, YAmount, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, ScrollWindowExFlags.SW_INVALIDATE | ScrollWindowExFlags.SW_ERASE | (with_children ? ScrollWindowExFlags.SW_SCROLLCHILDREN : ScrollWindowExFlags.SW_NONE));
+ }
+
+ internal override bool SystrayAdd(IntPtr hwnd, string tip, Icon icon, out ToolTip tt) {
+ NOTIFYICONDATA nid;
+
+ nid = new NOTIFYICONDATA();
+
+ nid.cbSize = (uint)Marshal.SizeOf(nid);
+ nid.hWnd = hwnd;
+ nid.uID = 1;
+ nid.uCallbackMessage = (uint)Msg.WM_USER;
+ nid.uFlags = NotifyIconFlags.NIF_MESSAGE;
+
+ if (tip != null) {
+ nid.szTip = tip;
+ nid.uFlags |= NotifyIconFlags.NIF_TIP;
+ }
+
+ if (icon != null) {
+ nid.hIcon = icon.Handle;
+ nid.uFlags |= NotifyIconFlags.NIF_ICON;
+ }
+
+ tt = null;
+
+ return Win32Shell_NotifyIcon(NotifyIconMessage.NIM_ADD, ref nid);
+ }
+
+ internal override bool SystrayChange(IntPtr hwnd, string tip, Icon icon, ref ToolTip tt) {
+ NOTIFYICONDATA nid;
+
+ nid = new NOTIFYICONDATA();
+
+ nid.cbSize = (uint)Marshal.SizeOf(nid);
+ nid.hIcon = icon.Handle;
+ nid.hWnd = hwnd;
+ nid.uID = 1;
+ nid.uCallbackMessage = (uint)Msg.WM_USER;
+ nid.uFlags = NotifyIconFlags.NIF_MESSAGE;
+
+ if (tip != null) {
+ nid.szTip = tip;
+ nid.uFlags |= NotifyIconFlags.NIF_TIP;
+ }
+
+ if (icon != null) {
+ nid.hIcon = icon.Handle;
+ nid.uFlags |= NotifyIconFlags.NIF_ICON;
+ }
+
+ return Win32Shell_NotifyIcon(NotifyIconMessage.NIM_MODIFY, ref nid);
+ }
+
+ internal override void SystrayRemove(IntPtr hwnd, ref ToolTip tt) {
+ NOTIFYICONDATA nid;
+
+ nid = new NOTIFYICONDATA();
+
+ nid.cbSize = (uint)Marshal.SizeOf(nid);
+ nid.hWnd = hwnd;
+ nid.uID = 1;
+ nid.uFlags = 0;
+
+ Win32Shell_NotifyIcon(NotifyIconMessage.NIM_DELETE, ref nid);
+ }
+
+
+ internal override void SetBorderStyle(IntPtr handle, FormBorderStyle border_style) {
+ uint style;
+ uint exstyle;
+
+ style = Win32GetWindowLong(handle, WindowLong.GWL_STYLE);
+ exstyle = Win32GetWindowLong(handle, WindowLong.GWL_EXSTYLE);
+
+ switch (border_style) {
+ case FormBorderStyle.None: {
+ style &= ~(uint)WindowStyles.WS_BORDER;
+ exstyle &= ~(uint)WindowExStyles.WS_EX_CLIENTEDGE;
+ break;
+ }
+
+ case FormBorderStyle.FixedSingle: {
+ style |= (uint)WindowStyles.WS_BORDER;
+ exstyle &= ~(uint)WindowExStyles.WS_EX_CLIENTEDGE;
+ break;
+ }
+
+ case FormBorderStyle.Fixed3D: {
+ style |= (uint)WindowStyles.WS_BORDER;
+ exstyle |= (uint)WindowExStyles.WS_EX_CLIENTEDGE;
+ break;
+ }
+ }
+
+ Win32SetWindowLong(handle, WindowLong.GWL_STYLE, style);
+ Win32SetWindowLong(handle, WindowLong.GWL_EXSTYLE, exstyle);
+
+ Win32SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0,
+ SetWindowPosFlags.SWP_FRAMECHANGED | SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOACTIVATE);
+ }
+
+ internal override void SetMenu(IntPtr handle, Menu menu) {
+ // Trigger WM_NCCALC
+ Win32SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0, SetWindowPosFlags.SWP_FRAMECHANGED | SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE);
+ }
+
+
+ internal override Point GetMenuOrigin(IntPtr handle) {
+ return new Point(SystemInformation.FrameBorderSize.Width, SystemInformation.FrameBorderSize.Height + ThemeEngine.Current.CaptionHeight);
+ }
+
+ internal override void SetIcon(IntPtr hwnd, Icon icon) {
+ Win32SendMessage(hwnd, Msg.WM_SETICON, (IntPtr)1, icon.Handle); // 1 = large icon (0 would be small)
+ }
+
+ internal override void ClipboardClose(IntPtr handle) {
+ if (handle != clip_magic) {
+ throw new ArgumentException("handle is not a valid clipboard handle");
+ }
+ Win32CloseClipboard();
+ }
+
+ internal override int ClipboardGetID(IntPtr handle, string format) {
+ if (handle != clip_magic) {
+ throw new ArgumentException("handle is not a valid clipboard handle");
+ }
+ if (format == "Text" ) return 1;
+ else if (format == "Bitmap" ) return 2;
+ else if (format == "MetaFilePict" ) return 3;
+ else if (format == "SymbolicLink" ) return 4;
+ else if (format == "DataInterchangeFormat" ) return 5;
+ else if (format == "Tiff" ) return 6;
+ else if (format == "OEMText" ) return 7;
+ else if (format == "DeviceIndependentBitmap" ) return 8;
+ else if (format == "Palette" ) return 9;
+ else if (format == "PenData" ) return 10;
+ else if (format == "RiffAudio" ) return 11;
+ else if (format == "WaveAudio" ) return 12;
+ else if (format == "UnicodeText" ) return 13;
+ else if (format == "EnhancedMetafile" ) return 14;
+ else if (format == "FileDrop" ) return 15;
+ else if (format == "Locale" ) return 16;
+
+ return (int)Win32RegisterClipboardFormat(format);
+ }
+
+ internal override IntPtr ClipboardOpen() {
+ Win32OpenClipboard(FosterParent);
+ return clip_magic;
+ }
+
+ internal override int[] ClipboardAvailableFormats(IntPtr handle) {
+ uint format;
+ int[] result;
+ int count;
+
+ if (handle != clip_magic) {
+ return null;
+ }
+
+ // Count first
+ count = 0;
+ format = 0;
+ do {
+ format = Win32EnumClipboardFormats(format);
+ if (format != 0) {
+ count++;
+ }
+ } while (format != 0);
+
+ // Now assign
+ result = new int[count];
+ count = 0;
+ format = 0;
+ do {
+ format = Win32EnumClipboardFormats(format);
+ if (format != 0) {
+ result[count++] = (int)format;
+ }
+ } while (format != 0);
+
+ return result;
+ }
+
+
+ internal override object ClipboardRetrieve(IntPtr handle, int type, XplatUI.ClipboardToObject converter) {
+ IntPtr hmem;
+ IntPtr data;
+ object obj;
+
+ if (handle != clip_magic) {
+ throw new ArgumentException("handle is not a valid clipboard handle");
+ }
+
+ hmem = Win32GetClipboardData((uint)type);
+ if (hmem == IntPtr.Zero) {
+ return null;
+ }
+
+ data = Win32GlobalLock(hmem);
+ if (data == IntPtr.Zero) {
+ uint error = Win32GetLastError();
+ Console.WriteLine("Error: {0}", error);
+ return null;
+ }
+
+ obj = null;
+
+ if (type == DataFormats.GetFormat(DataFormats.Rtf).Id) {
+ obj = AnsiToString(data);
+ } else switch ((ClipboardFormats)type) {
+ case ClipboardFormats.CF_TEXT: {
+ obj = AnsiToString(data);
+ break;
+ }
+
+ case ClipboardFormats.CF_DIB: {
+ obj = DIBtoImage(data);
+ break;
+ }
+
+ case ClipboardFormats.CF_UNICODETEXT: {
+ obj = UnicodeToString(data);
+ break;
+ }
+
+ default: {
+ if (converter != null && !converter(type, data, out obj)) {
+ obj = null;
+ }
+ break;
+ }
+ }
+ Win32GlobalUnlock(hmem);
+
+ return obj;
+
+ }
+
+ internal override void ClipboardStore(IntPtr handle, object obj, int type, XplatUI.ObjectToClipboard converter) {
+ byte[] data;
+ IntPtr hmem;
+ IntPtr hmem_ptr;
+
+ if (handle != clip_magic) {
+ throw new ArgumentException("handle is not a valid clipboard handle");
+ }
+
+ if (obj == null) {
+ // Just clear it
+ Win32EmptyClipboard();
+ return;
+ }
+
+ if (type == -1) {
+ if (obj is string) {
+ type = (int)ClipboardFormats.CF_UNICODETEXT;
+ } else if (obj is Image) {
+ type = (int)ClipboardFormats.CF_DIB;
+ }
+ }
+
+ if (type == DataFormats.GetFormat(DataFormats.Rtf).Id) {
+ hmem = Marshal.StringToHGlobalAnsi((string)obj);
+ Win32SetClipboardData((uint)type, hmem);
+ return;
+ } else switch((ClipboardFormats)type) {
+ case ClipboardFormats.CF_UNICODETEXT: {
+ hmem = Marshal.StringToHGlobalUni((string)obj);
+ Win32SetClipboardData((uint)type, hmem);
+ return;
+ }
+
+ case ClipboardFormats.CF_TEXT: {
+ hmem = Marshal.StringToHGlobalAnsi((string)obj);
+ Win32SetClipboardData((uint)type, hmem);
+ return;
+ }
+
+ case ClipboardFormats.CF_BITMAP:
+ case ClipboardFormats.CF_DIB: {
+ data = ImageToDIB((Image)obj);
+
+ hmem = Win32GlobalAlloc(GAllocFlags.GMEM_MOVEABLE | GAllocFlags.GMEM_DDESHARE, data.Length);
+ hmem_ptr = Win32GlobalLock(hmem);
+ Marshal.Copy(data, 0, hmem_ptr, data.Length);
+ Win32GlobalUnlock(hmem);
+ Win32SetClipboardData((uint)ClipboardFormats.CF_DIB, hmem);
+ return;
+ }
+
+ default: {
+ if (converter != null && converter(ref type, obj, out data)) {
+ hmem = Win32GlobalAlloc(GAllocFlags.GMEM_MOVEABLE | GAllocFlags.GMEM_DDESHARE, data.Length);
+ hmem_ptr = Win32GlobalLock(hmem);
+ Marshal.Copy(data, 0, hmem_ptr, data.Length);
+ Win32GlobalUnlock(hmem);
+ Win32SetClipboardData((uint)type, hmem);
+ }
+ return;
+ }
+ }
+ }
+
+ internal override void SetAllowDrop(IntPtr hwnd, bool allowed) {
+ if (allowed) {
+ Win32DnD.RegisterDropTarget(hwnd);
+ } else {
+ Win32DnD.UnregisterDropTarget(hwnd);
+ }
+ }
+
+ internal override DragDropEffects StartDrag(IntPtr hwnd, object data, DragDropEffects allowedEffects) {
+ return Win32DnD.StartDrag(hwnd, data, allowedEffects);
+ }
+
+ internal override void DrawReversibleRectangle(IntPtr handle, Rectangle rect, int line_width) {
+ IntPtr hdc;
+ IntPtr pen;
+ IntPtr oldpen;
+ POINT pt;
+
+ pt = new POINT();
+ pt.x = 0;
+ pt.y = 0;
+ Win32ClientToScreen(handle, ref pt);
+
+ // If we want the standard hatch pattern we would
+ // need to create a brush
+
+ // Grab a pen
+ pen = Win32CreatePen(PenStyle.PS_SOLID, line_width, IntPtr.Zero);
+
+ hdc = Win32GetDC(IntPtr.Zero);
+ Win32SetROP2(hdc, ROP2DrawMode.R2_NOT);
+ oldpen = Win32SelectObject(hdc, pen);
+
+ // We might need to add clipping to the WindowRect of 'handle' - right now we're drawing on the desktop
+
+ Win32MoveToEx(hdc, pt.x + rect.Left, pt.y + rect.Top, IntPtr.Zero);
+ if ((rect.Width > 0) && (rect.Height > 0)) {
+ Win32LineTo(hdc, pt.x + rect.Right, pt.y + rect.Top);
+ Win32LineTo(hdc, pt.x + rect.Right, pt.y + rect.Bottom);
+ Win32LineTo(hdc, pt.x + rect.Left, pt.y + rect.Bottom);
+ Win32LineTo(hdc, pt.x + rect.Left, pt.y + rect.Top);
+ } else {
+ if (rect.Width > 0) {
+ Win32LineTo(hdc, pt.x + rect.Right, pt.y + rect.Top);
+ } else {
+ Win32LineTo(hdc, pt.x + rect.Left, pt.y + rect.Bottom);
+ }
+ }
+
+ Win32SelectObject(hdc, oldpen);
+ Win32DeleteObject(pen);
+ Win32ReleaseDC(IntPtr.Zero, hdc);
+ }
+
+ internal override SizeF GetAutoScaleSize(Font font) {
+ Graphics g;
+ float width;
+ string magic_string = "The quick brown fox jumped over the lazy dog.";
+ double magic_number = 44.549996948242189;
+
+ g = Graphics.FromHwnd(FosterParent);
+
+ width = (float) (g.MeasureString (magic_string, font).Width / magic_number);
+ return new SizeF(width, font.Height);
+ }
+
+ internal override IntPtr SendMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) {
+ return Win32SendMessage(hwnd, message, wParam, lParam);
+ }
+
+ internal override bool PostMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) {
+ return Win32PostMessage(hwnd, message, wParam, lParam);
+ }
+
+ internal override int KeyboardSpeed {
+ get {
+ Console.WriteLine ("KeyboardSpeed: need to query Windows");
+
+ //
+ // Return values range from 0 to 31 which map to 2.5 to 30 repetitions per second.
+ //
+ return 0;
+ }
+ }
+
+ internal override int KeyboardDelay {
+ get {
+ Console.WriteLine ("KeyboardDelay: need to query Windows");
+
+ //
+ // Return values must range from 0 to 4, 0 meaning 250ms,
+ // and 4 meaning 1000 ms.
+ //
+ return 1;
+ }
+ }
+
+ internal override event EventHandler Idle;
+
+ // Santa's little helper
+ static void Where() {
+ Console.WriteLine("Here: {0}", new StackTrace().ToString());
+ }
+ #endregion // Public Static Methods
+
+ #region Win32 Imports
+ [DllImport ("kernel32.dll", EntryPoint="GetLastError", CallingConvention=CallingConvention.StdCall)]
+ private extern static uint Win32GetLastError();
+
+ [DllImport ("user32.dll", EntryPoint="CreateWindowExW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ internal extern static IntPtr Win32CreateWindow(uint dwExStyle, string lpClassName, string lpWindowName, uint dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lParam);
+
+ [DllImport ("user32.dll", EntryPoint="DestroyWindow", CallingConvention=CallingConvention.StdCall)]
+ internal extern static bool Win32DestroyWindow(IntPtr hWnd);
+
+ [DllImport ("user32.dll", EntryPoint="PeekMessageW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ internal extern static bool Win32PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags);
+
+ [DllImport ("user32.dll", EntryPoint="GetMessageW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ internal extern static bool Win32GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax);
+
+ [DllImport ("user32.dll", EntryPoint="TranslateMessage", CallingConvention=CallingConvention.StdCall)]
+ internal extern static bool Win32TranslateMessage(ref MSG msg);
+
+ [DllImport ("user32.dll", EntryPoint="DispatchMessageW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ internal extern static IntPtr Win32DispatchMessage(ref MSG msg);
+
+ [DllImport ("user32.dll", EntryPoint="MoveWindow", CallingConvention=CallingConvention.StdCall)]
+ internal extern static bool Win32MoveWindow(IntPtr hWnd, int x, int y, int width, int height, bool repaint);
+
+ [DllImport ("user32.dll", EntryPoint="SetWindowPos", CallingConvention=CallingConvention.StdCall)]
+ internal extern static bool Win32SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, SetWindowPosFlags Flags);
+
+ [DllImport ("user32.dll", EntryPoint="SetWindowPos", CallingConvention=CallingConvention.StdCall)]
+ internal extern static bool Win32SetWindowPos(IntPtr hWnd, SetWindowPosZOrder pos, int x, int y, int cx, int cy, SetWindowPosFlags Flags);
+
+ [DllImport ("user32.dll", EntryPoint="SetWindowTextW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ internal extern static bool Win32SetWindowText(IntPtr hWnd, string lpString);
+
+ [DllImport ("user32.dll", EntryPoint="GetWindowTextW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ internal extern static bool Win32GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
+
+ [DllImport ("user32.dll", EntryPoint="SetParent", CallingConvention=CallingConvention.StdCall)]
+ internal extern static IntPtr Win32SetParent(IntPtr hWnd, IntPtr hParent);
+
+ [DllImport ("user32.dll", EntryPoint="RegisterClassW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32RegisterClass(ref WNDCLASS wndClass);
+
+ [DllImport ("user32.dll", EntryPoint="LoadCursorW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32LoadCursor(IntPtr hInstance, LoadCursorType type);
+
+ [DllImport ("user32.dll", EntryPoint="ShowCursor", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32ShowCursor(bool bShow);
+
+ [DllImport ("user32.dll", EntryPoint="SetCursor", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32SetCursor(IntPtr hCursor);
+
+ [DllImport ("user32.dll", EntryPoint="CreateCursor", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32CreateCursor(IntPtr hInstance, int xHotSpot, int yHotSpot, int nWidth, int nHeight, Byte[] pvANDPlane, Byte[] pvORPlane);
+
+ [DllImport ("user32.dll", EntryPoint="DestroyCursor", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32DestroyCursor(IntPtr hCursor);
+
+ [DllImport ("user32.dll", EntryPoint="DefWindowProcW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32DefWindowProc(IntPtr hWnd, Msg Msg, IntPtr wParam, IntPtr lParam);
+
+ [DllImport ("user32.dll", EntryPoint="DefDlgProcW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32DefDlgProc(IntPtr hWnd, Msg Msg, IntPtr wParam, IntPtr lParam);
+
+ [DllImport ("user32.dll", EntryPoint="PostQuitMessage", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32PostQuitMessage(int nExitCode);
+
+ [DllImport ("user32.dll", EntryPoint="UpdateWindow", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32UpdateWindow(IntPtr hWnd);
+
+ [DllImport ("user32.dll", EntryPoint="GetUpdateRect", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32GetUpdateRect(IntPtr hWnd, ref RECT rect, bool erase);
+
+ [DllImport ("user32.dll", EntryPoint="BeginPaint", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32BeginPaint(IntPtr hWnd, ref PAINTSTRUCT ps);
+
+ [DllImport ("user32.dll", EntryPoint="EndPaint", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32EndPaint(IntPtr hWnd, ref PAINTSTRUCT ps);
+
+ [DllImport ("user32.dll", EntryPoint="GetDC", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32GetDC(IntPtr hWnd);
+
+ [DllImport ("user32.dll", EntryPoint="GetWindowDC", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32GetWindowDC(IntPtr hWnd);
+
+ [DllImport ("user32.dll", EntryPoint="GetDCEx", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32GetDCEx(IntPtr hWnd, IntPtr hRgn, DCExFlags flags);
+
+ [DllImport ("user32.dll", EntryPoint="ReleaseDC", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32ReleaseDC(IntPtr hWnd, IntPtr hDC);
+
+ [DllImport ("user32.dll", EntryPoint="MessageBoxW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32MessageBox(IntPtr hParent, string pText, string pCaption, uint uType);
+
+ [DllImport ("user32.dll", EntryPoint="InvalidateRect", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32InvalidateRect(IntPtr hWnd, ref RECT lpRect, bool bErase);
+
+ [DllImport ("user32.dll", EntryPoint="InvalidateRect", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32InvalidateRect(IntPtr hWnd, IntPtr lpRect, bool bErase);
+
+ [DllImport ("user32.dll", EntryPoint="SetCapture", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32SetCapture(IntPtr hWnd);
+
+ [DllImport ("user32.dll", EntryPoint="ReleaseCapture", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32ReleaseCapture();
+
+ [DllImport ("user32.dll", EntryPoint="GetWindowRect", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32GetWindowRect(IntPtr hWnd, out RECT rect);
+
+ [DllImport ("user32.dll", EntryPoint="GetClientRect", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32GetClientRect(IntPtr hWnd, out RECT rect);
+
+ [DllImport ("user32.dll", EntryPoint="ScreenToClient", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32ScreenToClient(IntPtr hWnd, ref POINT pt);
+
+ [DllImport ("user32.dll", EntryPoint="ClientToScreen", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32ClientToScreen(IntPtr hWnd, ref POINT pt);
+
+ [DllImport ("user32.dll", EntryPoint="GetParent", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32GetParent(IntPtr hWnd);
+
+ [DllImport ("user32.dll", EntryPoint="SetActiveWindow", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32SetActiveWindow(IntPtr hWnd);
+
+ [DllImport ("user32.dll", EntryPoint="AdjustWindowRectEx", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32AdjustWindowRectEx(ref RECT lpRect, int dwStyle, bool bMenu, int dwExStyle);
+
+ [DllImport ("user32.dll", EntryPoint="GetCursorPos", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32GetCursorPos(out POINT lpPoint);
+
+ [DllImport ("user32.dll", EntryPoint="SetCursorPos", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32SetCursorPos(int x, int y);
+
+ [DllImport ("user32.dll", EntryPoint="GetWindowPlacement", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl);
+
+ [DllImport ("user32.dll", EntryPoint="TrackMouseEvent", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32TrackMouseEvent(ref TRACKMOUSEEVENT tme);
+
+ [DllImport ("gdi32.dll", EntryPoint="CreateBrushIndirect", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32CreateBrushIndirect(ref LOGBRUSH lb);
+
+ [DllImport ("user32.dll", EntryPoint="FillRect", CallingConvention=CallingConvention.StdCall)]
+ private extern static int Win32FillRect(IntPtr hdc, ref RECT rect, IntPtr hbr);
+
+ [DllImport ("user32.dll", EntryPoint="SetWindowLong", CallingConvention=CallingConvention.StdCall)]
+ private extern static uint Win32SetWindowLong(IntPtr hwnd, WindowLong index, uint value);
+
+ [DllImport ("user32.dll", EntryPoint="GetWindowLong", CallingConvention=CallingConvention.StdCall)]
+ private extern static uint Win32GetWindowLong(IntPtr hwnd, WindowLong index);
+
+ [DllImport ("user32.dll", EntryPoint="SetLayeredWindowAttributes", CallingConvention=CallingConvention.StdCall)]
+ private extern static uint Win32SetLayeredWindowAttributes (IntPtr hwnd, COLORREF crKey, byte bAlpha, LayeredWindowAttributes dwFlags);
+
+ [DllImport ("gdi32.dll", EntryPoint="DeleteObject", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32DeleteObject(IntPtr o);
+
+ [DllImport ("user32.dll", EntryPoint="GetKeyState", CallingConvention=CallingConvention.StdCall)]
+ private extern static short Win32GetKeyState(VirtualKeys nVirtKey);
+
+ [DllImport ("user32.dll", EntryPoint="GetDesktopWindow", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32GetDesktopWindow();
+
+ [DllImport ("user32.dll", EntryPoint="SetTimer", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32SetTimer(IntPtr hwnd, int nIDEvent, uint uElapse, IntPtr timerProc);
+
+ [DllImport ("user32.dll", EntryPoint="KillTimer", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32KillTimer(IntPtr hwnd, int nIDEvent);
+
+ [DllImport ("user32.dll", EntryPoint="ShowWindow", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32ShowWindow(IntPtr hwnd, WindowPlacementFlags nCmdShow);
+
+ [DllImport ("user32.dll", EntryPoint="EnableWindow", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32EnableWindow(IntPtr hwnd, bool Enabled);
+
+ [DllImport ("user32.dll", EntryPoint="SetFocus", CallingConvention=CallingConvention.StdCall)]
+ internal extern static IntPtr Win32SetFocus(IntPtr hwnd);
+
+ [DllImport ("user32.dll", EntryPoint="CreateCaret", CallingConvention=CallingConvention.StdCall)]
+ internal extern static bool Win32CreateCaret(IntPtr hwnd, IntPtr hBitmap, int nWidth, int nHeight);
+
+ [DllImport ("user32.dll", EntryPoint="DestroyCaret", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32DestroyCaret();
+
+ [DllImport ("user32.dll", EntryPoint="ShowCaret", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32ShowCaret(IntPtr hwnd);
+
+ [DllImport ("user32.dll", EntryPoint="HideCaret", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32HideCaret(IntPtr hwnd);
+
+ [DllImport ("user32.dll", EntryPoint="SetCaretPos", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32SetCaretPos(int X, int Y);
+
+ [DllImport ("user32.dll", EntryPoint="GetCaretBlinkTime", CallingConvention=CallingConvention.StdCall)]
+ private extern static uint Win32GetCaretBlinkTime();
+
+ [DllImport ("gdi32.dll", EntryPoint="GetTextMetricsW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ internal extern static bool Win32GetTextMetrics(IntPtr hdc, ref TEXTMETRIC tm);
+
+ [DllImport ("gdi32.dll", EntryPoint="SelectObject", CallingConvention=CallingConvention.StdCall)]
+ internal extern static IntPtr Win32SelectObject(IntPtr hdc, IntPtr hgdiobject);
+
+ [DllImport ("user32.dll", EntryPoint="ScrollWindowEx", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32ScrollWindowEx(IntPtr hwnd, int dx, int dy, ref RECT prcScroll, ref RECT prcClip, IntPtr hrgnUpdate, out RECT prcUpdate, ScrollWindowExFlags flags);
+
+ [DllImport ("user32.dll", EntryPoint="ScrollWindowEx", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32ScrollWindowEx(IntPtr hwnd, int dx, int dy, ref RECT prcScroll, ref RECT prcClip, IntPtr hrgnUpdate, IntPtr prcUpdate, ScrollWindowExFlags flags);
+
+ [DllImport ("user32.dll", EntryPoint="ScrollWindowEx", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32ScrollWindowEx(IntPtr hwnd, int dx, int dy, ref RECT prcScroll, IntPtr prcClip, IntPtr hrgnUpdate, IntPtr prcUpdate, ScrollWindowExFlags flags);
+
+ [DllImport ("user32.dll", EntryPoint="ScrollWindowEx", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32ScrollWindowEx(IntPtr hwnd, int dx, int dy, IntPtr prcScroll, IntPtr prcClip, IntPtr hrgnUpdate, IntPtr prcUpdate, ScrollWindowExFlags flags);
+
+ [DllImport ("user32.dll", EntryPoint="GetActiveWindow", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32GetActiveWindow();
+
+ [DllImport ("user32.dll", EntryPoint="GetSystemMetrics", CallingConvention=CallingConvention.StdCall)]
+ private extern static int Win32GetSystemMetrics(SystemMetrics nIndex);
+
+ [DllImport ("shell32.dll", EntryPoint="Shell_NotifyIconW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32Shell_NotifyIcon(NotifyIconMessage dwMessage, ref NOTIFYICONDATA lpData);
+
+ [DllImport ("gdi32.dll", EntryPoint="CreateRectRgn", CallingConvention=CallingConvention.StdCall)]
+ internal extern static IntPtr Win32CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
+
+ [DllImport ("user32.dll", EntryPoint="IsWindowEnabled", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool IsWindowEnabled(IntPtr hwnd);
+
+ [DllImport ("user32.dll", EntryPoint="IsWindowVisible", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool IsWindowVisible(IntPtr hwnd);
+
+ [DllImport ("user32.dll", EntryPoint="SetClassLong", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32SetClassLong(IntPtr hwnd, ClassLong nIndex, IntPtr dwNewLong);
+
+ [DllImport ("user32.dll", EntryPoint="SendMessageW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32SendMessage(IntPtr hwnd, Msg msg, IntPtr wParam, IntPtr lParam);
+
+ [DllImport ("user32.dll", EntryPoint="PostMessageW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32PostMessage(IntPtr hwnd, Msg msg, IntPtr wParam, IntPtr lParam);
+
+ [DllImport ("user32.dll", EntryPoint="SystemParametersInfoW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32SystemParametersInfo(SPIAction uiAction, uint uiParam, ref RECT rect, uint fWinIni);
+
+ [DllImport ("user32.dll", EntryPoint="SystemParametersInfoW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32SystemParametersInfo(SPIAction uiAction, uint uiParam, ref uint value, uint fWinIni);
+
+ [DllImport ("user32.dll", EntryPoint="SystemParametersInfoW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32SystemParametersInfo(SPIAction uiAction, uint uiParam, ref int value, uint fWinIni);
+
+ [DllImport ("user32.dll", EntryPoint="OpenClipboard", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32OpenClipboard(IntPtr hwnd);
+
+ [DllImport ("user32.dll", EntryPoint="EmptyClipboard", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32EmptyClipboard();
+
+ [DllImport ("user32.dll", EntryPoint="RegisterClipboardFormatW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
+ private extern static uint Win32RegisterClipboardFormat(string format);
+
+ [DllImport ("user32.dll", EntryPoint="CloseClipboard", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32CloseClipboard();
+
+ [DllImport ("user32.dll", EntryPoint="EnumClipboardFormats", CallingConvention=CallingConvention.StdCall)]
+ private extern static uint Win32EnumClipboardFormats(uint format);
+
+ [DllImport ("user32.dll", EntryPoint="GetClipboardData", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32GetClipboardData(uint format);
+
+ [DllImport ("user32.dll", EntryPoint="SetClipboardData", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32SetClipboardData(uint format, IntPtr handle);
+
+ [DllImport ("kernel32.dll", EntryPoint="GlobalAlloc", CallingConvention=CallingConvention.StdCall)]
+ internal extern static IntPtr Win32GlobalAlloc(GAllocFlags Flags, int dwBytes);
+
+ [DllImport ("kernel32.dll", EntryPoint="CopyMemory", CallingConvention=CallingConvention.StdCall)]
+ internal extern static void Win32CopyMemory(IntPtr Destination, IntPtr Source, int length);
+
+ [DllImport ("kernel32.dll", EntryPoint="GlobalFree", CallingConvention=CallingConvention.StdCall)]
+ internal extern static IntPtr Win32GlobalFree(IntPtr hMem);
+
+ [DllImport ("kernel32.dll", EntryPoint="GlobalSize", CallingConvention=CallingConvention.StdCall)]
+ internal extern static uint Win32GlobalSize(IntPtr hMem);
+
+ [DllImport ("kernel32.dll", EntryPoint="GlobalLock", CallingConvention=CallingConvention.StdCall)]
+ internal extern static IntPtr Win32GlobalLock(IntPtr hMem);
+
+ [DllImport ("kernel32.dll", EntryPoint="GlobalUnlock", CallingConvention=CallingConvention.StdCall)]
+ internal extern static IntPtr Win32GlobalUnlock(IntPtr hMem);
+
+ [DllImport ("gdi32.dll", EntryPoint="SetROP2", CallingConvention=CallingConvention.StdCall)]
+ internal extern static int Win32SetROP2(IntPtr hdc, ROP2DrawMode fnDrawMode);
+
+ [DllImport ("gdi32.dll", EntryPoint="MoveToEx", CallingConvention=CallingConvention.StdCall)]
+ internal extern static bool Win32MoveToEx(IntPtr hdc, int x, int y, ref POINT lpPoint);
+
+ [DllImport ("gdi32.dll", EntryPoint="MoveToEx", CallingConvention=CallingConvention.StdCall)]
+ internal extern static bool Win32MoveToEx(IntPtr hdc, int x, int y, IntPtr lpPoint);
+
+ [DllImport ("gdi32.dll", EntryPoint="LineTo", CallingConvention=CallingConvention.StdCall)]
+ internal extern static bool Win32LineTo(IntPtr hdc, int x, int y);
+
+ [DllImport ("gdi32.dll", EntryPoint="CreatePen", CallingConvention=CallingConvention.StdCall)]
+ internal extern static IntPtr Win32CreatePen(PenStyle fnPenStyle, int nWidth, ref COLORREF color);
+
+ [DllImport ("gdi32.dll", EntryPoint="CreatePen", CallingConvention=CallingConvention.StdCall)]
+ internal extern static IntPtr Win32CreatePen(PenStyle fnPenStyle, int nWidth, IntPtr color);
+
+ [DllImport ("gdi32.dll", EntryPoint="GetStockObject", CallingConvention=CallingConvention.StdCall)]
+ internal extern static IntPtr Win32GetStockObject(StockObject fnObject);
+
+ [DllImport ("gdi32.dll", EntryPoint="CreateHatchBrush", CallingConvention=CallingConvention.StdCall)]
+ internal extern static IntPtr Win32CreateHatchBrush(HatchStyle fnStyle, IntPtr color);
+
+ [DllImport ("gdi32.dll", EntryPoint="CreateHatchBrush", CallingConvention=CallingConvention.StdCall)]
+ internal extern static IntPtr Win32CreateHatchBrush(HatchStyle fnStyle, ref COLORREF color);
+
+ [DllImport ("winmm.dll", EntryPoint="PlaySoundW", CallingConvention=CallingConvention.StdCall, CharSet=CharSet.Unicode)]
+ internal extern static IntPtr Win32PlaySound(string pszSound, IntPtr hmod, SndFlags fdwSound);
+ #endregion
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
new file mode 100644
index 00000000000..1746db0aca3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
@@ -0,0 +1,4581 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+// NOTE:
+// This driver understands the following environment variables: (Set the var to enable feature)
+//
+// MONO_XEXCEPTIONS = throw an exception when a X11 error is encountered;
+// by default a message is displayed but execution continues
+//
+// MONO_XSYNC = perform all X11 commands synchronous; this is slower but
+// helps in debugging errors
+//
+
+// NOT COMPLETE
+
+// define to log Window handles and relationships to stdout
+#undef DriverDebug
+
+// Extra detailed debug
+#undef DriverDebugExtra
+#undef DriverDebugParent
+#undef DriverDebugCreate
+#undef DriverDebugDestroy
+
+using System;
+using System.ComponentModel;
+using System.Collections;
+using System.Diagnostics;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading;
+
+// Only do the poll when building with mono for now
+#if __MonoCS__
+using Mono.Unix.Native;
+#endif
+
+/// X11 Version
+namespace System.Windows.Forms {
+ internal class XplatUIX11 : XplatUIDriver {
+ #region Local Variables
+ // General
+ static volatile XplatUIX11 Instance;
+ private static int RefCount;
+ private static object XlibLock; // Our locking object
+ private static bool ThemesEnabled;
+
+ // General X11
+ private static IntPtr DisplayHandle; // X11 handle to display
+ private static int ScreenNo; // Screen number used
+ private static IntPtr DefaultColormap; // Colormap for screen
+ private static IntPtr CustomVisual; // Visual for window creation
+ private static IntPtr CustomColormap; // Colormap for window creation
+ private static IntPtr RootWindow; // Handle of the root window for the screen/display
+ private static IntPtr FosterParent; // Container to hold child windows until their parent exists
+ private static XErrorHandler ErrorHandler; // Error handler delegate
+ private static bool ErrorExceptions; // Throw exceptions on X errors
+ private static bool PostQuitState; // True if we've got an pending exit
+
+ // Clipboard
+ private static IntPtr ClipMagic = new IntPtr(27051977);
+ private static ClipboardStruct Clipboard; // Our clipboard
+
+ // Communication
+ private static IntPtr PostAtom; // PostMessage atom
+ private static IntPtr AsyncAtom; // Support for async messages
+
+ // Message Loop
+ private static XEventQueue MessageQueue; // Holds our queued up events
+ #if __MonoCS__ //
+ private static Pollfd[] pollfds; // For watching the X11 socket
+ #endif //
+ private static X11Keyboard Keyboard; //
+ private static X11Dnd Dnd;
+ private static Socket listen; //
+ private static Socket wake; //
+ private static Socket wake_receive; //
+ private static byte[] network_buffer; //
+
+
+ // Focus tracking
+ private static IntPtr ActiveWindow; // Handle of the active window
+ private static IntPtr FocusWindow; // Handle of the window with keyboard focus (if any)
+
+ // Modality support
+ private static Stack ModalWindows; // Stack of our modal windows
+
+ // Systray
+ private static IntPtr SystrayMgrWindow; // Handle of the Systray Manager window
+
+ // Cursors
+ private static IntPtr LastCursorWindow; // The last window we set the cursor on
+ private static IntPtr LastCursorHandle; // The handle that was last set on LastCursorWindow
+ private static IntPtr OverrideCursorHandle; // The cursor that is set to override any other cursors
+
+ // Caret
+ private static CaretStruct Caret; //
+
+ // Support for Window Styles
+ private static IntPtr[] NetAtoms; // All atoms we know
+
+ // mouse hover message generation
+ private static HoverStruct HoverState; //
+
+ // double click message generation
+ private static ClickStruct ClickPending; //
+
+ // Support for mouse grab
+ private static GrabStruct Grab; //
+
+ // State
+ private static Point MousePosition; // Last position of mouse, in screen coords
+ internal static MouseButtons MouseState; // Last state of mouse buttons
+
+ // Timers
+ private static ArrayList TimerList; // Holds SWF.Timers
+
+ // 'Constants'
+ private static int DoubleClickInterval; // msec; max interval between clicks to count as double click
+
+ const EventMask SelectInputMask = EventMask.ButtonPressMask |
+ EventMask.ButtonReleaseMask |
+ EventMask.KeyPressMask |
+ EventMask.KeyReleaseMask |
+ EventMask.EnterWindowMask |
+ EventMask.LeaveWindowMask |
+ EventMask.ExposureMask |
+ EventMask.FocusChangeMask |
+ EventMask.PointerMotionMask |
+ EventMask.VisibilityChangeMask |
+ EventMask.SubstructureNotifyMask |
+ EventMask.StructureNotifyMask;
+
+ static readonly object lockobj = new object ();
+
+ #endregion // Local Variables
+ #region Constructors
+ private XplatUIX11() {
+ // Handle singleton stuff first
+ RefCount = 0;
+
+ // Now regular initialization
+ XlibLock = new object ();
+ MessageQueue = new XEventQueue ();
+ TimerList = new ArrayList ();
+ XInitThreads();
+
+ ErrorExceptions = false;
+
+ // X11 Initialization
+ SetDisplay(XOpenDisplay(IntPtr.Zero));
+ X11DesktopColors.Initialize();
+
+ // Handle any upcoming errors; we re-set it here, X11DesktopColor stuff might have stolen it (gtk does)
+ ErrorHandler = new XErrorHandler(HandleError);
+ XSetErrorHandler(ErrorHandler);
+ }
+ #endregion // Constructors
+
+ #region Singleton Specific Code
+ public static XplatUIX11 GetInstance() {
+ lock (lockobj) {
+ if (Instance == null) {
+ Instance=new XplatUIX11();
+ }
+ RefCount++;
+ }
+ return Instance;
+ }
+
+ public int Reference {
+ get {
+ return RefCount;
+ }
+ }
+ #endregion
+
+ #region Internal Properties
+ internal static IntPtr Display {
+ get {
+ return DisplayHandle;
+ }
+
+ set {
+ XplatUIX11.GetInstance().SetDisplay(value);
+ }
+ }
+
+ internal static int Screen {
+ get {
+ return ScreenNo;
+ }
+
+ set {
+ ScreenNo = value;
+ }
+ }
+
+ internal static IntPtr RootWindowHandle {
+ get {
+ return RootWindow;
+ }
+
+ set {
+ RootWindow = value;
+ }
+ }
+
+ internal static IntPtr Visual {
+ get {
+ return CustomVisual;
+ }
+
+ set {
+ CustomVisual = value;
+ }
+ }
+
+ internal static IntPtr ColorMap {
+ get {
+ return CustomColormap;
+ }
+
+ set {
+ CustomColormap = value;
+ }
+ }
+ #endregion
+
+ #region XExceptionClass
+ internal class XException : ApplicationException {
+ IntPtr Display;
+ IntPtr ResourceID;
+ IntPtr Serial;
+ XRequest RequestCode;
+ byte ErrorCode;
+ byte MinorCode;
+
+ public XException(IntPtr Display, IntPtr ResourceID, IntPtr Serial, byte ErrorCode, XRequest RequestCode, byte MinorCode) {
+ this.Display = Display;
+ this.ResourceID = ResourceID;
+ this.Serial = Serial;
+ this.RequestCode = RequestCode;
+ this.ErrorCode = ErrorCode;
+ this.MinorCode = MinorCode;
+ }
+
+ public override string Message {
+ get {
+ return GetMessage(Display, ResourceID, Serial, ErrorCode, RequestCode, MinorCode);
+ }
+ }
+
+ public static string GetMessage(IntPtr Display, IntPtr ResourceID, IntPtr Serial, byte ErrorCode, XRequest RequestCode, byte MinorCode) {
+ StringBuilder sb;
+ string x_error_text;
+ string error;
+ string hwnd_text;
+ string control_text;
+ Hwnd hwnd;
+ Control c;
+
+ sb = new StringBuilder(160);
+ XGetErrorText(Display, ErrorCode, sb, sb.Capacity);
+ x_error_text = sb.ToString();
+ hwnd = Hwnd.ObjectFromHandle(ResourceID);
+ if (hwnd != null) {
+ hwnd_text = hwnd.ToString();
+ c = Control.FromHandle(hwnd.Handle);
+ if (c != null) {
+ control_text = c.ToString();
+ } else {
+ control_text = String.Format("<handle {0:X} non-existant>", hwnd.Handle);
+ }
+ } else {
+ hwnd_text = "<null>";
+ control_text = "<null>";
+ }
+
+
+ error = String.Format("\n Error: {0}\n Request: {1:D} ({2})\n Resource ID: 0x{3:X}\n Serial: {4}\n Hwnd: {5}\n Control: {6}", x_error_text, RequestCode, RequestCode, ResourceID.ToInt32(), Serial, hwnd_text, control_text);
+ return error;
+ }
+ }
+ #endregion // XExceptionClass
+
+ #region Internal Methods
+ internal void SetDisplay(IntPtr display_handle) {
+ if (display_handle != IntPtr.Zero) {
+ Hwnd hwnd;
+
+ if ((DisplayHandle != IntPtr.Zero) && (FosterParent != IntPtr.Zero)) {
+ hwnd = Hwnd.ObjectFromHandle(FosterParent);
+ XDestroyWindow(DisplayHandle, FosterParent);
+ hwnd.Dispose();
+ }
+
+ if (DisplayHandle != IntPtr.Zero) {
+ XCloseDisplay(DisplayHandle);
+ }
+
+ DisplayHandle=display_handle;
+
+ // We need to tell System.Drawing our DisplayHandle. FromHdcInternal has
+ // been hacked to do this for us.
+ Graphics.FromHdcInternal (DisplayHandle);
+
+ // Debugging support
+ if (Environment.GetEnvironmentVariable ("MONO_XSYNC") != null) {
+ XSynchronize(DisplayHandle, true);
+ }
+
+ if (Environment.GetEnvironmentVariable ("MONO_XEXCEPTIONS") != null) {
+ ErrorExceptions = true;
+ }
+
+ // Generic X11 setup
+ ScreenNo = XDefaultScreen(DisplayHandle);
+ RootWindow = XRootWindow(DisplayHandle, ScreenNo);
+ DefaultColormap = XDefaultColormap(DisplayHandle, ScreenNo);
+
+ // Create the foster parent
+ FosterParent=XCreateSimpleWindow(DisplayHandle, RootWindow, 0, 0, 1, 1, 4, UIntPtr.Zero, UIntPtr.Zero);
+ if (FosterParent==IntPtr.Zero) {
+ Console.WriteLine("XplatUIX11 Constructor failed to create FosterParent");
+ }
+
+ hwnd = new Hwnd();
+ hwnd.WholeWindow = FosterParent;
+ hwnd.ClientWindow = FosterParent;
+
+ // For sleeping on the X11 socket
+ listen = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
+ IPEndPoint ep = new IPEndPoint(IPAddress.Loopback, 0);
+ listen.Bind(ep);
+ listen.Listen(1);
+
+ // To wake up when a timer is ready
+ network_buffer = new byte[10];
+
+ wake = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
+ wake.Connect(listen.LocalEndPoint);
+ wake_receive = listen.Accept();
+
+ #if __MonoCS__
+ pollfds = new Pollfd [2];
+ pollfds [0] = new Pollfd ();
+ pollfds [0].fd = XConnectionNumber (DisplayHandle);
+ pollfds [0].events = PollEvents.POLLIN;
+
+ pollfds [1] = new Pollfd ();
+ pollfds [1].fd = wake_receive.Handle.ToInt32 ();
+ pollfds [1].events = PollEvents.POLLIN;
+ #endif
+
+ Keyboard = new X11Keyboard(DisplayHandle, FosterParent);
+ Dnd = new X11Dnd (DisplayHandle);
+
+ PostQuitState = false;
+
+ DoubleClickInterval = 500;
+
+ HoverState.Interval = 500;
+ HoverState.Timer = new Timer();
+ HoverState.Timer.Enabled = false;
+ HoverState.Timer.Interval = HoverState.Interval;
+ HoverState.Timer.Tick += new EventHandler(MouseHover);
+ HoverState.Size = new Size(4, 4);
+ HoverState.X = -1;
+ HoverState.Y = -1;
+
+ ActiveWindow = IntPtr.Zero;
+ FocusWindow = IntPtr.Zero;
+ ModalWindows = new Stack(3);
+
+ MouseState = MouseButtons.None;
+ MousePosition = new Point(0, 0);
+
+ Caret.Timer = new Timer();
+ Caret.Timer.Interval = 500; // FIXME - where should this number come from?
+ Caret.Timer.Tick += new EventHandler(CaretCallback);
+
+ SetupAtoms();
+
+ // Grab atom changes off the root window to catch certain WM events
+ XSelectInput(DisplayHandle, RootWindow, new IntPtr ((int)EventMask.PropertyChangeMask));
+
+ // Handle any upcoming errors
+ ErrorHandler = new XErrorHandler(HandleError);
+ XSetErrorHandler(ErrorHandler);
+ } else {
+ throw new ArgumentNullException("Display", "Could not open display (X-Server required. Check you DISPLAY environment variable)");
+ }
+ }
+
+ internal static void Where() {
+ Console.WriteLine("Here: {0}\n", WhereString());
+ }
+
+ internal static string WhereString() {
+ StackTrace stack;
+ StackFrame frame;
+ string newline;
+ string unknown;
+ StringBuilder sb;
+ MethodBase method;
+
+ newline = String.Format("{0}\t {1} ", Environment.NewLine, Locale.GetText("at"));
+ unknown = Locale.GetText("<unknown method>");
+ sb = new StringBuilder();
+ stack = new StackTrace(true);
+
+ for (int i = 0; i < stack.FrameCount; i++) {
+ frame = stack.GetFrame(i);
+ sb.Append(newline);
+
+ method = frame.GetMethod();
+ if (method != null) {
+ #if not
+ sb.AppendFormat(frame.ToString());
+ #endif
+ if (frame.GetFileLineNumber() != 0) {
+ sb.AppendFormat("{0}.{1} () [{2}:{3}]", method.DeclaringType.FullName, method.Name, Path.GetFileName(frame.GetFileName()), frame.GetFileLineNumber());
+ } else {
+ sb.AppendFormat("{0}.{1} ()", method.DeclaringType.FullName, method.Name);
+ }
+ } else {
+ sb.Append(unknown);
+ }
+ }
+ return sb.ToString();
+ }
+ #endregion // Internal Methods
+
+ #region Private Methods
+ private static void SetupAtoms() {
+ NetAtoms = new IntPtr[(int)NA.LAST_NET_ATOM];
+
+ NetAtoms[(int)NA.WM_PROTOCOLS] = XInternAtom(DisplayHandle, "WM_PROTOCOLS", false);
+ NetAtoms[(int)NA.WM_DELETE_WINDOW] = XInternAtom(DisplayHandle, "WM_DELETE_WINDOW", false);
+ NetAtoms[(int)NA.WM_TAKE_FOCUS] = XInternAtom(DisplayHandle, "WM_TAKE_FOCUS", false);
+
+ NetAtoms[(int)NA._NET_SUPPORTED] = XInternAtom(DisplayHandle, "_NET_SUPPORTED", false);
+ NetAtoms[(int)NA._NET_CLIENT_LIST] = XInternAtom(DisplayHandle, "_NET_CLIENT_LIST", false);
+ NetAtoms[(int)NA._NET_NUMBER_OF_DESKTOPS] = XInternAtom(DisplayHandle, "_NET_NUMBER_OF_DESKTOPS", false);
+ NetAtoms[(int)NA._NET_DESKTOP_GEOMETRY] = XInternAtom(DisplayHandle, "_NET_DESKTOP_GEOMETRY", false);
+ NetAtoms[(int)NA._NET_DESKTOP_VIEWPORT] = XInternAtom(DisplayHandle, "_NET_DESKTOP_VIEWPORT", false);
+ NetAtoms[(int)NA._NET_CURRENT_DESKTOP] = XInternAtom(DisplayHandle, "_NET_CURRENT_DESKTOP", false);
+ NetAtoms[(int)NA._NET_DESKTOP_NAMES] = XInternAtom(DisplayHandle, "_NET_DESKTOP_NAMES", false);
+ NetAtoms[(int)NA._NET_ACTIVE_WINDOW] = XInternAtom(DisplayHandle, "_NET_ACTIVE_WINDOW", false);
+ NetAtoms[(int)NA._NET_WORKAREA] = XInternAtom(DisplayHandle, "_NET_WORKAREA", false);
+ NetAtoms[(int)NA._NET_SUPPORTING_WM_CHECK] = XInternAtom(DisplayHandle, "_NET_SUPPORTING_WM_CHECK", false);
+ NetAtoms[(int)NA._NET_VIRTUAL_ROOTS] = XInternAtom(DisplayHandle, "_NET_VIRTUAL_ROOTS", false);
+ NetAtoms[(int)NA._NET_DESKTOP_LAYOUT] = XInternAtom(DisplayHandle, "_NET_DESKTOP_LAYOUT", false);
+ NetAtoms[(int)NA._NET_SHOWING_DESKTOP] = XInternAtom(DisplayHandle, "_NET_SHOWING_DESKTOP", false);
+
+ NetAtoms[(int)NA._NET_CLOSE_WINDOW] = XInternAtom(DisplayHandle, "_NET_CLOSE_WINDOW", false);
+ NetAtoms[(int)NA._NET_MOVERESIZE_WINDOW] = XInternAtom(DisplayHandle, "_NET_MOVERESIZE_WINDOW", false);
+ NetAtoms[(int)NA._NET_WM_MOVERESIZE] = XInternAtom(DisplayHandle, "_NET_WM_MOVERESIZE", false);
+ NetAtoms[(int)NA._NET_RESTACK_WINDOW] = XInternAtom(DisplayHandle, "_NET_RESTACK_WINDOW", false);
+ NetAtoms[(int)NA._NET_REQUEST_FRAME_EXTENTS] = XInternAtom(DisplayHandle, "_NET_REQUEST_FRAME_EXTENTS", false);
+
+ NetAtoms[(int)NA._NET_WM_NAME] = XInternAtom(DisplayHandle, "_NET_WM_NAME", false);
+ NetAtoms[(int)NA._NET_WM_VISIBLE_NAME] = XInternAtom(DisplayHandle, "_NET_WM_VISIBLE_NAME", false);
+ NetAtoms[(int)NA._NET_WM_ICON_NAME] = XInternAtom(DisplayHandle, "_NET_WM_ICON_NAME", false);
+ NetAtoms[(int)NA._NET_WM_VISIBLE_ICON_NAME] = XInternAtom(DisplayHandle, "_NET_WM_VISIBLE_ICON_NAME", false);
+ NetAtoms[(int)NA._NET_WM_DESKTOP] = XInternAtom(DisplayHandle, "_NET_WM_DESKTOP", false);
+ NetAtoms[(int)NA._NET_WM_WINDOW_TYPE] = XInternAtom(DisplayHandle, "_NET_WM_WINDOW_TYPE", false);
+ NetAtoms[(int)NA._NET_WM_STATE] = XInternAtom(DisplayHandle, "_NET_WM_STATE", false);
+ NetAtoms[(int)NA._NET_WM_ALLOWED_ACTIONS] = XInternAtom(DisplayHandle, "_NET_WM_ALLOWED_ACTIONS", false);
+ NetAtoms[(int)NA._NET_WM_STRUT] = XInternAtom(DisplayHandle, "_NET_WM_STRUT", false);
+ NetAtoms[(int)NA._NET_WM_STRUT_PARTIAL] = XInternAtom(DisplayHandle, "_NET_WM_STRUT_PARTIAL", false);
+ NetAtoms[(int)NA._NET_WM_ICON_GEOMETRY] = XInternAtom(DisplayHandle, "_NET_WM_ICON_GEOMETRY", false);
+ NetAtoms[(int)NA._NET_WM_ICON] = XInternAtom(DisplayHandle, "_NET_WM_ICON", false);
+ NetAtoms[(int)NA._NET_WM_PID] = XInternAtom(DisplayHandle, "_NET_WM_PID", false);
+ NetAtoms[(int)NA._NET_WM_HANDLED_ICONS] = XInternAtom(DisplayHandle, "_NET_WM_HANDLED_ICONS", false);
+ NetAtoms[(int)NA._NET_WM_USER_TIME] = XInternAtom(DisplayHandle, "_NET_WM_USER_TIME", false);
+ NetAtoms[(int)NA._NET_FRAME_EXTENTS] = XInternAtom(DisplayHandle, "_NET_FRAME_EXTENTS", false);
+
+ NetAtoms[(int)NA._NET_WM_PING] = XInternAtom(DisplayHandle, "_NET_WM_PING", false);
+ NetAtoms[(int)NA._NET_WM_SYNC_REQUEST] = XInternAtom(DisplayHandle, "_NET_WM_SYNC_REQUEST", false);
+
+ NetAtoms[(int)NA._NET_SYSTEM_TRAY_S] = XInternAtom(DisplayHandle, "_NET_SYSTEM_TRAY_S" + ScreenNo.ToString(), false);
+ NetAtoms[(int)NA._NET_SYSTEM_TRAY_OPCODE] = XInternAtom(DisplayHandle, "_NET_SYSTEM_TRAY_OPCODE", false);
+ NetAtoms[(int)NA._NET_SYSTEM_TRAY_ORIENTATION] = XInternAtom(DisplayHandle, "_NET_SYSTEM_TRAY_ORIENTATION", false);
+
+ NetAtoms[(int)NA._NET_WM_STATE_MAXIMIZED_HORZ] = XInternAtom(DisplayHandle, "_NET_WM_STATE_MAXIMIZED_HORZ", false);
+ NetAtoms[(int)NA._NET_WM_STATE_MAXIMIZED_VERT] = XInternAtom(DisplayHandle, "_NET_WM_STATE_MAXIMIZED_VERT", false);
+ NetAtoms[(int)NA._NET_WM_STATE_HIDDEN] = XInternAtom(DisplayHandle, "_NET_WM_STATE_HIDDEN", false);
+
+ NetAtoms[(int)NA._XEMBED] = XInternAtom(DisplayHandle, "_XEMBED", false);
+ NetAtoms[(int)NA._XEMBED_INFO] = XInternAtom(DisplayHandle, "_XEMBED_INFO", false);
+
+ NetAtoms[(int)NA._MOTIF_WM_HINTS] = XInternAtom(DisplayHandle, "_MOTIF_WM_HINTS", false);
+
+ NetAtoms[(int)NA._NET_WM_STATE_NO_TASKBAR] = XInternAtom(DisplayHandle, "_NET_WM_STATE_NO_TASKBAR", false);
+ NetAtoms[(int)NA._NET_WM_STATE_ABOVE] = XInternAtom(DisplayHandle, "_NET_WM_STATE_ABOVE", false);
+ NetAtoms[(int)NA._NET_WM_STATE_MODAL] = XInternAtom(DisplayHandle, "_NET_WM_STATE_MODAL", false);
+ NetAtoms[(int)NA._NET_WM_CONTEXT_HELP] = XInternAtom(DisplayHandle, "_NET_WM_CONTEXT_HELP", false);
+ NetAtoms[(int)NA._NET_WM_WINDOW_OPACITY] = XInternAtom(DisplayHandle, "_NET_WM_WINDOW_OPACITY", false);
+
+ // Clipboard support
+ NetAtoms[(int)NA.CLIPBOARD] = XInternAtom (DisplayHandle, "CLIPBOARD", false);
+ NetAtoms[(int)NA.DIB] = (IntPtr)Atom.XA_PIXMAP;
+ NetAtoms[(int)NA.OEMTEXT] = XInternAtom(DisplayHandle, "COMPOUND_TEXT", false);
+ NetAtoms[(int)NA.UNICODETEXT] = XInternAtom(DisplayHandle, "UTF8_STRING", false);
+ NetAtoms[(int)NA.TARGETS] = XInternAtom(DisplayHandle, "TARGETS", false);
+
+ // Special Atoms
+ AsyncAtom = XInternAtom(DisplayHandle, "_SWF_AsyncAtom", false);
+ PostAtom = XInternAtom (DisplayHandle, "_SWF_PostMessageAtom", false);
+ HoverState.Atom = XInternAtom(DisplayHandle, "_SWF_HoverAtom", false);
+ }
+
+ private void GetSystrayManagerWindow() {
+ XGrabServer(DisplayHandle);
+ SystrayMgrWindow = XGetSelectionOwner(DisplayHandle, NetAtoms[(int)NA._NET_SYSTEM_TRAY_S]);
+ XUngrabServer(DisplayHandle);
+ XFlush(DisplayHandle);
+ }
+
+ private void SendNetWMMessage(IntPtr window, IntPtr message_type, IntPtr l0, IntPtr l1, IntPtr l2) {
+ XEvent xev;
+
+ xev = new XEvent();
+ xev.ClientMessageEvent.type = XEventName.ClientMessage;
+ xev.ClientMessageEvent.send_event = true;
+ xev.ClientMessageEvent.window = window;
+ xev.ClientMessageEvent.message_type = message_type;
+ xev.ClientMessageEvent.format = 32;
+ xev.ClientMessageEvent.ptr1 = l0;
+ xev.ClientMessageEvent.ptr2 = l1;
+ xev.ClientMessageEvent.ptr3 = l2;
+ XSendEvent(DisplayHandle, RootWindow, false, new IntPtr ((int) (EventMask.SubstructureRedirectMask | EventMask.SubstructureNotifyMask)), ref xev);
+ }
+
+ private void SendNetClientMessage(IntPtr window, IntPtr message_type, IntPtr l0, IntPtr l1, IntPtr l2) {
+ XEvent xev;
+
+ xev = new XEvent();
+ xev.ClientMessageEvent.type = XEventName.ClientMessage;
+ xev.ClientMessageEvent.send_event = true;
+ xev.ClientMessageEvent.window = window;
+ xev.ClientMessageEvent.message_type = message_type;
+ xev.ClientMessageEvent.format = 32;
+ xev.ClientMessageEvent.ptr1 = l0;
+ xev.ClientMessageEvent.ptr2 = l1;
+ xev.ClientMessageEvent.ptr3 = l2;
+ XSendEvent(DisplayHandle, window, false, new IntPtr ((int)EventMask.NoEventMask), ref xev);
+ }
+
+ private void DeriveStyles(int Style, int ExStyle, out FormBorderStyle border_style, out TitleStyle title_style, out int caption_height, out int tool_caption_height) {
+
+ // Only MDI windows get caption_heights
+ caption_height = 0;
+ tool_caption_height = 19;
+
+ if ((Style & (int) WindowStyles.WS_CHILD) != 0) {
+ if ((ExStyle & (int) WindowExStyles.WS_EX_CLIENTEDGE) != 0) {
+ border_style = FormBorderStyle.Fixed3D;
+ } else if ((Style & (int) WindowStyles.WS_BORDER) == 0) {
+ border_style = FormBorderStyle.None;
+ } else {
+ border_style = FormBorderStyle.FixedSingle;
+ }
+ title_style = TitleStyle.None;
+
+ if ((ExStyle & (int) WindowExStyles.WS_EX_MDICHILD) != 0) {
+ caption_height = 26;
+
+ if ((Style & (int)WindowStyles.WS_CAPTION) != 0) {
+ if ((ExStyle & (int)WindowExStyles.WS_EX_TOOLWINDOW) != 0) {
+ title_style = TitleStyle.Tool;
+ } else {
+ title_style = TitleStyle.Normal;
+ }
+ }
+
+ if ((Style & (int) WindowStyles.WS_OVERLAPPEDWINDOW) != 0 ||
+ (ExStyle & (int) WindowExStyles.WS_EX_TOOLWINDOW) != 0) {
+ border_style = (FormBorderStyle) 0xFFFF;
+ } else {
+ border_style = FormBorderStyle.None;
+ }
+ }
+
+ } else {
+ title_style = TitleStyle.None;
+ if ((Style & (int)WindowStyles.WS_CAPTION) != 0) {
+ if ((ExStyle & (int)WindowExStyles.WS_EX_TOOLWINDOW) != 0) {
+ title_style = TitleStyle.Tool;
+ } else {
+ title_style = TitleStyle.Normal;
+ }
+ }
+
+ border_style = FormBorderStyle.None;
+
+ if ((Style & (int)WindowStyles.WS_THICKFRAME) != 0) {
+ if ((ExStyle & (int)WindowExStyles.WS_EX_TOOLWINDOW) != 0) {
+ border_style = FormBorderStyle.SizableToolWindow;
+ } else {
+ border_style = FormBorderStyle.Sizable;
+ }
+ } else {
+ if ((ExStyle & (int)WindowExStyles.WS_EX_CLIENTEDGE) != 0) {
+ border_style = FormBorderStyle.Fixed3D;
+ } else if ((ExStyle & (int)WindowExStyles.WS_EX_DLGMODALFRAME) != 0) {
+ border_style = FormBorderStyle.FixedDialog;
+ } else if ((ExStyle & (int)WindowExStyles.WS_EX_TOOLWINDOW) != 0) {
+ border_style = FormBorderStyle.FixedToolWindow;
+ } else if ((Style & (int)WindowStyles.WS_BORDER) != 0) {
+ border_style = FormBorderStyle.Sizable;
+ } else {
+ border_style = FormBorderStyle.None;
+ }
+ }
+ }
+ }
+
+ private void SetHwndStyles(Hwnd hwnd, CreateParams cp) {
+ DeriveStyles(cp.Style, cp.ExStyle, out hwnd.border_style, out hwnd.title_style, out hwnd.caption_height, out hwnd.tool_caption_height);
+ }
+
+ private void SetWMStyles(Hwnd hwnd, CreateParams cp) {
+ MotifWmHints mwmHints;
+ MotifFunctions functions;
+ MotifDecorations decorations;
+ int atom_count;
+ Rectangle client_rect;
+
+ // Child windows don't need WM window styles
+ if ((cp.Style & (int)WindowStyles.WS_CHILDWINDOW) != 0) {
+ return;
+ }
+
+ mwmHints = new MotifWmHints();
+ functions = 0;
+ decorations = 0;
+
+ mwmHints.flags = (IntPtr)(MotifFlags.Functions | MotifFlags.Decorations);
+ mwmHints.functions = (IntPtr)0;
+ mwmHints.decorations = (IntPtr)0;
+
+ if ((cp.Style & (int)WindowStyles.WS_CAPTION) != 0) {
+ functions |= MotifFunctions.Move;
+ decorations |= MotifDecorations.Title | MotifDecorations.Menu;
+ }
+
+ if ((cp.Style & ((int)WindowStyles.WS_THICKFRAME)) != 0) {
+ functions |= MotifFunctions.Move | MotifFunctions.Resize;
+ decorations |= MotifDecorations.Border | MotifDecorations.ResizeH;
+ }
+ if ((cp.Style & ((int)WindowStyles.WS_MINIMIZEBOX)) != 0) {
+ functions |= MotifFunctions.Minimize;
+ decorations |= MotifDecorations.Minimize;
+ }
+
+ if ((cp.Style & ((int)WindowStyles.WS_MAXIMIZEBOX)) != 0) {
+ functions |= MotifFunctions.Maximize;
+ decorations |= MotifDecorations.Maximize;
+ }
+
+ if ((cp.Style & ((int)WindowStyles.WS_SYSMENU)) != 0) {
+ functions |= MotifFunctions.Close;
+ }
+
+ if ((cp.ExStyle & ((int)WindowExStyles.WS_EX_DLGMODALFRAME)) != 0) {
+ decorations |= MotifDecorations.Border;
+ }
+
+ if ((cp.Style & ((int)WindowStyles.WS_DLGFRAME)) != 0) {
+ decorations |= MotifDecorations.Border;
+ }
+
+ if ((cp.Style & ((int)WindowStyles.WS_BORDER)) != 0) {
+ decorations |= MotifDecorations.Border;
+ }
+
+ if ((cp.ExStyle & ((int)WindowExStyles.WS_EX_TOOLWINDOW)) != 0) {
+ functions = 0;
+ decorations = 0;
+ }
+
+ if ((functions & MotifFunctions.Resize) == 0) {
+ hwnd.fixed_size = true;
+ XplatUI.SetWindowMinMax(hwnd.Handle, new Rectangle(cp.X, cp.Y, cp.Width, cp.Height), new Size(cp.Width, cp.Height), new Size(cp.Width, cp.Height));
+ } else {
+ hwnd.fixed_size = false;
+ }
+
+ mwmHints.functions = (IntPtr)functions;
+ mwmHints.decorations = (IntPtr)decorations;
+
+ client_rect = hwnd.ClientRect;
+ lock (XlibLock) {
+ XChangeProperty(DisplayHandle, hwnd.whole_window, NetAtoms[(int)NA._MOTIF_WM_HINTS], NetAtoms[(int)NA._MOTIF_WM_HINTS], 32, PropertyMode.Replace, ref mwmHints, 5);
+
+ if (((cp.Style & (int)WindowStyles.WS_POPUP) != 0) && (hwnd.parent != null) && (hwnd.parent.whole_window != IntPtr.Zero)) {
+ XSetTransientForHint(DisplayHandle, hwnd.whole_window, hwnd.parent.whole_window);
+ }
+ XMoveResizeWindow(DisplayHandle, hwnd.client_window, client_rect.X, client_rect.Y, client_rect.Width, client_rect.Height);
+
+ int[] atoms = new int[8];
+ atom_count = 0;
+
+ if ((cp.ExStyle & ((int)WindowExStyles.WS_EX_TOOLWINDOW)) != 0) {
+ atoms[atom_count++] = NetAtoms[(int)NA._NET_WM_STATE_NO_TASKBAR].ToInt32();
+ }
+ XChangeProperty(DisplayHandle, hwnd.whole_window, NetAtoms[(int)NA._NET_WM_STATE], (IntPtr)Atom.XA_ATOM, 32, PropertyMode.Replace, atoms, atom_count);
+
+ atom_count = 0;
+ IntPtr[] atom_ptrs = new IntPtr[2];
+
+ atom_ptrs[atom_count++] = NetAtoms[(int)NA.WM_DELETE_WINDOW];
+ if ((cp.ExStyle & (int)WindowExStyles.WS_EX_CONTEXTHELP) != 0) {
+ atom_ptrs[atom_count++] = NetAtoms[(int)NA._NET_WM_CONTEXT_HELP];
+ }
+
+ XSetWMProtocols(DisplayHandle, hwnd.whole_window, atom_ptrs, atom_count);
+ }
+ }
+
+ private void SetIcon(Hwnd hwnd, Icon icon) {
+ Bitmap bitmap;
+ int size;
+ uint[] data;
+ int index;
+
+ bitmap = icon.ToBitmap();
+ index = 0;
+ size = bitmap.Width * bitmap.Height + 2;
+ data = new uint[size];
+
+ data[index++] = (uint)bitmap.Width;
+ data[index++] = (uint)bitmap.Height;
+
+ for (int y = 0; y < bitmap.Height; y++) {
+ for (int x = 0; x < bitmap.Width; x++) {
+ data[index++] = (uint)bitmap.GetPixel(x, y).ToArgb();
+ }
+ }
+ XChangeProperty(DisplayHandle, hwnd.whole_window, NetAtoms[(int)NA._NET_WM_ICON], (IntPtr)Atom.XA_CARDINAL, 32, PropertyMode.Replace, data, size);
+ }
+
+ private IntPtr ImageToPixmap(Image image) {
+ return IntPtr.Zero;
+ }
+
+ private void WakeupMain () {
+ wake.Send (new byte [] { 0xFF });
+ }
+
+ private void TranslatePropertyToClipboard(IntPtr property) {
+ IntPtr actual_atom;
+ int actual_format;
+ IntPtr nitems;
+ IntPtr bytes_after;
+ IntPtr prop = IntPtr.Zero;
+
+ Clipboard.Item = null;
+
+ XGetWindowProperty(DisplayHandle, FosterParent, property, IntPtr.Zero, new IntPtr (0x7fffffff), true, (IntPtr)Atom.AnyPropertyType, out actual_atom, out actual_format, out nitems, out bytes_after, ref prop);
+
+ if ((long)nitems > 0) {
+ if (property == (IntPtr)Atom.XA_STRING) {
+ Clipboard.Item = Marshal.PtrToStringAnsi(prop);
+ } else if (property == (IntPtr)Atom.XA_BITMAP) {
+ // FIXME - convert bitmap to image
+ } else if (property == (IntPtr)Atom.XA_PIXMAP) {
+ // FIXME - convert pixmap to image
+ } else if (property == NetAtoms[(int)NA.OEMTEXT]) {
+ Clipboard.Item = Marshal.PtrToStringAnsi(prop);
+ } else if (property == NetAtoms[(int)NA.UNICODETEXT]) {
+ Clipboard.Item = Marshal.PtrToStringAnsi(prop);
+ }
+
+ XFree(prop);
+ }
+ }
+
+ private void AddExpose (XEvent xevent) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.GetObjectFromWindow(xevent.AnyEvent.window);
+
+ // Don't waste time
+ if (hwnd == null) {
+ return;
+ }
+
+ if (xevent.AnyEvent.window == hwnd.client_window) {
+ hwnd.AddInvalidArea(xevent.ExposeEvent.x, xevent.ExposeEvent.y, xevent.ExposeEvent.width, xevent.ExposeEvent.height);
+ if (!hwnd.expose_pending) {
+ MessageQueue.Enqueue(xevent);
+ hwnd.expose_pending = true;
+ }
+ } else {
+ hwnd.AddNcInvalidArea (xevent.ExposeEvent.x, xevent.ExposeEvent.y, xevent.ExposeEvent.width, xevent.ExposeEvent.height);
+
+ if (!hwnd.nc_expose_pending) {
+ MessageQueue.Enqueue(xevent);
+ hwnd.nc_expose_pending = true;
+ }
+ }
+ }
+
+ private void InvalidateWholeWindow(IntPtr handle) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ InvalidateWholeWindow(handle, new Rectangle(0, 0, hwnd.Width, hwnd.Height));
+ }
+
+ private void InvalidateWholeWindow(IntPtr handle, Rectangle rectangle) {
+ Hwnd hwnd;
+ XEvent xevent;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+
+ xevent = new XEvent ();
+ xevent.type = XEventName.Expose;
+ xevent.ExposeEvent.display = DisplayHandle;
+ xevent.ExposeEvent.window = hwnd.whole_window;
+
+ xevent.ExposeEvent.x = rectangle.X;
+ xevent.ExposeEvent.y = rectangle.Y;
+ xevent.ExposeEvent.width = rectangle.Width;
+ xevent.ExposeEvent.height = rectangle.Height;
+
+ AddExpose (xevent);
+ }
+
+ private void WholeToScreen(IntPtr handle, ref int x, ref int y) {
+ int dest_x_return;
+ int dest_y_return;
+ IntPtr child;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ lock (XlibLock) {
+ XTranslateCoordinates(DisplayHandle, hwnd.whole_window, RootWindow, x, y, out dest_x_return, out dest_y_return, out child);
+ }
+
+ x = dest_x_return;
+ y = dest_y_return;
+ }
+
+ private void AbsoluteGeometry(IntPtr window, out int ret_x, out int ret_y, out int width, out int height) {
+ IntPtr root;
+ IntPtr win;
+ IntPtr parent;
+ IntPtr children;
+ int x;
+ int y;
+ int w;
+ int h;
+ int absX;
+ int absY;
+ int b;
+ int d;
+ int nchildren;
+
+ absX = 0;
+ absY = 0;
+ win = window;
+ width = 0;
+ height = 0;
+ do {
+ XGetGeometry(DisplayHandle, win, out root, out x, out y, out w, out h, out b, out d);
+ if (win == window) {
+ width = w;
+ height = h;
+ }
+ absX += x;
+ absY += y;
+ if (XQueryTree(DisplayHandle, win, out root, out parent, out children, out nchildren) == 0) {
+ break;
+ }
+
+ if (children != IntPtr.Zero) {
+ XFree(children);
+ }
+ win = parent;
+ } while (win != root);
+
+ ret_x = absX;
+ ret_y = absY;
+
+//Console.WriteLine("Absolute pos for window {0} = {1},{2} {3}x{4}", XplatUI.Window(window), ret_x, ret_y, width, height);
+ }
+
+ private void FrameExtents(IntPtr window, out int left, out int top) {
+ IntPtr actual_atom;
+ int actual_format;
+ IntPtr nitems;
+ IntPtr bytes_after;
+ IntPtr prop = IntPtr.Zero;
+
+ XGetWindowProperty(DisplayHandle, window, NetAtoms[(int)NA._NET_FRAME_EXTENTS], IntPtr.Zero, new IntPtr (16), false, (IntPtr)Atom.XA_CARDINAL, out actual_atom, out actual_format, out nitems, out bytes_after, ref prop);
+ if (((long)nitems == 4) && (prop != IntPtr.Zero)) {
+ left = Marshal.ReadInt32(prop, 0);
+ //right = Marshal.ReadInt32(prop, 4);
+ top = Marshal.ReadInt32(prop, 8);
+ //bottom = Marshal.ReadInt32(prop, 12);
+ } else {
+ left = 0;
+ top = 0;
+ }
+
+ if (prop != IntPtr.Zero) {
+ XFree(prop);
+ }
+ return;
+ }
+
+ private void AddConfigureNotify (XEvent xevent) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.GetObjectFromWindow(xevent.ConfigureEvent.window);
+
+ // Don't waste time
+ if (hwnd == null) {
+ return;
+ }
+
+ if (xevent.ConfigureEvent.window == hwnd.whole_window) {
+ if (!hwnd.reparented) {
+ hwnd.x = xevent.ConfigureEvent.x;
+ hwnd.y = xevent.ConfigureEvent.y;
+ } else {
+ // This sucks ass, part 1
+ // Every WM does the ConfigureEvents of toplevel windows different, so there's
+ // no standard way of getting our adjustment.
+ // The code below is needed for KDE and FVWM, the 'whacky_wm' part is for metacity
+ // Several other WMs do their decorations different yet again and we fail to deal
+ // with that, since I couldn't find any frigging commonality between them.
+ // The only sane WM seems to be KDE
+
+ if (!xevent.ConfigureEvent.send_event) {
+ IntPtr dummy_ptr;
+
+ XTranslateCoordinates(DisplayHandle, hwnd.whole_window, RootWindow, -xevent.ConfigureEvent.x, -xevent.ConfigureEvent.y, out hwnd.x, out hwnd.y, out dummy_ptr);
+ } else {
+ // This is a synthetic event, coordinates are in root space
+ hwnd.x = xevent.ConfigureEvent.x;
+ hwnd.y = xevent.ConfigureEvent.y;
+ if (hwnd.whacky_wm) {
+ int frame_left;
+ int frame_top;
+
+ FrameExtents(hwnd.whole_window, out frame_left, out frame_top);
+ hwnd.x -= frame_left;
+ hwnd.y -= frame_top;
+ }
+ }
+ }
+ hwnd.width = xevent.ConfigureEvent.width;
+ hwnd.height = xevent.ConfigureEvent.height;
+
+ if (!hwnd.configure_pending) {
+ MessageQueue.Enqueue(xevent);
+ hwnd.configure_pending = true;
+ }
+ }
+ // We drop configure events for Client windows
+ }
+
+ private void ShowCaret() {
+ if ((Caret.gc == IntPtr.Zero) || Caret.On) {
+ return;
+ }
+ Caret.On = true;
+
+ lock (XlibLock) {
+ XDrawLine(DisplayHandle, Caret.Window, Caret.gc, Caret.X, Caret.Y, Caret.X, Caret.Y + Caret.Height);
+ }
+ }
+
+ private void HideCaret() {
+ if ((Caret.gc == IntPtr.Zero) || !Caret.On) {
+ return;
+ }
+ Caret.On = false;
+
+ lock (XlibLock) {
+ XDrawLine(DisplayHandle, Caret.Window, Caret.gc, Caret.X, Caret.Y, Caret.X, Caret.Y + Caret.Height);
+ }
+ }
+
+ private int NextTimeout (DateTime now) {
+ int timeout = Int32.MaxValue;
+ lock (TimerList) {
+ foreach (Timer timer in TimerList) {
+ int next = (int) (timer.Expires - now).TotalMilliseconds;
+ if (next < 0) {
+ return 0; // Have a timer that has already expired
+ }
+
+ if (next < timeout) {
+ timeout = next;
+ }
+ }
+ }
+ if (timeout < Timer.Minimum) {
+ timeout = Timer.Minimum;
+ }
+
+ if (timeout > 1000)
+ timeout = 1000;
+ return timeout;
+ }
+
+ private void CheckTimers (DateTime now) {
+ lock (TimerList) {
+ int count;
+
+ count = TimerList.Count;
+
+ if (count == 0) {
+ return;
+ }
+
+ for (int i = 0; i < TimerList.Count; i++) {
+ Timer timer;
+
+ timer = (Timer) TimerList[i];
+
+ if (timer.Enabled && timer.Expires <= now) {
+ timer.Update (now);
+ timer.FireTick ();
+ }
+ }
+ }
+ }
+
+ private void UpdateMessageQueue () {
+ DateTime now;
+ int pending;
+
+ now = DateTime.Now;
+
+ lock (XlibLock) {
+ pending = XPending (DisplayHandle);
+ }
+
+ if (pending == 0) {
+ if (Idle != null) {
+ Idle (this, EventArgs.Empty);
+ }
+
+ lock (XlibLock) {
+ pending = XPending (DisplayHandle);
+ }
+ }
+
+ if (pending == 0) {
+ int timeout;
+
+ timeout = NextTimeout (now);
+ if (timeout > 0) {
+ #if __MonoCS__
+ Syscall.poll (pollfds, (uint) pollfds.Length, timeout);
+ // Clean out buffer, so we're not busy-looping on the same data
+ if (pollfds[1].revents != 0) {
+ wake_receive.Receive(network_buffer, 0, 1, SocketFlags.None);
+ }
+ #endif
+ lock (XlibLock) {
+ pending = XPending (DisplayHandle);
+ }
+ }
+ }
+
+ CheckTimers (now);
+
+ if (pending == 0) {
+ lock (XlibLock) {
+ pending = XPending (DisplayHandle);
+ }
+ }
+
+ while (pending > 0) {
+ XEvent xevent = new XEvent ();
+
+ lock (XlibLock) {
+ XNextEvent (DisplayHandle, ref xevent);
+
+ if (xevent.AnyEvent.type == XEventName.KeyPress) {
+ if (XFilterEvent(ref xevent, FosterParent)) {
+ continue;
+ }
+ }
+ }
+//Console.WriteLine("Got x event {0}", xevent);
+ switch (xevent.type) {
+ case XEventName.Expose:
+ AddExpose (xevent);
+ break;
+
+ case XEventName.SelectionClear: {
+ // Should we do something?
+ break;
+ }
+
+ case XEventName.SelectionRequest: {
+ if (Dnd.HandleSelectionRequestEvent (ref xevent))
+ break;
+ XEvent sel_event;
+
+ sel_event = new XEvent();
+ sel_event.SelectionEvent.type = XEventName.SelectionNotify;
+ sel_event.SelectionEvent.send_event = true;
+ sel_event.SelectionEvent.display = DisplayHandle;
+ sel_event.SelectionEvent.selection = xevent.SelectionRequestEvent.selection;
+ sel_event.SelectionEvent.target = xevent.SelectionRequestEvent.target;
+ sel_event.SelectionEvent.requestor = xevent.SelectionRequestEvent.requestor;
+ sel_event.SelectionEvent.time = xevent.SelectionRequestEvent.time;
+ sel_event.SelectionEvent.property = IntPtr.Zero;
+
+ // Seems that some apps support asking for supported types
+ if (xevent.SelectionEvent.target == NetAtoms[(int)NA.TARGETS]) {
+ int[] atoms;
+ int atom_count;
+
+ atoms = new int[5];
+ atom_count = 0;
+
+ if (Clipboard.Item is String) {
+ atoms[atom_count++] = (int)Atom.XA_STRING;
+ atoms[atom_count++] = (int)NetAtoms[(int)NA.OEMTEXT];
+ atoms[atom_count++] = (int)NetAtoms[(int)NA.UNICODETEXT];
+ } else if (Clipboard.Item is Image) {
+ atoms[atom_count++] = (int)Atom.XA_PIXMAP;
+ atoms[atom_count++] = (int)Atom.XA_BITMAP;
+ } else {
+ // FIXME - handle other types
+ }
+
+ XChangeProperty(DisplayHandle, xevent.SelectionEvent.requestor, (IntPtr)xevent.SelectionRequestEvent.property, (IntPtr)xevent.SelectionRequestEvent.target, 32, PropertyMode.Replace, atoms, atom_count);
+ } else if (Clipboard.Item is string) {
+ IntPtr buffer;
+ int buflen;
+
+ buflen = 0;
+
+ if (xevent.SelectionRequestEvent.target == (IntPtr)Atom.XA_STRING) {
+ Byte[] bytes;
+
+ bytes = new ASCIIEncoding().GetBytes((string)Clipboard.Item);
+ buffer = Marshal.AllocHGlobal(bytes.Length);
+ buflen = bytes.Length;
+
+ for (int i = 0; i < buflen; i++) {
+ Marshal.WriteByte(buffer, i, bytes[i]);
+ }
+ } else if (xevent.SelectionRequestEvent.target == NetAtoms[(int)NA.OEMTEXT]) {
+ // FIXME - this should encode into ISO2022
+ buffer = Marshal.StringToHGlobalAnsi((string)Clipboard.Item);
+ while (Marshal.ReadByte(buffer, buflen) != 0) {
+ buflen++;
+ }
+ } else if (xevent.SelectionRequestEvent.target == NetAtoms[(int)NA.UNICODETEXT]) {
+ buffer = Marshal.StringToHGlobalAnsi((string)Clipboard.Item);
+ while (Marshal.ReadByte(buffer, buflen) != 0) {
+ buflen++;
+ }
+ } else {
+ buffer = IntPtr.Zero;
+ }
+
+ if (buffer != IntPtr.Zero) {
+ XChangeProperty(DisplayHandle, xevent.SelectionRequestEvent.requestor, (IntPtr)xevent.SelectionRequestEvent.property, (IntPtr)xevent.SelectionRequestEvent.target, 8, PropertyMode.Replace, buffer, buflen);
+ sel_event.SelectionEvent.property = xevent.SelectionRequestEvent.property;
+ Marshal.FreeHGlobal(buffer);
+ }
+ } else if (Clipboard.Item is Image) {
+ if (xevent.SelectionEvent.target == (IntPtr)Atom.XA_PIXMAP) {
+ // FIXME - convert image and store as property
+ } else if (xevent.SelectionEvent.target == (IntPtr)Atom.XA_PIXMAP) {
+ // FIXME - convert image and store as property
+ }
+ }
+
+ XSendEvent(DisplayHandle, xevent.SelectionRequestEvent.requestor, false, new IntPtr ((int)EventMask.NoEventMask), ref sel_event);
+ break;
+ }
+
+ case XEventName.SelectionNotify: {
+ if (Clipboard.Enumerating) {
+ Clipboard.Enumerating = false;
+ if (xevent.SelectionEvent.property != IntPtr.Zero) {
+ XDeleteProperty(DisplayHandle, FosterParent, (IntPtr)xevent.SelectionEvent.property);
+ if (!Clipboard.Formats.Contains(xevent.SelectionEvent.property)) {
+ Clipboard.Formats.Add(xevent.SelectionEvent.property);
+ #if DriverDebugExtra
+ Console.WriteLine("Got supported clipboard atom format: {0}", xevent.SelectionEvent.property);
+ #endif
+ }
+ }
+ } else if (Clipboard.Retrieving) {
+ Clipboard.Retrieving = false;
+ if (xevent.SelectionEvent.property != IntPtr.Zero) {
+ TranslatePropertyToClipboard(xevent.SelectionEvent.property);
+ } else {
+ Clipboard.Item = null;
+ }
+ } else {
+ Dnd.HandleSelectionNotifyEvent (ref xevent);
+ }
+ break;
+ }
+
+ case XEventName.KeyPress:
+ case XEventName.KeyRelease:
+ case XEventName.ButtonPress:
+ case XEventName.ButtonRelease:
+ case XEventName.MotionNotify:
+ case XEventName.EnterNotify:
+ case XEventName.LeaveNotify:
+ case XEventName.CreateNotify:
+ case XEventName.DestroyNotify:
+ case XEventName.FocusIn:
+ case XEventName.FocusOut:
+ case XEventName.ClientMessage:
+ case XEventName.ReparentNotify:
+ MessageQueue.Enqueue (xevent);
+ break;
+
+ case XEventName.ConfigureNotify:
+ AddConfigureNotify(xevent);
+ break;
+
+ case XEventName.PropertyNotify:
+ if (xevent.PropertyEvent.atom == NetAtoms[(int)NA._NET_ACTIVE_WINDOW]) {
+ IntPtr actual_atom;
+ int actual_format;
+ IntPtr nitems;
+ IntPtr bytes_after;
+ IntPtr prop = IntPtr.Zero;
+ IntPtr prev_active;;
+
+ prev_active = ActiveWindow;
+ XGetWindowProperty(DisplayHandle, RootWindow, NetAtoms[(int)NA._NET_ACTIVE_WINDOW], IntPtr.Zero, new IntPtr (1), false, (IntPtr)Atom.XA_WINDOW, out actual_atom, out actual_format, out nitems, out bytes_after, ref prop);
+ if (((long)nitems > 0) && (prop != IntPtr.Zero)) {
+ ActiveWindow = Hwnd.GetHandleFromWindow((IntPtr)Marshal.ReadInt32(prop));
+ XFree(prop);
+
+ if (prev_active != ActiveWindow) {
+ if (prev_active != IntPtr.Zero) {
+ PostMessage(prev_active, Msg.WM_ACTIVATE, (IntPtr)WindowActiveFlags.WA_INACTIVE, IntPtr.Zero);
+ }
+ if (ActiveWindow != IntPtr.Zero) {
+ PostMessage(ActiveWindow, Msg.WM_ACTIVATE, (IntPtr)WindowActiveFlags.WA_ACTIVE, IntPtr.Zero);
+ }
+ }
+ if (ModalWindows.Count == 0) {
+ break;
+ } else {
+ // Modality handling, if we are modal and the new active window is one
+ // of ours but not the modal one, switch back to the modal window
+
+ if (NativeWindow.FindWindow(ActiveWindow) != null) {
+ if (ActiveWindow != (IntPtr)ModalWindows.Peek()) {
+ Activate((IntPtr)ModalWindows.Peek());
+ }
+ }
+ break;
+ }
+ }
+ }
+ break;
+
+ }
+
+ lock (XlibLock) {
+ pending = XPending (DisplayHandle);
+ }
+ }
+ }
+
+ private IntPtr GetMousewParam(int Delta) {
+ int result = 0;
+
+ if ((MouseState & MouseButtons.Left) != 0) {
+ result |= (int)MsgButtons.MK_LBUTTON;
+ }
+
+ if ((MouseState & MouseButtons.Middle) != 0) {
+ result |= (int)MsgButtons.MK_MBUTTON;
+ }
+
+ if ((MouseState & MouseButtons.Right) != 0) {
+ result |= (int)MsgButtons.MK_RBUTTON;
+ }
+
+ Keys mods = ModifierKeys;
+ if ((mods & Keys.Control) != 0) {
+ result |= (int)MsgButtons.MK_CONTROL;
+ }
+
+ if ((mods & Keys.Shift) != 0) {
+ result |= (int)MsgButtons.MK_SHIFT;
+ }
+
+ result |= Delta << 16;
+
+ return (IntPtr)result;
+ }
+ private IntPtr XGetParent(IntPtr handle) {
+ IntPtr Root;
+ IntPtr Parent;
+ IntPtr Children;
+ int ChildCount;
+
+ lock (XlibLock) {
+ XQueryTree(DisplayHandle, handle, out Root, out Parent, out Children, out ChildCount);
+ }
+
+ if (Children!=IntPtr.Zero) {
+ lock (XlibLock) {
+ XFree(Children);
+ }
+ }
+ return Parent;
+ }
+
+ private int HandleError(IntPtr display, ref XErrorEvent error_event) {
+ if (ErrorExceptions) {
+ throw new XException(error_event.display, error_event.resourceid, error_event.serial, error_event.error_code, error_event.request_code, error_event.minor_code);
+ } else {
+ Console.WriteLine("X11 Error encountered: {0}{1}\n", XException.GetMessage(error_event.display, error_event.resourceid, error_event.serial, error_event.error_code, error_event.request_code, error_event.minor_code), WhereString());
+ }
+ return 0;
+ }
+
+ private void DestroyChildWindow(Control c) {
+ Hwnd hwnd;
+ int i;
+ Control[] controls;
+
+ if (c != null) {
+ controls = c.child_controls.GetAllControls ();
+
+ for (i = 0; i < controls.Length; i++) {
+ if (controls[i].IsHandleCreated) {
+ hwnd = Hwnd.ObjectFromHandle(controls[i].Handle);
+ #if DriverDebugDestroy
+ Console.WriteLine("Destroying {0} [Child of {1}]", XplatUI.Window(controls[i].Handle), XplatUI.Window(controls[i].parent.Handle));
+ #endif
+ SendMessage(controls[i].Handle, Msg.WM_DESTROY, IntPtr.Zero, IntPtr.Zero);
+ hwnd.Dispose();
+ }
+ DestroyChildWindow(controls[i]);
+ }
+ }
+ }
+
+ private void PerformNCCalc(Hwnd hwnd) {
+ XplatUIWin32.NCCALCSIZE_PARAMS ncp;
+ IntPtr ptr;
+ Rectangle rect;
+
+ rect = hwnd.DefaultClientRect;
+
+ ncp = new XplatUIWin32.NCCALCSIZE_PARAMS();
+ ptr = Marshal.AllocHGlobal(Marshal.SizeOf(ncp));
+
+ ncp.rgrc1.left = rect.Left;
+ ncp.rgrc1.top = rect.Top;
+ ncp.rgrc1.right = rect.Right;
+ ncp.rgrc1.bottom = rect.Bottom;
+
+ Marshal.StructureToPtr(ncp, ptr, true);
+ NativeWindow.WndProc(hwnd.client_window, Msg.WM_NCCALCSIZE, (IntPtr)1, ptr);
+ ncp = (XplatUIWin32.NCCALCSIZE_PARAMS)Marshal.PtrToStructure(ptr, typeof(XplatUIWin32.NCCALCSIZE_PARAMS));
+ Marshal.FreeHGlobal(ptr);
+
+ // FIXME - debug this with Menus, need to set hwnd.ClientRect
+
+ rect = new Rectangle(ncp.rgrc1.left, ncp.rgrc1.top, ncp.rgrc1.right - ncp.rgrc1.left, ncp.rgrc1.bottom - ncp.rgrc1.top);
+
+ Control c;
+ c = Control.FromHandle(hwnd.Handle);
+
+ if (hwnd.visible) {
+ XMoveResizeWindow(DisplayHandle, hwnd.client_window, rect.X, rect.Y, rect.Width, rect.Height);
+ }
+ }
+ #endregion // Private Methods
+
+ #region Callbacks
+ private void MouseHover(object sender, EventArgs e) {
+ XEvent xevent;
+ HoverState.Timer.Enabled = false;
+
+ if (HoverState.Window != IntPtr.Zero) {
+ xevent = new XEvent ();
+
+ xevent.type = XEventName.ClientMessage;
+ xevent.ClientMessageEvent.display = DisplayHandle;
+ xevent.ClientMessageEvent.window = HoverState.Window;
+ xevent.ClientMessageEvent.message_type = HoverState.Atom;
+ xevent.ClientMessageEvent.format = 32;
+ xevent.ClientMessageEvent.ptr1 = (IntPtr) (HoverState.Y << 16 | HoverState.X);
+
+ MessageQueue.EnqueueLocked (xevent);
+
+ WakeupMain ();
+ }
+ }
+
+ private void CaretCallback(object sender, EventArgs e) {
+ if (Caret.Paused) {
+ return;
+ }
+ Caret.On = !Caret.On;
+
+ XDrawLine(DisplayHandle, Caret.Hwnd, Caret.gc, Caret.X, Caret.Y, Caret.X, Caret.Y + Caret.Height);
+ }
+ #endregion // Callbacks
+
+ #region Public Properties
+
+ internal override int Caption {
+ get {
+ return 19;
+ }
+ }
+
+ internal override Size CursorSize {
+ get {
+ int x;
+ int y;
+
+ if (XQueryBestCursor(DisplayHandle, RootWindow, 32, 32, out x, out y) != 0) {
+ return new Size(x, y);
+ } else {
+ return new Size(16, 16);
+ }
+ }
+ }
+
+ internal override bool DragFullWindows {
+ get {
+ return true;
+ }
+ }
+
+ internal override Size DragSize {
+ get {
+ return new Size(4, 4);
+ }
+ }
+
+ internal override Size FrameBorderSize {
+ get {
+ throw new NotImplementedException();
+ }
+ }
+
+ internal override Size IconSize {
+ get {
+ IntPtr list;
+ XIconSize size;
+ int count;
+
+ if (XGetIconSizes(DisplayHandle, RootWindow, out list, out count) != 0) {
+ long current;
+ int largest;
+
+ current = (long)list;
+ largest = 0;
+
+ size = new XIconSize();
+
+ for (int i = 0; i < count; i++) {
+ size = (XIconSize)Marshal.PtrToStructure((IntPtr)current, size.GetType());
+ current += Marshal.SizeOf(size);
+
+ // Look for our preferred size
+ if (size.min_width == 32) {
+ XFree(list);
+ return new Size(32, 32);
+ }
+
+ if (size.max_width == 32) {
+ XFree(list);
+ return new Size(32, 32);
+ }
+
+ if (size.min_width < 32 && size.max_width > 32) {
+ int x;
+
+ // check if we can fit one
+ x = size.min_width;
+ while (x < size.max_width) {
+ x += size.width_inc;
+ if (x == 32) {
+ XFree(list);
+ return new Size(32, 32);
+ }
+ }
+ }
+
+ if (largest < size.max_width) {
+ largest = size.max_width;
+ }
+ }
+
+ // We didn't find a match or we wouldn't be here
+ return new Size(largest, largest);
+
+ } else {
+ return new Size(32, 32);
+ }
+ }
+ }
+
+ internal override int KeyboardSpeed {
+ get{
+ //
+ // A lot harder: need to do:
+ // XkbQueryExtension(0x08051008, 0xbfffdf4c, 0xbfffdf50, 0xbfffdf54, 0xbfffdf58) = 1
+ // XkbAllocKeyboard(0x08051008, 0xbfffdf4c, 0xbfffdf50, 0xbfffdf54, 0xbfffdf58) = 0x080517a8
+ // XkbGetControls(0x08051008, 1, 0x080517a8, 0xbfffdf54, 0xbfffdf58) = 0
+ //
+ // And from that we can tell the repetition rate
+ //
+ // Notice, the values must map to:
+ // [0, 31] which maps to 2.5 to 30 repetitions per second.
+ //
+ return 0;
+ }
+ }
+
+ internal override int KeyboardDelay {
+ get {
+ //
+ // Return values must range from 0 to 4, 0 meaning 250ms,
+ // and 4 meaning 1000 ms.
+ //
+ return 1; // ie, 500 ms
+ }
+ }
+
+ internal override Size MaxWindowTrackSize {
+ get {
+ return new Size (WorkingArea.Width, WorkingArea.Height);
+ }
+ }
+
+ internal override Size MinimizedWindowSize {
+ get {
+ return new Size(1, 1);
+ }
+ }
+
+ internal override Size MinimizedWindowSpacingSize {
+ get {
+ return new Size(1, 1);
+ }
+ }
+
+ internal override Size MinimumWindowSize {
+ get {
+ return new Size(1, 1);
+ }
+ }
+
+ internal override Size MinWindowTrackSize {
+ get {
+ return new Size(1, 1);
+ }
+ }
+
+ internal override Keys ModifierKeys {
+ get {
+ return Keyboard.ModifierKeys;
+ }
+ }
+
+ internal override Size SmallIconSize {
+ get {
+ IntPtr list;
+ XIconSize size;
+ int count;
+
+ if (XGetIconSizes(DisplayHandle, RootWindow, out list, out count) != 0) {
+ long current;
+ int smallest;
+
+ current = (long)list;
+ smallest = 0;
+
+ size = new XIconSize();
+
+ for (int i = 0; i < count; i++) {
+ size = (XIconSize)Marshal.PtrToStructure((IntPtr)current, size.GetType());
+ current += Marshal.SizeOf(size);
+
+ // Look for our preferred size
+ if (size.min_width == 16) {
+ XFree(list);
+ return new Size(16, 16);
+ }
+
+ if (size.max_width == 16) {
+ XFree(list);
+ return new Size(16, 16);
+ }
+
+ if (size.min_width < 16 && size.max_width > 16) {
+ int x;
+
+ // check if we can fit one
+ x = size.min_width;
+ while (x < size.max_width) {
+ x += size.width_inc;
+ if (x == 16) {
+ XFree(list);
+ return new Size(16, 16);
+ }
+ }
+ }
+
+ if (smallest == 0 || smallest > size.min_width) {
+ smallest = size.min_width;
+ }
+ }
+
+ // We didn't find a match or we wouldn't be here
+ return new Size(smallest, smallest);
+
+ } else {
+ return new Size(16, 16);
+ }
+ }
+ }
+
+ internal override int MouseButtonCount {
+ get {
+ return 3;
+ }
+ }
+
+ internal override bool MouseButtonsSwapped {
+ get {
+ return false; // FIXME - how to detect?
+ }
+ }
+
+ internal override Size MouseHoverSize {
+ get {
+ return new Size (1, 1);
+ }
+ }
+
+ internal override int MouseHoverTime {
+ get {
+ return HoverState.Interval;
+ }
+ }
+
+
+
+ internal override bool MouseWheelPresent {
+ get {
+ return true; // FIXME - how to detect?
+ }
+ }
+
+ internal override Rectangle VirtualScreen {
+ get {
+ return WorkingArea;
+ }
+ }
+
+ internal override Rectangle WorkingArea {
+ get {
+ IntPtr actual_atom;
+ int actual_format;
+ IntPtr nitems;
+ IntPtr bytes_after;
+ IntPtr prop = IntPtr.Zero;
+ int width;
+ int height;
+
+ XGetWindowProperty(DisplayHandle, RootWindow, NetAtoms[(int)NA._NET_DESKTOP_GEOMETRY], IntPtr.Zero, new IntPtr (256), false, (IntPtr)Atom.XA_CARDINAL, out actual_atom, out actual_format, out nitems, out bytes_after, ref prop);
+ if (((long)nitems == 2) && (prop != IntPtr.Zero) && IntPtr.Size == 4) {
+ width = Marshal.ReadInt32(prop, 0);
+ height = Marshal.ReadInt32(prop, 4);
+
+ XFree(prop);
+ return new Rectangle(0, 0, width, height);
+ } else {
+ XWindowAttributes attributes=new XWindowAttributes();
+
+ lock (XlibLock) {
+ XGetWindowAttributes(DisplayHandle, XRootWindow(DisplayHandle, 0), ref attributes);
+ }
+
+ return new Rectangle(0, 0, attributes.width, attributes.height);
+ }
+ }
+ }
+ #endregion // Public properties
+
+ #region Public Static Methods
+ internal override IntPtr InitializeDriver() {
+ lock (this) {
+ if (DisplayHandle==IntPtr.Zero) {
+ SetDisplay(XOpenDisplay(IntPtr.Zero));
+ }
+ }
+ return IntPtr.Zero;
+ }
+
+ internal override void ShutdownDriver(IntPtr token) {
+ lock (this) {
+ if (DisplayHandle!=IntPtr.Zero) {
+ XCloseDisplay(DisplayHandle);
+ DisplayHandle=IntPtr.Zero;
+ }
+ }
+ }
+
+ internal override void EnableThemes() {
+ ThemesEnabled = true;
+ }
+
+
+ internal override void Activate(IntPtr handle) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ if (hwnd != null) lock (XlibLock) {
+ SendNetWMMessage(hwnd.whole_window, NetAtoms[(int)NA._NET_ACTIVE_WINDOW], IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
+ //XRaiseWindow(DisplayHandle, handle);
+ }
+ return;
+ }
+
+ internal override void AudibleAlert() {
+ XBell(DisplayHandle, 0);
+ return;
+ }
+
+
+ internal override void CaretVisible(IntPtr handle, bool visible) {
+ // Visible is cumulative; two hides require two shows before the caret is visible again
+ if (Caret.Hwnd == handle) {
+ if (visible) {
+ if (!Caret.Visible) {
+ Caret.Visible = true;
+ ShowCaret();
+ Caret.Timer.Start();
+ }
+ } else {
+ Caret.Visible = false;
+ Caret.Timer.Stop();
+ HideCaret();
+ }
+ }
+ }
+
+ internal override bool CalculateWindowRect(ref Rectangle ClientRect, int Style, int ExStyle, Menu menu, out Rectangle WindowRect) {
+ FormBorderStyle border_style;
+ TitleStyle title_style;
+ int caption_height;
+ int tool_caption_height;
+
+ DeriveStyles(Style, ExStyle, out border_style, out title_style,
+ out caption_height, out tool_caption_height);
+
+ WindowRect = Hwnd.GetWindowRectangle(border_style, menu, title_style,
+ caption_height, tool_caption_height,
+ ClientRect);
+
+ return true;
+ }
+
+ internal override void ClientToScreen(IntPtr handle, ref int x, ref int y) {
+ int dest_x_return;
+ int dest_y_return;
+ IntPtr child;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ lock (XlibLock) {
+ XTranslateCoordinates(DisplayHandle, hwnd.client_window, RootWindow, x, y, out dest_x_return, out dest_y_return, out child);
+ }
+
+ x = dest_x_return;
+ y = dest_y_return;
+ }
+
+ internal override int[] ClipboardAvailableFormats(IntPtr handle) {
+ DataFormats.Format f;
+ int[] result;
+
+ f = DataFormats.Format.List;
+
+ if (XGetSelectionOwner(DisplayHandle, NetAtoms[(int)NA.CLIPBOARD]) == IntPtr.Zero) {
+ return null;
+ }
+
+ Clipboard.Formats = new ArrayList();
+
+ while (f != null) {
+ XConvertSelection(DisplayHandle, NetAtoms[(int)NA.CLIPBOARD], (IntPtr)f.Id, (IntPtr)f.Id, FosterParent, IntPtr.Zero);
+
+ Clipboard.Enumerating = true;
+ while (Clipboard.Enumerating) {
+ UpdateMessageQueue();
+ }
+ f = f.Next;
+ }
+
+ result = new int[Clipboard.Formats.Count];
+
+ for (int i = 0; i < Clipboard.Formats.Count; i++) {
+ result[i] = (int)Clipboard.Formats[i];
+ }
+
+ Clipboard.Formats = null;
+ return result;
+ }
+
+ internal override void ClipboardClose(IntPtr handle) {
+ if (handle != ClipMagic) {
+ throw new ArgumentException("handle is not a valid clipboard handle");
+ }
+ return;
+ }
+
+ internal override int ClipboardGetID(IntPtr handle, string format) {
+ if (handle != ClipMagic) {
+ throw new ArgumentException("handle is not a valid clipboard handle");
+ }
+
+ if (format == "Text" ) return (int)Atom.XA_STRING;
+ else if (format == "Bitmap" ) return (int)Atom.XA_BITMAP;
+ //else if (format == "MetaFilePict" ) return 3;
+ //else if (format == "SymbolicLink" ) return 4;
+ //else if (format == "DataInterchangeFormat" ) return 5;
+ //else if (format == "Tiff" ) return 6;
+ else if (format == "OEMText" ) return XInternAtom(DisplayHandle, "COMPOUND_TEXT", false).ToInt32();
+ else if (format == "DeviceIndependentBitmap" ) return (int)Atom.XA_PIXMAP;
+ else if (format == "Palette" ) return (int)Atom.XA_COLORMAP; // Useless
+ //else if (format == "PenData" ) return 10;
+ //else if (format == "RiffAudio" ) return 11;
+ //else if (format == "WaveAudio" ) return 12;
+ else if (format == "UnicodeText" ) return XInternAtom(DisplayHandle, "UTF8_STRING", false).ToInt32();
+ //else if (format == "EnhancedMetafile" ) return 14;
+ //else if (format == "FileDrop" ) return 15;
+ //else if (format == "Locale" ) return 16;
+
+ return XInternAtom(DisplayHandle, format, false).ToInt32();
+ }
+
+ internal override IntPtr ClipboardOpen() {
+ return ClipMagic;
+ }
+
+ internal override object ClipboardRetrieve(IntPtr handle, int type, XplatUI.ClipboardToObject converter) {
+ XConvertSelection(DisplayHandle, NetAtoms[(int)NA.CLIPBOARD], (IntPtr)type, (IntPtr)type, FosterParent, IntPtr.Zero);
+
+ Clipboard.Retrieving = true;
+ while (Clipboard.Retrieving) {
+ UpdateMessageQueue();
+ }
+
+ return Clipboard.Item;
+ }
+
+ internal override void ClipboardStore(IntPtr handle, object obj, int type, XplatUI.ObjectToClipboard converter) {
+ Clipboard.Item = obj;
+ Clipboard.Type = type;
+ Clipboard.Converter = converter;
+
+ if (obj != null) {
+ XSetSelectionOwner(DisplayHandle, NetAtoms[(int)NA.CLIPBOARD], FosterParent, IntPtr.Zero);
+ } else {
+ // Clearing the selection
+ XSetSelectionOwner(DisplayHandle, NetAtoms[(int)NA.CLIPBOARD], IntPtr.Zero, IntPtr.Zero);
+ }
+ }
+
+ internal override void CreateCaret(IntPtr handle, int width, int height) {
+ XGCValues gc_values;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ if (Caret.Hwnd != IntPtr.Zero) {
+ DestroyCaret(Caret.Hwnd);
+ }
+
+ Caret.Hwnd = handle;
+ Caret.Window = hwnd.client_window;
+ Caret.Width = width;
+ Caret.Height = height;
+ Caret.Visible = false;
+ Caret.On = false;
+
+ gc_values = new XGCValues();
+ gc_values.line_width = width;
+
+ Caret.gc = XCreateGC(DisplayHandle, Caret.Window, new IntPtr ((int)GCFunction.GCLineWidth), ref gc_values);
+ if (Caret.gc == IntPtr.Zero) {
+ Caret.Hwnd = IntPtr.Zero;
+ return;
+ }
+
+ XSetFunction(DisplayHandle, Caret.gc, GXFunction.GXinvert);
+ }
+
+ internal override IntPtr CreateWindow(CreateParams cp) {
+ XSetWindowAttributes Attributes;
+ Hwnd hwnd;
+ int X;
+ int Y;
+ int Width;
+ int Height;
+ IntPtr ParentHandle;
+ IntPtr WholeWindow;
+ IntPtr ClientWindow;
+ Rectangle ClientRect;
+ SetWindowValuemask ValueMask;
+
+
+ hwnd = new Hwnd();
+
+ Attributes = new XSetWindowAttributes();
+ X = cp.X;
+ Y = cp.Y;
+ Width = cp.Width;
+ Height = cp.Height;
+
+ if (Width<1) Width=1;
+ if (Height<1) Height=1;
+
+ if (cp.Parent != IntPtr.Zero) {
+ ParentHandle = Hwnd.ObjectFromHandle(cp.Parent).client_window;
+ } else {
+ if ((cp.Style & (int)WindowStyles.WS_CHILD) != 0) {
+ // We need to use our foster parent window until this poor child gets it's parent assigned
+ ParentHandle=FosterParent;
+ } else if ((cp.Style & (int)WindowStyles.WS_POPUP) != 0) {
+ ParentHandle=RootWindow;
+ } else {
+ // Default position on screen, if window manager doesn't place us somewhere else
+ if (X<1) X = 50;
+ if (Y<1) Y = 50;
+ ParentHandle=RootWindow;
+ }
+ }
+
+ ValueMask = SetWindowValuemask.BitGravity | SetWindowValuemask.WinGravity;
+
+ Attributes.bit_gravity = Gravity.NorthWestGravity;
+ Attributes.win_gravity = Gravity.NorthWestGravity;
+
+ // Save what's under the toolwindow
+ if ((cp.ExStyle & (int)WindowExStyles.WS_EX_TOOLWINDOW) != 0) {
+ Attributes.save_under = true;
+ ValueMask |= SetWindowValuemask.SaveUnder;
+ }
+
+
+ // If we're a popup without caption we override the WM
+ if ((cp.Style & ((int)WindowStyles.WS_POPUP)) != 0) {
+ if ((cp.Style & (int)WindowStyles.WS_CAPTION) == 0) {
+ Attributes.override_redirect = true;
+ ValueMask |= SetWindowValuemask.OverrideRedirect;
+ }
+ }
+
+ hwnd.x = X;
+ hwnd.y = Y;
+ hwnd.width = Width;
+ hwnd.height = Height;
+ hwnd.parent = Hwnd.ObjectFromHandle(cp.Parent);
+
+ if ((cp.Style & ((int)WindowStyles.WS_DISABLED)) != 0) {
+ hwnd.enabled = false;
+ }
+
+ ClientRect = hwnd.ClientRect;
+ ClientWindow = IntPtr.Zero;
+
+ lock (XlibLock) {
+ WholeWindow = XCreateWindow(DisplayHandle, ParentHandle, X, Y, Width, Height, 0, (int)CreateWindowArgs.CopyFromParent, (int)CreateWindowArgs.InputOutput, IntPtr.Zero, new UIntPtr ((uint)ValueMask), ref Attributes);
+ if (WholeWindow != IntPtr.Zero) {
+ ValueMask &= ~(SetWindowValuemask.OverrideRedirect | SetWindowValuemask.SaveUnder);
+
+ if (CustomVisual != IntPtr.Zero && CustomColormap != IntPtr.Zero) {
+ ValueMask = SetWindowValuemask.ColorMap;
+ Attributes.colormap = CustomColormap;
+ }
+ ClientWindow = XCreateWindow(DisplayHandle, WholeWindow, ClientRect.X, ClientRect.Y, ClientRect.Width, ClientRect.Height, 0, (int)CreateWindowArgs.CopyFromParent, (int)CreateWindowArgs.InputOutput, CustomVisual, new UIntPtr ((uint)ValueMask), ref Attributes);
+ }
+ }
+
+ if ((WholeWindow == IntPtr.Zero) || (ClientWindow == IntPtr.Zero)) {
+ throw new Exception("Could not create X11 windows");
+ }
+
+ hwnd.WholeWindow = WholeWindow;
+ hwnd.ClientWindow = ClientWindow;
+
+ #if DriverDebug || DriverDebugCreate
+ Console.WriteLine("Created window {0:X} / {1:X} parent {2:X}, Style {3}, ExStyle {4}", ClientWindow.ToInt32(), WholeWindow.ToInt32(), hwnd.parent != null ? hwnd.parent.Handle.ToInt32() : 0, (WindowStyles)cp.Style, (WindowExStyles)cp.ExStyle);
+ #endif
+
+ lock (XlibLock) {
+ XSelectInput(DisplayHandle, hwnd.whole_window, new IntPtr ((int)SelectInputMask));
+ XSelectInput(DisplayHandle, hwnd.client_window, new IntPtr ((int)SelectInputMask));
+
+ if ((cp.Style & (int)WindowStyles.WS_VISIBLE) != 0) {
+ XMapWindow(DisplayHandle, hwnd.whole_window);
+ XMapWindow(DisplayHandle, hwnd.client_window);
+ hwnd.visible = true;
+ }
+ }
+
+ if ((cp.ExStyle & (int) WindowExStyles.WS_EX_TOPMOST) != 0) {
+ Console.WriteLine ("Setting transient: " + XSetTransientForHint (DisplayHandle, hwnd.whole_window, RootWindow));
+ }
+
+ SetWMStyles(hwnd, cp);
+
+ if ((cp.Style & (int)WindowStyles.WS_MINIMIZE) != 0) {
+ SetWindowState(hwnd.Handle, FormWindowState.Minimized);
+ } else if ((cp.Style & (int)WindowStyles.WS_MAXIMIZE) != 0) {
+ SetWindowState(hwnd.Handle, FormWindowState.Maximized);
+ }
+
+ // for now make all windows dnd enabled
+ Dnd.SetAllowDrop (hwnd, true);
+
+ // Set caption/window title
+ Text(hwnd.Handle, cp.Caption);
+
+ return hwnd.Handle;
+ }
+
+ internal override IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
+ CreateParams create_params = new CreateParams();
+
+ create_params.Caption = "";
+ create_params.X = X;
+ create_params.Y = Y;
+ create_params.Width = Width;
+ create_params.Height = Height;
+
+ create_params.ClassName=XplatUI.DefaultClassName;
+ create_params.ClassStyle = 0;
+ create_params.ExStyle=0;
+ create_params.Parent=IntPtr.Zero;
+ create_params.Param=0;
+
+ return CreateWindow(create_params);
+ }
+
+ internal override IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
+ IntPtr cursor;
+ Bitmap cursor_bitmap;
+ Bitmap cursor_mask;
+ Byte[] cursor_bits;
+ Byte[] mask_bits;
+ Color c_pixel;
+ Color m_pixel;
+ int width;
+ int height;
+ IntPtr cursor_pixmap;
+ IntPtr mask_pixmap;
+ XColor fg;
+ XColor bg;
+ bool and;
+ bool xor;
+
+ if (XQueryBestCursor(DisplayHandle, RootWindow, bitmap.Width, bitmap.Height, out width, out height) == 0) {
+ return IntPtr.Zero;
+ }
+
+ // Win32 only allows creation cursors of a certain size
+ if ((bitmap.Width != width) || (bitmap.Width != height)) {
+ cursor_bitmap = new Bitmap(bitmap, new Size(width, height));
+ cursor_mask = new Bitmap(mask, new Size(width, height));
+ } else {
+ cursor_bitmap = bitmap;
+ cursor_mask = mask;
+ }
+
+ width = cursor_bitmap.Width;
+ height = cursor_bitmap.Height;
+
+ cursor_bits = new Byte[(width / 8) * height];
+ mask_bits = new Byte[(width / 8) * height];
+
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ c_pixel = cursor_bitmap.GetPixel(x, y);
+ m_pixel = cursor_mask.GetPixel(x, y);
+
+ and = c_pixel == cursor_pixel;
+ xor = m_pixel == mask_pixel;
+
+ if (!and && !xor) {
+ // Black
+ // cursor_bits[y * width / 8 + x / 8] &= (byte)~((1 << (x % 8))); // The bit already is 0
+ mask_bits[y * width / 8 + x / 8] |= (byte)(1 << (x % 8));
+ } else if (and && !xor) {
+ // White
+ cursor_bits[y * width / 8 + x / 8] |= (byte)(1 << (x % 8));
+ mask_bits[y * width / 8 + x / 8] |= (byte)(1 << (x % 8));
+#if notneeded
+ } else if (and && !xor) {
+ // Screen
+ } else if (and && xor) {
+ // Inverse Screen
+
+ // X11 doesn't know the 'reverse screen' concept, so we'll treat them the same
+ // we want both to be 0 so nothing to be done
+ //cursor_bits[y * width / 8 + x / 8] &= (byte)~((1 << (x % 8)));
+ //mask_bits[y * width / 8 + x / 8] |= (byte)(01 << (x % 8));
+#endif
+ }
+ }
+ }
+
+ cursor_pixmap = XCreatePixmapFromBitmapData(DisplayHandle, RootWindow, cursor_bits, width, height, (IntPtr)1, (IntPtr)0, 1);
+ mask_pixmap = XCreatePixmapFromBitmapData(DisplayHandle, RootWindow, mask_bits, width, height, (IntPtr)1, (IntPtr)0, 1);
+ fg = new XColor();
+ bg = new XColor();
+
+ fg.pixel = XWhitePixel(DisplayHandle, ScreenNo);
+ fg.red = (ushort)65535;
+ fg.green = (ushort)65535;
+ fg.blue = (ushort)65535;
+
+ bg.pixel = XBlackPixel(DisplayHandle, ScreenNo);
+
+ cursor = XCreatePixmapCursor(DisplayHandle, cursor_pixmap, mask_pixmap, ref fg, ref bg, xHotSpot, yHotSpot);
+
+ XFreePixmap(DisplayHandle, cursor_pixmap);
+ XFreePixmap(DisplayHandle, mask_pixmap);
+
+ return cursor;
+ }
+
+ internal override IntPtr DefineStdCursor(StdCursor id) {
+ CursorFontShape shape;
+ IntPtr cursor;
+
+ // FIXME - define missing shapes
+
+ switch (id) {
+ case StdCursor.AppStarting: {
+ shape = CursorFontShape.XC_watch;
+ break;
+ }
+
+ case StdCursor.Arrow: {
+ return IntPtr.Zero;
+ }
+
+ case StdCursor.Cross: {
+ shape = CursorFontShape.XC_crosshair;
+ break;
+ }
+
+ case StdCursor.Default: {
+ return IntPtr.Zero;
+ }
+
+ case StdCursor.Hand: {
+ shape = CursorFontShape.XC_hand1;
+ break;
+ }
+
+ case StdCursor.Help: {
+ shape = CursorFontShape.XC_question_arrow;
+ break;
+ }
+
+ case StdCursor.HSplit: {
+ shape = CursorFontShape.XC_sb_v_double_arrow;
+ break;
+ }
+
+ case StdCursor.IBeam: {
+ shape = CursorFontShape.XC_xterm;
+ break;
+ }
+
+ case StdCursor.No: {
+ shape = CursorFontShape.XC_circle;
+ break;
+ }
+
+ case StdCursor.NoMove2D: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.NoMoveHoriz: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.NoMoveVert: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.PanEast: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.PanNE: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.PanNorth: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.PanNW: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.PanSE: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.PanSouth: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.PanSW: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.PanWest: {
+ shape = CursorFontShape.XC_sizing;
+ break;
+ }
+
+ case StdCursor.SizeAll: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.SizeNESW: {
+ shape = CursorFontShape.XC_top_right_corner;
+ break;
+ }
+
+ case StdCursor.SizeNS: {
+ shape = CursorFontShape.XC_sb_v_double_arrow;
+ break;
+ }
+
+ case StdCursor.SizeNWSE: {
+ shape = CursorFontShape.XC_top_left_corner;
+ break;
+ }
+
+ case StdCursor.SizeWE: {
+ shape = CursorFontShape.XC_sb_h_double_arrow;
+ break;
+ }
+
+ case StdCursor.UpArrow: {
+ shape = CursorFontShape.XC_center_ptr;
+ break;
+ }
+
+ case StdCursor.VSplit: {
+ shape = CursorFontShape.XC_sb_h_double_arrow;
+ break;
+ }
+
+ case StdCursor.WaitCursor: {
+ shape = CursorFontShape.XC_watch;
+ break;
+ }
+
+ default: {
+ return IntPtr.Zero;
+ }
+ }
+
+ lock (XlibLock) {
+ cursor = XCreateFontCursor(DisplayHandle, shape);
+ }
+ return cursor;
+ }
+
+ internal override IntPtr DefWndProc(ref Message msg) {
+ switch ((Msg)msg.Msg) {
+ case Msg.WM_SETCURSOR: {
+ Hwnd hwnd;
+ // Pass to parent window first
+ hwnd = Hwnd.GetObjectFromWindow(msg.HWnd);
+ while ((hwnd.parent != null) && (msg.Result == IntPtr.Zero)) {
+ hwnd = hwnd.parent;
+ NativeWindow.WndProc(hwnd.Handle, Msg.WM_SETCURSOR, msg.HWnd, msg.LParam);
+ }
+
+ if (msg.Result == IntPtr.Zero) {
+ IntPtr handle;
+
+ switch((HitTest)(msg.LParam.ToInt32() & 0xffff)) {
+ case HitTest.HTBOTTOM: handle = Cursors.SizeNS.handle; break;
+ case HitTest.HTBORDER: handle = Cursors.SizeNS.handle; break;
+ case HitTest.HTBOTTOMLEFT: handle = Cursors.SizeNESW.handle; break;
+ case HitTest.HTBOTTOMRIGHT: handle = Cursors.SizeNWSE.handle; break;
+ case HitTest.HTERROR: if ((msg.LParam.ToInt32() >> 16) == (int)Msg.WM_LBUTTONDOWN) {
+ AudibleAlert();
+ }
+ handle = Cursors.Default.handle;
+ break;
+
+ case HitTest.HTHELP: handle = Cursors.Help.handle; break;
+ case HitTest.HTLEFT: handle = Cursors.SizeWE.handle; break;
+ case HitTest.HTRIGHT: handle = Cursors.SizeWE.handle; break;
+ case HitTest.HTTOP: handle = Cursors.SizeNS.handle; break;
+ case HitTest.HTTOPLEFT: handle = Cursors.SizeNWSE.handle; break;
+ case HitTest.HTTOPRIGHT: handle = Cursors.SizeNESW.handle; break;
+
+ #if SameAsDefault
+ case HitTest.HTGROWBOX:
+ case HitTest.HTSIZE:
+ case HitTest.HTZOOM:
+ case HitTest.HTVSCROLL:
+ case HitTest.HTSYSMENU:
+ case HitTest.HTREDUCE:
+ case HitTest.HTNOWHERE:
+ case HitTest.HTMAXBUTTON:
+ case HitTest.HTMINBUTTON:
+ case HitTest.HTMENU:
+ case HitTest.HSCROLL:
+ case HitTest.HTBOTTOM:
+ case HitTest.HTCAPTION:
+ case HitTest.HTCLIENT:
+ case HitTest.HTCLOSE:
+ #endif
+ default: handle = Cursors.Default.handle; break;
+ }
+ SetCursor(msg.HWnd, handle);
+ }
+ return (IntPtr)1;
+ }
+ }
+ return IntPtr.Zero;
+ }
+
+ internal override void DestroyCaret(IntPtr handle) {
+ if (Caret.Hwnd == handle) {
+ if (Caret.Visible == true) {
+ Caret.Timer.Stop();
+ HideCaret();
+ }
+ if (Caret.gc != IntPtr.Zero) {
+ XFreeGC(DisplayHandle, Caret.gc);
+ Caret.gc = IntPtr.Zero;
+ }
+ Caret.Hwnd = IntPtr.Zero;
+ Caret.Visible = false;
+ Caret.On = false;
+ }
+ }
+
+ internal override void DestroyCursor(IntPtr cursor) {
+ lock (XlibLock) {
+ XFreeCursor(DisplayHandle, cursor);
+ }
+ }
+
+ internal override void DestroyWindow(IntPtr handle) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ if (hwnd == null) {
+ #if DriverDebug || DriverDebugDestroy
+ Console.WriteLine("window {0:X} already destroyed", handle.ToInt32());
+ #endif
+ return;
+ }
+
+ #if DriverDebug || DriverDebugDestroy
+ Console.WriteLine("Destroying window {0:X}", handle.ToInt32());
+ #endif
+
+ // Make sure if the caret is in the window, that we destroy the caret, too
+ if (Caret.Hwnd == hwnd.client_window) {
+ DestroyCaret(handle);
+ }
+
+ // Send destroy message
+ SendMessage(handle, Msg.WM_DESTROY, IntPtr.Zero, IntPtr.Zero);
+
+ // Mark our children as gone as well
+ DestroyChildWindow(Control.ControlNativeWindow.ControlFromHandle(handle));
+
+ lock (XlibLock) {
+ if (hwnd.client_window != IntPtr.Zero) {
+ XDestroyWindow(DisplayHandle, hwnd.client_window);
+ }
+
+ if ((hwnd.whole_window != IntPtr.Zero) && (hwnd.whole_window != hwnd.client_window)) {
+ XDestroyWindow(DisplayHandle, hwnd.whole_window);
+ }
+ }
+ hwnd.Dispose();
+ }
+
+ internal override IntPtr DispatchMessage(ref MSG msg) {
+ return NativeWindow.WndProc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
+ }
+
+ internal override void DrawReversibleRectangle(IntPtr handle, Rectangle rect, int line_width) {
+ Hwnd hwnd;
+ XGCValues gc_values;
+ IntPtr gc;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ gc_values = new XGCValues();
+
+ gc_values.subwindow_mode = GCSubwindowMode.IncludeInferiors;
+ gc_values.line_width = line_width;
+ gc_values.foreground = XBlackPixel(DisplayHandle, ScreenNo);
+
+ // This logic will give us true rubber bands: (libsx, SANE_XOR)
+ //mask = foreground ^ background;
+ //XSetForeground(DisplayHandle, gc, 0xffffffff);
+ //XSetBackground(DisplayHandle, gc, background);
+ //XSetFunction(DisplayHandle, gc, GXxor);
+ //XSetPlaneMask(DisplayHandle, gc, mask);
+
+
+ gc = XCreateGC(DisplayHandle, hwnd.client_window, new IntPtr ((int) (GCFunction.GCSubwindowMode | GCFunction.GCLineWidth | GCFunction.GCForeground)), ref gc_values);
+ uint foreground;
+ uint background;
+
+ Control control;
+ control = Control.FromHandle(handle);
+
+ XColor xcolor = new XColor();
+
+ xcolor.red = (ushort)(control.ForeColor.R * 257);
+ xcolor.green = (ushort)(control.ForeColor.G * 257);
+ xcolor.blue = (ushort)(control.ForeColor.B * 257);
+ XAllocColor(DisplayHandle, DefaultColormap, ref xcolor);
+ foreground = (uint)xcolor.pixel.ToInt32();
+
+ xcolor.red = (ushort)(control.BackColor.R * 257);
+ xcolor.green = (ushort)(control.BackColor.G * 257);
+ xcolor.blue = (ushort)(control.BackColor.B * 257);
+ XAllocColor(DisplayHandle, DefaultColormap, ref xcolor);
+ background = (uint)xcolor.pixel.ToInt32();
+
+ uint mask = foreground ^ background;
+
+ XSetForeground(DisplayHandle, gc, (UIntPtr)0xffffffff);
+ XSetBackground(DisplayHandle, gc, (UIntPtr)background);
+ XSetFunction(DisplayHandle, gc, GXFunction.GXxor);
+ XSetPlaneMask(DisplayHandle, gc, (IntPtr)mask);
+
+ if ((rect.Width > 0) && (rect.Height > 0)) {
+ XDrawRectangle(DisplayHandle, hwnd.client_window, gc, rect.Left, rect.Top, rect.Width, rect.Height);
+ } else {
+ if (rect.Width > 0) {
+ XDrawLine(DisplayHandle, hwnd.client_window, gc, rect.X, rect.Y, rect.Right, rect.Y);
+ } else {
+ XDrawLine(DisplayHandle, hwnd.client_window, gc, rect.X, rect.Y, rect.X, rect.Bottom);
+ }
+ }
+ XFreeGC(DisplayHandle, gc);
+ }
+
+ internal override void DoEvents() {
+ MSG msg = new MSG ();
+
+ if (OverrideCursorHandle != IntPtr.Zero) {
+ OverrideCursorHandle = IntPtr.Zero;
+ }
+
+ while (PeekMessage(ref msg, IntPtr.Zero, 0, 0, (uint)PeekMessageFlags.PM_REMOVE)) {
+ TranslateMessage (ref msg);
+ DispatchMessage (ref msg);
+ }
+ }
+
+ internal override void EnableWindow(IntPtr handle, bool Enable) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+ if (hwnd != null) {
+ hwnd.Enabled = Enable;
+ }
+ }
+
+ internal override void EndLoop(Thread thread) {
+ // This is where we one day will shut down the loop for the thread
+ }
+
+
+ internal override IntPtr GetActive() {
+ IntPtr actual_atom;
+ int actual_format;
+ IntPtr nitems;
+ IntPtr bytes_after;
+ IntPtr prop = IntPtr.Zero;
+ IntPtr active = IntPtr.Zero;
+
+ XGetWindowProperty(DisplayHandle, RootWindow, NetAtoms[(int)NA._NET_ACTIVE_WINDOW], IntPtr.Zero, new IntPtr (1), false, (IntPtr)Atom.XA_WINDOW, out actual_atom, out actual_format, out nitems, out bytes_after, ref prop);
+ if (((long)nitems > 0) && (prop != IntPtr.Zero)) {
+ active = (IntPtr)Marshal.ReadInt32(prop);
+ XFree(prop);
+ }
+
+ if (active != IntPtr.Zero) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.GetObjectFromWindow(active);
+ if (hwnd != null) {
+ active = hwnd.Handle;
+ } else {
+ active = IntPtr.Zero;
+ }
+ }
+ return active;
+ }
+
+ internal override void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
+ throw new NotImplementedException ();
+ }
+
+ internal override void GetDisplaySize(out Size size) {
+ XWindowAttributes attributes=new XWindowAttributes();
+
+ lock (XlibLock) {
+ // FIXME - use _NET_WM messages instead?
+ XGetWindowAttributes(DisplayHandle, XRootWindow(DisplayHandle, 0), ref attributes);
+ }
+
+ size = new Size(attributes.width, attributes.height);
+ }
+
+ internal override SizeF GetAutoScaleSize(Font font) {
+ Graphics g;
+ float width;
+ string magic_string = "The quick brown fox jumped over the lazy dog.";
+ double magic_number = 44.549996948242189;
+
+ g = Graphics.FromHwnd(FosterParent);
+
+ width = (float) (g.MeasureString (magic_string, font).Width / magic_number);
+ return new SizeF(width, font.Height);
+ }
+
+ internal override IntPtr GetParent(IntPtr handle) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+ if (hwnd != null && hwnd.parent != null) {
+ return hwnd.parent.Handle;
+ }
+ return IntPtr.Zero;
+ }
+
+ internal override void GetCursorPos(IntPtr handle, out int x, out int y) {
+ IntPtr use_handle;
+ IntPtr root;
+ IntPtr child;
+ int root_x;
+ int root_y;
+ int win_x;
+ int win_y;
+ int keys_buttons;
+
+ if (handle != IntPtr.Zero) {
+ use_handle = Hwnd.ObjectFromHandle(handle).client_window;
+ } else {
+ use_handle = RootWindow;
+ }
+
+ lock (XlibLock) {
+ XQueryPointer(DisplayHandle, use_handle, out root, out child, out root_x, out root_y, out win_x, out win_y, out keys_buttons);
+ }
+
+ if (handle != IntPtr.Zero) {
+ x = win_x;
+ y = win_y;
+ } else {
+ x = root_x;
+ y = root_y;
+ }
+ }
+
+ internal override bool GetFontMetrics(Graphics g, Font font, out int ascent, out int descent) {
+ return GetFontMetrics(g.GetHdc(), font.ToHfont(), out ascent, out descent);
+ }
+
+ internal override Point GetMenuOrigin(IntPtr handle) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ if (hwnd != null) {
+ return hwnd.MenuOrigin;
+ }
+ return Point.Empty;
+ }
+
+ internal override bool GetMessage(ref MSG msg, IntPtr handle, int wFilterMin, int wFilterMax) {
+ XEvent xevent;
+ bool client;
+ Hwnd hwnd;
+
+ ProcessNextMessage:
+
+ if (MessageQueue.Count > 0) {
+ xevent = (XEvent) MessageQueue.Dequeue ();
+ } else {
+ UpdateMessageQueue ();
+
+ if (MessageQueue.Count > 0) {
+ xevent = (XEvent) MessageQueue.Dequeue ();
+ } else {
+ if (!PostQuitState) {
+ msg.hwnd= IntPtr.Zero;
+ msg.message = Msg.WM_ENTERIDLE;
+ return true;
+ }
+
+ // We reset ourselves so GetMessage can be called again
+ PostQuitState = false;
+
+ return false;
+ }
+ }
+
+ // FIXME - handle filtering
+
+ hwnd = Hwnd.GetObjectFromWindow(xevent.AnyEvent.window);
+
+ // Handle messages for windows that are already or are about to be destroyed
+ if (hwnd == null) {
+ #if DriverDebug
+ Console.WriteLine("GetMessage(): Got message {0} for non-existent or already destroyed window {1:X}", xevent.type, xevent.AnyEvent.window.ToInt32());
+ #endif
+ goto ProcessNextMessage;
+ }
+
+ if (hwnd.client_window == xevent.AnyEvent.window) {
+ client = true;
+ //Console.WriteLine("Client message, sending to window {0:X}", msg.hwnd.ToInt32());
+ } else {
+ client = false;
+ //Console.WriteLine("Non-Client message, sending to window {0:X}", msg.hwnd.ToInt32());
+ }
+
+ msg.hwnd = hwnd.Handle;
+
+ //
+ // If you add a new event to this switch make sure to add it in
+ // UpdateMessage also unless it is not coming through the X event system.
+ //
+ switch(xevent.type) {
+ case XEventName.KeyPress: {
+ Keyboard.KeyEvent (FocusWindow, xevent, ref msg);
+ break;
+ }
+
+ case XEventName.KeyRelease: {
+ Keyboard.KeyEvent (FocusWindow, xevent, ref msg);
+ break;
+ }
+
+ case XEventName.ButtonPress: {
+ switch(xevent.ButtonEvent.button) {
+ case 1: {
+ MouseState |= MouseButtons.Left;
+ if (client) {
+ msg.message = Msg.WM_LBUTTONDOWN;
+ } else {
+ msg.message = Msg.WM_NCLBUTTONDOWN;
+ WholeToScreen (msg.hwnd, ref xevent.ButtonEvent.x, ref xevent.ButtonEvent.y);
+ }
+ // TODO: For WM_NCLBUTTONDOWN wParam specifies a hit-test value not the virtual keys down
+ msg.wParam=GetMousewParam(0);
+ break;
+ }
+
+ case 2: {
+ MouseState |= MouseButtons.Middle;
+ if (client) {
+ msg.message = Msg.WM_MBUTTONDOWN;
+ } else {
+ msg.message = Msg.WM_NCMBUTTONDOWN;
+ WholeToScreen (msg.hwnd, ref xevent.ButtonEvent.x, ref xevent.ButtonEvent.y);
+ }
+ msg.wParam=GetMousewParam(0);
+ break;
+ }
+
+ case 3: {
+ MouseState |= MouseButtons.Right;
+ if (client) {
+ msg.message = Msg.WM_RBUTTONDOWN;
+ } else {
+ msg.message = Msg.WM_NCRBUTTONDOWN;
+ WholeToScreen (msg.hwnd, ref xevent.ButtonEvent.x, ref xevent.ButtonEvent.y);
+ }
+ msg.wParam=GetMousewParam(0);
+ break;
+ }
+
+ case 4: {
+ msg.message=Msg.WM_MOUSEWHEEL;
+ msg.wParam=GetMousewParam(120);
+ break;
+ }
+
+ case 5: {
+ msg.message=Msg.WM_MOUSEWHEEL;
+ msg.wParam=GetMousewParam(-120);
+ break;
+ }
+
+ }
+
+ msg.lParam=(IntPtr) (xevent.ButtonEvent.y << 16 | xevent.ButtonEvent.x);
+ MousePosition.X = xevent.ButtonEvent.x;
+ MousePosition.Y = xevent.ButtonEvent.y;
+
+ if (!hwnd.Enabled) {
+ IntPtr dummy;
+
+ msg.hwnd = hwnd.EnabledHwnd;
+ XTranslateCoordinates(DisplayHandle, xevent.AnyEvent.window, Hwnd.ObjectFromHandle(msg.hwnd).ClientWindow, xevent.ButtonEvent.x, xevent.ButtonEvent.y, out xevent.ButtonEvent.x, out xevent.ButtonEvent.y, out dummy);
+ msg.lParam = (IntPtr)(MousePosition.Y << 16 | MousePosition.X);
+ }
+
+ if (Grab.Hwnd != IntPtr.Zero) {
+ msg.hwnd = Grab.Hwnd;
+ }
+
+ if (!ClickPending.Pending) {
+ ClickPending.Pending = true;
+ ClickPending.Hwnd = msg.hwnd;
+ ClickPending.Message = msg.message;
+ ClickPending.wParam = msg.wParam;
+ ClickPending.lParam = msg.lParam;
+ ClickPending.Time = (long)xevent.ButtonEvent.time;
+ } else {
+ if ((((long)xevent.ButtonEvent.time - ClickPending.Time) < DoubleClickInterval) && (msg.wParam == ClickPending.wParam) && (msg.lParam == ClickPending.lParam) && (msg.message == ClickPending.Message)) {
+ // Looks like a genuine double click, clicked twice on the same spot with the same keys
+ switch(xevent.ButtonEvent.button) {
+ case 1: {
+ msg.message = client ? Msg.WM_LBUTTONDBLCLK : Msg.WM_NCLBUTTONDBLCLK;
+ break;
+ }
+
+ case 2: {
+ msg.message = client ? Msg.WM_MBUTTONDBLCLK : Msg.WM_NCMBUTTONDBLCLK;
+ break;
+ }
+
+ case 3: {
+ msg.message = client ? Msg.WM_RBUTTONDBLCLK : Msg.WM_NCRBUTTONDBLCLK;
+ break;
+ }
+ }
+ }
+ ClickPending.Pending = false;
+ }
+
+ break;
+ }
+
+ case XEventName.ButtonRelease: {
+ Dnd.HandleButtonRelease (ref xevent);
+ switch(xevent.ButtonEvent.button) {
+ case 1: {
+ MouseState &= ~MouseButtons.Left;
+ if (client) {
+ msg.message = Msg.WM_LBUTTONUP;
+ } else {
+ msg.message = Msg.WM_NCLBUTTONUP;
+ WholeToScreen (msg.hwnd, ref xevent.ButtonEvent.x, ref xevent.ButtonEvent.y);
+ }
+ msg.wParam=GetMousewParam(0);
+ break;
+ }
+
+ case 2: {
+ MouseState &= ~MouseButtons.Middle;
+ if (client) {
+ msg.message = Msg.WM_MBUTTONUP;
+ } else {
+ msg.message = Msg.WM_NCMBUTTONUP;
+ WholeToScreen (msg.hwnd, ref xevent.ButtonEvent.x, ref xevent.ButtonEvent.y);
+ }
+ msg.wParam=GetMousewParam(0);
+ break;
+ }
+
+ case 3: {
+ MouseState &= ~MouseButtons.Right;
+ if (client) {
+ msg.message = Msg.WM_RBUTTONUP;
+ } else {
+ msg.message = Msg.WM_NCRBUTTONUP;
+ WholeToScreen (msg.hwnd, ref xevent.ButtonEvent.x, ref xevent.ButtonEvent.y);
+ }
+ msg.wParam=GetMousewParam(0);
+ break;
+ }
+
+ case 4: {
+ goto ProcessNextMessage;
+ }
+
+ case 5: {
+ goto ProcessNextMessage;
+ }
+ }
+
+ if (!hwnd.Enabled) {
+ IntPtr dummy;
+
+ msg.hwnd = hwnd.EnabledHwnd;
+ XTranslateCoordinates(DisplayHandle, xevent.AnyEvent.window, Hwnd.ObjectFromHandle(msg.hwnd).ClientWindow, xevent.ButtonEvent.x, xevent.ButtonEvent.y, out xevent.ButtonEvent.x, out xevent.ButtonEvent.y, out dummy);
+ msg.lParam = (IntPtr)(MousePosition.Y << 16 | MousePosition.X);
+ }
+
+ if (Grab.Hwnd != IntPtr.Zero) {
+ msg.hwnd = Grab.Hwnd;
+ }
+
+ msg.lParam=(IntPtr) (xevent.ButtonEvent.y << 16 | xevent.ButtonEvent.x);
+ MousePosition.X = xevent.ButtonEvent.x;
+ MousePosition.Y = xevent.ButtonEvent.y;
+ break;
+ }
+
+ case XEventName.MotionNotify: {
+ if (client) {
+ #if DriverDebugExtra
+ Console.WriteLine("GetMessage(): Window {0:X} MotionNotify x={1} y={2}", client ? hwnd.client_window.ToInt32() : hwnd.whole_window.ToInt32(), xevent.MotionEvent.x, xevent.MotionEvent.y);
+ #endif
+
+ if (Dnd.HandleMotionNotify (ref xevent))
+ goto ProcessNextMessage;
+ if (Grab.Hwnd != IntPtr.Zero) {
+ msg.hwnd = Grab.Hwnd;
+ } else {
+ NativeWindow.WndProc(msg.hwnd, Msg.WM_SETCURSOR, msg.hwnd, (IntPtr)HitTest.HTCLIENT);
+ }
+
+ msg.message = Msg.WM_MOUSEMOVE;
+ msg.wParam = GetMousewParam(0);
+ msg.lParam = (IntPtr) (xevent.MotionEvent.y << 16 | xevent.MotionEvent.x & 0xFFFF);
+
+ if (!hwnd.Enabled) {
+ IntPtr dummy;
+
+ msg.hwnd = hwnd.EnabledHwnd;
+ XTranslateCoordinates(DisplayHandle, xevent.AnyEvent.window, Hwnd.ObjectFromHandle(msg.hwnd).ClientWindow, xevent.MotionEvent.x, xevent.MotionEvent.y, out xevent.MotionEvent.x, out xevent.MotionEvent.y, out dummy);
+ msg.lParam = (IntPtr)(MousePosition.Y << 16 | MousePosition.X);
+ }
+
+ MousePosition.X = xevent.MotionEvent.x;
+ MousePosition.Y = xevent.MotionEvent.y;
+
+ if ((HoverState.Timer.Enabled) &&
+ (((MousePosition.X + HoverState.Size.Width) < HoverState.X) ||
+ ((MousePosition.X - HoverState.Size.Width) > HoverState.X) ||
+ ((MousePosition.Y + HoverState.Size.Height) < HoverState.Y) ||
+ ((MousePosition.Y - HoverState.Size.Height) > HoverState.Y))) {
+ HoverState.Timer.Stop();
+ HoverState.Timer.Start();
+ HoverState.X = MousePosition.X;
+ HoverState.Y = MousePosition.Y;
+ }
+
+ break;
+ } else {
+ HitTest ht;
+ IntPtr dummy;
+ int screen_x;
+ int screen_y;
+
+ #if DriverDebugExtra
+ Console.WriteLine("GetMessage(): non-client area {0:X} MotionNotify x={1} y={2}", client ? hwnd.client_window.ToInt32() : hwnd.whole_window.ToInt32(), xevent.MotionEvent.x, xevent.MotionEvent.y);
+ #endif
+ msg.message = Msg.WM_NCMOUSEMOVE;
+
+ if (!hwnd.Enabled) {
+ msg.hwnd = hwnd.EnabledHwnd;
+ XTranslateCoordinates(DisplayHandle, xevent.AnyEvent.window, Hwnd.ObjectFromHandle(msg.hwnd).ClientWindow, xevent.MotionEvent.x, xevent.MotionEvent.y, out xevent.MotionEvent.x, out xevent.MotionEvent.y, out dummy);
+ msg.lParam = (IntPtr)(MousePosition.Y << 16 | MousePosition.X);
+ }
+
+ // The hit test is sent in screen coordinates
+ XTranslateCoordinates (DisplayHandle, hwnd.client_window, RootWindow,
+ xevent.MotionEvent.x, xevent.MotionEvent.y,
+ out screen_x, out screen_y, out dummy);
+
+ msg.lParam = (IntPtr) (screen_y << 16 | screen_x & 0xFFFF);
+ ht = (HitTest)NativeWindow.WndProc (hwnd.client_window, Msg.WM_NCHITTEST,
+ IntPtr.Zero, msg.lParam).ToInt32 ();
+ NativeWindow.WndProc(hwnd.client_window, Msg.WM_SETCURSOR, msg.hwnd, (IntPtr)ht);
+
+ MousePosition.X = xevent.MotionEvent.x;
+ MousePosition.Y = xevent.MotionEvent.y;
+ }
+
+ break;
+ }
+
+ case XEventName.EnterNotify: {
+ if (!hwnd.Enabled) {
+ goto ProcessNextMessage;
+ }
+ if (xevent.CrossingEvent.mode != NotifyMode.NotifyNormal) {
+ goto ProcessNextMessage;
+ }
+ msg.message = Msg.WM_MOUSE_ENTER;
+ HoverState.X = xevent.CrossingEvent.x;
+ HoverState.Y = xevent.CrossingEvent.y;
+ HoverState.Timer.Enabled = true;
+ HoverState.Window = xevent.CrossingEvent.window;
+ break;
+ }
+
+ case XEventName.LeaveNotify: {
+ if (!hwnd.Enabled) {
+ goto ProcessNextMessage;
+ }
+ if (xevent.CrossingEvent.mode != NotifyMode.NotifyNormal) {
+ goto ProcessNextMessage;
+ }
+ msg.message=Msg.WM_MOUSE_LEAVE;
+ HoverState.Timer.Enabled = false;
+ HoverState.Window = IntPtr.Zero;
+ break;
+ }
+
+ #if later
+ case XEventName.CreateNotify: {
+ if (client && (xevent.ConfigureEvent.xevent == xevent.ConfigureEvent.window)) {
+ msg.message = WM_CREATE;
+ // Set up CreateStruct
+ } else {
+ goto ProcessNextMessage;
+ }
+ break;
+ }
+ #endif
+
+
+ case XEventName.ReparentNotify: {
+ if (hwnd.parent == null) { // Toplevel
+ if ((xevent.ReparentEvent.parent != IntPtr.Zero) && (xevent.ReparentEvent.window == hwnd.whole_window)) {
+ // We need to adjust x/y
+ // This sucks ass, part 2
+ // Every WM does the reparenting of toplevel windows different, so there's
+ // no standard way of getting our adjustment considering frames/decorations
+ // The code below is needed for metacity. KDE doesn't works just fine without this
+ int dummy_int;
+ IntPtr dummy_ptr;
+ int new_x;
+ int new_y;
+ int frame_left;
+ int frame_top;
+
+ hwnd.Reparented = true;
+
+ XGetGeometry(DisplayHandle, XGetParent(hwnd.whole_window), out dummy_ptr, out new_x, out new_y, out dummy_int, out dummy_int, out dummy_int, out dummy_int);
+ FrameExtents(hwnd.whole_window, out frame_left, out frame_top);
+ if ((frame_left != 0) && (frame_top != 0) && (new_x != frame_left) && (new_y != frame_top)) {
+ hwnd.x = new_x;
+ hwnd.y = new_y;
+ hwnd.whacky_wm = true;
+ }
+
+ msg.message = Msg.WM_WINDOWPOSCHANGED;
+ if (hwnd.opacity != 0xffffffff) {
+ uint opacity;
+
+ opacity = hwnd.opacity;
+ XChangeProperty(DisplayHandle, XGetParent(hwnd.whole_window), NetAtoms[(int)NA._NET_WM_WINDOW_OPACITY], (IntPtr)Atom.XA_CARDINAL, 32, PropertyMode.Replace, ref opacity, 1);
+ }
+ } else {
+ hwnd.Reparented = false;
+ goto ProcessNextMessage;
+ }
+ }
+ break;
+ }
+
+ case XEventName.ConfigureNotify: {
+ if (PostQuitState || !client && (xevent.ConfigureEvent.xevent == xevent.ConfigureEvent.window)) { // Ignore events for children (SubstructureNotify) and client areas
+ #if DriverDebugExtra
+ Console.WriteLine("GetMessage(): Window {0:X} ConfigureNotify x={1} y={2} width={3} height={4}", hwnd.client_window.ToInt32(), xevent.ConfigureEvent.x, xevent.ConfigureEvent.y, xevent.ConfigureEvent.width, xevent.ConfigureEvent.height);
+ #endif
+ msg.message = Msg.WM_WINDOWPOSCHANGED;
+ hwnd.configure_pending = false;
+
+ // We need to adjust our client window to track the resize of whole_window
+ PerformNCCalc(hwnd);
+ } else {
+ goto ProcessNextMessage;
+ }
+
+ msg.lParam=IntPtr.Zero; // FIXME - Generate LPWINDOWPOS structure and pass on
+ break;
+ }
+
+ case XEventName.FocusIn: {
+ // We received focus. We use X11 focus only to know if the app window does or does not have focus
+ // We do not track the actual focussed window via it. Instead, this is done via FocusWindow internally
+ // Receiving focus means we've gotten activated and therefore we need to let the actual FocusWindow know
+ // about it having focus again
+ if (xevent.FocusChangeEvent.detail != NotifyDetail.NotifyNonlinear) {
+ goto ProcessNextMessage;
+ }
+ Keyboard.FocusIn(FocusWindow);
+ SendMessage(FocusWindow, Msg.WM_SETFOCUS, IntPtr.Zero, IntPtr.Zero);
+ goto ProcessNextMessage;
+ }
+
+ case XEventName.FocusOut: {
+ // Se the comment for our FocusIn handler
+ if (xevent.FocusChangeEvent.detail != NotifyDetail.NotifyNonlinear) {
+ goto ProcessNextMessage;
+ }
+ Keyboard.FocusOut(FocusWindow);
+
+ while (Keyboard.ResetKeyState(FocusWindow, ref msg)) {
+ SendMessage(FocusWindow, msg.message, msg.wParam, msg.lParam);
+ }
+
+ SendMessage(FocusWindow, Msg.WM_KILLFOCUS, IntPtr.Zero, IntPtr.Zero);
+ goto ProcessNextMessage;
+ }
+
+ case XEventName.Expose: {
+ if (PostQuitState) {
+ goto ProcessNextMessage;
+ }
+
+
+ if (client) {
+ if (!hwnd.expose_pending) {
+ goto ProcessNextMessage;
+ }
+ } else {
+ if (!hwnd.nc_expose_pending) {
+ goto ProcessNextMessage;
+ }
+
+ switch (hwnd.border_style) {
+ case FormBorderStyle.Fixed3D: {
+ Graphics g;
+
+ g = Graphics.FromHwnd(hwnd.whole_window);
+ ControlPaint.DrawBorder3D(g, new Rectangle(0, 0, hwnd.Width, hwnd.Height), Border3DStyle.Sunken);
+ g.Dispose();
+ break;
+ }
+
+ case FormBorderStyle.FixedSingle: {
+ Graphics g;
+
+ g = Graphics.FromHwnd(hwnd.whole_window);
+ ControlPaint.DrawBorder(g, new Rectangle(0, 0, hwnd.Width, hwnd.Height), Color.Black, ButtonBorderStyle.Solid);
+ g.Dispose();
+ break;
+ }
+ }
+ #if DriverDebugExtra
+ Console.WriteLine("GetMessage(): Window {0:X} Exposed non-client area {1},{2} {3}x{4}", hwnd.client_window.ToInt32(), xevent.ExposeEvent.x, xevent.ExposeEvent.y, xevent.ExposeEvent.width, xevent.ExposeEvent.height);
+ #endif
+
+ Rectangle rect = new Rectangle (xevent.ExposeEvent.x, xevent.ExposeEvent.y, xevent.ExposeEvent.width, xevent.ExposeEvent.height);
+ Region region = new Region (rect);
+ IntPtr hrgn = region.GetHrgn (null); // Graphics object isn't needed
+ msg.message = Msg.WM_NCPAINT;
+ msg.wParam = hrgn;
+ hwnd.nc_expose_pending = false;
+ break;
+ }
+ #if DriverDebugExtra
+ Console.WriteLine("GetMessage(): Window {0:X} Exposed area {1},{2} {3}x{4}", hwnd.client_window.ToInt32(), xevent.ExposeEvent.x, xevent.ExposeEvent.y, xevent.ExposeEvent.width, xevent.ExposeEvent.height);
+ #endif
+ if (Caret.Visible == true) {
+ Caret.Paused = true;
+ HideCaret();
+ }
+
+ if (Caret.Visible == true) {
+ ShowCaret();
+ Caret.Paused = false;
+ }
+ msg.message = Msg.WM_PAINT;
+ break;
+ }
+
+ case XEventName.DestroyNotify: {
+
+ // This is a bit tricky, we don't receive our own DestroyNotify, we only get those for our children
+ hwnd = Hwnd.ObjectFromHandle(xevent.DestroyWindowEvent.window);
+
+ // We may get multiple for the same window, act only one the first (when Hwnd still knows about it)
+ if ((hwnd != null) && (hwnd.client_window == xevent.DestroyWindowEvent.window)) {
+ msg.hwnd = hwnd.client_window;
+ msg.message=Msg.WM_DESTROY;
+ hwnd.Dispose();
+
+ #if DriverDebug
+ Console.WriteLine("Got DestroyNotify on Window {0:X}", msg.hwnd.ToInt32());
+ #endif
+ } else {
+ goto ProcessNextMessage;
+ }
+
+ break;
+ }
+
+ case XEventName.ClientMessage: {
+ if (Dnd.HandleClientMessage (ref xevent)) {
+ goto ProcessNextMessage;
+ }
+
+ if (xevent.ClientMessageEvent.message_type == AsyncAtom) {
+ XplatUIDriverSupport.ExecuteClientMessage((GCHandle)xevent.ClientMessageEvent.ptr1);
+ break;
+ }
+
+ if (xevent.ClientMessageEvent.message_type == HoverState.Atom) {
+ msg.message = Msg.WM_MOUSEHOVER;
+ msg.wParam = GetMousewParam(0);
+ msg.lParam = (IntPtr) (xevent.ClientMessageEvent.ptr1);
+ break;
+ }
+
+ if (xevent.ClientMessageEvent.message_type == (IntPtr)PostAtom) {
+ msg.hwnd = xevent.ClientMessageEvent.ptr1;
+ msg.message = (Msg) xevent.ClientMessageEvent.ptr2.ToInt32 ();
+ msg.wParam = xevent.ClientMessageEvent.ptr3;
+ msg.lParam = xevent.ClientMessageEvent.ptr4;
+ break;
+ }
+
+ #if dontcare
+ if (xevent.ClientMessageEvent.message_type == NetAtoms[(int)NA._XEMBED]) {
+ Console.WriteLine("GOT EMBED MESSAGE {0:X}", xevent.ClientMessageEvent.ptr2.ToInt32());
+ break;
+ }
+ #endif
+
+ if (xevent.ClientMessageEvent.message_type == NetAtoms[(int)NA.WM_PROTOCOLS]) {
+ if (xevent.ClientMessageEvent.ptr1 == NetAtoms[(int)NA.WM_DELETE_WINDOW]) {
+ msg.message = Msg.WM_CLOSE;
+ Graphics.FromHdcInternal (IntPtr.Zero);
+ break;
+ }
+
+ // We should not get this, but I'll leave the code in case we need it in the future
+ if (xevent.ClientMessageEvent.ptr1 == NetAtoms[(int)NA.WM_TAKE_FOCUS]) {
+ goto ProcessNextMessage;
+ }
+ }
+ break;
+ }
+
+ case XEventName.TimerNotify: {
+ xevent.TimerNotifyEvent.handler (this, EventArgs.Empty);
+ break;
+ }
+
+ default: {
+ goto ProcessNextMessage;
+ }
+ }
+
+ return true;
+ }
+
+ internal override bool GetText(IntPtr handle, out string text) {
+ IntPtr textptr;
+
+ textptr = IntPtr.Zero;
+
+ lock (XlibLock) {
+ // FIXME - use _NET properties
+ XFetchName(DisplayHandle, Hwnd.ObjectFromHandle(handle).whole_window, ref textptr);
+ }
+ if (textptr != IntPtr.Zero) {
+ text = Marshal.PtrToStringAnsi(textptr);
+ XFree(textptr);
+ return true;
+ } else {
+ text = "";
+ return false;
+ }
+ }
+
+ internal override void GetWindowPos(IntPtr handle, bool is_toplevel, out int x, out int y, out int width, out int height, out int client_width, out int client_height) {
+ Hwnd hwnd;
+ Rectangle rect;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ if (hwnd != null) {
+ x = hwnd.x;
+ y = hwnd.y;
+ width = hwnd.width;
+ height = hwnd.height;
+
+ rect = Hwnd.GetClientRectangle(hwnd.border_style, hwnd.menu, hwnd.title_style, hwnd.caption_height, hwnd.tool_caption_height, width, height);
+
+ client_width = rect.Width;
+ client_height = rect.Height;
+
+ return;
+ }
+
+ // Should we throw an exception or fail silently?
+ // throw new ArgumentException("Called with an invalid window handle", "handle");
+
+ x = 0;
+ y = 0;
+ width = 0;
+ height = 0;
+ client_width = 0;
+ client_height = 0;
+ }
+
+ internal override FormWindowState GetWindowState(IntPtr handle) {
+ IntPtr actual_atom;
+ int actual_format;
+ IntPtr nitems;
+ IntPtr bytes_after;
+ IntPtr prop = IntPtr.Zero;
+ IntPtr atom;
+ int maximized;
+ bool minimized;
+ XWindowAttributes attributes;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ maximized = 0;
+ minimized = false;
+ XGetWindowProperty(DisplayHandle, hwnd.whole_window, NetAtoms[(int)NA._NET_WM_STATE], IntPtr.Zero, new IntPtr (256), false, (IntPtr)Atom.XA_ATOM, out actual_atom, out actual_format, out nitems, out bytes_after, ref prop);
+ if (((long)nitems > 0) && (prop != IntPtr.Zero)) {
+ for (int i = 0; i < (long)nitems; i++) {
+ atom = (IntPtr)Marshal.ReadInt32(prop, i * 4);
+ if ((atom == NetAtoms[(int)NA._NET_WM_STATE_MAXIMIZED_HORZ]) || (atom == NetAtoms[(int)NA._NET_WM_STATE_MAXIMIZED_VERT])) {
+ maximized++;
+ } else if (atom == NetAtoms[(int)NA._NET_WM_STATE_HIDDEN]) {
+ minimized = true;
+ }
+ }
+ XFree(prop);
+ }
+
+ if (minimized) {
+ return FormWindowState.Minimized;
+ } else if (maximized == 2) {
+ return FormWindowState.Maximized;
+ }
+
+ attributes = new XWindowAttributes();
+ XGetWindowAttributes(DisplayHandle, handle, ref attributes);
+ if (attributes.map_state == MapState.IsUnmapped) {
+ throw new NotSupportedException("Cannot retrieve the state of an unmapped window");
+ }
+
+
+ return FormWindowState.Normal;
+ }
+
+ internal override void GrabInfo(out IntPtr handle, out bool GrabConfined, out Rectangle GrabArea) {
+ handle = Grab.Hwnd;
+ GrabConfined = Grab.Confined;
+ GrabArea = Grab.Area;
+ }
+
+ internal override void GrabWindow(IntPtr handle, IntPtr confine_to_handle) {
+ Hwnd hwnd;
+ IntPtr confine_to_window;
+
+ confine_to_window = IntPtr.Zero;
+
+ if (confine_to_handle != IntPtr.Zero) {
+ XWindowAttributes attributes = new XWindowAttributes();
+
+ hwnd = Hwnd.ObjectFromHandle(confine_to_handle);
+
+ lock (XlibLock) {
+ XGetWindowAttributes(DisplayHandle, hwnd.client_window, ref attributes);
+ }
+ Grab.Area.X = attributes.x;
+ Grab.Area.Y = attributes.y;
+ Grab.Area.Width = attributes.width;
+ Grab.Area.Height = attributes.height;
+ Grab.Confined = true;
+ confine_to_window = hwnd.client_window;
+ }
+
+ Grab.Hwnd = handle;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ lock (XlibLock) {
+ XGrabPointer(DisplayHandle, hwnd.client_window, false,
+ EventMask.ButtonPressMask | EventMask.ButtonMotionMask |
+ EventMask.ButtonReleaseMask | EventMask.PointerMotionMask,
+ GrabMode.GrabModeAsync, GrabMode.GrabModeAsync, confine_to_window, IntPtr.Zero, IntPtr.Zero);
+ }
+ }
+
+ internal override void UngrabWindow(IntPtr hwnd) {
+ lock (XlibLock) {
+ XUngrabPointer(DisplayHandle, IntPtr.Zero);
+ XFlush(DisplayHandle);
+ }
+ Grab.Hwnd = IntPtr.Zero;
+ Grab.Confined = false;
+ }
+
+ internal override void HandleException(Exception e) {
+ StackTrace st = new StackTrace(e, true);
+ Console.WriteLine("Exception '{0}'", e.Message+st.ToString());
+ Console.WriteLine("{0}{1}", e.Message, st.ToString());
+ }
+
+ internal override void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
+ Hwnd hwnd;
+ XEvent xevent;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+
+ xevent = new XEvent ();
+ xevent.type = XEventName.Expose;
+ xevent.ExposeEvent.display = DisplayHandle;
+ xevent.ExposeEvent.window = hwnd.client_window;
+
+ if (clear) {
+ xevent.ExposeEvent.x = hwnd.X;
+ xevent.ExposeEvent.y = hwnd.Y;
+ xevent.ExposeEvent.width = hwnd.Width;
+ xevent.ExposeEvent.height = hwnd.Height;
+ } else {
+ xevent.ExposeEvent.x = rc.X;
+ xevent.ExposeEvent.y = rc.Y;
+ xevent.ExposeEvent.width = rc.Width;
+ xevent.ExposeEvent.height = rc.Height;
+ }
+
+ AddExpose (xevent);
+ }
+
+ internal override bool IsEnabled(IntPtr handle) {
+ return Hwnd.ObjectFromHandle(handle).Enabled;
+ }
+
+ internal override bool IsVisible(IntPtr handle) {
+ return Hwnd.ObjectFromHandle(handle).visible;
+ }
+
+ internal override void KillTimer(Timer timer) {
+ lock (TimerList) {
+ TimerList.Remove(timer);
+ }
+ }
+
+ internal override void MenuToScreen(IntPtr handle, ref int x, ref int y) {
+ int dest_x_return;
+ int dest_y_return;
+ IntPtr child;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ lock (XlibLock) {
+ XTranslateCoordinates(DisplayHandle, hwnd.whole_window, RootWindow, x, y, out dest_x_return, out dest_y_return, out child);
+ }
+
+ x = dest_x_return;
+ y = dest_y_return;
+ }
+
+ internal override void OverrideCursor(IntPtr cursor) {
+ OverrideCursorHandle = cursor;
+ }
+
+ internal override PaintEventArgs PaintEventStart(IntPtr handle, bool client) {
+ PaintEventArgs paint_event;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ if (Caret.Visible == true) {
+ Caret.Paused = true;
+ HideCaret();
+ }
+
+ if (client) {
+ hwnd.client_dc = Graphics.FromHwnd (hwnd.client_window);
+ hwnd.client_dc.SetClip(hwnd.invalid);
+ paint_event = new PaintEventArgs(hwnd.client_dc, hwnd.invalid);
+ hwnd.expose_pending = false;
+
+ return paint_event;
+ } else {
+ hwnd.non_client_dc = Graphics.FromHwnd (hwnd.whole_window);
+ hwnd.non_client_dc.SetClip (hwnd.nc_invalid);
+ paint_event = new PaintEventArgs(hwnd.non_client_dc, hwnd.nc_invalid);
+ hwnd.nc_expose_pending = false;
+
+ return paint_event;
+ }
+ }
+
+ internal override void PaintEventEnd(IntPtr handle, bool client) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ if (client) {
+ hwnd.ClearInvalidArea();
+
+ hwnd.client_dc.Flush();
+ hwnd.client_dc.Dispose();
+ hwnd.client_dc = null;
+ } else {
+ hwnd.ClearNcInvalidArea ();
+
+ hwnd.non_client_dc.Flush ();
+ hwnd.non_client_dc.Dispose ();
+ hwnd.non_client_dc = null;
+ }
+
+
+
+ if (Caret.Visible == true) {
+ ShowCaret();
+ Caret.Paused = false;
+ }
+ }
+
+ internal override bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
+ bool pending;
+
+ // FIXME - imlement filtering
+
+ if ((flags & (uint)PeekMessageFlags.PM_REMOVE) == 0) {
+ throw new NotImplementedException("PeekMessage PM_NOREMOVE is not implemented yet"); // FIXME - Implement PM_NOREMOVE flag
+ }
+
+ pending = false;
+ if (MessageQueue.Count > 0) {
+ pending = true;
+ } else {
+ // Only call UpdateMessageQueue if real events are pending
+ // otherwise we go to sleep on the socket
+ if (XPending(DisplayHandle) != 0) {
+ UpdateMessageQueue();
+ pending = true;
+ }
+ }
+
+ CheckTimers(DateTime.Now);
+
+ if (!pending) {
+ return false;
+ }
+ return GetMessage(ref msg, hWnd, wFilterMin, wFilterMax);
+ }
+
+ // FIXME - I think this should just enqueue directly
+ internal override bool PostMessage (IntPtr handle, Msg message, IntPtr wparam, IntPtr lparam) {
+ XEvent xevent = new XEvent ();
+ Hwnd hwnd = Hwnd.ObjectFromHandle(handle);
+
+ xevent.type = XEventName.ClientMessage;
+ xevent.ClientMessageEvent.display = DisplayHandle;
+
+ if (hwnd != null) {
+ xevent.ClientMessageEvent.window = hwnd.whole_window;
+ } else {
+ xevent.ClientMessageEvent.window = IntPtr.Zero;
+ }
+
+ xevent.ClientMessageEvent.message_type = (IntPtr) PostAtom;
+ xevent.ClientMessageEvent.format = 32;
+ xevent.ClientMessageEvent.ptr1 = handle;
+ xevent.ClientMessageEvent.ptr2 = (IntPtr) message;
+ xevent.ClientMessageEvent.ptr3 = wparam;
+ xevent.ClientMessageEvent.ptr4 = lparam;
+
+ MessageQueue.Enqueue (xevent);
+
+ return true;
+ }
+
+ internal override void PostQuitMessage(int exitCode) {
+ XFlush(DisplayHandle);
+ PostQuitState = true;
+
+ // Remove our display handle from S.D
+ Graphics.FromHdcInternal (IntPtr.Zero);
+ }
+
+ internal override void RequestNCRecalc(IntPtr handle) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ if (hwnd == null) {
+ return;
+ }
+
+ PerformNCCalc(hwnd);
+ SendMessage(handle, Msg.WM_WINDOWPOSCHANGED, IntPtr.Zero, IntPtr.Zero);
+ InvalidateWholeWindow(handle);
+ }
+
+ internal override void ResetMouseHover(IntPtr handle) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+ if (hwnd == null) {
+ return;
+ }
+
+ HoverState.Timer.Enabled = true;
+ HoverState.X = MousePosition.X;
+ HoverState.Y = MousePosition.Y;
+ HoverState.Window = handle;
+ }
+
+
+ internal override void ScreenToClient(IntPtr handle, ref int x, ref int y) {
+ int dest_x_return;
+ int dest_y_return;
+ IntPtr child;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ lock (XlibLock) {
+ XTranslateCoordinates (DisplayHandle, RootWindow, hwnd.client_window, x, y, out dest_x_return, out dest_y_return, out child);
+ }
+
+ x = dest_x_return;
+ y = dest_y_return;
+ }
+
+ internal override void ScreenToMenu(IntPtr handle, ref int x, ref int y) {
+ int dest_x_return;
+ int dest_y_return;
+ IntPtr child;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ lock (XlibLock) {
+ XTranslateCoordinates (DisplayHandle, RootWindow, hwnd.whole_window, x, y, out dest_x_return, out dest_y_return, out child);
+ }
+
+ x = dest_x_return;
+ y = dest_y_return;
+ }
+
+ internal override void ScrollWindow(IntPtr handle, Rectangle area, int XAmount, int YAmount, bool with_children) {
+ Hwnd hwnd;
+ IntPtr gc;
+ XGCValues gc_values;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ if (hwnd.invalid != Rectangle.Empty) {
+ // BIG FAT WARNING. This only works with how we use this function right now
+ // where we basically still scroll the whole window, but work around areas
+ // that are covered by our children
+
+ hwnd.invalid.X += XAmount;
+ hwnd.invalid.Y += YAmount;
+
+ if (hwnd.invalid.X < 0) {
+ hwnd.invalid.Width += hwnd.invalid.X;
+ hwnd.invalid.X =0;
+ }
+
+ if (hwnd.invalid.Y < 0) {
+ hwnd.invalid.Height += hwnd.invalid.Y;
+ hwnd.invalid.Y =0;
+ }
+ }
+
+ gc_values = new XGCValues();
+
+ if (with_children) {
+ gc_values.subwindow_mode = GCSubwindowMode.IncludeInferiors;
+ }
+
+ gc = XCreateGC(DisplayHandle, hwnd.client_window, IntPtr.Zero, ref gc_values);
+
+ XCopyArea(DisplayHandle, hwnd.client_window, hwnd.client_window, gc, area.X - XAmount, area.Y - YAmount, area.Width, area.Height, area.X, area.Y);
+
+ // Generate an expose for the area exposed by the horizontal scroll
+ if (XAmount > 0) {
+ hwnd.AddInvalidArea (area.X, area.Y, XAmount, area.Height);
+ } else if (XAmount < 0) {
+ hwnd.AddInvalidArea (XAmount + area.X + area.Width, area.Y, -XAmount, area.Height);
+ }
+
+ // Generate an expose for the area exposed by the vertical scroll
+ if (YAmount > 0) {
+ hwnd.AddInvalidArea (area.X, area.Y, area.Width, YAmount);
+ } else if (YAmount < 0) {
+ hwnd.AddInvalidArea (area.X, YAmount + area.Y + area.Height, area.Width, -YAmount);
+ }
+ XFreeGC(DisplayHandle, gc);
+
+ UpdateWindow(handle);
+ }
+
+ internal override void ScrollWindow(IntPtr handle, int XAmount, int YAmount, bool with_children) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.GetObjectFromWindow(handle);
+
+ ScrollWindow(handle, hwnd.ClientRect, XAmount, YAmount, with_children);
+ }
+
+ internal override void SendAsyncMethod (AsyncMethodData method) {
+ XEvent xevent = new XEvent ();
+
+ xevent.type = XEventName.ClientMessage;
+ xevent.ClientMessageEvent.display = DisplayHandle;
+ xevent.ClientMessageEvent.window = FosterParent;
+ xevent.ClientMessageEvent.message_type = (IntPtr)AsyncAtom;
+ xevent.ClientMessageEvent.format = 32;
+ xevent.ClientMessageEvent.ptr1 = (IntPtr) GCHandle.Alloc (method);
+
+ MessageQueue.EnqueueLocked (xevent);
+
+ WakeupMain ();
+ }
+
+ internal override IntPtr SendMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) {
+ return NativeWindow.WndProc(hwnd, message, wParam, lParam);
+ }
+
+ internal override void SetAllowDrop (IntPtr handle, bool value)
+ {
+ // We allow drop on all windows
+ }
+
+ internal override DragDropEffects StartDrag (IntPtr handle, object data,
+ DragDropEffects allowed_effects)
+ {
+ Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
+
+ if (hwnd == null)
+ throw new ArgumentException ("Attempt to begin drag from invalid window handle (" + handle.ToInt32 () + ").");
+
+ return Dnd.StartDrag (hwnd.client_window, data, allowed_effects);
+ }
+
+ internal override void SetBorderStyle(IntPtr handle, FormBorderStyle border_style) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ hwnd.border_style = border_style;
+ RequestNCRecalc(handle);
+ }
+
+ internal override void SetCaretPos(IntPtr handle, int x, int y) {
+ if (Caret.Hwnd == handle) {
+ Caret.Timer.Stop();
+ HideCaret();
+
+ Caret.X = x;
+ Caret.Y = y;
+
+ if (Caret.Visible == true) {
+ ShowCaret();
+ Caret.Timer.Start();
+ }
+ }
+ }
+
+ internal override void SetCursor(IntPtr handle, IntPtr cursor) {
+ Hwnd hwnd;
+
+ if (OverrideCursorHandle == IntPtr.Zero) {
+ if ((LastCursorWindow == handle) && (LastCursorHandle == cursor)) {
+ return;
+ }
+
+ LastCursorHandle = cursor;
+ LastCursorWindow = handle;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+ lock (XlibLock) {
+ if (cursor != IntPtr.Zero) {
+ XDefineCursor(DisplayHandle, hwnd.whole_window, cursor);
+ } else {
+ XUndefineCursor(DisplayHandle, hwnd.whole_window);
+ }
+ }
+ return;
+ }
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+ lock (XlibLock) {
+ XDefineCursor(DisplayHandle, hwnd.whole_window, OverrideCursorHandle);
+ }
+ }
+
+ internal override void SetCursorPos(IntPtr handle, int x, int y) {
+ if (handle == IntPtr.Zero) {
+ lock (XlibLock) {
+ XWarpPointer(DisplayHandle, IntPtr.Zero, IntPtr.Zero, 0, 0, 0, 0, x, y);
+ }
+ return;
+ } else {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+ lock (XlibLock) {
+ XWarpPointer(DisplayHandle, IntPtr.Zero, hwnd.client_window, 0, 0, 0, 0, x, y);
+ }
+ return;
+ }
+ }
+
+ internal override void SetFocus(IntPtr handle) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ if (hwnd.client_window == FocusWindow) {
+ return;
+ }
+
+ SendMessage(hwnd.client_window, Msg.WM_SETFOCUS, FocusWindow, IntPtr.Zero);
+ if (FocusWindow != IntPtr.Zero) {
+ SendMessage(FocusWindow, Msg.WM_KILLFOCUS, hwnd.client_window, IntPtr.Zero);
+ }
+ FocusWindow = hwnd.client_window;
+
+ //XSetInputFocus(DisplayHandle, Hwnd.ObjectFromHandle(handle).client_window, RevertTo.None, IntPtr.Zero);
+ }
+
+ internal override void SetIcon(IntPtr handle, Icon icon) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+ if (hwnd != null) {
+ SetIcon(hwnd, icon);
+ }
+ }
+
+ internal override void SetMenu(IntPtr handle, Menu menu) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+ hwnd.menu = menu;
+
+ RequestNCRecalc(handle);
+ }
+
+ internal override void SetModal(IntPtr handle, bool Modal) {
+ if (Modal) {
+ ModalWindows.Push(handle);
+ } else {
+ if (ModalWindows.Contains(handle)) {
+ ModalWindows.Pop();
+ }
+ if (ModalWindows.Count > 0) {
+ Activate((IntPtr)ModalWindows.Peek());
+ }
+ }
+ }
+
+ internal override IntPtr SetParent(IntPtr handle, IntPtr parent) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+ hwnd.parent = Hwnd.ObjectFromHandle(parent);
+
+ lock (XlibLock) {
+ #if DriverDebug || DriverDebugParent
+ Console.WriteLine("Parent for window {0} = {1}", XplatUI.Window(hwnd.Handle), XplatUI.Window(hwnd.parent != null ? hwnd.parent.Handle : IntPtr.Zero));
+ #endif
+ XReparentWindow(DisplayHandle, hwnd.whole_window, hwnd.parent.client_window, hwnd.x, hwnd.y);
+ }
+
+ return IntPtr.Zero;
+ }
+
+ internal override void SetTimer (Timer timer) {
+ lock (TimerList) {
+ TimerList.Add(timer);
+ }
+ WakeupMain ();
+ }
+
+ internal override bool SetTopmost(IntPtr handle, IntPtr handle_owner, bool enabled) {
+ Hwnd hwnd;
+ Hwnd hwnd_owner;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ if (handle_owner != IntPtr.Zero) {
+ hwnd_owner = Hwnd.ObjectFromHandle(handle_owner);
+ } else {
+ hwnd_owner = null;
+ }
+
+ if (enabled) {
+ lock (XlibLock) {
+ if (hwnd_owner != null) {
+ XSetTransientForHint(DisplayHandle, hwnd.whole_window, hwnd_owner.whole_window);
+ } else {
+ XSetTransientForHint(DisplayHandle, hwnd.whole_window, FosterParent);
+ }
+ }
+ } else {
+ lock (XlibLock) {
+ XDeleteProperty(DisplayHandle, hwnd.whole_window, (IntPtr)Atom.XA_WM_TRANSIENT_FOR);
+ }
+ }
+ return true;
+ }
+
+ internal override bool SetVisible(IntPtr handle, bool visible) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+ hwnd.visible = visible;
+
+ lock (XlibLock) {
+ if (visible) {
+ if (Control.FromHandle(handle) is Form) {
+ FormWindowState s;
+
+ s = ((Form)Control.FromHandle(handle)).WindowState;
+
+ XMapWindow(DisplayHandle, hwnd.whole_window);
+ XMapWindow(DisplayHandle, hwnd.client_window);
+
+ switch(s) {
+ case FormWindowState.Minimized: SetWindowState(handle, FormWindowState.Minimized); break;
+ case FormWindowState.Maximized: SetWindowState(handle, FormWindowState.Maximized); break;
+ }
+
+ } else {
+ XMapWindow(DisplayHandle, hwnd.whole_window);
+ XMapWindow(DisplayHandle, hwnd.client_window);
+ }
+ SendMessage(handle, Msg.WM_WINDOWPOSCHANGED, IntPtr.Zero, IntPtr.Zero);
+ } else {
+ XUnmapWindow(DisplayHandle, hwnd.whole_window);
+ }
+ }
+ return true;
+ }
+
+ internal override void SetWindowMinMax(IntPtr handle, Rectangle maximized, Size min, Size max) {
+ Hwnd hwnd;
+ XSizeHints hints;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+ if (hwnd == null) {
+ return;
+ }
+
+ hints = new XSizeHints();
+
+ if (min != Size.Empty) {
+ hints.flags = (IntPtr)((int)hints.flags | (int)XSizeHintsFlags.PMinSize);
+ hints.min_width = min.Width;
+ hints.min_height = min.Height;
+ }
+
+ if (max != Size.Empty) {
+ hints.flags = (IntPtr)((int)hints.flags | (int)XSizeHintsFlags.PMaxSize);
+ hints.max_width = max.Width;
+ hints.max_height = max.Height;
+ }
+
+ if (hints.flags != IntPtr.Zero) {
+ XSetWMNormalHints(DisplayHandle, hwnd.whole_window, ref hints);
+ }
+
+ if (maximized != Rectangle.Empty) {
+ hints.flags = (IntPtr)XSizeHintsFlags.PPosition;
+ hints.x = maximized.X;
+ hints.y = maximized.Y;
+ hints.width = maximized.Width;
+ hints.height = maximized.Height;
+
+ // Metacity does not seem to follow this constraint for maximized (zoomed) windows
+ XSetZoomHints(DisplayHandle, hwnd.whole_window, ref hints);
+ }
+ }
+
+
+ internal override void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
+ Hwnd hwnd;
+ Rectangle client_rect;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ // X requires a sanity check for width & height; otherwise it dies
+ if (hwnd.zero_sized && width > 0 && height > 0) {
+ if (hwnd.visible) {
+ XMapWindow(DisplayHandle, hwnd.whole_window);
+ }
+ hwnd.zero_sized = false;
+ }
+
+ if (width < 1) {
+ hwnd.zero_sized = true;
+ XUnmapWindow(DisplayHandle, hwnd.whole_window);
+ }
+
+ if (height < 1) {
+ hwnd.zero_sized = true;
+ XUnmapWindow(DisplayHandle, hwnd.whole_window);
+ }
+
+ client_rect = Hwnd.GetClientRectangle(hwnd.border_style, hwnd.menu, hwnd.title_style, hwnd.caption_height, hwnd.tool_caption_height, width, height);
+
+ // Save a server roundtrip (and prevent a feedback loop)
+ if ((hwnd.x == x) && (hwnd.y == y) &&
+ (hwnd.width == width) && (hwnd.height == height) &&
+ (hwnd.ClientRect == client_rect)) {
+ return;
+ }
+
+ if (!hwnd.zero_sized) {
+
+ if (hwnd.fixed_size) {
+ SetWindowMinMax(handle, Rectangle.Empty, new Size(width, height), new Size(width, height));
+ }
+
+ lock (XlibLock) {
+ XMoveResizeWindow(DisplayHandle, hwnd.whole_window, x, y, width, height);
+ XMoveResizeWindow(DisplayHandle, hwnd.client_window, client_rect.X, client_rect.Y, client_rect.Width, client_rect.Height);
+ }
+ }
+
+ // Prevent an old queued ConfigureNotify from setting our width with outdated data, set it now
+ hwnd.width = width;
+ hwnd.height = height;
+ }
+
+ internal override void SetWindowState(IntPtr handle, FormWindowState state) {
+ FormWindowState current_state;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ try {
+ current_state = GetWindowState(handle);
+ }
+ catch (NotSupportedException) {
+ current_state = (FormWindowState)(-1);
+ }
+
+ if (current_state == state) {
+ return;
+ }
+
+ switch(state) {
+ case FormWindowState.Normal: {
+ lock (XlibLock) {
+ if (current_state == FormWindowState.Minimized) {
+ XMapWindow(DisplayHandle, hwnd.whole_window);
+ XMapWindow(DisplayHandle, hwnd.client_window);
+ } else if (current_state == FormWindowState.Maximized) {
+ SendNetWMMessage(hwnd.whole_window, NetAtoms[(int)NA._NET_WM_STATE], (IntPtr)2 /* toggle */, NetAtoms[(int)NA._NET_WM_STATE_MAXIMIZED_HORZ], NetAtoms[(int)NA._NET_WM_STATE_MAXIMIZED_VERT]);
+ }
+ }
+ Activate(handle);
+ return;
+ }
+
+ case FormWindowState.Minimized: {
+ lock (XlibLock) {
+ if (current_state == FormWindowState.Maximized) {
+ SendNetWMMessage(hwnd.whole_window, NetAtoms[(int)NA._NET_WM_STATE], (IntPtr)2 /* toggle */, NetAtoms[(int)NA._NET_WM_STATE_MAXIMIZED_HORZ], NetAtoms[(int)NA._NET_WM_STATE_MAXIMIZED_VERT]);
+ }
+ XIconifyWindow(DisplayHandle, hwnd.whole_window, ScreenNo);
+ }
+ return;
+ }
+
+ case FormWindowState.Maximized: {
+ lock (XlibLock) {
+ if (current_state == FormWindowState.Minimized) {
+ XMapWindow(DisplayHandle, hwnd.whole_window);
+ XMapWindow(DisplayHandle, hwnd.client_window);
+ }
+
+ SendNetWMMessage(hwnd.whole_window, NetAtoms[(int)NA._NET_WM_STATE], (IntPtr)1 /* Add */, NetAtoms[(int)NA._NET_WM_STATE_MAXIMIZED_HORZ], NetAtoms[(int)NA._NET_WM_STATE_MAXIMIZED_VERT]);
+ }
+ Activate(handle);
+ return;
+ }
+ }
+ }
+
+ internal override void SetWindowStyle(IntPtr handle, CreateParams cp) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+ SetHwndStyles(hwnd, cp);
+ SetWMStyles(hwnd, cp);
+ }
+
+ internal override void SetWindowTransparency(IntPtr handle, double transparency, Color key) {
+ Hwnd hwnd;
+ uint opacity;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ if (hwnd == null) {
+ return;
+ }
+
+ hwnd.opacity = (uint)(0xffffffff * transparency);
+ opacity = hwnd.opacity;
+
+ if (hwnd.reparented) {
+ XChangeProperty(DisplayHandle, XGetParent(hwnd.whole_window), NetAtoms[(int)NA._NET_WM_WINDOW_OPACITY], (IntPtr)Atom.XA_CARDINAL, 32, PropertyMode.Replace, ref opacity, 1);
+ }
+ }
+
+ internal override bool SetZOrder(IntPtr handle, IntPtr after_handle, bool top, bool bottom) {
+ Hwnd hwnd = Hwnd.ObjectFromHandle(handle);
+
+ if (top) {
+ lock (XlibLock) {
+ XRaiseWindow(DisplayHandle, hwnd.whole_window);
+ }
+ return true;
+ } else if (!bottom) {
+ Hwnd after_hwnd = null;
+
+ if (after_handle != IntPtr.Zero) {
+ after_hwnd = Hwnd.ObjectFromHandle(after_handle);
+ }
+
+ XWindowChanges values = new XWindowChanges();
+
+ if (after_hwnd == null) {
+ throw new ArgumentNullException("after_handle", "Need sibling to adjust z-order");
+ }
+ values.sibling = after_hwnd.whole_window;
+ values.stack_mode = StackMode.Below;
+
+ lock (XlibLock) {
+ XConfigureWindow(DisplayHandle, hwnd.whole_window, ChangeWindowFlags.CWStackMode | ChangeWindowFlags.CWSibling, ref values);
+ }
+ } else {
+ // Bottom
+ lock (XlibLock) {
+ XLowerWindow(DisplayHandle, hwnd.whole_window);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ internal override void ShowCursor(bool show) {
+ ; // FIXME - X11 doesn't 'hide' the cursor. we could create an empty cursor
+ }
+
+ internal override void StartLoop(Thread thread) {
+ // Future place for prepping a new queue for this specific thread
+ }
+
+ internal override bool SupportsTransparency() {
+ // We need to check if the x compositing manager is running
+ return true;
+ }
+
+ internal override bool SystrayAdd(IntPtr handle, string tip, Icon icon, out ToolTip tt) {
+ GetSystrayManagerWindow();
+
+ if (SystrayMgrWindow != IntPtr.Zero) {
+ XSizeHints size_hints;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+ #if DriverDebug
+ Console.WriteLine("Adding Systray Whole:{0:X}, Client:{1:X}", hwnd.whole_window.ToInt32(), hwnd.client_window.ToInt32());
+ #endif
+
+ XUnmapWindow(DisplayHandle, hwnd.whole_window);
+ XUnmapWindow(DisplayHandle, hwnd.client_window);
+
+ // Oh boy.
+ XDestroyWindow(DisplayHandle, hwnd.client_window);
+ hwnd.client_window = hwnd.whole_window;
+
+ size_hints = new XSizeHints();
+
+ size_hints.flags = (IntPtr)(XSizeHintsFlags.PMinSize | XSizeHintsFlags.PMaxSize | XSizeHintsFlags.PBaseSize);
+ size_hints.min_width = icon.Width;
+ size_hints.min_height = icon.Height;
+
+ size_hints.max_width = icon.Width;
+ size_hints.max_height = icon.Height;
+
+ size_hints.base_width = icon.Width;
+ size_hints.base_height = icon.Height;
+ XSetWMNormalHints(DisplayHandle, hwnd.whole_window, ref size_hints);
+
+ int[] atoms = new int[2];
+ atoms [0] = 1; // Version 1
+ atoms [1] = 0; // We're not mapped
+
+ // This line cost me 3 days...
+ XChangeProperty(DisplayHandle, hwnd.whole_window, NetAtoms[(int)NA._XEMBED_INFO], NetAtoms[(int)NA._XEMBED_INFO], 32, PropertyMode.Replace, atoms, 2);
+
+ // Need to pick some reasonable defaults
+ tt = new ToolTip();
+ tt.AutomaticDelay = 100;
+ tt.InitialDelay = 250;
+ tt.ReshowDelay = 250;
+ tt.ShowAlways = true;
+
+ if ((tip != null) && (tip != string.Empty)) {
+ tt.SetToolTip(Control.FromHandle(handle), tip);
+ tt.Active = true;
+ } else {
+ tt.Active = false;
+ }
+
+ // Make sure the window exists
+ XSync(DisplayHandle, hwnd.whole_window);
+
+ SendNetClientMessage(SystrayMgrWindow, NetAtoms[(int)NA._NET_SYSTEM_TRAY_OPCODE], IntPtr.Zero, (IntPtr)SystrayRequest.SYSTEM_TRAY_REQUEST_DOCK, hwnd.whole_window);
+ return true;
+ }
+ tt = null;
+ return false;
+ }
+
+ internal override bool SystrayChange(IntPtr handle, string tip, Icon icon, ref ToolTip tt) {
+ Control control;
+
+ control = Control.FromHandle(handle);
+ if (control != null && tt != null) {
+ tt.SetToolTip(control, tip);
+ tt.Active = true;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ internal override void SystrayRemove(IntPtr handle, ref ToolTip tt) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ XUnmapWindow(DisplayHandle, hwnd.whole_window);
+ SetParent(hwnd.whole_window, FosterParent);
+
+ // The caller can now re-dock it later...
+ if (tt != null) {
+ tt.Dispose();
+ tt = null;
+ }
+ }
+
+ internal override bool Text(IntPtr handle, string text) {
+ lock (XlibLock) {
+ // FIXME - use _NET properties
+ XStoreName(DisplayHandle, Hwnd.ObjectFromHandle(handle).whole_window, text);
+ }
+ return true;
+ }
+
+ internal override bool TranslateMessage(ref MSG msg) {
+ return Keyboard.TranslateMessage (ref msg);
+ }
+
+ internal override void UpdateWindow(IntPtr handle) {
+ XEvent xevent;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ if (!hwnd.visible || hwnd.expose_pending) {
+ return;
+ }
+
+#if not
+ SendMessage(handle, Msg.WM_PAINT, IntPtr.Zero, IntPtr.Zero);
+#else
+ xevent = new XEvent();
+ xevent.type = XEventName.Expose;
+ xevent.ExposeEvent.display = DisplayHandle;
+ xevent.ExposeEvent.window = hwnd.client_window;
+
+ MessageQueue.Enqueue(xevent);
+ hwnd.expose_pending = true;
+#endif
+ }
+
+ private bool WindowIsMapped(IntPtr handle) {
+ XWindowAttributes attributes;
+
+ attributes = new XWindowAttributes();
+ XGetWindowAttributes(DisplayHandle, handle, ref attributes);
+ if (attributes.map_state == MapState.IsUnmapped) {
+ return false;
+ }
+ return true;
+ }
+
+ #endregion // Public Static Methods
+
+ #region Events
+ internal override event EventHandler Idle;
+ #endregion // Events
+
+ #region X11 Imports
+ [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="XSynchronize")]
+ internal extern static IntPtr XSynchronize(IntPtr display, bool onoff);
+
+ [DllImport ("libX11", EntryPoint="XCreateWindow")]
+ internal extern static IntPtr XCreateWindow(IntPtr display, IntPtr parent, int x, int y, int width, int height, int border_width, int depth, int xclass, IntPtr visual, UIntPtr valuemask, ref XSetWindowAttributes attributes);
+ [DllImport ("libX11", EntryPoint="XCreateSimpleWindow")]
+ internal extern static IntPtr XCreateSimpleWindow(IntPtr display, IntPtr parent, int x, int y, int width, int height, int border_width, UIntPtr border, UIntPtr background);
+ [DllImport ("libX11", EntryPoint="XMapWindow")]
+ internal extern static int XMapWindow(IntPtr display, IntPtr window);
+ [DllImport ("libX11", EntryPoint="XUnmapWindow")]
+ internal extern static int XUnmapWindow(IntPtr display, IntPtr window);
+ [DllImport ("libX11", EntryPoint="XMapSubwindows")]
+ internal extern static int XMapSubindows(IntPtr display, IntPtr window);
+ [DllImport ("libX11", EntryPoint="XUnmapSubwindows")]
+ internal extern static int XUnmapSubwindows(IntPtr display, IntPtr window);
+ [DllImport ("libX11", EntryPoint="XRootWindow")]
+ internal extern static IntPtr XRootWindow(IntPtr display, int screen_number);
+ [DllImport ("libX11", EntryPoint="XNextEvent")]
+ internal extern static IntPtr XNextEvent(IntPtr display, ref XEvent xevent);
+ [DllImport ("libX11")]
+ internal extern static int XConnectionNumber (IntPtr diplay);
+ [DllImport ("libX11")]
+ internal extern static int XPending (IntPtr diplay);
+ [DllImport ("libX11", EntryPoint="XSelectInput")]
+ internal extern static IntPtr XSelectInput(IntPtr display, IntPtr window, IntPtr mask);
+
+ [DllImport ("libX11", EntryPoint="XDestroyWindow")]
+ internal extern static int XDestroyWindow(IntPtr display, IntPtr window);
+
+ [DllImport ("libX11", EntryPoint="XReparentWindow")]
+ internal extern static int XReparentWindow(IntPtr display, IntPtr window, IntPtr parent, int x, int y);
+ [DllImport ("libX11", EntryPoint="XMoveResizeWindow")]
+ internal extern static int XMoveResizeWindow(IntPtr display, IntPtr window, int x, int y, int width, int height);
+
+ [DllImport ("libX11", EntryPoint="XResizeWindow")]
+ internal extern static int XResizeWindow(IntPtr display, IntPtr window, int width, int height);
+
+ [DllImport ("libX11", EntryPoint="XGetWindowAttributes")]
+ internal extern static int XGetWindowAttributes(IntPtr display, IntPtr window, ref XWindowAttributes attributes);
+
+ [DllImport ("libX11", EntryPoint="XFlush")]
+ internal extern static int XFlush(IntPtr display);
+
+ [DllImport ("libX11", EntryPoint="XSetWMName")]
+ internal extern static int XSetWMName(IntPtr display, IntPtr window, ref XTextProperty text_prop);
+
+ [DllImport ("libX11", EntryPoint="XStoreName")]
+ internal extern static int XStoreName(IntPtr display, IntPtr window, string window_name);
+
+ [DllImport ("libX11", EntryPoint="XFetchName")]
+ internal extern static int XFetchName(IntPtr display, IntPtr window, ref IntPtr window_name);
+
+ [DllImport ("libX11", EntryPoint="XSendEvent")]
+ internal extern static int XSendEvent(IntPtr display, IntPtr window, bool propagate, IntPtr event_mask, ref XEvent send_event);
+
+ [DllImport ("libX11", EntryPoint="XQueryTree")]
+ internal extern static int XQueryTree(IntPtr display, IntPtr window, out IntPtr root_return, out IntPtr parent_return, out IntPtr children_return, out int nchildren_return);
+
+ [DllImport ("libX11", EntryPoint="XFree")]
+ internal extern static int XFree(IntPtr data);
+
+ [DllImport ("libX11", EntryPoint="XRaiseWindow")]
+ internal extern static int XRaiseWindow(IntPtr display, IntPtr window);
+
+ [DllImport ("libX11", EntryPoint="XLowerWindow")]
+ internal extern static uint XLowerWindow(IntPtr display, IntPtr window);
+
+ [DllImport ("libX11", EntryPoint="XConfigureWindow")]
+ internal extern static uint XConfigureWindow(IntPtr display, IntPtr window, ChangeWindowFlags value_mask, ref XWindowChanges values);
+
+ [DllImport ("libX11", EntryPoint="XInternAtom")]
+ internal extern static IntPtr XInternAtom(IntPtr display, string atom_name, bool only_if_exists);
+
+ [DllImport ("libX11", EntryPoint="XSetWMProtocols")]
+ internal extern static int XSetWMProtocols(IntPtr display, IntPtr window, IntPtr[] protocols, int count);
+
+ [DllImport ("libX11", EntryPoint="XGrabPointer")]
+ internal extern static int XGrabPointer(IntPtr display, IntPtr window, bool owner_events, EventMask event_mask, GrabMode pointer_mode, GrabMode keyboard_mode, IntPtr confine_to, IntPtr cursor, IntPtr timestamp);
+
+ [DllImport ("libX11", EntryPoint="XUngrabPointer")]
+ internal extern static int XUngrabPointer(IntPtr display, IntPtr timestamp);
+
+ [DllImport ("libX11", EntryPoint="XQueryPointer")]
+ internal extern static bool XQueryPointer(IntPtr display, IntPtr window, out IntPtr root, out IntPtr child, out int root_x, out int root_y, out int win_x, out int win_y, out int keys_buttons);
+
+ [DllImport ("libX11", EntryPoint="XTranslateCoordinates")]
+ internal extern static bool XTranslateCoordinates (IntPtr display, IntPtr src_w, IntPtr dest_w, int src_x, int src_y, out int intdest_x_return, out int dest_y_return, out IntPtr child_return);
+
+ [DllImport ("libX11", EntryPoint="XGetGeometry")]
+ internal extern static bool XGetGeometry(IntPtr display, IntPtr window, out IntPtr root, out int x, out int y, out int width, out int height, out int border_width, out int depth);
+
+ [DllImport ("libX11", EntryPoint="XGetGeometry")]
+ internal extern static bool XGetGeometry(IntPtr display, IntPtr window, IntPtr root, out int x, out int y, out int width, out int height, IntPtr border_width, IntPtr depth);
+
+ [DllImport ("libX11", EntryPoint="XGetGeometry")]
+ internal extern static bool XGetGeometry(IntPtr display, IntPtr window, IntPtr root, out int x, out int y, IntPtr width, IntPtr height, IntPtr border_width, IntPtr depth);
+
+ [DllImport ("libX11", EntryPoint="XGetGeometry")]
+ internal extern static bool XGetGeometry(IntPtr display, IntPtr window, IntPtr root, IntPtr x, IntPtr y, out int width, out int height, IntPtr border_width, IntPtr depth);
+
+ [DllImport ("libX11", EntryPoint="XWarpPointer")]
+ internal extern static uint XWarpPointer(IntPtr display, IntPtr src_w, IntPtr dest_w, int src_x, int src_y, uint src_width, uint src_height, int dest_x, int dest_y);
+
+ [DllImport ("libX11", EntryPoint="XClearWindow")]
+ internal extern static int XClearWindow(IntPtr display, IntPtr window);
+
+ [DllImport ("libX11", EntryPoint="XClearArea")]
+ internal extern static int XClearArea(IntPtr display, IntPtr window, int x, int y, int width, int height, bool exposures);
+
+ // Colormaps
+ [DllImport ("libX11", EntryPoint="XDefaultScreenOfDisplay")]
+ internal extern static IntPtr XDefaultScreenOfDisplay(IntPtr display);
+
+ [DllImport ("libX11", EntryPoint="XScreenNumberOfScreen")]
+ internal extern static int XScreenNumberOfScreen(IntPtr display, IntPtr Screen);
+
+ [DllImport ("libX11", EntryPoint="XDefaultVisual")]
+ internal extern static IntPtr XDefaultVisual(IntPtr display, int screen_number);
+
+ [DllImport ("libX11", EntryPoint="XDefaultDepth")]
+ internal extern static uint XDefaultDepth(IntPtr display, int screen_number);
+
+ [DllImport ("libX11", EntryPoint="XDefaultScreen")]
+ internal extern static int XDefaultScreen(IntPtr display);
+
+ [DllImport ("libX11", EntryPoint="XDefaultColormap")]
+ internal extern static IntPtr XDefaultColormap(IntPtr display, int screen_number);
+
+ [DllImport ("libX11", EntryPoint="XLookupColor")]
+ internal extern static int XLookupColor(IntPtr display, IntPtr Colormap, string Coloranem, ref XColor exact_def_color, ref XColor screen_def_color);
+
+ [DllImport ("libX11", EntryPoint="XAllocColor")]
+ internal extern static int XAllocColor(IntPtr display, IntPtr Colormap, ref XColor colorcell_def);
+
+ [DllImport ("libX11", EntryPoint="XSetTransientForHint")]
+ internal extern static int XSetTransientForHint(IntPtr display, IntPtr window, IntPtr prop_window);
+
+ [DllImport ("libX11", EntryPoint="XChangeProperty")]
+ internal extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, ref MotifWmHints data, int nelements);
+
+ [DllImport ("libX11", EntryPoint="XChangeProperty")]
+ internal extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, ref uint value, int nelements);
+
+ [DllImport ("libX11", EntryPoint="XChangeProperty")]
+ internal extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, uint[] data, int nelements);
+
+ [DllImport ("libX11", EntryPoint="XChangeProperty")]
+ internal extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, int[] data, int nelements);
+
+ [DllImport ("libX11", EntryPoint="XChangeProperty")]
+ internal extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, IntPtr atoms, int nelements);
+
+ [DllImport ("libX11", EntryPoint="XChangeProperty", CharSet=CharSet.Ansi)]
+ internal extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, string text, int text_length);
+
+ [DllImport ("libX11", EntryPoint="XDeleteProperty")]
+ internal extern static int XDeleteProperty(IntPtr display, IntPtr window, IntPtr property);
+
+ [DllImport ("gdiplus", EntryPoint="GetFontMetrics")]
+ internal extern static bool GetFontMetrics(IntPtr graphicsObject, IntPtr nativeObject, out int ascent, out int descent);
+
+ // Drawing
+ [DllImport ("libX11", EntryPoint="XCreateGC")]
+ internal extern static IntPtr XCreateGC(IntPtr display, IntPtr window, IntPtr valuemask, ref XGCValues values);
+
+ [DllImport ("libX11", EntryPoint="XFreeGC")]
+ internal extern static int XFreeGC(IntPtr display, IntPtr gc);
+
+ [DllImport ("libX11", EntryPoint="XSetFunction")]
+ internal extern static int XSetFunction(IntPtr display, IntPtr gc, GXFunction function);
+
+ [DllImport ("libX11", EntryPoint="XDrawLine")]
+ internal extern static int XDrawLine(IntPtr display, IntPtr drawable, IntPtr gc, int x1, int y1, int x2, int y2);
+
+ [DllImport ("libX11", EntryPoint="XDrawRectangle")]
+ internal extern static int XDrawRectangle(IntPtr display, IntPtr drawable, IntPtr gc, int x1, int y1, int width, int height);
+
+ [DllImport ("libX11", EntryPoint="XSetWindowBackground")]
+ internal extern static int XSetWindowBackground(IntPtr display, IntPtr window, IntPtr background);
+
+ [DllImport ("libX11", EntryPoint="XCopyArea")]
+ internal extern static int XCopyArea(IntPtr display, IntPtr src, IntPtr dest, IntPtr gc, int src_x, int src_y, int width, int height, int dest_x, int dest_y);
+
+ [DllImport ("libX11", EntryPoint="XGetWindowProperty")]
+ internal extern static int XGetWindowProperty(IntPtr display, IntPtr window, IntPtr atom, IntPtr long_offset, IntPtr long_length, bool delete, IntPtr req_type, out IntPtr actual_type, out int actual_format, out IntPtr nitems, out IntPtr bytes_after, ref IntPtr prop);
+
+ [DllImport ("libX11", EntryPoint="XSetInputFocus")]
+ internal extern static int XSetInputFocus(IntPtr display, IntPtr window, RevertTo revert_to, IntPtr time);
+
+ [DllImport ("libX11", EntryPoint="XIconifyWindow")]
+ internal extern static int XIconifyWindow(IntPtr display, IntPtr window, int screen_number);
+
+ [DllImport ("libX11", EntryPoint="XDefineCursor")]
+ internal extern static int XDefineCursor(IntPtr display, IntPtr window, IntPtr cursor);
+
+ [DllImport ("libX11", EntryPoint="XUndefineCursor")]
+ internal extern static int XUndefineCursor(IntPtr display, IntPtr window);
+
+ [DllImport ("libX11", EntryPoint="XFreeCursor")]
+ internal extern static int XFreeCursor(IntPtr display, IntPtr cursor);
+
+ [DllImport ("libX11", EntryPoint="XCreateFontCursor")]
+ internal extern static IntPtr XCreateFontCursor(IntPtr display, CursorFontShape shape);
+
+ [DllImport ("libX11", EntryPoint="XCreatePixmapCursor")]
+ internal extern static IntPtr XCreatePixmapCursor(IntPtr display, IntPtr source, IntPtr mask, ref XColor foreground_color, ref XColor background_color, int x_hot, int y_hot);
+
+ [DllImport ("libX11", EntryPoint="XCreatePixmapFromBitmapData")]
+ internal extern static IntPtr XCreatePixmapFromBitmapData(IntPtr display, IntPtr drawable, byte[] data, int width, int height, IntPtr fg, IntPtr bg, int depth);
+
+ [DllImport ("libX11", EntryPoint="XFreePixmap")]
+ internal extern static IntPtr XFreePixmap(IntPtr display, IntPtr pixmap);
+
+ [DllImport ("libX11", EntryPoint="XQueryBestCursor")]
+ internal extern static int XQueryBestCursor(IntPtr display, IntPtr drawable, int width, int height, out int best_width, out int best_height);
+
+ [DllImport ("libX11", EntryPoint="XWhitePixel")]
+ internal extern static IntPtr XWhitePixel(IntPtr display, int screen_no);
+
+ [DllImport ("libX11", EntryPoint="XBlackPixel")]
+ internal extern static IntPtr XBlackPixel(IntPtr display, int screen_no);
+
+ [DllImport ("libX11", EntryPoint="XGrabServer")]
+ internal extern static void XGrabServer(IntPtr display);
+
+ [DllImport ("libX11", EntryPoint="XUngrabServer")]
+ internal extern static void XUngrabServer(IntPtr display);
+
+ [DllImport ("libX11", EntryPoint="XSetWMNormalHints")]
+ internal extern static void XSetWMNormalHints(IntPtr display, IntPtr window, ref XSizeHints hints);
+
+ [DllImport ("libX11", EntryPoint="XSetZoomHints")]
+ internal extern static void XSetZoomHints(IntPtr display, IntPtr window, ref XSizeHints hints);
+
+ [DllImport ("libX11", EntryPoint="XSetWMHints")]
+ internal extern static void XSetWMHints(IntPtr display, IntPtr window, ref XWMHints wmhints);
+
+ [DllImport ("libX11", EntryPoint="XSync")]
+ internal extern static void XSync(IntPtr display, IntPtr window);
+
+ [DllImport ("libX11", EntryPoint="XGetIconSizes")]
+ internal extern static int XGetIconSizes(IntPtr display, IntPtr window, out IntPtr size_list, out int count);
+
+ [DllImport ("libX11", EntryPoint="XSetErrorHandler")]
+ internal extern static IntPtr XSetErrorHandler(XErrorHandler error_handler);
+
+ [DllImport ("libX11", EntryPoint="XGetErrorText")]
+ internal extern static IntPtr XGetErrorText(IntPtr display, byte code, StringBuilder buffer, int length);
+
+ [DllImport ("libX11", EntryPoint="XInitThreads")]
+ internal extern static int XInitThreads();
+
+ [DllImport ("libX11", EntryPoint="XConvertSelection")]
+ internal extern static int XConvertSelection(IntPtr display, IntPtr selection, IntPtr target, IntPtr property, IntPtr requestor, IntPtr time);
+
+ [DllImport ("libX11", EntryPoint="XGetSelectionOwner")]
+ internal extern static IntPtr XGetSelectionOwner(IntPtr display, IntPtr selection);
+
+ [DllImport ("libX11", EntryPoint="XSetSelectionOwner")]
+ internal extern static int XSetSelectionOwner(IntPtr display, IntPtr selection, IntPtr owner, IntPtr time);
+
+ [DllImport ("libX11", EntryPoint="XSetPlaneMask")]
+ internal extern static int XSetPlaneMask(IntPtr display, IntPtr gc, IntPtr mask);
+
+ [DllImport ("libX11", EntryPoint="XSetForeground")]
+ internal extern static int XSetForeground(IntPtr display, IntPtr gc, UIntPtr foreground);
+
+ [DllImport ("libX11", EntryPoint="XSetBackground")]
+ internal extern static int XSetBackground(IntPtr display, IntPtr gc, UIntPtr background);
+
+ [DllImport ("libX11", EntryPoint="XBell")]
+ internal extern static int XBell(IntPtr display, int percent);
+
+ [DllImport ("libX11", EntryPoint="XChangeActivePointerGrab")]
+ internal extern static int XChangeActivePointerGrab (IntPtr display, EventMask event_mask, IntPtr cursor, IntPtr time);
+
+ [DllImport ("libX11", EntryPoint="XFilterEvent")]
+ internal extern static bool XFilterEvent(ref XEvent xevent, IntPtr window);
+ #endregion
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11GTK.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11GTK.cs
new file mode 100644
index 00000000000..ea16de4e26b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11GTK.cs
@@ -0,0 +1,4778 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004-2006 Novell, Inc.
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+// Alexander Olk alex.olk@googlemail.com
+//
+//
+
+// NOTE:
+// This driver understands the following environment variables: (Set the var to enable feature)
+//
+// MONO_XEXCEPTIONS = throw an exception when a X11 error is encountered;
+// by default a message is displayed but execution continues
+//
+// MONO_XSYNC = perform all X11 commands synchronous; this is slower but
+// helps in debugging errors
+//
+
+// NOT COMPLETE - WORK IN PROGRESS
+
+// One feature of the driver is, that PaintEventstart returns a graphics context created from a offscreen drawable (pixmap)
+
+// define to log Window handles and relationships to stdout
+#undef DriverDebug
+
+// Extra detailed debug
+#undef DriverDebugExtra
+
+using System;
+using System.ComponentModel;
+using System.Collections;
+using System.Diagnostics;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading;
+
+// Only do the poll when building with mono for now
+#if __MonoCS__
+using Mono.Unix.Native;
+#endif
+
+/// X11 Version
+namespace System.Windows.Forms {
+ internal class XplatUIX11GTK : XplatUIDriver {
+
+ internal enum GdkWindowClass {
+ GDK_INPUT_OUTPUT,
+ GDK_INPUT_ONLY
+ }
+
+ internal enum GdkWindowType {
+ GDK_WINDOW_ROOT,
+ GDK_WINDOW_TOPLEVEL,
+ GDK_WINDOW_CHILD,
+ GDK_WINDOW_DIALOG,
+ GDK_WINDOW_TEMP,
+ GDK_WINDOW_FOREIGN
+ }
+
+ internal enum GdkWindowHints {
+ GDK_HINT_POS = 1 << 0,
+ GDK_HINT_MIN_SIZE = 1 << 1,
+ GDK_HINT_MAX_SIZE = 1 << 2,
+ GDK_HINT_BASE_SIZE = 1 << 3,
+ GDK_HINT_ASPECT = 1 << 4,
+ GDK_HINT_RESIZE_INC = 1 << 5,
+ GDK_HINT_WIN_GRAVITY = 1 << 6,
+ GDK_HINT_USER_POS = 1 << 7,
+ GDK_HINT_USER_SIZE = 1 << 8
+ }
+
+ internal enum GdkGravity {
+ GDK_GRAVITY_NORTH_WEST = 1,
+ GDK_GRAVITY_NORTH,
+ GDK_GRAVITY_NORTH_EAST,
+ GDK_GRAVITY_WEST,
+ GDK_GRAVITY_CENTER,
+ GDK_GRAVITY_EAST,
+ GDK_GRAVITY_SOUTH_WEST,
+ GDK_GRAVITY_SOUTH,
+ GDK_GRAVITY_SOUTH_EAST,
+ GDK_GRAVITY_STATIC
+ }
+
+ internal enum GdkWindowEdge {
+ GDK_WINDOW_EDGE_NORTH_WEST,
+ GDK_WINDOW_EDGE_NORTH,
+ GDK_WINDOW_EDGE_NORTH_EAST,
+ GDK_WINDOW_EDGE_WEST,
+ GDK_WINDOW_EDGE_EAST,
+ GDK_WINDOW_EDGE_SOUTH_WEST,
+ GDK_WINDOW_EDGE_SOUTH,
+ GDK_WINDOW_EDGE_SOUTH_EAST
+ }
+
+ internal enum GdkWindowTypeHint {
+ GDK_WINDOW_TYPE_HINT_NORMAL,
+ GDK_WINDOW_TYPE_HINT_DIALOG,
+ GDK_WINDOW_TYPE_HINT_MENU,
+ GDK_WINDOW_TYPE_HINT_TOOLBAR,
+ GDK_WINDOW_TYPE_HINT_SPLASHSCREEN,
+ GDK_WINDOW_TYPE_HINT_UTILITY,
+ GDK_WINDOW_TYPE_HINT_DOCK,
+ GDK_WINDOW_TYPE_HINT_DESKTOP
+ }
+
+ internal enum GdkWindowAttributesType {
+ GDK_WA_TITLE = 1 << 1,
+ GDK_WA_X = 1 << 2,
+ GDK_WA_Y = 1 << 3,
+ GDK_WA_CURSOR = 1 << 4,
+ GDK_WA_COLORMAP = 1 << 5,
+ GDK_WA_VISUAL = 1 << 6,
+ GDK_WA_WMCLASS = 1 << 7,
+ GDK_WA_NOREDIR = 1 << 8
+ }
+
+ internal enum GdkEventMask {
+ GDK_EXPOSURE_MASK = 1 << 1,
+ GDK_POINTER_MOTION_MASK = 1 << 2,
+ GDK_POINTER_MOTION_HINT_MASK = 1 << 3,
+ GDK_BUTTON_MOTION_MASK = 1 << 4,
+ GDK_BUTTON1_MOTION_MASK = 1 << 5,
+ GDK_BUTTON2_MOTION_MASK = 1 << 6,
+ GDK_BUTTON3_MOTION_MASK = 1 << 7,
+ GDK_BUTTON_PRESS_MASK = 1 << 8,
+ GDK_BUTTON_RELEASE_MASK = 1 << 9,
+ GDK_KEY_PRESS_MASK = 1 << 10,
+ GDK_KEY_RELEASE_MASK = 1 << 11,
+ GDK_ENTER_NOTIFY_MASK = 1 << 12,
+ GDK_LEAVE_NOTIFY_MASK = 1 << 13,
+ GDK_FOCUS_CHANGE_MASK = 1 << 14,
+ GDK_STRUCTURE_MASK = 1 << 15,
+ GDK_PROPERTY_CHANGE_MASK = 1 << 16,
+ GDK_VISIBILITY_NOTIFY_MASK = 1 << 17,
+ GDK_PROXIMITY_IN_MASK = 1 << 18,
+ GDK_PROXIMITY_OUT_MASK = 1 << 19,
+ GDK_SUBSTRUCTURE_MASK = 1 << 20,
+ GDK_SCROLL_MASK = 1 << 21,
+ GDK_ALL_EVENTS_MASK = 0x3FFFFE
+ }
+
+ internal enum GdkEventType {
+ GDK_NOTHING = -1,
+ GDK_DELETE = 0,
+ GDK_DESTROY = 1,
+ GDK_EXPOSE = 2,
+ GDK_MOTION_NOTIFY = 3,
+ GDK_BUTTON_PRESS = 4,
+ GDK_2BUTTON_PRESS = 5,
+ GDK_3BUTTON_PRESS = 6,
+ GDK_BUTTON_RELEASE = 7,
+ GDK_KEY_PRESS = 8,
+ GDK_KEY_RELEASE = 9,
+ GDK_ENTER_NOTIFY = 10,
+ GDK_LEAVE_NOTIFY = 11,
+ GDK_FOCUS_CHANGE = 12,
+ GDK_CONFIGURE = 13,
+ GDK_MAP = 14,
+ GDK_UNMAP = 15,
+ GDK_PROPERTY_NOTIFY = 16,
+ GDK_SELECTION_CLEAR = 17,
+ GDK_SELECTION_REQUEST = 18,
+ GDK_SELECTION_NOTIFY = 19,
+ GDK_PROXIMITY_IN = 20,
+ GDK_PROXIMITY_OUT = 21,
+ GDK_DRAG_ENTER = 22,
+ GDK_DRAG_LEAVE = 23,
+ GDK_DRAG_MOTION = 24,
+ GDK_DRAG_STATUS = 25,
+ GDK_DROP_START = 26,
+ GDK_DROP_FINISHED = 27,
+ GDK_CLIENT_EVENT = 28,
+ GDK_VISIBILITY_NOTIFY = 29,
+ GDK_NO_EXPOSE = 30,
+ GDK_SCROLL = 31,
+ GDK_WINDOW_STATE = 32,
+ GDK_SETTING = 33,
+ GDK_OWNER_CHANGE = 34,
+ GDK_GRAB_BROKEN = 35
+ }
+
+ internal enum GdkWMDecoration {
+ GDK_DECOR_ALL = 1 << 0,
+ GDK_DECOR_BORDER = 1 << 1,
+ GDK_DECOR_RESIZEH = 1 << 2,
+ GDK_DECOR_TITLE = 1 << 3,
+ GDK_DECOR_MENU = 1 << 4,
+ GDK_DECOR_MINIMIZE = 1 << 5,
+ GDK_DECOR_MAXIMIZE = 1 << 6
+ }
+
+ internal enum GdkWMFunction {
+ GDK_FUNC_ALL = 1 << 0,
+ GDK_FUNC_RESIZE = 1 << 1,
+ GDK_FUNC_MOVE = 1 << 2,
+ GDK_FUNC_MINIMIZE = 1 << 3,
+ GDK_FUNC_MAXIMIZE = 1 << 4,
+ GDK_FUNC_CLOSE = 1 << 5
+ }
+
+ internal enum GdkCursorType {
+ GDK_X_CURSOR = 0,
+ GDK_ARROW = 2,
+ GDK_BASED_ARROW_DOWN = 4,
+ GDK_BASED_ARROW_UP = 6,
+ GDK_BOAT = 8,
+ GDK_BOGOSITY = 10,
+ GDK_BOTTOM_LEFT_CORNER = 12,
+ GDK_BOTTOM_RIGHT_CORNER = 14,
+ GDK_BOTTOM_SIDE = 16,
+ GDK_BOTTOM_TEE = 18,
+ GDK_BOX_SPIRAL = 20,
+ GDK_CENTER_PTR = 22,
+ GDK_CIRCLE = 24,
+ GDK_CLOCK = 26,
+ GDK_COFFEE_MUG = 28,
+ GDK_CROSS = 30,
+ GDK_CROSS_REVERSE = 32,
+ GDK_CROSSHAIR = 34,
+ GDK_DIAMOND_CROSS = 36,
+ GDK_DOT = 38,
+ GDK_DOTBOX = 40,
+ GDK_DOUBLE_ARROW = 42,
+ GDK_DRAFT_LARGE = 44,
+ GDK_DRAFT_SMALL = 46,
+ GDK_DRAPED_BOX = 48,
+ GDK_EXCHANGE = 50,
+ GDK_FLEUR = 52,
+ GDK_GOBBLER = 54,
+ GDK_GUMBY = 56,
+ GDK_HAND1 = 58,
+ GDK_HAND2 = 60,
+ GDK_HEART = 62,
+ GDK_ICON = 64,
+ GDK_IRON_CROSS = 66,
+ GDK_LEFT_PTR = 68,
+ GDK_LEFT_SIDE = 70,
+ GDK_LEFT_TEE = 72,
+ GDK_LEFTBUTTON = 74,
+ GDK_LL_ANGLE = 76,
+ GDK_LR_ANGLE = 78,
+ GDK_MAN = 80,
+ GDK_MIDDLEBUTTON = 82,
+ GDK_MOUSE = 84,
+ GDK_PENCIL = 86,
+ GDK_PIRATE = 88,
+ GDK_PLUS = 90,
+ GDK_QUESTION_ARROW = 92,
+ GDK_RIGHT_PTR = 94,
+ GDK_RIGHT_SIDE = 96,
+ GDK_RIGHT_TEE = 98,
+ GDK_RIGHTBUTTON = 100,
+ GDK_RTL_LOGO = 102,
+ GDK_SAILBOAT = 104,
+ GDK_SB_DOWN_ARROW = 106,
+ GDK_SB_H_DOUBLE_ARROW = 108,
+ GDK_SB_LEFT_ARROW = 110,
+ GDK_SB_RIGHT_ARROW = 112,
+ GDK_SB_UP_ARROW = 114,
+ GDK_SB_V_DOUBLE_ARROW = 116,
+ GDK_SHUTTLE = 118,
+ GDK_SIZING = 120,
+ GDK_SPIDER = 122,
+ GDK_SPRAYCAN = 124,
+ GDK_STAR = 126,
+ GDK_TARGET = 128,
+ GDK_TCROSS = 130,
+ GDK_TOP_LEFT_ARROW = 132,
+ GDK_TOP_LEFT_CORNER = 134,
+ GDK_TOP_RIGHT_CORNER = 136,
+ GDK_TOP_SIDE = 138,
+ GDK_TOP_TEE = 140,
+ GDK_TREK = 142,
+ GDK_UL_ANGLE = 144,
+ GDK_UMBRELLA = 146,
+ GDK_UR_ANGLE = 148,
+ GDK_WATCH = 150,
+ GDK_XTERM = 152,
+ GDK_LAST_CURSOR,
+ GDK_CURSOR_IS_PIXMAP = -1
+ }
+
+ internal enum GdkPropMode {
+ GDK_PROP_MODE_REPLACE,
+ GDK_PROP_MODE_PREPEND,
+ GDK_PROP_MODE_APPEND
+ }
+
+ [StructLayout (LayoutKind.Sequential)]
+ internal struct GdkGeometry {
+ internal int min_width;
+ internal int min_height;
+ internal int max_width;
+ internal int max_height;
+ internal int base_width;
+ internal int base_height;
+ internal int width_inc;
+ internal int height_inc;
+ internal double min_aspect;
+ internal double max_aspect;
+ internal GdkGravity win_gravity;
+ }
+
+ [StructLayout (LayoutKind.Sequential)]
+ internal struct GdkWindowAttr {
+ internal string title;
+ internal int event_mask;
+ internal int x, y;
+ internal int width;
+ internal int height;
+ internal GdkWindowClass wclass;
+ internal IntPtr visual;
+ internal IntPtr colormap;
+ internal GdkWindowType window_type;
+ internal IntPtr cursor;
+ internal string wmclass_name;
+ internal string wmclass_class;
+ internal bool override_redirect;
+ }
+
+ #region Local Variables
+ // General
+ static volatile XplatUIX11GTK Instance;
+ private static int RefCount;
+ private static object XlibLock; // Our locking object
+ private static bool ThemesEnabled;
+
+ // General X11
+ private static IntPtr DisplayHandle; // X11 handle to display
+ private static IntPtr GdkDisplayHandle; // gdk handle to display
+ private static int ScreenNo; // Screen number used
+ private static IntPtr GdkScreen;
+ private static IntPtr DefaultColormap; // Colormap for screen
+ private static IntPtr GdkDefaultColormap; // Gdk Colormap for screen
+ private static IntPtr CustomVisual; // Visual for window creation
+ private static IntPtr GdkCustomVisual;
+ private static IntPtr CustomColormap; // Colormap for window creation
+ private static IntPtr GdkCustomColormap;
+ private static int VisualBestDepth;
+ private static IntPtr RootWindow; // Handle of the root window for the screen/display
+ private static IntPtr GdkRootWindow; // Gdk handle of the root window for the screen/display
+ private static IntPtr FosterParent; // Container to hold child windows until their parent exists
+ private static IntPtr GdkFosterParent; // Container to hold child windows until their parent exists
+ private static XErrorHandler ErrorHandler; // Error handler delegate
+ private static bool ErrorExceptions; // Throw exceptions on X errors
+ private static bool PostQuitState; // True if we've got an pending exit
+
+ // Clipboard
+ private static IntPtr ClipMagic = new IntPtr(27051977);
+ private static ClipboardStruct Clipboard; // Our clipboard
+
+ // Communication
+ private static int PostAtom; // PostMessage atom
+ private static int AsyncAtom; // Support for async messages
+
+ // Message Loop
+ private static XEventQueue MessageQueue; // Holds our queued up events
+ #if __MonoCS__ //
+ private static Pollfd[] pollfds; // For watching the X11 socket
+ #endif //
+ private static X11Keyboard Keyboard; //
+ private static X11Dnd Dnd;
+ private static Socket listen; //
+ private static Socket wake; //
+ private static Socket wake_receive; //
+ private static byte[] network_buffer; //
+
+
+ // Focus tracking
+ private static IntPtr ActiveWindow; // Handle of the active window
+ private static IntPtr FocusWindow; // Handle of the window with keyboard focus (if any)
+
+ // Modality support
+ private static Stack ModalWindows; // Stack of our modal windows
+
+ // Systray
+ private static IntPtr SystrayMgrWindow; // Handle of the Systray Manager window
+
+ // Cursors
+ private static IntPtr LastCursorWindow; // The last window we set the cursor on
+ private static IntPtr LastCursorHandle; // The handle that was last set on LastCursorWindow
+ private static IntPtr OverrideCursorHandle; // The cursor that is set to override any other cursors
+
+ // Caret
+ private static CaretStruct Caret; //
+
+ // Support for Window Styles
+ private static int[] NetAtoms; // All atoms we know
+
+ // mouse hover message generation
+ private static HoverStruct HoverState; //
+
+ // double click message generation
+ private static ClickStruct ClickPending; //
+
+ // Support for mouse grab
+ private static GrabStruct Grab; //
+
+ // State
+ private static Point MousePosition; // Last position of mouse, in screen coords
+ internal static MouseButtons MouseState; // Last state of mouse buttons
+
+ // Timers
+ private static ArrayList TimerList; // Holds SWF.Timers
+
+ // 'Constants'
+ private static int DoubleClickInterval; // msec; max interval between clicks to count as double click
+
+ const GdkEventMask GdkSelectInputMask = GdkEventMask.GDK_BUTTON_PRESS_MASK |
+ GdkEventMask.GDK_BUTTON_RELEASE_MASK |
+ GdkEventMask.GDK_KEY_PRESS_MASK |
+ GdkEventMask.GDK_KEY_RELEASE_MASK |
+ GdkEventMask.GDK_ENTER_NOTIFY_MASK |
+ GdkEventMask.GDK_LEAVE_NOTIFY_MASK |
+ GdkEventMask.GDK_EXPOSURE_MASK |
+ GdkEventMask.GDK_FOCUS_CHANGE_MASK |
+ GdkEventMask.GDK_POINTER_MOTION_MASK |
+ GdkEventMask.GDK_VISIBILITY_NOTIFY_MASK |
+ GdkEventMask.GDK_SUBSTRUCTURE_MASK |
+ GdkEventMask.GDK_STRUCTURE_MASK;
+
+ static readonly object lockobj = new object ();
+
+ static Hashtable backing_store = new Hashtable (5);
+
+ #endregion // Local Variables
+ #region Constructors
+ private XplatUIX11GTK ()
+ {
+ Console.WriteLine ("XplatUIX11GTK ctor...");
+ // Handle singleton stuff first
+ RefCount = 0;
+
+ // init gdk
+ int argc = 0;
+ string argv = "";
+
+ gdk_init_check (out argc, argv);
+
+ // Now regular initialization
+ XlibLock = new object ();
+ MessageQueue = new XEventQueue ();
+ TimerList = new ArrayList ();
+ XInitThreads ();
+
+ ErrorExceptions = false;
+
+ // X11 Initialization
+ SetDisplay (gdk_x11_display_get_xdisplay (gdk_display_get_default ()));
+ X11DesktopColors.Initialize ();
+
+ // Handle any upcoming errors; we re-set it here, X11DesktopColor stuff might have stolen it (gtk does)
+ ErrorHandler = new XErrorHandler (HandleError);
+ XSetErrorHandler (ErrorHandler);
+ }
+ #endregion // Constructors
+
+ #region Singleton Specific Code
+ public static XplatUIX11GTK GetInstance ()
+ {
+ lock (lockobj) {
+ if (Instance == null) {
+ Instance = new XplatUIX11GTK ();
+ }
+ RefCount++;
+ }
+ return Instance;
+ }
+
+ public int Reference {
+ get {
+ return RefCount;
+ }
+ }
+ #endregion
+
+ #region Internal Properties
+ internal static IntPtr Display {
+ get {
+ return DisplayHandle;
+ }
+
+ set {
+ XplatUIX11GTK.GetInstance ().SetDisplay (value);
+ }
+ }
+
+ internal static int Screen {
+ get {
+ return ScreenNo;
+ }
+
+ set {
+ ScreenNo = value;
+ }
+ }
+
+ internal static IntPtr RootWindowHandle {
+ get {
+ return RootWindow;
+ }
+
+ set {
+ RootWindow = value;
+ }
+ }
+
+ internal static IntPtr Visual {
+ get {
+ return CustomVisual;
+ }
+
+ set {
+ CustomVisual = value;
+ }
+ }
+
+ internal static IntPtr ColorMap {
+ get {
+ return CustomColormap;
+ }
+
+ set {
+ CustomColormap = value;
+ }
+ }
+ #endregion
+
+ #region XExceptionClass
+ internal class XException : ApplicationException {
+ IntPtr Display;
+ IntPtr ResourceID;
+ IntPtr Serial;
+ XRequest RequestCode;
+ byte ErrorCode;
+ byte MinorCode;
+
+ public XException (IntPtr Display, IntPtr ResourceID, IntPtr Serial, byte ErrorCode, XRequest RequestCode, byte MinorCode)
+ {
+ this.Display = Display;
+ this.ResourceID = ResourceID;
+ this.Serial = Serial;
+ this.RequestCode = RequestCode;
+ this.ErrorCode = ErrorCode;
+ this.MinorCode = MinorCode;
+ }
+
+ public override string Message {
+ get {
+ return GetMessage (Display, ResourceID, Serial, ErrorCode, RequestCode, MinorCode);
+ }
+ }
+
+ public static string GetMessage (IntPtr Display, IntPtr ResourceID, IntPtr Serial, byte ErrorCode, XRequest RequestCode, byte MinorCode)
+ {
+ StringBuilder sb;
+ string x_error_text;
+ string error;
+
+ sb = new StringBuilder (160);
+ XGetErrorText (Display, ErrorCode, sb, sb.Capacity);
+ x_error_text = sb.ToString ();
+
+ error = String.Format ("\n Error: {0}\n Request: {1:D} ({2})\n Resource ID: 0x{3:x}\n Serial: {4}", x_error_text, RequestCode, RequestCode, ResourceID.ToInt32 (), Serial);
+ return error;
+ }
+ }
+ #endregion // XExceptionClass
+
+ #region Internal Methods
+ // native X display handle
+ internal void SetDisplay (IntPtr display_handle)
+ {
+ if (display_handle != IntPtr.Zero) {
+ Hwnd hwnd;
+
+ if ((GdkDisplayHandle != IntPtr.Zero) && (GdkFosterParent != IntPtr.Zero)) {
+ hwnd = Hwnd.ObjectFromHandle (gdk_x11_drawable_get_xid (GdkFosterParent));
+ gdk_window_destroy (GdkFosterParent);
+ hwnd.Dispose ();
+ }
+
+ if (GdkDisplayHandle != IntPtr.Zero) {
+ gdk_display_close (GdkDisplayHandle);
+ }
+
+ DisplayHandle = display_handle;
+ GdkDisplayHandle = gdk_x11_lookup_xdisplay (display_handle);
+
+ // We need to tell System.Drawing our DisplayHandle. FromHdcInternal has
+ // been hacked to do this for us.
+ Graphics.FromHdcInternal (DisplayHandle);
+
+ // Debugging support
+ if (Environment.GetEnvironmentVariable ("MONO_XSYNC") != null) {
+ XSynchronize (DisplayHandle, true);
+ }
+
+ if (Environment.GetEnvironmentVariable ("MONO_XEXCEPTIONS") != null) {
+ ErrorExceptions = true;
+ }
+
+ // Generic X11 setup
+ GdkScreen = gdk_screen_get_default ();
+ // or gdk_x11_get_default_screen
+ ScreenNo = gdk_screen_get_number (GdkScreen);
+ GdkRootWindow = gdk_get_default_root_window ();
+ RootWindow = gdk_x11_drawable_get_xid (GdkRootWindow);
+ GdkDefaultColormap = gdk_colormap_get_system ();
+ DefaultColormap = gdk_x11_colormap_get_xcolormap (GdkDefaultColormap);
+
+ VisualBestDepth = gdk_visual_get_best_depth ();
+ //Console.WriteLine (VisualBestDepth);
+
+ // Create the foster parent
+ FosterParent = XCreateSimpleWindow (DisplayHandle, RootWindow, 0, 0, 1, 1, 4, 0, 0);
+ GdkFosterParent = gdk_window_foreign_new (FosterParent);
+
+ if (GdkFosterParent == IntPtr.Zero) {
+ Console.WriteLine ("XplatUIX11GTK Constructor failed to create FosterParent");
+ }
+
+ hwnd = new Hwnd ();
+
+ hwnd.WholeWindow = FosterParent;
+ hwnd.ClientWindow = FosterParent;
+
+ // For sleeping on the X11 socket
+ listen = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
+ IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 0);
+ listen.Bind (ep);
+ listen.Listen (1);
+
+ // To wake up when a timer is ready
+ network_buffer = new byte [10];
+
+ wake = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
+ wake.Connect (listen.LocalEndPoint);
+ wake_receive = listen.Accept ();
+
+ #if __MonoCS__
+ pollfds = new Pollfd [2];
+ pollfds [0] = new Pollfd ();
+ pollfds [0].fd = XConnectionNumber (DisplayHandle);
+ pollfds [0].events = PollEvents.POLLIN;
+
+ pollfds [1] = new Pollfd ();
+ pollfds [1].fd = wake_receive.Handle.ToInt32 ();
+ pollfds [1].events = PollEvents.POLLIN;
+ #endif
+
+ Keyboard = new X11Keyboard (DisplayHandle);
+ Dnd = new X11Dnd (DisplayHandle);
+
+ PostQuitState = false;
+
+ DoubleClickInterval = 500;
+
+ HoverState.Interval = 500;
+ HoverState.Timer = new Timer ();
+ HoverState.Timer.Enabled = false;
+ HoverState.Timer.Interval = HoverState.Interval;
+ HoverState.Timer.Tick += new EventHandler (MouseHover);
+ HoverState.X = -1;
+ HoverState.Y = -1;
+
+ ActiveWindow = IntPtr.Zero;
+ FocusWindow = IntPtr.Zero;
+ ModalWindows = new Stack (3);
+
+ MouseState = MouseButtons.None;
+ MousePosition = new Point (0, 0);
+
+ Caret.Timer = new Timer ();
+ Caret.Timer.Interval = 500; // FIXME - where should this number come from?
+ Caret.Timer.Tick += new EventHandler (CaretCallback);
+
+ SetupAtoms ();
+
+ // Grab atom changes off the root window to catch certain WM events
+ gdk_window_set_events (GdkRootWindow, (int)GdkEventMask.GDK_PROPERTY_CHANGE_MASK);
+
+ // Handle any upcoming errors
+ ErrorHandler = new XErrorHandler (HandleError);
+ XSetErrorHandler (ErrorHandler);
+ } else {
+ throw new ArgumentNullException ("Display", "Could not open display (X-Server required. Check you DISPLAY environment variable)");
+ }
+ }
+
+ internal static void Where ()
+ {
+ Console.WriteLine ("Here: {0}\n", WhereString ());
+ }
+
+ internal static string WhereString ()
+ {
+ StackTrace stack;
+ StackFrame frame;
+ string newline;
+ string unknown;
+ StringBuilder sb;
+ MethodBase method;
+
+ newline = String.Format ("{0}\t {1} ", Environment.NewLine, Locale.GetText ("at"));
+ unknown = Locale.GetText ("<unknown method>");
+ sb = new StringBuilder ();
+ stack = new StackTrace (true);
+
+ for (int i = 0; i < stack.FrameCount; i++) {
+ frame = stack.GetFrame (i);
+ sb.Append (newline);
+
+ method = frame.GetMethod ();
+ if (method != null) {
+ #if not
+ sb.AppendFormat(frame.ToString());
+ #endif
+ if (frame.GetFileLineNumber () != 0) {
+ sb.AppendFormat ("{0}.{1} () [{2}:{3}]", method.DeclaringType.FullName, method.Name, Path.GetFileName (frame.GetFileName ()), frame.GetFileLineNumber ());
+ } else {
+ sb.AppendFormat ("{0}.{1} ()", method.DeclaringType.FullName, method.Name);
+ }
+ } else {
+ sb.Append (unknown);
+ }
+ }
+ return sb.ToString ();
+ }
+ #endregion // Internal Methods
+
+ #region Private Methods
+ private static void SetupAtoms ()
+ {
+ NetAtoms = new int [(int)NA.LAST_NET_ATOM];
+
+ NetAtoms [(int)NA.WM_PROTOCOLS] = XInternAtom (DisplayHandle, "WM_PROTOCOLS", false);
+ NetAtoms [(int)NA.WM_DELETE_WINDOW] = XInternAtom (DisplayHandle, "WM_DELETE_WINDOW", false);
+ NetAtoms [(int)NA.WM_TAKE_FOCUS] = XInternAtom (DisplayHandle, "WM_TAKE_FOCUS", false);
+
+ NetAtoms [(int)NA._NET_SUPPORTED] = XInternAtom (DisplayHandle, "_NET_SUPPORTED", false);
+ NetAtoms [(int)NA._NET_CLIENT_LIST] = XInternAtom (DisplayHandle, "_NET_CLIENT_LIST", false);
+ NetAtoms [(int)NA._NET_NUMBER_OF_DESKTOPS] = XInternAtom (DisplayHandle, "_NET_NUMBER_OF_DESKTOPS", false);
+ NetAtoms [(int)NA._NET_DESKTOP_GEOMETRY] = XInternAtom (DisplayHandle, "_NET_DESKTOP_GEOMETRY", false);
+ NetAtoms [(int)NA._NET_DESKTOP_VIEWPORT] = XInternAtom (DisplayHandle, "_NET_DESKTOP_VIEWPORT", false);
+ NetAtoms [(int)NA._NET_CURRENT_DESKTOP] = XInternAtom (DisplayHandle, "_NET_CURRENT_DESKTOP", false);
+ NetAtoms [(int)NA._NET_DESKTOP_NAMES] = XInternAtom (DisplayHandle, "_NET_DESKTOP_NAMES", false);
+ NetAtoms [(int)NA._NET_ACTIVE_WINDOW] = XInternAtom (DisplayHandle, "_NET_ACTIVE_WINDOW", false);
+ NetAtoms [(int)NA._NET_WORKAREA] = XInternAtom (DisplayHandle, "_NET_WORKAREA", false);
+ NetAtoms [(int)NA._NET_SUPPORTING_WM_CHECK] = XInternAtom (DisplayHandle, "_NET_SUPPORTING_WM_CHECK", false);
+ NetAtoms [(int)NA._NET_VIRTUAL_ROOTS] = XInternAtom (DisplayHandle, "_NET_VIRTUAL_ROOTS", false);
+ NetAtoms [(int)NA._NET_DESKTOP_LAYOUT] = XInternAtom (DisplayHandle, "_NET_DESKTOP_LAYOUT", false);
+ NetAtoms [(int)NA._NET_SHOWING_DESKTOP] = XInternAtom (DisplayHandle, "_NET_SHOWING_DESKTOP", false);
+
+ NetAtoms [(int)NA._NET_CLOSE_WINDOW] = XInternAtom (DisplayHandle, "_NET_CLOSE_WINDOW", false);
+ NetAtoms [(int)NA._NET_MOVERESIZE_WINDOW] = XInternAtom (DisplayHandle, "_NET_MOVERESIZE_WINDOW", false);
+ NetAtoms [(int)NA._NET_WM_MOVERESIZE] = XInternAtom (DisplayHandle, "_NET_WM_MOVERESIZE", false);
+ NetAtoms [(int)NA._NET_RESTACK_WINDOW] = XInternAtom (DisplayHandle, "_NET_RESTACK_WINDOW", false);
+ NetAtoms [(int)NA._NET_REQUEST_FRAME_EXTENTS] = XInternAtom (DisplayHandle, "_NET_REQUEST_FRAME_EXTENTS", false);
+
+ NetAtoms [(int)NA._NET_WM_NAME] = XInternAtom (DisplayHandle, "_NET_WM_NAME", false);
+ NetAtoms [(int)NA._NET_WM_VISIBLE_NAME] = XInternAtom (DisplayHandle, "_NET_WM_VISIBLE_NAME", false);
+ NetAtoms [(int)NA._NET_WM_ICON_NAME] = XInternAtom (DisplayHandle, "_NET_WM_ICON_NAME", false);
+ NetAtoms [(int)NA._NET_WM_VISIBLE_ICON_NAME] = XInternAtom (DisplayHandle, "_NET_WM_VISIBLE_ICON_NAME", false);
+ NetAtoms [(int)NA._NET_WM_DESKTOP] = XInternAtom (DisplayHandle, "_NET_WM_DESKTOP", false);
+ NetAtoms [(int)NA._NET_WM_WINDOW_TYPE] = XInternAtom (DisplayHandle, "_NET_WM_WINDOW_TYPE", false);
+ NetAtoms [(int)NA._NET_WM_STATE] = XInternAtom (DisplayHandle, "_NET_WM_STATE", false);
+ NetAtoms [(int)NA._NET_WM_ALLOWED_ACTIONS] = XInternAtom (DisplayHandle, "_NET_WM_ALLOWED_ACTIONS", false);
+ NetAtoms [(int)NA._NET_WM_STRUT] = XInternAtom (DisplayHandle, "_NET_WM_STRUT", false);
+ NetAtoms [(int)NA._NET_WM_STRUT_PARTIAL] = XInternAtom (DisplayHandle, "_NET_WM_STRUT_PARTIAL", false);
+ NetAtoms [(int)NA._NET_WM_ICON_GEOMETRY] = XInternAtom (DisplayHandle, "_NET_WM_ICON_GEOMETRY", false);
+ NetAtoms [(int)NA._NET_WM_ICON] = XInternAtom (DisplayHandle, "_NET_WM_ICON", false);
+ NetAtoms [(int)NA._NET_WM_PID] = XInternAtom (DisplayHandle, "_NET_WM_PID", false);
+ NetAtoms [(int)NA._NET_WM_HANDLED_ICONS] = XInternAtom (DisplayHandle, "_NET_WM_HANDLED_ICONS", false);
+ NetAtoms [(int)NA._NET_WM_USER_TIME] = XInternAtom (DisplayHandle, "_NET_WM_USER_TIME", false);
+ NetAtoms [(int)NA._NET_FRAME_EXTENTS] = XInternAtom (DisplayHandle, "_NET_FRAME_EXTENTS", false);
+
+ NetAtoms [(int)NA._NET_WM_PING] = XInternAtom (DisplayHandle, "_NET_WM_PING", false);
+ NetAtoms [(int)NA._NET_WM_SYNC_REQUEST] = XInternAtom (DisplayHandle, "_NET_WM_SYNC_REQUEST", false);
+
+ NetAtoms [(int)NA._NET_SYSTEM_TRAY_S] = XInternAtom (DisplayHandle, "_NET_SYSTEM_TRAY_S" + ScreenNo.ToString (), false);
+ NetAtoms [(int)NA._NET_SYSTEM_TRAY_OPCODE] = XInternAtom (DisplayHandle, "_NET_SYSTEM_TRAY_OPCODE", false);
+ NetAtoms [(int)NA._NET_SYSTEM_TRAY_ORIENTATION] = XInternAtom (DisplayHandle, "_NET_SYSTEM_TRAY_ORIENTATION", false);
+
+ NetAtoms [(int)NA._NET_WM_STATE_MAXIMIZED_HORZ] = XInternAtom (DisplayHandle, "_NET_WM_STATE_MAXIMIZED_HORZ", false);
+ NetAtoms [(int)NA._NET_WM_STATE_MAXIMIZED_VERT] = XInternAtom (DisplayHandle, "_NET_WM_STATE_MAXIMIZED_VERT", false);
+ NetAtoms [(int)NA._NET_WM_STATE_HIDDEN] = XInternAtom (DisplayHandle, "_NET_WM_STATE_HIDDEN", false);
+
+ NetAtoms [(int)NA._XEMBED] = XInternAtom (DisplayHandle, "_XEMBED", false);
+ NetAtoms [(int)NA._XEMBED_INFO] = XInternAtom (DisplayHandle, "_XEMBED_INFO", false);
+
+ NetAtoms [(int)NA._MOTIF_WM_HINTS] = XInternAtom (DisplayHandle, "_MOTIF_WM_HINTS", false);
+
+ NetAtoms [(int)NA._NET_WM_STATE_NO_TASKBAR] = XInternAtom (DisplayHandle, "_NET_WM_STATE_NO_TASKBAR", false);
+ NetAtoms [(int)NA._NET_WM_STATE_ABOVE] = XInternAtom (DisplayHandle, "_NET_WM_STATE_ABOVE", false);
+ NetAtoms [(int)NA._NET_WM_STATE_MODAL] = XInternAtom (DisplayHandle, "_NET_WM_STATE_MODAL", false);
+ NetAtoms [(int)NA._NET_WM_CONTEXT_HELP] = XInternAtom (DisplayHandle, "_NET_WM_CONTEXT_HELP", false);
+ NetAtoms [(int)NA._NET_WM_WINDOW_OPACITY] = XInternAtom (DisplayHandle, "_NET_WM_WINDOW_OPACITY", false);
+
+ // Clipboard support
+ NetAtoms [(int)NA.CLIPBOARD] = XInternAtom (DisplayHandle, "CLIPBOARD", false);
+ NetAtoms [(int)NA.DIB] = (int)Atom.XA_PIXMAP;
+ NetAtoms [(int)NA.OEMTEXT] = XInternAtom (DisplayHandle, "COMPOUND_TEXT", false);
+ NetAtoms [(int)NA.UNICODETEXT] = XInternAtom (DisplayHandle, "UTF8_STRING", false);
+ NetAtoms [(int)NA.TARGETS] = XInternAtom (DisplayHandle, "TARGETS", false);
+
+ // Special Atoms
+ AsyncAtom = XInternAtom (DisplayHandle, "_SWF_AsyncAtom", false);
+ PostAtom = XInternAtom (DisplayHandle, "_SWF_PostMessageAtom", false);
+ HoverState.Atom = XInternAtom (DisplayHandle, "_SWF_HoverAtom", false);
+ }
+
+ private void GetSystrayManagerWindow ()
+ {
+ gdk_x11_grab_server ();
+ SystrayMgrWindow = XGetSelectionOwner (DisplayHandle, NetAtoms [(int)NA._NET_SYSTEM_TRAY_S]);
+ gdk_x11_ungrab_server ();
+ gdk_display_flush (GdkDisplayHandle);
+ }
+
+ private void SendNetWMMessage (IntPtr window, IntPtr message_type, IntPtr l0, IntPtr l1, IntPtr l2)
+ {
+ XEvent xev;
+
+ xev = new XEvent ();
+ xev.ClientMessageEvent.type = XEventName.ClientMessage;
+ xev.ClientMessageEvent.send_event = true;
+ xev.ClientMessageEvent.window = window;
+ xev.ClientMessageEvent.message_type = message_type;
+ xev.ClientMessageEvent.format = 32;
+ xev.ClientMessageEvent.ptr1 = l0;
+ xev.ClientMessageEvent.ptr2 = l1;
+ xev.ClientMessageEvent.ptr3 = l2;
+ XSendEvent (DisplayHandle, RootWindow, false, EventMask.SubstructureRedirectMask | EventMask.SubstructureNotifyMask, ref xev);
+ }
+
+ private void SendNetClientMessage (IntPtr window, IntPtr message_type, IntPtr l0, IntPtr l1, IntPtr l2)
+ {
+ XEvent xev;
+
+ xev = new XEvent ();
+ xev.ClientMessageEvent.type = XEventName.ClientMessage;
+ xev.ClientMessageEvent.send_event = true;
+ xev.ClientMessageEvent.window = window;
+ xev.ClientMessageEvent.message_type = message_type;
+ xev.ClientMessageEvent.format = 32;
+ xev.ClientMessageEvent.ptr1 = l0;
+ xev.ClientMessageEvent.ptr2 = l1;
+ xev.ClientMessageEvent.ptr3 = l2;
+ XSendEvent (DisplayHandle, window, false, EventMask.NoEventMask, ref xev);
+ }
+
+ private void DeriveStyles (IntPtr handle, int Style, int ExStyle, out FormBorderStyle border_style, out TitleStyle title_style, out int caption_height, out int tool_caption_height)
+ {
+
+ // Only MDI windows get caption_heights
+ caption_height = 0;
+ tool_caption_height = 19;
+
+ if ((Style & (int) WindowStyles.WS_CHILD) != 0) {
+ if ((Style & (int) WindowStyles.WS_BORDER) == 0) {
+ border_style = FormBorderStyle.None;
+ } else if ((ExStyle & (int) WindowStyles.WS_EX_CLIENTEDGE) != 0) {
+ border_style = FormBorderStyle.Fixed3D;
+ } else {
+ border_style = FormBorderStyle.FixedSingle;
+ }
+ title_style = TitleStyle.None;
+ } else {
+ bool is_mdi = false;
+
+ if ((ExStyle & (int) WindowStyles.WS_EX_MDICHILD) != 0) {
+ caption_height = 26;
+ is_mdi = true;
+ }
+
+ title_style = TitleStyle.None;
+ if ((Style & (int)WindowStyles.WS_CAPTION) != 0) {
+ if ((ExStyle & (int)WindowStyles.WS_EX_TOOLWINDOW) != 0) {
+ title_style = TitleStyle.Tool;
+ } else {
+ title_style = TitleStyle.Normal;
+ }
+ }
+
+ if (!is_mdi) {
+ border_style = FormBorderStyle.None;
+
+ if ((Style & (int)WindowStyles.WS_THICKFRAME) != 0) {
+ if ((ExStyle & (int)WindowStyles.WS_EX_TOOLWINDOW) != 0) {
+ border_style = FormBorderStyle.SizableToolWindow;
+ } else {
+ border_style = FormBorderStyle.Sizable;
+ }
+ } else {
+ if ((ExStyle & (int)WindowStyles.WS_EX_CLIENTEDGE) != 0) {
+ border_style = FormBorderStyle.Fixed3D;
+ } else if ((ExStyle & (int)WindowStyles.WS_EX_DLGMODALFRAME) != 0) {
+ border_style = FormBorderStyle.FixedDialog;
+ } else if ((ExStyle & (int)WindowStyles.WS_EX_TOOLWINDOW) != 0) {
+ border_style = FormBorderStyle.FixedToolWindow;
+ } else if ((Style & (int)WindowStyles.WS_BORDER) != 0) {
+ border_style = FormBorderStyle.Sizable;
+ } else {
+ border_style = FormBorderStyle.None;
+ }
+ }
+ } else {
+ if ((Style & (int) WindowStyles.WS_OVERLAPPEDWINDOW) != 0 ||
+ (ExStyle & (int) WindowStyles.WS_EX_TOOLWINDOW) != 0) {
+ border_style = (FormBorderStyle) 0xFFFF;
+ } else {
+ border_style = FormBorderStyle.None;
+ }
+ }
+ }
+ }
+
+ private void SetHwndStyles (Hwnd hwnd, CreateParams cp)
+ {
+ DeriveStyles (hwnd.Handle, cp.Style, cp.ExStyle, out hwnd.border_style, out hwnd.title_style, out hwnd.caption_height, out hwnd.tool_caption_height);
+ }
+
+ private void SetWMStyles (Hwnd hwnd, CreateParams cp)
+ {
+ GdkWMDecoration decorations = GdkWMDecoration.GDK_DECOR_ALL;
+
+ if ((cp.Style & (int)WindowStyles.WS_CAPTION) != 0) {
+ decorations |= GdkWMDecoration.GDK_DECOR_TITLE | GdkWMDecoration.GDK_DECOR_MENU;
+ }
+
+ if ((cp.Style & ((int)WindowStyles.WS_THICKFRAME)) != 0) {
+ decorations |= GdkWMDecoration.GDK_DECOR_BORDER | GdkWMDecoration.GDK_DECOR_RESIZEH;
+ }
+ if ((cp.Style & ((int)WindowStyles.WS_MINIMIZEBOX)) != 0) {
+ decorations |= GdkWMDecoration.GDK_DECOR_MINIMIZE;
+ }
+
+ if ((cp.Style & ((int)WindowStyles.WS_MAXIMIZEBOX)) != 0) {
+ decorations |= GdkWMDecoration.GDK_DECOR_MAXIMIZE;
+ }
+
+ // is this needed ? most window managers do not even honour any MotifFunctions...
+// if ((cp.Style & ((int)WindowStyles.WS_SYSMENU)) != 0) {
+// functions |= MotifFunctions.Close;
+// }
+
+ if ((cp.ExStyle & ((int)WindowStyles.WS_EX_DLGMODALFRAME)) != 0) {
+ decorations |= GdkWMDecoration.GDK_DECOR_BORDER;
+ }
+
+ if ((cp.Style & ((int)WindowStyles.WS_DLGFRAME)) != 0) {
+ decorations |= GdkWMDecoration.GDK_DECOR_BORDER;
+ }
+
+ if ((cp.Style & ((int)WindowStyles.WS_BORDER)) != 0) {
+ decorations |= GdkWMDecoration.GDK_DECOR_BORDER;
+ }
+
+ if ((cp.ExStyle & ((int)WindowStyles.WS_EX_TOOLWINDOW)) != 0) {
+ decorations = 0;
+ }
+
+ gdk_window_set_decorations (gdk_window_foreign_new (hwnd.whole_window), (int)decorations);
+ }
+
+ private void SetIcon (Hwnd hwnd, Icon icon)
+ {
+ Bitmap bitmap;
+ int size;
+ uint[] data;
+ int index;
+
+ bitmap = icon.ToBitmap ();
+ index = 0;
+ size = bitmap.Width * bitmap.Height + 2;
+ data = new uint [size];
+
+ data [index++] = (uint)bitmap.Width;
+ data [index++] = (uint)bitmap.Height;
+
+ for (int y = 0; y < bitmap.Height; y++) {
+ for (int x = 0; x < bitmap.Width; x++) {
+ data [index++] = (uint)bitmap.GetPixel (x, y).ToArgb ();
+ }
+ }
+ XChangeProperty (DisplayHandle, hwnd.whole_window, NetAtoms [(int)NA._NET_WM_ICON], Atom.XA_CARDINAL, 32, PropertyMode.Replace, data, size);
+ }
+
+ private IntPtr ImageToPixmap (Image image)
+ {
+ return IntPtr.Zero;
+ }
+
+ private void WakeupMain ()
+ {
+ wake.Send (new byte [] { 0xFF });
+ }
+
+ private void TranslatePropertyToClipboard (int property)
+ {
+ Atom actual_atom;
+ int actual_format;
+ int nitems;
+ int bytes_after;
+ IntPtr prop = IntPtr.Zero;
+
+ Clipboard.Item = null;
+
+ XGetWindowProperty (DisplayHandle, FosterParent, property, 0, 0x7fffffff, true, Atom.AnyPropertyType, out actual_atom, out actual_format, out nitems, out bytes_after, ref prop);
+
+ if (nitems > 0) {
+ if (property == (int)Atom.XA_STRING) {
+ Clipboard.Item = Marshal.PtrToStringAnsi (prop);
+ } else if (property == (int)Atom.XA_BITMAP) {
+ // FIXME - convert bitmap to image
+ } else if (property == (int)Atom.XA_PIXMAP) {
+ // FIXME - convert pixmap to image
+ } else if (property == NetAtoms [(int)NA.OEMTEXT]) {
+ Clipboard.Item = Marshal.PtrToStringAnsi (prop);
+ } else if (property == NetAtoms [(int)NA.UNICODETEXT]) {
+ Clipboard.Item = Marshal.PtrToStringAnsi (prop);
+ }
+
+ XFree (prop);
+ }
+ }
+
+ private void AddExpose (XEvent xevent)
+ {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.GetObjectFromWindow (xevent.AnyEvent.window);
+
+ // Don't waste time
+ if (hwnd == null) {
+ return;
+ }
+
+ if (xevent.AnyEvent.window == hwnd.client_window) {
+ hwnd.AddInvalidArea (xevent.ExposeEvent.x, xevent.ExposeEvent.y, xevent.ExposeEvent.width, xevent.ExposeEvent.height);
+ if (!hwnd.expose_pending) {
+ MessageQueue.Enqueue (xevent);
+ hwnd.expose_pending = true;
+ }
+ } else {
+ if (!hwnd.nc_expose_pending) {
+ MessageQueue.Enqueue (xevent);
+ hwnd.nc_expose_pending = true;
+ }
+ }
+ }
+
+ private void InvalidateWholeWindow (IntPtr handle)
+ {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ InvalidateWholeWindow (handle, new Rectangle (0, 0, hwnd.Width, hwnd.Height));
+ }
+
+ private void InvalidateWholeWindow (IntPtr handle, Rectangle rectangle)
+ {
+ Hwnd hwnd;
+ XEvent xevent;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+
+ xevent = new XEvent ();
+ xevent.type = XEventName.Expose;
+ xevent.ExposeEvent.display = DisplayHandle;
+ xevent.ExposeEvent.window = hwnd.whole_window;
+
+ xevent.ExposeEvent.x = rectangle.X;
+ xevent.ExposeEvent.y = rectangle.Y;
+ xevent.ExposeEvent.width = rectangle.Width;
+ xevent.ExposeEvent.height = rectangle.Height;
+
+ AddExpose (xevent);
+ }
+
+ private void WholeToScreen (IntPtr handle, ref int x, ref int y)
+ {
+ int dest_x_return;
+ int dest_y_return;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ lock (XlibLock) {
+ gdk_window_get_origin (gdk_window_lookup (hwnd.whole_window), out dest_x_return, out dest_y_return);
+ }
+
+ x = dest_x_return;
+ y = dest_y_return;
+ }
+
+ private void AddConfigureNotify (XEvent xevent)
+ {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.GetObjectFromWindow (xevent.ConfigureEvent.window);
+
+ // Don't waste time
+ if (hwnd == null) {
+ return;
+ }
+
+ if (xevent.ConfigureEvent.window == hwnd.whole_window) {
+ if (!hwnd.reparented) {
+ hwnd.x = xevent.ConfigureEvent.x;
+ hwnd.y = xevent.ConfigureEvent.y;
+ } else {
+ int dummy_int;
+
+ gdk_window_get_geometry (gdk_window_lookup (hwnd.whole_window), out hwnd.x, out hwnd.y, out dummy_int, out dummy_int, out dummy_int);
+ }
+
+ hwnd.width = xevent.ConfigureEvent.width;
+ hwnd.height = xevent.ConfigureEvent.height;
+
+ if (!hwnd.configure_pending) {
+ MessageQueue.Enqueue (xevent);
+ hwnd.configure_pending = true;
+ }
+ }
+ // We drop configure events for Client windows
+ }
+
+ private void ShowCaret ()
+ {
+ if ((Caret.gc == IntPtr.Zero) || Caret.On) {
+ return;
+ }
+ Caret.On = true;
+
+ // gdk_gc_set_foreground
+ // gdk_draw_line
+ lock (XlibLock) {
+ XDrawLine (DisplayHandle, Caret.Window, Caret.gc, Caret.X, Caret.Y, Caret.X, Caret.Y + Caret.Height);
+ }
+ }
+
+ private void HideCaret ()
+ {
+ if ((Caret.gc == IntPtr.Zero) || !Caret.On) {
+ return;
+ }
+ Caret.On = false;
+
+ // gdk_gc_set_foreground
+ // gdk_draw_text_wc
+ lock (XlibLock) {
+ XDrawLine (DisplayHandle, Caret.Window, Caret.gc, Caret.X, Caret.Y, Caret.X, Caret.Y + Caret.Height);
+ }
+ }
+
+ private int NextTimeout (DateTime now)
+ {
+ int timeout = Int32.MaxValue;
+ lock (TimerList) {
+ foreach (Timer timer in TimerList) {
+ int next = (int) (timer.Expires - now).TotalMilliseconds;
+ if (next < 0) {
+ return 0; // Have a timer that has already expired
+ }
+
+ if (next < timeout) {
+ timeout = next;
+ }
+ }
+ }
+ if (timeout < Timer.Minimum) {
+ timeout = Timer.Minimum;
+ }
+
+ return timeout;
+ }
+
+ private void CheckTimers (DateTime now)
+ {
+ lock (TimerList) {
+ int count;
+
+ count = TimerList.Count;
+
+ if (count == 0) {
+ return;
+ }
+
+ for (int i = 0; i < TimerList.Count; i++) {
+ Timer timer;
+
+ timer = (Timer) TimerList [i];
+
+ if (timer.Enabled && timer.Expires <= now) {
+ timer.Update (now);
+ timer.FireTick ();
+ }
+ }
+ }
+ }
+
+ private void UpdateMessageQueue ()
+ {
+ DateTime now;
+ int pending;
+
+ now = DateTime.Now;
+
+ lock (XlibLock) {
+ pending = XPending (DisplayHandle);
+ }
+
+ if (pending == 0) {
+ if (Idle != null) {
+ Idle (this, EventArgs.Empty);
+ }
+
+ lock (XlibLock) {
+ pending = XPending (DisplayHandle);
+ }
+ }
+
+ if (pending == 0) {
+ int timeout;
+
+ timeout = NextTimeout (now);
+ if (timeout > 0) {
+ #if __MonoCS__
+ Syscall.poll (pollfds, (uint) pollfds.Length, timeout);
+ // Clean out buffer, so we're not busy-looping on the same data
+ if (pollfds[1].revents != 0) {
+ wake_receive.Receive(network_buffer, 0, 1, SocketFlags.None);
+ }
+ #endif
+ lock (XlibLock) {
+ pending = XPending (DisplayHandle);
+ }
+ }
+ }
+
+ CheckTimers (now);
+
+ if (pending == 0) {
+ lock (XlibLock) {
+ pending = XPending (DisplayHandle);
+ }
+ }
+
+ while (pending > 0) {
+ XEvent xevent = new XEvent ();
+
+ lock (XlibLock) {
+ XNextEvent (DisplayHandle, ref xevent);
+ }
+//Console.WriteLine("Got x event {0}", xevent);
+ switch (xevent.type) {
+ case XEventName.Expose:
+ AddExpose (xevent);
+ break;
+
+ case XEventName.SelectionClear: {
+ // Should we do something?
+ break;
+ }
+
+ case XEventName.SelectionRequest: {
+ if (Dnd.HandleSelectionRequestEvent (ref xevent))
+ break;
+ XEvent sel_event;
+
+ sel_event = new XEvent ();
+ sel_event.SelectionEvent.type = XEventName.SelectionNotify;
+ sel_event.SelectionEvent.send_event = true;
+ sel_event.SelectionEvent.display = DisplayHandle;
+ sel_event.SelectionEvent.selection = xevent.SelectionRequestEvent.selection;
+ sel_event.SelectionEvent.target = xevent.SelectionRequestEvent.target;
+ sel_event.SelectionEvent.requestor = xevent.SelectionRequestEvent.requestor;
+ sel_event.SelectionEvent.time = xevent.SelectionRequestEvent.time;
+ sel_event.SelectionEvent.property = 0;
+
+ // Seems that some apps support asking for supported types
+ if (xevent.SelectionEvent.target == NetAtoms [(int)NA.TARGETS]) {
+ uint[] atoms;
+ int atom_count;
+
+ atoms = new uint [5];
+ atom_count = 0;
+
+ if (Clipboard.Item is String) {
+ atoms [atom_count++] = (uint)Atom.XA_STRING;
+ atoms [atom_count++] = (uint)NetAtoms [(int)NA.OEMTEXT];
+ atoms [atom_count++] = (uint)NetAtoms [(int)NA.UNICODETEXT];
+ } else if (Clipboard.Item is Image) {
+ atoms [atom_count++] = (uint)Atom.XA_PIXMAP;
+ atoms [atom_count++] = (uint)Atom.XA_BITMAP;
+ } else {
+ // FIXME - handle other types
+ }
+
+ XChangeProperty (DisplayHandle, xevent.SelectionEvent.requestor, xevent.SelectionRequestEvent.property, xevent.SelectionRequestEvent.target, 32, PropertyMode.Replace, atoms, atom_count);
+ } else if (Clipboard.Item is string) {
+ IntPtr buffer;
+ int buflen;
+
+ buflen = 0;
+
+ if (xevent.SelectionRequestEvent.target == (int)Atom.XA_STRING) {
+ Byte[] bytes;
+
+ bytes = new ASCIIEncoding ().GetBytes ((string)Clipboard.Item);
+ buffer = Marshal.AllocHGlobal (bytes.Length);
+ buflen = bytes.Length;
+
+ for (int i = 0; i < buflen; i++) {
+ Marshal.WriteByte (buffer, i, bytes [i]);
+ }
+ } else if (xevent.SelectionRequestEvent.target == NetAtoms [(int)NA.OEMTEXT]) {
+ // FIXME - this should encode into ISO2022
+ buffer = Marshal.StringToHGlobalAnsi ((string)Clipboard.Item);
+ while (Marshal.ReadByte (buffer, buflen) != 0) {
+ buflen++;
+ }
+ } else if (xevent.SelectionRequestEvent.target == NetAtoms [(int)NA.UNICODETEXT]) {
+ buffer = Marshal.StringToHGlobalAnsi ((string)Clipboard.Item);
+ while (Marshal.ReadByte (buffer, buflen) != 0) {
+ buflen++;
+ }
+ } else {
+ buffer = IntPtr.Zero;
+ }
+
+ if (buffer != IntPtr.Zero) {
+ XChangeProperty (DisplayHandle, xevent.SelectionRequestEvent.requestor, xevent.SelectionRequestEvent.property, xevent.SelectionRequestEvent.target, 8, PropertyMode.Replace, buffer, buflen);
+ sel_event.SelectionEvent.property = xevent.SelectionRequestEvent.property;
+ Marshal.FreeHGlobal (buffer);
+ }
+ } else if (Clipboard.Item is Image) {
+ if (xevent.SelectionEvent.target == (int)Atom.XA_PIXMAP) {
+ // FIXME - convert image and store as property
+ } else if (xevent.SelectionEvent.target == (int)Atom.XA_PIXMAP) {
+ // FIXME - convert image and store as property
+ }
+ }
+
+ XSendEvent (DisplayHandle, xevent.SelectionRequestEvent.requestor, false, EventMask.NoEventMask, ref sel_event);
+ break;
+ }
+
+ case XEventName.SelectionNotify: {
+ if (Clipboard.Enumerating) {
+ Clipboard.Enumerating = false;
+ if (xevent.SelectionEvent.property != 0) {
+ XDeleteProperty (DisplayHandle, FosterParent, xevent.SelectionEvent.property);
+ if (!Clipboard.Formats.Contains (xevent.SelectionEvent.property)) {
+ Clipboard.Formats.Add (xevent.SelectionEvent.property);
+ #if DriverDebugExtra
+ Console.WriteLine("Got supported clipboard atom format: {0}", xevent.SelectionEvent.property);
+ #endif
+ }
+ }
+ } else if (Clipboard.Retrieving) {
+ Clipboard.Retrieving = false;
+ if (xevent.SelectionEvent.property != 0) {
+ TranslatePropertyToClipboard (xevent.SelectionEvent.property);
+ } else {
+ Clipboard.Item = null;
+ }
+ } else {
+ Dnd.HandleSelectionNotifyEvent (ref xevent);
+ }
+ break;
+ }
+
+ case XEventName.KeyPress:
+ case XEventName.KeyRelease:
+ case XEventName.ButtonPress:
+ case XEventName.ButtonRelease:
+ case XEventName.MotionNotify:
+ case XEventName.EnterNotify:
+ case XEventName.LeaveNotify:
+ case XEventName.CreateNotify:
+ case XEventName.DestroyNotify:
+ case XEventName.FocusIn:
+ case XEventName.FocusOut:
+ case XEventName.ClientMessage:
+ case XEventName.ReparentNotify:
+ MessageQueue.Enqueue (xevent);
+ break;
+
+ case XEventName.ConfigureNotify:
+ AddConfigureNotify (xevent);
+ break;
+
+ case XEventName.PropertyNotify:
+ if (xevent.PropertyEvent.atom == NetAtoms [(int)NA._NET_ACTIVE_WINDOW]) {
+ Atom actual_atom;
+ int actual_format;
+ int nitems;
+ int bytes_after;
+ IntPtr prop = IntPtr.Zero;
+ IntPtr prev_active;;
+
+ prev_active = ActiveWindow;
+ XGetWindowProperty (DisplayHandle, RootWindow, NetAtoms [(int)NA._NET_ACTIVE_WINDOW], 0, 1, false, Atom.XA_WINDOW, out actual_atom, out actual_format, out nitems, out bytes_after, ref prop);
+ if ((nitems > 0) && (prop != IntPtr.Zero)) {
+ ActiveWindow = Hwnd.GetHandleFromWindow ((IntPtr)Marshal.ReadInt32 (prop));
+ XFree (prop);
+
+ if (prev_active != ActiveWindow) {
+ if (prev_active != IntPtr.Zero) {
+ PostMessage (prev_active, Msg.WM_ACTIVATE, (IntPtr)WindowActiveFlags.WA_INACTIVE, IntPtr.Zero);
+ }
+ if (ActiveWindow != IntPtr.Zero) {
+ PostMessage (ActiveWindow, Msg.WM_ACTIVATE, (IntPtr)WindowActiveFlags.WA_ACTIVE, IntPtr.Zero);
+ }
+ }
+ if (ModalWindows.Count == 0) {
+ break;
+ } else {
+ // Modality handling, if we are modal and the new active window is one
+ // of ours but not the modal one, switch back to the modal window
+
+ if (NativeWindow.FindWindow (ActiveWindow) != null) {
+ if (ActiveWindow != (IntPtr)ModalWindows.Peek ()) {
+ Activate ((IntPtr)ModalWindows.Peek ());
+ }
+ }
+ break;
+ }
+ }
+ }
+ break;
+
+ }
+
+ lock (XlibLock) {
+ pending = XPending (DisplayHandle);
+ }
+ }
+ }
+
+ private IntPtr GetMousewParam (int Delta)
+ {
+ int result = 0;
+
+ if ((MouseState & MouseButtons.Left) != 0) {
+ result |= (int)MsgButtons.MK_LBUTTON;
+ }
+
+ if ((MouseState & MouseButtons.Middle) != 0) {
+ result |= (int)MsgButtons.MK_MBUTTON;
+ }
+
+ if ((MouseState & MouseButtons.Right) != 0) {
+ result |= (int)MsgButtons.MK_RBUTTON;
+ }
+
+ Keys mods = ModifierKeys;
+ if ((mods & Keys.Control) != 0) {
+ result |= (int)MsgButtons.MK_CONTROL;
+ }
+
+ if ((mods & Keys.Shift) != 0) {
+ result |= (int)MsgButtons.MK_SHIFT;
+ }
+
+ result |= Delta << 16;
+
+ return (IntPtr)result;
+ }
+ private IntPtr XGetParent (IntPtr handle)
+ {
+ return gdk_x11_drawable_get_xid (gdk_window_get_parent (gdk_window_lookup (handle)));
+ }
+
+ private int HandleError (IntPtr display, ref XErrorEvent error_event)
+ {
+ if (ErrorExceptions) {
+ throw new XException (error_event.display, error_event.resourceid, error_event.serial, error_event.error_code, error_event.request_code, error_event.minor_code);
+ } else {
+ Console.WriteLine ("X11 Error encountered: {0}{1}\n", XException.GetMessage (error_event.display, error_event.resourceid, error_event.serial, error_event.error_code, error_event.request_code, error_event.minor_code), WhereString ());
+ }
+ return 0;
+ }
+
+ private void DestroyChildWindow (Control c)
+ {
+ Hwnd hwnd;
+ int i;
+ Control[] controls;
+
+ if (c != null) {
+ controls = c.child_controls.GetAllControls ();
+
+ for (i = 0; i < controls.Length; i++) {
+ if (controls [i].IsHandleCreated) {
+ hwnd = Hwnd.ObjectFromHandle (controls [i].Handle);
+ SendMessage (controls [i].Handle, Msg.WM_DESTROY, IntPtr.Zero, IntPtr.Zero);
+ hwnd.Dispose ();
+ }
+ DestroyChildWindow (controls [i]);
+ }
+ }
+ }
+
+ #endregion // Private Methods
+
+ #region Callbacks
+ private void MouseHover (object sender, EventArgs e)
+ {
+ if ((HoverState.X == MousePosition.X) && (HoverState.Y == MousePosition.Y)) {
+ XEvent xevent;
+
+ HoverState.Timer.Enabled = false;
+
+ if (HoverState.Window != IntPtr.Zero) {
+ xevent = new XEvent ();
+
+ xevent.type = XEventName.ClientMessage;
+ xevent.ClientMessageEvent.display = DisplayHandle;
+ xevent.ClientMessageEvent.window = (IntPtr)HoverState.Window;
+ xevent.ClientMessageEvent.message_type = (IntPtr)HoverState.Atom;
+ xevent.ClientMessageEvent.format = 32;
+ xevent.ClientMessageEvent.ptr1 = (IntPtr) (HoverState.Y << 16 | HoverState.X);
+
+ MessageQueue.EnqueueLocked (xevent);
+
+ WakeupMain ();
+ }
+ }
+ }
+
+ private void CaretCallback (object sender, EventArgs e)
+ {
+ if (Caret.Paused) {
+ return;
+ }
+ Caret.On = !Caret.On;
+
+ XDrawLine (DisplayHandle, Caret.Hwnd, Caret.gc, Caret.X, Caret.Y, Caret.X, Caret.Y + Caret.Height);
+ }
+ #endregion // Callbacks
+
+ #region Public Properties
+
+ internal override int Caption {
+ get {
+ return 25;
+ }
+ }
+
+ internal override Size CursorSize {
+ get {
+ uint x;
+ uint y;
+ gdk_display_get_maximal_cursor_size (GdkDisplayHandle, out x, out y);
+
+ return new Size ((int)x, (int)y);
+ }
+ }
+
+ internal override bool DragFullWindows {
+ get {
+ return true;
+ }
+ }
+
+ internal override Size DragSize {
+ get {
+ return new Size (4, 4);
+ }
+ }
+
+ internal override Size FrameBorderSize {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ internal override Size IconSize {
+ get {
+ IntPtr list;
+ XIconSize size;
+ int count;
+
+ if (XGetIconSizes (DisplayHandle, RootWindow, out list, out count) != 0) {
+ long current;
+ int largest;
+
+ current = (long)list;
+ largest = 0;
+
+ size = new XIconSize ();
+
+ for (int i = 0; i < count; i++) {
+ size = (XIconSize)Marshal.PtrToStructure ((IntPtr)current, size.GetType ());
+ current += Marshal.SizeOf (size);
+
+ // Look for our preferred size
+ if (size.min_width == 32) {
+ XFree (list);
+ return new Size (32, 32);
+ }
+
+ if (size.max_width == 32) {
+ XFree (list);
+ return new Size (32, 32);
+ }
+
+ if (size.min_width < 32 && size.max_width > 32) {
+ int x;
+
+ // check if we can fit one
+ x = size.min_width;
+ while (x < size.max_width) {
+ x += size.width_inc;
+ if (x == 32) {
+ XFree (list);
+ return new Size (32, 32);
+ }
+ }
+ }
+
+ if (largest < size.max_width) {
+ largest = size.max_width;
+ }
+ }
+
+ // We didn't find a match or we wouldn't be here
+ return new Size (largest, largest);
+
+ } else {
+ return new Size (32, 32);
+ }
+ }
+ }
+
+ internal override int KeyboardSpeed {
+ get {
+ //
+ // A lot harder: need to do:
+ // XkbQueryExtension(0x08051008, 0xbfffdf4c, 0xbfffdf50, 0xbfffdf54, 0xbfffdf58) = 1
+ // XkbAllocKeyboard(0x08051008, 0xbfffdf4c, 0xbfffdf50, 0xbfffdf54, 0xbfffdf58) = 0x080517a8
+ // XkbGetControls(0x08051008, 1, 0x080517a8, 0xbfffdf54, 0xbfffdf58) = 0
+ //
+ // And from that we can tell the repetition rate
+ //
+ // Notice, the values must map to:
+ // [0, 31] which maps to 2.5 to 30 repetitions per second.
+ //
+ return 0;
+ }
+ }
+
+ internal override int KeyboardDelay {
+ get {
+ //
+ // Return values must range from 0 to 4, 0 meaning 250ms,
+ // and 4 meaning 1000 ms.
+ //
+ return 1; // ie, 500 ms
+ }
+ }
+
+ internal override Size MaxWindowTrackSize {
+ get {
+ return new Size (WorkingArea.Width, WorkingArea.Height);
+ }
+ }
+
+ internal override Size MinimizedWindowSize {
+ get {
+ return new Size (1, 1);
+ }
+ }
+
+ internal override Size MinimizedWindowSpacingSize {
+ get {
+ return new Size (1, 1);
+ }
+ }
+
+ internal override Size MinimumWindowSize {
+ get {
+ return new Size (1, 1);
+ }
+ }
+
+ internal override Size MinWindowTrackSize {
+ get {
+ return new Size (1, 1);
+ }
+ }
+
+ internal override Keys ModifierKeys {
+ get {
+ return Keyboard.ModifierKeys;
+ }
+ }
+
+ internal override Size SmallIconSize {
+ get {
+ IntPtr list;
+ XIconSize size;
+ int count;
+
+ if (XGetIconSizes (DisplayHandle, RootWindow, out list, out count) != 0) {
+ long current;
+ int smallest;
+
+ current = (long)list;
+ smallest = 0;
+
+ size = new XIconSize ();
+
+ for (int i = 0; i < count; i++) {
+ size = (XIconSize)Marshal.PtrToStructure ((IntPtr)current, size.GetType ());
+ current += Marshal.SizeOf (size);
+
+ // Look for our preferred size
+ if (size.min_width == 16) {
+ XFree (list);
+ return new Size (16, 16);
+ }
+
+ if (size.max_width == 16) {
+ XFree (list);
+ return new Size (16, 16);
+ }
+
+ if (size.min_width < 16 && size.max_width > 16) {
+ int x;
+
+ // check if we can fit one
+ x = size.min_width;
+ while (x < size.max_width) {
+ x += size.width_inc;
+ if (x == 16) {
+ XFree (list);
+ return new Size (16, 16);
+ }
+ }
+ }
+
+ if (smallest == 0 || smallest > size.min_width) {
+ smallest = size.min_width;
+ }
+ }
+
+ // We didn't find a match or we wouldn't be here
+ return new Size (smallest, smallest);
+
+ } else {
+ return new Size (16, 16);
+ }
+ }
+ }
+
+ internal override int MouseButtonCount {
+ get {
+ return 3;
+ }
+ }
+
+ internal override bool MouseButtonsSwapped {
+ get {
+ return false; // FIXME - how to detect?
+ }
+ }
+
+ internal override bool MouseWheelPresent {
+ get {
+ return true; // FIXME - how to detect?
+ }
+ }
+
+ internal override Rectangle VirtualScreen {
+ get {
+ return WorkingArea;
+ }
+ }
+
+ internal override Rectangle WorkingArea {
+ get {
+ Atom actual_atom;
+ int actual_format;
+ int nitems;
+ int bytes_after;
+ IntPtr prop = IntPtr.Zero;
+ int width;
+ int height;
+
+ XGetWindowProperty (DisplayHandle, RootWindow, NetAtoms [(int)NA._NET_DESKTOP_GEOMETRY], 0, 256, false, Atom.XA_CARDINAL, out actual_atom, out actual_format, out nitems, out bytes_after, ref prop);
+ if ((nitems == 2) && (prop != IntPtr.Zero)) {
+ width = Marshal.ReadInt32 (prop, 0);
+ height = Marshal.ReadInt32 (prop, 4);
+
+ XFree (prop);
+ return new Rectangle (0, 0, width, height);
+ } else {
+ XWindowAttributes attributes=new XWindowAttributes ();
+
+ lock (XlibLock) {
+ XGetWindowAttributes (DisplayHandle, XRootWindow (DisplayHandle, ScreenNo), ref attributes);
+ }
+
+ return new Rectangle (0, 0, attributes.width, attributes.height);
+ }
+ }
+ }
+ #endregion // Public properties
+
+ #region Public Static Methods
+ internal override IntPtr InitializeDriver ()
+ {
+ lock (this) {
+ if (GdkDisplayHandle == IntPtr.Zero) {
+ SetDisplay (gdk_x11_display_get_xdisplay (gdk_display_get_default ()));
+ }
+ }
+ return IntPtr.Zero;
+ }
+
+ internal override void ShutdownDriver (IntPtr token)
+ {
+ lock (this) {
+ if (GdkDisplayHandle != IntPtr.Zero) {
+ gdk_display_close (GdkDisplayHandle);
+ DisplayHandle = IntPtr.Zero;
+ GdkDisplayHandle = IntPtr.Zero;
+ }
+ }
+ }
+
+ internal override void EnableThemes ()
+ {
+ ThemesEnabled = true;
+ }
+
+
+ internal override void Activate (IntPtr handle)
+ {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ if (hwnd != null) lock (XlibLock) {
+ SendNetWMMessage (hwnd.whole_window, (IntPtr)NetAtoms [(int)NA._NET_ACTIVE_WINDOW], IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
+ //XRaiseWindow(DisplayHandle, handle);
+ }
+ return;
+ }
+
+ internal override void AudibleAlert ()
+ {
+ gdk_display_beep (gdk_x11_lookup_xdisplay (DisplayHandle));
+ return;
+ }
+
+
+ internal override void CaretVisible (IntPtr handle, bool visible)
+ {
+ // Visible is cumulative; two hides require two shows before the caret is visible again
+ if (Caret.Hwnd == handle) {
+ if (visible) {
+ if (Caret.Visible < 1) {
+ Caret.Visible++;
+ Caret.On = false;
+ if (Caret.Visible == 1) {
+ ShowCaret ();
+ Caret.Timer.Start ();
+ }
+ }
+ } else {
+ Caret.Visible--;
+ if (Caret.Visible == 0) {
+ Caret.Timer.Stop ();
+ HideCaret ();
+ }
+ }
+ }
+ }
+
+ internal override bool CalculateWindowRect (IntPtr handle, ref Rectangle ClientRect, int Style, int ExStyle, Menu menu, out Rectangle WindowRect)
+ {
+ FormBorderStyle border_style;
+ TitleStyle title_style;
+ int caption_height;
+ int tool_caption_height;
+
+ DeriveStyles (handle, Style, ExStyle, out border_style, out title_style,
+ out caption_height, out tool_caption_height);
+
+ WindowRect = Hwnd.GetWindowRectangle (border_style, menu, title_style,
+ caption_height, tool_caption_height,
+ ClientRect);
+
+ return true;
+ }
+
+ internal override void ClientToScreen (IntPtr handle, ref int x, ref int y)
+ {
+ int dest_x_return;
+ int dest_y_return;
+ IntPtr child;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ lock (XlibLock) {
+ XTranslateCoordinates (DisplayHandle, hwnd.client_window, RootWindow, x, y, out dest_x_return, out dest_y_return, out child);
+ }
+
+ x = dest_x_return;
+ y = dest_y_return;
+ }
+
+ internal override int[] ClipboardAvailableFormats (IntPtr handle)
+ {
+ DataFormats.Format f;
+ int[] result;
+
+ f = DataFormats.Format.List;
+
+ if (XGetSelectionOwner (DisplayHandle, NetAtoms [(int)NA.CLIPBOARD]) == IntPtr.Zero) {
+ return null;
+ }
+
+ Clipboard.Formats = new ArrayList ();
+
+ while (f != null) {
+ XConvertSelection (DisplayHandle, NetAtoms [(int)NA.CLIPBOARD], f.Id, f.Id, FosterParent, IntPtr.Zero);
+
+ Clipboard.Enumerating = true;
+ while (Clipboard.Enumerating) {
+ UpdateMessageQueue ();
+ }
+ f = f.Next;
+ }
+
+ result = new int [Clipboard.Formats.Count];
+
+ for (int i = 0; i < Clipboard.Formats.Count; i++) {
+ result [i] = (int)Clipboard.Formats [i];
+ }
+
+ Clipboard.Formats = null;
+ return result;
+ }
+
+ internal override void ClipboardClose (IntPtr handle)
+ {
+ if (handle != ClipMagic) {
+ throw new ArgumentException ("handle is not a valid clipboard handle");
+ }
+ return;
+ }
+
+ internal override int ClipboardGetID (IntPtr handle, string format)
+ {
+ if (handle != ClipMagic) {
+ throw new ArgumentException ("handle is not a valid clipboard handle");
+ }
+
+ if (format == "Text") return (int)Atom.XA_STRING;
+ else if (format == "Bitmap") return (int)Atom.XA_BITMAP;
+ //else if (format == "MetaFilePict" ) return 3;
+ //else if (format == "SymbolicLink" ) return 4;
+ //else if (format == "DataInterchangeFormat" ) return 5;
+ //else if (format == "Tiff" ) return 6;
+ else if (format == "OEMText") return XInternAtom (DisplayHandle, "COMPOUND_TEXT", false);
+ else if (format == "DeviceIndependentBitmap") return (int)Atom.XA_PIXMAP;
+ else if (format == "Palette") return (int)Atom.XA_COLORMAP; // Useless
+ //else if (format == "PenData" ) return 10;
+ //else if (format == "RiffAudio" ) return 11;
+ //else if (format == "WaveAudio" ) return 12;
+ else if (format == "UnicodeText") return XInternAtom (DisplayHandle, "UTF8_STRING", false);
+ //else if (format == "EnhancedMetafile" ) return 14;
+ //else if (format == "FileDrop" ) return 15;
+ //else if (format == "Locale" ) return 16;
+
+ return XInternAtom (DisplayHandle, format, false);
+ }
+
+ internal override IntPtr ClipboardOpen ()
+ {
+ return ClipMagic;
+ }
+
+ internal override object ClipboardRetrieve (IntPtr handle, int type, XplatUI.ClipboardToObject converter)
+ {
+ XConvertSelection (DisplayHandle, NetAtoms [(int)NA.CLIPBOARD], type, type, FosterParent, IntPtr.Zero);
+
+ Clipboard.Retrieving = true;
+ while (Clipboard.Retrieving) {
+ UpdateMessageQueue ();
+ }
+
+ return Clipboard.Item;
+ }
+
+ internal override void ClipboardStore (IntPtr handle, object obj, int type, XplatUI.ObjectToClipboard converter)
+ {
+ Clipboard.Item = obj;
+ Clipboard.Type = type;
+ Clipboard.Converter = converter;
+
+ if (obj != null) {
+ XSetSelectionOwner (DisplayHandle, NetAtoms [(int)NA.CLIPBOARD], FosterParent, IntPtr.Zero);
+ } else {
+ // Clearing the selection
+ XSetSelectionOwner (DisplayHandle, NetAtoms [(int)NA.CLIPBOARD], IntPtr.Zero, IntPtr.Zero);
+ }
+ }
+
+ internal override void CreateCaret (IntPtr handle, int width, int height)
+ {
+ XGCValues gc_values;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ if (Caret.Hwnd != IntPtr.Zero) {
+ DestroyCaret (Caret.Hwnd);
+ }
+
+ Caret.Hwnd = handle;
+ Caret.Window = hwnd.client_window;
+ Caret.Width = width;
+ Caret.Height = height;
+ Caret.Visible = 0;
+ Caret.On = false;
+
+ gc_values = new XGCValues ();
+ gc_values.line_width = width;
+
+ Caret.gc = XCreateGC (DisplayHandle, Caret.Window, GCFunction.GCLineWidth, ref gc_values);
+ if (Caret.gc == IntPtr.Zero) {
+ Caret.Hwnd = IntPtr.Zero;
+ return;
+ }
+
+ XSetFunction (DisplayHandle, Caret.gc, GXFunction.GXinvert);
+ }
+
+ internal override IntPtr CreateWindow (CreateParams cp)
+ {
+ GdkWindowAttr gdk_window_attributes;
+ GdkWindowAttributesType attributes_mask = 0;
+ Hwnd hwnd;
+ int X;
+ int Y;
+ int Width;
+ int Height;
+ IntPtr GdkParentHandle;
+ IntPtr GdkWholeWindow;
+ IntPtr GdkClientWindow;
+ Rectangle ClientRect;
+ GdkWindowType gdk_window_type;
+
+
+ hwnd = new Hwnd ();
+
+ gdk_window_attributes = new GdkWindowAttr ();
+
+ X = cp.X;
+ Y = cp.Y;
+ Width = cp.Width;
+ Height = cp.Height;
+
+ if (Width < 1) Width = 1;
+ if (Height < 1) Height = 1;
+
+ gdk_window_type = GdkWindowType.GDK_WINDOW_CHILD;
+
+ if (cp.Parent != IntPtr.Zero) {
+ GdkParentHandle = gdk_window_lookup (Hwnd.ObjectFromHandle (cp.Parent).client_window);
+ } else {
+ if ((cp.Style & (int)WindowStyles.WS_CHILD) != 0) {
+ // We need to use our foster parent window until this poor child gets it's parent assigned
+ GdkParentHandle = GdkFosterParent;
+ } else if ((cp.Style & (int)WindowStyles.WS_POPUP) != 0) {
+ GdkParentHandle = GdkRootWindow;
+ } else {
+ // Default position on screen, if window manager doesn't place us somewhere else
+ if (X < 1) X = 50;
+ if (Y < 1) Y = 50;
+ GdkParentHandle = GdkRootWindow;
+ }
+ }
+
+// ValueMask = SetWindowValuemask.BitGravity | SetWindowValuemask.WinGravity;
+
+// Attributes.bit_gravity = Gravity.NorthWestGravity;
+// Attributes.win_gravity = Gravity.NorthWestGravity;
+
+ // FIXME: does gdk need that ?
+ // Save what's under the toolwindow
+ if ((cp.ExStyle & (int)WindowStyles.WS_EX_TOOLWINDOW) != 0) {
+// Attributes.save_under = true;
+// ValueMask |= SetWindowValuemask.SaveUnder;
+ }
+
+ // If we're a popup without caption we override the WM
+ if ((cp.Style & ((int)WindowStyles.WS_POPUP)) != 0) {
+ if ((cp.Style & (int)WindowStyles.WS_CAPTION) == 0) {
+ gdk_window_attributes.override_redirect = true;
+ attributes_mask |= GdkWindowAttributesType.GDK_WA_NOREDIR;
+ }
+ }
+
+ hwnd.x = X;
+ hwnd.y = Y;
+ hwnd.width = Width;
+ hwnd.height = Height;
+ hwnd.parent = Hwnd.ObjectFromHandle (cp.Parent);
+
+ if ((cp.Style & ((int)WindowStyles.WS_DISABLED)) != 0) {
+ hwnd.enabled = false;
+ }
+
+ ClientRect = hwnd.ClientRect;
+ GdkClientWindow = IntPtr.Zero;
+
+ gdk_window_attributes.x = X;
+ gdk_window_attributes.y = Y;
+ gdk_window_attributes.width = Width;
+ gdk_window_attributes.height = Height;
+ gdk_window_attributes.window_type = gdk_window_type;
+
+ attributes_mask |= GdkWindowAttributesType.GDK_WA_X | GdkWindowAttributesType.GDK_WA_Y;
+
+ gdk_window_attributes.wclass = GdkWindowClass.GDK_INPUT_OUTPUT;
+
+ lock (XlibLock) {
+ GdkWholeWindow = gdk_window_new (GdkParentHandle, ref gdk_window_attributes, (int)attributes_mask);
+
+ if (GdkWholeWindow != IntPtr.Zero) {
+ attributes_mask &= ~GdkWindowAttributesType.GDK_WA_NOREDIR;
+
+ if (GdkCustomVisual != IntPtr.Zero && GdkCustomColormap != IntPtr.Zero) {
+ attributes_mask |= GdkWindowAttributesType.GDK_WA_COLORMAP | GdkWindowAttributesType.GDK_WA_VISUAL;
+ gdk_window_attributes.colormap = GdkCustomColormap;
+ gdk_window_attributes.visual = GdkCustomVisual;
+ }
+
+ gdk_window_attributes.x = ClientRect.X;
+ gdk_window_attributes.y = ClientRect.Y;
+ gdk_window_attributes.width = ClientRect.Width;
+ gdk_window_attributes.height = ClientRect.Height;
+
+ GdkClientWindow = gdk_window_new (GdkWholeWindow, ref gdk_window_attributes, (int)attributes_mask);
+ }
+ }
+
+ if ((GdkWholeWindow == IntPtr.Zero) || (GdkClientWindow == IntPtr.Zero)) {
+ throw new Exception ("Could not create X11 Gdk windows");
+ }
+
+ hwnd.WholeWindow = gdk_x11_drawable_get_xid (GdkWholeWindow);
+ hwnd.ClientWindow = gdk_x11_drawable_get_xid (GdkClientWindow);
+
+ #if DriverDebug
+ Console.WriteLine("Created window {0:X} / {1:X} parent {2:X}", ClientWindow.ToInt32(), WholeWindow.ToInt32(), hwnd.parent != null ? hwnd.parent.Handle.ToInt32() : 0);
+ #endif
+
+ lock (XlibLock) {
+ gdk_window_set_events (GdkWholeWindow, (int)GdkSelectInputMask);
+ gdk_window_set_events (GdkClientWindow, (int)GdkSelectInputMask);
+
+ if ((cp.Style & (int)WindowStyles.WS_VISIBLE) != 0) {
+ gdk_window_show (GdkWholeWindow);
+ gdk_window_show (GdkClientWindow);
+ hwnd.visible = true;
+ }
+ }
+
+ SetWMStyles (hwnd, cp);
+
+ if ((cp.Style & (int)WindowStyles.WS_MINIMIZE) != 0) {
+ SetWindowState (hwnd.Handle, FormWindowState.Minimized);
+ } else if ((cp.Style & (int)WindowStyles.WS_MAXIMIZE) != 0) {
+ SetWindowState (hwnd.Handle, FormWindowState.Maximized);
+ }
+
+ // for now make all windows dnd enabled
+ Dnd.SetAllowDrop (hwnd, true);
+
+ // Set caption/window title
+ Text (hwnd.Handle, cp.Caption);
+
+ return hwnd.Handle;
+ }
+
+ internal override IntPtr CreateWindow (IntPtr Parent, int X, int Y, int Width, int Height)
+ {
+ CreateParams create_params = new CreateParams ();
+
+ create_params.Caption = "";
+ create_params.X = X;
+ create_params.Y = Y;
+ create_params.Width = Width;
+ create_params.Height = Height;
+
+ create_params.ClassName = XplatUI.DefaultClassName;
+ create_params.ClassStyle = 0;
+ create_params.ExStyle = 0;
+ create_params.Parent = IntPtr.Zero;
+ create_params.Param = 0;
+
+ return CreateWindow (create_params);
+ }
+
+ internal override IntPtr DefineCursor (Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot)
+ {
+ IntPtr cursor;
+ Bitmap cursor_bitmap;
+ Bitmap cursor_mask;
+ Byte[] cursor_bits;
+ Byte[] mask_bits;
+ Color c_pixel;
+ Color m_pixel;
+ int width;
+ int height;
+ IntPtr cursor_pixmap;
+ IntPtr mask_pixmap;
+ XColor fg;
+ XColor bg;
+ bool and;
+ bool xor;
+
+ Size cursor_size = CursorSize;
+ width = cursor_size.Width;
+ height = cursor_size.Height;
+
+ // Win32 only allows creation cursors of a certain size
+ if ((bitmap.Width != width) || (bitmap.Width != height)) {
+ cursor_bitmap = new Bitmap (bitmap, new Size (width, height));
+ cursor_mask = new Bitmap (mask, new Size (width, height));
+ } else {
+ cursor_bitmap = bitmap;
+ cursor_mask = mask;
+ }
+
+ width = cursor_bitmap.Width;
+ height = cursor_bitmap.Height;
+
+ cursor_bits = new Byte [(width / 8) * height];
+ mask_bits = new Byte [(width / 8) * height];
+
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ c_pixel = cursor_bitmap.GetPixel (x, y);
+ m_pixel = cursor_mask.GetPixel (x, y);
+
+ and = c_pixel == cursor_pixel;
+ xor = m_pixel == mask_pixel;
+
+ if (!and && !xor) {
+ // Black
+ // cursor_bits[y * width / 8 + x / 8] &= (byte)~((1 << (x % 8))); // The bit already is 0
+ mask_bits [y * width / 8 + x / 8] |= (byte)(1 << (x % 8));
+ } else if (and && !xor) {
+ // White
+ cursor_bits [y * width / 8 + x / 8] |= (byte)(1 << (x % 8));
+ mask_bits [y * width / 8 + x / 8] |= (byte)(1 << (x % 8));
+ #if notneeded
+ } else if (and && !xor) {
+ // Screen
+ } else if (and && xor) {
+ // Inverse Screen
+
+ // X11 doesn't know the 'reverse screen' concept, so we'll treat them the same
+ // we want both to be 0 so nothing to be done
+ //cursor_bits[y * width / 8 + x / 8] &= (byte)~((1 << (x % 8)));
+ //mask_bits[y * width / 8 + x / 8] |= (byte)(01 << (x % 8));
+ #endif
+ }
+ }
+ }
+
+ cursor_pixmap = XCreatePixmapFromBitmapData (DisplayHandle, RootWindow, cursor_bits, width, height, (IntPtr)1, (IntPtr)0, 1);
+ mask_pixmap = XCreatePixmapFromBitmapData (DisplayHandle, RootWindow, mask_bits, width, height, (IntPtr)1, (IntPtr)0, 1);
+ fg = new XColor ();
+ bg = new XColor ();
+
+ fg.pixel = XWhitePixel (DisplayHandle, ScreenNo);
+ fg.red = (ushort)65535;
+ fg.green = (ushort)65535;
+ fg.blue = (ushort)65535;
+
+ bg.pixel = XBlackPixel (DisplayHandle, ScreenNo);
+
+ cursor = XCreatePixmapCursor (DisplayHandle, cursor_pixmap, mask_pixmap, ref fg, ref bg, xHotSpot, yHotSpot);
+
+ XFreePixmap (DisplayHandle, cursor_pixmap);
+ XFreePixmap (DisplayHandle, mask_pixmap);
+
+ return cursor;
+ }
+
+ internal override IntPtr DefineStdCursor (StdCursor id)
+ {
+ CursorFontShape shape;
+ IntPtr cursor;
+
+ // FIXME - define missing shapes
+
+ switch (id) {
+ case StdCursor.AppStarting: {
+ shape = CursorFontShape.XC_watch;
+ break;
+ }
+
+ case StdCursor.Arrow: {
+ return IntPtr.Zero;
+ }
+
+ case StdCursor.Cross: {
+ shape = CursorFontShape.XC_crosshair;
+ break;
+ }
+
+ case StdCursor.Default: {
+ return IntPtr.Zero;
+ }
+
+ case StdCursor.Hand: {
+ shape = CursorFontShape.XC_hand1;
+ break;
+ }
+
+ case StdCursor.Help: {
+ shape = CursorFontShape.XC_question_arrow;
+ break;
+ }
+
+ case StdCursor.HSplit: {
+ shape = CursorFontShape.XC_sb_v_double_arrow;
+ break;
+ }
+
+ case StdCursor.IBeam: {
+ shape = CursorFontShape.XC_xterm;
+ break;
+ }
+
+ case StdCursor.No: {
+ shape = CursorFontShape.XC_circle;
+ break;
+ }
+
+ case StdCursor.NoMove2D: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.NoMoveHoriz: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.NoMoveVert: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.PanEast: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.PanNE: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.PanNorth: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.PanNW: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.PanSE: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.PanSouth: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.PanSW: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.PanWest: {
+ shape = CursorFontShape.XC_sizing;
+ break;
+ }
+
+ case StdCursor.SizeAll: {
+ shape = CursorFontShape.XC_fleur;
+ break;
+ }
+
+ case StdCursor.SizeNESW: {
+ shape = CursorFontShape.XC_top_right_corner;
+ break;
+ }
+
+ case StdCursor.SizeNS: {
+ shape = CursorFontShape.XC_sb_v_double_arrow;
+ break;
+ }
+
+ case StdCursor.SizeNWSE: {
+ shape = CursorFontShape.XC_top_left_corner;
+ break;
+ }
+
+ case StdCursor.SizeWE: {
+ shape = CursorFontShape.XC_sb_h_double_arrow;
+ break;
+ }
+
+ case StdCursor.UpArrow: {
+ shape = CursorFontShape.XC_center_ptr;
+ break;
+ }
+
+ case StdCursor.VSplit: {
+ shape = CursorFontShape.XC_sb_h_double_arrow;
+ break;
+ }
+
+ case StdCursor.WaitCursor: {
+ shape = CursorFontShape.XC_watch;
+ break;
+ }
+
+ default: {
+ return IntPtr.Zero;
+ }
+ }
+
+ lock (XlibLock) {
+ cursor = XCreateFontCursor (DisplayHandle, shape);
+ }
+ return cursor;
+ }
+
+ internal override IntPtr DefWndProc (ref Message msg)
+ {
+ return IntPtr.Zero;
+ }
+
+ internal override void DestroyCaret (IntPtr handle)
+ {
+ if (Caret.Hwnd == handle) {
+ if (Caret.Visible == 1) {
+ Caret.Timer.Stop ();
+ HideCaret ();
+ }
+ if (Caret.gc != IntPtr.Zero) {
+ XFreeGC (DisplayHandle, Caret.gc);
+ Caret.gc = IntPtr.Zero;
+ }
+ Caret.Hwnd = IntPtr.Zero;
+ Caret.Visible = 0;
+ Caret.On = false;
+ }
+ }
+
+ internal override void DestroyCursor (IntPtr cursor)
+ {
+ lock (XlibLock) {
+ XFreeCursor (DisplayHandle, cursor);
+ }
+ }
+
+ internal override void DestroyWindow (IntPtr handle)
+ {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ if (hwnd == null) {
+ #if DriverDebug
+ Console.WriteLine("window {0:X} already destroyed", handle.ToInt32());
+ #endif
+ return;
+ }
+
+ #if DriverDebug
+ Console.WriteLine("Destroying window {0:X}", handle.ToInt32());
+ #endif
+
+ // Make sure if the caret is in the window, that we destroy the caret, too
+ if (Caret.Hwnd == hwnd.client_window) {
+ DestroyCaret (handle);
+ }
+
+ // Mark our children as gone as well
+ DestroyChildWindow (Control.ControlNativeWindow.ControlFromHandle (handle));
+
+ // Send destroy message
+ SendMessage (handle, Msg.WM_DESTROY, IntPtr.Zero, IntPtr.Zero);
+
+ lock (XlibLock) {
+ if (hwnd.client_window != IntPtr.Zero) {
+ gdk_window_destroy (gdk_window_lookup (hwnd.client_window));
+ }
+
+ if ((hwnd.whole_window != IntPtr.Zero) && (hwnd.whole_window != hwnd.client_window)) {
+ gdk_window_destroy (gdk_window_lookup (hwnd.whole_window));
+ }
+ }
+ hwnd.Dispose ();
+ }
+
+ internal override IntPtr DispatchMessage (ref MSG msg)
+ {
+ return NativeWindow.WndProc (msg.hwnd, msg.message, msg.wParam, msg.lParam);
+ }
+
+ internal override void DrawReversibleRectangle (IntPtr handle, Rectangle rect, int line_width)
+ {
+ Hwnd hwnd;
+ XGCValues gc_values;
+ IntPtr gc;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ gc_values = new XGCValues ();
+
+ gc_values.subwindow_mode = GCSubwindowMode.IncludeInferiors;
+ gc_values.line_width = line_width;
+ gc_values.foreground = XBlackPixel (DisplayHandle, ScreenNo);
+
+ // This logic will give us true rubber bands: (libsx, SANE_XOR)
+ //mask = foreground ^ background;
+ //XSetForeground(DisplayHandle, gc, 0xffffffff);
+ //XSetBackground(DisplayHandle, gc, background);
+ //XSetFunction(DisplayHandle, gc, GXxor);
+ //XSetPlaneMask(DisplayHandle, gc, mask);
+
+
+ gc = XCreateGC (DisplayHandle, hwnd.client_window, GCFunction.GCSubwindowMode | GCFunction.GCLineWidth | GCFunction.GCForeground, ref gc_values);
+ uint foreground;
+ uint background;
+
+ Control control;
+ control = Control.FromHandle (handle);
+
+ XColor xcolor = new XColor ();
+
+ xcolor.red = (ushort)(control.ForeColor.R * 257);
+ xcolor.green = (ushort)(control.ForeColor.G * 257);
+ xcolor.blue = (ushort)(control.ForeColor.B * 257);
+ XAllocColor (DisplayHandle, DefaultColormap, ref xcolor);
+ foreground = (uint)xcolor.pixel.ToInt32 ();
+
+ xcolor.red = (ushort)(control.BackColor.R * 257);
+ xcolor.green = (ushort)(control.BackColor.G * 257);
+ xcolor.blue = (ushort)(control.BackColor.B * 257);
+ XAllocColor (DisplayHandle, DefaultColormap, ref xcolor);
+ background = (uint)xcolor.pixel.ToInt32 ();
+
+ uint mask = foreground ^ background;
+
+ XSetForeground (DisplayHandle, gc, 0xffffffff);
+ XSetBackground (DisplayHandle, gc, background);
+ XSetFunction (DisplayHandle, gc, GXFunction.GXxor);
+ XSetPlaneMask (DisplayHandle, gc, mask);
+
+ if ((rect.Width > 0) && (rect.Height > 0)) {
+ XDrawRectangle (DisplayHandle, hwnd.client_window, gc, rect.Left, rect.Top, rect.Width, rect.Height);
+ } else {
+ if (rect.Width > 0) {
+ XDrawLine (DisplayHandle, hwnd.client_window, gc, rect.X, rect.Y, rect.Right, rect.Y);
+ } else {
+ XDrawLine (DisplayHandle, hwnd.client_window, gc, rect.X, rect.Y, rect.X, rect.Bottom);
+ }
+ }
+ XFreeGC (DisplayHandle, gc);
+ }
+
+ internal override void DoEvents ()
+ {
+ MSG msg = new MSG ();
+
+ if (OverrideCursorHandle != IntPtr.Zero) {
+ OverrideCursorHandle = IntPtr.Zero;
+ }
+
+ while (PeekMessage (ref msg, IntPtr.Zero, 0, 0, (uint)PeekMessageFlags.PM_REMOVE)) {
+ TranslateMessage (ref msg);
+ DispatchMessage (ref msg);
+ }
+ }
+
+ internal override void EnableWindow (IntPtr handle, bool Enable)
+ {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+ if (hwnd != null) {
+ hwnd.Enabled = Enable;
+ }
+ }
+
+ internal override void EndLoop (Thread thread)
+ {
+ // This is where we one day will shut down the loop for the thread
+ }
+
+
+ internal override IntPtr GetActive ()
+ {
+ Atom actual_atom;
+ int actual_format;
+ int nitems;
+ int bytes_after;
+ IntPtr prop = IntPtr.Zero;
+ IntPtr active = IntPtr.Zero;
+
+ XGetWindowProperty (DisplayHandle, RootWindow, NetAtoms [(int)NA._NET_ACTIVE_WINDOW], 0, 1, false, Atom.XA_WINDOW, out actual_atom, out actual_format, out nitems, out bytes_after, ref prop);
+ if ((nitems > 0) && (prop != IntPtr.Zero)) {
+ active = (IntPtr)Marshal.ReadInt32 (prop);
+ XFree (prop);
+ }
+
+ if (active != IntPtr.Zero) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.GetObjectFromWindow (active);
+ if (hwnd != null) {
+ active = hwnd.Handle;
+ } else {
+ active = IntPtr.Zero;
+ }
+ }
+ return active;
+ }
+
+ internal override void GetCursorInfo (IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y)
+ {
+ throw new NotImplementedException ();
+ }
+
+ internal override void GetDisplaySize (out Size size)
+ {
+ XWindowAttributes attributes=new XWindowAttributes ();
+
+ lock (XlibLock) {
+ // FIXME - use _NET_WM messages instead?
+ XGetWindowAttributes (DisplayHandle, XRootWindow (DisplayHandle, ScreenNo), ref attributes);
+ }
+
+ size = new Size (attributes.width, attributes.height);
+ }
+
+ internal override SizeF GetAutoScaleSize (Font font)
+ {
+ Graphics g;
+ float width;
+ string magic_string = "The quick brown fox jumped over the lazy dog.";
+ double magic_number = 44.549996948242189;
+
+ g = Graphics.FromHwnd (FosterParent);
+
+ width = (float) (g.MeasureString (magic_string, font).Width / magic_number);
+ return new SizeF (width, font.Height);
+ }
+
+ internal override IntPtr GetParent (IntPtr handle)
+ {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+ if (hwnd != null && hwnd.parent != null) {
+ return hwnd.parent.Handle;
+ }
+ return IntPtr.Zero;
+ }
+
+ internal override void GetCursorPos (IntPtr handle, out int x, out int y)
+ {
+ IntPtr use_handle;
+ IntPtr root;
+ IntPtr child;
+ int root_x;
+ int root_y;
+ int win_x;
+ int win_y;
+ int keys_buttons;
+
+ if (handle != IntPtr.Zero) {
+ use_handle = Hwnd.ObjectFromHandle (handle).client_window;
+ } else {
+ use_handle = RootWindow;
+ }
+
+ lock (XlibLock) {
+ XQueryPointer (DisplayHandle, use_handle, out root, out child, out root_x, out root_y, out win_x, out win_y, out keys_buttons);
+ }
+
+ if (handle != IntPtr.Zero) {
+ x = win_x;
+ y = win_y;
+ } else {
+ x = root_x;
+ y = root_y;
+ }
+ }
+
+ internal override bool GetFontMetrics (Graphics g, Font font, out int ascent, out int descent)
+ {
+ return GetFontMetrics (g.GetHdc (), font.ToHfont (), out ascent, out descent);
+ }
+
+ internal override Point GetMenuOrigin (IntPtr handle)
+ {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ if (hwnd != null) {
+ return hwnd.MenuOrigin;
+ }
+ return Point.Empty;
+ }
+
+ internal override bool GetMessage (ref MSG msg, IntPtr handle, int wFilterMin, int wFilterMax)
+ {
+ XEvent xevent;
+ bool client;
+ Hwnd hwnd;
+
+ ProcessNextMessage:
+
+ if (MessageQueue.Count > 0) {
+ xevent = (XEvent) MessageQueue.Dequeue ();
+ } else {
+ UpdateMessageQueue ();
+
+ if (MessageQueue.Count > 0) {
+ xevent = (XEvent) MessageQueue.Dequeue ();
+ } else {
+ if (!PostQuitState) {
+ msg.hwnd = IntPtr.Zero;
+ msg.message = Msg.WM_ENTERIDLE;
+ return true;
+ }
+
+ // We reset ourselves so GetMessage can be called again
+ PostQuitState = false;
+
+ return false;
+ }
+ }
+
+ // FIXME - handle filtering
+
+ hwnd = Hwnd.GetObjectFromWindow (xevent.AnyEvent.window);
+
+ // Handle messages for windows that are already or are about to be destroyed
+ if (hwnd == null) {
+ #if DriverDebug
+ Console.WriteLine("GetMessage(): Got message {0} for non-existent or already destroyed window {1:X}", xevent.type, xevent.AnyEvent.window.ToInt32());
+ #endif
+ goto ProcessNextMessage;
+ }
+
+ if (hwnd.client_window == xevent.AnyEvent.window) {
+ client = true;
+ //Console.WriteLine("Client message, sending to window {0:X}", msg.hwnd.ToInt32());
+ } else {
+ client = false;
+ //Console.WriteLine("Non-Client message, sending to window {0:X}", msg.hwnd.ToInt32());
+ }
+
+ msg.hwnd = hwnd.Handle;
+
+ //
+ // If you add a new event to this switch make sure to add it in
+ // UpdateMessage also unless it is not coming through the X event system.
+ //
+ switch (xevent.type) {
+ case XEventName.KeyPress: {
+ Keyboard.KeyEvent (FocusWindow, xevent, ref msg);
+ break;
+ }
+
+ case XEventName.KeyRelease: {
+ Keyboard.KeyEvent (FocusWindow, xevent, ref msg);
+ break;
+ }
+
+ case XEventName.ButtonPress: {
+ switch (xevent.ButtonEvent.button) {
+ case 1: {
+ MouseState |= MouseButtons.Left;
+ if (client) {
+ msg.message = Msg.WM_LBUTTONDOWN;
+ } else {
+ msg.message = Msg.WM_NCLBUTTONDOWN;
+ WholeToScreen (msg.hwnd, ref xevent.ButtonEvent.x, ref xevent.ButtonEvent.y);
+ }
+ // TODO: For WM_NCLBUTTONDOWN wParam specifies a hit-test value not the virtual keys down
+ msg.wParam = GetMousewParam (0);
+ break;
+ }
+
+ case 2: {
+ MouseState |= MouseButtons.Middle;
+ if (client) {
+ msg.message = Msg.WM_MBUTTONDOWN;
+ } else {
+ msg.message = Msg.WM_NCMBUTTONDOWN;
+ WholeToScreen (msg.hwnd, ref xevent.ButtonEvent.x, ref xevent.ButtonEvent.y);
+ }
+ msg.wParam = GetMousewParam (0);
+ break;
+ }
+
+ case 3: {
+ MouseState |= MouseButtons.Right;
+ if (client) {
+ msg.message = Msg.WM_RBUTTONDOWN;
+ } else {
+ msg.message = Msg.WM_NCRBUTTONDOWN;
+ WholeToScreen (msg.hwnd, ref xevent.ButtonEvent.x, ref xevent.ButtonEvent.y);
+ }
+ msg.wParam = GetMousewParam (0);
+ break;
+ }
+
+ case 4: {
+ msg.message = Msg.WM_MOUSEWHEEL;
+ msg.wParam = GetMousewParam (120);
+ break;
+ }
+
+ case 5: {
+ msg.message = Msg.WM_MOUSEWHEEL;
+ msg.wParam = GetMousewParam (-120);
+ break;
+ }
+
+ }
+
+ msg.lParam = (IntPtr) (xevent.ButtonEvent.y << 16 | xevent.ButtonEvent.x);
+ MousePosition.X = xevent.ButtonEvent.x;
+ MousePosition.Y = xevent.ButtonEvent.y;
+
+ if (!hwnd.Enabled) {
+ IntPtr dummy;
+
+ msg.hwnd = hwnd.EnabledHwnd;
+ XTranslateCoordinates (DisplayHandle, xevent.AnyEvent.window, Hwnd.ObjectFromHandle (msg.hwnd).ClientWindow, xevent.ButtonEvent.x, xevent.ButtonEvent.y, out xevent.ButtonEvent.x, out xevent.ButtonEvent.y, out dummy);
+ msg.lParam = (IntPtr)(MousePosition.Y << 16 | MousePosition.X);
+ }
+
+ if (Grab.Hwnd != IntPtr.Zero) {
+ msg.hwnd = Grab.Hwnd;
+ }
+
+ if (!ClickPending.Pending) {
+ ClickPending.Pending = true;
+ ClickPending.Hwnd = msg.hwnd;
+ ClickPending.Message = msg.message;
+ ClickPending.wParam = msg.wParam;
+ ClickPending.lParam = msg.lParam;
+ ClickPending.Time = (long)xevent.ButtonEvent.time;
+ } else {
+ if ((((long)xevent.ButtonEvent.time - ClickPending.Time) < DoubleClickInterval) && (msg.wParam == ClickPending.wParam) && (msg.lParam == ClickPending.lParam) && (msg.message == ClickPending.Message)) {
+ // Looks like a genuine double click, clicked twice on the same spot with the same keys
+ switch (xevent.ButtonEvent.button) {
+ case 1: {
+ msg.message = client ? Msg.WM_LBUTTONDBLCLK : Msg.WM_NCLBUTTONDBLCLK;
+ break;
+ }
+
+ case 2: {
+ msg.message = client ? Msg.WM_MBUTTONDBLCLK : Msg.WM_NCMBUTTONDBLCLK;
+ break;
+ }
+
+ case 3: {
+ msg.message = client ? Msg.WM_RBUTTONDBLCLK : Msg.WM_NCRBUTTONDBLCLK;
+ break;
+ }
+ }
+ }
+ ClickPending.Pending = false;
+ }
+
+ break;
+ }
+
+ case XEventName.ButtonRelease: {
+ Dnd.HandleButtonRelease (ref xevent);
+ switch (xevent.ButtonEvent.button) {
+ case 1: {
+ MouseState &= ~MouseButtons.Left;
+ if (client) {
+ msg.message = Msg.WM_LBUTTONUP;
+ } else {
+ msg.message = Msg.WM_NCLBUTTONUP;
+ WholeToScreen (msg.hwnd, ref xevent.ButtonEvent.x, ref xevent.ButtonEvent.y);
+ }
+ msg.wParam = GetMousewParam (0);
+ break;
+ }
+
+ case 2: {
+ MouseState &= ~MouseButtons.Middle;
+ if (client) {
+ msg.message = Msg.WM_MBUTTONUP;
+ } else {
+ msg.message = Msg.WM_NCMBUTTONUP;
+ WholeToScreen (msg.hwnd, ref xevent.ButtonEvent.x, ref xevent.ButtonEvent.y);
+ }
+ msg.wParam = GetMousewParam (0);
+ break;
+ }
+
+ case 3: {
+ MouseState &= ~MouseButtons.Right;
+ if (client) {
+ msg.message = Msg.WM_RBUTTONUP;
+ } else {
+ msg.message = Msg.WM_NCRBUTTONUP;
+ WholeToScreen (msg.hwnd, ref xevent.ButtonEvent.x, ref xevent.ButtonEvent.y);
+ }
+ msg.wParam = GetMousewParam (0);
+ break;
+ }
+
+ case 4: {
+ goto ProcessNextMessage;
+ }
+
+ case 5: {
+ goto ProcessNextMessage;
+ }
+ }
+
+ if (!hwnd.Enabled) {
+ IntPtr dummy;
+
+ msg.hwnd = hwnd.EnabledHwnd;
+ XTranslateCoordinates (DisplayHandle, xevent.AnyEvent.window, Hwnd.ObjectFromHandle (msg.hwnd).ClientWindow, xevent.ButtonEvent.x, xevent.ButtonEvent.y, out xevent.ButtonEvent.x, out xevent.ButtonEvent.y, out dummy);
+ msg.lParam = (IntPtr)(MousePosition.Y << 16 | MousePosition.X);
+ }
+
+ if (Grab.Hwnd != IntPtr.Zero) {
+ msg.hwnd = Grab.Hwnd;
+ }
+
+ msg.lParam = (IntPtr) (xevent.ButtonEvent.y << 16 | xevent.ButtonEvent.x);
+ MousePosition.X = xevent.ButtonEvent.x;
+ MousePosition.Y = xevent.ButtonEvent.y;
+ break;
+ }
+
+ case XEventName.MotionNotify: {
+ if (client) {
+ #if DriverDebugExtra
+ Console.WriteLine("GetMessage(): Window {0:X} MotionNotify x={1} y={2}", client ? hwnd.client_window.ToInt32() : hwnd.whole_window.ToInt32(), xevent.MotionEvent.x, xevent.MotionEvent.y);
+ #endif
+
+ if (Dnd.HandleMotionNotify (ref xevent))
+ goto ProcessNextMessage;
+ if (Grab.Hwnd != IntPtr.Zero) {
+ msg.hwnd = Grab.Hwnd;
+ } else {
+ NativeWindow.WndProc (msg.hwnd, Msg.WM_SETCURSOR, msg.hwnd, (IntPtr)HitTest.HTCLIENT);
+ }
+
+ msg.message = Msg.WM_MOUSEMOVE;
+ msg.wParam = GetMousewParam (0);
+ msg.lParam = (IntPtr) (xevent.MotionEvent.y << 16 | xevent.MotionEvent.x & 0xFFFF);
+
+ if (!hwnd.Enabled) {
+ IntPtr dummy;
+
+ msg.hwnd = hwnd.EnabledHwnd;
+ XTranslateCoordinates (DisplayHandle, xevent.AnyEvent.window, Hwnd.ObjectFromHandle (msg.hwnd).ClientWindow, xevent.MotionEvent.x, xevent.MotionEvent.y, out xevent.MotionEvent.x, out xevent.MotionEvent.y, out dummy);
+ msg.lParam = (IntPtr)(MousePosition.Y << 16 | MousePosition.X);
+ }
+
+ HoverState.X = MousePosition.X = xevent.MotionEvent.x;
+ HoverState.Y = MousePosition.Y = xevent.MotionEvent.y;
+
+ break;
+ } else {
+ #if DriverDebugExtra
+ Console.WriteLine("GetMessage(): non-client area {0:X} MotionNotify x={1} y={2}", client ? hwnd.client_window.ToInt32() : hwnd.whole_window.ToInt32(), xevent.MotionEvent.x, xevent.MotionEvent.y);
+ #endif
+ msg.message = Msg.WM_NCMOUSEMOVE;
+ msg.lParam = (IntPtr) (xevent.MotionEvent.y << 16 | xevent.MotionEvent.x & 0xFFFF);
+
+ if (!hwnd.Enabled) {
+ IntPtr dummy;
+
+ msg.hwnd = hwnd.EnabledHwnd;
+ XTranslateCoordinates (DisplayHandle, xevent.AnyEvent.window, Hwnd.ObjectFromHandle (msg.hwnd).ClientWindow, xevent.MotionEvent.x, xevent.MotionEvent.y, out xevent.MotionEvent.x, out xevent.MotionEvent.y, out dummy);
+ msg.lParam = (IntPtr)(MousePosition.Y << 16 | MousePosition.X);
+ }
+
+ #if notyet
+ // Not sure we need this...
+ HitTest ht;
+ ht = NativeWindow.WndProc(hwnd.client_window, Msg.WM_NCHITTEST, IntPtr.Zero, msg.lParam);
+ #endif
+
+ MousePosition.X = xevent.MotionEvent.x;
+ MousePosition.Y = xevent.MotionEvent.y;
+ }
+
+ break;
+ }
+
+ case XEventName.EnterNotify: {
+ if (!hwnd.Enabled) {
+ goto ProcessNextMessage;
+ }
+ if (xevent.CrossingEvent.mode != NotifyMode.NotifyNormal) {
+ goto ProcessNextMessage;
+ }
+ msg.message = Msg.WM_MOUSE_ENTER;
+ HoverState.Timer.Enabled = true;
+ HoverState.Window = xevent.CrossingEvent.window;
+ break;
+ }
+
+ case XEventName.LeaveNotify: {
+ if (!hwnd.Enabled) {
+ goto ProcessNextMessage;
+ }
+ if (xevent.CrossingEvent.mode != NotifyMode.NotifyNormal) {
+ goto ProcessNextMessage;
+ }
+ msg.message = Msg.WM_MOUSE_LEAVE;
+ HoverState.Timer.Enabled = false;
+ HoverState.Window = IntPtr.Zero;
+ break;
+ }
+
+ #if later
+ case XEventName.CreateNotify: {
+ if (client && (xevent.ConfigureEvent.xevent == xevent.ConfigureEvent.window)) {
+ msg.message = WM_CREATE;
+ // Set up CreateStruct
+ } else {
+ goto ProcessNextMessage;
+ }
+ break;
+ }
+ #endif
+
+
+ case XEventName.ReparentNotify: {
+ if (hwnd.parent == null) { // Toplevel
+ if (xevent.ReparentEvent.parent != IntPtr.Zero) {
+ // We need to adjust x/y
+ int dummy_int;
+
+ hwnd.Reparented = true;
+
+ gdk_window_get_geometry (gdk_window_lookup (hwnd.whole_window), out hwnd.x, out hwnd.y, out dummy_int, out dummy_int, out dummy_int);
+ msg.message = Msg.WM_WINDOWPOSCHANGED;
+ if (hwnd.opacity != 0xffffffff) {
+ uint opacity;
+
+ opacity = hwnd.opacity;
+ XChangeProperty (DisplayHandle, XGetParent (hwnd.whole_window), NetAtoms [(int)NA._NET_WM_WINDOW_OPACITY], Atom.XA_CARDINAL, 32, PropertyMode.Replace, ref opacity, 1);
+ }
+ } else {
+ hwnd.Reparented = false;
+ goto ProcessNextMessage;
+ }
+ }
+ break;
+ }
+
+ case XEventName.ConfigureNotify: {
+ if (!client && (xevent.ConfigureEvent.xevent == xevent.ConfigureEvent.window)) { // Ignore events for children (SubstructureNotify) and client areas
+ XplatUIWin32.NCCALCSIZE_PARAMS ncp;
+ IntPtr ptr;
+ Rectangle rect;
+
+ #if DriverDebugExtra
+ Console.WriteLine("GetMessage(): Window {0:X} ConfigureNotify x={1} y={2} width={3} height={4}", hwnd.client_window.ToInt32(), xevent.ConfigureEvent.x, xevent.ConfigureEvent.y, xevent.ConfigureEvent.width, xevent.ConfigureEvent.height);
+ #endif
+ msg.message = Msg.WM_WINDOWPOSCHANGED;
+ hwnd.configure_pending = false;
+
+ // We need to adjust our client window to track the resize of whole_window
+ rect = hwnd.DefaultClientRect;
+
+ ncp = new XplatUIWin32.NCCALCSIZE_PARAMS ();
+ ptr = Marshal.AllocHGlobal (Marshal.SizeOf (ncp));
+
+ ncp.rgrc1.left = rect.Left;
+ ncp.rgrc1.top = rect.Top;
+ ncp.rgrc1.right = rect.Right;
+ ncp.rgrc1.bottom = rect.Bottom;
+
+ Marshal.StructureToPtr (ncp, ptr, true);
+ NativeWindow.WndProc (hwnd.client_window, Msg.WM_NCCALCSIZE, (IntPtr)1, ptr);
+ ncp = (XplatUIWin32.NCCALCSIZE_PARAMS)Marshal.PtrToStructure (ptr, typeof(XplatUIWin32.NCCALCSIZE_PARAMS));
+ Marshal.FreeHGlobal (ptr);
+
+ // FIXME - debug this with Menus, need to set hwnd.ClientRect
+
+ rect = new Rectangle (ncp.rgrc1.left, ncp.rgrc1.top, ncp.rgrc1.right - ncp.rgrc1.left, ncp.rgrc1.bottom - ncp.rgrc1.top);
+ //Console.WriteLine("CreateOffscreenbuffer...");
+// CreateOffscreenBuffer (ref hwnd.client_offscreen, rect.Width, rect.Height);
+
+ XMoveResizeWindow (DisplayHandle, hwnd.client_window, rect.X, rect.Y, rect.Width, rect.Height);
+ } else {
+ goto ProcessNextMessage;
+ }
+
+ msg.lParam = IntPtr.Zero; // FIXME - Generate LPWINDOWPOS structure and pass on
+ break;
+ }
+
+ case XEventName.FocusIn: {
+ if (!hwnd.Enabled) {
+ goto ProcessNextMessage;
+ }
+ msg.message = Msg.WM_SETFOCUS;
+ msg.wParam = IntPtr.Zero;
+ break;
+ }
+
+ case XEventName.FocusOut: {
+ if (!hwnd.Enabled) {
+ goto ProcessNextMessage;
+ }
+ msg.message = Msg.WM_KILLFOCUS;
+ msg.wParam = IntPtr.Zero;
+ break;
+ }
+
+ case XEventName.Expose: {
+ if (PostQuitState) {
+ goto ProcessNextMessage;
+ }
+
+
+ if (client) {
+ if (!hwnd.expose_pending) {
+ goto ProcessNextMessage;
+ }
+ } else {
+ if (!hwnd.nc_expose_pending) {
+ goto ProcessNextMessage;
+ }
+
+ switch (hwnd.border_style) {
+ case FormBorderStyle.Fixed3D: {
+ Graphics g;
+
+ g = Graphics.FromHwnd (hwnd.whole_window);
+ ControlPaint.DrawBorder3D (g, new Rectangle (0, 0, hwnd.Width, hwnd.Height));
+ g.Dispose ();
+ break;
+ }
+
+ case FormBorderStyle.FixedSingle: {
+ Graphics g;
+
+ g = Graphics.FromHwnd (hwnd.whole_window);
+ ControlPaint.DrawBorder (g, new Rectangle (0, 0, hwnd.Width, hwnd.Height), Color.Black, ButtonBorderStyle.Solid);
+ g.Dispose ();
+ break;
+ }
+ }
+ #if DriverDebugExtra
+ Console.WriteLine("GetMessage(): Window {0:X} Exposed non-client area {1},{2} {3}x{4}", hwnd.client_window.ToInt32(), xevent.ExposeEvent.x, xevent.ExposeEvent.y, xevent.ExposeEvent.width, xevent.ExposeEvent.height);
+ #endif
+
+ Rectangle rect = new Rectangle (xevent.ExposeEvent.x, xevent.ExposeEvent.y, xevent.ExposeEvent.width, xevent.ExposeEvent.height);
+ Region region = new Region (rect);
+ IntPtr hrgn = region.GetHrgn (null); // Graphics object isn't needed
+ msg.message = Msg.WM_NCPAINT;
+ msg.wParam = hrgn;
+ hwnd.nc_expose_pending = false;
+ break;
+ }
+ #if DriverDebugExtra
+ Console.WriteLine("GetMessage(): Window {0:X} Exposed area {1},{2} {3}x{4}", hwnd.client_window.ToInt32(), xevent.ExposeEvent.x, xevent.ExposeEvent.y, xevent.ExposeEvent.width, xevent.ExposeEvent.height);
+ #endif
+ if (Caret.Visible == 1) {
+ Caret.Paused = true;
+ HideCaret ();
+ }
+
+ if (Caret.Visible == 1) {
+ ShowCaret ();
+ Caret.Paused = false;
+ }
+ msg.message = Msg.WM_PAINT;
+ break;
+ }
+
+ case XEventName.DestroyNotify: {
+
+ // This is a bit tricky, we don't receive our own DestroyNotify, we only get those for our children
+ hwnd = Hwnd.ObjectFromHandle (xevent.DestroyWindowEvent.window);
+
+ // We may get multiple for the same window, act only one the first (when Hwnd still knows about it)
+ if (hwnd.client_window == xevent.DestroyWindowEvent.window) {
+ msg.hwnd = hwnd.client_window;
+ msg.message = Msg.WM_DESTROY;
+ hwnd.Dispose ();
+
+ #if DriverDebug
+ Console.WriteLine("Got DestroyNotify on Window {0:X}", msg.hwnd.ToInt32());
+ #endif
+ } else {
+ goto ProcessNextMessage;
+ }
+
+ break;
+ }
+
+ case XEventName.ClientMessage: {
+ if (Dnd.HandleClientMessage (ref xevent)) {
+ goto ProcessNextMessage;
+ }
+
+ if (xevent.ClientMessageEvent.message_type == (IntPtr)AsyncAtom) {
+ XplatUIDriverSupport.ExecuteClientMessage ((GCHandle)xevent.ClientMessageEvent.ptr1);
+ break;
+ }
+
+ if (xevent.ClientMessageEvent.message_type == (IntPtr)HoverState.Atom) {
+ msg.message = Msg.WM_MOUSEHOVER;
+ msg.wParam = GetMousewParam (0);
+ msg.lParam = (IntPtr) (xevent.ClientMessageEvent.ptr1);
+ break;
+ }
+
+ if (xevent.ClientMessageEvent.message_type == (IntPtr)PostAtom) {
+ msg.hwnd = xevent.ClientMessageEvent.ptr1;
+ msg.message = (Msg) xevent.ClientMessageEvent.ptr2.ToInt32 ();
+ msg.wParam = xevent.ClientMessageEvent.ptr3;
+ msg.lParam = xevent.ClientMessageEvent.ptr4;
+ break;
+ }
+
+ #if dontcare
+ if (xevent.ClientMessageEvent.message_type == (IntPtr)NetAtoms[(int)NA._XEMBED]) {
+ Console.WriteLine("GOT EMBED MESSAGE {0:X}", xevent.ClientMessageEvent.ptr2.ToInt32());
+ break;
+ }
+ #endif
+
+ if (xevent.ClientMessageEvent.message_type == (IntPtr)NetAtoms [(int)NA.WM_PROTOCOLS]) {
+ if (xevent.ClientMessageEvent.ptr1 == (IntPtr)NetAtoms [(int)NA.WM_DELETE_WINDOW]) {
+ msg.message = Msg.WM_CLOSE;
+ Graphics.FromHdcInternal (IntPtr.Zero);
+ break;
+ }
+
+ // We should not get this, but I'll leave the code in case we need it in the future
+ if (xevent.ClientMessageEvent.ptr1 == (IntPtr)NetAtoms [(int)NA.WM_TAKE_FOCUS]) {
+ goto ProcessNextMessage;
+ }
+ }
+ break;
+ }
+
+ case XEventName.TimerNotify: {
+ xevent.TimerNotifyEvent.handler (this, EventArgs.Empty);
+ break;
+ }
+
+ default: {
+ goto ProcessNextMessage;
+ }
+ }
+
+ return true;
+ }
+
+ internal override bool GetText (IntPtr handle, out string text)
+ {
+ IntPtr textptr;
+
+ textptr = IntPtr.Zero;
+
+ lock (XlibLock) {
+ // FIXME - use _NET properties
+ XFetchName (DisplayHandle, Hwnd.ObjectFromHandle (handle).whole_window, ref textptr);
+ }
+ if (textptr != IntPtr.Zero) {
+ text = Marshal.PtrToStringAnsi (textptr);
+ XFree (textptr);
+ return true;
+ } else {
+ text = "";
+ return false;
+ }
+ }
+
+ internal override void GetWindowPos (IntPtr handle, bool is_toplevel, out int x, out int y, out int width, out int height, out int client_width, out int client_height)
+ {
+ Hwnd hwnd;
+ Rectangle rect;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ if (hwnd != null) {
+ x = hwnd.x;
+ y = hwnd.y;
+ width = hwnd.width;
+ height = hwnd.height;
+
+ rect = Hwnd.GetClientRectangle (hwnd.border_style, hwnd.menu, hwnd.title_style, hwnd.caption_height, hwnd.tool_caption_height, width, height);
+
+ client_width = rect.Width;
+ client_height = rect.Height;
+
+ return;
+ }
+
+ // Should we throw an exception or fail silently?
+ // throw new ArgumentException("Called with an invalid window handle", "handle");
+
+ x = 0;
+ y = 0;
+ width = 0;
+ height = 0;
+ client_width = 0;
+ client_height = 0;
+ }
+
+ internal override FormWindowState GetWindowState (IntPtr handle)
+ {
+ Atom actual_atom;
+ int actual_format;
+ int nitems;
+ int bytes_after;
+ IntPtr prop = IntPtr.Zero;
+ IntPtr atom;
+ int maximized;
+ bool minimized;
+ XWindowAttributes attributes;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ maximized = 0;
+ minimized = false;
+ XGetWindowProperty (DisplayHandle, hwnd.whole_window, NetAtoms [(int)NA._NET_WM_STATE], 0, 256, false, Atom.XA_ATOM, out actual_atom, out actual_format, out nitems, out bytes_after, ref prop);
+ if ((nitems > 0) && (prop != IntPtr.Zero)) {
+ for (int i = 0; i < nitems; i++) {
+ atom = (IntPtr)Marshal.ReadInt32 (prop, i * 4);
+ if ((atom == (IntPtr)NetAtoms [(int)NA._NET_WM_STATE_MAXIMIZED_HORZ]) || (atom == (IntPtr)NetAtoms [(int)NA._NET_WM_STATE_MAXIMIZED_VERT])) {
+ maximized++;
+ } else if (atom == (IntPtr)NetAtoms [(int)NA._NET_WM_STATE_HIDDEN]) {
+ minimized = true;
+ }
+ }
+ XFree (prop);
+ }
+
+ if (minimized) {
+ return FormWindowState.Minimized;
+ } else if (maximized == 2) {
+ return FormWindowState.Maximized;
+ }
+
+ attributes = new XWindowAttributes ();
+ XGetWindowAttributes (DisplayHandle, handle, ref attributes);
+ if (attributes.map_state == MapState.IsUnmapped) {
+ throw new NotSupportedException ("Cannot retrieve the state of an unmapped window");
+ }
+
+
+ return FormWindowState.Normal;
+ }
+
+ internal override void GrabInfo (out IntPtr handle, out bool GrabConfined, out Rectangle GrabArea)
+ {
+ handle = Grab.Hwnd;
+ GrabConfined = Grab.Confined;
+ GrabArea = Grab.Area;
+ }
+
+ internal override void GrabWindow (IntPtr handle, IntPtr confine_to_handle)
+ {
+ Hwnd hwnd;
+ IntPtr confine_to_window;
+
+ confine_to_window = IntPtr.Zero;
+
+ if (confine_to_handle != IntPtr.Zero) {
+ XWindowAttributes attributes = new XWindowAttributes ();
+
+ hwnd = Hwnd.ObjectFromHandle (confine_to_handle);
+
+ lock (XlibLock) {
+ XGetWindowAttributes (DisplayHandle, hwnd.client_window, ref attributes);
+ }
+ Grab.Area.X = attributes.x;
+ Grab.Area.Y = attributes.y;
+ Grab.Area.Width = attributes.width;
+ Grab.Area.Height = attributes.height;
+ Grab.Confined = true;
+ confine_to_window = hwnd.client_window;
+ }
+
+ Grab.Hwnd = handle;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ lock (XlibLock) {
+ XGrabPointer (DisplayHandle, hwnd.client_window, false,
+ EventMask.ButtonPressMask | EventMask.ButtonMotionMask |
+ EventMask.ButtonReleaseMask | EventMask.PointerMotionMask,
+ GrabMode.GrabModeAsync, GrabMode.GrabModeAsync, confine_to_window, 0, 0);
+ }
+ }
+
+ internal override void UngrabWindow (IntPtr hwnd)
+ {
+ lock (XlibLock) {
+ XUngrabPointer (DisplayHandle, 0);
+ XFlush (DisplayHandle);
+ }
+ Grab.Hwnd = IntPtr.Zero;
+ Grab.Confined = false;
+ }
+
+ internal override void HandleException (Exception e)
+ {
+ StackTrace st = new StackTrace (e, true);
+ Console.WriteLine ("Exception '{0}'", e.Message + st.ToString ());
+ Console.WriteLine ("{0}{1}", e.Message, st.ToString ());
+ }
+
+ internal override void Invalidate (IntPtr handle, Rectangle rc, bool clear)
+ {
+ Hwnd hwnd;
+ XEvent xevent;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+
+ xevent = new XEvent ();
+ xevent.type = XEventName.Expose;
+ xevent.ExposeEvent.display = DisplayHandle;
+ xevent.ExposeEvent.window = hwnd.client_window;
+
+ if (clear) {
+ xevent.ExposeEvent.x = hwnd.X;
+ xevent.ExposeEvent.y = hwnd.Y;
+ xevent.ExposeEvent.width = hwnd.Width;
+ xevent.ExposeEvent.height = hwnd.Height;
+ } else {
+ xevent.ExposeEvent.x = rc.X;
+ xevent.ExposeEvent.y = rc.Y;
+ xevent.ExposeEvent.width = rc.Width;
+ xevent.ExposeEvent.height = rc.Height;
+ }
+
+ AddExpose (xevent);
+ }
+
+ internal override bool IsEnabled (IntPtr handle)
+ {
+ return Hwnd.ObjectFromHandle (handle).Enabled;
+ }
+
+ internal override bool IsVisible (IntPtr handle)
+ {
+ return Hwnd.ObjectFromHandle (handle).visible;
+ }
+
+ internal override void KillTimer (Timer timer)
+ {
+ lock (TimerList) {
+ TimerList.Remove (timer);
+ }
+ }
+
+ internal override void MenuToScreen (IntPtr handle, ref int x, ref int y)
+ {
+ int dest_x_return;
+ int dest_y_return;
+ IntPtr child;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ lock (XlibLock) {
+ XTranslateCoordinates (DisplayHandle, hwnd.whole_window, RootWindow, x, y, out dest_x_return, out dest_y_return, out child);
+ }
+
+ x = dest_x_return;
+ y = dest_y_return;
+ }
+
+ internal override void OverrideCursor (IntPtr cursor)
+ {
+ OverrideCursorHandle = cursor;
+ }
+
+ internal override PaintEventArgs PaintEventStart (IntPtr handle, bool client)
+ {
+ PaintEventArgs paint_event;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ if (Caret.Visible == 1) {
+ Caret.Paused = true;
+ HideCaret ();
+ }
+
+ if (client) {
+ // handle backing store
+ IntPtr gdk_window = gdk_window_lookup (hwnd.client_window);
+ IntPtr gdk_pixmap = NewPixmap (gdk_window, hwnd.ClientRect.Width, hwnd.ClientRect.Height);
+
+ backing_store [gdk_window] = gdk_pixmap;
+
+ hwnd.client_dc = Graphics.FromHwnd (gdk_x11_drawable_get_xid (gdk_pixmap));
+ hwnd.client_dc.SetClip (hwnd.invalid);
+ paint_event = new PaintEventArgs (hwnd.client_dc, hwnd.invalid);
+ hwnd.expose_pending = false;
+
+ return paint_event;
+ } else {
+ hwnd.client_dc = Graphics.FromHwnd (hwnd.whole_window);
+ paint_event = new PaintEventArgs (hwnd.client_dc, new Rectangle (0, 0, hwnd.width, hwnd.height));
+ hwnd.nc_expose_pending = false;
+
+ return paint_event;
+ }
+ }
+
+ internal override void PaintEventEnd (IntPtr handle, bool client)
+ {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ hwnd.client_dc.Flush ();
+
+ if (client) {
+ // clients are already drawn to a backing store pixmap
+ IntPtr gdk_window = gdk_window_lookup (hwnd.client_window);
+ IntPtr gdk_pixmap = (IntPtr)backing_store [gdk_window];
+
+ BlitOffscreenPixmap (gdk_pixmap, gdk_window, hwnd.Invalid);
+
+ g_object_unref (gdk_pixmap);
+ backing_store.Remove (gdk_pixmap);
+
+ hwnd.ClearInvalidArea ();
+ }
+
+ hwnd.client_dc.Dispose ();
+ hwnd.client_dc = null;
+
+ if (Caret.Visible == 1) {
+ ShowCaret ();
+ Caret.Paused = false;
+ }
+ }
+
+ internal override bool PeekMessage (ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags)
+ {
+ bool pending;
+
+ // FIXME - imlement filtering
+
+ if ((flags & (uint)PeekMessageFlags.PM_REMOVE) == 0) {
+ throw new NotImplementedException ("PeekMessage PM_NOREMOVE is not implemented yet"); // FIXME - Implement PM_NOREMOVE flag
+ }
+
+ pending = false;
+ if (MessageQueue.Count > 0) {
+ pending = true;
+ } else {
+ // Only call UpdateMessageQueue if real events are pending
+ // otherwise we go to sleep on the socket
+ if (XPending (DisplayHandle) != 0) {
+ UpdateMessageQueue ();
+ pending = true;
+ }
+ }
+
+ CheckTimers (DateTime.Now);
+
+ if (!pending) {
+ return false;
+ }
+ return GetMessage (ref msg, hWnd, wFilterMin, wFilterMax);
+ }
+
+ // FIXME - I think this should just enqueue directly
+ internal override bool PostMessage (IntPtr handle, Msg message, IntPtr wparam, IntPtr lparam)
+ {
+ XEvent xevent = new XEvent ();
+ Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
+
+ xevent.type = XEventName.ClientMessage;
+ xevent.ClientMessageEvent.display = DisplayHandle;
+
+ if (hwnd != null) {
+ xevent.ClientMessageEvent.window = hwnd.whole_window;
+ } else {
+ xevent.ClientMessageEvent.window = IntPtr.Zero;
+ }
+
+ xevent.ClientMessageEvent.message_type = (IntPtr) PostAtom;
+ xevent.ClientMessageEvent.format = 32;
+ xevent.ClientMessageEvent.ptr1 = handle;
+ xevent.ClientMessageEvent.ptr2 = (IntPtr) message;
+ xevent.ClientMessageEvent.ptr3 = wparam;
+ xevent.ClientMessageEvent.ptr4 = lparam;
+
+ MessageQueue.Enqueue (xevent);
+
+ return true;
+ }
+
+ internal override void PostQuitMessage (int exitCode)
+ {
+ XFlush (DisplayHandle);
+ PostQuitState = true;
+
+ // Remove our display handle from S.D
+ Graphics.FromHdcInternal (IntPtr.Zero);
+ }
+
+ internal override void ScreenToClient (IntPtr handle, ref int x, ref int y)
+ {
+ int dest_x_return;
+ int dest_y_return;
+ IntPtr child;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ lock (XlibLock) {
+ XTranslateCoordinates (DisplayHandle, RootWindow, hwnd.client_window, x, y, out dest_x_return, out dest_y_return, out child);
+ }
+
+ x = dest_x_return;
+ y = dest_y_return;
+ }
+
+ internal override void ScreenToMenu (IntPtr handle, ref int x, ref int y)
+ {
+ int dest_x_return;
+ int dest_y_return;
+ IntPtr child;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ lock (XlibLock) {
+ XTranslateCoordinates (DisplayHandle, RootWindow, hwnd.whole_window, x, y, out dest_x_return, out dest_y_return, out child);
+ }
+
+ x = dest_x_return;
+ y = dest_y_return;
+ }
+
+ internal override void ScrollWindow (IntPtr handle, Rectangle area, int XAmount, int YAmount, bool with_children)
+ {
+ Hwnd hwnd;
+ IntPtr gc;
+ XGCValues gc_values;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ if (hwnd.invalid != Rectangle.Empty) {
+ // BIG FAT WARNING. This only works with how we use this function right now
+ // where we basically still scroll the whole window, but work around areas
+ // that are covered by our children
+
+ hwnd.invalid.X += XAmount;
+ hwnd.invalid.Y += YAmount;
+
+ if (hwnd.invalid.X < 0) {
+ hwnd.invalid.Width += hwnd.invalid.X;
+ hwnd.invalid.X = 0;
+ }
+
+ if (hwnd.invalid.Y < 0) {
+ hwnd.invalid.Height += hwnd.invalid.Y;
+ hwnd.invalid.Y = 0;
+ }
+ }
+
+ gc_values = new XGCValues ();
+
+ if (with_children) {
+ gc_values.subwindow_mode = GCSubwindowMode.IncludeInferiors;
+ }
+
+ gc = XCreateGC (DisplayHandle, hwnd.client_window, 0, ref gc_values);
+
+ XCopyArea (DisplayHandle, hwnd.client_window, hwnd.client_window, gc, area.X - XAmount, area.Y - YAmount, area.Width, area.Height, area.X, area.Y);
+
+ // Generate an expose for the area exposed by the horizontal scroll
+ if (XAmount > 0) {
+ hwnd.AddInvalidArea (area.X, area.Y, XAmount, area.Height);
+ } else if (XAmount < 0) {
+ hwnd.AddInvalidArea (XAmount + area.X + area.Width, area.Y, -XAmount, area.Height);
+ }
+
+ // Generate an expose for the area exposed by the vertical scroll
+ if (YAmount > 0) {
+ hwnd.AddInvalidArea (area.X, area.Y, area.Width, YAmount);
+ } else if (YAmount < 0) {
+ hwnd.AddInvalidArea (area.X, YAmount + area.Y + area.Height, area.Width, -YAmount);
+ }
+ XFreeGC (DisplayHandle, gc);
+
+ UpdateWindow (handle);
+ }
+
+ internal override void ScrollWindow (IntPtr handle, int XAmount, int YAmount, bool with_children)
+ {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.GetObjectFromWindow (handle);
+
+ ScrollWindow (handle, hwnd.ClientRect, XAmount, YAmount, with_children);
+ }
+
+ internal override void SendAsyncMethod (AsyncMethodData method)
+ {
+ XEvent xevent = new XEvent ();
+
+ xevent.type = XEventName.ClientMessage;
+ xevent.ClientMessageEvent.display = DisplayHandle;
+ xevent.ClientMessageEvent.window = FosterParent;
+ xevent.ClientMessageEvent.message_type = (IntPtr)AsyncAtom;
+ xevent.ClientMessageEvent.format = 32;
+ xevent.ClientMessageEvent.ptr1 = (IntPtr) GCHandle.Alloc (method);
+
+ MessageQueue.EnqueueLocked (xevent);
+
+ WakeupMain ();
+ }
+
+ internal override IntPtr SendMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam)
+ {
+ return NativeWindow.WndProc (hwnd, message, wParam, lParam);
+ }
+
+ internal override void SetAllowDrop (IntPtr handle, bool value)
+ {
+ // We allow drop on all windows
+ }
+
+ internal override DragDropEffects StartDrag (IntPtr handle, object data,
+ DragDropEffects allowed_effects)
+ {
+ Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
+
+ if (hwnd == null)
+ throw new ArgumentException ("Attempt to begin drag from invalid window handle (" + handle.ToInt32 () + ").");
+
+ return Dnd.StartDrag (hwnd.client_window, data, allowed_effects);
+ }
+
+ internal override void SetBorderStyle (IntPtr handle, FormBorderStyle border_style)
+ {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ hwnd.border_style = border_style;
+
+ XMoveResizeWindow (DisplayHandle, hwnd.client_window, hwnd.ClientRect.X, hwnd.ClientRect.Y, hwnd.ClientRect.Width, hwnd.ClientRect.Height);
+
+ InvalidateWholeWindow (handle);
+ }
+
+ internal override void SetCaretPos (IntPtr handle, int x, int y)
+ {
+ if (Caret.Hwnd == handle) {
+ Caret.Timer.Stop ();
+ HideCaret ();
+
+ Caret.X = x;
+ Caret.Y = y;
+
+ if (Caret.Visible == 1) {
+ ShowCaret ();
+ Caret.Timer.Start ();
+ }
+ }
+ }
+
+ internal override void SetCursor (IntPtr handle, IntPtr cursor)
+ {
+ Hwnd hwnd;
+
+ if (OverrideCursorHandle == IntPtr.Zero) {
+ if ((LastCursorWindow == handle) && (LastCursorHandle == cursor)) {
+ return;
+ }
+
+ LastCursorHandle = cursor;
+ LastCursorWindow = handle;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+ lock (XlibLock) {
+ if (cursor != IntPtr.Zero) {
+ XDefineCursor (DisplayHandle, hwnd.whole_window, cursor);
+ } else {
+ XUndefineCursor (DisplayHandle, hwnd.whole_window);
+ }
+ }
+ return;
+ }
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+ lock (XlibLock) {
+ XDefineCursor (DisplayHandle, hwnd.whole_window, OverrideCursorHandle);
+ }
+ }
+
+ internal override void SetCursorPos (IntPtr handle, int x, int y)
+ {
+ if (handle == IntPtr.Zero) {
+ lock (XlibLock) {
+ XWarpPointer (DisplayHandle, IntPtr.Zero, IntPtr.Zero, 0, 0, 0, 0, x, y);
+ }
+ return;
+ } else {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+ lock (XlibLock) {
+ XWarpPointer (DisplayHandle, IntPtr.Zero, hwnd.client_window, 0, 0, 0, 0, x, y);
+ }
+ return;
+ }
+ }
+
+ internal override void SetFocus (IntPtr handle)
+ {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ if (FocusWindow != IntPtr.Zero) {
+ PostMessage (FocusWindow, Msg.WM_KILLFOCUS, hwnd.client_window, IntPtr.Zero);
+ }
+ PostMessage (hwnd.client_window, Msg.WM_SETFOCUS, FocusWindow, IntPtr.Zero);
+ FocusWindow = hwnd.client_window;
+
+ //XSetInputFocus(DisplayHandle, Hwnd.ObjectFromHandle(handle).client_window, RevertTo.None, IntPtr.Zero);
+ }
+
+ internal override void SetIcon (IntPtr handle, Icon icon)
+ {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+ if (hwnd != null) {
+ SetIcon (hwnd, icon);
+ }
+ }
+
+ internal override void SetMenu (IntPtr handle, Menu menu)
+ {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+ hwnd.menu = menu;
+
+ // FIXME - do we need to trigger some resize?
+ }
+
+ internal override void SetModal (IntPtr handle, bool Modal)
+ {
+ if (Modal) {
+ ModalWindows.Push (handle);
+ } else {
+ if (ModalWindows.Contains (handle)) {
+ ModalWindows.Pop ();
+ }
+ if (ModalWindows.Count > 0) {
+ Activate ((IntPtr)ModalWindows.Peek ());
+ }
+ }
+ }
+
+ internal override IntPtr SetParent (IntPtr handle, IntPtr parent)
+ {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+ hwnd.parent = Hwnd.ObjectFromHandle (parent);
+
+ lock (XlibLock) {
+ #if DriverDebug
+ Console.WriteLine("Parent for window {0:X} / {1:X} = {2:X} (Handle:{3:X})", hwnd.ClientWindow.ToInt32(), hwnd.WholeWindow.ToInt32(), hwnd.parent != null ? hwnd.parent.Handle.ToInt32() : 0, parent.ToInt32());
+ #endif
+ XReparentWindow (DisplayHandle, hwnd.whole_window, hwnd.parent.client_window, hwnd.x, hwnd.y);
+ }
+
+ return IntPtr.Zero;
+ }
+
+ internal override void SetTimer (Timer timer)
+ {
+ lock (TimerList) {
+ TimerList.Add (timer);
+ }
+ WakeupMain ();
+ }
+
+ internal override bool SetTopmost (IntPtr handle, IntPtr handle_owner, bool enabled)
+ {
+ Hwnd hwnd;
+ Hwnd hwnd_owner;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ if (handle_owner != IntPtr.Zero) {
+ hwnd_owner = Hwnd.ObjectFromHandle (handle_owner);
+ } else {
+ hwnd_owner = null;
+ }
+
+ if (enabled) {
+ lock (XlibLock) {
+ if (hwnd_owner != null) {
+ XSetTransientForHint (DisplayHandle, hwnd.whole_window, hwnd_owner.whole_window);
+ } else {
+ XSetTransientForHint (DisplayHandle, hwnd.whole_window, FosterParent);
+ }
+ }
+ } else {
+ lock (XlibLock) {
+ XDeleteProperty (DisplayHandle, hwnd.whole_window, (int)Atom.XA_WM_TRANSIENT_FOR);
+ }
+ }
+ return true;
+ }
+
+ internal override bool SetVisible (IntPtr handle, bool visible)
+ {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+ hwnd.visible = visible;
+
+ lock (XlibLock) {
+ if (visible) {
+ if (Control.FromHandle (handle) is Form) {
+ FormWindowState s;
+
+ s = ((Form)Control.FromHandle (handle)).WindowState;
+
+ XMapWindow (DisplayHandle, hwnd.whole_window);
+ XMapWindow (DisplayHandle, hwnd.client_window);
+
+ switch (s) {
+ case FormWindowState.Minimized: SetWindowState (handle, FormWindowState.Minimized); break;
+ case FormWindowState.Maximized: SetWindowState (handle, FormWindowState.Maximized); break;
+ }
+ } else {
+ XMapWindow (DisplayHandle, hwnd.whole_window);
+ XMapWindow (DisplayHandle, hwnd.client_window);
+ }
+ } else {
+ XUnmapWindow (DisplayHandle, hwnd.whole_window);
+ }
+ }
+ return true;
+ }
+
+ internal override void SetWindowMinMax (IntPtr handle, Rectangle maximized, Size min, Size max)
+ {
+ Hwnd hwnd;
+ XSizeHints hints;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+ if (hwnd == null) {
+ return;
+ }
+
+ hints = new XSizeHints ();
+
+ if (min != Size.Empty) {
+ hints.flags = (IntPtr)((int)hints.flags | (int)XSizeHintsFlags.PMinSize);
+ hints.min_width = min.Width;
+ hints.min_height = min.Height;
+ }
+
+ if (max != Size.Empty) {
+ hints.flags = (IntPtr)((int)hints.flags | (int)XSizeHintsFlags.PMaxSize);
+ hints.max_width = max.Width;
+ hints.max_height = max.Height;
+ }
+
+ XSetWMNormalHints (DisplayHandle, hwnd.whole_window, ref hints);
+
+ if (maximized != Rectangle.Empty) {
+ hints.flags = (IntPtr)XSizeHintsFlags.PPosition;
+ hints.x = maximized.X;
+ hints.y = maximized.Y;
+ hints.width = maximized.Width;
+ hints.height = maximized.Height;
+
+ // Metacity does not seem to follow this constraint for maximized (zoomed) windows
+ XSetZoomHints (DisplayHandle, hwnd.whole_window, ref hints);
+ }
+ }
+
+
+ internal override void SetWindowPos (IntPtr handle, int x, int y, int width, int height)
+ {
+ Hwnd hwnd;
+ Rectangle client_rect;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ // X requires a sanity check for width & height; otherwise it dies
+ if (hwnd.zero_sized && width > 0 && height > 0) {
+ if (hwnd.visible) {
+ XMapWindow (DisplayHandle, hwnd.whole_window);
+ }
+ hwnd.zero_sized = false;
+ }
+
+ if (width < 1) {
+ hwnd.zero_sized = true;
+ XUnmapWindow (DisplayHandle, hwnd.whole_window);
+ }
+
+ if (height < 1) {
+ hwnd.zero_sized = true;
+ XUnmapWindow (DisplayHandle, hwnd.whole_window);
+ }
+
+ client_rect = Hwnd.GetClientRectangle (hwnd.border_style, hwnd.menu, hwnd.title_style, hwnd.caption_height, hwnd.tool_caption_height, width, height);
+
+ // Save a server roundtrip (and prevent a feedback loop)
+ if ((hwnd.x == x) && (hwnd.y == y) &&
+ (hwnd.width == width) && (hwnd.height == height) &&
+ (hwnd.ClientRect == client_rect)) {
+ return;
+ }
+
+ if (!hwnd.zero_sized) {
+ lock (XlibLock) {
+ XMoveResizeWindow (DisplayHandle, hwnd.whole_window, x, y, width, height);
+ XMoveResizeWindow (DisplayHandle, hwnd.client_window, client_rect.X, client_rect.Y, client_rect.Width, client_rect.Height);
+ }
+ }
+
+ // Prevent an old queued ConfigureNotify from setting our width with outdated data, set it now
+ hwnd.width = width;
+ hwnd.height = height;
+ }
+
+ internal override void SetWindowState (IntPtr handle, FormWindowState state)
+ {
+ FormWindowState current_state;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ current_state = GetWindowState (handle);
+
+ if (current_state == state) {
+ return;
+ }
+
+ switch (state) {
+ case FormWindowState.Normal: {
+ lock (XlibLock) {
+ if (current_state == FormWindowState.Minimized) {
+ XMapWindow (DisplayHandle, hwnd.whole_window);
+ XMapWindow (DisplayHandle, hwnd.client_window);
+ } else if (current_state == FormWindowState.Maximized) {
+ SendNetWMMessage (hwnd.whole_window, (IntPtr)(uint)NetAtoms [(int)NA._NET_WM_STATE], (IntPtr)2 /* toggle */, (IntPtr)NetAtoms [(int)NA._NET_WM_STATE_MAXIMIZED_HORZ], (IntPtr)NetAtoms [(int)NA._NET_WM_STATE_MAXIMIZED_VERT]);
+ }
+ }
+ Activate (handle);
+ return;
+ }
+
+ case FormWindowState.Minimized: {
+ lock (XlibLock) {
+ if (current_state == FormWindowState.Maximized) {
+ SendNetWMMessage (hwnd.whole_window, (IntPtr)NetAtoms [(int)NA._NET_WM_STATE], (IntPtr)2 /* toggle */, (IntPtr)NetAtoms [(int)NA._NET_WM_STATE_MAXIMIZED_HORZ], (IntPtr)NetAtoms [(int)NA._NET_WM_STATE_MAXIMIZED_VERT]);
+ }
+ XIconifyWindow (DisplayHandle, hwnd.whole_window, ScreenNo);
+ }
+ return;
+ }
+
+ case FormWindowState.Maximized: {
+ lock (XlibLock) {
+ if (current_state == FormWindowState.Minimized) {
+ XMapWindow (DisplayHandle, hwnd.whole_window);
+ XMapWindow (DisplayHandle, hwnd.client_window);
+ }
+
+ SendNetWMMessage (hwnd.whole_window, (IntPtr)NetAtoms [(int)NA._NET_WM_STATE], (IntPtr)1 /* Add */, (IntPtr)NetAtoms [(int)NA._NET_WM_STATE_MAXIMIZED_HORZ], (IntPtr)NetAtoms [(int)NA._NET_WM_STATE_MAXIMIZED_VERT]);
+ }
+ Activate (handle);
+ return;
+ }
+ }
+ }
+
+ internal override void SetWindowStyle (IntPtr handle, CreateParams cp)
+ {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+ SetHwndStyles (hwnd, cp);
+ SetWMStyles (hwnd, cp);
+ }
+
+ internal override void SetWindowTransparency (IntPtr handle, double transparency, Color key)
+ {
+ Hwnd hwnd;
+ uint opacity;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ if (hwnd == null) {
+ return;
+ }
+
+ hwnd.opacity = (uint)(0xffffffff * transparency);
+ opacity = hwnd.opacity;
+
+ if (hwnd.reparented) {
+ XChangeProperty (DisplayHandle, XGetParent (hwnd.whole_window), NetAtoms [(int)NA._NET_WM_WINDOW_OPACITY], Atom.XA_CARDINAL, 32, PropertyMode.Replace, ref opacity, 1);
+ }
+ }
+
+ internal override bool SetZOrder (IntPtr handle, IntPtr after_handle, bool top, bool bottom)
+ {
+ Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
+
+ if (top) {
+ lock (XlibLock) {
+ XRaiseWindow (DisplayHandle, hwnd.whole_window);
+ }
+ return true;
+ } else if (!bottom) {
+ Hwnd after_hwnd = null;
+
+ if (after_handle != IntPtr.Zero) {
+ after_hwnd = Hwnd.ObjectFromHandle (after_handle);
+ }
+
+ XWindowChanges values = new XWindowChanges ();
+
+ if (after_hwnd == null) {
+ throw new ArgumentNullException ("after_handle", "Need sibling to adjust z-order");
+ }
+ values.sibling = after_hwnd.whole_window;
+ values.stack_mode = StackMode.Below;
+
+ lock (XlibLock) {
+ XConfigureWindow (DisplayHandle, hwnd.whole_window, ChangeWindowFlags.CWStackMode | ChangeWindowFlags.CWSibling, ref values);
+ }
+ } else {
+ // Bottom
+ lock (XlibLock) {
+ XLowerWindow (DisplayHandle, hwnd.whole_window);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ internal override void ShowCursor (bool show)
+ {
+ ; // FIXME - X11 doesn't 'hide' the cursor. we could create an empty cursor
+ }
+
+ internal override void StartLoop (Thread thread)
+ {
+ // Future place for prepping a new queue for this specific thread
+ }
+
+ internal override bool SupportsTransparency ()
+ {
+ // We need to check if the x compositing manager is running
+ return true;
+ }
+
+ internal override bool SystrayAdd (IntPtr handle, string tip, Icon icon, out ToolTip tt)
+ {
+ GetSystrayManagerWindow ();
+
+ if (SystrayMgrWindow != IntPtr.Zero) {
+ uint[] atoms;
+ XSizeHints size_hints;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+ #if DriverDebug
+ Console.WriteLine("Adding Systray Whole:{0:X}, Client:{1:X}", hwnd.whole_window.ToInt32(), hwnd.client_window.ToInt32());
+ #endif
+
+ XUnmapWindow (DisplayHandle, hwnd.whole_window);
+ XUnmapWindow (DisplayHandle, hwnd.client_window);
+
+ // Oh boy.
+ gdk_window_destroy (gdk_window_lookup (hwnd.client_window));
+ hwnd.client_window = hwnd.whole_window;
+
+ size_hints = new XSizeHints ();
+
+ size_hints.flags = (IntPtr)(XSizeHintsFlags.PMinSize | XSizeHintsFlags.PMaxSize | XSizeHintsFlags.PBaseSize);
+ size_hints.min_width = icon.Width;
+ size_hints.min_height = icon.Height;
+
+ size_hints.max_width = icon.Width;
+ size_hints.max_height = icon.Height;
+
+ size_hints.base_width = icon.Width;
+ size_hints.base_height = icon.Height;
+ XSetWMNormalHints (DisplayHandle, hwnd.whole_window, ref size_hints);
+
+ atoms = new uint [2];
+ atoms [0] = 1; // Version 1
+ atoms [1] = 0; // We're not mapped
+
+ // This line cost me 3 days...
+ XChangeProperty (DisplayHandle, hwnd.whole_window, NetAtoms [(int)NA._XEMBED_INFO], NetAtoms [(int)NA._XEMBED_INFO], 32, PropertyMode.Replace, atoms, 2);
+
+ // Need to pick some reasonable defaults
+ tt = new ToolTip ();
+ tt.AutomaticDelay = 100;
+ tt.InitialDelay = 250;
+ tt.ReshowDelay = 250;
+ tt.ShowAlways = true;
+
+ if ((tip != null) && (tip != string.Empty)) {
+ tt.SetToolTip (Control.FromHandle (handle), tip);
+ tt.Active = true;
+ } else {
+ tt.Active = false;
+ }
+
+ // Make sure the window exists
+ XSync (DisplayHandle, hwnd.whole_window);
+
+ SendNetClientMessage (SystrayMgrWindow, (IntPtr)NetAtoms [(int)NA._NET_SYSTEM_TRAY_OPCODE], IntPtr.Zero, (IntPtr)SystrayRequest.SYSTEM_TRAY_REQUEST_DOCK, hwnd.whole_window);
+ return true;
+ }
+
+ tt = null;
+ return false;
+ }
+
+ internal override bool SystrayChange (IntPtr handle, string tip, Icon icon, ref ToolTip tt)
+ {
+ Control control;
+
+ control = Control.FromHandle (handle);
+ if (control != null && tt != null) {
+ tt.SetToolTip (control, tip);
+ tt.Active = true;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ internal override void SystrayRemove (IntPtr handle, ref ToolTip tt)
+ {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ XUnmapWindow (DisplayHandle, hwnd.whole_window);
+ SetParent (hwnd.whole_window, FosterParent);
+
+ // The caller can now re-dock it later...
+ if (tt != null) {
+ tt.Dispose ();
+ tt = null;
+ }
+ }
+
+ internal override bool Text (IntPtr handle, string text)
+ {
+ lock (XlibLock) {
+ gdk_window_set_title (gdk_window_lookup (Hwnd.ObjectFromHandle (handle).whole_window), text);
+ }
+ return true;
+ }
+
+ internal override bool TranslateMessage (ref MSG msg)
+ {
+ return Keyboard.TranslateMessage (ref msg);
+ }
+
+ internal override void UpdateWindow (IntPtr handle)
+ {
+ XEvent xevent;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle (handle);
+
+ if (!hwnd.visible || hwnd.expose_pending) {
+ return;
+ }
+
+ #if not
+ SendMessage(handle, Msg.WM_PAINT, IntPtr.Zero, IntPtr.Zero);
+ #else
+ xevent = new XEvent ();
+ xevent.type = XEventName.Expose;
+ xevent.ExposeEvent.display = DisplayHandle;
+ xevent.ExposeEvent.window = hwnd.client_window;
+
+ MessageQueue.Enqueue (xevent);
+ hwnd.expose_pending = true;
+ #endif
+ }
+
+ internal static IntPtr NewPixmap (IntPtr gdk_window, int width, int height)
+ {
+ return gdk_pixmap_new (gdk_window, width, height, 24); // FIXME: instead of 24, get the correct display depth
+ }
+
+ internal static void BlitOffscreenPixmap (IntPtr gdk_pixmap, IntPtr dest_drawable, Rectangle area)
+ {
+ IntPtr gdk_gc = gdk_gc_new (gdk_pixmap);
+
+ gdk_draw_drawable (dest_drawable, gdk_gc, gdk_pixmap, area.X, area.Y, area.X, area.Y, area.Width, area.Height);
+
+ g_object_unref (gdk_gc);
+ }
+ #endregion // Public Static Methods
+
+ #region Events
+ internal override event EventHandler Idle;
+ #endregion // Events
+
+ #region X11 Imports
+ [DllImport ("libX11", EntryPoint="XSynchronize")]
+ internal extern static IntPtr XSynchronize (IntPtr display, bool onoff);
+
+ [DllImport ("libX11", EntryPoint="XCreateWindow")]
+ internal extern static IntPtr XCreateWindow (IntPtr display, IntPtr parent, int x, int y, int width, int height, int border_width, int depth, int xclass, IntPtr visual, SetWindowValuemask valuemask, ref XSetWindowAttributes attributes);
+ [DllImport ("libX11", EntryPoint="XCreateSimpleWindow")]
+ internal extern static IntPtr XCreateSimpleWindow (IntPtr display, IntPtr parent, int x, int y, int width, int height, int border_width, int border, int background);
+ [DllImport ("libX11", EntryPoint="XMapWindow")]
+ internal extern static int XMapWindow (IntPtr display, IntPtr window);
+ [DllImport ("libX11", EntryPoint="XUnmapWindow")]
+ internal extern static int XUnmapWindow (IntPtr display, IntPtr window);
+ [DllImport ("libX11", EntryPoint="XMapSubwindows")]
+ internal extern static int XMapSubindows (IntPtr display, IntPtr window);
+ [DllImport ("libX11", EntryPoint="XUnmapSubwindows")]
+ internal extern static int XUnmapSubwindows (IntPtr display, IntPtr window);
+ [DllImport ("libX11", EntryPoint="XRootWindow")]
+ internal extern static IntPtr XRootWindow (IntPtr display, int screen_number);
+ [DllImport ("libX11", EntryPoint="XNextEvent")]
+ internal extern static IntPtr XNextEvent (IntPtr display, ref XEvent xevent);
+ [DllImport ("libX11")]
+ internal extern static int XConnectionNumber (IntPtr diplay);
+ [DllImport ("libX11")]
+ internal extern static int XPending (IntPtr diplay);
+ [DllImport ("libX11")]
+ internal extern static bool XCheckWindowEvent (IntPtr display, IntPtr window, EventMask mask, ref XEvent xevent);
+ [DllImport ("libX11")]
+ internal extern static bool XCheckMaskEvent (IntPtr display, EventMask mask, ref XEvent xevent);
+ [DllImport ("libX11", EntryPoint="XSelectInput")]
+ internal extern static IntPtr XSelectInput (IntPtr display, IntPtr window, EventMask mask);
+
+ [DllImport ("libX11", EntryPoint="XReparentWindow")]
+ internal extern static int XReparentWindow (IntPtr display, IntPtr window, IntPtr parent, int x, int y);
+ [DllImport ("libX11", EntryPoint="XMoveResizeWindow")]
+ internal extern static int XMoveResizeWindow (IntPtr display, IntPtr window, int x, int y, int width, int height);
+
+ [DllImport ("libX11", EntryPoint="XResizeWindow")]
+ internal extern static int XResizeWindow (IntPtr display, IntPtr window, int width, int height);
+
+ [DllImport ("libX11", EntryPoint="XGetWindowAttributes")]
+ internal extern static int XGetWindowAttributes (IntPtr display, IntPtr window, ref XWindowAttributes attributes);
+
+ [DllImport ("libX11", EntryPoint="XFlush")]
+ internal extern static int XFlush (IntPtr display);
+
+ [DllImport ("libX11", EntryPoint="XSetWMName")]
+ internal extern static int XSetWMName (IntPtr display, IntPtr window, ref XTextProperty text_prop);
+
+ [DllImport ("libX11", EntryPoint="XStoreName")]
+ internal extern static int XStoreName (IntPtr display, IntPtr window, string window_name);
+
+ [DllImport ("libX11", EntryPoint="XFetchName")]
+ internal extern static int XFetchName (IntPtr display, IntPtr window, ref IntPtr window_name);
+
+ [DllImport ("libX11", EntryPoint="XSendEvent")]
+ internal extern static int XSendEvent (IntPtr display, IntPtr window, bool propagate, EventMask event_mask, ref XEvent send_event);
+
+ [DllImport ("libX11", EntryPoint="XQueryTree")]
+ internal extern static int XQueryTree (IntPtr display, IntPtr window, out IntPtr root_return, out IntPtr parent_return, out IntPtr children_return, out int nchildren_return);
+
+ [DllImport ("libX11", EntryPoint="XFree")]
+ internal extern static int XFree (IntPtr data);
+
+ [DllImport ("libX11", EntryPoint="XRaiseWindow")]
+ internal extern static int XRaiseWindow (IntPtr display, IntPtr window);
+
+ [DllImport ("libX11", EntryPoint="XLowerWindow")]
+ internal extern static uint XLowerWindow (IntPtr display, IntPtr window);
+
+ [DllImport ("libX11", EntryPoint="XConfigureWindow")]
+ internal extern static uint XConfigureWindow (IntPtr display, IntPtr window, ChangeWindowFlags value_mask, ref XWindowChanges values);
+
+ [DllImport ("libX11", EntryPoint="XInternAtom")]
+ internal extern static int XInternAtom (IntPtr display, string atom_name, bool only_if_exists);
+
+ [DllImport ("libX11", EntryPoint="XSetWMProtocols")]
+ internal extern static int XSetWMProtocols (IntPtr display, IntPtr window, uint[] protocols, int count);
+
+ [DllImport ("libX11", EntryPoint="XGrabPointer")]
+ internal extern static int XGrabPointer (IntPtr display, IntPtr window, bool owner_events, EventMask event_mask, GrabMode pointer_mode, GrabMode keyboard_mode, IntPtr confine_to, uint cursor, uint timestamp);
+
+ [DllImport ("libX11", EntryPoint="XUngrabPointer")]
+ internal extern static int XUngrabPointer (IntPtr display, uint timestamp);
+
+ [DllImport ("libX11", EntryPoint="XQueryPointer")]
+ internal extern static bool XQueryPointer (IntPtr display, IntPtr window, out IntPtr root, out IntPtr child, out int root_x, out int root_y, out int win_x, out int win_y, out int keys_buttons);
+
+ [DllImport ("libX11", EntryPoint="XTranslateCoordinates")]
+ internal extern static bool XTranslateCoordinates (IntPtr display, IntPtr src_w, IntPtr dest_w, int src_x, int src_y, out int intdest_x_return, out int dest_y_return, out IntPtr child_return);
+
+ [DllImport ("libX11", EntryPoint="XWarpPointer")]
+ internal extern static uint XWarpPointer (IntPtr display, IntPtr src_w, IntPtr dest_w, int src_x, int src_y, uint src_width, uint src_height, int dest_x, int dest_y);
+
+ [DllImport ("libX11", EntryPoint="XClearWindow")]
+ internal extern static int XClearWindow (IntPtr display, IntPtr window);
+
+ [DllImport ("libX11", EntryPoint="XClearArea")]
+ internal extern static int XClearArea (IntPtr display, IntPtr window, int x, int y, int width, int height, bool exposures);
+
+ // Colormaps
+ [DllImport ("libX11", EntryPoint="XDefaultScreenOfDisplay")]
+ internal extern static IntPtr XDefaultScreenOfDisplay (IntPtr display);
+
+ [DllImport ("libX11", EntryPoint="XScreenNumberOfScreen")]
+ internal extern static int XScreenNumberOfScreen (IntPtr display, IntPtr Screen);
+
+ [DllImport ("libX11", EntryPoint="XDefaultVisual")]
+ internal extern static IntPtr XDefaultVisual (IntPtr display, int screen_number);
+
+ [DllImport ("libX11", EntryPoint="XDefaultDepth")]
+ internal extern static uint XDefaultDepth (IntPtr display, int screen_number);
+
+ [DllImport ("libX11", EntryPoint="XDefaultColormap")]
+ internal extern static IntPtr XDefaultColormap (IntPtr display, int screen_number);
+
+ [DllImport ("libX11", EntryPoint="XLookupColor")]
+ internal extern static int XLookupColor (IntPtr display, IntPtr Colormap, string Coloranem, ref XColor exact_def_color, ref XColor screen_def_color);
+
+ [DllImport ("libX11", EntryPoint="XAllocColor")]
+ internal extern static int XAllocColor (IntPtr display, IntPtr Colormap, ref XColor colorcell_def);
+
+ [DllImport ("libX11", EntryPoint="XSetTransientForHint")]
+ internal extern static int XSetTransientForHint (IntPtr display, IntPtr window, IntPtr prop_window);
+
+ [DllImport ("libX11", EntryPoint="XChangeProperty")]
+ internal extern static int XChangeProperty (IntPtr display, IntPtr window, int property, int type, int format, PropertyMode mode, ref MotifWmHints data, int nelements);
+
+ [DllImport ("libX11", EntryPoint="XChangeProperty")]
+ internal extern static int XChangeProperty (IntPtr display, IntPtr window, int property, Atom format, int type, PropertyMode mode, uint[] atoms, int nelements);
+
+ [DllImport ("libX11", EntryPoint="XChangeProperty")]
+ internal extern static int XChangeProperty (IntPtr display, IntPtr window, int property, Atom format, int type, PropertyMode mode, ref uint value, int nelements);
+
+ [DllImport ("libX11", EntryPoint="XChangeProperty")]
+ internal extern static int XChangeProperty (IntPtr display, IntPtr window, int property, int format, int type, PropertyMode mode, uint[] atoms, int nelements);
+
+ [DllImport ("libX11", EntryPoint="XChangeProperty")]
+ internal extern static int XChangeProperty (IntPtr display, IntPtr window, int property, int format, int type, PropertyMode mode, IntPtr atoms, int nelements);
+
+ [DllImport ("libX11", EntryPoint="XChangeProperty")]
+ internal extern static int XChangeProperty (IntPtr display, IntPtr window, int property, Atom format, int type, PropertyMode mode, IntPtr atoms, int nelements);
+
+ [DllImport ("libX11", EntryPoint="XChangeProperty", CharSet=CharSet.Ansi)]
+ internal extern static int XChangeProperty (IntPtr display, IntPtr window, int property, int type, int format, PropertyMode mode, string text, int text_length);
+
+ [DllImport ("libX11", EntryPoint="XDeleteProperty")]
+ internal extern static int XDeleteProperty (IntPtr display, IntPtr window, int property);
+
+ [DllImport ("gdiplus", EntryPoint="GetFontMetrics")]
+ internal extern static bool GetFontMetrics (IntPtr graphicsObject, IntPtr nativeObject, out int ascent, out int descent);
+
+ // Drawing
+ [DllImport ("libX11", EntryPoint="XCreateGC")]
+ internal extern static IntPtr XCreateGC (IntPtr display, IntPtr window, GCFunction valuemask, ref XGCValues values);
+
+ [DllImport ("libX11", EntryPoint="XFreeGC")]
+ internal extern static int XFreeGC (IntPtr display, IntPtr gc);
+
+ [DllImport ("libX11", EntryPoint="XSetFunction")]
+ internal extern static int XSetFunction (IntPtr display, IntPtr gc, GXFunction function);
+
+ [DllImport ("libX11", EntryPoint="XDrawLine")]
+ internal extern static int XDrawLine (IntPtr display, IntPtr drawable, IntPtr gc, int x1, int y1, int x2, int y2);
+
+ [DllImport ("libX11", EntryPoint="XDrawRectangle")]
+ internal extern static int XDrawRectangle (IntPtr display, IntPtr drawable, IntPtr gc, int x1, int y1, int width, int height);
+
+ [DllImport ("libX11", EntryPoint="XSetWindowBackground")]
+ internal extern static int XSetWindowBackground (IntPtr display, IntPtr window, IntPtr background);
+
+ [DllImport ("libX11", EntryPoint="XCopyArea")]
+ internal extern static int XCopyArea (IntPtr display, IntPtr src, IntPtr dest, IntPtr gc, int src_x, int src_y, int width, int height, int dest_x, int dest_y);
+
+ [DllImport ("libX11", EntryPoint="XGetAtomName")]
+ internal extern static string XGetAtomName (IntPtr display, int atom);
+
+ [DllImport ("libX11", EntryPoint="XGetWindowProperty")]
+ internal extern static int XGetWindowProperty (IntPtr display, IntPtr window, int atom, int long_offset, int long_length, bool delete, Atom req_type, out Atom actual_type, out int actual_format, out int nitems, out int bytes_after, ref IntPtr prop);
+
+ [DllImport ("libX11", EntryPoint="XSetInputFocus")]
+ internal extern static int XSetInputFocus (IntPtr display, IntPtr window, RevertTo revert_to, IntPtr time);
+
+ [DllImport ("libX11", EntryPoint="XIconifyWindow")]
+ internal extern static int XIconifyWindow (IntPtr display, IntPtr window, int screen_number);
+
+ [DllImport ("libX11", EntryPoint="XDefineCursor")]
+ internal extern static int XDefineCursor (IntPtr display, IntPtr window, IntPtr cursor);
+
+ [DllImport ("libX11", EntryPoint="XUndefineCursor")]
+ internal extern static int XUndefineCursor (IntPtr display, IntPtr window);
+
+ [DllImport ("libX11", EntryPoint="XFreeCursor")]
+ internal extern static int XFreeCursor (IntPtr display, IntPtr cursor);
+
+ [DllImport ("libX11", EntryPoint="XCreateFontCursor")]
+ internal extern static IntPtr XCreateFontCursor (IntPtr display, CursorFontShape shape);
+
+ [DllImport ("libX11", EntryPoint="XCreatePixmapCursor")]
+ internal extern static IntPtr XCreatePixmapCursor (IntPtr display, IntPtr source, IntPtr mask, ref XColor foreground_color, ref XColor background_color, int x_hot, int y_hot);
+
+ [DllImport ("libX11", EntryPoint="XCreatePixmapFromBitmapData")]
+ internal extern static IntPtr XCreatePixmapFromBitmapData (IntPtr display, IntPtr drawable, byte[] data, int width, int height, IntPtr fg, IntPtr bg, int depth);
+
+ [DllImport ("libX11", EntryPoint="XFreePixmap")]
+ internal extern static IntPtr XFreePixmap (IntPtr display, IntPtr pixmap);
+
+ [DllImport ("libX11", EntryPoint="XWhitePixel")]
+ internal extern static IntPtr XWhitePixel (IntPtr display, int screen_no);
+
+ [DllImport ("libX11", EntryPoint="XBlackPixel")]
+ internal extern static IntPtr XBlackPixel (IntPtr display, int screen_no);
+
+ [DllImport ("libX11", EntryPoint="XGrabServer")]
+ internal extern static void XGrabServer (IntPtr display);
+
+ [DllImport ("libX11", EntryPoint="XUngrabServer")]
+ internal extern static void XUngrabServer (IntPtr display);
+
+ [DllImport ("libX11", EntryPoint="XSetWMNormalHints")]
+ internal extern static void XSetWMNormalHints (IntPtr display, IntPtr window, ref XSizeHints hints);
+
+ [DllImport ("libX11", EntryPoint="XSetZoomHints")]
+ internal extern static void XSetZoomHints (IntPtr display, IntPtr window, ref XSizeHints hints);
+
+ [DllImport ("libX11", EntryPoint="XSetWMHints")]
+ internal extern static void XSetWMHints (IntPtr display, IntPtr window, ref XWMHints wmhints);
+
+ [DllImport ("libX11", EntryPoint="XSync")]
+ internal extern static void XSync (IntPtr display, IntPtr window);
+
+ [DllImport ("libX11", EntryPoint="XGetIconSizes")]
+ internal extern static int XGetIconSizes (IntPtr display, IntPtr window, out IntPtr size_list, out int count);
+
+ [DllImport ("libX11", EntryPoint="XSetErrorHandler")]
+ internal extern static IntPtr XSetErrorHandler (XErrorHandler error_handler);
+
+ [DllImport ("libX11", EntryPoint="XGetErrorText")]
+ internal extern static IntPtr XGetErrorText (IntPtr display, byte code, StringBuilder buffer, int length);
+
+ [DllImport ("libX11", EntryPoint="XInitThreads")]
+ internal extern static int XInitThreads ();
+
+ [DllImport ("libX11", EntryPoint="XConvertSelection")]
+ internal extern static int XConvertSelection (IntPtr display, int selection, int target, int property, IntPtr requestor, IntPtr time);
+
+ [DllImport ("libX11", EntryPoint="XGetSelectionOwner")]
+ internal extern static IntPtr XGetSelectionOwner (IntPtr display, int selection);
+
+ [DllImport ("libX11", EntryPoint="XSetSelectionOwner")]
+ internal extern static int XSetSelectionOwner (IntPtr display, int selection, IntPtr owner, IntPtr time);
+
+ [DllImport ("libX11", EntryPoint="XSetPlaneMask")]
+ internal extern static int XSetPlaneMask (IntPtr display, IntPtr gc, uint mask);
+
+ [DllImport ("libX11", EntryPoint="XSetForeground")]
+ internal extern static int XSetForeground (IntPtr display, IntPtr gc, uint foreground);
+
+ [DllImport ("libX11", EntryPoint="XSetBackground")]
+ internal extern static int XSetBackground (IntPtr display, IntPtr gc, uint background);
+
+ #endregion
+
+ #region gdk imports
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern bool gdk_init_check (out int argc, string argv);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ internal static extern IntPtr gdk_x11_display_get_xdisplay (IntPtr display);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ internal static extern IntPtr gdk_display_get_default ();
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern IntPtr gdk_pixmap_new (IntPtr drawable, int width, int height, int depth);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern IntPtr gdk_x11_drawable_get_xid (IntPtr gdkdrawable);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern void gdk_draw_drawable (IntPtr drawable_dest, IntPtr gdk_gc, IntPtr drawable_src, int xsrc, int ysrc, int xdest, int ydest, int width, int height);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern IntPtr gdk_gc_new (IntPtr drawable);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern IntPtr gdk_window_foreign_new (IntPtr anid);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern IntPtr gdk_x11_lookup_xdisplay (IntPtr xdisplay);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern void gdk_display_close (IntPtr display);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern void gdk_display_beep (IntPtr display);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern void gdk_display_sync (IntPtr display);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern IntPtr gdk_get_default_root_window ();
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern IntPtr gdk_colormap_get_system ();
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern IntPtr gdk_x11_colormap_get_xcolormap (IntPtr gdk_colormap);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern void gdk_window_destroy (IntPtr gdk_window);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern void gdk_x11_grab_server ();
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern void gdk_x11_ungrab_server ();
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern void gdk_display_flush (IntPtr gdk_display);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern void gdk_window_iconify (IntPtr gdk_window);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern void gdk_window_deiconify (IntPtr gdk_window);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern void gdk_window_set_decorations (IntPtr gdk_window, int decorations);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern IntPtr gdk_screen_get_default ();
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern int gdk_screen_get_number (IntPtr gdk_screen);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern IntPtr gdk_window_lookup (IntPtr anid);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern IntPtr gdk_window_new (IntPtr gdk_parent, ref GdkWindowAttr gdk_window_attributes, int attributes_mask);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern void gdk_window_set_events (IntPtr gdk_window, int event_mask);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern void gdk_window_show (IntPtr window);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern void gdk_window_set_title (IntPtr gdk_window, string title);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern int gdk_window_get_origin (IntPtr gdk_window, out int x, out int y);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern void gdk_window_get_geometry (IntPtr gdk_window, out int x, out int y, out int width, out int height, out int depth);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern void gdk_property_change (IntPtr gdk_window, /*GdkAtom*/IntPtr property, /*GdkAtom*/IntPtr type, int format, int gdk_prop_mode, /*const guchar **/ IntPtr data, int nelements);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern IntPtr gdk_window_get_parent (IntPtr gdk_window);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern void gdk_display_get_maximal_cursor_size (IntPtr gdk_display, out uint width, out uint height);
+
+ [DllImport("libgdk-x11-2.0.so")]
+ static extern int gdk_visual_get_best_depth ();
+ #endregion
+
+ #region gobject imports
+ [DllImport("libglib-2.0.so")]
+ static extern void g_free (IntPtr mem);
+
+ [DllImport("libgobject-2.0.so")]
+ static extern void g_object_unref (IntPtr nativeObject);
+ #endregion
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources b/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources
new file mode 100644
index 00000000000..fc8e8de8562
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources
@@ -0,0 +1,52 @@
+System.Windows.Forms/ButtonTest.cs
+System.Windows.Forms/CheckBoxEventTest.cs
+System.Windows.Forms/CheckBoxTest.cs
+System.Windows.Forms/CheckedListBoxEventTest.cs
+System.Windows.Forms/CheckedListBoxTest.cs
+System.Windows.Forms/ComboBoxTest.cs
+System.Windows.Forms/ComboBoxTests.cs
+System.Windows.Forms/Common.cs
+System.Windows.Forms/ControlEventTest.cs
+System.Windows.Forms/ControlTest.cs
+System.Windows.Forms/ControlPaintTest.cs
+System.Windows.Forms/ControlStyleTest.cs
+System.Windows.Forms/CursorTest.cs
+System.Windows.Forms/DataGridTableStyleTest.cs
+System.Windows.Forms/DataGridTest.cs
+System.Windows.Forms/DataGridTextBoxColumnTest.cs
+System.Windows.Forms/DataGridViewAdvancedBorderStyleTest.cs
+System.Windows.Forms/DataGridViewBandTest.cs
+System.Windows.Forms/DataGridViewCellStyleTest.cs
+System.Windows.Forms/DataGridViewCellTest.cs
+System.Windows.Forms/DataGridViewElementTest.cs
+System.Windows.Forms/DataGridViewRowTest.cs
+System.Windows.Forms/DataGridViewTest.cs
+System.Windows.Forms/GridColumnStylesCollectionTest.cs
+System.Windows.Forms/GridTableStylesCollectionTest.cs
+System.Windows.Forms/GroupBoxTest.cs
+System.Windows.Forms/ImageListTest.cs
+System.Windows.Forms/LabelPropertyTest.cs
+System.Windows.Forms/LabelTest.cs
+System.Windows.Forms/ListBoxEventTest.cs
+System.Windows.Forms/ListBoxTest.cs
+System.Windows.Forms/ListViewCollectionsTest.cs
+System.Windows.Forms/ListViewEventTest.cs
+System.Windows.Forms/ListViewTest.cs
+System.Windows.Forms/ListViewItemTest.cs
+System.Windows.Forms/MenuTest.cs
+System.Windows.Forms/MenuItemTest.cs
+System.Windows.Forms/MonthCalendarTest.cs
+System.Windows.Forms/PictureBoxTest.cs
+System.Windows.Forms/ProgressBarTest.cs
+System.Windows.Forms/RadioButtonTest.cs
+System.Windows.Forms/RichTextBoxTest.cs
+System.Windows.Forms/ScrollBarTest.cs
+System.Windows.Forms/StatusBarTest.cs
+System.Windows.Forms/TestImageIndexConverter.cs
+System.Windows.Forms/ToolBarTest.cs
+System.Windows.Forms/ToolTipTest.cs
+System.Windows.Forms/TreeNodeTest.cs
+System.Windows.Forms/TreeViewTest.cs
+System.Resources/CompatTest.cs
+System.Resources/CultureTest.cs
+System.Resources/WriterTest.cs
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ChangeLog b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ChangeLog
new file mode 100644
index 00000000000..09ac87ed97c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ChangeLog
@@ -0,0 +1,12 @@
+2006-01-14 Robert Jordan <robertj@gmx.net>
+
+ * compat_2_0.resx: Added a CDATA element as a test for bug #77253.
+
+2005-12-01 Robert Jordan <robertj@gmx.net>
+
+ * CompatTest.cs, compat*.resx: Compatibility unit tests.
+ * WriterTest.cs: Unit tests for ResXResourceWriter.
+
+2005-11-30 Robert Jordan <robertj@gmx.net>
+
+ * CultureTest.cs: Unit tests for the culture-invariance.
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/CompatTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/CompatTest.cs
new file mode 100644
index 00000000000..453d5ba6774
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/CompatTest.cs
@@ -0,0 +1,51 @@
+//
+// CompatTest.cs: Compatibility unit tests for ResXResourceReader.
+//
+// Authors:
+// Robert Jordan <robertj@gmx.net>
+//
+
+using System;
+using System.Collections;
+using System.Drawing;
+using System.IO;
+using System.Resources;
+using NUnit.Framework;
+
+namespace MonoTests.System.Resources
+{
+ [TestFixture]
+ public class CompatTest
+ {
+ class Helper
+ {
+ public static void TestReader (string fileName)
+ {
+ ResXResourceReader r = new ResXResourceReader (fileName);
+ Hashtable h = new Hashtable();
+ foreach (DictionaryEntry e in r) {
+ h.Add (e.Key, e.Value);
+ }
+ r.Close ();
+
+ Assert.AreEqual ("hola", (string) h["String"], fileName + "#1");
+ Assert.AreEqual ("hello", (string) h["String2"], fileName + "#2");
+ Assert.AreEqual (42, (int) h["Int"], fileName + "#3");
+ Assert.AreEqual (PlatformID.Win32NT, (PlatformID) h["Enum"], fileName + "#4");
+ Assert.AreEqual (43, ((Point) h["Convertible"]).X, fileName + "#5");
+ Assert.AreEqual (2, (byte) ((ArrayList) h["Serializable"])[1], fileName + "#6");
+ Assert.AreEqual (13, ((byte[]) h["ByteArray"])[1], fileName + "#7");
+ Assert.AreEqual (16, ((byte[]) h["ByteArray2"])[1], fileName + "#8");
+ Assert.AreEqual (1013, ((int[]) h["IntArray"])[1], fileName + "#9");
+ Assert.AreEqual ("world", ((string[]) h["StringArray"])[1], fileName + "#10");
+ }
+ }
+
+ [Test]
+ public void TestReader ()
+ {
+ Helper.TestReader ("Test/System.Resources/compat_1_1.resx");
+ Helper.TestReader ("Test/System.Resources/compat_2_0.resx");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/CultureTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/CultureTest.cs
new file mode 100644
index 00000000000..1c9e65114ce
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/CultureTest.cs
@@ -0,0 +1,59 @@
+//
+// CultureTest.cs: Test cases for culture-invariant string convertions
+//
+// Authors:
+// Robert Jordan <robertj@gmx.net>
+//
+
+using System;
+using System.Collections;
+using System.Globalization;
+using System.Drawing;
+using System.IO;
+using System.Resources;
+using System.Threading;
+using NUnit.Framework;
+
+namespace MonoTests.System.Resources
+{
+ [TestFixture]
+ public class CultureTest
+ {
+ string fileName = Path.GetTempFileName ();
+
+ [Test]
+ public void TestWriter ()
+ {
+ Thread.CurrentThread.CurrentCulture =
+ Thread.CurrentThread.CurrentUICulture = new CultureInfo ("de-DE");
+
+ ResXResourceWriter w = new ResXResourceWriter (fileName);
+ w.AddResource ("point", new Point (42, 43));
+ w.Generate ();
+ w.Close ();
+ }
+
+ [Test]
+ public void TestReader ()
+ {
+ Thread.CurrentThread.CurrentCulture =
+ Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
+
+ int count = 0;
+ ResXResourceReader r = new ResXResourceReader (fileName);
+ IDictionaryEnumerator e = r.GetEnumerator ();
+ while (e.MoveNext ()) {
+ if ((string)e.Key == "point") {
+ Assert.AreEqual (typeof (Point), e.Value.GetType (), "#1");
+ Point p = (Point) e.Value;
+ Assert.AreEqual (42, p.X, "#2");
+ Assert.AreEqual (43, p.Y, "#3");
+ count++;
+ }
+ }
+ r.Close ();
+ File.Delete (fileName);
+ Assert.AreEqual (1, count, "#100");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/WriterTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/WriterTest.cs
new file mode 100644
index 00000000000..a5f20d556b5
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/WriterTest.cs
@@ -0,0 +1,60 @@
+//
+// WriterTest.cs: Unit Tests for ResXResourceWriter.
+//
+// Authors:
+// Robert Jordan <robertj@gmx.net>
+//
+
+using System;
+using System.Collections;
+using System.Drawing;
+using System.IO;
+using System.Resources;
+using NUnit.Framework;
+
+namespace MonoTests.System.Resources
+{
+ [TestFixture]
+ public class WriterTest
+ {
+ string fileName = Path.GetTempFileName ();
+
+ [Test]
+ public void TestWriter ()
+ {
+ ResXResourceWriter w = new ResXResourceWriter (fileName);
+ w.AddResource ("String", "hola");
+ w.AddResource ("String2", (object) "hello");
+ w.AddResource ("Int", 42);
+ w.AddResource ("Enum", PlatformID.Win32NT);
+ w.AddResource ("Convertible", new Point (43, 45));
+ w.AddResource ("Serializable", new ArrayList(new byte[] {1, 2, 3, 4}));
+ w.AddResource ("ByteArray", new byte[] {12, 13, 14});
+ w.AddResource ("ByteArray2", (object) new byte[] {15, 16, 17});
+ w.AddResource ("IntArray", new int[] {1012, 1013, 1014});
+ w.AddResource ("StringArray", new string[] {"hello", "world"});
+ w.Generate ();
+ w.Close ();
+
+ ResXResourceReader r = new ResXResourceReader (fileName);
+ Hashtable h = new Hashtable();
+ foreach (DictionaryEntry e in r) {
+ h.Add (e.Key, e.Value);
+ }
+ r.Close ();
+
+ Assert.AreEqual ("hola", (string) h["String"], "#1");
+ Assert.AreEqual ("hello", (string) h["String2"], "#2");
+ Assert.AreEqual (42, (int) h["Int"], "#3");
+ Assert.AreEqual (PlatformID.Win32NT, (PlatformID) h["Enum"], "#4");
+ Assert.AreEqual (43, ((Point) h["Convertible"]).X, "#5");
+ Assert.AreEqual (2, (byte) ((ArrayList) h["Serializable"])[1], "#6");
+ Assert.AreEqual (13, ((byte[]) h["ByteArray"])[1], "#7");
+ Assert.AreEqual (16, ((byte[]) h["ByteArray2"])[1], "#8");
+ Assert.AreEqual (1013, ((int[]) h["IntArray"])[1], "#9");
+ Assert.AreEqual ("world", ((string[]) h["StringArray"])[1], "#10");
+
+ File.Delete (fileName);
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/compat_1_1.resx b/mcs/class/Managed.Windows.Forms/Test/System.Resources/compat_1_1.resx
new file mode 100644
index 00000000000..bbf08ef6e1a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/compat_1_1.resx
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 1.3 (NET_1_1)
+
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>1.3</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="String">
+ <value>hola</value>
+ </data>
+ <data name="String2">
+ <value>hello</value>
+ </data>
+ <data name="Int" type="System.Int32, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>42</value>
+ </data>
+ <data name="Enum" type="System.PlatformID, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>Win32NT</value>
+ </data>
+ <data name="Convertible" type="System.Drawing.Point, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>43, 45</value>
+ </data>
+ <data name="Serializable" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>
+ AAEAAAD/////AQAAAAAAAAAEAQAAABxTeXN0ZW0uQ29sbGVjdGlvbnMuQXJyYXlMaXN0AwAAAAZfaXRl
+ bXMFX3NpemUIX3ZlcnNpb24FAAAICAkCAAAABAAAAAEAAAAQAgAAAAQAAAAIAgEIAgIIAgMIAgQL
+</value>
+ </data>
+ <data name="ByteArray" type="System.Byte[], mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>DA0O</value>
+ </data>
+ <data name="ByteArray2" type="System.Byte[], mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>DxAR</value>
+ </data>
+ <data name="IntArray" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>AAEAAAD/////AQAAAAAAAAAPAQAAAAMAAAAI9AMAAPUDAAD2AwAACw==</value>
+ </data>
+ <data name="StringArray" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>AAEAAAD/////AQAAAAAAAAARAQAAAAIAAAAGAgAAAAVoZWxsbwYDAAAABXdvcmxkCw==</value>
+ </data>
+</root>
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/compat_2_0.resx b/mcs/class/Managed.Windows.Forms/Test/System.Resources/compat_2_0.resx
new file mode 100644
index 00000000000..e24b5cf03f7
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/compat_2_0.resx
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0 (NET_2_0)
+
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="String" xml:space="preserve">
+ <value>hola</value>
+ </data>
+ <data name="String2" xml:space="preserve"><![CDATA[hello]]></data>
+ <assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <data name="Int" type="System.Int32, mscorlib">
+ <value>42</value>
+ </data>
+ <data name="Enum" type="System.PlatformID, mscorlib">
+ <value>Win32NT</value>
+ </data>
+ <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ <data name="Convertible" type="System.Drawing.Point, System.Drawing">
+ <value>43, 45</value>
+ </data>
+ <data name="Serializable" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>
+ AAEAAAD/////AQAAAAAAAAAEAQAAABxTeXN0ZW0uQ29sbGVjdGlvbnMuQXJyYXlMaXN0AwAAAAZfaXRl
+ bXMFX3NpemUIX3ZlcnNpb24FAAAICAkCAAAABAAAAAEAAAAQAgAAAAQAAAAIAgEIAgIIAgMIAgQL
+</value>
+ </data>
+ <data name="ByteArray" type="System.Byte[], mscorlib">
+ <value>DA0O</value>
+ </data>
+ <data name="ByteArray2" type="System.Byte[], mscorlib">
+ <value>DxAR</value>
+ </data>
+ <data name="IntArray" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>AAEAAAD/////AQAAAAAAAAAPAQAAAAMAAAAI9AMAAPUDAAD2AwAACw==</value>
+ </data>
+ <data name="StringArray" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>AAEAAAD/////AQAAAAAAAAARAQAAAAIAAAAGAgAAAAVoZWxsbwYDAAAABXdvcmxkCw==</value>
+ </data>
+</root>
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ButtonTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ButtonTest.cs
new file mode 100644
index 00000000000..f792e8de509
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ButtonTest.cs
@@ -0,0 +1,104 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class ButtonTest
+ {
+ [Test]
+ public void FlatStyleTest ()
+ {
+ Button B1 = new Button ();
+ Assert.AreEqual (FlatStyle.Standard, B1.FlatStyle, "#1");
+ }
+
+ [Test]
+ public void ImageTest ()
+ {
+ Button B1 = new Button ();
+ B1.Visible = true;
+ B1.Image = Image.FromFile ("M.gif");
+ Assert.AreEqual (ContentAlignment.MiddleCenter, B1.ImageAlign, "#2");
+ }
+
+ [Test]
+ public void ImageListTest ()
+ {
+ Button B1 = new Button ();
+ B1.Image = Image.FromFile ("M.gif");
+ Assert.AreEqual (null, B1.ImageList, "#3a");
+ ImageList ImageList1 = new ImageList ();
+ ImageList1.Images.Add(Image.FromFile ("M.gif"));
+ B1.ImageList = ImageList1;
+ Assert.AreEqual (-1, B1.ImageIndex, "#3b");
+ B1.ImageIndex = 0;
+ Assert.AreEqual (1, B1.ImageList.Images.Count, "#3c");
+ Assert.AreEqual (16, B1.ImageList.ImageSize.Height, "#3d");
+ Assert.AreEqual (16, B1.ImageList.ImageSize.Width, "#3e");
+ }
+
+ [Test]
+ public void IMeModeTest ()
+ {
+ Button B1 = new Button ();
+ Assert.AreEqual (ImeMode.Disable, B1.ImeMode, "#4");
+ }
+
+ [Test]
+ public void TextAlignTest ()
+ {
+ Button B1 = new Button ();
+ Assert.AreEqual (ContentAlignment.MiddleCenter, B1.TextAlign, "#5");
+ }
+
+ [Test]
+ public void DialogResultTest ()
+ {
+ Form f = new Form ();
+ Button B1 = new Button ();
+ B1.Text = "DialogResult";
+ B1.DialogResult = DialogResult.No;
+ B1.TextAlign = ContentAlignment.BottomRight;
+ B1.Visible = true;
+ f.Controls.Add (B1);
+ Assert.AreEqual (DialogResult.No, B1.DialogResult, "#6");
+ }
+
+ [Test]
+ public void PerformClickTest ()
+ {
+ Form f = new Form ();
+ Button B1 = new Button ();
+ B1.Text = "DialogResult";
+ B1.Visible = true;
+ f.Controls.Add (B1);
+ B1.PerformClick ();
+ Assert.AreEqual (DialogResult.None, B1.DialogResult, "#7");
+ }
+
+ [Test]
+ public void NotifyDefaultTest ()
+ {
+ Button B1 = new Button ();
+ Assert.AreEqual ("System.Windows.Forms.Button, Text: ", B1.ToString (), "#8");
+ }
+
+ [Test]
+ public void ToStringTest ()
+ {
+ Button B1 = new Button ();
+ Assert.AreEqual ("System.Windows.Forms.Button, Text: " , B1.ToString (), "#9");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
new file mode 100644
index 00000000000..969fdfb5bbf
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
@@ -0,0 +1,262 @@
+2006-02-28 Matt Hargett (matt@use.net)
+
+ * ComboBoxTests.cs: Added
+
+2006-02-02 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ControlTest.cs: Added test for layout nesting
+ * MonthCalendarTest.cs: Fixed typo in class name
+
+2005-12-01 Jackson Harper <jackson@ximian.com>
+
+ * TreeNodeTest.cs: TreeNodeTest.cs : Added namespace +
+ SingleNodeIndexTest.
+ - Fixed warning CS0219. Patches by Dieter Bremes
+
+2005-11-12 Pedro Martínez Juliá <pedromj@gmail.com>
+
+ * DataGridViewElementTest.cs DataGridViewBandTest.cs
+ DataGridViewCellTest.cs DataGridViewAdvancedBorderStyleTest.cs
+ DataGridViewCellStyleTest.cs DataGridViewRowTest.cs DataGridViewTest.cs:
+
+ Add some DataGridView tests.
+
+2005-11-11 Ankit Jain <jankit@novell.com>
+
+ * RichTextBoxTest.cs: Fix typos.
+
+2005-11-09 Peter Dennis Bartok <pbartok@novell.com>
+
+ * RichTextBoxTest.cs: Added Find() tests
+
+2005-11-05 Kornél Pál <kornelpal@hotmail.com>
+
+ * LabelPropertyTest.cs: Updated product version to 1.1.4322.2032 (1.1 SP1).
+
+2005-10-18 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListViewCollectionsTest.cs: Add tests for the ListView Collections
+
+2005-10-17 Ritvik Mayank <mritvik@novell.com>
+
+ * TabControlTest.cs : Added test case for TabControl
+
+2005-10-16 Ritvik Mayank <mritvik@novell.com>
+
+ * TrackBarTest.cs : Added test case for TrackBar
+
+2005-10-16 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridBoolColumn.cs: fixes warning
+
+2005-10-10 Peter Dennis Bartok <pbartok@novell.com>
+
+ * GenerateControlStyleTest.cs, ControlStyleTest.cs: Flipped
+ order for want and actual to avoid misleading errors
+
+2005-10-07 Peter Dennis Bartok <pbartok@novell.com>
+
+ * GenerateControlStyleTest.cs: Code to auto-generate the
+ source file ControlStyleTest.cs
+ * ControlStyleTest.cs: Tests for testing ControlStyles
+
+2005-09-28 Hisham Mardam Bey <hisham.mardambey@gmail.com>
+
+ * Common.cs : Add common things here.
+ * LabelTest.cs : Remove common declarations to Common.cs
+ * ScrollBarTest.cs : Remove common declarations to Common.cs
+ Add more propery range / exception tests
+ Add more event order tests
+ Fix Mouse tests.
+ Add event arg tests.
+
+2005-09-27 Hisham Mardam Bey <hisham.mardambey@gmail.com>
+
+ * LabelTest.cs : Added more event tests (external handlers)
+ Added event arg checks
+ Fixed OnPaint tests.
+ Seperated invalidation tests.
+
+2005-09-26 Hisham Mardam Bey <hisham.mardambey@gmail.com>
+
+ * ScrollBarTest.cs : Add more tests for event firing order
+ Messages to simulate mouse events
+
+2005-09-23 Ritvik Mayank <mritvik@novell.com>
+
+ * ErrorProviderTest.cs : Added test case for ErrorProvider
+
+2005-09-23 Hisham Mardam Bey <hisham.mardambey@gmail.com>
+
+ * LabelTest.cs : Added messages to simulate Key* events.
+ Key* events have tests now.
+
+2005-09-22 Hisham Mardam Bey <hisham.mardambey@gmail.com>
+
+ * LabelTest.cs : Implement event firing order tests.
+ * ScrollBarTest.cs : Implement event firing order tests.
+
+2005-09-22 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * MenuTest.cs: Fixes some tests
+ * MenuItemTest.cs: New unit test
+
+2005-09-21 Hisham Mardam Bey <hisham.mardambey@gmail.com>
+
+ * LabelTest.cs : Several new tests.
+ * ScrollBarTest.cs : Several new tests.
+ * bitmaps : added dir containing images for tests.
+
+2005-09-21 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListViewItemTest.cs: New unit test
+
+2005-09-20 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ButtonTest.cs, LabelTest.cs, ControlEventTest.cs, ScrollBarTest.cs,
+ LabelPropertyTest.cs, ProgressBarTest.cs, StatusBarTest.cs,
+ ImageListTest.cs, MonthCalendarTest.cs, ControlTest.cs,
+ ListBoxEventTest.cs, TreeViewTest.cs, TestImageIndexConverter.cs,
+ ToolBarTest.cs, MenuTest.cs
+
+ Remove all the tests that are giving errors. All of them should
+ be reviewed. Right now having this text throwing 40 errors do not
+ help at all to do regression testing. Peter has already assigned
+ a group of controls to every developer that will be tested and
+ reviewed.
+
+2005-09-20 Ritvik Mayank <mritvik@novell.com>
+
+ * PictureBoxTest.cs : Test case for PictureBox
+
+2005-09-08 Ritvik Mayank <mritvik@novell.com>
+
+ * MonthCalendarTest.cs : Test case for MonthCalendar
+
+2005-08-29 Ritvik Mayank <mritvik@novell.com>
+
+ * ProgressBarTest.cs : Test case for ProgressBar
+ * ToolBarTest.cs : Test case for ToolBar
+ * ToolTipTest.cs : Test case for ToolTip
+ * RichTextBoxTest.cs : Test case for RichTextBox
+
+2005-08-16 Martin Baulig <martin@ximian.com>
+
+ * ControlTest.cs: Renamed namespace `MWF.Test' -> `MWF.MonoTest'
+ to make it compile.
+
+2005-08-16 Ritvik Mayank <mritvik@novell.com>
+
+ * ScrollBarTest.cs, ImageListTest.cs, CheckedListBoxTest.cs, CheckedListBoxEventTest.cs, MenuTest.cs,
+ ListViewTest.cs: enhancement and cleanup
+
+2005-08-16 Ritvik Mayank <mritvik@novell.com>
+
+ * ImageListTest.cs : Test case for ImageList
+ * RadioButtonTest.cs : Test case for RadioButton
+ * ScrollBarTest.cs : Test case for ScrollBar
+ * StatusBatTest.cs : Test case for StatusBar
+
+2005-08-10 Ritvik Mayank <mritvik@novell.com>
+
+ * ControlTest.cs : Commented out test for GetChildAtPointSkip (feature not
+ yet implemented)
+
+2005-08-08 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBoxTest.cs: new tests for properties, exceptions, and colletions
+ * ListBoxTest.cs: new tests for properties, exceptions, and colletionss
+
+2005-08-06 Ritvik Mayank <mritvik@novell.com>
+
+ * ComboBoxTest.cs, ListBoxTest.cs : Cleanup, added few more tests
+
+2005-08-05 Ritvik Mayank <mritvik@novell.com>
+
+ * ButtonTest.cs, ImageListTest.cs, ControlEventTest.cs,
+ LabelPropertyTest.cs, CheckBoxTest.cs, ListBoxEventTest.cs,
+ CheckBoxEventTest.cs, CheckedListBoxTest.cs, TextBoxTest.cs,
+ CheckedListBoxEventTest.cs, FormTest.cs, MenuTest.cs,
+ FormEventTest.cs, GroupBoxTest.cs, ListViewTest.cs,
+ ListViewEventTest.cs :
+ Cleanup, Ignored tests which need manual intervention,
+ work still in progress.
+
+2005-08-05 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumnTest.cs: test fixes and enhancements
+ * GridTableStylesCollectionTest.cs: test fixes and enhancements
+ * DataGridTest.cs: test fixes and enhancements
+ * DataGridCellTest.cs: New unit test
+ * GridColumnStylesCollectionTest.cs: test fixes and enhancements
+ * DataGridTableStyleTest.cs: test fixes and enhancements
+
+2005-08-04 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ControlTest.cs: Cleanup, fixed commented out tests with syntax
+ errors, streamlined a few tests, added full tab order test, still
+ work in progress
+
+2005-08-02 Ritvik Mayank <mritvik@novell.com>
+
+ * FormTest.cs : Test case for Form
+ * GropBoxTest : Test case for GroupBox
+ * MenuTest.cs : Test case for Menu
+ * ImageListTest.cs : Test case for ImageList
+
+2005-07-26 Ritvik Mayank <mritvik@novell.com>
+
+ * ListViewTest.cs : Test case for ListView
+ * ListViewEventTest.cs : Test case for ListView events
+ * ComboBoxTest.cs : Test case for ComboBox
+ * FormEventTest.cs : Test case for Form events
+
+2005-07-12 Ritvik Mayank <mritvik@novell.com>
+
+ * CheckBoxTest.cs : Test case for CheckBox
+ * CheckBoxEventTest.cs : Test case for CheckBox events
+ * CheckedListBoxTest.cs : Test case for CheckedListBox
+ * CheckedListBoxEventTest.cs : Test case for CheckedListBox events
+
+2005-07-05 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumnTest.cs: Test case
+ * GridTableStylesCollectionTest.cs: Test case
+ * DataGridTest.cs: Test case
+ * GridColumnStylesCollectionTest.cs: Test case
+ * DataGridTableStyleTest.cs: Test case
+
+
+2005-07-04 Ritvik Mayank <mritvik@novell.com>
+
+ * ListBoxTest.cs : Test Cases for ListBox Properties and Methods
+ * ListBoxEventTest.cs : Test Cases for ListBox Events
+
+2005-06-13 Ritvik Mayank <mritvik@novell.com>
+
+ * TextBoxTest.cs : Test Cases for TextBox
+ * BUttonTest.cs : Test Cases for Buttons
+
+2005-05-11 Ritvik Mayank <mritvik@novell.com>
+
+ * ControlEventTest.cs : Test Cases for Events
+
+2005-05-02 Ritvik Mayank <mritvik@novell.com>
+
+ * ControlTest.cs : Minor modifications
+
+2005-05-02 Ritvik Mayank <mritvik@novell.com>
+
+ * ControlTest.cs : Test for Control
+
+2005-04-25 Ritvik Mayank <mritvik@novell.com>
+ * LabelPropertyTest.cs : Test for Label
+
+2004-11-29 Marek Safar <marek.safar@seznam.cz>
+ * TreeViewTest.cs : Test for TreeView
+ * TreeNodeTest.cs : Test for TreeNode
+
+2004-11-29 Ravindra <rkumar@novell.com>
+ * ImageIndexConverter.cs : Test for ImageIndexConversion.
+
+
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckBoxEventTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckBoxEventTest.cs
new file mode 100644
index 00000000000..a81d3764894
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckBoxEventTest.cs
@@ -0,0 +1,65 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class CheckBoxEventTest
+ {
+ static bool eventhandled = false;
+ public void CheckBox_EventHandler (object sender,EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void ApperanceEventTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ CheckBox chkbox = new CheckBox ();
+ chkbox.Visible = true;
+ myform.Controls.Add (chkbox);
+ chkbox.AppearanceChanged += new EventHandler (CheckBox_EventHandler);
+ chkbox.Appearance = Appearance.Button;
+ Assert.AreEqual (true, eventhandled, "#A1");
+ }
+
+ [Test]
+ public void CheckedChangedEventTest ()
+ {
+ eventhandled = false;
+ Form myform = new Form ();
+ myform.Visible = true;
+ CheckBox chkbox = new CheckBox ();
+ chkbox.Visible = true;
+ myform.Controls.Add (chkbox);
+ chkbox.CheckedChanged += new EventHandler (CheckBox_EventHandler);
+ chkbox.CheckState = CheckState.Indeterminate;
+ Assert.AreEqual (true, eventhandled, "#A2");
+ }
+
+ [Test]
+ public void CheckStateChangedEventTest ()
+ {
+ eventhandled = false;
+ Form myform = new Form ();
+ myform.Visible = true;
+ CheckBox chkbox = new CheckBox ();
+ chkbox.Visible = true;
+ myform.Controls.Add (chkbox);
+ chkbox.CheckStateChanged += new EventHandler (CheckBox_EventHandler);
+ chkbox.CheckState = CheckState.Checked;
+ Assert.AreEqual (true, eventhandled, "#A3");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckBoxTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckBoxTest.cs
new file mode 100644
index 00000000000..2fd428da8fb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckBoxTest.cs
@@ -0,0 +1,40 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+
+using System;
+using System.Collections;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+using System.Threading;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class CheckBoxTest
+ {
+ [Test]
+ public void CheckBoxPropertyTest ()
+ {
+ Form myform = new Form ();
+ CheckBox mychkbox = new CheckBox();
+ myform.Controls.Add (mychkbox);
+ Assert.AreEqual (Appearance.Normal, mychkbox.Appearance, "#1");
+ mychkbox.Appearance = Appearance.Button;
+ Assert.AreEqual (Appearance.Button, mychkbox.Appearance, "#2");
+ Assert.AreEqual (true, mychkbox.AutoCheck, "#3");
+ mychkbox.AutoCheck = false;
+ Assert.AreEqual (false, mychkbox.AutoCheck, "#4");
+ Assert.AreEqual (false, mychkbox.Checked, "#5");
+ Assert.AreEqual (CheckState.Unchecked, mychkbox.CheckState, "#6");
+ Assert.AreEqual (ContentAlignment.MiddleLeft, mychkbox.CheckAlign, "#7");
+ Assert.AreEqual (ContentAlignment.MiddleLeft, mychkbox.TextAlign, "#8");
+ Assert.AreEqual (false, mychkbox.ThreeState, "#9");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckedListBoxEventTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckedListBoxEventTest.cs
new file mode 100644
index 00000000000..8bd1fe0b0dc
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckedListBoxEventTest.cs
@@ -0,0 +1,42 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class CheckedListBoxItemCheckEvent
+ {
+ static bool eventhandled = false;
+ public void ItemCheck_EventHandler (object sender,ItemCheckEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void ItemCheckTest ()
+ {
+ Form myform = new Form ();
+ CheckedListBox mychklstbox = new CheckedListBox ();
+ mychklstbox.Items.Add ("test1");
+ mychklstbox.Items.Add ("test2");
+ //Test ItemCheck Event
+ mychklstbox.ItemCheck += new ItemCheckEventHandler (ItemCheck_EventHandler);
+ mychklstbox.Items.Add ("test1",CheckState.Checked);
+ myform.Controls.Add (mychklstbox);
+ myform.Show ();
+ Assert.AreEqual (true, eventhandled, "#A1");
+ eventhandled = false;
+ mychklstbox.SetItemChecked (1,true);
+ Assert.AreEqual (true, eventhandled, "#A2");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckedListBoxTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckedListBoxTest.cs
new file mode 100644
index 00000000000..f88b583d5ef
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckedListBoxTest.cs
@@ -0,0 +1,133 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+
+using System;
+using System.Collections;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class CheckedListBoxTest
+ {
+ [Test]
+ public void CheckedListBoxPropertyTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ CheckedListBox mychklistbox = new CheckedListBox ();
+ ArrayList checked_items = new ArrayList (2);
+ ArrayList checked_pos = new ArrayList (2);
+ mychklistbox.Items.Add ("test1", true);
+ checked_items.Add ("test1"); checked_pos.Add (0);
+ mychklistbox.Items.Add ("test2");
+ mychklistbox.Items.Add ("test3", true);
+ checked_items.Add ("test3"); checked_pos.Add (2);
+ mychklistbox.Visible = true;
+ myform.Controls.Add (mychklistbox);
+ Assert.AreEqual (checked_items.Count, mychklistbox.CheckedIndices.Count, "#1");
+ Assert.AreEqual (checked_items.Count, mychklistbox.CheckedItems.Count, "#2");
+ foreach (object o in mychklistbox.CheckedItems)
+ {
+ Assert.IsTrue (checked_items.Contains (o),"#3");
+ checked_items.Remove (o);
+ }
+
+ Assert.AreEqual (0, checked_items.Count);
+ for (int i = 0; i < mychklistbox.Items.Count; ++i)
+ {
+ if (checked_pos.Contains (i))
+ Assert.AreEqual (CheckState.Checked, mychklistbox.GetItemCheckState (i),"#4");
+ else
+ Assert.IsFalse (CheckState.Checked == mychklistbox.GetItemCheckState (i),"#5");
+ }
+ Assert.AreEqual (false, mychklistbox.CheckOnClick, "#6");
+ Assert.AreEqual (3, mychklistbox.Items.Count, "#7");
+ Assert.AreEqual (SelectionMode.One, mychklistbox.SelectionMode, "#8");
+ Assert.AreEqual (false , mychklistbox.ThreeDCheckBoxes, "#9");
+ }
+
+ [Test]
+ public void GetItemCheckedTest ()
+ {
+ Form f = new Form ();
+ f.Visible = true;
+ CheckedListBox mychklistbox = new CheckedListBox ();
+ mychklistbox.Items.Add ("test1",true);
+ mychklistbox.Items.Add ("test2",CheckState.Indeterminate);
+ mychklistbox.Items.Add ("test3");
+ mychklistbox.Visible = true;
+ f.Controls.Add (mychklistbox);
+ Assert.AreEqual (true, mychklistbox.GetItemChecked (0), "#10");
+ Assert.AreEqual (true, mychklistbox.GetItemChecked (1), "#11");
+ Assert.AreEqual (false, mychklistbox.GetItemChecked (2), "#12");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException) )]
+ public void GetItemCheckedExceptionTest ()
+ {
+ CheckedListBox mychklistbox = new CheckedListBox ();
+ mychklistbox.Items.Add ("test1",true);
+ Assert.AreEqual (true, mychklistbox.GetItemChecked (1), "#13");
+ }
+
+ [Test]
+ public void GetItemCheckStateTest ()
+ {
+ Form f = new Form ();
+ f.Visible = true;
+ CheckedListBox mychklistbox = new CheckedListBox ();
+ mychklistbox.Items.Add ("test1",true);
+ mychklistbox.Items.Add ("test2",CheckState.Indeterminate);
+ mychklistbox.Items.Add ("test3");
+ mychklistbox.Visible = true;
+ f.Controls.Add (mychklistbox);
+ Assert.AreEqual (CheckState.Checked, mychklistbox.GetItemCheckState (0), "#14");
+ Assert.AreEqual (CheckState.Indeterminate, mychklistbox.GetItemCheckState (1), "#15");
+ Assert.AreEqual (CheckState.Unchecked, mychklistbox.GetItemCheckState (2), "#16");
+ }
+
+ [Test]
+ public void SetItemCheckedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ CheckedListBox mychklistbox = new CheckedListBox ();
+ mychklistbox.Items.Add ("test1");
+ mychklistbox.Items.Add ("test2");
+ mychklistbox.Visible = true;
+ myform.Controls.Add (mychklistbox);
+ mychklistbox.SetItemChecked (0,true);
+ mychklistbox.SetItemChecked (1,false);
+ Assert.AreEqual (CheckState.Checked, mychklistbox.GetItemCheckState (0), "#17");
+ Assert.AreEqual (CheckState.Unchecked, mychklistbox.GetItemCheckState (1), "#18");
+ }
+
+ [Test]
+ public void SetItemCheckStateTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ CheckedListBox mychklistbox = new CheckedListBox ();
+ mychklistbox.Items.Add ("test1");
+ mychklistbox.Items.Add ("test2");
+ mychklistbox.Items.Add ("test3");
+ mychklistbox.Visible = true;
+ myform.Controls.Add (mychklistbox);
+ mychklistbox.SetItemCheckState (0,CheckState.Checked);
+ mychklistbox.SetItemCheckState (1,CheckState.Indeterminate);
+ mychklistbox.SetItemCheckState (2,CheckState.Unchecked);
+ Assert.AreEqual (CheckState.Checked, mychklistbox.GetItemCheckState (0), "#19");
+ Assert.AreEqual (CheckState.Indeterminate, mychklistbox.GetItemCheckState (1), "#20");
+ Assert.AreEqual (CheckState.Unchecked, mychklistbox.GetItemCheckState (2), "#21");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ComboBoxTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ComboBoxTest.cs
new file mode 100644
index 00000000000..67765f281d6
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ComboBoxTest.cs
@@ -0,0 +1,326 @@
+//
+// ComboBoxTest.cs: Test cases for ComboBox.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Ritvik Mayank <mritvik@novell.com>
+// Jordi Mas i Hernandez <jordi@ximian.com>
+
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+using System.Collections;
+using System.ComponentModel;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class ComboBoxTest
+ {
+ [Test]
+ public void ComboBoxPropertyTest ()
+ {
+ ComboBox mycmbbox = new ComboBox ();
+ Assert.AreEqual (DrawMode.Normal, mycmbbox.DrawMode, "#1");
+ Assert.AreEqual (ComboBoxStyle.DropDown, mycmbbox.DropDownStyle, "#2");
+ Assert.AreEqual (121, mycmbbox.DropDownWidth, "#3");
+ Assert.AreEqual (false, mycmbbox.DroppedDown, "#4");
+ Assert.AreEqual (true, mycmbbox.IntegralHeight, "#5");
+ Assert.AreEqual (0, mycmbbox.Items.Count, "#6");
+ //Assert.AreEqual (15, mycmbbox.ItemHeight, "#7"); // Note: Item height depends on the current font.
+ Assert.AreEqual (8, mycmbbox.MaxDropDownItems, "#8");
+ Assert.AreEqual (0, mycmbbox.MaxLength, "#9");
+ Assert.AreEqual (20, mycmbbox.PreferredHeight, "#10");
+ Assert.AreEqual (-1, mycmbbox.SelectedIndex, "#11");
+ Assert.AreEqual (null, mycmbbox.SelectedItem, "#12");
+ Assert.AreEqual ("", mycmbbox.SelectedText, "#13");
+ Assert.AreEqual (0, mycmbbox.SelectionLength, "#14");
+ Assert.AreEqual (0, mycmbbox.SelectionStart, "#15");
+ Assert.AreEqual (false, mycmbbox.Sorted, "#16");
+ Assert.AreEqual ("", mycmbbox.Text, "#17");
+ }
+
+ [Test]
+ public void BeginEndUpdateTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.Items.Add ("A");
+ cmbbox.Visible = true;
+ myform.Controls.Add (cmbbox);
+ cmbbox.BeginUpdate ();
+ for (int x = 1 ; x < 5000 ; x++) {
+ cmbbox.Items.Add ("Item " + x.ToString ());
+ }
+ cmbbox.EndUpdate ();
+ }
+
+ [Test]
+ public void FindStringTest ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.FindString ("Hola", -5); // No exception, it's empty
+ int x = cmbbox.FindString ("Hello");
+ Assert.AreEqual (-1, x, "#19");
+ cmbbox.Items.AddRange(new object[] {"ACBD", "ABDC", "ACBD", "ABCD"});
+ String myString = "ABC";
+ x = cmbbox.FindString (myString);
+ Assert.AreEqual (3, x, "#191");
+ x = cmbbox.FindString (string.Empty);
+ Assert.AreEqual (0, x, "#192");
+ x = cmbbox.FindString ("NonExistant");
+ Assert.AreEqual (-1, x, "#193");
+ }
+
+ [Test]
+ public void FindStringExactTest ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.FindStringExact ("Hola", -5); // No exception, it's empty
+ int x = cmbbox.FindStringExact ("Hello");
+ Assert.AreEqual (-1, x, "#20");
+ cmbbox.Items.AddRange (new object[] {"ABCD","ABC","ABDC"});
+ String myString = "ABC";
+ x = cmbbox.FindStringExact (myString);
+ Assert.AreEqual (1, x, "#201");
+ x = cmbbox.FindStringExact (string.Empty);
+ Assert.AreEqual (-1, x, "#202");
+ x = cmbbox.FindStringExact ("NonExistant");
+ Assert.AreEqual (-1, x, "#203");
+ }
+
+ [Test]
+ public void GetItemHeightTest ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.Items.Add ("ABC");
+ cmbbox.Items.Add ("BCD");
+ cmbbox.Items.Add ("DEF");
+ int x = -1;
+ x = cmbbox.GetItemHeight (x);
+ Assert.IsTrue (cmbbox.ItemHeight > 0, "#21");
+ }
+
+
+ //
+ // Exceptions
+ //
+
+ [Test]
+ [ExpectedException (typeof (InvalidEnumArgumentException))]
+ public void DropDownStyleException ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.DropDownStyle = (ComboBoxStyle) 10;
+ }
+
+ [Test]
+ [ExpectedException (typeof (InvalidEnumArgumentException))]
+ public void DrawModeException ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.DrawMode = (DrawMode) 10;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void DropDownWidthException ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.DropDownWidth = 0;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ItemHeightException ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.ItemHeight = -1;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void SelectedIndexException ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.SelectedIndex = -2;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void FindStringExactMinException ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.Items.AddRange(new object[] {"ACBD", "ABDC", "ACBD", "ABCD"});
+ cmbbox.FindStringExact ("Hola", -2);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void FindStringExactMaxException ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.Items.AddRange(new object[] {"ACBD", "ABDC", "ACBD", "ABCD"});
+ cmbbox.FindStringExact ("Hola", 3);
+ }
+
+ //
+ // Events
+ //
+ private bool eventFired;
+ private DrawItemEventArgs drawItemsArgs;
+ private void DrawItemEventH (object sender, DrawItemEventArgs e)
+ {
+ eventFired = true;
+ drawItemsArgs = e;
+ }
+
+ private void GenericHandler (object sender, EventArgs e)
+ {
+ eventFired = true;
+ }
+
+ [Ignore ("Bugs in X11 prevent this test to run properly")]
+ public void DrawItemEventTest ()
+ {
+ eventFired = false;
+ drawItemsArgs = null;
+ Form myform = new Form ();
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.DropDownStyle = ComboBoxStyle.Simple;
+ cmbbox.DrawMode = DrawMode.OwnerDrawFixed;
+ cmbbox.DrawItem += new DrawItemEventHandler (DrawItemEventH);
+
+ myform.Controls.Add (cmbbox);
+ cmbbox.Items.AddRange(new object[] {"Item1"});
+
+ myform.Visible = true;
+ cmbbox.Visible = true;
+ cmbbox.Refresh ();
+
+ Assert.AreEqual (true, eventFired, "DW1");
+ Assert.AreEqual (0, drawItemsArgs.Index, "DW2");
+ }
+
+ [Test]
+ public void DropDownStyleEventTest ()
+ {
+ eventFired = false;
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.DropDownStyleChanged += new EventHandler (GenericHandler);
+ cmbbox.DropDownStyle = ComboBoxStyle.Simple;
+
+ Assert.AreEqual (true, eventFired, "DI1");
+ }
+
+ [Test]
+ public void SelectedIndextTest ()
+ {
+ eventFired = false;
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.Items.AddRange(new object[] {"Item1", "Item2"});
+ cmbbox.SelectedIndexChanged += new EventHandler (GenericHandler);
+ cmbbox.SelectedIndex = 1;
+ Assert.AreEqual (true, eventFired, "SI1");
+ }
+
+ }
+
+ [TestFixture]
+ public class ComboBoxObjectCollectionTest
+ {
+ [Test]
+ public void ComboBoxObjectCollectionPropertyTest ()
+ {
+ ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+ Assert.AreEqual (false, col.IsReadOnly, "#B1");
+ Assert.AreEqual (false, ((ICollection)col).IsSynchronized, "#B2");
+ Assert.AreEqual (col, ((ICollection)col).SyncRoot, "#B3");
+ Assert.AreEqual (false, ((IList)col).IsFixedSize, "#B4");
+ }
+
+ [Test]
+ public void AddTest ()
+ {
+ ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+ col.Add ("Item1");
+ col.Add ("Item2");
+ Assert.AreEqual (2, col.Count, "#C1");
+ }
+
+ [Test]
+ public void ClearTest ()
+ {
+ ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+ col.Add ("Item1");
+ col.Add ("Item2");
+ col.Clear ();
+ Assert.AreEqual (0, col.Count, "#D1");
+ }
+
+ [Test]
+ public void ContainsTest ()
+ {
+ ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+ object obj = "Item1";
+ col.Add (obj);
+ Assert.AreEqual (true, col.Contains ("Item1"), "#E1");
+ Assert.AreEqual (false, col.Contains ("Item2"), "#E2");
+ }
+
+ [Test]
+ public void IndexOfTest ()
+ {
+ ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+ col.Add ("Item1");
+ col.Add ("Item2");
+ Assert.AreEqual (1, col.IndexOf ("Item2"), "#F1");
+ }
+
+ [Test]
+ public void RemoveTest ()
+ {
+ ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+ col.Add ("Item1");
+ col.Add ("Item2");
+ col.Remove ("Item1");
+ Assert.AreEqual (1, col.Count, "#G1");
+ }
+
+ [Test]
+ public void RemoveAtTest ()
+ {
+ ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+ col.Add ("Item1");
+ col.Add ("Item2");
+ col.RemoveAt (0);
+ Assert.AreEqual (1, col.Count, "#H1");
+ Assert.AreEqual (true, col.Contains ("Item2"), "#H1");
+ }
+ }
+
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ComboBoxTests.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ComboBoxTests.cs
new file mode 100644
index 00000000000..bf1af3f5568
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ComboBoxTests.cs
@@ -0,0 +1,97 @@
+//
+// ComboBoxTests.cs: Test cases for ComboBox.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2006 Matt Hargett
+//
+// Authors:
+// Matt Hargett <matt@use.net>
+//
+
+
+using System.Windows.Forms;
+using System;
+using NUnit.Framework;
+
+[TestFixture]
+public class ComboBoxTests
+{
+ ComboBox comboBox;
+ bool textChanged, layoutUpdated;
+
+ [SetUp]
+ public void SetUp()
+ {
+ comboBox = new ComboBox();
+ textChanged = false;
+ layoutUpdated = false;
+ comboBox.TextChanged += new EventHandler(textChangedEventHandler);
+ comboBox.Layout += new LayoutEventHandler(layoutEventHandler);
+ }
+
+ private void textChangedEventHandler(object sender, EventArgs e)
+ {
+ textChanged = true;
+ }
+
+ private void layoutEventHandler(object sender, LayoutEventArgs e)
+ {
+ layoutUpdated = true;
+ }
+
+
+ [Test]
+ public void InitialPropertyValues()
+ {
+
+ Assert.AreEqual(String.Empty, comboBox.Text);
+ Assert.AreEqual(-1, comboBox.SelectedIndex);
+ Assert.IsNull(comboBox.SelectedItem);
+ Assert.AreEqual(121, comboBox.Size.Width);
+ Assert.AreEqual(20, comboBox.Size.Height);
+ Assert.IsFalse(textChanged);
+ Assert.IsFalse(layoutUpdated);
+ }
+
+ [Test]
+ public void SetNegativeOneSelectedIndex()
+ {
+ comboBox.SelectedIndex = -1;
+ Assert.AreEqual(String.Empty, comboBox.Text);
+ Assert.IsFalse(textChanged);
+ }
+
+ [Test]
+ public void SetDifferentText()
+ {
+ comboBox.Text = "foooooooooooooooooooooooooo";
+ Assert.IsTrue(textChanged);
+ Assert.IsFalse(layoutUpdated);
+ }
+
+ [Test]
+ public void SetSameText()
+ {
+ comboBox.Text = String.Empty;
+ Assert.IsFalse(textChanged);
+ Assert.IsFalse(layoutUpdated);
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/Common.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/Common.cs
new file mode 100644
index 00000000000..d02e9424b36
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/Common.cs
@@ -0,0 +1,251 @@
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms
+{
+ internal enum WndMsg {
+ WM_NULL = 0x0000,
+ WM_CREATE = 0x0001,
+ WM_DESTROY = 0x0002,
+ WM_MOVE = 0x0003,
+ WM_SIZE = 0x0005,
+ WM_ACTIVATE = 0x0006,
+ WM_SETFOCUS = 0x0007,
+ WM_KILLFOCUS = 0x0008,
+ //public const uint WM_SETVISIBLE = 0x0009;
+ WM_ENABLE = 0x000A,
+ WM_SETREDRAW = 0x000B,
+ WM_SETTEXT = 0x000C,
+ WM_GETTEXT = 0x000D,
+ WM_GETTEXTLENGTH = 0x000E,
+ WM_PAINT = 0x000F,
+ WM_CLOSE = 0x0010,
+ WM_QUERYENDSESSION = 0x0011,
+ WM_QUIT = 0x0012,
+ WM_QUERYOPEN = 0x0013,
+ WM_ERASEBKGND = 0x0014,
+ WM_SYSCOLORCHANGE = 0x0015,
+ WM_ENDSESSION = 0x0016,
+ //public const uint WM_SYSTEMERROR = 0x0017;
+ WM_SHOWWINDOW = 0x0018,
+ WM_CTLCOLOR = 0x0019,
+ WM_WININICHANGE = 0x001A,
+ WM_SETTINGCHANGE = 0x001A,
+ WM_DEVMODECHANGE = 0x001B,
+ WM_ACTIVATEAPP = 0x001C,
+ WM_FONTCHANGE = 0x001D,
+ WM_TIMECHANGE = 0x001E,
+ WM_CANCELMODE = 0x001F,
+ WM_SETCURSOR = 0x0020,
+ WM_MOUSEACTIVATE = 0x0021,
+ WM_CHILDACTIVATE = 0x0022,
+ WM_QUEUESYNC = 0x0023,
+ WM_GETMINMAXINFO = 0x0024,
+ WM_PAINTICON = 0x0026,
+ WM_ICONERASEBKGND = 0x0027,
+ WM_NEXTDLGCTL = 0x0028,
+ //public const uint WM_ALTTABACTIVE = 0x0029;
+ WM_SPOOLERSTATUS = 0x002A,
+ WM_DRAWITEM = 0x002B,
+ WM_MEASUREITEM = 0x002C,
+ WM_DELETEITEM = 0x002D,
+ WM_VKEYTOITEM = 0x002E,
+ WM_CHARTOITEM = 0x002F,
+ WM_SETFONT = 0x0030,
+ WM_GETFONT = 0x0031,
+ WM_SETHOTKEY = 0x0032,
+ WM_GETHOTKEY = 0x0033,
+ //public const uint WM_FILESYSCHANGE = 0x0034;
+ //public const uint WM_ISACTIVEICON = 0x0035;
+ //public const uint WM_QUERYPARKICON = 0x0036;
+ WM_QUERYDRAGICON = 0x0037,
+ WM_COMPAREITEM = 0x0039,
+ //public const uint WM_TESTING = 0x003a;
+ //public const uint WM_OTHERWINDOWCREATED = 0x003c;
+ WM_GETOBJECT = 0x003D,
+ //public const uint WM_ACTIVATESHELLWINDOW = 0x003e;
+ WM_COMPACTING = 0x0041,
+ WM_COMMNOTIFY = 0x0044 ,
+ WM_WINDOWPOSCHANGING = 0x0046,
+ WM_WINDOWPOSCHANGED = 0x0047,
+ WM_POWER = 0x0048,
+ WM_COPYDATA = 0x004A,
+ WM_CANCELJOURNAL = 0x004B,
+ WM_NOTIFY = 0x004E,
+ WM_INPUTLANGCHANGEREQUEST = 0x0050,
+ WM_INPUTLANGCHANGE = 0x0051,
+ WM_TCARD = 0x0052,
+ WM_HELP = 0x0053,
+ WM_USERCHANGED = 0x0054,
+ WM_NOTIFYFORMAT = 0x0055,
+ WM_CONTEXTMENU = 0x007B,
+ WM_STYLECHANGING = 0x007C,
+ WM_STYLECHANGED = 0x007D,
+ WM_DISPLAYCHANGE = 0x007E,
+ WM_GETICON = 0x007F,
+
+ // Non-Client messages
+ WM_SETICON = 0x0080,
+ WM_NCCREATE = 0x0081,
+ WM_NCDESTROY = 0x0082,
+ WM_NCCALCSIZE = 0x0083,
+ WM_NCHITTEST = 0x0084,
+ WM_NCPAINT = 0x0085,
+ WM_NCACTIVATE = 0x0086,
+ WM_GETDLGCODE = 0x0087,
+ WM_SYNCPAINT = 0x0088,
+ //public const uint WM_SYNCTASK = 0x0089;
+ WM_NCMOUSEMOVE = 0x00A0,
+ WM_NCLBUTTONDOWN = 0x00A1,
+ WM_NCLBUTTONUP = 0x00A2,
+ WM_NCLBUTTONDBLCLK = 0x00A3,
+ WM_NCRBUTTONDOWN = 0x00A4,
+ WM_NCRBUTTONUP = 0x00A5,
+ WM_NCRBUTTONDBLCLK = 0x00A6,
+ WM_NCMBUTTONDOWN = 0x00A7,
+ WM_NCMBUTTONUP = 0x00A8,
+ WM_NCMBUTTONDBLCLK = 0x00A9,
+ //public const uint WM_NCXBUTTONDOWN = 0x00ab;
+ //public const uint WM_NCXBUTTONUP = 0x00ac;
+ //public const uint WM_NCXBUTTONDBLCLK = 0x00ad;
+ WM_KEYDOWN = 0x0100,
+ WM_KEYFIRST = 0x0100,
+ WM_KEYUP = 0x0101,
+ WM_CHAR = 0x0102,
+ WM_DEADCHAR = 0x0103,
+ WM_SYSKEYDOWN = 0x0104,
+ WM_SYSKEYUP = 0x0105,
+ WM_SYSCHAR = 0x0106,
+ WM_SYSDEADCHAR = 0x0107,
+ WM_KEYLAST = 0x0108,
+ WM_IME_STARTCOMPOSITION = 0x010D,
+ WM_IME_ENDCOMPOSITION = 0x010E,
+ WM_IME_COMPOSITION = 0x010F,
+ WM_IME_KEYLAST = 0x010F,
+ WM_INITDIALOG = 0x0110,
+ WM_COMMAND = 0x0111,
+ WM_SYSCOMMAND = 0x0112,
+ WM_TIMER = 0x0113,
+ WM_HSCROLL = 0x0114,
+ WM_VSCROLL = 0x0115,
+ WM_INITMENU = 0x0116,
+ WM_INITMENUPOPUP = 0x0117,
+ //public const uint WM_SYSTIMER = 0x0118;
+ WM_MENUSELECT = 0x011F,
+ WM_MENUCHAR = 0x0120,
+ WM_ENTERIDLE = 0x0121,
+ WM_MENURBUTTONUP = 0x0122,
+ WM_MENUDRAG = 0x0123,
+ WM_MENUGETOBJECT = 0x0124,
+ WM_UNINITMENUPOPUP = 0x0125,
+ WM_MENUCOMMAND = 0x0126,
+ //public const uint WM_CHANGEUISTATE = 0x0127;
+ //public const uint WM_UPDATEUISTATE = 0x0128;
+ //public const uint WM_QUERYUISTATE = 0x0129;
+ //
+ //public const uint WM_LBTRACKPOINT = 0x0131;
+ WM_CTLCOLORMSGBOX = 0x0132,
+ WM_CTLCOLOREDIT = 0x0133,
+ WM_CTLCOLORLISTBOX = 0x0134,
+ WM_CTLCOLORBTN = 0x0135,
+ WM_CTLCOLORDLG = 0x0136,
+ WM_CTLCOLORSCROLLBAR = 0x0137,
+ WM_CTLCOLORSTATIC = 0x0138,
+ WM_MOUSEMOVE = 0x0200,
+ WM_MOUSEFIRST = 0x0200,
+ WM_LBUTTONDOWN = 0x0201,
+ WM_LBUTTONUP = 0x0202,
+ WM_LBUTTONDBLCLK = 0x0203,
+ WM_RBUTTONDOWN = 0x0204,
+ WM_RBUTTONUP = 0x0205,
+ WM_RBUTTONDBLCLK = 0x0206,
+ WM_MBUTTONDOWN = 0x0207,
+ WM_MBUTTONUP = 0x0208,
+ WM_MBUTTONDBLCLK = 0x0209,
+ WM_MOUSEWHEEL = 0x020A,
+ WM_MOUSELAST = 0x020D,
+ //public const uint WM_XBUTTONDOWN = 0x020B;
+ //public const uint WM_XBUTTONUP = 0x020C;
+ //public const uint WM_XBUTTONDBLCLK = 0x020D;
+ WM_PARENTNOTIFY = 0x0210,
+ WM_ENTERMENULOOP = 0x0211,
+ WM_EXITMENULOOP = 0x0212,
+ WM_NEXTMENU = 0x0213,
+ WM_SIZING = 0x0214,
+ WM_CAPTURECHANGED = 0x0215,
+ WM_MOVING = 0x0216,
+ //public const uint WM_POWERBROADCAST = 0x0218;
+ WM_DEVICECHANGE = 0x0219,
+ WM_MDICREATE = 0x0220,
+ WM_MDIDESTROY = 0x0221,
+ WM_MDIACTIVATE = 0x0222,
+ WM_MDIRESTORE = 0x0223,
+ WM_MDINEXT = 0x0224,
+ WM_MDIMAXIMIZE = 0x0225,
+ WM_MDITILE = 0x0226,
+ WM_MDICASCADE = 0x0227,
+ WM_MDIICONARRANGE = 0x0228,
+ WM_MDIGETACTIVE = 0x0229,
+ /* D&D messages */
+ //public const uint WM_DROPOBJECT = 0x022A;
+ //public const uint WM_QUERYDROPOBJECT = 0x022B;
+ //public const uint WM_BEGINDRAG = 0x022C;
+ //public const uint WM_DRAGLOOP = 0x022D;
+ //public const uint WM_DRAGSELECT = 0x022E;
+ //public const uint WM_DRAGMOVE = 0x022F;
+ WM_MDISETMENU = 0x0230,
+ WM_ENTERSIZEMOVE = 0x0231,
+ WM_EXITSIZEMOVE = 0x0232,
+ WM_DROPFILES = 0x0233,
+ WM_MDIREFRESHMENU = 0x0234,
+ WM_IME_SETCONTEXT = 0x0281,
+ WM_IME_NOTIFY = 0x0282,
+ WM_IME_CONTROL = 0x0283,
+ WM_IME_COMPOSITIONFULL = 0x0284,
+ WM_IME_SELECT = 0x0285,
+ WM_IME_CHAR = 0x0286,
+ WM_IME_REQUEST = 0x0288,
+ WM_IME_KEYDOWN = 0x0290,
+ WM_IME_KEYUP = 0x0291,
+ WM_MOUSEHOVER = 0x02A1,
+ WM_MOUSELEAVE = 0x02A3,
+ WM_CUT = 0x0300,
+ WM_COPY = 0x0301,
+ WM_PASTE = 0x0302,
+ WM_CLEAR = 0x0303,
+ WM_UNDO = 0x0304,
+ WM_RENDERFORMAT = 0x0305,
+ WM_RENDERALLFORMATS = 0x0306,
+ WM_DESTROYCLIPBOARD = 0x0307,
+ WM_DRAWCLIPBOARD = 0x0308,
+ WM_PAINTCLIPBOARD = 0x0309,
+ WM_VSCROLLCLIPBOARD = 0x030A,
+ WM_SIZECLIPBOARD = 0x030B,
+ WM_ASKCBFORMATNAME = 0x030C,
+ WM_CHANGECBCHAIN = 0x030D,
+ WM_HSCROLLCLIPBOARD = 0x030E,
+ WM_QUERYNEWPALETTE = 0x030F,
+ WM_PALETTEISCHANGING = 0x0310,
+ WM_PALETTECHANGED = 0x0311,
+ WM_HOTKEY = 0x0312,
+ WM_PRINT = 0x0317,
+ WM_PRINTCLIENT = 0x0318,
+ WM_HANDHELDFIRST = 0x0358,
+ WM_HANDHELDLAST = 0x035F,
+ WM_AFXFIRST = 0x0360,
+ WM_AFXLAST = 0x037F,
+ WM_PENWINFIRST = 0x0380,
+ WM_PENWINLAST = 0x038F,
+ WM_APP = 0x8000,
+ WM_USER = 0x0400,
+
+ // Our "private" ones
+ WM_MOUSE_ENTER = 0x0401,
+ WM_MOUSE_LEAVE = 0x0402,
+ WM_ASYNC_MESSAGE = 0x0403,
+ WM_REFLECT = WM_USER + 0x1c00
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlEventTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlEventTest.cs
new file mode 100644
index 00000000000..e44734c03d3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlEventTest.cs
@@ -0,0 +1,300 @@
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Threading;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class EventClass
+ {
+ static bool eventhandled = false;
+ public static void Event_Handler1 (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void BackColorChangedTest ()
+ {
+ Control c = new Control ();
+ // Test BackColorChanged Event
+ c.BackColorChanged += new EventHandler (Event_Handler1);
+ c.BackColor = Color.Black;
+ Assert.AreEqual (true, eventhandled, "#A1");
+
+ }
+
+ [Test]
+ public void BgrndImageChangedTest ()
+ {
+ Control c = new Control ();
+ // Test BackgroundImageChanged Event
+ c.BackgroundImageChanged += new EventHandler (Event_Handler1);
+ string abc = "M.gif";
+ eventhandled = false;
+ c.BackgroundImage = Image.FromFile (abc);
+ Assert.AreEqual (true, eventhandled, "#A2");
+ }
+
+ [Test]
+ public void BindingContextChangedTest ()
+ {
+ Control c = new Control ();
+ // Test BindingContextChanged Event
+ c.BindingContextChanged += new EventHandler (Event_Handler1);
+ BindingContext bcG1 = new BindingContext ();
+ eventhandled = false;
+ c.BindingContext = bcG1;
+ Assert.AreEqual (true, eventhandled, "#A3");
+
+ }
+
+ [Test]
+ public void CausesValidationChangedTest ()
+ {
+ Control c = new Control ();
+ // Test CausesValidationChanged Event
+ c.CausesValidationChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.CausesValidation = false;
+ Assert.AreEqual (true, eventhandled, "#A4");
+
+ }
+
+ [Test]
+ public void CursorChangedTest ()
+ {
+ Control c = new Control ();
+ // Test CursorChanged Event
+ c.CursorChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Cursor = Cursors.Hand;
+ Assert.AreEqual (true, eventhandled, "#A6");
+ }
+
+ [Test]
+ public void DisposedTest ()
+ {
+ Control c = new Control ();
+ // Test Disposed Event
+ c.Disposed += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Dispose ();
+ Assert.AreEqual (true, eventhandled, "#A7");
+ }
+
+ [Test]
+ public void DockChangedTest ()
+ {
+ Control c = new Control ();
+ // Test DockChanged Event
+ c.DockChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Dock = DockStyle.Bottom;
+ Assert.AreEqual (true, eventhandled, "#A8");
+ }
+
+ [Test]
+ public void EnabledChangedTest ()
+ {
+ Control c = new Control ();
+ // Test EnabledChanged Event
+ c.EnabledChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Enabled = false;
+ Assert.AreEqual (true, eventhandled, "#A9");
+ }
+
+ [Test]
+ public void FontChangedTest ()
+ {
+ Control c = new Control ();
+ // Test FontChanged Event
+ c.FontChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Font = new Font (c.Font, FontStyle.Bold);
+ Assert.AreEqual (true, eventhandled, "#A11");
+ }
+
+ [Test]
+ public void ForeColorChangedTest ()
+ {
+ Control c = new Control ();
+ // Test ForeColorChanged Event
+ c.ForeColorChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.ForeColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "#A12");
+ }
+
+ [Test]
+ public void HandleCreatedTest ()
+ {
+ Control c = new Control ();
+ // Test HandleCreated Event
+ c.HandleCreated += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Handle.GetType ();
+ Assert.AreEqual (true, eventhandled, "#A15");
+ }
+
+ [Test]
+ public void ImeModeChangedTest ()
+ {
+ Control c = new Control ();
+ // Test ImeModeChanged Event
+ c.ImeModeChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.ImeMode = ImeMode.Off;
+ Assert.AreEqual (true, eventhandled, "#A19");
+ }
+
+ [Test]
+ public void LocationChangedTest ()
+ {
+ Control c = new Control ();
+ // Test LocationChanged Event
+ c.LocationChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Left = 20;
+ Assert.AreEqual (true, eventhandled, "#A20");
+ }
+
+ [Test]
+ public void ResizeTest ()
+ {
+ Control c = new Control ();
+ // Test Resize Event
+ c.Resize += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Height = 20;
+ Assert.AreEqual (true, eventhandled, "#A22");
+ }
+
+ [Test]
+ public void RightToLeftChangedTest ()
+ {
+ Control c = new Control ();
+ // Test RightToLeftChanged Event
+ c.RightToLeftChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.RightToLeft = RightToLeft.Yes;
+ Assert.AreEqual (true, eventhandled, "#A23");
+ }
+
+ [Test]
+ public void SizeChangedTest ()
+ {
+ Control c = new Control ();
+ // Test SizeChanged Event
+ c.SizeChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Height = 80;
+ Assert.AreEqual (true, eventhandled, "#A24");
+ }
+
+ [Test]
+ public void TabIndexChangedTest ()
+ {
+ Control c = new Control ();
+ // Test TabIndexChanged Event
+ c.TabIndexChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.TabIndex = 1;
+ Assert.AreEqual (true, eventhandled, "#A27");
+ }
+
+ [Test]
+ public void TabStopChangedTest ()
+ {
+ Control c = new Control ();
+ // Test TabStopChanged Event
+ c.TabStopChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.TabStop = false;
+ Assert.AreEqual (true, eventhandled, "#A28");
+ }
+
+ [Test]
+ public void TextChangedTest ()
+ {
+ Control c = new Control ();
+ // Test TextChanged Event
+ c.TextChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Text = "some Text";
+ Assert.AreEqual (true, eventhandled, "#A29");
+ }
+
+ [Test]
+ public void VisibleChangedTest ()
+ {
+ Control c = new Control ();
+ // Test VisibleChanged Event
+ c.VisibleChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Visible = false;
+ Assert.AreEqual (true, eventhandled, "#A30");
+ }
+ }
+
+
+ [TestFixture]
+ public class LayoutEventClass
+ {
+ static bool eventhandled = false;
+ public static void LayoutEvent (object sender, LayoutEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void LayoutTest ()
+ {
+ Control c = new Control ();
+ c.Layout += new LayoutEventHandler (LayoutEvent);
+ eventhandled = false;
+ c.Visible = true;
+ c.Height = 100;
+ Assert.AreEqual (true, eventhandled, "#D1");
+
+ }
+ }
+
+ [TestFixture]
+ public class ControlAddRemoveEventClass
+ {
+ static bool eventhandled = false;
+ public static void ControlEvent (object sender, ControlEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void ControlAddedTest ()
+ {
+ Control c = new Control ();
+ c.ControlAdded += new ControlEventHandler (ControlEvent);
+ TextBox TB = new TextBox ();
+ eventhandled = false;
+ c.Controls.Add (TB);
+ Assert.AreEqual (true, eventhandled, "#F1");
+ }
+
+ [Test]
+ public void ControlRemovedTest ()
+ {
+ Control c = new Control ();
+ c.ControlRemoved += new ControlEventHandler (ControlEvent);
+ TextBox TB = new TextBox ();
+ c.Controls.Add (TB);
+ eventhandled = false;
+ c.Controls.Remove (TB);
+ Assert.AreEqual (true, eventhandled, "#F2");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlPaintTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlPaintTest.cs
new file mode 100644
index 00000000000..f1bca95c8f7
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlPaintTest.cs
@@ -0,0 +1,150 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+
+ [TestFixture]
+ class ControlPaintTest
+ {
+ [Test]
+ public void DarkTest ()
+ {
+ Color color;
+
+ // Non control colours
+ color = Color.FromArgb (255, 100, 0, 50);
+ color = ControlPaint.Dark (color);
+ Assert.AreEqual (255, color.A, "testdark#1A");
+ Assert.AreEqual (34, color.R, "testdark#1R");
+ Assert.AreEqual (0, color.G, "testdark#1G");
+ Assert.AreEqual (17, color.B, "testdark#1B");
+
+ color = Color.FromArgb (255, 40, 50, 60);
+ color = ControlPaint.Dark (color);
+ Assert.AreEqual (255, color.A, "testdark#2A");
+ Assert.AreEqual (14, color.R, "testdark#2R");
+ Assert.AreEqual (17, color.G, "testdark#2G");
+ Assert.AreEqual (20, color.B, "testdark#2B");
+
+ // Non-control colours using a specific percentage
+ color = Color.FromArgb (255, 20, 50, 40);
+ color = ControlPaint.Dark (color, 0.8f);
+ Assert.AreEqual (255, color.A, "testdark#3A");
+ Assert.AreEqual (3, color.R, "testdark#3R");
+ Assert.AreEqual (7, color.G, "testdark#3G");
+ Assert.AreEqual (6, color.B, "testdark#3B");
+
+ color = Color.FromArgb (255, 100, 0, 50);
+ color = ControlPaint.Dark (color, 0.6f);
+ Assert.AreEqual (255, color.A, "testdark#4A");
+ Assert.AreEqual (28, color.R, "testdark#4R");
+ Assert.AreEqual (0, color.G, "testdark#4G");
+ Assert.AreEqual (14, color.B, "testdark#4B");
+
+ // Fixed Control colours
+ color = Color.FromKnownColor (KnownColor.Control);
+ color = ControlPaint.Dark (color, 1f);
+ Assert.AreEqual (Color.FromKnownColor (KnownColor.ControlDarkDark), color, "testdark#5");
+
+ color = Color.FromKnownColor (KnownColor.Control);
+ color = ControlPaint.Dark (color, 0f);
+ Assert.AreEqual (Color.FromKnownColor (KnownColor.ControlDark), color, "testdark#6");
+
+ // Calculated non control fixed colour
+ color = Color.FromKnownColor (KnownColor.Control);
+ color = ControlPaint.Dark (color, 0.5f);
+
+ int r_sub, g_sub, b_sub;
+ Color new_color;
+ float per = 0.5f;
+
+ r_sub = Color.FromKnownColor (KnownColor.ControlDarkDark).R -
+ Color.FromKnownColor (KnownColor.ControlDark).R;
+ g_sub = Color.FromKnownColor (KnownColor.ControlDarkDark).G -
+ Color.FromKnownColor (KnownColor.ControlDark).G;
+ b_sub = Color.FromKnownColor (KnownColor.ControlDarkDark).B -
+ Color.FromKnownColor (KnownColor.ControlDark).B;
+
+ new_color = Color.FromArgb (Color.FromKnownColor (KnownColor.ControlDark).A,
+ (int) (Color.FromKnownColor (KnownColor.ControlDark).R + (r_sub * per)),
+ (int) (Color.FromKnownColor (KnownColor.ControlDark).G + (g_sub * per)),
+ (int) (Color.FromKnownColor (KnownColor.ControlDark).B + (b_sub * per)));
+
+ Assert.AreEqual (new_color, color, "testdark#7");
+ }
+
+ [Test]
+ public void LightTest ()
+ {
+ Color color;
+
+ // Non control colours
+
+ // Non-control colours using a specific percentage
+
+ // Fixed Control colours
+ color = Color.FromKnownColor (KnownColor.Control);
+ color = ControlPaint.Light (color, 1f);
+ Assert.AreEqual (Color.FromKnownColor (KnownColor.ControlLightLight), color, "testlight#5");
+
+ color = Color.FromKnownColor (KnownColor.Control);
+ color = ControlPaint.Light (color, 0f);
+ Assert.AreEqual (Color.FromKnownColor (KnownColor.ControlLight), color, "testlight#6");
+
+ // Calculated non control fixed colour
+ color = Color.FromKnownColor (KnownColor.Control);
+ color = ControlPaint.Light (color, 0.5f);
+
+ int r_sub, g_sub, b_sub;
+ Color new_color;
+ float per = 0.5f;
+
+ r_sub = Color.FromKnownColor (KnownColor.ControlLightLight).R -
+ Color.FromKnownColor (KnownColor.ControlLight).R;
+ g_sub = Color.FromKnownColor (KnownColor.ControlLightLight).G -
+ Color.FromKnownColor (KnownColor.ControlLight).G;
+ b_sub = Color.FromKnownColor (KnownColor.ControlLightLight).B -
+ Color.FromKnownColor (KnownColor.ControlLight).B;
+
+ new_color = Color.FromArgb (Color.FromKnownColor (KnownColor.ControlLight).A,
+ (int) (Color.FromKnownColor (KnownColor.ControlLight).R + (r_sub * per)),
+ (int) (Color.FromKnownColor (KnownColor.ControlLight).G + (g_sub * per)),
+ (int) (Color.FromKnownColor (KnownColor.ControlLight).B + (b_sub * per)));
+
+ Assert.AreEqual (new_color, color, "testlight#7");
+
+ }
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlStyleTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlStyleTest.cs
new file mode 100644
index 00000000000..77568afb8d8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlStyleTest.cs
@@ -0,0 +1,961 @@
+//
+// ControlStyleTest.cs (Auto-generated by GenerateControlStyleTest.cs).
+//
+// Author:
+// Peter Dennis Bartok (pbartok@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms {
+ [TestFixture]
+ public class TestControlStyle {
+
+ static Array style_values = Enum.GetValues(typeof(ControlStyles));
+ static string[] style_names = Enum.GetNames(typeof(ControlStyles));
+
+ public static string[] GetStyles(Control control) {
+ string[] result;
+
+ result = new string[style_names.Length];
+
+ for (int i = 0; i < style_values.Length; i++) {
+ result[i] = style_names[i] + "=" + control.GetType().GetMethod("GetStyle", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(control, new object[1] {(ControlStyles)style_values.GetValue(i)});
+ }
+
+ return result;
+ }
+
+ [Test]
+ public void ControlStyleTest ()
+ {
+ string[] Control_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(Control_want, GetStyles(new Control()), "ControlStyles");
+ }
+
+
+ [Test]
+ public void ButtonStyleTest ()
+ {
+ string[] Button_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=True",
+ "ResizeRedraw=True",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=True",
+ "SupportsTransparentBackColor=True",
+ "StandardDoubleClick=False",
+ "AllPaintingInWmPaint=True",
+ "CacheText=True",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=True"
+ };
+
+ Assert.AreEqual(Button_want, GetStyles(new Button()), "ButtonStyles");
+ }
+
+
+ [Test]
+ public void CheckBoxStyleTest ()
+ {
+ string[] CheckBox_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=True",
+ "ResizeRedraw=True",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=True",
+ "SupportsTransparentBackColor=True",
+ "StandardDoubleClick=False",
+ "AllPaintingInWmPaint=True",
+ "CacheText=True",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=True"
+ };
+
+ Assert.AreEqual(CheckBox_want, GetStyles(new CheckBox()), "CheckBoxStyles");
+ }
+
+
+ [Test]
+ public void RadioButtonStyleTest ()
+ {
+ string[] RadioButton_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=True",
+ "ResizeRedraw=True",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=True",
+ "SupportsTransparentBackColor=True",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=True",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=True"
+ };
+
+ Assert.AreEqual(RadioButton_want, GetStyles(new RadioButton()), "RadioButtonStyles");
+ }
+
+
+ [Test]
+ public void DataGridStyleTest ()
+ {
+ string[] DataGrid_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=True",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(DataGrid_want, GetStyles(new DataGrid()), "DataGridStyles");
+ }
+
+
+ [Test]
+ public void DateTimePickerStyleTest ()
+ {
+ string[] DateTimePicker_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=True",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(DateTimePicker_want, GetStyles(new DateTimePicker()), "DateTimePickerStyles");
+ }
+
+
+ [Test]
+ public void GroupBoxStyleTest ()
+ {
+ string[] GroupBox_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=True",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=True",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(GroupBox_want, GetStyles(new GroupBox()), "GroupBoxStyles");
+ }
+
+
+ [Test]
+ public void LabelStyleTest ()
+ {
+ string[] Label_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=True",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=True",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=True"
+ };
+
+ Assert.AreEqual(Label_want, GetStyles(new Label()), "LabelStyles");
+ }
+
+
+ [Test]
+ public void LinkLabelStyleTest ()
+ {
+ string[] LinkLabel_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=True",
+ "ResizeRedraw=True",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=True",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=True"
+ };
+
+ Assert.AreEqual(LinkLabel_want, GetStyles(new LinkLabel()), "LinkLabelStyles");
+ }
+
+
+ [Test]
+ public void ComboBoxStyleTest ()
+ {
+ string[] ComboBox_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(ComboBox_want, GetStyles(new ComboBox()), "ComboBoxStyles");
+ }
+
+
+ [Test]
+ public void ListBoxStyleTest ()
+ {
+ string[] ListBox_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(ListBox_want, GetStyles(new ListBox()), "ListBoxStyles");
+ }
+
+
+ [Test]
+ public void CheckedListBoxStyleTest ()
+ {
+ string[] CheckedListBox_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=True",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(CheckedListBox_want, GetStyles(new CheckedListBox()), "CheckedListBoxStyles");
+ }
+
+
+ [Test]
+ public void ListViewStyleTest ()
+ {
+ string[] ListView_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(ListView_want, GetStyles(new ListView()), "ListViewStyles");
+ }
+
+
+ [Test]
+ public void MdiClientStyleTest ()
+ {
+ string[] MdiClient_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(MdiClient_want, GetStyles(new MdiClient()), "MdiClientStyles");
+ }
+
+
+ [Test]
+ public void MonthCalendarStyleTest ()
+ {
+ string[] MonthCalendar_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(MonthCalendar_want, GetStyles(new MonthCalendar()), "MonthCalendarStyles");
+ }
+
+
+ [Test]
+ public void PictureBoxStyleTest ()
+ {
+ string[] PictureBox_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=True",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=True"
+ };
+
+ Assert.AreEqual(PictureBox_want, GetStyles(new PictureBox()), "PictureBoxStyles");
+ }
+
+
+ [Test]
+ public void ProgressBarStyleTest ()
+ {
+ string[] ProgressBar_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(ProgressBar_want, GetStyles(new ProgressBar()), "ProgressBarStyles");
+ }
+
+
+ [Test]
+ public void ScrollableControlStyleTest ()
+ {
+ string[] ScrollableControl_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=False",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(ScrollableControl_want, GetStyles(new ScrollableControl()), "ScrollableControlStyles");
+ }
+
+
+ [Test]
+ public void ContainerControlStyleTest ()
+ {
+ string[] ContainerControl_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=False",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(ContainerControl_want, GetStyles(new ContainerControl()), "ContainerControlStyles");
+ }
+
+
+ [Test]
+ public void FormStyleTest ()
+ {
+ string[] Form_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=False",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(Form_want, GetStyles(new Form()), "FormStyles");
+ }
+
+
+ [Test]
+ public void PropertyGridStyleTest ()
+ {
+ string[] PropertyGrid_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=False",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(PropertyGrid_want, GetStyles(new PropertyGrid()), "PropertyGridStyles");
+ }
+
+
+ [Test]
+ public void DomainUpDownStyleTest ()
+ {
+ string[] DomainUpDown_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=True",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=False",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(DomainUpDown_want, GetStyles(new DomainUpDown()), "DomainUpDownStyles");
+ }
+
+
+ [Test]
+ public void NumericUpDownStyleTest ()
+ {
+ string[] NumericUpDown_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=True",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=False",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(NumericUpDown_want, GetStyles(new NumericUpDown()), "NumericUpDownStyles");
+ }
+
+
+ [Test]
+ public void UserControlStyleTest ()
+ {
+ string[] UserControl_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=False",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(UserControl_want, GetStyles(new UserControl()), "UserControlStyles");
+ }
+
+
+ [Test]
+ public void PanelStyleTest ()
+ {
+ string[] Panel_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=True",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=False",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(Panel_want, GetStyles(new Panel()), "PanelStyles");
+ }
+
+
+ [Test]
+ public void TabPageStyleTest ()
+ {
+ string[] TabPage_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=True",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=False",
+ "CacheText=True",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(TabPage_want, GetStyles(new TabPage()), "TabPageStyles");
+ }
+
+
+ [Test]
+ public void HScrollBarStyleTest ()
+ {
+ string[] HScrollBar_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(HScrollBar_want, GetStyles(new HScrollBar()), "HScrollBarStyles");
+ }
+
+
+ [Test]
+ public void VScrollBarStyleTest ()
+ {
+ string[] VScrollBar_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(VScrollBar_want, GetStyles(new VScrollBar()), "VScrollBarStyles");
+ }
+
+
+ [Test]
+ public void SplitterStyleTest ()
+ {
+ string[] Splitter_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(Splitter_want, GetStyles(new Splitter()), "SplitterStyles");
+ }
+
+
+ [Test]
+ public void StatusBarStyleTest ()
+ {
+ string[] StatusBar_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(StatusBar_want, GetStyles(new StatusBar()), "StatusBarStyles");
+ }
+
+
+ [Test]
+ public void TabControlStyleTest ()
+ {
+ string[] TabControl_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(TabControl_want, GetStyles(new TabControl()), "TabControlStyles");
+ }
+
+
+ [Test]
+ public void RichTextBoxStyleTest ()
+ {
+ string[] RichTextBox_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(RichTextBox_want, GetStyles(new RichTextBox()), "RichTextBoxStyles");
+ }
+
+
+ [Test]
+ public void TextBoxStyleTest ()
+ {
+ string[] TextBox_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=True",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=False",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(TextBox_want, GetStyles(new TextBox()), "TextBoxStyles");
+ }
+
+
+ [Test]
+ public void DataGridTextBoxStyleTest ()
+ {
+ string[] DataGridTextBox_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=True",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=False",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(DataGridTextBox_want, GetStyles(new DataGridTextBox()), "DataGridTextBoxStyles");
+ }
+
+
+ [Test]
+ public void ToolBarStyleTest ()
+ {
+ string[] ToolBar_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=True",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(ToolBar_want, GetStyles(new ToolBar()), "ToolBarStyles");
+ }
+
+
+ [Test]
+ public void TrackBarStyleTest ()
+ {
+ string[] TrackBar_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(TrackBar_want, GetStyles(new TrackBar()), "TrackBarStyles");
+ }
+
+
+ [Test]
+ public void TreeViewStyleTest ()
+ {
+ string[] TreeView_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(TreeView_want, GetStyles(new TreeView()), "TreeViewStyles");
+ }
+
+
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlTest.cs
new file mode 100644
index 00000000000..de8055f36af
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlTest.cs
@@ -0,0 +1,790 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Threading;
+using System.Reflection;
+using System.Runtime.Remoting;
+
+using NUnit.Framework;
+
+namespace MWF.MonoTest
+{
+ [TestFixture]
+ public class ControlTest
+ {
+ internal static void TestAccessibility(Control c, string Default, string Description, string Name, AccessibleRole Role) {
+ Assert.AreEqual(false, c.AccessibilityObject == null, "Acc1");
+ Assert.AreEqual(Default, c.AccessibleDefaultActionDescription, "Acc2");
+ Assert.AreEqual(Description, c.AccessibleDescription, "Acc3");
+ Assert.AreEqual(Name, c.AccessibleName, "Acc4");
+ Assert.AreEqual(Role, c.AccessibleRole, "Acc5");
+ }
+
+ [Test]
+ public void PubPropTest()
+ {
+ Control c = new Control();
+
+ TestAccessibility(c, null, null, null, AccessibleRole.Default);
+
+ // A
+ Assert.AreEqual(false, c.AllowDrop , "A1");
+ Assert.AreEqual(AnchorStyles.Top | AnchorStyles.Left, c.Anchor, "A2");
+
+ // B
+ Assert.AreEqual("Control", c.BackColor.Name , "B1");
+ Assert.AreEqual(null, c.BackgroundImage, "B2");
+ Assert.AreEqual(null, c.BindingContext, "B3");
+ Assert.AreEqual(0, c.Bottom, "B4");
+ Assert.AreEqual (new Rectangle (0,0, 0, 0) , c.Bounds , "B5");
+
+ // C
+ Assert.AreEqual(false, c.CanFocus, "C1");
+ Assert.AreEqual(true, c.CanSelect, "C2");
+ Assert.AreEqual(false, c.Capture, "C3");
+ Assert.AreEqual(true, c.CausesValidation, "C4");
+ Assert.AreEqual (new Rectangle(0, 0, 0, 0) , c.ClientRectangle , "C5");
+ Assert.AreEqual (new Size(0, 0), c.ClientSize , "C6");
+
+ string name = c.CompanyName;
+ if (!name.Equals("Mono Project, Novell, Inc.") && !name.Equals("Microsoft Corporation")) {
+ Assert.Fail("CompanyName property does not match any accepted value - C7");
+ }
+ Assert.AreEqual(null, c.Container, "C8");
+ Assert.AreEqual(false, c.ContainsFocus, "C9");
+ Assert.AreEqual(null, c.ContextMenu, "C10");
+ Assert.AreEqual(0, c.Controls.Count, "C11");
+ Assert.AreEqual(true, c.Created, "C12");
+ Assert.AreEqual(Cursors.Default, c.Cursor, "C13");
+
+ // D
+ Assert.AreEqual(false, c.DataBindings == null, "D1");
+ Assert.AreEqual("Control", Control.DefaultBackColor.Name, "D2");
+ Assert.AreEqual("ControlText", Control.DefaultForeColor.Name, "D3");
+ Assert.AreEqual(FontStyle.Regular, Control.DefaultFont.Style, "D4");
+ Assert.AreEqual (new Rectangle(0, 0, 0, 0), c.DisplayRectangle , "D5");
+ Assert.AreEqual(false, c.Disposing, "D6");
+ Assert.AreEqual(DockStyle.None, c.Dock, "D7");
+
+ // E
+ Assert.AreEqual(true, c.Enabled, "E1");
+
+ // F
+ Assert.AreEqual(false, c.Focused, "F1");
+ Assert.AreEqual(FontStyle.Regular, c.Font.Style, "F2");
+ Assert.AreEqual(SystemColors.ControlText, c.ForeColor, "F3");
+
+ // G
+
+ // H
+ Assert.AreEqual (((IWin32Window)c).Handle, c.Handle, "H1");
+ Assert.AreEqual(false, c.HasChildren, "H2");
+ Assert.AreEqual(0, c.Height, "H3");
+
+ // I
+ Assert.AreEqual (ImeMode.NoControl, c.ImeMode, "I1");
+ Assert.AreEqual(false, c.InvokeRequired, "I2");
+ Assert.AreEqual(false, c.IsAccessible, "I3");
+ Assert.AreEqual(false, c.IsDisposed, "I4");
+ Assert.AreEqual(true, c.IsHandleCreated, "I5");
+
+ // J
+
+ // K
+
+ // L
+ Assert.AreEqual(0, c.Left, "L1");
+ Assert.AreEqual(Point.Empty, c.Location, "L2");
+
+ // M
+ Assert.AreEqual(Keys.None, Control.ModifierKeys, "M1");
+ Assert.AreEqual(false, Control.MousePosition.IsEmpty, "M2");
+ Assert.AreEqual(MouseButtons.None, Control.MouseButtons, "M3");
+
+ // N
+ Assert.AreEqual("", c.Name, "N1");
+
+ // O
+
+ // P
+ Assert.AreEqual(null, c.Parent, "P1");
+ name = c.ProductName;
+ if (!name.Equals("Novell Mono MWF") && !name.Equals("Microsoft (R) .NET Framework"))
+ Assert.Fail("ProductName property does not match any accepted value - P2");
+
+ name = c.ProductVersion;
+ if (!name.Equals("1.1.4322.2032")) {
+ Assert.Fail("This test is being run against the wrong framework version.\nExpected is Net 1.1sp1. - P3");
+ }
+
+ // R
+ Assert.AreEqual(false, c.RecreatingHandle, "R1");
+ Assert.AreEqual(null, c.Region, "R2");
+ Assert.AreEqual(0, c.Right, "R3");
+ Assert.AreEqual(RightToLeft.No, c.RightToLeft, "R4");
+
+ // S
+ Assert.AreEqual(null, c.Site, "S1");
+ Assert.AreEqual (new Size(0, 0), c.Size, "S2");
+
+ // T
+ Assert.AreEqual(0, c.TabIndex , "T1");
+ Assert.AreEqual(true, c.TabStop, "T2");
+ Assert.AreEqual(null, c.Tag, "T3");
+ Assert.AreEqual("", c.Text, "T4");
+ Assert.AreEqual(0, c.Top, "T5");
+ Assert.AreEqual(null, c.TopLevelControl, "T6");
+
+ // U
+
+ // V
+ Assert.AreEqual(true, c.Visible, "V1");
+
+ // W
+ Assert.AreEqual(0, c.Width, "W1");
+
+ // XYZ
+ }
+
+ [Test]
+ public void RelationTest() {
+ Control c1;
+ Control c2;
+
+ c1 = new Control();
+ c2 = new Control();
+
+ Assert.AreEqual(true , c1.Visible , "Rel1");
+ Assert.AreEqual(false, c1.Contains(c2) , "Rel2");
+ Assert.AreEqual("System.Windows.Forms.Control", c1.ToString() , "Rel3");
+
+ c1.Controls.Add(c2);
+ Assert.AreEqual(true , c2.Visible , "Rel4");
+ Assert.AreEqual(true, c1.Contains(c2) , "Rel5");
+
+ c1.Anchor = AnchorStyles.Top;
+ c1.SuspendLayout ();
+ c1.Anchor = AnchorStyles.Left ;
+ c1.ResumeLayout ();
+ Assert.AreEqual(AnchorStyles.Left , c1.Anchor, "Rel6");
+
+ c1.SetBounds(10, 20, 30, 40) ;
+ Assert.AreEqual(new Rectangle(10, 20, 30, 40), c1.Bounds, "Rel7");
+
+ Assert.AreEqual(c1, c2.Parent, "Rel8");
+ }
+
+ private string TestControl(Control container, Control start, bool forward) {
+ Control ctl;
+
+ ctl = container.GetNextControl(start, forward);
+
+ if (ctl == null) {
+ return null;
+ }
+
+ return ctl.Text;
+ }
+
+ [Test]
+ public void TabOrder() {
+ Form form;
+ Control active;
+
+ Label label1 = new Label(); // To test non-tabstop items as well
+ Label label2 = new Label();
+
+ GroupBox group1 = new GroupBox();
+ GroupBox group2 = new GroupBox();
+ GroupBox group3 = new GroupBox();
+
+ TextBox text1 = new TextBox();
+
+ RadioButton radio11 = new RadioButton();
+ RadioButton radio12 = new RadioButton();
+ RadioButton radio13 = new RadioButton();
+ RadioButton radio14 = new RadioButton();
+ RadioButton radio21 = new RadioButton();
+ RadioButton radio22 = new RadioButton();
+ RadioButton radio23 = new RadioButton();
+ RadioButton radio24 = new RadioButton();
+ RadioButton radio31 = new RadioButton();
+ RadioButton radio32 = new RadioButton();
+ RadioButton radio33 = new RadioButton();
+ RadioButton radio34 = new RadioButton();
+
+ form = new Form();
+
+ form.ClientSize = new System.Drawing.Size (520, 520);
+ Assert.AreEqual(new Size(520, 520), form.ClientSize, "Tab1");
+
+ form.Text = "SWF Taborder Test App Form";
+ Assert.AreEqual("SWF Taborder Test App Form", form.Text, "Tab2");
+
+ label1.Location = new Point(10, 10);
+ Assert.AreEqual(new Point(10, 10), label1.Location, "Tab3");
+ label1.Text = "Label1";
+ form.Controls.Add(label1);
+
+ label2.Location = new Point(200, 10);
+ label2.Text = "Label2";
+ form.Controls.Add(label2);
+
+ group1.Text = "Group1";
+ group2.Text = "Group2";
+ group3.Text = "Group3";
+
+ group1.Size = new Size(200, 400);
+ group2.Size = new Size(200, 400);
+ group3.Size = new Size(180, 180);
+ Assert.AreEqual(new Size(180, 180), group3.Size, "Tab4");
+
+ group1.Location = new Point(10, 40);
+ group2.Location = new Point(220, 40);
+ group3.Location = new Point(10, 210);
+
+ group1.TabIndex = 30;
+ Assert.AreEqual(30, group1.TabIndex, "Tab5");
+ group1.TabStop = true;
+
+ // Don't assign, test automatic assignment
+ //group2.TabIndex = 0;
+ group2.TabStop = true;
+ Assert.AreEqual(0, group2.TabIndex, "Tab6");
+
+ group3.TabIndex = 35;
+ group3.TabStop = true;
+
+ // Test default tab index
+ Assert.AreEqual(0, radio11.TabIndex, "Tab7");
+
+ text1.Text = "Edit Control";
+
+ radio11.Text = "Radio 1-1 [Tab1]";
+ radio12.Text = "Radio 1-2 [Tab2]";
+ radio13.Text = "Radio 1-3 [Tab3]";
+ radio14.Text = "Radio 1-4 [Tab4]";
+
+ radio21.Text = "Radio 2-1 [Tab4]";
+ radio22.Text = "Radio 2-2 [Tab3]";
+ radio23.Text = "Radio 2-3 [Tab2]";
+ radio24.Text = "Radio 2-4 [Tab1]";
+
+ radio31.Text = "Radio 3-1 [Tab1]";
+ radio32.Text = "Radio 3-2 [Tab3]";
+ radio33.Text = "Radio 3-3 [Tab2]";
+ radio34.Text = "Radio 3-4 [Tab4]";
+
+ // We don't assign TabIndex for radio1X; test automatic assignment
+ text1.TabStop = true;
+ radio11.TabStop = true;
+
+ radio21.TabIndex = 4;
+ radio22.TabIndex = 3;
+ radio23.TabIndex = 2;
+ radio24.TabIndex = 1;
+ radio24.TabStop = true;
+
+ radio31.TabIndex = 11;
+ radio31.TabStop = true;
+ radio32.TabIndex = 13;
+ radio33.TabIndex = 12;
+ radio34.TabIndex = 14;
+
+ text1.Location = new Point(10, 100);
+
+ radio11.Location = new Point(10, 20);
+ radio12.Location = new Point(10, 40);
+ radio13.Location = new Point(10, 60);
+ radio14.Location = new Point(10, 80);
+
+ radio21.Location = new Point(10, 20);
+ radio22.Location = new Point(10, 40);
+ radio23.Location = new Point(10, 60);
+ radio24.Location = new Point(10, 80);
+
+ radio31.Location = new Point(10, 20);
+ radio32.Location = new Point(10, 40);
+ radio33.Location = new Point(10, 60);
+ radio34.Location = new Point(10, 80);
+
+ text1.Size = new Size(150, text1.PreferredHeight);
+
+ radio11.Size = new Size(150, 20);
+ radio12.Size = new Size(150, 20);
+ radio13.Size = new Size(150, 20);
+ radio14.Size = new Size(150, 20);
+
+ radio21.Size = new Size(150, 20);
+ radio22.Size = new Size(150, 20);
+ radio23.Size = new Size(150, 20);
+ radio24.Size = new Size(150, 20);
+
+ radio31.Size = new Size(150, 20);
+ radio32.Size = new Size(150, 20);
+ radio33.Size = new Size(150, 20);
+ radio34.Size = new Size(150, 20);
+
+ group1.Controls.Add(text1);
+
+ group1.Controls.Add(radio11);
+ group1.Controls.Add(radio12);
+ group1.Controls.Add(radio13);
+ group1.Controls.Add(radio14);
+
+ group2.Controls.Add(radio21);
+ group2.Controls.Add(radio22);
+ group2.Controls.Add(radio23);
+ group2.Controls.Add(radio24);
+
+ group3.Controls.Add(radio31);
+ group3.Controls.Add(radio32);
+ group3.Controls.Add(radio33);
+ group3.Controls.Add(radio34);
+
+ form.Controls.Add(group1);
+ form.Controls.Add(group2);
+ group2.Controls.Add(group3);
+
+ // Perform some tests, the TabIndex stuff below will alter the outcome
+ Assert.AreEqual(null, TestControl(group2, radio34, true), "Tab8");
+ Assert.AreEqual(31, group2.TabIndex, "Tab9");
+
+ // Does the taborder of containers and non-selectable things change behaviour?
+ label1.TabIndex = 5;
+ label2.TabIndex = 4;
+ group1.TabIndex = 3;
+ group2.TabIndex = 1;
+
+ // Start verification
+ Assert.AreEqual(null, TestControl(group2, radio34, true), "Tab10");
+ Assert.AreEqual(radio24.Text, TestControl(group2, group2, true), "Tab11");
+ Assert.AreEqual(radio31.Text, TestControl(group2, group3, true), "Tab12");
+ Assert.AreEqual(null, TestControl(group1, radio14, true), "Tab13");
+ Assert.AreEqual(radio23.Text, TestControl(group2, radio24, true), "Tab14");
+ Assert.AreEqual(group3.Text, TestControl(group2, radio21, true), "Tab15");
+ Assert.AreEqual(radio13.Text, TestControl(form, radio12, true), "Tab16");
+ Assert.AreEqual(label2.Text, TestControl(form, radio14, true), "Tab17");
+ Assert.AreEqual(group1.Text, TestControl(form, radio34, true), "Tab18");
+ Assert.AreEqual(radio23.Text, TestControl(group2, radio24, true), "Tab19");
+
+ // Sanity checks
+ Assert.AreEqual(null, TestControl(radio11, radio21, true), "Tab20");
+ Assert.AreEqual(text1.Text, TestControl(group1, radio21, true), "Tab21");
+
+ Assert.AreEqual(radio14.Text, TestControl(form, label2, false), "Tab22");
+ Assert.AreEqual(radio21.Text, TestControl(group2, group3, false), "Tab23");
+
+ Assert.AreEqual(4, radio21.TabIndex, "Tab24");
+ Assert.AreEqual(1, radio11.TabIndex, "Tab25");
+ Assert.AreEqual(3, radio13.TabIndex, "Tab26");
+ Assert.AreEqual(35, group3.TabIndex, "Tab27");
+ Assert.AreEqual(1, group2.TabIndex, "Tab28");
+
+ Assert.AreEqual(label1.Text, TestControl(form, form, false), "Tab29");
+ Assert.AreEqual(radio14.Text, TestControl(group1, group1, false), "Tab30");
+ Assert.AreEqual(radio34.Text, TestControl(group3, group3, false), "Tab31");
+
+ Assert.AreEqual(null, TestControl(label1, label1, false), "Tab31");
+ Assert.AreEqual(null, TestControl(radio11, radio21, false), "Tab32");
+ }
+
+ [Test]
+ public void ScaleTest()
+ {
+ Control r1 = new Control();
+
+ r1.Width = 40;
+ r1.Height = 20;
+ r1.Scale(2);
+ Assert.AreEqual(80, r1.Width, "Scale1");
+ Assert.AreEqual(40, r1.Height, "Scale2");
+ }
+
+ [Test]
+ public void TextTest()
+ {
+ Control r1 = new Control();
+ r1.Text = "Hi" ;
+ Assert.AreEqual("Hi" , r1.Text , "Text1");
+
+ r1.ResetText();
+ Assert.AreEqual("" , r1.Text , "Text2");
+ }
+
+ [Test]
+ public void PubMethodTest7()
+ {
+ Control r1 = new Control();
+ r1.RightToLeft = RightToLeft.Yes ;
+ r1.ResetRightToLeft() ;
+ Assert.AreEqual(RightToLeft.No , r1.RightToLeft , "#81");
+ r1.ImeMode = ImeMode.Off ;
+ r1.ResetImeMode () ;
+ Assert.AreEqual(ImeMode.NoControl , r1.ImeMode , "#82");
+ r1.ForeColor= SystemColors.GrayText ;
+ r1.ResetForeColor() ;
+ Assert.AreEqual(SystemColors.ControlText , r1.ForeColor , "#83");
+ //r1.Font = Font.FromHdc();
+ r1.ResetFont () ;
+ //Assert.AreEqual(FontFamily.GenericSansSerif , r1.Font , "#83");
+ r1.Cursor = Cursors.Hand ;
+ r1.ResetCursor () ;
+ Assert.AreEqual(Cursors.Default , r1.Cursor , "#83");
+ //r1.DataBindings = System.Windows.Forms.Binding ;
+ //r1.ResetBindings() ;
+ //Assert.AreEqual(ControlBindingsCollection , r1.DataBindings , "#83");
+ r1.BackColor = System.Drawing.Color.Black ;
+ r1.ResetBackColor() ;
+ Assert.AreEqual( SystemColors.Control , r1.BackColor , "#84");
+ r1.BackColor = System.Drawing.Color.Black ;
+ r1.Refresh() ;
+ Assert.AreEqual( null , r1.Region , "#85");
+ Rectangle M = new Rectangle(10, 20, 30 ,40);
+ r1.RectangleToScreen(M) ;
+ Assert.AreEqual( null , r1.Region , "#86");
+
+ }
+
+ [Test]
+ public void ScreenClientCoords()
+ {
+ Label l;
+ Point p1;
+ Point p2;
+ Point p3;
+
+ l = new Label();
+ l.Left = 10;
+ l.Top = 12;
+ l.Visible = true;
+ p1 = new Point (10,10);
+ p2 = l.PointToScreen(p1);
+ p3 = l.PointToClient(p2);
+
+ Assert.AreEqual (p1, p3, "SC1");
+ }
+
+ [Test]
+ public void ContainsTest ()
+ {
+ Control t = new Control ();
+ Control s = new Control ();
+
+ t.Controls.Add (s);
+
+ Assert.AreEqual (true, t.Contains (s), "Con1");
+ Assert.AreEqual (false, s.Contains (t), "Con2");
+ Assert.AreEqual (false, s.Contains (null), "Con3");
+ Assert.AreEqual (false, t.Contains (new Control ()), "Con4");
+ }
+
+ [Test]
+ public void CreateHandleTest ()
+ {
+ Control parent;
+ Control child;
+
+ parent = null;
+ child = null;
+
+ try {
+ parent = new Control ();
+ child = new Control ();
+
+ parent.Visible = true;
+ parent.Controls.Add (child);
+
+ Assert.IsFalse (parent.IsHandleCreated, "CH1");
+ Assert.IsFalse (child.IsHandleCreated, "CH2");
+
+ parent.CreateControl ();
+ Assert.IsNotNull (parent.Handle, "CH3");
+ Assert.IsNotNull (child.Handle, "CH4");
+ Assert.IsTrue (parent.IsHandleCreated, "CH5");
+ Assert.IsTrue (child.IsHandleCreated, "CH6");
+ } finally {
+ if (parent != null)
+ parent.Dispose ();
+ if (child != null)
+ child.Dispose ();
+ }
+
+ // Accessing Handle Property creates the handle
+ try {
+ parent = new Control ();
+ parent.Visible = true;
+ child = new Control ();
+ parent.Controls.Add (child);
+ Assert.IsFalse (parent.IsHandleCreated, "CH7");
+ Assert.IsFalse (child.IsHandleCreated, "CH8");
+ Assert.IsNotNull (parent.Handle, "CH9");
+ Assert.IsTrue (parent.IsHandleCreated, "CH10");
+ Assert.IsTrue (child.IsHandleCreated, "CH11");
+ } finally {
+ if (parent != null)
+ parent.Dispose ();
+ if (child != null)
+ child.Dispose ();
+ }
+ }
+
+ [Test]
+ public void CreateGraphicsTest ()
+ {
+ Graphics g = null;
+ Pen p = null;
+
+ try {
+ Control c = new Control ();
+ c.SetBounds (0,0, 20, 20);
+ g = c.CreateGraphics ();
+ Assert.IsNotNull (g, "Graph1");
+ } finally {
+ if (p != null)
+ p.Dispose ();
+ if (g != null)
+ g.Dispose ();
+ }
+ }
+
+ bool delegateCalled = false;
+ public delegate void TestDelegate ();
+
+ [Test]
+ [ExpectedException(typeof(System.InvalidOperationException))]
+ public void InvokeException1 () {
+ Control c = new Control ();
+ IAsyncResult result;
+
+ result = c.BeginInvoke (new TestDelegate (delegate_call));
+ c.EndInvoke (result);
+ }
+
+ [Test]
+ public void InvokeTest () {
+ Control c = null;
+
+ try {
+ c = new Control ();
+ IAsyncResult result;
+
+ c.CreateControl ();
+ result = c.BeginInvoke (new TestDelegate (delegate_call));
+ c.EndInvoke (result);
+ Assert.AreEqual (true, delegateCalled, "Invoke1");
+ } finally {
+ if (c != null)
+ c.Dispose ();
+ }
+ }
+
+ public void delegate_call () {
+ delegateCalled = true;
+ }
+
+ [Test]
+ public void FindFormTest () {
+ Form f = new Form ();
+
+ f.Name = "form";
+ Control c = null;
+
+ try {
+ f.Controls.Add (c = new Control ());
+ Assert.AreEqual (f.Name, c.FindForm ().Name, "Find1");
+
+ f.Controls.Remove (c);
+
+ GroupBox g = new GroupBox ();
+ g.Name = "box";
+ f.Controls.Add (g);
+ g.Controls.Add (c);
+
+ Assert.AreEqual (f.Name, f.FindForm ().Name, "Find2");
+
+ g.Controls.Remove (c);
+ Assert.IsNull(c.FindForm (), "Find3");
+
+ } finally {
+ if (c != null)
+ c.Dispose ();
+ if (f != null)
+ f.Dispose ();
+ }
+ }
+
+ [Test]
+ public void FocusTest ()
+ {
+ Form f = null;
+ Button c = null, d = null;
+
+ try {
+ f = new Form ();
+ f.Visible = true;
+ c = new Button ();
+ c.Visible = true;
+ f.Controls.Add (c);
+
+ d = new Button ();
+ d.Visible = false;
+ f.Controls.Add (d);
+
+ Assert.IsTrue (c.CanFocus, "Focus1");
+ Assert.IsFalse (c.Focused, "Focus2");
+ c.Focus ();
+ Assert.IsTrue (c.Focused, "Focus3");
+ d.Focus ();
+ Assert.IsFalse (d.Focused, "Focus4");
+
+ d.Visible = true;
+ d.Focus ();
+ Assert.IsTrue (d.Focused, "Focus5");
+ Assert.IsFalse (c.Focused, "Focus6");
+
+ c.Enabled = false;
+ Assert.IsFalse (c.Focused, "Focus7");
+ } finally {
+ if (f != null)
+ f.Dispose ();
+ if (c != null)
+ c.Dispose ();
+ if (d != null)
+ d.Dispose ();
+ }
+ }
+
+ [Test]
+ public void FromHandleTest ()
+ {
+ Control c1 = null;
+ Control c2 = null;
+
+ try {
+ c1 = new Control ();
+ c2 = new Control ();
+
+ c1.Name = "parent";
+ c2.Name = "child";
+ c1.Controls.Add(c2);
+
+ // Handle
+ Assert.AreEqual (c1.Name, Control.FromHandle (c1.Handle).Name, "Handle1");
+ Assert.IsNull (Control.FromHandle (IntPtr.Zero), "Handle2");
+
+ // ChildHandle
+ Assert.AreEqual (c1.Name, Control.FromChildHandle (c1.Handle).Name, "Handle3");
+ Assert.IsNull (Control.FromChildHandle (IntPtr.Zero), "Handle4");
+
+
+ } finally {
+ if (c1 != null)
+ c1.Dispose ();
+
+ if (c2 != null)
+ c2.Dispose ();
+ }
+ }
+
+ [Test]
+ public void GetChildAtPointTest ()
+ {
+ Control c = null, d = null, e = null;
+
+ try {
+ c = new Control ();
+ c.Name = "c1";
+ c.SetBounds (0, 0, 100, 100);
+
+ d = new Control ();
+ d.Name = "d1";
+ d.SetBounds (10, 10, 40, 40);
+ c.Controls.Add (d);
+
+ e = new Control ();
+ e.Name = "e1";
+ e.SetBounds (55, 55, 10, 10);
+
+ Control l = c.GetChildAtPoint (new Point (15, 15));
+ Assert.AreEqual (d.Name, l.Name, "Child1");
+ Assert.IsFalse (e.Name == l.Name, "Child2");
+
+ l = c.GetChildAtPoint (new Point (57, 57));
+ Assert.IsNull (l, "Child3");
+
+ l = c.GetChildAtPoint (new Point (10, 10));
+ Assert.AreEqual (d.Name, l.Name, "Child4");
+
+ // GetChildAtPointSkip is not implemented and the following test is breaking for Net_2_0 profile
+// #if NET_2_0
+// c.Controls.Add (e);
+// e.Visible = false;
+// l = c.GetChildAtPoint (new Point (57, 57), GetChildAtPointSkip.Invisible);
+// Assert.IsNull (l, "Child5");
+
+// e.Visible = true;
+// l = c.GetChildAtPoint (new Point (57, 57), GetChildAtPointSkip.Invisible);
+// Assert.AreSame (e.Name, l.Name, "Child6");
+// #endif // NET_2_0
+ } finally {
+ if (c != null)
+ c.Dispose ();
+ if (d != null)
+ d.Dispose ();
+ }
+ }
+
+
+ public class LayoutTestControl : Control {
+ public int LayoutCount;
+
+ public LayoutTestControl () : base() {
+ LayoutCount = 0;
+ }
+
+ protected override void OnLayout(LayoutEventArgs levent) {
+ LayoutCount++;
+ base.OnLayout (levent);
+ }
+ }
+
+ [Test]
+ public void LayoutTest() {
+ LayoutTestControl c;
+
+ c = new LayoutTestControl();
+
+ c.SuspendLayout();
+ c.SuspendLayout();
+ c.SuspendLayout();
+ c.SuspendLayout();
+
+ c.ResumeLayout(true);
+ c.PerformLayout();
+ c.ResumeLayout(true);
+ c.PerformLayout();
+ c.ResumeLayout(true);
+ c.PerformLayout();
+ c.ResumeLayout(true);
+ c.PerformLayout();
+ c.ResumeLayout(true);
+ c.PerformLayout();
+ c.ResumeLayout(true);
+ c.PerformLayout();
+ c.ResumeLayout(true);
+ c.PerformLayout();
+ c.SuspendLayout();
+ c.PerformLayout();
+
+ Assert.AreEqual(5, c.LayoutCount, "Layout Suspend/Resume locking does not bottom out at 0");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CursorTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CursorTest.cs
new file mode 100644
index 00000000000..e7123e1891d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CursorTest.cs
@@ -0,0 +1,29 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Miguel de Icaza
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class CursorTest
+ {
+ [Test]
+ public void LoadCursorKind2 ()
+ {
+ //
+ // This test tries to load a cursor with type 1
+ // this contains an and mask, it used to crash
+ //
+
+ new Cursor (typeof (CursorTest).Assembly.GetManifestResourceStream ("a.cur"));
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridCellTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridCellTest.cs
new file mode 100644
index 00000000000..5213c36003a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridCellTest.cs
@@ -0,0 +1,56 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+using System;
+using System.ComponentModel;
+using System.Windows.Forms;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ class DataGridCellTest
+ {
+ private bool eventhandled;
+
+
+ [Test]
+ public void TestDefaultValues ()
+ {
+ DataGridCell cell = new DataGridCell (5, 10);
+
+ Assert.AreEqual (5, cell.RowNumber, "A1 RowNumber");
+ Assert.AreEqual (10, cell.ColumnNumber, "A2 ColumnNumber");
+
+ cell.ColumnNumber = 20;
+ cell.RowNumber = 30;
+
+ Assert.AreEqual (30, cell.RowNumber, "A3 RowNumber");
+ Assert.AreEqual (20, cell.ColumnNumber, "A4 ColumnNumber");
+ }
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTableStyleTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTableStyleTest.cs
new file mode 100644
index 00000000000..97cbda27cb3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTableStyleTest.cs
@@ -0,0 +1,270 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ class DataGridTableStyleTest
+ {
+ private bool eventhandled;
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady ()
+ {
+ }
+
+ [Test]
+ public void TestDefaultValues ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+
+ Assert.AreEqual (true, dg.AllowSorting, "AllowSorting property");
+ Assert.AreEqual (true, dg.ColumnHeadersVisible, "ColumnHeadersVisible property");
+ Assert.AreEqual (DataGridLineStyle.Solid, dg.GridLineStyle, "GridLineStyle property");
+ Assert.AreEqual (75, dg.PreferredColumnWidth, "PreferredColumnWidth property");
+ Assert.AreEqual (16, dg.PreferredRowHeight, "PreferredRowHeight property");
+ Assert.AreEqual (false, dg.ReadOnly, "ReadOnly property");
+ Assert.AreEqual (true, dg.RowHeadersVisible, "RowHeadersVisible property");
+ Assert.AreEqual (35, dg.RowHeaderWidth, "RowHeaderWidth property");
+ }
+
+ [Test]
+ public void TestAllowSortingChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.AllowSortingChanged += new EventHandler (OnEventHandler);
+ dg.AllowSorting = !dg.AllowSorting;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestAlternatingBackColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.AlternatingBackColorChanged += new EventHandler (OnEventHandler);
+ dg.AlternatingBackColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Ignore ("Microsoft lunches ForeColor event instead of BackColor")]
+ public void TestBackColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.BackColorChanged += new EventHandler (OnEventHandler);
+ dg.BackColor = Color.Yellow;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestColumnHeadersVisibleChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.ColumnHeadersVisibleChanged += new EventHandler (OnEventHandler);
+ dg.ColumnHeadersVisible = !dg.ColumnHeadersVisible;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Ignore ("Microsoft lunches BackColor event instead of ForeColor")]
+ public void TestForeColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.ForeColorChanged += new EventHandler (OnEventHandler);
+ dg.ForeColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestGridLineColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.GridLineColorChanged += new EventHandler (OnEventHandler);
+ dg.GridLineColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestGridLineStyleChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.GridLineStyleChanged += new EventHandler (OnEventHandler);
+ dg.GridLineStyle = DataGridLineStyle.None;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestHeaderBackColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.HeaderBackColorChanged += new EventHandler (OnEventHandler);
+ dg.HeaderBackColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestHeaderFontChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.HeaderFontChanged += new EventHandler (OnEventHandler);
+ dg.HeaderFont = new Font ("Arial", 20);
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestHeaderForeColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.HeaderForeColorChanged += new EventHandler (OnEventHandler);
+ dg.HeaderForeColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestLinkColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.LinkColorChanged += new EventHandler (OnEventHandler);
+ dg.LinkColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+
+ [Ignore ("Microsoft is not firing any event")]
+ public void TestLinkHoverColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.LinkHoverColorChanged += new EventHandler (OnEventHandler);
+ dg.LinkHoverColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestMappingNameChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.MappingNameChanged += new EventHandler (OnEventHandler);
+ dg.MappingName = "name1";
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestPreferredColumnWidthChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.PreferredColumnWidthChanged += new EventHandler (OnEventHandler);
+ dg.PreferredColumnWidth = dg.PreferredColumnWidth++;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestPreferredRowHeightChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.PreferredRowHeightChanged += new EventHandler (OnEventHandler);
+ dg.PreferredRowHeight = dg.PreferredRowHeight++;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+ [Test]
+ public void TestReadOnlyChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.ReadOnlyChanged += new EventHandler (OnEventHandler);
+ dg.ReadOnly = !dg.ReadOnly;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestRowHeadersVisibleChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.RowHeadersVisibleChanged += new EventHandler (OnEventHandler);
+ dg.RowHeadersVisible = !dg.RowHeadersVisible;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestRowHeaderWidthChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.RowHeaderWidthChanged += new EventHandler (OnEventHandler);
+ dg.RowHeaderWidth = dg.RowHeaderWidth++;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestSelectionBackColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.SelectionBackColorChanged += new EventHandler (OnEventHandler);
+ dg.SelectionBackColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestSelectionForeColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.SelectionForeColorChanged += new EventHandler (OnEventHandler);
+ dg.SelectionForeColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ public void OnEventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTest.cs
new file mode 100644
index 00000000000..77b061906a1
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTest.cs
@@ -0,0 +1,314 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ // Helper classes
+
+ class TestDataGrid : DataGrid
+ {
+ public TestDataGrid ()
+ {
+
+ }
+
+ public CurrencyManager Manager {
+ get {
+ return ListManager;
+ }
+ }
+ }
+
+ [TestFixture]
+ class DataGridTest
+ {
+ private bool eventhandled;
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady ()
+ {
+ }
+
+ [Test]
+ public void TestDefaultValues ()
+ {
+ DataGrid dg = new DataGrid ();
+
+ Assert.AreEqual (true, dg.AllowNavigation, "AllowNavigation property");
+ Assert.AreEqual (true, dg.AllowSorting, "AllowSorting property");
+ Assert.AreEqual (BorderStyle.Fixed3D, dg.BorderStyle, "BorderStyle property");
+ Assert.AreEqual (string.Empty, dg.CaptionText, "CaptionText property");
+ Assert.AreEqual (true, dg.CaptionVisible, "CaptionVisible property");
+ Assert.AreEqual (true, dg.ColumnHeadersVisible, "ColumnHeadersVisible property");
+ Assert.AreEqual (new DataGridCell (), dg.CurrentCell, "CurrentCell property");
+ Assert.AreEqual (-1, dg.CurrentRowIndex, "CurrentRowIndex property");
+ Assert.AreEqual (string.Empty, dg.DataMember, "DataMember property");
+ Assert.AreEqual (null, dg.DataSource, "DataSource property");
+ Assert.AreEqual (0, dg.FirstVisibleColumn, "FirstVisibleColumn property");
+ Assert.AreEqual (false, dg.FlatMode, "FlatMode property");
+ Assert.AreEqual (DataGridLineStyle.Solid, dg.GridLineStyle, "GridLineStyle property");
+ Assert.AreEqual (DataGridParentRowsLabelStyle.Both, dg.ParentRowsLabelStyle, "ParentRowsLabelStyle property");
+ Assert.AreEqual (true, dg.ParentRowsVisible, "ParentRowsVisible property");
+ Assert.AreEqual (75, dg.PreferredColumnWidth, "PreferredColumnWidth property");
+ //Assert.AreEqual (16, dg.PreferredRowHeight, "PreferredRowHeight property");
+ Assert.AreEqual (false, dg.ReadOnly, "ReadOnly property");
+ Assert.AreEqual (true, dg.RowHeadersVisible, "RowHeadersVisible property");
+ Assert.AreEqual (35, dg.RowHeaderWidth, "RowHeaderWidth property");
+ Assert.AreEqual (null, dg.Site, "Site property");
+ Assert.AreEqual (string.Empty, dg.Text, "Text property");
+ Assert.AreEqual (0, dg.VisibleColumnCount, "VisibleColumnCount property");
+ }
+
+ [Test]
+ public void TestAllowNavigationChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.AllowNavigationChanged += new EventHandler (OnEventHandler);
+ dg.AllowNavigation = !dg.AllowNavigation;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestBackgroundColorChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.BackgroundColorChanged += new EventHandler (OnEventHandler);
+ dg.BackgroundColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestBorderStyleChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.BorderStyleChanged += new EventHandler (OnEventHandler);
+ dg.BorderStyle = BorderStyle.None;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestCaptionVisibleChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.CaptionVisibleChanged += new EventHandler (OnEventHandler);
+ dg.CaptionVisible = !dg.CaptionVisible;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestFlatModeChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.FlatModeChanged += new EventHandler (OnEventHandler);
+ dg.FlatMode = !dg.FlatMode;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestParentRowsLabelStyleChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.ParentRowsLabelStyleChanged += new EventHandler (OnEventHandler);
+ dg.ParentRowsLabelStyle = DataGridParentRowsLabelStyle.None;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestParentRowsVisibleChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.ParentRowsVisibleChanged += new EventHandler (OnEventHandler);
+ dg.ParentRowsVisible = !dg.ParentRowsVisible;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestReadOnlyChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.ReadOnlyChanged += new EventHandler (OnEventHandler);
+ dg.ReadOnly = !dg.ReadOnly;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ public void OnEventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ // Property exceptions
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void GridLineColorException ()
+ {
+ DataGrid dg = new DataGrid ();
+ dg.GridLineColor = Color.Empty;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void HeaderBackColorException ()
+ {
+ DataGrid dg = new DataGrid ();
+ dg.HeaderBackColor = Color.Empty;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void PreferredColumnWidthException ()
+ {
+ DataGrid dg = new DataGrid ();
+ dg.PreferredColumnWidth = -1;
+ }
+
+ [Test]
+ public void ResetAlternatingBackColor ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.AlternatingBackColor = Color.Red;
+ dg2.ResetAlternatingBackColor ();
+ Assert.AreEqual (dg.AlternatingBackColor, dg2.AlternatingBackColor, "A1");
+ }
+
+ // Test reset colour methods
+ [Test]
+ public void ResetBackColorMethod ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.BackColor = Color.Red;
+ dg2.ResetBackColor ();
+ Assert.AreEqual (dg.BackColor, dg2.BackColor, "A1");
+ }
+
+ [Test]
+ public void ResetForeColorMethod ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.ForeColor = Color.Red;
+ dg2.ResetForeColor ();
+ Assert.AreEqual (dg.ForeColor, dg2.ForeColor, "A1");
+ }
+
+ [Test]
+ public void ResetGridLineColorMethod ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.GridLineColor = Color.Red;
+ dg2.ResetGridLineColor ();
+ Assert.AreEqual (dg.GridLineColor, dg2.GridLineColor, "A1");
+ }
+
+ [Test]
+ public void ResetHeaderBackColorMethod ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.HeaderBackColor = Color.Red;
+ dg2.ResetHeaderBackColor ();
+ Assert.AreEqual (dg.HeaderBackColor, dg2.HeaderBackColor, "A1");
+ }
+
+ [Test]
+ public void ResetHeaderFontMethod ()
+ {
+ }
+
+ [Test]
+ public void ResetHeaderForeColorMethod ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.HeaderForeColor = Color.Red;
+ dg2.ResetHeaderForeColor ();
+ Assert.AreEqual (dg.HeaderForeColor, dg2.HeaderForeColor, "A1");
+ }
+
+ [Test]
+ public void ResetLinkColorMethod ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.LinkColor = Color.Red;
+ dg2.ResetLinkColor ();
+ Assert.AreEqual (dg.LinkColor, dg2.LinkColor, "A1");
+ }
+
+ [Test]
+ public void ResetLinkHoverColor ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.LinkHoverColor = Color.Red;
+ dg2.ResetLinkHoverColor ();
+ Assert.AreEqual (dg.LinkHoverColor, dg2.LinkHoverColor, "A1");
+ }
+
+ [Test]
+ public void ResetSelectionBackColor ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.SelectionBackColor = Color.Red;
+ dg2.ResetSelectionBackColor ();
+ Assert.AreEqual (dg.SelectionBackColor, dg2.SelectionBackColor, "A1");
+ }
+
+ [Test]
+ public void ResetSelectionForeColor ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.SelectionForeColor = Color.Red;
+ dg2.ResetSelectionForeColor ();
+ Assert.AreEqual (dg.SelectionForeColor, dg2.SelectionForeColor, "A1");
+ }
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTextBoxColumnTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTextBoxColumnTest.cs
new file mode 100644
index 00000000000..601faae3cfd
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTextBoxColumnTest.cs
@@ -0,0 +1,105 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ class DataGridTextBoxColumnTest
+ {
+ private bool eventhandled;
+ private object Element;
+ private CollectionChangeAction Action;
+
+ [Test]
+ public void TestDefaultValues ()
+ {
+ DataGridTextBoxColumn col = new DataGridTextBoxColumn ();
+
+ Assert.AreEqual (HorizontalAlignment.Left, col.Alignment, "HorizontalAlignment property");
+ Assert.AreEqual ("", col.HeaderText, "HeaderText property");
+ Assert.AreEqual ("", col.MappingName, "MappingName property");
+ Assert.AreEqual ("(null)", col.NullText, "NullText property");
+ Assert.AreEqual (false, col.ReadOnly, "ReadOnly property");
+ Assert.AreEqual (-1, col.Width, "Width property");
+ Assert.AreEqual ("", col.Format, "Format property");
+ Assert.AreEqual (null, col.FormatInfo, "FormatInfo property");
+ }
+
+ [Test]
+ public void TestMappingNameChangedEvent ()
+ {
+ DataGridTextBoxColumn col = new DataGridTextBoxColumn ();
+ eventhandled = false;
+ col.MappingNameChanged += new EventHandler (OnEventHandler);
+ col.MappingName = "name1";
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestAlignmentChangedEvent ()
+ {
+ DataGridTextBoxColumn col = new DataGridTextBoxColumn ();
+ eventhandled = false;
+ col.AlignmentChanged += new EventHandler (OnEventHandler);
+ col.Alignment = HorizontalAlignment.Center;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestHeaderTextChangedEvent ()
+ {
+ DataGridTextBoxColumn col = new DataGridTextBoxColumn ();
+ eventhandled = false;
+ col.HeaderTextChanged += new EventHandler (OnEventHandler);
+ col.HeaderText = "Header";
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestNullTextChangedEvent ()
+ {
+ DataGridTextBoxColumn col = new DataGridTextBoxColumn ();
+ eventhandled = false;
+ col.NullTextChanged += new EventHandler (OnEventHandler);
+ col.NullText = "Null";
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+
+ private void OnEventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewAdvancedBorderStyleTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewAdvancedBorderStyleTest.cs
new file mode 100644
index 00000000000..7d125797913
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewAdvancedBorderStyleTest.cs
@@ -0,0 +1,149 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms {
+
+ [TestFixture]
+ public class DataGridViewAdvancedBorderStyleTest : Assertion {
+
+ private DataGridViewAdvancedBorderStyle style;
+
+ [SetUp]
+ public void GetReady() {
+ style = new DataGridViewAdvancedBorderStyle();
+ }
+
+ [TearDown]
+ public void Clean() {
+ }
+
+ [Test]
+ public void TestDefaultValues () {
+ AssertEquals("All property before any change", DataGridViewAdvancedCellBorderStyle.None, style.All);
+ style.Left = DataGridViewAdvancedCellBorderStyle.Single;
+ AssertEquals("All property after changes", DataGridViewAdvancedCellBorderStyle.NotSet, style.All);
+ style.All = DataGridViewAdvancedCellBorderStyle.Single;
+ AssertEquals("All property after changes", DataGridViewAdvancedCellBorderStyle.Single, style.All);
+ AssertEquals("Left property after changes", DataGridViewAdvancedCellBorderStyle.Single, style.Left);
+ AssertEquals("Right property after changes", DataGridViewAdvancedCellBorderStyle.Single, style.Right);
+ AssertEquals("Top property after changes", DataGridViewAdvancedCellBorderStyle.Single, style.Top);
+ AssertEquals("Bottom property after changes", DataGridViewAdvancedCellBorderStyle.Single, style.Bottom);
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestLeftInvalidEnumArgumentException () {
+ style.Left = (DataGridViewAdvancedCellBorderStyle) 8;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestLeftArgumentException1 () {
+ style.Left = DataGridViewAdvancedCellBorderStyle.NotSet;
+ }
+
+ /*
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestLeftArgumentException2 () {
+ Control.RightToLeft = true;
+ style.Left = DataGridViewAdvancedCellBorderStyle.InsetDouble;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestLeftArgumentException3 () {
+ Control.RightToLeft = true;
+ style.Left = DataGridViewAdvancedCellBorderStyle.OutsetDouble;
+ }
+ */
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestRightInvalidEnumArgumentException () {
+ style.Right = (DataGridViewAdvancedCellBorderStyle) 8;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestRightArgumentException1 () {
+ style.Right = DataGridViewAdvancedCellBorderStyle.NotSet;
+ }
+
+ /*
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestRightArgumentException2 () {
+ Control.RightToLeft = false;
+ style.Right = DataGridViewAdvancedCellBorderStyle.InsetDouble;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestRightArgumentException3 () {
+ Control.RightToLeft = false;
+ style.Right = DataGridViewAdvancedCellBorderStyle.OutsetDouble;
+ }
+ */
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestTopInvalidEnumArgumentException () {
+ style.Top = (DataGridViewAdvancedCellBorderStyle) 8;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestTopArgumentException () {
+ style.Top = DataGridViewAdvancedCellBorderStyle.NotSet;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestBottomInvalidEnumArgumentException () {
+ style.Bottom = (DataGridViewAdvancedCellBorderStyle) 8;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestBottomArgumentException () {
+ style.Bottom = DataGridViewAdvancedCellBorderStyle.NotSet;
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewBandTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewBandTest.cs
new file mode 100644
index 00000000000..475237c7d14
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewBandTest.cs
@@ -0,0 +1,73 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms {
+
+ [TestFixture]
+ public class DataGridViewBandTest : Assertion {
+
+ [SetUp]
+ public void GetReady() {}
+
+ [TearDown]
+ public void Clean() {}
+
+ [Test]
+ public void TestDefaultValues () {
+ DataGridViewBand band = new DataGridViewBand();
+ // AssertEquals("ContextMenuStrip property", null, band.ContextMenuStrip);
+ AssertEquals("Frozen", false, band.Frozen);
+ AssertEquals("HasDefaultCellStyle property", false, band.HasDefaultCellStyle);
+ AssertEquals("Index property", -1, band.Index);
+ AssertEquals("InheritedStyle property", null, band.InheritedStyle);
+ AssertEquals("ReadOnly property", false, band.ReadOnly);
+ AssertEquals("Resizable property", DataGridViewTriState.True, band.Resizable);
+ AssertEquals("Selected property", false, band.Selected);
+ AssertEquals("Tag property", null, band.Tag);
+ AssertEquals("Visible property", true, band.Visible);
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void TestSelectedInvalidOperationException () {
+ DataGridViewBand band = new DataGridViewBand();
+ band.Selected = true;
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellStyleTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellStyleTest.cs
new file mode 100644
index 00000000000..269ab9fb9fb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellStyleTest.cs
@@ -0,0 +1,125 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Collections;
+using System.Globalization;
+
+namespace MonoTests.System.Windows.Forms {
+
+ [TestFixture]
+ public class DataGridViewCellStyleTest : Assertion {
+
+ DataGridViewCellStyle style;
+
+ [SetUp]
+ public void GetReady() {
+ style = new DataGridViewCellStyle();
+ }
+
+ [TearDown]
+ public void Clean() {
+ style = new DataGridViewCellStyle();
+ }
+
+ [Test]
+ public void TestDefaultValues () {
+ AssertEquals("Alignment property", DataGridViewContentAlignment.NotSet, style.Alignment);
+ AssertEquals("BackColor property", Color.Empty, style.BackColor);
+ AssertEquals("Font property", null, style.Font);
+ AssertEquals("ForeColor property", Color.Empty, style.ForeColor);
+ AssertEquals("Format property", String.Empty, style.Format);
+ AssertEquals("FormatProvider property", CultureInfo.CurrentUICulture, style.FormatProvider);
+ AssertEquals("IsFormatProviderDefault property", true, style.IsFormatProviderDefault);
+ AssertEquals("IsNullValueDefault property", true, style.IsNullValueDefault);
+ AssertEquals("NullValue property", "(null)", style.NullValue);
+ AssertEquals("SelectionBackColor property", Color.Empty, style.SelectionBackColor);
+ AssertEquals("SelectionForeColor property", Color.Empty, style.SelectionForeColor);
+ AssertEquals("Tag property", null, style.Tag);
+ AssertEquals("WrapMode property", DataGridViewTriState.NotSet, style.WrapMode);
+ }
+
+ [Test]
+ public void TestApplyStyle () {
+ DataGridViewCellStyle style_aux = new DataGridViewCellStyle();
+ style.ApplyStyle(style_aux);
+ AssertEquals("ApplyStyle method", style_aux, style);
+ }
+
+ [Test]
+ public void TestClone () {
+ DataGridViewCellStyle style_aux = (DataGridViewCellStyle) style.Clone();
+ AssertEquals("Clone method", style_aux, style);
+ }
+
+ [Test]
+ public void TestEquals () {
+ DataGridViewCellStyle style_aux = (DataGridViewCellStyle) style.Clone();
+ AssertEquals("Equals method", true, (style_aux.Equals(style)));
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestAlignmentInvalidEnumArgumentException () {
+ style.Alignment = DataGridViewContentAlignment.BottomCenter | DataGridViewContentAlignment.BottomRight;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestSelectionBackColorArgumentException () {
+ style.SelectionBackColor = Color.FromArgb(100, Color.Red);
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestWrapModeInvalidEnumArgumentException () {
+ style.WrapMode = (DataGridViewTriState) 3;
+ }
+
+ /*
+ [Test]
+ [ExpectedException(typeof(Exception))]
+ public void TestException () {
+ ConcreteCollection myCollection;
+ myCollection = new ConcreteCollection();
+ ....
+ AssertEquals ("#UniqueID", expected, actual);
+ ....
+ Fail ("Message");
+ }
+ */
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellTest.cs
new file mode 100644
index 00000000000..4b133b16760
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellTest.cs
@@ -0,0 +1,74 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms {
+
+ [TestFixture]
+ public class DataGridViewCellTest : Assertion {
+
+ [SetUp]
+ public void GetReady() {}
+
+ [TearDown]
+ public void Clean() {}
+
+ [Test]
+ public void TestDefaultValues () {
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestException () {
+ throw new InvalidEnumArgumentException();
+ }
+
+ /*
+ [Test]
+ [ExpectedException(typeof(Exception))]
+ public void TestException () {
+ ConcreteCollection myCollection;
+ myCollection = new ConcreteCollection();
+ ....
+ AssertEquals ("#UniqueID", expected, actual);
+ ....
+ Fail ("Message");
+ }
+ */
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewElementTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewElementTest.cs
new file mode 100644
index 00000000000..36d9306dda2
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewElementTest.cs
@@ -0,0 +1,57 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms {
+
+ [TestFixture]
+ public class DataGridViewElementTest : Assertion {
+
+ [SetUp]
+ public void GetReady() {}
+
+ [TearDown]
+ public void Clean() {}
+
+ [Test]
+ public void TestDefaultValues () {
+ DataGridViewElement element = new DataGridViewElement();
+ AssertEquals("DataGridView property", null, element.DataGridView);
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewRowTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewRowTest.cs
new file mode 100644
index 00000000000..41cfde87aa0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewRowTest.cs
@@ -0,0 +1,64 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms {
+
+ [TestFixture]
+ public class DataGridViewRowTest : Assertion {
+
+ [SetUp]
+ public void GetReady() {}
+
+ [TearDown]
+ public void Clean() {}
+
+ [Test]
+ public void TestDefaultValues () {
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void TestVisibleInvalidOperationException () {
+ DataGridView grid = new DataGridView();
+ DataGridViewRow row = new DataGridViewRow();
+ grid.Rows.Add(row);
+ row.Visible = false;
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewTest.cs
new file mode 100644
index 00000000000..a0dd21e9ce0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewTest.cs
@@ -0,0 +1,282 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms {
+
+ [TestFixture]
+ public class DataGridViewTest : Assertion {
+
+ [SetUp]
+ public void GetReady() {}
+
+ [TearDown]
+ public void Clean() {}
+
+ [Test]
+ public void TestDefaultValues () {
+ DataGridView grid = new DataGridView();
+ AssertEquals("AllowUserToAddRows property", true, grid.AllowUserToAddRows);
+ AssertEquals("AllowUserToDeleteRows property", true, grid.AllowUserToDeleteRows);
+ AssertEquals("AllowUserToOrderColumns property", false, grid.AllowUserToOrderColumns);
+ AssertEquals("AllowUserToResizeColumns property", true, grid.AllowUserToResizeColumns);
+ AssertEquals("AllowUserToResizeRows property", true, grid.AllowUserToResizeRows);
+ AssertEquals("AlternatingRowsDefaultCellStyle property", new DataGridViewCellStyle(), grid.AlternatingRowsDefaultCellStyle);
+ AssertEquals("AutoGenerateColumns property", true, grid.AutoGenerateColumns);
+ AssertEquals("AutoSizeRowsMode property", DataGridViewAutoSizeRowsMode.None, grid.AutoSizeRowsMode);
+ AssertEquals("BackColor property", Control.DefaultBackColor, grid.BackColor);
+ AssertEquals("BackgroundColor property", SystemColors.AppWorkspace, grid.BackgroundColor);
+ AssertEquals("BorderStyle property", BorderStyle.FixedSingle, grid.BorderStyle);
+ AssertEquals("ClipboardCopyMode property", DataGridViewClipboardCopyMode.EnableWithAutoHeaderText, grid.ClipboardCopyMode);
+ AssertEquals("ColumnHeadersDefaultCellStyle.BackColor property", SystemColors.Control, grid.ColumnHeadersDefaultCellStyle.BackColor);
+ AssertEquals("ColumnHeadersDefaultCellStyle.ForeColor property", SystemColors.WindowText, grid.ColumnHeadersDefaultCellStyle.ForeColor);
+ AssertEquals("ColumnHeadersDefaultCellStyle.SelectionBackColor property", SystemColors.Highlight, grid.ColumnHeadersDefaultCellStyle.SelectionBackColor);
+ AssertEquals("ColumnHeadersDefaultCellStyle.SelectionForeColor property", SystemColors.HighlightText, grid.ColumnHeadersDefaultCellStyle.SelectionForeColor);
+ AssertEquals("ColumnHeadersDefaultCellStyle.Font property", grid.Font, grid.ColumnHeadersDefaultCellStyle.Font);
+ AssertEquals("ColumnHeadersDefaultCellStyle.Alignment property", DataGridViewContentAlignment.MiddleLeft, grid.ColumnHeadersDefaultCellStyle.Alignment);
+ AssertEquals("ColumnHeadersDefaultCellStyle.WrapMode property", DataGridViewTriState.True, grid.ColumnHeadersDefaultCellStyle.WrapMode);
+ AssertEquals("ColumnHeadersHeight property", 23, grid.ColumnHeadersHeight);
+ AssertEquals("ColumnHeadersHeightSizeMode property", DataGridViewColumnHeadersHeightSizeMode.EnableResizing, grid.ColumnHeadersHeightSizeMode);
+ AssertEquals("ColumnHeadersVisible property", true, grid.ColumnHeadersVisible);
+ AssertEquals("DataMember property", String.Empty, grid.DataMember);
+ AssertEquals("DefaultCellStyle.BackColor property", SystemColors.Control, grid.DefaultCellStyle.BackColor);
+ AssertEquals("DefaultCellStyle.ForeColor property", SystemColors.WindowText, grid.DefaultCellStyle.ForeColor);
+ AssertEquals("DefaultCellStyle.SelectionBackColor property", SystemColors.Highlight, grid.DefaultCellStyle.SelectionBackColor);
+ AssertEquals("DefaultCellStyle.SelectionForeColor property", SystemColors.HighlightText, grid.DefaultCellStyle.SelectionForeColor);
+ AssertEquals("DefaultCellStyle.Font property", grid.Font, grid.DefaultCellStyle.Font);
+ AssertEquals("DefaultCellStyle.Alignment property", DataGridViewContentAlignment.MiddleLeft, grid.DefaultCellStyle.Alignment);
+ AssertEquals("DefaultCellStyle.WrapMode property", DataGridViewTriState.True, grid.DefaultCellStyle.WrapMode);
+ AssertEquals("EditMode property", DataGridViewEditMode.EditOnKeystrokeOrF2, grid.EditMode);
+ AssertEquals("Font property", Control.DefaultFont, grid.Font);
+ AssertEquals("ForeColor property", Control.DefaultForeColor, grid.ForeColor);
+ AssertEquals("GridColor property", Color.FromKnownColor(KnownColor.ControlDarkDark), grid.GridColor);
+ AssertEquals("MultiSelect property", true, grid.MultiSelect);
+ AssertEquals("NewRowIndex property", grid.Rows.Count - 1, grid.NewRowIndex);
+ AssertEquals("Padding property", Padding.Empty, grid.Padding);
+ AssertEquals("ReadOnly property", false, grid.ReadOnly);
+ AssertEquals("RowHeadersVisible property", true, grid.RowHeadersVisible);
+ AssertEquals("RowHeadersWidth property", 43, grid.RowHeadersWidth);
+ AssertEquals("SelectionMode property", DataGridViewSelectionMode.RowHeaderSelect, grid.SelectionMode);
+ AssertEquals("ShowCellErrors property", true, grid.ShowCellErrors);
+ AssertEquals("ShowEditingIcon property", true, grid.ShowEditingIcon);
+ AssertEquals("UserSetCursor property", Cursor.Current, grid.UserSetCursor);
+ AssertEquals("VirtualMode property", false, grid.VirtualMode);
+ }
+
+ #region AutoSizeColumnsModeExceptions
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestAutoSizeColumnsModeInvalidEnumArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill | DataGridViewAutoSizeColumnsMode.None;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void TestAutoSizeColumnsModeInvalidOperationException1 () {
+ DataGridView grid = new DataGridView();
+ grid.ColumnHeadersVisible = false;
+ DataGridViewColumn col = new DataGridViewColumn();
+ col.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
+ grid.Columns.Add(col);
+ grid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void TestAutoSizeColumnsModeInvalidOperationException2 () {
+ DataGridView grid = new DataGridView();
+ DataGridViewColumn col = new DataGridViewColumn();
+ col.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
+ col.Frozen = true;
+ grid.Columns.Add(col);
+ grid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ }
+
+ #endregion
+
+ #region AutoSizeRowsModeExceptions
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestAutoSizeRowsModeInvalidEnumArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.AutoSizeRowsMode = (DataGridViewAutoSizeRowsMode) 4;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void TestAutoSizeRowsModeInvalidOperationException1 () {
+ DataGridView grid = new DataGridView();
+ grid.RowHeadersVisible = false;
+ grid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllHeaders;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void TestAutoSizeRowsModeInvalidOperationException2 () {
+ DataGridView grid = new DataGridView();
+ grid.RowHeadersVisible = false;
+ grid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedHeaders;
+ }
+
+ #endregion
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestBackgroundColorArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.BackgroundColor = Color.Empty;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestBorderStyleInvalidEnumArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.BorderStyle = BorderStyle.FixedSingle | BorderStyle.Fixed3D;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestColumnCountArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.ColumnCount = -1;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void TestColumnCountInvalidOperationException () {
+ DataGridView grid = new DataGridView();
+ grid.DataSource = new ArrayList();
+ grid.ColumnCount = 0;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestColumnHeadersHeightArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.ColumnHeadersHeight = 3;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestColumnHeadersHeightSizeModeInvalidEnumArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.ColumnHeadersHeightSizeMode = (DataGridViewColumnHeadersHeightSizeMode) 3;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestCurrentCellArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.CurrentCell = new DataGridViewTextBoxCell();
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestRowHeadersWidthArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.RowHeadersWidth = 3;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestDataGridViewRowHeadersWidthSizeModeInvalidEnumArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.RowHeadersWidthSizeMode = (DataGridViewRowHeadersWidthSizeMode) 5;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestScrollBarsInvalidEnumArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.ScrollBars = (ScrollBars) 4;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestSelectionModeInvalidEnumArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.SelectionMode = (DataGridViewSelectionMode) 5;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestAutoResizeRowsInvalidEnumArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.AutoResizeRows((DataGridViewAutoSizeRowsMode) 4);
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void TestAutoResizeRowsInvalidOperationException1 () {
+ DataGridView grid = new DataGridView();
+ grid.RowHeadersVisible = false;
+ grid.AutoResizeRows(DataGridViewAutoSizeRowsMode.AllHeaders);
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void TestAutoResizeRowsInvalidOperationException2 () {
+ DataGridView grid = new DataGridView();
+ grid.RowHeadersVisible = false;
+ grid.AutoResizeRows(DataGridViewAutoSizeRowsMode.DisplayedHeaders);
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestAutoResizeRowsArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.AutoResizeRows(DataGridViewAutoSizeRowsMode.None);
+ }
+
+ /*
+ [Test]
+ [ExpectedException(typeof(Exception))]
+ public void TestException () {
+ ConcreteCollection myCollection;
+ myCollection = new ConcreteCollection();
+ ....
+ AssertEquals ("#UniqueID", expected, actual);
+ ....
+ Fail ("Message");
+ }
+ */
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ErrorProviderTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ErrorProviderTest.cs
new file mode 100644
index 00000000000..182b9a0673d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ErrorProviderTest.cs
@@ -0,0 +1,98 @@
+//
+// ErrorProviderTest.cs: Test cases for ErrorProvider.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Data;
+using System.Runtime.Remoting;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class ErrorProviderTest
+ {
+
+ [Test]
+ public void ErrorProviderPropertyTest ()
+ {
+ ErrorProvider myErrorProvider = new ErrorProvider ();
+
+ // B
+ Assert.AreEqual (250, myErrorProvider.BlinkRate, "#B1");
+ Assert.AreEqual (ErrorBlinkStyle.BlinkIfDifferentError, myErrorProvider.BlinkStyle, "#B2");
+
+ // C
+ Assert.AreEqual (null, myErrorProvider.ContainerControl, "#C1");
+
+ // D
+ Assert.AreEqual (null, myErrorProvider.DataMember, "#D1");
+ Assert.AreEqual (null, myErrorProvider.DataSource, "#D2");
+
+ // I
+ Assert.AreEqual (16, myErrorProvider.Icon.Height, "#I1");
+ Assert.AreEqual (16, myErrorProvider.Icon.Width, "#I2");
+
+ // S
+ Assert.AreEqual (null, myErrorProvider.Site, "#S1");
+ }
+
+ [Test]
+ public void BindToDateAndErrorsTest ()
+ {
+ ErrorProvider myErrorProvider = new ErrorProvider ();
+ DataSet myDataSet= new DataSet();
+ myErrorProvider.DataSource = myDataSet;
+ myErrorProvider.DataMember = "Customers";
+ Assert.AreEqual (myDataSet, myErrorProvider.DataSource, "#Bind1");
+ Assert.AreEqual ("Customers", myErrorProvider.DataMember, "#Bind2");
+ }
+
+ [Test]
+ public void CanExtendTest ()
+ {
+ Control myControl = new Control ();
+ Form myForm = new Form ();
+ ToolBar myToolBar = new ToolBar ();
+ ErrorProvider myErrorProvider = new ErrorProvider ();
+ Assert.AreEqual (myErrorProvider.CanExtend (myControl), true, "#ext1");
+ Assert.AreEqual (myErrorProvider.CanExtend (myToolBar), false, "#ext2");
+ Assert.AreEqual (myErrorProvider.CanExtend (myForm), false, "#ext3");
+ }
+
+ [Test]
+ public void GetandSetErrorTest ()
+ {
+ Form myForm = new Form ();
+ Label myLabel = new Label ();
+ ErrorProvider myErrorProvider = new ErrorProvider ();
+ myErrorProvider.SetError(myLabel, "New Error msg for Label");
+ Assert.AreEqual ("New Error msg for Label", myErrorProvider.GetError (myLabel), "#getset1");
+ }
+
+ [Test]
+ public void GetandSetIconAlignmentTest ()
+ {
+ TextBox myTextBox = new TextBox ();
+ ErrorProvider myErrorProvider = new ErrorProvider ();
+ myErrorProvider.SetIconAlignment (myTextBox, ErrorIconAlignment.MiddleRight);
+ Assert.AreEqual (ErrorIconAlignment.MiddleRight, myErrorProvider.GetIconAlignment (myTextBox), "#getset2");
+ }
+
+ [Test]
+ public void GetandSetIconPaddingTest ()
+ {
+ Form myForm = new Form ();
+ ErrorProvider myErrorProvider = new ErrorProvider ();
+ myErrorProvider.SetIconPadding (myForm, 2);
+ Assert.AreEqual (2, myErrorProvider.GetIconPadding (myForm), "#getset3");
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormEventTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormEventTest.cs
new file mode 100644
index 00000000000..e396aa1ea51
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormEventTest.cs
@@ -0,0 +1,237 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Threading;
+using System.Globalization;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class FormEvent
+ {
+ static bool eventhandled = false;
+ public void New_EventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test, Ignore ("Manual Intervention")]
+ public void ActivatedTest ()
+ {
+ Form myform = new Form ();
+ myform.Activated += new EventHandler (New_EventHandler);
+ myform.Activate ();
+ myform.ShowDialog ();
+ Assert.AreEqual (true, eventhandled, "#A1");
+ }
+
+ [Test, Ignore ("Manual Intervention")]
+ public void ClosedTest ()
+ {
+ Form myform = new Form ();
+ myform.Closed += new EventHandler (New_EventHandler);
+ eventhandled = false;
+ myform.Close ();
+ myform.ShowDialog ();
+ Assert.AreEqual (true, eventhandled, "#A2");
+ }
+
+ [Test, Ignore ("Manual Intervention")]
+ public void DeactivateTest ()
+ {
+ Form myform = new Form ();
+ myform.Deactivate += new EventHandler (New_EventHandler);
+ eventhandled = false;
+ myform.Close ();
+ myform.Activate ();
+ myform.ShowDialog ();
+ Assert.AreEqual (true, eventhandled, "#A3");
+ }
+
+ [Test, Ignore ("Manual Intervention")]
+ public void LoadTest ()
+ {
+ Form myform = new Form ();
+ myform.Load += new EventHandler (New_EventHandler);
+ eventhandled = false;
+ myform.ShowDialog ();
+ Assert.AreEqual (true, eventhandled, "#A4");
+ myform.Dispose ();
+ }
+
+ class MyForm : Form
+ {
+ public void MaximizeBoundsTest ()
+ {
+ this.MaximizedBounds = new Rectangle (10,10,100,100);
+ }
+ }
+
+ [Test]
+ public void MaximizedBoundsChangedTest ()
+ {
+ MyForm myform = new MyForm ();
+ myform.MaximizedBoundsChanged += new EventHandler (New_EventHandler);
+ eventhandled = false;
+ myform.MaximizeBoundsTest ();
+ Assert.AreEqual (true, eventhandled, "#A5");
+ myform.Dispose ();
+ }
+
+ [Test]
+ public void MaximumSizeChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.MaximumSizeChanged += new EventHandler (New_EventHandler);
+ eventhandled = false;
+ myform.MaximumSize = new Size (500, 500);
+ Assert.AreEqual (true, eventhandled, "#A6");
+ myform.Dispose ();
+ }
+
+ [Test, Ignore ("Manual Intervention")]
+ public void MdiChildActivateTest ()
+ {
+ Form parent = new Form ();
+ Form child = new Form ();
+ parent.IsMdiContainer = true;
+ child.IsMdiContainer = false;
+ child.MdiParent = parent;
+ parent.MdiChildActivate += new EventHandler (New_EventHandler);
+ eventhandled = false;
+ using (parent)
+ {
+ child.Visible = true;
+ parent.Show ();
+ Assert.AreEqual (true, eventhandled, "#A7");
+ eventhandled = false;
+ child.Close ();
+ Assert.AreEqual (true, eventhandled, "#A8");
+ }
+ }
+
+ [Test]
+ public void MinimumSizeChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.MinimumSizeChanged += new EventHandler (New_EventHandler);
+ eventhandled = false;
+ myform.MinimumSize = new Size(100, 100);
+ Assert.AreEqual (true, eventhandled, "#A10");
+ myform.Dispose ();
+ }
+ }
+
+ [TestFixture]
+ public class ClosingEvent
+ {
+ bool cancel = true;
+ CancelEventArgs args = null;
+ public void Closing_Handler (object sender, CancelEventArgs e)
+ {
+ e.Cancel = cancel;
+ args = e;
+ }
+
+ [Test, Ignore ("visual test")]
+ public void ClosingEventTest ()
+ {
+ Form myform = new Form ();
+ myform.Closing += new CancelEventHandler (Closing_Handler);
+ myform.Show ();
+ args = null;
+ myform.Close ();
+ Assert.AreEqual (true, args != null, "#A11");
+ Assert.AreEqual (true, myform.Visible, "#A12");
+ cancel = false;
+ args = null;
+ myform.Close ();
+ Assert.AreEqual (true, args != null, "#A13");
+ Assert.AreEqual (false, myform.Visible, "#A14");
+ }
+ }
+
+ [TestFixture,Ignore ("Test Breaks")]
+ public class InputLanguageChangedEvent
+ {
+ static bool eventhandled = false;
+ public void InputLanguage_Handler (object sender,InputLanguageChangedEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void InputLanguageChangedEventTest ()
+ {
+ Form myform = new Form ();
+ CultureInfo oldci = Thread.CurrentThread.CurrentCulture;
+ CultureInfo oldcui = Thread.CurrentThread.CurrentUICulture;
+ InputLanguage oldil = InputLanguage.CurrentInputLanguage;
+ try
+ {
+ if (InputLanguage.InstalledInputLanguages.Count > 1)
+ {
+ InputLanguage.CurrentInputLanguage = InputLanguage.InstalledInputLanguages[0];
+ myform.InputLanguageChanged += new InputLanguageChangedEventHandler (InputLanguage_Handler);
+ Thread.CurrentThread.CurrentCulture = new CultureInfo ("ta-IN");
+ Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
+ InputLanguage.CurrentInputLanguage = InputLanguage.InstalledInputLanguages[1];
+ Assert.AreEqual (true, eventhandled, "#A15");
+ }
+ }
+ finally
+ {
+ Thread.CurrentThread.CurrentCulture = oldci;
+ Thread.CurrentThread.CurrentUICulture = oldcui;
+ InputLanguage.CurrentInputLanguage = oldil;
+ }
+ }
+ }
+
+ [TestFixture,Ignore ("Test Breaks")]
+ public class InputLanguageChangingdEvent
+ {
+ static bool eventhandled = false;
+ public void InputLangChanging_Handler(object sender,InputLanguageChangingEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void InputLanguageChangingEventTest ()
+ {
+ Form myform = new Form ();
+ CultureInfo oldci = Thread.CurrentThread.CurrentCulture;
+ CultureInfo oldcui = Thread.CurrentThread.CurrentUICulture;
+ InputLanguage oldil = InputLanguage.CurrentInputLanguage;
+ try
+ {
+ if (InputLanguage.InstalledInputLanguages.Count > 1)
+ {
+ InputLanguage.CurrentInputLanguage = InputLanguage.InstalledInputLanguages[0];
+ myform.InputLanguageChanging += new InputLanguageChangingEventHandler (InputLangChanging_Handler);
+ Thread.CurrentThread.CurrentCulture = new CultureInfo ("ta-IN");
+ Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
+ InputLanguage.CurrentInputLanguage = InputLanguage.InstalledInputLanguages[1];
+ Assert.AreEqual (true, eventhandled, "#A16");
+ }
+ }
+ finally
+ {
+ Thread.CurrentThread.CurrentCulture = oldci;
+ Thread.CurrentThread.CurrentUICulture = oldcui;
+ InputLanguage.CurrentInputLanguage = oldil;
+ }
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormTest.cs
new file mode 100644
index 00000000000..c83c72fefd5
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormTest.cs
@@ -0,0 +1,175 @@
+//
+// FormTest.cs: Test cases for Form.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class FormTest
+ {
+ [Test]
+ public void FormPropertyTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ myform.Text = "NewForm";
+ myform.Name = "FormTest";
+ Assert.AreEqual (null, myform.AcceptButton, "#1");
+ //Assert.AreEqual (null, myform.ActiveMdiChild, "#2");
+ //System.NotImplementedException for ActiveMdiChild. Feature not implemented.
+ Assert.AreEqual (false, myform.AutoScale, "#3");
+ Assert.AreEqual (13, myform.AutoScaleBaseSize.Height, "#4");
+ Assert.AreEqual (5, myform.AutoScaleBaseSize.Width, "#5");
+ Assert.AreEqual (null, myform.CancelButton, "#6");
+ Assert.AreEqual (273, myform.ClientSize.Height, "#7");
+ Assert.AreEqual (292, myform.ClientSize.Width, "#8");
+ Assert.AreEqual (true, myform.ControlBox, "#9");
+ Assert.IsTrue (myform.DesktopBounds.X > 0, "#10a");
+ Assert.IsTrue (myform.DesktopBounds.Y > 0, "#10b");
+ Assert.AreEqual (300, myform.DesktopBounds.Height, "#10c");
+ Assert.AreEqual (300, myform.DesktopBounds.Width, "#10d");
+ Assert.IsTrue (myform.DesktopLocation.X > 0, "#11a");
+ Assert.IsTrue (myform.DesktopLocation.Y > 0, "#11b");
+ Assert.AreEqual (DialogResult.None, myform.DialogResult, "#12");
+ Assert.AreEqual (FormBorderStyle.Sizable, myform.FormBorderStyle, "#13");
+ Assert.AreEqual (false, myform.HelpButton, "#14");
+ Assert.AreEqual ("System.Drawing.Icon", myform.Icon.GetType ().ToString (), "#15");
+ Assert.AreEqual (false, myform.IsMdiChild, "#16");
+ Assert.AreEqual (false, myform.IsMdiContainer, "#17");
+ Assert.AreEqual (false, myform.KeyPreview, "#18");
+ Assert.AreEqual (true, myform.MaximizeBox, "#19");
+ Assert.AreEqual (0, myform.MaximumSize.Height, "#20a");
+ Assert.AreEqual (0, myform.MaximumSize.Width, "#20b");
+ Assert.AreEqual (0, myform.MdiChildren.Length, "#21a");
+ Assert.AreEqual (1, myform.MdiChildren.Rank, "#21b");
+ Assert.AreEqual (false, myform.MdiChildren.IsSynchronized, "#21c");
+ Assert.AreEqual (null, myform.MdiParent, "#22");
+ Assert.AreEqual (null, myform.Menu, "#23");
+ //Assert.AreEqual (null, myform.MergedMenu, "#24");
+ //System.NotImplementedException for MergedMenu. Feature not implemented.
+ Assert.AreEqual (true, myform.MinimizeBox, "#25");
+ Assert.AreEqual (0, myform.MinimumSize.Height, "#26a");
+ Assert.AreEqual (0, myform.MinimumSize.Width, "#26b");
+ Assert.AreEqual (true, myform.MinimumSize.IsEmpty, "#26c");
+ Assert.AreEqual (false, myform.Modal, "#27");
+ //Assert.AreEqual (1, myform.Opacity, "#28");
+ //System.NotImplementedException for Opacity. Feature not implemented.
+ Assert.AreEqual (0, myform.OwnedForms.Length, "#29a");
+ Assert.AreEqual (1, myform.OwnedForms.Rank, "#29b");
+ Assert.AreEqual (null, myform.Owner, "#30");
+ Assert.AreEqual (true, myform.ShowInTaskbar, "#31");
+ Assert.AreEqual (300, myform.Size.Height, "#32a");
+ Assert.AreEqual (300, myform.Size.Width, "#32b");
+ Assert.AreEqual (SizeGripStyle.Auto, myform.SizeGripStyle, "#33");
+ Assert.AreEqual (FormStartPosition.WindowsDefaultLocation, myform.StartPosition, "#34");
+ Assert.AreEqual (true, myform.TopLevel, "#35");
+ Assert.AreEqual (false, myform.TopMost, "#36");
+ Assert.AreEqual (Color.Empty, myform.TransparencyKey, "#37");
+ Assert.AreEqual (FormWindowState.Normal, myform.WindowState, "#38");
+ }
+
+ [Test]
+ public void ActivateTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ myform.Text = "NewForm";
+ myform.Name = "FormTest";
+ myform.Activate ();
+ Assert.AreEqual (true, myform.Focus (), "#40");
+ }
+
+ [Test]
+ public void AddOwnedFormTest ()
+ {
+ Form parent = new Form ();
+ parent.Text = "NewParent";
+ Form ownedForm = new Form ();
+ ownedForm.Text = "Owned Form";
+ parent.AddOwnedForm (ownedForm);
+ ownedForm.Show ();
+ Assert.AreEqual ("NewParent", ownedForm.Owner.Text, "#41");
+ }
+
+ [Test]
+ public void CloseTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ myform.Text = "NewForm";
+ myform.Name = "FormTest";
+ myform.Close ();
+ Assert.IsTrue (myform.Size.Height > 0, "#42");
+ }
+
+ [Test]
+ [Ignore ("System.NotImplementedException. LayoutMdi not implemented")]
+ public void LayoutMdiTest ()
+ {
+ Form parent = new Form ();
+ Form child = new Form ();
+ parent.IsMdiContainer = true;
+ child.IsMdiContainer = false;
+ child.MdiParent = parent;
+ parent.LayoutMdi (MdiLayout.TileHorizontal);
+ child.Visible = true;
+ parent.Show ();
+ }
+
+ [Test]
+ public void RemoveOwnedFormTest ()
+ {
+ Form myform = new Form ();
+ myform.Text = "NewForm";
+ myform.Name = "FormTest";
+ myform.RemoveOwnedForm (myform);
+ myform.Show ();
+ Assert.AreEqual (null, myform.Owner, "#44");
+ }
+
+ [Test]
+ public void SetDesktopBoundsTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ myform.Text = "NewForm";
+ myform.Name = "FormTest";
+ myform.SetDesktopBounds (10, 10, 200 , 200);
+ Assert.AreEqual (200, myform.DesktopBounds.Height, "#45");
+ }
+
+ [Test]
+ public void SetDesktopLocationTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ myform.Text = "NewForm";
+ myform.Name = "FormTest";
+ myform.SetDesktopLocation (10, 10);
+ Assert.AreEqual (10, myform.DesktopLocation.X, "#46");
+ }
+
+ [Test, Ignore ("Needs Manual Intervention")]
+ public void ShowDialogTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = false;
+ myform.Text = "NewForm";
+ myform.Name = "FormTest";
+ myform.ShowDialog ();
+ Assert.AreEqual (DialogResult.Cancel, myform.DialogResult, "#47");
+ myform.Dispose ();
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GenerateControlStyleTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GenerateControlStyleTest.cs
new file mode 100644
index 00000000000..9e030762a49
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GenerateControlStyleTest.cs
@@ -0,0 +1,129 @@
+//
+// This code generates the ControlStylesTest.cs test
+//
+// Author: Peter Dennis Bartok (pbartok@novell.com)
+//
+
+
+using System.Windows.Forms;
+using System.Drawing;
+using System;
+using System.Reflection;
+using System.IO;
+using System.Text;
+
+namespace TestApp {
+ class MainForm {
+ static Array style_values = Enum.GetValues(typeof(ControlStyles));
+ static string[] style_names = Enum.GetNames(typeof(ControlStyles));
+ static string TestHeader = "//\n" +
+ "// ControlStyleTest.cs (Auto-generated by GenerateControlStyleTest.cs).\n" +
+ "//\n" +
+ "// Author: \n" +
+ "// Peter Dennis Bartok (pbartok@novell.com)\n" +
+ "//\n" +
+ "// (C) 2005 Novell, Inc. (http://www.novell.com)\n" +
+ "//\n" +
+ "using System;\n" +
+ "using System.Windows.Forms;\n" +
+ "using System.Drawing;\n" +
+ "using System.Reflection;\n" +
+ "using NUnit.Framework;\n\n" +
+ "namespace MonoTests.System.Windows.Forms {\n" +
+ "\t[TestFixture]\n" +
+ "\tpublic class TestControlStyle {\n\n" +
+ "\t\tstatic Array style_values = Enum.GetValues(typeof(ControlStyles));\n" +
+ "\t\tstatic string[] style_names = Enum.GetNames(typeof(ControlStyles));\n\n" +
+ " public static string[] GetStyles(Control control) {\n" +
+ " string[] result;\n\n" +
+ " result = new string[style_names.Length];\n\n" +
+ " for (int i = 0; i < style_values.Length; i++) {\n" +
+ " result[i] = style_names[i] + \"=\" + control.GetType().GetMethod(\"GetStyle\", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(control, new object[1] {(ControlStyles)style_values.GetValue(i)});\n" +
+ " }\n\n" +
+ " return result;\n" +
+ " }\n";
+ static string TestFooter = "\t}\n}\n";
+
+ public static string[] GetStyles(Control control) {
+ string[] result;
+
+ result = new string[style_names.Length];
+
+ for (int i = 0; i < style_values.Length; i++) {
+ result[i] = style_names[i] + "=" + control.GetType().GetMethod("GetStyle", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(control, new object[1] {(ControlStyles)style_values.GetValue(i)});
+ }
+
+ return result;
+ }
+
+ public static void TestStyles(StreamWriter file, Control control, string name) {
+ string[] results;
+
+ results = GetStyles(control);
+
+ file.WriteLine("\t\t[Test]");
+ file.WriteLine("\t\tpublic void {0}StyleTest ()", name);
+ file.WriteLine("\t\t{");
+
+ file.WriteLine("\t\t\tstring[] {0}_want = {{", name);
+ for (int i=0; i < results.Length; i++) {
+ if ((i+1) != results.Length) {
+ file.WriteLine("\t\t\t\t\"{0}\",", results[i]);
+ } else {
+ file.WriteLine("\t\t\t\t\"{0}\"", results[i]);
+ }
+ }
+ file.WriteLine("\t\t\t};\n");
+ file.WriteLine("\t\t\tAssert.AreEqual({0}_want, GetStyles(new {0}()), \"{0}Styles\");", name);
+ file.WriteLine("\t\t}\n\n");
+ }
+
+ public static void Main(string[] args) {
+ using (StreamWriter file = new StreamWriter("c:\\ControlStyleTest.cs", false, Encoding.ASCII, 1024)) {
+ file.WriteLine(TestHeader);
+ TestStyles(file, new Control(), "Control");
+ TestStyles(file, new Button(), "Button");
+ TestStyles(file, new CheckBox(), "CheckBox");
+ TestStyles(file, new RadioButton(), "RadioButton");
+ TestStyles(file, new DataGrid(), "DataGrid");
+ TestStyles(file, new DateTimePicker(), "DateTimePicker");
+ TestStyles(file, new GroupBox(), "GroupBox");
+ TestStyles(file, new Label(), "Label");
+ TestStyles(file, new LinkLabel(), "LinkLabel");
+ TestStyles(file, new ComboBox(), "ComboBox");
+ TestStyles(file, new ListBox(), "ListBox");
+ TestStyles(file, new CheckedListBox(), "CheckedListBox");
+ TestStyles(file, new ListView(), "ListView");
+ TestStyles(file, new MdiClient(), "MdiClient");
+ TestStyles(file, new MonthCalendar(), "MonthCalendar");
+ TestStyles(file, new PictureBox(), "PictureBox");
+ // Mono doesn't support yet
+ //TestStyles(file, new PrintPreviewControl(), "PrintPreviewControl");
+ TestStyles(file, new ProgressBar(), "ProgressBar");
+ TestStyles(file, new ScrollableControl(), "ScrollableControl");
+ TestStyles(file, new ContainerControl(), "ContainerControl");
+ TestStyles(file, new Form(), "Form");
+ TestStyles(file, new PropertyGrid(), "PropertyGrid");
+ TestStyles(file, new DomainUpDown(), "DomainUpDown");
+ TestStyles(file, new NumericUpDown(), "NumericUpDown");
+ TestStyles(file, new UserControl(), "UserControl");
+ TestStyles(file, new Panel(), "Panel");
+ TestStyles(file, new TabPage(), "TabPage");
+ TestStyles(file, new HScrollBar(), "HScrollBar");
+ TestStyles(file, new VScrollBar(), "VScrollBar");
+ TestStyles(file, new Splitter(), "Splitter");
+ TestStyles(file, new StatusBar(), "StatusBar");
+ TestStyles(file, new TabControl(), "TabControl");
+ TestStyles(file, new RichTextBox(), "RichTextBox");
+ TestStyles(file, new TextBox(), "TextBox");
+ TestStyles(file, new DataGridTextBox(), "DataGridTextBox");
+ TestStyles(file, new ToolBar(), "ToolBar");
+ TestStyles(file, new TrackBar(), "TrackBar");
+ TestStyles(file, new TreeView(), "TreeView");
+ file.WriteLine(TestFooter);
+ }
+ }
+ }
+
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridColumnStylesCollectionTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridColumnStylesCollectionTest.cs
new file mode 100644
index 00000000000..ee12067c62e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridColumnStylesCollectionTest.cs
@@ -0,0 +1,199 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ class GridColumnStylesCollectionTest
+ {
+ private bool eventhandled;
+ private object Element;
+ private CollectionChangeAction Action;
+ private int times;
+
+
+ [Test]
+ public void TestDefaultValues ()
+ {
+ DataGridTableStyle ts = new DataGridTableStyle ();
+ GridColumnStylesCollection sc = ts.GridColumnStyles;
+
+ Assert.AreEqual (false, sc.IsSynchronized, "IsSynchronized property");
+ Assert.AreEqual (0, sc.Count, "Count");
+ Assert.AreEqual (sc, sc.SyncRoot, "SyncRoot property");
+ Assert.AreEqual (false, ((IList)sc).IsFixedSize, "IsFixedSize property");
+ Assert.AreEqual (false, sc.IsReadOnly, "IsReadOnly property");
+ }
+
+ [Test]
+ public void TestAdd ()
+ {
+ DataGridTableStyle ts = new DataGridTableStyle ();
+ GridColumnStylesCollection sc = ts.GridColumnStyles;
+ sc.CollectionChanged += new CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ // Add single
+ ResetEventData ();
+ DataGridTextBoxColumn col1 = new DataGridTextBoxColumn ();
+ col1.MappingName = "Column1";
+ sc.Add (col1);
+ Assert.AreEqual (true, eventhandled);
+ Assert.AreEqual (col1, Element);
+ Assert.AreEqual (CollectionChangeAction.Add, Action);
+
+ // Add multiple
+ ResetEventData ();
+ DataGridTextBoxColumn elem1 = new DataGridTextBoxColumn ();
+ DataGridTextBoxColumn elem2 = new DataGridTextBoxColumn ();
+ sc.AddRange (new DataGridTextBoxColumn [] {elem1, elem2});
+ Assert.AreEqual (true, eventhandled, "A1");
+ Assert.AreEqual (CollectionChangeAction.Add, Action, "A2");
+ Assert.AreEqual (elem2, Element, "A3");
+
+ }
+
+ [Test]
+ public void TestAddRange ()
+ {
+ DataGridTableStyle ts = new DataGridTableStyle ();
+ GridColumnStylesCollection sc = ts.GridColumnStyles;
+ sc.CollectionChanged += new CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ ResetEventData ();
+ DataGridTextBoxColumn col1 = new DataGridTextBoxColumn ();
+ col1.MappingName = "Column1";
+
+ DataGridTextBoxColumn col2 = new DataGridTextBoxColumn ();
+ col2.MappingName = "Column2";
+ sc.AddRange (new DataGridColumnStyle[] {col1, col2});
+
+ Assert.AreEqual (true, eventhandled, "A1");
+ Assert.AreEqual (col2, Element, "A2");
+ Assert.AreEqual (CollectionChangeAction.Add, Action, "A3");
+ Assert.AreEqual (2, times, "A4");
+ }
+
+ [Test]
+ public void TestRemove ()
+ {
+ DataGridTableStyle ts = new DataGridTableStyle ();
+ GridColumnStylesCollection sc = ts.GridColumnStyles;
+ sc.CollectionChanged += new CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ // Add single
+ DataGridTextBoxColumn col1 = new DataGridTextBoxColumn ();
+ col1.MappingName = "Column1";
+ sc.Add (col1);
+
+ DataGridTextBoxColumn col2 = new DataGridTextBoxColumn ();
+ col2.MappingName = "Column2";
+ sc.Add (col2);
+
+ DataGridTextBoxColumn col3 = new DataGridTextBoxColumn ();
+ col3.MappingName = "Column3";
+ sc.Add (col3);
+
+ ResetEventData ();
+ sc.Remove (col2);
+ Assert.AreEqual (true, eventhandled, "A1");
+ Assert.AreEqual (col2, Element, "A2");
+ Assert.AreEqual (CollectionChangeAction.Remove, Action, "A3");
+ Assert.AreEqual (2, sc.Count, "A4");
+
+ ResetEventData ();
+ sc.RemoveAt (0);
+ Assert.AreEqual (true, eventhandled, "A5");
+ Assert.AreEqual (col1, Element, "A6");
+ Assert.AreEqual (CollectionChangeAction.Remove, Action, "A6");
+ Assert.AreEqual (1, sc.Count, "A7");
+
+ ResetEventData ();
+ sc.Clear ();
+ Assert.AreEqual (null, Element, "A8");
+ Assert.AreEqual (CollectionChangeAction.Refresh, Action, "A9");
+
+ }
+
+ [Test]
+ public void TestIndexContains ()
+ {
+ DataGridTableStyle ts = new DataGridTableStyle ();
+ GridColumnStylesCollection sc = ts.GridColumnStyles;
+ sc.CollectionChanged += new CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ // Add single
+ DataGridTextBoxColumn col1 = new DataGridTextBoxColumn ();
+ col1.MappingName = "Column1";
+ sc.Add (col1);
+
+ DataGridTextBoxColumn col2 = new DataGridTextBoxColumn ();
+ col2.MappingName = "Column2";
+ sc.Add (col2);
+
+ DataGridTextBoxColumn col3 = new DataGridTextBoxColumn ();
+ col3.MappingName = "Column3";
+ sc.Add (col3);
+
+ ResetEventData ();
+ IList ilist = (IList) sc;
+ Assert.AreEqual (1, ilist.IndexOf (col2), "A1");
+ Assert.AreEqual (false, sc.Contains ("nothing"), "A2");
+ Assert.AreEqual (true, sc.Contains (col3), "A3");
+ }
+
+ private void ResetEventData ()
+ {
+ times = 0;
+ eventhandled = false;
+ Element = null;
+ Action = (CollectionChangeAction) 0;
+ }
+
+ private void OnEventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ private void OnCollectionEventHandler (object sender, CollectionChangeEventArgs e)
+ {
+ eventhandled = true;
+ Element = e.Element;
+ Action = e.Action;
+ times++;
+ }
+
+
+ }
+
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridTableStylesCollectionTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridTableStylesCollectionTest.cs
new file mode 100644
index 00000000000..708f284587b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridTableStylesCollectionTest.cs
@@ -0,0 +1,193 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ class GridTableStylesCollectionTest
+ {
+ private bool eventhandled;
+ private object Element;
+ private CollectionChangeAction Action;
+ private int times;
+
+ [Test]
+ public void TestDefaultValues ()
+ {
+ DataGrid grid = new DataGrid ();
+ GridTableStylesCollection sc = grid.TableStyles;
+
+ Assert.AreEqual (false, sc.IsSynchronized, "IsSynchronized property");
+ Assert.AreEqual (0, sc.Count, "Count");
+ Assert.AreEqual (sc, sc.SyncRoot, "SyncRoot property");
+ Assert.AreEqual (false, ((IList)sc).IsFixedSize, "IsFixedSize property");
+ Assert.AreEqual (false, sc.IsReadOnly, "IsReadOnly property");
+ }
+
+ [Test]
+ public void TestAdd ()
+ {
+ DataGrid grid = new DataGrid ();
+ GridTableStylesCollection sc = grid.TableStyles;
+ sc.CollectionChanged += new CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ // Add single
+ ResetEventData ();
+ DataGridTableStyle ts = new DataGridTableStyle ();
+ ts.MappingName = "Table1";
+ sc.Add (ts);
+ Assert.AreEqual (true, eventhandled, "A1");
+ Assert.AreEqual (ts, Element, "A2");
+ Assert.AreEqual (CollectionChangeAction.Add, Action, "A3");
+
+ // Add multiple
+ ResetEventData ();
+ sc.AddRange (new DataGridTableStyle [] {new DataGridTableStyle (), new DataGridTableStyle ()});
+ Assert.AreEqual (true, eventhandled, "A4");
+ Assert.AreEqual (null, Element, "A5");
+ Assert.AreEqual (CollectionChangeAction.Refresh, Action, "A6");
+ }
+
+ [Test]
+ public void TestAddRange ()
+ {
+ DataGrid grid = new DataGrid ();
+ GridTableStylesCollection sc = grid.TableStyles;
+ sc.CollectionChanged += new CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ ResetEventData ();
+ DataGridTableStyle ts1 = new DataGridTableStyle ();
+ ts1.MappingName = "Table1";
+
+ DataGridTableStyle ts2 = new DataGridTableStyle ();
+ ts2.MappingName = "Table2";
+ sc.AddRange (new DataGridTableStyle[] {ts1, ts2});
+
+ Assert.AreEqual (true, eventhandled, "A1");
+ Assert.AreEqual (null, Element, "A2");
+ Assert.AreEqual (CollectionChangeAction.Refresh, Action, "A3");
+ Assert.AreEqual (1, times, "A4");
+ }
+
+ [Test]
+ public void TestRemove ()
+ {
+ DataGrid grid = new DataGrid ();
+ GridTableStylesCollection sc = grid.TableStyles;
+ sc.CollectionChanged += new CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ // Add single
+ DataGridTableStyle ts1 = new DataGridTableStyle ();
+ ts1.MappingName = "Table1";
+ sc.Add (ts1);
+
+ DataGridTableStyle ts2 = new DataGridTableStyle ();
+ ts2.MappingName = "Table2";
+ sc.Add (ts2);
+
+ DataGridTableStyle ts3 = new DataGridTableStyle ();
+ ts3.MappingName = "Table3";
+ sc.Add (ts3);
+
+ ResetEventData ();
+ sc.Remove (ts2);
+ Assert.AreEqual (true, eventhandled, "A1");
+ Assert.AreEqual (ts2, Element, "A2");
+ Assert.AreEqual (CollectionChangeAction.Remove, Action, "A3");
+ Assert.AreEqual (2, sc.Count, "A4");
+
+ ResetEventData ();
+ sc.RemoveAt (0);
+ Assert.AreEqual (true, eventhandled, "A5");
+ Assert.AreEqual (ts1, Element, "A6");
+ Assert.AreEqual (CollectionChangeAction.Remove, Action, "A7");
+ Assert.AreEqual (1, sc.Count, "A8");
+
+ ResetEventData ();
+ sc.Clear ();
+ Assert.AreEqual (null, Element, "A9");
+ Assert.AreEqual (CollectionChangeAction.Refresh, Action, "A10");
+
+ }
+
+ [Test]
+ public void TestIndexContains ()
+ {
+ DataGrid grid = new DataGrid ();
+ GridTableStylesCollection sc = grid.TableStyles;
+ sc.CollectionChanged += new CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ // Add single
+ DataGridTableStyle ts1 = new DataGridTableStyle ();
+ ts1.MappingName = "Table1";
+ sc.Add (ts1);
+
+ DataGridTableStyle ts2 = new DataGridTableStyle ();
+ ts2.MappingName = "Table2";
+ sc.Add (ts2);
+
+ DataGridTableStyle ts3 = new DataGridTableStyle ();
+ ts3.MappingName = "Table3";
+ sc.Add (ts3);
+
+ ResetEventData ();
+ IList ilist = (IList) sc;
+ Assert.AreEqual (1, ilist.IndexOf (ts2), "A1");
+ Assert.AreEqual (false, sc.Contains ("nothing"), "A2");
+ Assert.AreEqual (true, sc.Contains (ts3), "A3");
+ }
+
+ private void ResetEventData ()
+ {
+ times = 0;
+ eventhandled = false;
+ Element = null;
+ Action = (CollectionChangeAction) 0;
+ }
+
+ private void OnEventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ private void OnCollectionEventHandler (object sender, CollectionChangeEventArgs e)
+ {
+ times++;
+ eventhandled = true;
+ Element = e.Element;
+ Action = e.Action;
+ }
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GroupBoxTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GroupBoxTest.cs
new file mode 100644
index 00000000000..9d9ed081e09
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GroupBoxTest.cs
@@ -0,0 +1,40 @@
+//
+// GroupBoxTest.cs: Test cases for GroupBox.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class GroupBoxTest
+ {
+ [Test]
+ public void GroupBoxPropertyTest ()
+ {
+ Form myform = new Form ();
+ GroupBox mygrpbox = new GroupBox ();
+ RadioButton myradiobutton1 = new RadioButton ();
+ RadioButton myradiobutton2 = new RadioButton ();
+ mygrpbox.Controls.Add (myradiobutton1);
+ mygrpbox.Controls.Add (myradiobutton2);
+ myform.Show ();
+ Assert.AreEqual (FlatStyle.Standard, mygrpbox.FlatStyle, "#1");
+ mygrpbox.FlatStyle = FlatStyle.Popup;
+ Assert.AreEqual (FlatStyle.Popup, mygrpbox.FlatStyle, "#2");
+ mygrpbox.FlatStyle = FlatStyle.Flat;
+ Assert.AreEqual (FlatStyle.Flat, mygrpbox.FlatStyle, "#3");
+ mygrpbox.FlatStyle = FlatStyle.System;
+ Assert.AreEqual (FlatStyle.System, mygrpbox.FlatStyle, "#4");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ImageListTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ImageListTest.cs
new file mode 100644
index 00000000000..f2cf0200890
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ImageListTest.cs
@@ -0,0 +1,94 @@
+//
+// ImageImageListTest.cs: Test cases for ImageImageList.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+using System.Threading;
+
+
+namespace MonoTests.System.Windows.Forms
+{
+
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class ImageListTest
+ {
+ [Test]
+ public void ImageListPropertyTest ()
+ {
+ ImageList myimagelist = new ImageList ();
+
+ // C
+ Assert.AreEqual (ColorDepth.Depth8Bit, myimagelist.ColorDepth, "#C1");
+ myimagelist.ColorDepth = ColorDepth.Depth32Bit;
+ Assert.AreEqual (ColorDepth.Depth32Bit, myimagelist.ColorDepth, "#C2");
+ Assert.AreEqual (0, myimagelist.Images.Count, "#C3");
+ // H
+ Assert.AreEqual (false, myimagelist.HandleCreated, "#H1");
+ myimagelist.Handle.ToInt32 ();
+ Assert.AreEqual (true, myimagelist.HandleCreated, "#H2");
+ Assert.AreEqual ("System.IntPtr", myimagelist.Handle.GetType ().FullName, "#H3");
+
+ // I
+ Image myImage = Image.FromFile("M.gif");
+ myimagelist.Images.Add (myImage);
+ Assert.AreEqual (1, myimagelist.Images.Count, "#I1");
+ Assert.AreEqual (16, myimagelist.ImageSize.Height, "#I2");
+ Assert.AreEqual (16, myimagelist.ImageSize.Width, "#I3");
+ // [MonoTODO ("Add test for ImageStream")]
+ // [MonoTODO ("Test for Draw Method (visual test)")]
+
+ // T
+ Assert.AreEqual (Color.Transparent, myimagelist.TransparentColor, "#T1");
+ }
+
+ [Test]
+ public void ToStringMethodTest ()
+ {
+ ImageList myimagelist = new ImageList ();
+ Assert.AreEqual ("System.Windows.Forms.ImageList Images.Count: 0, ImageSize: {Width=16, Height=16}", myimagelist.ToString (), "#T3");
+ }
+
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class ImageListRecreateHandleEventClass
+ {
+ static bool eventhandled = false;
+ public static void RecreateHandle_EventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void RecreateHandleEvenTest ()
+ {
+ Form myform = new Form ();
+ Graphics mygraphics = null;
+ ImageList myimagelist = new ImageList ();
+ Image myImage = Image.FromFile("M.gif");
+ myimagelist.Images.Add (myImage);
+ myimagelist.ColorDepth = ColorDepth.Depth8Bit;
+ myimagelist.ImageSize = new Size (50,50);
+ myimagelist.RecreateHandle += new EventHandler (RecreateHandle_EventHandler);
+ mygraphics = Graphics.FromHwnd(myform.Handle);
+ myimagelist.Draw(mygraphics, new Point(5, 5), 0);
+ myimagelist.ImageSize = new Size (100,100);
+ Assert.AreEqual (true, eventhandled, "#1");
+ eventhandled = false;
+ myimagelist.Images.Add (myImage);
+ myimagelist.ColorDepth = ColorDepth.Depth32Bit;
+ Assert.AreEqual (true, eventhandled, "#2");
+ }
+
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/LabelPropertyTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/LabelPropertyTest.cs
new file mode 100644
index 00000000000..6b284f50240
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/LabelPropertyTest.cs
@@ -0,0 +1,138 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// $Log: LabelPropertyTest.cs,v $
+// Adding tests for Label
+//
+
+
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Runtime.Remoting;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class LabelTest {
+
+ [Test]
+ public void PubPropTest ()
+ {
+ Label l = new Label ();
+
+ Assert.AreEqual (false, l.AllowDrop , "#1");
+ Assert.AreEqual (false, l.AccessibilityObject == null, "#2");
+ Assert.AreEqual (false , l.AutoSize , "#3");
+ Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Left, l.Anchor, "#4");
+ Assert.AreEqual (false, l.AutoSize, "#5");
+
+ Assert.AreEqual ("Control", l.BackColor.Name , "#6");
+ Assert.AreEqual (null, l.BindingContext, "#7");
+ Assert.AreEqual (null, l.BackgroundImage, "#8");
+ Assert.AreEqual (BorderStyle.None , l.BorderStyle, "#9");
+ Assert.AreEqual (23, l.Bottom, "#10");
+ Assert.AreEqual (new Rectangle (0,0,100,23), l.Bounds, "#11");
+
+ Assert.AreEqual (false, l.CanFocus, "#12");
+ Assert.AreEqual (false, l.CanSelect, "#13");
+ Assert.AreEqual (false, l.Capture, "#14");
+ Assert.AreEqual (true, l.CausesValidation, "#15");
+ Assert.AreEqual (new Rectangle (0,0,100,23), l.ClientRectangle, "#16");
+ Assert.AreEqual (23, l.ClientSize.Height, "#17a");
+ Assert.AreEqual (100, l.ClientSize.Width, "#17b");
+ Assert.AreEqual ("Mono Project, Novell, Inc.", l.CompanyName, "#18");
+ Assert.AreEqual (null, l.Container, "#19");
+ Assert.AreEqual (false, l.ContainsFocus, "#20");
+ Assert.AreEqual (null, l.ContextMenu, "#21");
+ Assert.AreEqual (true, l.Created, "#23");
+ Assert.AreEqual (Cursors.Default , l.Cursor, "#24");
+
+ Assert.AreEqual (false, l.DataBindings == null , "#25");
+ Assert.AreEqual (false, l.Disposing , "#27");
+ Assert.AreEqual (DockStyle.None, l.Dock, "#28");
+
+ Assert.AreEqual (true, l.Enabled, "#29");
+
+ Assert.AreEqual (FlatStyle.Standard, l.FlatStyle, "#30");
+ Assert.AreEqual (false, l.Focused, "#31");
+ Assert.AreEqual (FontFamily.GenericSansSerif, l.Font.FontFamily, "#32");
+ Assert.AreEqual (SystemColors.ControlText, l.ForeColor, "#33");
+
+ Assert.AreEqual (((IWin32Window)l).Handle, l.Handle, "#34");
+ Assert.AreEqual (false, l.HasChildren, "#35");
+ Assert.AreEqual (23, l.Height, "#36");
+
+ Assert.AreEqual (null, l.Image, "#37");
+ Assert.AreEqual (ContentAlignment.MiddleCenter, l.ImageAlign, "#38");
+ Assert.AreEqual (-1, l.ImageIndex, "#39");
+ Assert.AreEqual (null, l.ImageList, "#40");
+ Assert.AreEqual (false, l.InvokeRequired, "#42");
+ Assert.AreEqual (false, l.IsAccessible, "#43");
+ Assert.AreEqual (false, l.IsDisposed, "#44");
+ Assert.AreEqual (true, l.IsHandleCreated, "#45");
+
+ Assert.AreEqual (0, l.Left, "#46");
+ Assert.AreEqual (Point.Empty, l.Location, "#47");
+
+ Assert.AreEqual ("", l.Name, "#48a");
+ l.Name = "New Label";
+ Assert.AreEqual ("New Label", l.Name, "#48b");
+
+ Assert.AreEqual (null, l.Parent, "#49");
+ Assert.AreEqual (16, l.PreferredHeight, "#50");
+ Assert.AreEqual (0, l.PreferredWidth, "#51");
+ Assert.AreEqual ("Novell Mono MWF", l.ProductName, "#52");
+ Assert.AreEqual ("1.1.4322.2032", l.ProductVersion, "#53");
+
+ Assert.AreEqual (false, l.RecreatingHandle, "#54");
+ Assert.AreEqual (null, l.Region, "#55");
+ Assert.AreEqual (100, l.Right, "#56");
+ Assert.AreEqual (RightToLeft.No, l.RightToLeft, "#57");
+
+ Assert.AreEqual (null, l.Site, "#58");
+ Assert.AreEqual (23, l.Size.Height, "#59a");
+ Assert.AreEqual (100, l.Size.Width, "#59b");
+
+ Assert.AreEqual (0, l.TabIndex, "#60");
+ Assert.AreEqual (null, l.Tag, "#61");
+ Assert.AreEqual ("", l.Text, "#62");
+ Assert.AreEqual (ContentAlignment.TopLeft, l.TextAlign, "#63");
+ Assert.AreEqual (0, l.Top, "#64");
+ Assert.AreEqual (null, l.TopLevelControl, "#65");
+
+ Assert.AreEqual (true, l.UseMnemonic, "#66");
+
+ Assert.AreEqual (true, l.Visible, "#67");
+
+ Assert.AreEqual (100, l.Width, "#68");
+ }
+
+ [Test]
+ public void LabelEqualsTest () {
+ Label s1 = new Label ();
+ Label s2 = new Label ();
+ s1.Text = "abc";
+ s2.Text = "abc";
+ Assert.AreEqual (false, s1.Equals (s2), "#69");
+ Assert.AreEqual (true, s1.Equals (s1), "#70");
+ }
+
+ [Test]
+ public void LabelScaleTest () {
+ Label r1 = new Label ();
+ r1.Width = 40;
+ r1.Height = 20 ;
+ r1.Scale (2);
+ Assert.AreEqual (80, r1.Width, "#71");
+ Assert.AreEqual (40, r1.Height, "#72");
+
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/LabelTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/LabelTest.cs
new file mode 100644
index 00000000000..236ee26e3b0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/LabelTest.cs
@@ -0,0 +1,970 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+//
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+
+ public class LabelTest2
+ {
+
+ [Test]
+ public void PubPropTest ()
+ {
+ Label l = new Label ();
+
+ // A
+ Assert.AreEqual (false, l.AutoSize, "A1");
+ l.AutoSize = true;
+ Assert.AreEqual (true, l.AutoSize, "A2");
+ l.AutoSize = false;
+ Assert.AreEqual (false, l.AutoSize, "A3");
+
+ // B
+ Assert.AreEqual (null, l.BackgroundImage, "B1");
+ l.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
+ Assert.IsNotNull (l.BackgroundImage, "B2");
+ Bitmap bmp = (Bitmap)l.BackgroundImage;
+ Assert.IsNotNull (bmp.GetPixel (0, 0), "B3");
+
+ Assert.AreEqual (BorderStyle.None, l.BorderStyle, "B4");
+ l.BorderStyle = BorderStyle.FixedSingle;
+ Assert.AreEqual (BorderStyle.FixedSingle, l.BorderStyle, "B5");
+ l.BorderStyle = BorderStyle.Fixed3D;
+ Assert.AreEqual (BorderStyle.Fixed3D, l.BorderStyle, "B6");
+ l.BorderStyle = BorderStyle.None;
+ Assert.AreEqual (BorderStyle.None, l.BorderStyle, "B7");
+
+ // C
+ string name = l.CompanyName;
+ if (!name.Equals("Mono Project, Novell, Inc.") && !name.Equals("Microsoft Corporation")) {
+ Assert.Fail("CompanyName property does not match any accepted value - C1");
+ }
+
+ // F
+ Assert.AreEqual (FlatStyle.Standard, l.FlatStyle, "F1");
+ l.FlatStyle = FlatStyle.Flat;
+ Assert.AreEqual (FlatStyle.Flat, l.FlatStyle, "F1");
+ l.FlatStyle = FlatStyle.Popup;
+ Assert.AreEqual (FlatStyle.Popup, l.FlatStyle, "F2");
+ l.FlatStyle = FlatStyle.Standard;
+ Assert.AreEqual (FlatStyle.Standard, l.FlatStyle, "F3");
+ l.FlatStyle = FlatStyle.System;
+ Assert.AreEqual (FlatStyle.System, l.FlatStyle, "F4");
+
+ // I
+ Assert.AreEqual (ContentAlignment.MiddleCenter, l.ImageAlign, "I1");
+ l.ImageAlign = ContentAlignment.TopLeft;
+ Assert.AreEqual (ContentAlignment.TopLeft, l.ImageAlign, "I2");
+ l.ImageAlign = ContentAlignment.TopCenter;
+ Assert.AreEqual (ContentAlignment.TopCenter, l.ImageAlign, "I3");
+ l.ImageAlign = ContentAlignment.TopRight;
+ Assert.AreEqual (ContentAlignment.TopRight, l.ImageAlign, "I4");
+ l.ImageAlign = ContentAlignment.MiddleLeft;
+ Assert.AreEqual (ContentAlignment.MiddleLeft, l.ImageAlign, "I5");
+ l.ImageAlign = ContentAlignment.MiddleCenter;
+ Assert.AreEqual (ContentAlignment.MiddleCenter, l.ImageAlign, "I6");
+ l.ImageAlign = ContentAlignment.MiddleRight;
+ Assert.AreEqual (ContentAlignment.MiddleRight, l.ImageAlign, "I7");
+ l.ImageAlign = ContentAlignment.BottomLeft;
+ Assert.AreEqual (ContentAlignment.BottomLeft, l.ImageAlign, "I8");
+ l.ImageAlign = ContentAlignment.BottomCenter;
+ Assert.AreEqual (ContentAlignment.BottomCenter, l.ImageAlign, "I9");
+ l.ImageAlign = ContentAlignment.BottomRight;
+ Assert.AreEqual (ContentAlignment.BottomRight, l.ImageAlign, "I10");
+ Assert.AreEqual (-1, l.ImageIndex, "I11");
+ Assert.AreEqual (null, l.ImageList, "I12");
+ Assert.AreEqual (null, l.Image, "I13");
+ l.Image = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
+ Assert.IsNotNull (l.Image, "I14");
+ bmp = (Bitmap)l.Image;
+ Assert.IsNotNull (bmp.GetPixel (0, 0), "I15");
+
+ ImageList il = new ImageList ();
+ il.ColorDepth = ColorDepth.Depth32Bit;
+ il.ImageSize = new Size (15, 15);
+ il.Images.Add (Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png"));
+ l.ImageList = il;
+ l.ImageIndex = 0;
+
+ Assert.AreEqual (0, l.ImageIndex, "I16");
+ Assert.IsNotNull (l.ImageList, "I17");
+
+ // PreferredHeight
+ // PregerredWidth
+ // RenderTransparent
+ //
+ // T
+ // Assert.AreEqual (false, l.TabStop, "T1");
+ Assert.AreEqual (ContentAlignment.TopLeft, l.TextAlign, "T2");
+
+ // U
+ Assert.AreEqual (true, l.UseMnemonic, "U1");
+ l.UseMnemonic = false;
+ Assert.AreEqual (false, l.UseMnemonic, "U2");
+ }
+
+ [Test]
+ public void LabelEqualsTest ()
+ {
+ Label s1 = new Label ();
+ Label s2 = new Label ();
+ s1.Text = "abc";
+ s2.Text = "abc";
+ Assert.AreEqual (false, s1.Equals (s2), "E1");
+ Assert.AreEqual (true, s1.Equals (s1), "E2");
+ }
+
+ [Test]
+ public void LabelScaleTest ()
+ {
+ Label r1 = new Label ();
+ r1.Width = 40;
+ r1.Height = 20 ;
+ r1.Scale (2);
+ Assert.AreEqual (80, r1.Width, "W1");
+ Assert.AreEqual (40, r1.Height, "H1");
+ }
+
+ [Test]
+ public void PubMethodTest ()
+ {
+ Label l = new Label ();
+
+ l.Text = "My Label";
+
+ Assert.AreEqual ("System.Windows.Forms.Label, Text: My Label", l.ToString (), "T1");
+
+ }
+ }
+
+ [TestFixture]
+ public class LabelEventTest
+ {
+ static bool eventhandled = false;
+ public void Label_EventHandler (object sender,EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ public void Label_KeyDownEventHandler (object sender, KeyEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void AutoSizeChangedChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ Label l = new Label ();
+ l.Visible = true;
+ myform.Controls.Add (l);
+ l.AutoSizeChanged += new EventHandler (Label_EventHandler);
+ l.AutoSize = true;
+ Assert.AreEqual (true, eventhandled, "B4");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void BackgroundImageChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ Label l = new Label ();
+ l.Visible = true;
+ myform.Controls.Add (l);
+ l.BackgroundImageChanged += new EventHandler (Label_EventHandler);
+ l.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
+ Assert.AreEqual (true, eventhandled, "B4");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void ImeModeChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ Label l = new Label ();
+ l.Visible = true;
+ myform.Controls.Add (l);
+ l.ImeModeChanged += new EventHandler (Label_EventHandler);
+ l.ImeMode = ImeMode.Katakana;
+ Assert.AreEqual (true, eventhandled, "I16");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void KeyDownTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ l.Visible = true;
+ myform.Controls.Add (l);
+ l.KeyDown += new KeyEventHandler (Label_KeyDownEventHandler);
+ l.KeyPressA ();
+
+ Assert.AreEqual (true, eventhandled, "K1");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void TabStopChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ Label l = new Label ();
+ l.Visible = true;
+ myform.Controls.Add (l);
+ l.TabStopChanged += new EventHandler (Label_EventHandler);
+ l.TabStop = true;
+ Assert.AreEqual (true, eventhandled, "T3");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void TextAlignChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ Label l = new Label ();
+ l.Visible = true;
+ myform.Controls.Add (l);
+ l.TextAlignChanged += new EventHandler (Label_EventHandler);
+ l.TextAlign = ContentAlignment.TopRight;
+ Assert.AreEqual (true, eventhandled, "T4");
+ eventhandled = false;
+ }
+ }
+
+public class MyLabelInvalidate : MyLabel
+ {
+ //protected ArrayList results = new ArrayList ();
+ public MyLabelInvalidate () : base ()
+ {}
+
+ protected override void OnInvalidated (InvalidateEventArgs e)
+ {
+ base.OnInvalidated (e);
+ string res = (string)results [results.Count - 1];
+ results [results.Count - 1 ] = string.Concat (res, "," + e.InvalidRect.ToString ());
+ //results.Add ("OnInvalidate," + e.InvalidRect.ToString ());
+ }
+
+ //public ArrayList Results {
+ // get { return results; }
+ //}
+
+ }
+
+public class MyLabel : Label
+ {
+ protected ArrayList results = new ArrayList ();
+ public MyLabel () : base ()
+ { }
+
+ protected override void OnAutoSizeChanged (EventArgs e)
+ {
+ results.Add ("OnAutoSizeChanged");
+ base.OnAutoSizeChanged (e);
+ }
+
+ protected override void OnBackgroundImageChanged (EventArgs e)
+ {
+ results.Add ("OnBackgroundImageChanged");
+ base.OnBackgroundImageChanged (e);
+ }
+
+ protected override void OnImeModeChanged (EventArgs e)
+ {
+ results.Add ("OnImeModeChanged");
+ base.OnImeModeChanged (e);
+ }
+
+ protected override void OnKeyDown (KeyEventArgs e)
+ {
+ results.Add ("OnKeyDown,"+(char)e.KeyValue);
+ base.OnKeyDown (e);
+ }
+
+ protected override void OnKeyPress (KeyPressEventArgs e)
+ {
+ results.Add ("OnKeyPress,"+e.KeyChar.ToString ());
+ base.OnKeyPress (e);
+ }
+
+ protected override void OnKeyUp (KeyEventArgs e)
+ {
+ results.Add ("OnKeyUp,"+(char)e.KeyValue);
+ base.OnKeyUp (e);
+ }
+
+ protected override void OnHandleCreated (EventArgs e)
+ {
+ results.Add ("OnHandleCreated");
+ base.OnHandleCreated (e);
+ }
+
+ protected override void OnBindingContextChanged (EventArgs e)
+ {
+ results.Add ("OnBindingContextChanged");
+ base.OnBindingContextChanged (e);
+ }
+
+ protected override void OnInvalidated (InvalidateEventArgs e)
+ {
+ results.Add("OnInvalidated");
+ base.OnInvalidated (e);
+ }
+
+ protected override void OnResize (EventArgs e)
+ {
+ results.Add("OnResize");
+ base.OnResize (e);
+ }
+
+ protected override void OnSizeChanged (EventArgs e)
+ {
+ results.Add("OnSizeChanged");
+ base.OnSizeChanged (e);
+ }
+
+ protected override void OnLayout (LayoutEventArgs e)
+ {
+ results.Add("OnLayout");
+ base.OnLayout (e);
+ }
+
+ protected override void OnVisibleChanged (EventArgs e)
+ {
+ results.Add("OnVisibleChanged");
+ base.OnVisibleChanged (e);
+ }
+
+ protected override void OnPaint (PaintEventArgs e)
+ {
+ results.Add("OnPaint");
+ base.OnPaint (e);
+ }
+
+ public void KeyPressA()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_KEYDOWN;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x41;
+ m.LParam = (IntPtr)0x1e0001;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_CHAR;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x61;
+ m.LParam = (IntPtr)0x1e0001;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_KEYUP;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x41;
+ m.LParam = (IntPtr)unchecked((int)0xC01e0001);
+ this.WndProc(ref m);
+ }
+
+ public void KeyDownA()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_KEYDOWN;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x41;
+ m.LParam = (IntPtr)0x1e0001;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_CHAR;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x61;
+ m.LParam = (IntPtr)0x1e0001;
+ this.WndProc(ref m);
+ }
+
+ public void KeyUpA()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_KEYUP;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x41;
+ m.LParam = (IntPtr)unchecked((int)0xC01e0001);
+ this.WndProc(ref m);
+ }
+
+ public ArrayList Results {
+ get { return results; }
+ }
+ }
+
+ [TestFixture]
+ public class LabelTestEventsOrder
+ {
+ public string [] ArrayListToString (ArrayList arrlist)
+ {
+ string [] retval = new string [arrlist.Count];
+ for (int i = 0; i < arrlist.Count; i++)
+ retval[i] = (string)arrlist[i];
+ return retval;
+ }
+
+ [Test]
+ public void CreateEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ myform.Controls.Add (l);
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void SizeChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnSizeChanged",
+ "OnResize",
+ "OnInvalidated",
+ "OnLayout"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ myform.Controls.Add (l);
+ l.Size = new Size (150, 20);
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void AutoSizeChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnSizeChanged",
+ "OnResize",
+ "OnInvalidated",
+ "OnLayout",
+ "OnAutoSizeChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ myform.Controls.Add (l);
+ l.AutoSize = true;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void BackgroundImageChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnBackgroundImageChanged",
+ "OnInvalidated"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ myform.Controls.Add (l);
+ l.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void ImeModeChangedChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnImeModeChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ myform.Controls.Add (l);
+ l.ImeMode = ImeMode.Katakana;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void KeyPressEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnKeyDown,A",
+ "OnKeyPress,a",
+ "OnKeyUp,A"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ myform.Controls.Add (l);
+ l.KeyPressA ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void TabStopChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ myform.Controls.Add (l);
+ l.TabStop = true;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void TextAlignChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnInvalidated"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ myform.Controls.Add (l);
+ l.TextAlign = ContentAlignment.TopRight;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void InvalidateEventsOrder ()
+ {
+ Rectangle rect = new Rectangle (new Point (0,0), new Size (2, 2));
+
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabelInvalidate l = new MyLabelInvalidate ();
+ myform.Controls.Add (l);
+ l.TextAlign = ContentAlignment.TopRight;
+
+ string [] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnInvalidated,{X=0,Y=0,Width="+l.Size.Width+",Height="+l.Size.Height+"}",
+ "OnInvalidated," + rect.ToString ()
+ };
+
+ l.Invalidate (rect);
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+
+ }
+
+ [Test]
+ public void PaintEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnInvalidated",
+ "OnInvalidated",
+ "OnPaint"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ myform.Controls.Add (l);
+ l.TextAlign = ContentAlignment.TopRight;
+ l.Refresh ();
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ }
+
+public class MyLabel2 : Label
+ {
+ protected ArrayList results = new ArrayList ();
+ public MyLabel2 () : base ()
+ {
+ this.AutoSizeChanged += new EventHandler (AutoSizeChanged_Handler);
+ this.HandleCreated += new EventHandler (HandleCreated_Handler);
+ this.BindingContextChanged += new EventHandler (BindingContextChanged_Handler);
+ this.BackgroundImageChanged += new EventHandler (BackgroundImageChanged_Handler);
+ this.ImeModeChanged += new EventHandler (ImeModeChanged_Handler);
+ this.KeyDown += new KeyEventHandler (KeyDown_Handler);
+ this.KeyPress += new KeyPressEventHandler (KeyPress_Handler);
+ this.KeyUp += new KeyEventHandler (KeyUp_Handler);
+ this.Invalidated += new InvalidateEventHandler (Invalidated_Handler);
+ this.Resize += new EventHandler (Resize_Handler);
+ this.SizeChanged += new EventHandler (SizeChanged_Handler);
+ this.Layout += new LayoutEventHandler (Layout_Handler);
+ this.VisibleChanged += new EventHandler (VisibleChanged_Handler);
+ this.Paint += new PaintEventHandler (Paint_Handler);
+ }
+
+ protected void AutoSizeChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("AutoSizeChanged");
+ }
+
+ protected void BackgroundImageChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("BackgroundImageChanged");
+ }
+
+ protected void ImeModeChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("ImeModeChanged");
+ }
+
+ protected void KeyDown_Handler (object sender, KeyEventArgs e)
+ {
+ results.Add ("KeyDown,"+(char)e.KeyValue);
+ }
+
+ protected void KeyPress_Handler (object sender, KeyPressEventArgs e)
+ {
+ results.Add ("KeyPress,"+e.KeyChar.ToString ());
+ }
+
+ protected void KeyUp_Handler (object sender, KeyEventArgs e)
+ {
+ results.Add ("KeyUp,"+(char)e.KeyValue);
+ }
+
+ protected void HandleCreated_Handler (object sender, EventArgs e)
+ {
+ results.Add ("HandleCreated");
+ }
+
+ protected void BindingContextChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("BindingContextChanged");
+ }
+
+ protected void Invalidated_Handler (object sender, InvalidateEventArgs e)
+ {
+ results.Add("Invalidated");
+ }
+
+ protected void Resize_Handler (object sender, EventArgs e)
+ {
+ results.Add("Resize");
+ }
+
+ protected void SizeChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add("SizeChanged");
+ }
+
+ protected void Layout_Handler (object sender, LayoutEventArgs e)
+ {
+ results.Add("Layout");
+ }
+
+ protected void VisibleChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add("VisibleChanged");
+ }
+
+ protected void Paint_Handler (object sender, PaintEventArgs e)
+ {
+ results.Add("Paint");
+ }
+
+ public void KeyPressA()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_KEYDOWN;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x41;
+ m.LParam = (IntPtr)0x1e0001;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_CHAR;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x61;
+ m.LParam = (IntPtr)0x1e0001;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_KEYUP;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x41;
+ m.LParam = (IntPtr)unchecked((int)0xC01e0001);
+ this.WndProc(ref m);
+ }
+
+ public void KeyDownA()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_KEYDOWN;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x41;
+ m.LParam = (IntPtr)0x1e0001;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_CHAR;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x61;
+ m.LParam = (IntPtr)0x1e0001;
+ this.WndProc(ref m);
+ }
+
+ public void KeyUpA()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_KEYUP;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x41;
+ m.LParam = (IntPtr)unchecked((int)0xC01e0001);
+ this.WndProc(ref m);
+ }
+
+ public ArrayList Results {
+ get { return results; }
+ }
+ }
+
+ [TestFixture]
+ public class LabelTestEventsOrder2
+ {
+ public string [] ArrayListToString (ArrayList arrlist)
+ {
+ string [] retval = new string [arrlist.Count];
+ for (int i = 0; i < arrlist.Count; i++)
+ retval[i] = (string)arrlist[i];
+ return retval;
+ }
+
+ [Test]
+ public void CreateEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel2 l = new MyLabel2 ();
+ myform.Controls.Add (l);
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void SizeChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Invalidated",
+ "Layout",
+ "Resize",
+ "SizeChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel2 l = new MyLabel2 ();
+ myform.Controls.Add (l);
+ l.Size = new Size (150, 20);
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void AutoSizeChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Invalidated",
+ "Layout",
+ "Resize",
+ "SizeChanged",
+ "AutoSizeChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel2 l = new MyLabel2 ();
+ myform.Controls.Add (l);
+ l.AutoSize = true;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void BackgroundImageChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Invalidated",
+ "BackgroundImageChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel2 l = new MyLabel2 ();
+ myform.Controls.Add (l);
+ l.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void ImeModeChangedChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "ImeModeChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel2 l = new MyLabel2 ();
+ myform.Controls.Add (l);
+ l.ImeMode = ImeMode.Katakana;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void KeyPressEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "KeyDown,A",
+ "KeyPress,a",
+ "KeyUp,A"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel2 l = new MyLabel2 ();
+ myform.Controls.Add (l);
+ l.KeyPressA ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void TabStopChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel2 l = new MyLabel2 ();
+ myform.Controls.Add (l);
+ l.TabStop = true;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void TextAlignChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Invalidated"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel2 l = new MyLabel2 ();
+ myform.Controls.Add (l);
+ l.TextAlign = ContentAlignment.TopRight;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void PaintEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Invalidated",
+ "Invalidated",
+ "Paint"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel2 l = new MyLabel2 ();
+ myform.Controls.Add (l);
+ l.TextAlign = ContentAlignment.TopRight;
+ l.Refresh ();
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ }
+
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListBoxEventTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListBoxEventTest.cs
new file mode 100644
index 00000000000..65d35511832
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListBoxEventTest.cs
@@ -0,0 +1,65 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class ListBoxDrawItemEvent
+ {
+ static bool eventhandled = false;
+ public void DrawItem_EventHandler (object sender,DrawItemEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void DrawItemTest ()
+ {
+ Form myform = new Form ();
+ ListBox lb1 = new ListBox ();
+ lb1.Items.Add ("A");
+ // Test DrawItem Event
+ lb1.DrawItem += new DrawItemEventHandler (DrawItem_EventHandler);
+ lb1.DrawMode = DrawMode.OwnerDrawFixed;
+ myform.Controls.Add (lb1);
+ myform.Show ();
+ Assert.AreEqual (true, eventhandled, "#A1");
+ }
+
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class ListBoxMeasureItemEvent
+ {
+ static bool eventhandled = false;
+ public void MeasureItem_EventHandler (object sender,MeasureItemEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void MeasureItemTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ListBox lb1 = new ListBox ();
+ lb1.Items.Add ("B");
+ lb1.Visible = true;
+ myform.Controls.Add (lb1);
+ // Test MeasureItem Event
+ lb1.MeasureItem += new MeasureItemEventHandler (MeasureItem_EventHandler);
+ lb1.DrawMode = DrawMode.OwnerDrawVariable;
+ Assert.AreEqual (true, eventhandled, "#A2");
+ }
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListBoxTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListBoxTest.cs
new file mode 100644
index 00000000000..4a620408656
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListBoxTest.cs
@@ -0,0 +1,353 @@
+//
+// ComboBoxTest.cs: Test cases for ComboBox.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Authors:
+// Ritvik Mayank <mritvik@novell.com>
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+using System.Collections;
+using System.ComponentModel;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class ListBoxTest
+ {
+ ListBox listBox;
+ Form form;
+
+ [SetUp]
+ public void SetUp()
+ {
+ listBox = new ListBox();
+ form = new Form();
+ }
+
+ [Test]
+ public void ListBoxPropertyTest ()
+ {
+ Assert.AreEqual (0, listBox.ColumnWidth, "#1");
+ Assert.AreEqual (DrawMode.Normal, listBox.DrawMode, "#2");
+ Assert.AreEqual (0, listBox.HorizontalExtent, "#3");
+ Assert.AreEqual (false, listBox.HorizontalScrollbar, "#4");
+ Assert.AreEqual (true, listBox.IntegralHeight, "#5");
+ //Assert.AreEqual (13, listBox.ItemHeight, "#6"); // Note: Item height depends on the current font.
+ listBox.Items.Add ("a");
+ listBox.Items.Add ("b");
+ listBox.Items.Add ("c");
+ Assert.AreEqual (3, listBox.Items.Count, "#7");
+ Assert.AreEqual (false, listBox.MultiColumn, "#8");
+ //Assert.AreEqual (46, listBox.PreferredHeight, "#9"); // Note: Item height depends on the current font.
+ //Assert.AreEqual (RightToLeft.No , listBox.RightToLeft, "#10"); // Depends on Windows version
+ Assert.AreEqual (false, listBox.ScrollAlwaysVisible, "#11");
+ Assert.AreEqual (-1, listBox.SelectedIndex, "#12");
+ listBox.SetSelected (2,true);
+ Assert.AreEqual (2, listBox.SelectedIndices[0], "#13");
+ Assert.AreEqual ("c", listBox.SelectedItem, "#14");
+ Assert.AreEqual ("c", listBox.SelectedItems[0], "#15");
+ Assert.AreEqual (SelectionMode.One, listBox.SelectionMode, "#16");
+ listBox.SetSelected (2,false);
+ Assert.AreEqual (false, listBox.Sorted, "#17");
+ Assert.AreEqual ("", listBox.Text, "#18");
+ Assert.AreEqual (0, listBox.TopIndex, "#19");
+ Assert.AreEqual (true, listBox.UseTabStops, "#20");
+ }
+
+ [Test]
+ public void BeginEndUpdateTest ()
+ {
+ form.Visible = true;
+ listBox.Items.Add ("A");
+ listBox.Visible = true;
+ form.Controls.Add (listBox);
+ listBox.BeginUpdate ();
+ for (int x = 1; x < 5000; x++)
+ {
+ listBox.Items.Add ("Item " + x.ToString ());
+ }
+ listBox.EndUpdate ();
+ listBox.SetSelected (1, true);
+ listBox.SetSelected (3, true);
+ Assert.AreEqual (true, listBox.SelectedItems.Contains ("Item 3"), "#21");
+ }
+
+ [Test]
+ public void ClearSelectedTest ()
+ {
+ form.Visible = true;
+ listBox.Items.Add ("A");
+ listBox.Visible = true;
+ form.Controls.Add (listBox);
+ listBox.SetSelected (0, true);
+ Assert.AreEqual ("A", listBox.SelectedItems [0].ToString (),"#22");
+ listBox.ClearSelected ();
+ Assert.AreEqual (0, listBox.SelectedItems.Count,"#23");
+ }
+
+ [Ignore ("It depends on user system settings")]
+ public void GetItemHeightTest ()
+ {
+ listBox.Visible = true;
+ form.Controls.Add (listBox);
+ listBox.Items.Add ("A");
+ Assert.AreEqual (13, listBox.GetItemHeight (0) , "#28");
+ }
+
+ [Ignore ("It depends on user system settings")]
+ public void GetItemRectangleTest ()
+ {
+ form.Visible = true;
+ listBox.Visible = true;
+ form.Controls.Add (listBox);
+ listBox.Items.Add ("A");
+ Assert.AreEqual (new Rectangle(0,0,116,13), listBox.GetItemRectangle (0), "#29");
+ }
+
+ [Test]
+ public void GetSelectedTest ()
+ {
+ listBox.Items.Add ("A");
+ listBox.Items.Add ("B");
+ listBox.Items.Add ("C");
+ listBox.Items.Add ("D");
+ listBox.Sorted = true;
+ listBox.SetSelected (0,true);
+ listBox.SetSelected (2,true);
+ listBox.TopIndex=0;
+ Assert.AreEqual (true, listBox.GetSelected (0), "#30");
+ listBox.SetSelected (2,false);
+ Assert.AreEqual (false, listBox.GetSelected (2), "#31");
+ }
+
+ [Test]
+ public void IndexFromPointTest ()
+ {
+ listBox.Items.Add ("A");
+ Point pt = new Point (100,100);
+ listBox.IndexFromPoint (pt);
+ Assert.AreEqual (-1, listBox.IndexFromPoint (100,100), "#32");
+ }
+
+ [Test]
+ public void FindStringTest ()
+ {
+ listBox.FindString ("Hola", -5); // No exception, it's empty
+ int x = listBox.FindString ("Hello");
+ Assert.AreEqual (-1, x, "#19");
+ listBox.Items.AddRange(new object[] {"ACBD", "ABDC", "ACBD", "ABCD"});
+ String myString = "ABC";
+ x = listBox.FindString (myString);
+ Assert.AreEqual (3, x, "#191");
+ x = listBox.FindString (string.Empty);
+ Assert.AreEqual (0, x, "#192");
+ x = listBox.FindString ("NonExistant");
+ Assert.AreEqual (-1, x, "#193");
+ }
+
+ [Test]
+ public void FindStringExactTest ()
+ {
+ listBox.FindStringExact ("Hola", -5); // No exception, it's empty
+ int x = listBox.FindStringExact ("Hello");
+ Assert.AreEqual (-1, x, "#20");
+ listBox.Items.AddRange (new object[] {"ABCD","ABC","ABDC"});
+ String myString = "ABC";
+ x = listBox.FindStringExact (myString);
+ Assert.AreEqual (1, x, "#201");
+ x = listBox.FindStringExact (string.Empty);
+ Assert.AreEqual (-1, x, "#202");
+ x = listBox.FindStringExact ("NonExistant");
+ Assert.AreEqual (-1, x, "#203");
+ }
+
+ //
+ // Exceptions
+ //
+
+ [Test]
+ [ExpectedException (typeof (InvalidEnumArgumentException))]
+ public void BorderStyleException ()
+ {
+ listBox.BorderStyle = (BorderStyle) 10;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ColumnWidthException ()
+ {
+ listBox.ColumnWidth = -1;
+ }
+
+ [Test]
+ [ExpectedException (typeof (InvalidEnumArgumentException))]
+ public void DrawModeException ()
+ {
+ listBox.DrawMode = (DrawMode) 10;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void DrawModeAndMultiColumnException ()
+ {
+ listBox.MultiColumn = true;
+ listBox.DrawMode = DrawMode.OwnerDrawVariable;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void ItemHeightException ()
+ {
+ listBox.ItemHeight = 256;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void SelectedIndexException ()
+ {
+ listBox.SelectedIndex = -2;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void SelectedIndexModeNoneException ()
+ {
+ listBox.SelectionMode = SelectionMode.None;
+ listBox.SelectedIndex = -1;
+ }
+
+ [Test]
+ [ExpectedException (typeof (InvalidEnumArgumentException))]
+ public void SelectionModeException ()
+ {
+ listBox.SelectionMode = (SelectionMode) 10;
+ }
+
+ [Test][ExpectedException(typeof(InvalidOperationException))]
+ public void SelectedValueNull()
+ {
+ listBox.SelectedValue = null;
+ }
+
+ [Test][ExpectedException(typeof(InvalidOperationException))]
+ public void SelectedValueEmptyString()
+ {
+ listBox.SelectedValue = String.Empty;
+ }
+
+ //
+ // Events
+ //
+ private bool eventFired;
+
+ private void GenericHandler (object sender, EventArgs e)
+ {
+ eventFired = true;
+ }
+
+
+ }
+
+ [TestFixture]
+ public class ListBoxObjectCollectionTest
+ {
+ ListBox.ObjectCollection col;
+
+ [SetUp]
+ public void SetUp()
+ {
+ col = new ListBox.ObjectCollection (new ListBox ());
+ }
+
+ [Test]
+ public void DefaultProperties ()
+ {
+ Assert.AreEqual (false, col.IsReadOnly, "#B1");
+ Assert.AreEqual (false, ((ICollection)col).IsSynchronized, "#B2");
+ Assert.AreEqual (col, ((ICollection)col).SyncRoot, "#B3");
+ Assert.AreEqual (false, ((IList)col).IsFixedSize, "#B4");
+ Assert.AreEqual (0, col.Count);
+ }
+
+ [Test]
+ public void AddTest ()
+ {
+ col.Add ("Item1");
+ col.Add ("Item2");
+ Assert.AreEqual (2, col.Count, "#C1");
+ }
+
+ [Test]
+ public void ClearTest ()
+ {
+ col.Add ("Item1");
+ col.Add ("Item2");
+ col.Clear ();
+ Assert.AreEqual (0, col.Count, "#D1");
+ }
+
+ [Test]
+ public void ContainsTest ()
+ {
+ object obj = "Item1";
+ col.Add (obj);
+ Assert.AreEqual (true, col.Contains ("Item1"), "#E1");
+ Assert.AreEqual (false, col.Contains ("Item2"), "#E2");
+ }
+
+ [Test]
+ public void IndexOfTest ()
+ {
+ col.Add ("Item1");
+ col.Add ("Item2");
+ Assert.AreEqual (1, col.IndexOf ("Item2"), "#F1");
+ }
+
+ [Test]
+ public void RemoveTest ()
+ {
+ col.Add ("Item1");
+ col.Add ("Item2");
+ col.Remove ("Item1");
+ Assert.AreEqual (1, col.Count, "#G1");
+ }
+
+ [Test]
+ public void RemoveAtTest ()
+ {
+ col.Add ("Item1");
+ col.Add ("Item2");
+ col.RemoveAt (0);
+ Assert.AreEqual (1, col.Count, "#H1");
+ Assert.AreEqual (true, col.Contains ("Item2"), "#H1");
+ }
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewCollectionsTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewCollectionsTest.cs
new file mode 100644
index 00000000000..3cde0af7b9f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewCollectionsTest.cs
@@ -0,0 +1,243 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using System.Collections;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class ListViewCollectionsTest
+ {
+ /*
+ ColumnHeaderCollection
+ */
+ [Test]
+ public void ColumnHeaderCollectionTest_PropertiesTest ()
+ {
+ ListView listview = new ListView ();
+
+ // Properties
+ Assert.AreEqual (false, listview.Columns.IsReadOnly, "ColumnHeaderCollectionTest_PropertiesTest#1");
+ Assert.AreEqual (true, ((ICollection)listview.Columns).IsSynchronized, "ColumnHeaderCollectionTest_PropertiesTest#2");
+ Assert.AreEqual (listview.Columns, ((ICollection)listview.Columns).SyncRoot, "ColumnHeaderCollectionTest_PropertiesTest#3");
+ Assert.AreEqual (false, ((IList)listview.Columns).IsFixedSize, "ColumnHeaderCollectionTest_PropertiesTest#4");
+ Assert.AreEqual (0, listview.Columns.Count, "ColumnHeaderCollectionTest_PropertiesTest#5");
+ }
+
+ [Test]
+ public void ColumnHeaderCollectionTest_AddTest ()
+ {
+ ListView listview = new ListView ();
+
+ // Duplicated elements with same text added
+ listview.Columns.Add (new ColumnHeader ());
+ listview.Columns.Add (new ColumnHeader ());
+ Assert.AreEqual (2, listview.Columns.Count, "ColumnHeaderCollectionTest_AddTest#1");
+ Assert.AreEqual ("ColumnHeader", listview.Columns[0].Text, "ColumnHeaderCollectionTest_AddTest#2");
+ }
+
+ [Test]
+ public void ColumnHeaderCollectionTest_ClearTest ()
+ {
+ ListView listview = new ListView ();
+
+ // Duplicated elements with same text added
+ listview.Columns.Add (new ColumnHeader ());
+ listview.Columns.Clear ();
+ Assert.AreEqual (0, listview.Columns.Count, "ColumnHeaderCollectionTest_ClearTest#1");
+ }
+
+ // Exceptions
+ [Test, ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void ColumnHeaderCollectionTest_GetItem_ExceptionTest ()
+ {
+ // Duplicated elements not added
+ ListView listview = new ListView ();
+ ColumnHeader item = listview.Columns[5];
+ }
+
+ /*
+ CheckedIndexCollection
+ */
+ [Test]
+ public void CheckedIndexCollectionTest_PropertiesTest ()
+ {
+ ListView listview = new ListView ();
+
+ // Properties
+ Assert.AreEqual (true, listview.CheckedIndices.IsReadOnly, "CheckedIndexCollectionTest_PropertiesTest#1");
+ Assert.AreEqual (false, ((ICollection)listview.CheckedIndices).IsSynchronized, "CheckedIndexCollectionTest_PropertiesTest#2");
+ Assert.AreEqual (listview.CheckedIndices, ((ICollection)listview.CheckedIndices).SyncRoot, "CheckedIndexCollectionTest_PropertiesTest#3");
+ Assert.AreEqual (true, ((IList)listview.CheckedIndices).IsFixedSize, "CheckedIndexCollectionTest_PropertiesTest#4");
+ Assert.AreEqual (0, listview.CheckedIndices.Count, "CheckedIndexCollectionTest_PropertiesTest#5");
+ }
+
+
+ // Exceptions
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void CheckedIndexCollectionTest_Add_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.CheckedIndices).Add (5);
+ }
+
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void CheckedIndexCollectionTest_Remove_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.CheckedIndices).Remove (5);
+ }
+
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void CheckedIndexCollectionTest_RemoveAt_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.CheckedIndices).RemoveAt (5);
+ }
+
+ /*
+ CheckedItemCollection
+ */
+ [Test]
+ public void CheckedItemCollectionTest_PropertiesTest ()
+ {
+ ListView listview = new ListView ();
+
+ // Properties
+ Assert.AreEqual (true, listview.CheckedItems.IsReadOnly, "CheckedItemCollectionTest_PropertiesTest#1");
+ Assert.AreEqual (false, ((ICollection)listview.CheckedItems).IsSynchronized, "CheckedItemCollectionTest_PropertiesTest#2");
+ Assert.AreEqual (listview.CheckedItems, ((ICollection)listview.CheckedItems).SyncRoot, "CheckedItemCollectionTest_PropertiesTest#3");
+ Assert.AreEqual (true, ((IList)listview.CheckedItems).IsFixedSize, "CheckedItemCollectionTest_PropertiesTest#4");
+ Assert.AreEqual (0, listview.CheckedItems.Count, "CheckedItemCollectionTest_PropertiesTest#5");
+ }
+
+
+ // Exceptions
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void CheckedItemCollectionTest_PropertiesTest_Add_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.CheckedItems).Add (5);
+ }
+
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void CheckedItemCollectionTest_PropertiesTest_Remove_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.CheckedItems).Remove (5);
+ }
+
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void CheckedItemCollectionTest_PropertiesTest_RemoveAt_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.CheckedItems).RemoveAt (5);
+ }
+
+ /*
+ SelectedIndexCollection
+ */
+ [Test]
+ public void SelectedIndexCollectionTest_PropertiesTest ()
+ {
+ ListView listview = new ListView ();
+
+ // Properties
+ Assert.AreEqual (true, listview.SelectedIndices.IsReadOnly, "SelectedIndexCollectionTest_PropertiesTest#1");
+ Assert.AreEqual (false, ((ICollection)listview.SelectedIndices).IsSynchronized, "SelectedIndexCollectionTest_PropertiesTest#2");
+ Assert.AreEqual (listview.SelectedIndices, ((ICollection)listview.SelectedIndices).SyncRoot, "SelectedIndexCollectionTest_PropertiesTest#3");
+ Assert.AreEqual (true, ((IList)listview.SelectedIndices).IsFixedSize, "SelectedIndexCollectionTest_PropertiesTest#4");
+ Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_PropertiesTest#5");
+ }
+
+
+ // Exceptions
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void SelectedIndexCollectionTest_Add_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.SelectedIndices).Add (5);
+ }
+
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void SelectedIndexCollectionTest_Remove_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.SelectedIndices).Remove (5);
+ }
+
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void SelectedIndexCollectionTest_RemoveAt_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.SelectedIndices).RemoveAt (5);
+ }
+
+ /*
+ SelectedItemCollection
+ */
+ [Test]
+ public void SelectedItemCollectionTest_PropertiesTest ()
+ {
+ ListView listview = new ListView ();
+
+ // Properties
+ Assert.AreEqual (true, listview.SelectedItems.IsReadOnly, "SelectedItemCollectionTest_PropertiesTest#1");
+ Assert.AreEqual (false, ((ICollection)listview.SelectedItems).IsSynchronized, "SelectedItemCollectionTest_PropertiesTest#2");
+ Assert.AreEqual (listview.SelectedItems, ((ICollection)listview.SelectedItems).SyncRoot, "SelectedItemCollectionTest_PropertiesTest#3");
+ Assert.AreEqual (true, ((IList)listview.SelectedItems).IsFixedSize, "SelectedItemCollectionTest_PropertiesTest#4");
+ Assert.AreEqual (0, listview.SelectedItems.Count, "SelectedItemCollectionTest_PropertiesTest#5");
+ }
+
+
+ // Exceptions
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void SelectedItemCollectionTest_PropertiesTest_Add_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.SelectedItems).Add (5);
+ }
+
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void SelectedItemCollectionTest_PropertiesTest_Remove_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.SelectedItems).Remove (5);
+ }
+
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void SelectedItemCollectionTest_PropertiesTest_RemoveAt_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.SelectedItems).RemoveAt (5);
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewEventTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewEventTest.cs
new file mode 100644
index 00000000000..9294bc2a168
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewEventTest.cs
@@ -0,0 +1,208 @@
+//
+// ListViewEventTest.cs: Test cases for ListView events.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture, Ignore ("Needs Manual Intervention")]
+ public class ListViewEvent
+ {
+ static bool eventhandled = false;
+ public void LabelEdit_EventHandler (object sender,LabelEditEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void AfterLabelEditTest ()
+ {
+ Form myform = new Form ();
+ ListView mylistview = new ListView ();
+ mylistview.LabelEdit = true ;
+ mylistview.AfterLabelEdit += new LabelEditEventHandler (LabelEdit_EventHandler);
+ mylistview.View = View.Details;
+ mylistview.SetBounds (10, 10, 200, 200, BoundsSpecified.All);
+ mylistview.Columns.Add ("A", -2, HorizontalAlignment.Center);
+ mylistview.Columns.Add ("B", -2, HorizontalAlignment.Center);
+ ListViewItem item1 = new ListViewItem ("A", -1);
+ mylistview.Items.Add (item1);
+ myform.Controls.Add (mylistview);
+ myform.ShowDialog ();
+ Assert.AreEqual (true, eventhandled, "#A1");
+ }
+
+ [Test]
+ public void BeforeLabelEditTest ()
+ {
+ Form myform = new Form ();
+ ListView mylistview = new ListView ();
+ mylistview.LabelEdit = true ;
+ mylistview.BeforeLabelEdit += new LabelEditEventHandler (LabelEdit_EventHandler);
+ eventhandled = false;
+ mylistview.View = View.Details;
+ mylistview.SetBounds (10, 10, 200, 200, BoundsSpecified.All);
+ mylistview.Columns.Add ("A", -2, HorizontalAlignment.Center);
+ mylistview.Columns.Add ("B", -2, HorizontalAlignment.Center);
+ ListViewItem item1 = new ListViewItem ("A", -1);
+ mylistview.Items.Add (item1);
+ myform.Controls.Add (mylistview);
+ myform.ShowDialog ();
+ Assert.AreEqual (true, eventhandled, "#A2");
+ }
+ }
+
+ [TestFixture, Ignore ("Needs Manual Intervention")]
+
+ public class ColumnClickEvent
+ {
+ static bool eventhandled = false;
+ public void ColumnClickEventHandler (object sender, ColumnClickEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void ColumnClickTest ()
+ {
+ Form myform = new Form ();
+ ListView mylistview = new ListView ();
+
+ mylistview.LabelEdit = true ;
+ mylistview.ColumnClick += new ColumnClickEventHandler (ColumnClickEventHandler);
+ mylistview.View = View.Details;
+ mylistview.SetBounds (10, 10, 200, 200, BoundsSpecified.All);
+ mylistview.Columns.Add ("A", -2, HorizontalAlignment.Center);
+ mylistview.Columns.Add ("B", -2, HorizontalAlignment.Center);
+ ListViewItem item1 = new ListViewItem ("A", -1);
+ mylistview.Items.Add (item1);
+ myform.Controls.Add (mylistview);
+ myform.ShowDialog ();
+ mylistview.Sort ();
+ Assert.AreEqual (true, eventhandled, "#A3");
+ }
+ }
+
+ [TestFixture, Ignore ("Needs Manual Intervention")]
+
+ public class MyEvent
+ {
+ static bool eventhandled = false;
+ public void New_EventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void ItemActivateTest ()
+ {
+ Form myform = new Form ();
+ ListView mylistview = new ListView ();
+ mylistview.Activation = ItemActivation.OneClick;
+ mylistview.LabelEdit = true ;
+ mylistview.ItemActivate += new EventHandler (New_EventHandler);
+ mylistview.View = View.Details;
+ mylistview.SetBounds (10, 10, 200, 200, BoundsSpecified.All);
+ mylistview.Columns.Add ("A", -2, HorizontalAlignment.Center);
+ mylistview.Columns.Add ("B", -2, HorizontalAlignment.Center);
+ ListViewItem item1 = new ListViewItem ("A", -1);
+ mylistview.Items.Add (item1);
+ myform.Controls.Add (mylistview);
+ myform.ShowDialog ();
+ Assert.AreEqual (true, eventhandled, "#A4");
+ }
+
+ [Test]
+ public void SelectedIndexChangedTest ()
+ {
+ Form myform = new Form ();
+ ListView mylistview = new ListView ();
+ mylistview.LabelEdit = true ;
+ mylistview.SelectedIndexChanged += new EventHandler (New_EventHandler);
+ eventhandled = false;
+ mylistview.View = View.Details;
+ mylistview.SetBounds (10, 10, 200, 200, BoundsSpecified.All);
+ mylistview.Columns.Add ("A", -2, HorizontalAlignment.Center);
+ mylistview.Columns.Add ("B", -2, HorizontalAlignment.Center);
+ ListViewItem item1 = new ListViewItem ("A", -1);
+ mylistview.Items.Add (item1);
+ myform.Controls.Add (mylistview);
+ myform.ShowDialog ();
+ Assert.AreEqual (true, eventhandled, "#A5");
+ }
+ }
+
+ [TestFixture, Ignore ("Needs Manual Intervention")]
+
+ public class ItemCheckEvent
+ {
+ static bool eventhandled = false;
+ public void ItemCheckEventHandler (object sender, ItemCheckEventArgs e)
+
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void ItemCheckTest ()
+ {
+ Form myform = new Form ();
+ ListView mylistview = new ListView ();
+ mylistview.CheckBoxes = true;
+ mylistview.LabelEdit = true ;
+ mylistview.ItemCheck += new ItemCheckEventHandler (ItemCheckEventHandler);
+ mylistview.View = View.Details;
+ mylistview.SetBounds (10, 10, 200, 200, BoundsSpecified.All);
+ mylistview.Columns.Add ("A", -2, HorizontalAlignment.Center);
+ mylistview.Columns.Add ("B", -2, HorizontalAlignment.Center);
+ ListViewItem item1 = new ListViewItem ("A", -1);
+ mylistview.Items.Add (item1);
+ myform.Controls.Add (mylistview);
+ myform.ShowDialog ();
+ mylistview.Visible = true;
+ Assert.AreEqual (true, eventhandled, "#A6");
+ }
+ }
+
+
+ [TestFixture, Ignore ("Needs Manual Intervention")]
+
+ public class ItemDragEvent
+ {
+ static bool eventhandled = false;
+ public void ItemDragEventHandler (object sender, ItemDragEventArgs e)
+
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void ItemDragTest ()
+ {
+ Form myform = new Form ();
+ ListView mylistview = new ListView ();
+ mylistview.ItemDrag += new ItemDragEventHandler (ItemDragEventHandler);
+ mylistview.View = View.Details;
+ mylistview.SetBounds (10, 10, 200, 200, BoundsSpecified.All);
+ mylistview.Columns.Add ("A", -2, HorizontalAlignment.Center);
+ mylistview.Columns.Add ("B", -2, HorizontalAlignment.Center);
+ ListViewItem item1 = new ListViewItem ("A", -1);
+ mylistview.Items.Add (item1);
+ myform.Controls.Add (mylistview);
+ myform.ShowDialog ();
+ mylistview.Visible = true;
+ mylistview.DoDragDrop (mylistview.SelectedItems, DragDropEffects.Link);
+ Assert.AreEqual (true, eventhandled, "#A7");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewItemTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewItemTest.cs
new file mode 100644
index 00000000000..e16b5023c44
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewItemTest.cs
@@ -0,0 +1,88 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class ListViewItemTest
+ {
+ [Test]
+ public void ListViewItemConstructors ()
+ {
+ Font fnt = new Font ("Arial", 12);
+ ListViewItem item1 = new ListViewItem ("Hello folks");
+ Assert.AreEqual ("Hello folks", item1.Text, "Constructor#1");
+
+ ListViewItem item2 = new ListViewItem (new string [] {"Element1", "Element2"},
+ -1, Color.Blue, Color.Red, fnt);
+
+ Assert.AreEqual (item2.ForeColor, Color.Blue, "Constructor#2");
+ Assert.AreEqual (item2.BackColor, Color.Red, "Constructor#3");
+
+ Assert.AreEqual (2, item2.SubItems.Count,"Constructor#4");
+ Assert.AreEqual (Color.Blue, item2.SubItems[0].ForeColor,"Constructor#5");
+ Assert.AreEqual (Color.Red, item2.SubItems[0].BackColor, "Constructor#6");
+ Assert.AreEqual (fnt, item2.SubItems[0].Font, "Constructor#7");
+ Assert.AreEqual ("Element1", item2.SubItems[0].Text, "Constructor#8");
+ Assert.AreEqual ("Element2", item2.SubItems[1].Text, "Constructor#12");
+ }
+
+ [Test]
+ public void ListViewItemDefaultValues ()
+ {
+ ListViewItem item = new ListViewItem ();
+
+ Assert.AreEqual (false, item.Focused, "DefaultValues#3");
+ Assert.AreEqual (false, item.Checked, "DefaultValues#4");
+ Assert.AreEqual (string.Empty, item.Text, "DefaultValues#5");
+ Assert.AreEqual (true, item.UseItemStyleForSubItems, "DefaultValues#6");
+ }
+
+ [Test]
+ public void ListViewItemTestClone ()
+ {
+ ListViewItem item1 = new ListViewItem ("Hello");
+ item1.ForeColor = Color.Blue;
+ item1.BackColor = Color.Red;
+ item1.Font = new Font ("Arial", 14);
+ item1.SubItems.Add ("Element2");
+
+ ListViewItem item2 = (ListViewItem) item1.Clone ();
+ Assert.AreEqual (item2.ForeColor, Color.Blue, "Clone#1");
+ Assert.AreEqual (item2.BackColor, Color.Red, "Clone#2");
+ Assert.AreEqual (item2.Text, "Hello", "Clone#3");
+ Assert.AreEqual (item2.Font, item1.Font, "Clone#4");
+ Assert.AreEqual (2, item2.SubItems.Count, "Clone#5");
+ Assert.AreEqual (item2.SubItems[1].Text, "Element2", "Clone#6");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewTest.cs
new file mode 100644
index 00000000000..f5f4f0c6f62
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewTest.cs
@@ -0,0 +1,136 @@
+//
+// ListViewTest.cs: Test cases for ListView.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class ListViewTest
+ {
+ [Test]
+ public void ListViewPropertyTest ()
+ {
+ ListView mylistview = new ListView ();
+ Assert.AreEqual (ItemActivation.Standard, mylistview.Activation, "#1");
+ Assert.AreEqual (ListViewAlignment.Top, mylistview.Alignment, "#2");
+ Assert.AreEqual (false, mylistview.AllowColumnReorder, "#3");
+ Assert.AreEqual (true, mylistview.AutoArrange, "#4");
+ Assert.AreEqual (BorderStyle.Fixed3D , mylistview.BorderStyle, "#5");
+ Assert.AreEqual (false, mylistview.CheckBoxes, "#6");
+ Assert.AreEqual (0, mylistview.CheckedIndices.Count, "#7");
+ Assert.AreEqual (0, mylistview.CheckedItems.Count, "#8");
+ Assert.AreEqual (0, mylistview.Columns.Count, "#9");
+ Assert.AreEqual (null, mylistview.FocusedItem, "#10");
+ Assert.AreEqual (false, mylistview.FullRowSelect, "#11");
+ Assert.AreEqual (false, mylistview.GridLines, "#12");
+ Assert.AreEqual (ColumnHeaderStyle.Clickable, mylistview.HeaderStyle, "#13");
+ Assert.AreEqual (true, mylistview.HideSelection, "#14");
+ Assert.AreEqual (false, mylistview.HoverSelection, "#15");
+ ListViewItem item1 = new ListViewItem ("A", -1);
+ mylistview.Items.Add (item1);
+ Assert.AreEqual (1, mylistview.Items.Count, "#16");
+ Assert.AreEqual (false, mylistview.LabelEdit, "#17");
+ Assert.AreEqual (true, mylistview.LabelWrap, "#18");
+ Assert.AreEqual (null, mylistview.LargeImageList, "#19");
+ Assert.AreEqual (null, mylistview.ListViewItemSorter, "#20");
+ Assert.AreEqual (true, mylistview.MultiSelect, "#21");
+ Assert.AreEqual (true, mylistview.Scrollable, "#22");
+ Assert.AreEqual (0, mylistview.SelectedIndices.Count, "#23");
+ Assert.AreEqual (0, mylistview.SelectedItems.Count, "#24");
+ Assert.AreEqual (null, mylistview.SmallImageList, "#25");
+ Assert.AreEqual (null, mylistview.LargeImageList, "#26");
+ Assert.AreEqual (SortOrder.None, mylistview.Sorting, "#27");
+ Assert.AreEqual (null, mylistview.StateImageList, "#28");
+ Assert.AreEqual (View.LargeIcon, mylistview.View, "#29");
+ mylistview.View = View.List;
+ Assert.AreEqual (false, mylistview.TopItem.Checked, "#30");
+ }
+
+ [Test]
+ public void ArrangeIconsTest ()
+ {
+ Form myform = new Form ();
+ ListView mylistview = new ListView ();
+ myform.Controls.Add (mylistview);
+ mylistview.Items.Add ("Item 1");
+ mylistview.Items.Add ("Item 2");
+ mylistview.View = View.LargeIcon;
+ mylistview.ArrangeIcons ();
+ }
+
+ [Test]
+ public void BeginEndUpdateTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ListView mylistview = new ListView();
+ mylistview.Items.Add ("A");
+ mylistview.Visible = true;
+ myform.Controls.Add (mylistview);
+ mylistview.BeginUpdate ();
+ for(int x = 1 ; x < 5000 ; x++){
+ mylistview.Items.Add ("Item " + x.ToString());
+ }
+ mylistview.EndUpdate ();
+ }
+
+ [Test]
+ public void ClearTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ListView mylistview = new ListView ();
+ mylistview.Items.Add ("A");
+ mylistview.Columns.Add ("Item Column", -2, HorizontalAlignment.Left);
+ mylistview.Visible = true;
+ myform.Controls.Add (mylistview);
+ Assert.AreEqual (1, mylistview.Columns.Count, "#31");
+ Assert.AreEqual (1, mylistview.Items.Count, "#32");
+ mylistview.Clear ();
+ Assert.AreEqual (0, mylistview.Columns.Count, "#33");
+ Assert.AreEqual (0, mylistview.Items.Count, "#34");
+ }
+
+ [Test]
+ public void EnsureVisibleTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ListView mylistview = new ListView ();
+ mylistview.Items.Add ("A");
+ myform.Controls.Add (mylistview);
+ mylistview.BeginUpdate ();
+ for(int x = 1 ; x < 5000 ; x++) {
+ mylistview.Items.Add ("Item " + x.ToString());
+ }
+ mylistview.EndUpdate ();
+ mylistview.EnsureVisible (4999);
+ }
+
+ [Test]
+ public void GetItemRectTest ()
+ {
+ ListView mylistview = new ListView ();
+ mylistview.Items.Add ("Item 1");
+ mylistview.Items.Add ("Item 2");
+ Rectangle r = mylistview.GetItemRect (1);
+ Assert.AreEqual (0, r.Top, "#35a");
+ Assert.IsTrue (r.Bottom > 0, "#35b");
+ Assert.IsTrue (r.Right > 0, "#35c");
+ Assert.IsTrue (r.Left > 0, "#35d");
+ Assert.IsTrue (r.Height > 0, "#35e");
+ Assert.IsTrue (r.Width > 0, "#35f");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MenuItemTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MenuItemTest.cs
new file mode 100644
index 00000000000..aad692b1188
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MenuItemTest.cs
@@ -0,0 +1,170 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class MenuItemTest
+ {
+ [Test]
+ public void MenuItemDefaultValues ()
+ {
+ MenuItem mi = new MenuItem ();
+
+ Assert.AreEqual (false, mi.BarBreak, "DefaultValues#1");
+ Assert.AreEqual (false, mi.Break, "DefaultValues#2");
+ Assert.AreEqual (false, mi.Checked, "DefaultValues#3");
+ Assert.AreEqual (false, mi.DefaultItem, "DefaultValues#4");
+ Assert.AreEqual (true, mi.Enabled, "DefaultValues#5");
+ Assert.AreEqual (-1, mi.Index, "DefaultValues#6");
+ Assert.AreEqual (false, mi.IsParent, "DefaultValues#7");
+
+ // TODO: MDI is not completed yet
+ //Assert.AreEqual (, mi.MdiList, "DefaultValues#8");
+
+ Assert.AreEqual (0, mi.MergeOrder, "DefaultValues#9");
+ Assert.AreEqual (MenuMerge.Add, mi.MergeType, "DefaultValues#10");
+ Assert.AreEqual ('\0', mi.Mnemonic, "DefaultValues#11");
+
+ Assert.AreEqual (false, mi.OwnerDraw, "DefaultValues#12");
+ Assert.AreEqual (null, mi.Parent, "DefaultValues#13");
+ Assert.AreEqual (false, mi.RadioCheck, "DefaultValues#14");
+ Assert.AreEqual (Shortcut.None, mi.Shortcut, "DefaultValues#15");
+ Assert.AreEqual (true, mi.ShowShortcut, "DefaultValues#16");
+ Assert.AreEqual (string.Empty, mi.Text, "DefaultValues#17");
+ Assert.AreEqual (true, mi.Visible, "DefaultValues#18");
+ }
+
+ [Test]
+ public void MenuItemConstructors ()
+ {
+ MenuItem mi;
+ MenuItem subitem1 = new MenuItem ("SubItem1");
+ MenuItem subitem2 = new MenuItem ("SubItem2");
+ MenuItem subitem3 = new MenuItem ("SubItem3");
+
+ {
+ mi = new MenuItem ("Item1");
+ Assert.AreEqual ("Item1", mi.Text, "Constructor#1");
+ }
+
+ {
+ mi = new MenuItem ("Item2", new MenuItem [] {subitem1,
+ subitem2, subitem3});
+
+ Assert.AreEqual ("Item2", mi.Text, "Constructor#2");
+ Assert.AreEqual (3, mi.MenuItems.Count, "Constructor#3");
+
+ Assert.AreEqual ("SubItem1", mi.MenuItems[0].Text, "Constructor#4");
+ Assert.AreEqual (mi, mi.MenuItems[0].Parent, "Constructor#5");
+
+ Assert.AreEqual ("SubItem2", mi.MenuItems[1].Text, "Constructor#6");
+ Assert.AreEqual (mi, mi.MenuItems[1].Parent, "Constructor#7");
+
+ Assert.AreEqual ("SubItem3", mi.MenuItems[2].Text, "Constructor#8");
+ Assert.AreEqual (mi, mi.MenuItems[2].Parent, "Constructor#9");
+ }
+
+ }
+
+ [Test]
+ public void MenuItemSimpleMerge ()
+ {
+ MainMenu mymainmenu1 = new MainMenu ();
+ MainMenu mymainmenu2 = new MainMenu ();
+ MenuItem mymenuitem1 = new MenuItem ();
+ MenuItem mymenuitem2 = new MenuItem ();
+ mymenuitem1.Text = "A";
+ mymenuitem2.Text = "B";
+ mymainmenu1.MenuItems.Add (mymenuitem1);
+ mymainmenu2.MenuItems.Add (mymenuitem2);
+ mymainmenu1.MergeMenu (mymainmenu2);
+ Assert.AreEqual (2, mymainmenu1.MenuItems.Count, "SimpleMerge#1");
+ }
+
+ [Test]
+ public void MenuItemMerge ()
+ {
+ MenuItem item1 = new MenuItem ("File (0)"); // Position 0
+ MenuItem item2 = new MenuItem ("Print the file (1)"); // Position 1
+ MenuItem item3 = new MenuItem ("Print Preview (2)"); // Position 2
+ MenuItem item4 = new MenuItem ("-"); // Position 3
+ MenuItem item5 = new MenuItem ("Recent files (4)"); // Position 4
+ MenuItem item6 = new MenuItem ("Exit (5)"); // Position 5
+
+ MenuItem item10 = new MenuItem ("Compare... (6)"); // Replace pos 3
+ MenuItem item11 = new MenuItem ("Sort (7)");
+ MenuItem item12 = new MenuItem ("Conversions (8)");
+ MenuItem item13 = new MenuItem ("Specials Functions (9)");
+ MenuItem item14 = new MenuItem ("Another option... (10)");
+
+ MenuItem item20 = new MenuItem ("autors.doc");
+ MenuItem item21 = new MenuItem ("testing.html");
+ MenuItem item22 = new MenuItem ("proves.txt");
+
+ MenuItem[] first_items = new MenuItem[] {item1, item2, item3, item4, item5, item6};
+ MenuItem[] second_items = new MenuItem[] {item10, item11, item12, item13, item14};
+ MenuItem[] third_items = new MenuItem[] {item20, item21, item22};
+
+ item14.MergeType = MenuMerge.Remove;
+ item10.MergeOrder = 40;
+
+ item11.MergeType = MenuMerge.Replace;
+ item11.MergeOrder = 30;
+ item12.MergeOrder = 5;
+ item10.MergeType = MenuMerge.MergeItems;
+
+ ContextMenu first_menu = new ContextMenu (first_items);
+ ContextMenu second_menu = new ContextMenu (second_items);
+ ContextMenu third_menu = new ContextMenu (third_items);
+
+ first_menu.MergeMenu (second_menu);
+ first_menu.MergeMenu (third_menu);
+
+ Assert.AreEqual ("File (0)", first_menu.MenuItems[0].Text, "ItemMerge#1");
+ Assert.AreEqual ("Print the file (1)", first_menu.MenuItems[1].Text, "ItemMerge#2");
+ Assert.AreEqual ("Print Preview (2)", first_menu.MenuItems[2].Text, "ItemMerge#3");
+ Assert.AreEqual ("-", first_menu.MenuItems[3].Text, "ItemMerge#4");
+ Assert.AreEqual ("Recent files (4)", first_menu.MenuItems[4].Text, "ItemMerge#5");
+ Assert.AreEqual ("Exit (5)", first_menu.MenuItems[5].Text, "ItemMerge#6");
+ Assert.AreEqual ("Specials Functions (9)", first_menu.MenuItems[6].Text, "ItemMerge#7");
+ Assert.AreEqual ("autors.doc", first_menu.MenuItems[7].Text, "ItemMerge#8");
+ Assert.AreEqual ("testing.html", first_menu.MenuItems[8].Text, "ItemMerge#9");
+ Assert.AreEqual ("proves.txt", first_menu.MenuItems[9].Text, "ItemMerge#10");
+ Assert.AreEqual ("Conversions (8)", first_menu.MenuItems[10].Text, "ItemMerge#11");
+ Assert.AreEqual ("Sort (7)", first_menu.MenuItems[11].Text, "ItemMerge#11");
+ Assert.AreEqual ("Compare... (6)", first_menu.MenuItems[12].Text, "ItemMerge#11");
+ }
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MenuTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MenuTest.cs
new file mode 100644
index 00000000000..176e36cba30
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MenuTest.cs
@@ -0,0 +1,86 @@
+//
+// MenuTest.cs: Test cases for Menu, MainMenu
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class MenuTest
+ {
+ [Test]
+ public void MenuPropertyTest ()
+ {
+ Menu mymenu = new MainMenu ();
+ Assert.AreEqual ("System.IntPtr", mymenu.Handle.GetType().FullName, "#1");
+ Assert.AreEqual (false, mymenu.IsParent, "#2");
+ // TODO: MDI is not completed yet
+ //Assert.AreEqual (null, mymenu.MdiListItem, "#3");
+ Assert.AreEqual (0, mymenu.MenuItems.Count,"#4");
+ mymenu.MenuItems.Add ("newmenu1");
+ mymenu.MenuItems.Add ("newmenu2");
+ Assert.AreEqual (2, mymenu.MenuItems.Count,"#5");
+ MainMenu mymainmenu = new MainMenu ();
+ Assert.AreEqual (RightToLeft.Inherit, mymainmenu.RightToLeft,"#6");
+ }
+
+ [Test]
+ public void GetMainMenuTest ()
+ {
+ MainMenu mymainmenu = new MainMenu ();
+ MenuItem mymenuitem = new MenuItem ();
+ mymenuitem.Text = "menu 1";
+ mymainmenu.MenuItems.Add (mymenuitem);
+ Assert.AreEqual (mymainmenu, mymenuitem.GetMainMenu (), "#7");
+ }
+
+ [Test]
+ public void CloneMenuTest ()
+ {
+ MainMenu mymainmenu1 = new MainMenu ();
+ MenuItem menuitem1 = new MenuItem ();
+ MenuItem menuitem2 = new MenuItem ();
+ menuitem1.Text = "item1";
+ menuitem2.Text = "item2";
+ mymainmenu1.MenuItems.Add (menuitem1);
+ mymainmenu1.MenuItems.Add (menuitem2);
+ MainMenu mymainmenu2 = mymainmenu1.CloneMenu ();
+ Assert.AreEqual ("item1", mymainmenu2.MenuItems[0].Text, "#9");
+ }
+
+ [Test]
+ public void GetFormTest ()
+ {
+ Form myform = new Form ();
+ myform.Name = "New Form";
+ MainMenu mymainmenu1 = new MainMenu ();
+ MenuItem menuitem1 = new MenuItem ();
+ menuitem1.Text = "item1";
+ mymainmenu1.MenuItems.Add (menuitem1);
+ myform.Menu = mymainmenu1;
+ Assert.AreEqual ("New Form", mymainmenu1.GetForm().Name, "#10");
+ }
+
+ [Test]
+ public void GetContextMenuTest ()
+ {
+ Form myform = new Form ();
+ ContextMenu mycontextmenu = new ContextMenu ();
+ myform.ContextMenu= mycontextmenu;
+ MenuItem menuItem1 = new MenuItem ();
+ menuItem1.Text = "1";
+ mycontextmenu.MenuItems.Add (menuItem1);
+ Assert.AreEqual (mycontextmenu, menuItem1.GetContextMenu (),"#11");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MonthCalendarTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MonthCalendarTest.cs
new file mode 100644
index 00000000000..b6737b9f565
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MonthCalendarTest.cs
@@ -0,0 +1,166 @@
+//
+// MonthCalendarTest.cs: Test case for MonthCalendar
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class MonthCalendarTest
+ {
+ [Test]
+ public void MonthCalendarPropertyTest ()
+ {
+ Form myfrm = new Form ();
+ MonthCalendar myMonthCal1 = new MonthCalendar ();
+ MonthCalendar myMonthCal2 = new MonthCalendar ();
+ myMonthCal1.Name = "MonthCendar";
+ myMonthCal1.TabIndex = 1;
+ DateTime myDateTime = new DateTime ();
+
+ // A
+ myMonthCal1.AddAnnuallyBoldedDate (new DateTime (2005, 09, 01));
+ Assert.AreEqual (new DateTime (2005, 09, 01), myMonthCal1.AnnuallyBoldedDates.GetValue (0), "#A1");
+
+ // B
+ Assert.AreEqual ("Window", myMonthCal1.BackColor.Name, "#B1");
+ myMonthCal1.AddBoldedDate (new DateTime (2005, 09, 01));
+ Assert.AreEqual (new DateTime (2005, 09, 01), myMonthCal1.BoldedDates.GetValue (0), "#B2");
+
+ // C
+ Assert.AreEqual (1, myMonthCal1.CalendarDimensions.Height, "#C1");
+ Assert.AreEqual (1, myMonthCal1.CalendarDimensions.Width, "#C2");
+ Assert.AreEqual (false, myMonthCal1.CalendarDimensions.IsEmpty, "#C3");
+
+ // F
+ Assert.AreEqual (Day.Default, myMonthCal1.FirstDayOfWeek, "#F1");
+ myMonthCal1.FirstDayOfWeek = Day.Sunday;
+ Assert.AreEqual (Day.Sunday, myMonthCal1.FirstDayOfWeek, "#F2");
+ Assert.AreEqual ("WindowText", myMonthCal1.ForeColor.Name, "#F3");
+
+ // M
+ Assert.AreEqual (new DateTime (9998,12,31), myMonthCal1.MaxDate, "#M1");
+ Assert.AreEqual (7, myMonthCal1.MaxSelectionCount, "#M2");
+ Assert.AreEqual (new DateTime (1753,1,1), myMonthCal1.MinDate, "#M3");
+ myMonthCal1.AddMonthlyBoldedDate (new DateTime (2005, 09, 01));
+ Assert.AreEqual (new DateTime(2005, 09, 01), myMonthCal1.MonthlyBoldedDates.GetValue (0), "#M4");
+
+ // S
+ Assert.AreEqual (0, myMonthCal1.ScrollChange, "#S1");
+ myMonthCal1.SelectionStart = new DateTime (2005,09,02);
+ myMonthCal1.SelectionEnd = new DateTime (2005,09,03);
+ Assert.AreEqual (new DateTime (2005,09,03), myMonthCal1.SelectionEnd, "#S2");
+ //Assert.AreEqual (new SelectionRange (new DateTime(2005,09,02), new DateTime(2005,09,03)), myMonthCal1.SelectionRange, "#S3");
+ Assert.AreEqual (new DateTime (2005,09,02), myMonthCal1.SelectionStart, "#S4");
+ Assert.AreEqual (true, myMonthCal1.ShowToday, "#S5");
+ Assert.AreEqual (true, myMonthCal1.ShowTodayCircle, "#S6");
+ Assert.AreEqual (false, myMonthCal1.ShowWeekNumbers, "#S7");
+ Assert.AreEqual (153, myMonthCal1.SingleMonthSize.Height, "#S8a");
+ Assert.AreEqual (176, myMonthCal1.SingleMonthSize.Width, "#S8b");
+ Assert.AreEqual (null, myMonthCal1.Site, "#S9");
+ // T
+ Assert.AreEqual ("ActiveCaption", myMonthCal1.TitleBackColor.Name, "#T1");
+ Assert.AreEqual ("ActiveCaptionText", myMonthCal1.TitleForeColor.Name, "#T2");
+ Assert.AreEqual (DateTime.Today, myMonthCal1.TodayDate, "#T3");
+ Assert.AreEqual (false, myMonthCal1.TodayDateSet, "#T4");
+ Assert.AreEqual ("GrayText", myMonthCal1.TrailingForeColor.Name, "#T5");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void MonthCalMaxSelectionCountException ()
+ {
+ MonthCalendar myMonthCal1 = new MonthCalendar ();
+ myMonthCal1.MaxSelectionCount = 0 ; // value is less than 1
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void MonthCalMaxDateException ()
+ {
+ MonthCalendar myMonthCal1 = new MonthCalendar ();
+ myMonthCal1.MaxDate = new DateTime (1752, 1, 1, 0, 0, 0, 0); // value is less than min date (01/01/1753)
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void MonthCalMinDateException ()
+ {
+ MonthCalendar myMonthCal1 = new MonthCalendar ();
+ myMonthCal1.MinDate = new DateTime(1752, 1, 1, 0, 0, 0, 0); // Date earlier than 01/01/1753
+ myMonthCal1.MinDate = new DateTime(9999, 12, 31, 0, 0, 0, 0); // Date greater than max date (01/01/1753)
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void MonthCalSelectRangeException ()
+ {
+ MonthCalendar myMonthCal1 = new MonthCalendar ();
+ myMonthCal1.SelectionRange = new SelectionRange (new DateTime (1752, 01, 01), new DateTime (1752, 01, 02));
+ myMonthCal1.SelectionRange = new SelectionRange (new DateTime (9999, 12, 30), new DateTime (9999, 12, 31));
+ }
+
+ [Test]
+ public void AddAnnuallyBoldedDateTest ()
+ {
+ Form myForm = new Form ();
+ MonthCalendar myMonthCal = new MonthCalendar ();
+ myMonthCal.AddAnnuallyBoldedDate (new DateTime (2005, 09, 01));
+ myForm.Controls.Add (myMonthCal);
+ Assert.AreEqual (new DateTime (2005, 09, 01), myMonthCal.AnnuallyBoldedDates.GetValue (0), "#add1");
+ }
+
+ [Test]
+ public void AddBoldedDateTest ()
+ {
+ Form myForm = new Form ();
+ MonthCalendar myMonthCal = new MonthCalendar ();
+ myMonthCal.AddBoldedDate (new DateTime (2005, 09, 02));
+ myForm.Controls.Add (myMonthCal);
+ Assert.AreEqual (new DateTime (2005, 09, 02), myMonthCal.BoldedDates.GetValue (0), "#add2");
+ }
+
+ [Test]
+ public void AddMonthlyBoldedDateTest ()
+ {
+ Form myForm = new Form ();
+ MonthCalendar myMonthCal = new MonthCalendar ();
+ myMonthCal.AddMonthlyBoldedDate (new DateTime (2005, 09, 03));
+ myForm.Controls.Add (myMonthCal);
+ Assert.AreEqual (new DateTime (2005, 09, 03), myMonthCal.MonthlyBoldedDates.GetValue (0), "#add2");
+ }
+
+ [Test]
+ public void GetDispalyRangeTest ()
+ {
+ Form myForm = new Form ();
+ MonthCalendar myMonthCal = new MonthCalendar ();
+ myForm.Controls.Add (myMonthCal);
+ SelectionRange mySelRange = new SelectionRange ();
+ mySelRange.Start = new DateTime (2005, 09, 01);
+ mySelRange.End = new DateTime (2005, 09, 30);
+ Assert.AreEqual (mySelRange.Start, myMonthCal.GetDisplayRange (true).Start, "#Get1");
+ Assert.AreEqual (mySelRange.End, myMonthCal.GetDisplayRange (true).End, "#Get22");
+ }
+
+ [Test]
+ public void HitTest ()
+ {
+ Form myForm = new Form ();
+ MonthCalendar myMonthCal = new MonthCalendar ();
+ myForm.Controls.Add (myMonthCal);
+ Assert.AreEqual (new DateTime (01, 01, 01), myMonthCal.HitTest(10, 10).Time, "#Hit1");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/PictureBoxTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/PictureBoxTest.cs
new file mode 100644
index 00000000000..3b0151afefb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/PictureBoxTest.cs
@@ -0,0 +1,82 @@
+//
+// PictureBoxTest.cs: Test cases for PictureBox.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+using System.Threading;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class PictureBoxTest
+ {
+ [Test]
+ public void PictureBoxPropertyTest ()
+ {
+ Form myForm = new Form ();
+ PictureBox myPicBox = new PictureBox ();
+ myForm.Controls.Add (myPicBox);
+
+ // B
+ Assert.AreEqual (BorderStyle.None, myPicBox.BorderStyle, "#B1");
+ myPicBox.BorderStyle = BorderStyle.Fixed3D;
+ Assert.AreEqual (BorderStyle.Fixed3D, myPicBox.BorderStyle, "#B2");
+
+ // I
+ Assert.AreEqual (null, myPicBox.Image, "#I1");
+ Image myImage = Image.FromFile("M.gif");
+ myPicBox.Image = myImage;
+ Assert.AreEqual (60, myPicBox.Image.Height, "#I2");
+ Assert.AreEqual (150, myPicBox.Image.Width, "#I3");
+
+ // P
+ Assert.AreEqual (PictureBoxSizeMode.Normal, myPicBox.SizeMode, "#P1");
+ myPicBox.SizeMode = PictureBoxSizeMode.AutoSize;
+ Assert.AreEqual (PictureBoxSizeMode.AutoSize, myPicBox.SizeMode, "#P2");
+ }
+
+
+ [Test, Ignore ("This seems to fail.")]
+ public void ToStringMethodTest ()
+ {
+ PictureBox myPicBox = new PictureBox ();
+ Assert.AreEqual ("System.Windows.Forms.PictureBox, SizeMode: Normal", myPicBox.ToString (), "#T1");
+ }
+
+ [TestFixture]
+ public class PictureBoxSizeModeEventClass
+ {
+ static bool eventhandled = false;
+ public static void SizeMode_EventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void PictureBoxEvenTest ()
+ {
+ Form myForm = new Form ();
+ PictureBox myPicBox = new PictureBox ();
+ myForm.Controls.Add (myPicBox);
+ myPicBox.SizeModeChanged += new EventHandler (SizeMode_EventHandler);
+ myPicBox.SizeMode = PictureBoxSizeMode.AutoSize;
+ Assert.AreEqual (true, eventhandled, "#SM1");
+ eventhandled = false;
+ myPicBox.SizeMode = PictureBoxSizeMode.CenterImage;
+ Assert.AreEqual (true, eventhandled, "#SM2");
+ eventhandled = false;
+ myPicBox.SizeMode = PictureBoxSizeMode.StretchImage;
+ Assert.AreEqual (true, eventhandled, "#SM3");
+ }
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ProgressBarTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ProgressBarTest.cs
new file mode 100644
index 00000000000..0b93e3db00b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ProgressBarTest.cs
@@ -0,0 +1,84 @@
+//
+// ProgressBarTest.cs: Test cases for ProgressBar.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class ProgressBarBaseTest
+ {
+ [Test]
+ public void ProgressBarPropertyTest ()
+ {
+ ProgressBar myProgressBar = new ProgressBar ();
+
+ // A
+ Assert.AreEqual (false, myProgressBar.AllowDrop, "#A1");
+
+ // B
+ Assert.AreEqual ("Control", myProgressBar.BackColor.Name, "#B1");
+ myProgressBar.BackColor = Color.White;
+ Assert.AreEqual (255, myProgressBar.BackColor.R, "#B2");
+ Assert.AreEqual (null, myProgressBar.BackgroundImage, "#B3");
+ string gif = "M.gif";
+ myProgressBar.BackgroundImage = Image.FromFile (gif);
+ // comparing image objects fails on MS .Net so using Size property
+ Assert.AreEqual (Image.FromFile(gif, true).Size, myProgressBar.BackgroundImage.Size, "#B4");
+
+ // F
+ Assert.AreEqual (8.25, myProgressBar.Font.Size, "#F1");
+ Assert.AreEqual (FontStyle.Regular, myProgressBar.Font.Style, "#F2");
+ Assert.AreEqual ("ControlText", myProgressBar.ForeColor.Name, "#F3");
+
+ // M
+ Assert.AreEqual (100, myProgressBar.Maximum, "#M1");
+ Assert.AreEqual (0, myProgressBar.Minimum, "#M2");
+
+ // R
+ Assert.AreEqual (RightToLeft.No, myProgressBar.RightToLeft, "#R1");
+
+ // S
+ Assert.AreEqual (10, myProgressBar.Step, "#S1");
+
+ // T
+ Assert.AreEqual ("", myProgressBar.Text, "#T1");
+ myProgressBar.Text = "New ProgressBar";
+ Assert.AreEqual ("New ProgressBar", myProgressBar.Text, "#T2");
+
+ // V
+ Assert.AreEqual (0, myProgressBar.Value, "#V1");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ValueTest ()
+ {
+ ProgressBar myProgressBar = new ProgressBar ();
+ myProgressBar.Value = -1;
+ myProgressBar.Value = 100;
+ }
+
+ [Test]
+ public void ToStringMethodTest ()
+ {
+ ProgressBar myProgressBar = new ProgressBar ();
+ myProgressBar.Text = "New ProgressBar";
+ Assert.AreEqual ("System.Windows.Forms.ProgressBar, Minimum: 0, Maximum: 100, Value: 0", myProgressBar.ToString (), "#T3");
+ }
+ // [MonoTODO("Add test for method Increment (Visual Test)")]
+ // [MonoTODO("Add test for method PerformStep (Visual Test)")]
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RadioButtonTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RadioButtonTest.cs
new file mode 100644
index 00000000000..b16dcc70427
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RadioButtonTest.cs
@@ -0,0 +1,104 @@
+//
+// RadioRadioButtonTest.cs: Test cases for RadioRadioButton.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class RadioButtonTest
+ {
+ [Test]
+ public void RadioButtonPropertyTest ()
+ {
+ RadioButton rButton1 = new RadioButton ();
+
+ // A
+ Assert.AreEqual (Appearance.Normal, rButton1.Appearance, "#A1");
+ Assert.AreEqual (true, rButton1.AutoCheck, "#A2");
+
+ // C
+ Assert.AreEqual (false, rButton1.Checked, "#C1");
+ Assert.AreEqual (ContentAlignment.MiddleLeft, rButton1.CheckAlign, "#C2");
+
+ // S
+ Assert.AreEqual (null, rButton1.Site, "#S1");
+
+ // T
+ rButton1.Text = "New RadioButton";
+ Assert.AreEqual ("New RadioButton", rButton1.Text, "#T1");
+ Assert.AreEqual (ContentAlignment.MiddleLeft, rButton1.TextAlign, "#T2");
+ }
+
+ [Test]
+ public void ToStringTest ()
+ {
+ RadioButton rButton1 = new RadioButton ();
+ Assert.AreEqual ("System.Windows.Forms.RadioButton, Checked: False" , rButton1.ToString (), "#9");
+ }
+ }
+
+ [TestFixture]
+ public class RadioButtonEventTestClass
+ {
+ static bool eventhandled = false;
+ public static void RadioButton_EventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void PanelClickTest ()
+ {
+ Form myForm = new Form ();
+ RadioButton rButton1 = new RadioButton ();
+ rButton1.Select ();
+ rButton1.Visible = true;
+ myForm.Controls.Add (rButton1);
+ eventhandled = false;
+ rButton1.Click += new EventHandler (RadioButton_EventHandler);
+ myForm.Show ();
+ rButton1.PerformClick ();
+ Assert.AreEqual (true, eventhandled, "#2");
+ }
+
+ [Test]
+ public void ApperanceChangedTest ()
+ {
+ Form myForm = new Form ();
+ RadioButton rButton1 = new RadioButton ();
+ rButton1.Select ();
+ rButton1.Visible = true;
+ myForm.Controls.Add (rButton1);
+ rButton1.Appearance = Appearance.Normal;
+ eventhandled = false;
+ rButton1.AppearanceChanged += new EventHandler (RadioButton_EventHandler);
+ rButton1.Appearance = Appearance.Button;
+ Assert.AreEqual (true, eventhandled, "#2");
+ }
+
+ [Test]
+ public void CheckedChangedTest ()
+ {
+ Form myForm = new Form ();
+ RadioButton rButton1 = new RadioButton ();
+ rButton1.Select ();
+ rButton1.Visible = true;
+ myForm.Controls.Add (rButton1);
+ rButton1.Checked = false;
+ eventhandled = false;
+ rButton1.CheckedChanged += new EventHandler (RadioButton_EventHandler);
+ rButton1.Checked = true;
+ Assert.AreEqual (true, eventhandled, "#3");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RichTextBoxTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RichTextBoxTest.cs
new file mode 100644
index 00000000000..64a74b79077
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RichTextBoxTest.cs
@@ -0,0 +1,187 @@
+//
+// RichTextBoxTest.cs: Test cases for RichTextBox.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class RichTextBoxBaseTest
+ {
+#if not
+ [Test]
+ public void RichTextBoxPropertyTest ()
+ {
+ RichTextBox rTBox = new RichTextBox ();
+
+ // A
+ Assert.AreEqual (false, rTBox.AllowDrop, "#A1");
+ rTBox.Multiline = true;
+ rTBox.AcceptsTab = true;
+ SendKeys.SendWait ("^%");
+ Assert.AreEqual (false, rTBox.AutoSize, "#A2");
+ Assert.AreEqual (false, rTBox.AutoWordSelection, "#A3");
+
+
+ // B
+ rTBox.BackColor = Color.White;
+ Assert.AreEqual (null, rTBox.BackgroundImage, "#B1");
+ string gif = "M.gif";
+ rTBox.BackgroundImage = Image.FromFile (gif);
+ // comparing image objects fails on MS .Net so using Size property
+ Assert.AreEqual (Image.FromFile(gif, true).Size, rTBox.BackgroundImage.Size, "#B2");
+ Assert.AreEqual (0, rTBox.BulletIndent, "#B3");
+
+ // C
+ Assert.AreEqual (false, rTBox.CanRedo, "#C1");
+ rTBox.Paste ();
+ Assert.AreEqual (false, rTBox.CanRedo, "#C2");
+ rTBox.ClearUndo ();
+ Assert.AreEqual (false, rTBox.CanRedo, "#C3");
+
+ // D
+ Assert.AreEqual (true, rTBox.DetectUrls, "#D1");
+
+ // F
+ Assert.AreEqual (FontStyle.Regular, rTBox.Font.Style, "#F1");
+ Assert.AreEqual ("WindowText", rTBox.ForeColor.Name, "#F2");
+
+ //M
+ Assert.AreEqual (2147483647, rTBox.MaxLength, "#M1");
+ Assert.AreEqual (true, rTBox.Multiline, "#M2");
+ rTBox.WordWrap = false;
+ Assert.AreEqual (true, rTBox.Multiline, "#M3");
+
+ // R
+ Assert.AreEqual ("", rTBox.RedoActionName, "#R1");
+ Assert.AreEqual (0, rTBox.RightMargin, "#R2");
+
+ // [MonoTODO ("Assert.AreEqual (false, rTBox.Rtf, "#R3");") ]
+
+ // S
+
+ // [MonoTODO ("Assert.AreEqual (ScrollBars.Both, rTBox.ScrollBars, "#S1");")]
+ Assert.AreEqual (RichTextBoxScrollBars.Both, rTBox.ScrollBars, "#S1");
+ Assert.AreEqual ("", rTBox.SelectedText, "#S3");
+ rTBox.Text = "sample TextBox";
+ Assert.AreEqual (HorizontalAlignment.Left, rTBox.SelectionAlignment, "#S5");
+ Assert.AreEqual (false, rTBox.SelectionBullet, "#S6");
+ Assert.AreEqual (0, rTBox.SelectionCharOffset, "#S7");
+ //Assert.AreEqual (Color.Black, rTBox.SelectionColor, "#S8"); // Random color
+ Assert.AreEqual ("Courier New", rTBox.SelectionFont.Name, "#S9a");
+ Assert.AreEqual (FontStyle.Regular, rTBox.SelectionFont.Style, "#S9b");
+ Assert.AreEqual (0, rTBox.SelectionHangingIndent, "#S10");
+ Assert.AreEqual (0, rTBox.SelectionIndent, "#S11");
+ Assert.AreEqual (0, rTBox.SelectionLength, "#S12");
+ Assert.AreEqual (false, rTBox.SelectionProtected, "#S13");
+ Assert.AreEqual (0, rTBox.SelectionRightIndent, "#S14");
+ Assert.AreEqual (false, rTBox.ShowSelectionMargin, "#S15");
+ // [MonoTODO ("Assert.AreEqual (, rTBox.SelectionTabs, "#S16");")]
+ // [MonoTODO("Assert.AreEqual (TypeCode.Empty, rTBox.SelectionType, "#S17");")]
+
+ // T
+ Assert.AreEqual ("sample TextBox", rTBox.Text, "#T1");
+ Assert.AreEqual (14, rTBox.TextLength, "#T2");
+
+ // UVW
+ Assert.AreEqual ("", rTBox.UndoActionName, "#U1");
+
+ // XYZ
+ Assert.AreEqual (1, rTBox.ZoomFactor, "#Z1");
+
+ }
+
+ [Test]
+ public void CanPasteTest ()
+ {
+ RichTextBox rTextBox = new RichTextBox ();
+ Bitmap myBitmap = new Bitmap ("M.gif");
+ Clipboard.SetDataObject (myBitmap);
+ DataFormats.Format myFormat = DataFormats.GetFormat (DataFormats.Bitmap);
+ Assert.AreEqual (true, rTextBox.CanPaste (myFormat), "#Mtd1");
+ }
+#endif
+
+ [Test]
+ public void FindCharTest ()
+ {
+ RichTextBox rTextBox = new RichTextBox ();
+ rTextBox.Text = "something";
+ Assert.AreEqual (2, rTextBox.Find (new char [] {'m'}), "#Mtd3");
+ Assert.AreEqual (-1, rTextBox.Find (new char [] {'t'},5), "#Mtd3a");
+ Assert.AreEqual (4, rTextBox.Find (new char [] {'t'},4,5), "#Mtd3b");
+ }
+
+ [Test]
+ public void FindStringTest ()
+ {
+ RichTextBox rTextBox = new RichTextBox ();
+ rTextBox.Text = "sample text for richtextbox";
+ int indexToText1 = rTextBox.Find ("for");
+ Assert.AreEqual (12, indexToText1, "#Mtd4");
+ int indexToText2 = rTextBox.Find ("for", 0, 14, RichTextBoxFinds.MatchCase);
+ Assert.AreEqual (-1, indexToText2, "#Mtd5");
+ int indexToText3 = rTextBox.Find ("for", 0, 15, RichTextBoxFinds.MatchCase);
+ Assert.AreEqual (12, indexToText3, "#Mtd6");
+ int indexToText4 = rTextBox.Find ("richtextbox", 0, RichTextBoxFinds.MatchCase);
+ Assert.AreEqual (16, indexToText4, "#Mtd7");
+ int indexToText5 = rTextBox.Find ("text", RichTextBoxFinds.MatchCase);
+ Assert.AreEqual (7, indexToText5, "#Mtd8");
+ }
+
+ [Test]
+ public void FindTest() {
+ RichTextBox t = new RichTextBox();
+
+ t.Text = "Testtext and arglblah may not be what we're looking for\n, but blah Blah is";
+
+ Assert.AreEqual(t.Find(new char[] {'b', 'l', 'a', 'h'}), 9, "Find1");
+ Assert.AreEqual(t.Find(new char[] {'b', 'l', 'a', 'h'}, 20), 20, "Find2");
+ Assert.AreEqual(t.Find(new char[] {'b', 'l', 'a', 'h'}, 25, 30), -1, "Find3");
+ Assert.AreEqual(t.Find("blah"), 17, "Find4");
+ Assert.AreEqual(t.Find("blah", 10, 30, RichTextBoxFinds.None), 17, "Find5");
+ Assert.AreEqual(t.Find("blah", 10, 30, RichTextBoxFinds.WholeWord), -1, "Find6");
+ Assert.AreEqual(t.Find("blah", 10, 30, RichTextBoxFinds.MatchCase), 17, "Find7");
+ Assert.AreEqual(t.Find("blah", 10, 70, RichTextBoxFinds.Reverse), 62, "Find8");
+ Assert.AreEqual(t.Find("blah", 10, 73, RichTextBoxFinds.Reverse), 67, "Find9");
+ Assert.AreEqual(t.Find("blah", 10, 73, RichTextBoxFinds.Reverse | RichTextBoxFinds.MatchCase), 62, "Find10");
+ Assert.AreEqual(t.Find("blah", 10, RichTextBoxFinds.None), 17, "Find11");
+ Assert.AreEqual(t.Find("blah", 10, RichTextBoxFinds.WholeWord), 62, "Find12");
+ Assert.AreEqual(t.Find("blah", 10, RichTextBoxFinds.MatchCase), 17, "Find13");
+ Assert.AreEqual(t.Find("blah", 10, RichTextBoxFinds.Reverse), 67, "Find14");
+ Assert.AreEqual(t.Find("blah", 10, RichTextBoxFinds.Reverse | RichTextBoxFinds.MatchCase), 62, "Find15");
+ Assert.AreEqual(t.Find("blah", RichTextBoxFinds.Reverse), 67, "Find16");
+ Assert.AreEqual(t.Find("blah", RichTextBoxFinds.MatchCase), 17, "Find17");
+ Assert.AreEqual(t.Find("blah", RichTextBoxFinds.WholeWord), 62, "Find18");
+
+ // Special cases
+ Assert.AreEqual(t.Find("blah", 10, 11, RichTextBoxFinds.None), -1, "Find19"); // Range to short to ever match
+ Assert.AreEqual(t.Find("blah", 17, 18, RichTextBoxFinds.None), -1, "Find20"); // Range to short to ever match, but starts matching
+ Assert.AreEqual(t.Find("is", RichTextBoxFinds.WholeWord), 72, "Find21"); // Last word in document
+ Assert.AreEqual(t.Find("for", RichTextBoxFinds.WholeWord), 52, "Find22"); // word followed by \n
+ Assert.AreEqual(t.Find("Testtext", RichTextBoxFinds.WholeWord), 0, "Find23"); // First word in document
+ Assert.AreEqual(t.Find("Testtext", RichTextBoxFinds.WholeWord | RichTextBoxFinds.Reverse), 0, "Find24"); // First word in document, searched in reverse
+ }
+
+ [Test]
+ public void GetCharFromPositionTest ()
+ {
+ Form myForm = new Form ();
+ RichTextBox rTextBox = new RichTextBox ();
+ rTextBox.Text = "sample text for richtextbox";
+ myForm.Controls.Add (rTextBox);
+ Assert.AreEqual ('m', rTextBox.GetCharFromPosition (new Point (10, 10)), "#21");
+ }
+ //[MonoTODO("Add test for method Paste (Visual Test)")]
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ScrollBarTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ScrollBarTest.cs
new file mode 100644
index 00000000000..0c0e2897a70
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ScrollBarTest.cs
@@ -0,0 +1,1453 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+// Ritvik Mayank (mritvik@novell.com)
+//
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms
+{
+
+public class MyScrollBar : HScrollBar
+ {
+ private ArrayList results = new ArrayList ();
+ public MyScrollBar () : base ()
+ {}
+
+ protected override void OnBackColorChanged (EventArgs e)
+ {
+ results.Add ("OnBackColorChanged");
+ base.OnBackColorChanged (e);
+ }
+
+ protected override void OnBackgroundImageChanged (EventArgs e)
+ {
+ results.Add ("OnBackgroundImageChanged");
+ base.OnBackgroundImageChanged (e);
+ }
+
+ protected override void OnClick (EventArgs e)
+ {
+ results.Add ("OnClick");
+ base.OnClick (e);
+ }
+
+ protected override void OnDoubleClick (EventArgs e)
+ {
+ results.Add ("OnDoubleClick");
+ base.OnDoubleClick (e);
+ }
+
+ protected override void OnFontChanged (EventArgs e)
+ {
+ results.Add ("OnFontChanged");
+ base.OnFontChanged (e);
+ }
+
+ protected override void OnForeColorChanged (EventArgs e)
+ {
+ results.Add ("OnForeColorChanged");
+ base.OnForeColorChanged (e);
+ }
+
+ protected override void OnImeModeChanged (EventArgs e)
+ {
+ results.Add ("OnImeModeChanged");
+ base.OnImeModeChanged (e);
+ }
+
+ protected override void OnMouseDown (MouseEventArgs e)
+ {
+ results.Add ("OnMouseDown");
+ base.OnMouseDown (e);
+ }
+
+ protected override void OnMouseMove (MouseEventArgs e)
+ {
+ results.Add ("OnMouseMove");
+ base.OnMouseMove (e);
+ }
+
+ protected override void OnMouseEnter (EventArgs e)
+ {
+ results.Add ("OnMouseEnter");
+ base.OnMouseEnter (e);
+ }
+
+ protected override void OnMouseLeave (EventArgs e)
+ {
+ results.Add ("OnMouseLeave");
+ base.OnMouseLeave (e);
+ }
+
+ protected override void OnMouseHover (EventArgs e)
+ {
+ results.Add ("OnMouseHover");
+ base.OnMouseHover (e);
+ }
+
+ protected override void OnMouseUp (MouseEventArgs e)
+ {
+ results.Add ("OnMouseUp");
+ base.OnMouseUp (e);
+ }
+
+ protected override void OnHandleCreated (EventArgs e)
+ {
+ results.Add ("OnHandleCreated");
+ base.OnHandleCreated (e);
+ }
+
+ protected override void OnBindingContextChanged (EventArgs e)
+ {
+ results.Add ("OnBindingContextChanged");
+ base.OnBindingContextChanged (e);
+ }
+
+ protected override void OnInvalidated (InvalidateEventArgs e)
+ {
+ results.Add("OnInvalidated");
+ base.OnInvalidated (e);
+ }
+
+ protected override void OnResize (EventArgs e)
+ {
+ results.Add("OnResize");
+ base.OnResize (e);
+ }
+
+ protected override void OnSizeChanged (EventArgs e)
+ {
+ results.Add("OnSizeChanged");
+ base.OnSizeChanged (e);
+ }
+
+ protected override void OnLayout (LayoutEventArgs e)
+ {
+ results.Add("OnLayout");
+ base.OnLayout (e);
+ }
+
+ protected override void OnVisibleChanged (EventArgs e)
+ {
+ results.Add("OnVisibleChanged");
+ base.OnVisibleChanged (e);
+ }
+
+ protected override void OnScroll (ScrollEventArgs e)
+ {
+ results.Add("OnScroll");
+ base.OnScroll (e);
+ }
+
+ protected override void OnTextChanged (EventArgs e)
+ {
+ results.Add("OnTextChanged");
+ base.OnTextChanged (e);
+ }
+
+ protected override void OnValueChanged (EventArgs e)
+ {
+ results.Add("OnValueChanged");
+ base.OnValueChanged (e);
+ }
+
+ protected override void OnPaint (PaintEventArgs e)
+ {
+ results.Add("OnPaint");
+ base.OnPaint (e);
+ }
+
+ public ArrayList Results {
+ get { return results; }
+ }
+
+ public void MoveMouse ()
+ {
+ Message m;
+
+ m = new Message ();
+
+ m.Msg = (int)WndMsg.WM_NCHITTEST;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x0;
+ m.LParam = (IntPtr)0x1c604ea;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_SETCURSOR;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x100448;
+ m.LParam = (IntPtr)0x2000001;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_MOUSEFIRST;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x0;
+ m.LParam = (IntPtr)0x14000b;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_MOUSEHOVER;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x0;
+ m.LParam = (IntPtr)0x14000b;
+ this.WndProc(ref m);
+ }
+
+ public void MouseClick()
+ {
+
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_LBUTTONDOWN;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x01;
+ m.LParam = (IntPtr)0x9004f;
+ this.WndProc(ref m);
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_LBUTTONUP;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x01;
+ m.LParam = (IntPtr)0x9004f;
+ this.WndProc(ref m);
+ }
+
+ public void MouseDoubleClick ()
+ {
+ MouseClick ();
+ MouseClick ();
+ }
+ public void MouseRightDown()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_RBUTTONDOWN;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x01;
+ m.LParam = (IntPtr)0x9004f;
+ this.WndProc(ref m);
+ }
+
+ public void MouseRightUp()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_RBUTTONUP;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x01;
+ m.LParam = (IntPtr)0x9004f;
+ this.WndProc(ref m);
+ }
+
+ public void ScrollNow ()
+ {
+ Message m;
+
+ m = new Message ();
+
+ m.Msg = 8468;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x1;
+ m.LParam = (IntPtr)0x1a051a;
+ this.WndProc(ref m);
+
+ m.Msg = 233;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x1;
+ m.LParam = (IntPtr)0x12eb34;
+ this.WndProc(ref m);
+ }
+ }
+ [TestFixture]
+ public class ScrollbarTest
+ {
+ [Test]
+ public void PubPropTest ()
+ {
+ MyScrollBar myscrlbar = new MyScrollBar ();
+
+ // B
+ myscrlbar.BackColor = Color.Red;
+ Assert.AreEqual (255, myscrlbar.BackColor.R, "B2");
+ myscrlbar.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
+ Assert.AreEqual (16, myscrlbar.BackgroundImage.Height, "B3");
+
+ // F
+ Assert.AreEqual ("ff000000", myscrlbar.ForeColor.Name, "F1");
+
+ // I
+ //Assert.AreEqual (ImeMode.Disable, myscrlbar.ImeMode, "I1");
+
+ // L
+ Assert.AreEqual (10, myscrlbar.LargeChange, "L1");
+
+ // M
+ Assert.AreEqual (100, myscrlbar.Maximum, "M1");
+ Assert.AreEqual (0, myscrlbar.Minimum, "M2");
+ myscrlbar.Maximum = 300;
+ myscrlbar.Minimum = 100;
+ Assert.AreEqual (300, myscrlbar.Maximum, "M3");
+ Assert.AreEqual (100, myscrlbar.Minimum, "M4");
+
+ // S
+ Assert.AreEqual (null, myscrlbar.Site, "S1");
+ Assert.AreEqual (1, myscrlbar.SmallChange, "S2");
+ myscrlbar.SmallChange = 10;
+ Assert.AreEqual (10, myscrlbar.SmallChange, "S3");
+
+ // T
+ Assert.AreEqual (false, myscrlbar.TabStop, "T1");
+ myscrlbar.TabStop = true;
+ Assert.AreEqual (true, myscrlbar.TabStop, "T2");
+ Assert.AreEqual ("", myscrlbar.Text, "T3");
+ myscrlbar.Text = "MONO SCROLLBAR";
+ Assert.AreEqual ("MONO SCROLLBAR", myscrlbar.Text, "T4");
+
+ // V
+ Assert.AreEqual (100, myscrlbar.Value, "V1");
+ myscrlbar.Value = 150;
+ Assert.AreEqual (150, myscrlbar.Value, "V2");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ExceptionValueTest ()
+ {
+ MyScrollBar myscrlbar = new MyScrollBar ();
+ myscrlbar.Minimum = 10;
+ myscrlbar.Maximum = 20;
+ myscrlbar.Value = 9;
+ myscrlbar.Value = 21;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ExceptionSmallChangeTest ()
+ {
+ MyScrollBar myscrlbar = new MyScrollBar ();
+ myscrlbar.SmallChange = -1;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ExceptionLargeChangeTest ()
+ {
+ MyScrollBar myscrlbar = new MyScrollBar ();
+ myscrlbar.LargeChange = -1;
+ }
+
+ [Test, Ignore ("Look into this")]
+ public void PubMethodTest ()
+ {
+ MyScrollBar myscrlbar = new MyScrollBar ();
+ myscrlbar.Text = "New HScrollBar";
+ Assert.AreEqual ("System.Windows.Forms.HScrollBar, Minimum: 0, Maximum: 100, Value: 0",
+ myscrlbar.ToString (), "T5");
+ }
+ }
+
+ [TestFixture]
+ public class ScrollBarEventTest
+ {
+ static bool eventhandled = false;
+ public void ScrollBar_EventHandler (object sender,EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ public void ScrollBarMouse_EventHandler (object sender,MouseEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ public void ScrollBarScroll_EventHandler (object sender,ScrollEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ public void ScrollBarPaint_EventHandler (object sender,PaintEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void BackColorChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ScrollBar myHscrlbar = new HScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.BackColorChanged += new EventHandler (ScrollBar_EventHandler);
+ myHscrlbar.BackColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "B4");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void BackgroundImageChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ScrollBar myHscrlbar = new HScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.BackgroundImageChanged += new EventHandler (ScrollBar_EventHandler);
+ myHscrlbar.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
+ Assert.AreEqual (true, eventhandled, "B5");
+ eventhandled = false;
+ }
+
+ [Test, Ignore ("Need to send proper Click / DoubleClick")]
+ public void ClickTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar myHscrlbar = new MyScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.Click += new EventHandler (ScrollBar_EventHandler);
+ myHscrlbar.MouseClick ();
+
+ Assert.AreEqual (false, eventhandled, "C1");
+ }
+
+ [Test, Ignore ("Need to send proper Click / DoubleClick")]
+ public void DoubleClickTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar myHscrlbar = new MyScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.DoubleClick += new EventHandler (ScrollBar_EventHandler);
+ myHscrlbar.MouseDoubleClick ();
+
+ Assert.AreEqual (false, eventhandled, "D1");
+ }
+
+ [Test]
+ public void FontChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ScrollBar myHscrlbar = new HScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.FontChanged += new EventHandler (ScrollBar_EventHandler);
+ FontDialog myFontDialog = new FontDialog();
+ myHscrlbar.Font = myFontDialog.Font;
+ Assert.AreEqual (true, eventhandled, "F2");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void ForeColorChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ScrollBar myHscrlbar = new HScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.ForeColorChanged += new EventHandler (ScrollBar_EventHandler);
+ myHscrlbar.ForeColor = Color.Azure;
+ Assert.AreEqual (true, eventhandled, "F3");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void ImeModehangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ScrollBar myHscrlbar = new HScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.ImeModeChanged += new EventHandler (ScrollBar_EventHandler);
+ myHscrlbar.ImeMode = ImeMode.Katakana;
+ Assert.AreEqual (true, eventhandled, "I2");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void MouseDownTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar myHscrlbar = new MyScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.MouseDown += new MouseEventHandler (ScrollBarMouse_EventHandler);
+ myHscrlbar.MouseRightDown ();
+
+ Assert.AreEqual (true, eventhandled, "M5");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void MouseMoveTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar myHscrlbar = new MyScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.MouseMove += new MouseEventHandler (ScrollBarMouse_EventHandler);
+ myHscrlbar.MoveMouse ();
+
+ Assert.AreEqual (true, eventhandled, "M6");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void MouseUpTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar myHscrlbar = new MyScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.MouseUp += new MouseEventHandler (ScrollBarMouse_EventHandler);
+ myHscrlbar.MouseRightUp ();
+
+ Assert.AreEqual (true, eventhandled, "M7");
+ eventhandled = false;
+ }
+
+ [Test, Ignore ("How can we force it to pain?")]
+ public void PaintTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar myHscrlbar = new MyScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.Paint += new PaintEventHandler (ScrollBarPaint_EventHandler);
+
+ myHscrlbar.Refresh ();
+
+ Assert.AreEqual (true, eventhandled, "P1");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void ScrollTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar myHscrlbar = new MyScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.Scroll += new ScrollEventHandler (ScrollBarScroll_EventHandler);
+ myHscrlbar.ScrollNow ();
+
+ Assert.AreEqual (true, eventhandled, "S4");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void TextChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar myHscrlbar = new MyScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.TextChanged += new EventHandler (ScrollBar_EventHandler);
+ myHscrlbar.Text = "foo";
+
+ Assert.AreEqual (true, eventhandled, "T6");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void ValueChangeTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar myHscrlbar = new MyScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.Value = 40 ;
+ myHscrlbar.ValueChanged += new EventHandler (ScrollBar_EventHandler);
+ myHscrlbar.Value = 50 ;
+ Assert.AreEqual (true, eventhandled, "V3");
+ eventhandled = false;
+ }
+ }
+
+public class MyHScrollBar : HScrollBar
+ {
+ public MyHScrollBar () : base ()
+ {
+ }
+
+ public Size MyDefaultSize {
+ get { return DefaultSize; }
+ }
+
+ public CreateParams MyCreateParams {
+ get { return CreateParams; }
+ }
+ }
+
+ [TestFixture]
+ public class MyHScrollBarTest
+ {
+ [Test]
+ public void ProtectedTest ()
+ {
+ MyHScrollBar msbar = new MyHScrollBar ();
+
+ Assert.AreEqual (80, msbar.MyDefaultSize.Width, "D1");
+ Assert.AreEqual (21, msbar.MyDefaultSize.Height, "D2");
+ }
+ }
+
+public class MyVScrollBar : VScrollBar
+ {
+ public MyVScrollBar () : base ()
+ {
+ }
+
+ public Size MyDefaultSize {
+ get { return DefaultSize; }
+ }
+
+ public CreateParams MyCreateParams {
+ get { return CreateParams; }
+ }
+ }
+
+ [TestFixture]
+ public class MyVScrollBarTest
+ {
+ [Test]
+ public void PubMethodTest ()
+ {
+ MyVScrollBar msbar = new MyVScrollBar ();
+
+ Assert.AreEqual (RightToLeft.No, msbar.RightToLeft, "R1");
+
+ }
+
+ [Test]
+ public void ProtMethodTest ()
+ {
+ MyVScrollBar msbar = new MyVScrollBar ();
+
+ Assert.AreEqual (21, msbar.MyDefaultSize.Width, "D3");
+ Assert.AreEqual (80, msbar.MyDefaultSize.Height, "D4");
+ }
+ }
+
+ [TestFixture]
+ public class HScrollBarTestEventsOrder
+ {
+ public string [] ArrayListToString (ArrayList arrlist)
+ {
+ string [] retval = new string [arrlist.Count];
+ for (int i = 0; i < arrlist.Count; i++)
+ retval[i] = (string)arrlist[i];
+ return retval;
+ }
+
+ [Test]
+ public void CreateEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void BackColorChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnBackColorChanged",
+ "OnInvalidated"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.BackColor = Color.Aqua;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void BackgroundImageChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnBackgroundImageChanged",
+ "OnInvalidated"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test, Ignore ("Need to send proper Click / DoubleClick")]
+ public void ClickEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.MouseClick ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test, Ignore ("Need to send proper Click / DoubleClick")]
+ public void DoubleClickEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.MouseDoubleClick ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void FontChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ FontDialog myFontDialog = new FontDialog();
+ s.Font = myFontDialog.Font;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void ForeColorChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnForeColorChanged",
+ "OnInvalidated"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.ForeColor = Color.Aqua;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void ImeModeChangedChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnImeModeChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.ImeMode = ImeMode.Katakana;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void MouseDownEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnMouseDown"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.MouseRightDown ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void MouseMoveEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnMouseMove",
+ "OnMouseHover"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.MoveMouse ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void MouseUpEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnMouseUp"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.MouseRightUp ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void PaintEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnInvalidated"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.Visible = true;
+ s.Refresh ();
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void ScrollEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnScroll",
+ "OnValueChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.ScrollNow ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void TextChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnTextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.Text = "foobar";
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void ValueChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnValueChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.Value = 10;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+ }
+
+public class MyScrollBar2 : HScrollBar
+ {
+ protected ArrayList results = new ArrayList ();
+ public MyScrollBar2 () : base ()
+ {
+ this.HandleCreated += new EventHandler (HandleCreated_Handler);
+ this.BackColorChanged += new EventHandler (BackColorChanged_Handler);
+ this.BackgroundImageChanged += new EventHandler (BackgroundImageChanged_Handler);
+ this.BindingContextChanged += new EventHandler (BindingContextChanged_Handler);
+ this.Click += new EventHandler (Click_Handler);
+ this.DoubleClick += new EventHandler (DoubleClick_Handler);
+ this.FontChanged += new EventHandler (FontChanged_Handler);
+ this.ForeColorChanged += new EventHandler (ForeColorChanged_Handler);
+ this.ImeModeChanged += new EventHandler (ImeModeChanged_Handler);
+ this.MouseDown += new MouseEventHandler (MouseDown_Handler);
+ this.MouseMove += new MouseEventHandler (MouseMove_Handler);
+ this.MouseUp += new MouseEventHandler (MouseUp_Handler);
+ this.Invalidated += new InvalidateEventHandler (Invalidated_Handler);
+ this.Resize += new EventHandler (Resize_Handler);
+ this.SizeChanged += new EventHandler (SizeChanged_Handler);
+ this.Layout += new LayoutEventHandler (Layout_Handler);
+ this.VisibleChanged += new EventHandler (VisibleChanged_Handler);
+ this.Paint += new PaintEventHandler (Paint_Handler);
+ this.Scroll += new ScrollEventHandler (Scroll_Handler);
+ this.TextChanged += new EventHandler (TextChanged_Handler);
+ this.ValueChanged += new EventHandler (ValueChanged_Handler);
+ }
+
+ protected void HandleCreated_Handler (object sender, EventArgs e)
+ {
+ results.Add ("HandleCreated");
+ }
+
+ protected void BackColorChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("BackColorChanged");
+ }
+
+ protected void BackgroundImageChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("BackgroundImageChanged");
+ }
+
+ protected void Click_Handler (object sender, EventArgs e)
+ {
+ results.Add ("Click");
+ }
+
+ protected void DoubleClick_Handler (object sender, EventArgs e)
+ {
+ results.Add ("DoubleClick");
+ }
+
+ protected void FontChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("FontChanged");
+ }
+
+ protected void ForeColorChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("ForeColorChanged");
+ }
+
+ protected void ImeModeChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("ImeModeChanged");
+ }
+
+ protected void MouseDown_Handler (object sender, MouseEventArgs e)
+ {
+ results.Add ("MouseDown");
+ }
+
+ protected void MouseMove_Handler (object sender, MouseEventArgs e)
+ {
+ results.Add ("MouseMove");
+ }
+
+ protected void MouseUp_Handler (object sender, MouseEventArgs e)
+ {
+ results.Add ("MouseUp");
+ }
+
+ protected void BindingContextChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("BindingContextChanged");
+ }
+
+ protected void Invalidated_Handler (object sender, InvalidateEventArgs e)
+ {
+ results.Add("Invalidated");
+ }
+
+ protected void Resize_Handler (object sender, EventArgs e)
+ {
+ results.Add("Resize");
+ }
+
+ protected void SizeChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add("SizeChanged");
+ }
+
+ protected void Layout_Handler (object sender, LayoutEventArgs e)
+ {
+ results.Add("Layout");
+ }
+
+ protected void VisibleChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add("VisibleChanged");
+ }
+
+ protected void Paint_Handler (object sender, PaintEventArgs e)
+ {
+ results.Add("Paint");
+ }
+
+ protected void Scroll_Handler (object sender, ScrollEventArgs e)
+ {
+ results.Add ("Scroll");
+ }
+
+ protected void TextChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("TextChanged");
+ }
+
+ protected void ValueChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("ValueChanged");
+ }
+
+ public ArrayList Results {
+ get { return results; }
+ }
+
+ public void MoveMouse ()
+ {
+ Message m;
+
+ m = new Message ();
+
+ m.Msg = (int)WndMsg.WM_NCHITTEST;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x0;
+ m.LParam = (IntPtr)0x1c604ea;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_SETCURSOR;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x100448;
+ m.LParam = (IntPtr)0x2000001;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_MOUSEFIRST;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x0;
+ m.LParam = (IntPtr)0x14000b;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_MOUSEHOVER;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x0;
+ m.LParam = (IntPtr)0x14000b;
+ this.WndProc(ref m);
+ }
+
+ public void MouseRightDown()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_RBUTTONDOWN;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x01;
+ m.LParam = (IntPtr)0x9004f;
+ this.WndProc(ref m);
+ }
+
+ public void MouseClick()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_LBUTTONDOWN;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x01;
+ m.LParam = (IntPtr)0x9004f;
+ this.WndProc(ref m);
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_LBUTTONUP;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x01;
+ m.LParam = (IntPtr)0x9004f;
+ this.WndProc(ref m);
+ }
+
+ public void MouseDoubleClick ()
+ {
+ MouseClick ();
+ MouseClick ();
+ }
+
+ public void MouseRightUp()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_RBUTTONUP;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x01;
+ m.LParam = (IntPtr)0x9004f;
+ this.WndProc(ref m);
+ }
+
+ public void ScrollNow ()
+ {
+ Message m;
+
+ m = new Message ();
+
+ m.Msg = 8468;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x1;
+ m.LParam = (IntPtr)0x1a051a;
+ this.WndProc(ref m);
+
+ m.Msg = 233;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x1;
+ m.LParam = (IntPtr)0x12eb34;
+ this.WndProc(ref m);
+ }
+ }
+
+ [TestFixture]
+ public class HScrollBarTestEventsOrder2
+ {
+ public string [] ArrayListToString (ArrayList arrlist)
+ {
+ string [] retval = new string [arrlist.Count];
+ for (int i = 0; i < arrlist.Count; i++)
+ retval[i] = (string)arrlist[i];
+ return retval;
+ }
+
+ [Test]
+ public void CreateEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void BackColorChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Invalidated",
+ "BackColorChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.BackColor = Color.Aqua;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void BackgroundImageChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Invalidated",
+ "BackgroundImageChanged"
+
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test, Ignore ("Need to send proper Click / DoubleClick")]
+ public void ClickEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.MouseClick ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test, Ignore ("Need to send proper Click / DoubleClick")]
+ public void DoubleClickEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.MouseDoubleClick ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void FontChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ FontDialog myFontDialog = new FontDialog();
+ s.Font = myFontDialog.Font;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void ForeColorChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Invalidated",
+ "ForeColorChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.ForeColor = Color.Aqua;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void ImeModeChangedChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "ImeModeChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.ImeMode = ImeMode.Katakana;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void MouseDownEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "MouseDown"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.MouseRightDown ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void MouseMoveEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "MouseMove"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.MoveMouse ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void MouseUpEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "MouseUp"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.MouseRightUp ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void PaintEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Invalidated"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.Visible = true;
+ s.Refresh ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void ScrollEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Scroll",
+ "ValueChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.ScrollNow ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void TextChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "TextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.Text = "foobar";
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void ValueChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "ValueChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.Value = 10;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+ }
+
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/StatusBarTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/StatusBarTest.cs
new file mode 100644
index 00000000000..a2bfe319124
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/StatusBarTest.cs
@@ -0,0 +1,75 @@
+//
+// StatusBarTest.cs: Test cases for StatusBar.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Runtime.Remoting;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class StatusBarTest
+ {
+
+ [Test]
+ public void StatusBarPropertyTest ()
+ {
+ Form myform = new Form ();
+ StatusBar mysbar = new StatusBar ();
+ StatusBarPanel sbarpanel1 = new StatusBarPanel ();
+ StatusBarPanel sbarpanel2 = new StatusBarPanel ();
+ sbarpanel1.Text = "Status Quo";
+ sbarpanel2.Text = "State 2";
+ mysbar.Panels.Add (sbarpanel1);
+ mysbar.Panels.Add (sbarpanel2);
+ myform.Controls.Add (mysbar);
+
+ // B
+ Assert.AreEqual ("Control", mysbar.BackColor.Name, "#B1");
+ mysbar.BackColor = Color.Red;
+ Assert.AreEqual (212, mysbar.BackColor.R, "#B2");
+ mysbar.BackgroundImage = Image.FromFile ("M.gif");
+ Assert.AreEqual (60, mysbar.BackgroundImage.Height, "#B3");
+
+ // D
+ Assert.AreEqual (DockStyle.Bottom, mysbar.Dock, "#D1");
+
+ // F
+ Assert.AreEqual (8.25, mysbar.Font.Size, "#F1");
+ Assert.AreEqual ("ControlText", mysbar.ForeColor.Name, "#F2");
+
+ // P
+ Assert.AreEqual (sbarpanel1.Text, mysbar.Panels [0].Text , "#P1");
+
+ // S
+ Assert.AreEqual (false, mysbar.ShowPanels, "#S1");
+ Assert.AreEqual (true, mysbar.SizingGrip, "#S2");
+ Assert.AreEqual (null, mysbar.Site, "#S3");
+
+ // T
+ Assert.AreEqual ("", mysbar.Text, "#T1");
+ mysbar.Text = "MONO STATUSBAR";
+ Assert.AreEqual ("MONO STATUSBAR", mysbar.Text, "#T2");
+
+ }
+
+ [Test]
+ public void ToStringMethodTest ()
+ {
+ StatusBar mysbar = new StatusBar ();
+ mysbar.Text = "New StatusBar";
+ Assert.AreEqual ("System.Windows.Forms.StatusBar, Panels.Count: 0", mysbar.ToString (), "#T3");
+ }
+ //[MonoTODO ("Test case for DrawItem")]
+ //[MonoTODO ("Test case for PanelClick")]
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TabControlTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TabControlTest.cs
new file mode 100644
index 00000000000..ede33a91594
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TabControlTest.cs
@@ -0,0 +1,87 @@
+//
+// TabControlTest.cs: Test cases for TabControl.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+[TestFixture]
+public class TabControlTest
+{
+ [Test]
+ public void TabControlPropertyTest ()
+ {
+ Form myForm = new Form ();
+ TabControl myTabControl = new TabControl ();
+ myTabControl.Visible = true;
+ myTabControl.Name = "Mono TabControl";
+
+ // A
+ Assert.AreEqual (TabAlignment.Top, myTabControl.Alignment, "A1");
+ Assert.AreEqual (TabAppearance.Normal, myTabControl.Appearance, "#A2");
+
+ // D
+ Assert.AreEqual (4, myTabControl.DisplayRectangle.X, "#D1");
+ Assert.AreEqual (4, myTabControl.DisplayRectangle.Y, "#D2");
+ Assert.AreEqual (192, myTabControl.DisplayRectangle.Width, "#D3");
+ Assert.AreEqual (92, myTabControl.DisplayRectangle.Height, "#D4");
+ Assert.AreEqual (TabDrawMode.Normal, myTabControl.DrawMode, "#D5");
+
+ // H
+ Assert.AreEqual (false, myTabControl.HotTrack, "#H1");
+
+ // I
+ Assert.AreEqual (null, myTabControl.ImageList, "#I1");
+ Assert.AreEqual (18, myTabControl.ItemSize.Height, "#I2");
+ Assert.AreEqual (0, myTabControl.ItemSize.Width, "#I3");
+
+ // M
+ Assert.AreEqual (false, myTabControl.Multiline, "#M1");
+
+ // P
+ Assert.AreEqual (6, myTabControl.Padding.X, "#P1");
+ Assert.AreEqual (3, myTabControl.Padding.Y, "#P1");
+
+ // R
+ Assert.AreEqual (0, myTabControl.RowCount, "#R1");
+
+ // S
+ Assert.AreEqual (-1, myTabControl.SelectedIndex, "#S1");
+ Assert.AreEqual (null, myTabControl.SelectedTab, "#S2");
+ Assert.AreEqual (false, myTabControl.ShowToolTips, "#S3");
+ Assert.AreEqual (TabSizeMode.Normal, myTabControl.SizeMode, "#S4");
+
+ // T
+ Assert.AreEqual (0, myTabControl.TabCount, "#T1");
+ Assert.AreEqual (0, myTabControl.TabPages.Count, "#T2");
+ }
+
+ [Test]
+ public void GetTabRectTest ()
+ {
+ TabControl myTabControl = new TabControl ();
+ TabPage myTabPage = new TabPage();
+ myTabControl.Controls.Add(myTabPage);
+ myTabPage.TabIndex = 0;
+ Rectangle myTabRect = new Rectangle ();
+ Assert.AreEqual (2, myTabControl.GetTabRect (0).X, "#GetT1");
+ Assert.AreEqual (2, myTabControl.GetTabRect (0).Y, "#GetT2");
+ Assert.AreEqual (42, myTabControl.GetTabRect (0).Width, "#GetT3");
+ Assert.AreEqual (18, myTabControl.GetTabRect (0).Height, "#GetT4");
+ }
+
+ [Test]
+ public void ToStringTest ()
+ {
+ TabControl myTabControl = new TabControl ();
+ Assert.AreEqual ("System.Windows.Forms.TabControl, TabPages.Count: 0", myTabControl.ToString(), "#Str1");
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TestImageIndexConverter.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TestImageIndexConverter.cs
new file mode 100644
index 00000000000..679dcef4ea2
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TestImageIndexConverter.cs
@@ -0,0 +1,157 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2004 Novell, Inc.
+//
+// Authors:
+// Ravindra (rkumar@novell.com)
+//
+//
+
+using NUnit.Framework;
+using System;
+using System.ComponentModel;
+using System.Windows.Forms;
+using System.Globalization;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class ImageIndexConverterTest
+ {
+ ToolBarButton button;
+ PropertyDescriptorCollection pdc;
+ ImageIndexConverter ic;
+
+ public ImageIndexConverterTest ()
+ {
+ button = new ToolBarButton ();
+ pdc = TypeDescriptor.GetProperties (button);
+ ic = (ImageIndexConverter) pdc.Find ("ImageIndex", true).Converter;
+ }
+
+ [TearDown]
+ public void TearDown () { }
+
+ [SetUp]
+ public void SetUp () { }
+
+ [Test]
+ public void TestCanConvertFrom ()
+ {
+ Assert.IsFalse (ic.CanConvertFrom (typeof (byte)), "CanConvertFromByte must be false.");
+ Assert.IsFalse (ic.CanConvertFrom (typeof (char)), "CanConvertFromChar must be false.");
+ Assert.IsFalse (ic.CanConvertFrom (typeof (int)), "CanConvertFromInt must be false.");
+ Assert.IsFalse (ic.CanConvertFrom (typeof (float)), "CanConvertFromFloat must be false.");
+ Assert.IsFalse (ic.CanConvertFrom (typeof (long)), "CanConvertFromLong must be false.");
+ Assert.IsFalse (ic.CanConvertFrom (typeof (double)), "CanConvertFromDouble must be false.");
+ Assert.IsTrue (ic.CanConvertFrom (typeof (string)), "CanConvertFromString must be true.");
+ Assert.IsFalse (ic.CanConvertFrom (typeof (object)), "CanConvertFromObject must be false.");
+ }
+
+ [Test]
+ public void TestCanConvertTo ()
+ {
+ Assert.IsTrue (ic.CanConvertTo (typeof (byte)), "CanConvertToByte must be true.");
+ Assert.IsTrue (ic.CanConvertTo (typeof (char)), "CanConvertToChar must be true.");
+ Assert.IsTrue (ic.CanConvertTo (typeof (int)), "CanConvertToInt must be true.");
+ Assert.IsTrue (ic.CanConvertTo (typeof (float)), "CanConvertToFloat must be true.");
+ Assert.IsTrue (ic.CanConvertTo (typeof (long)), "CanConvertToLong must be true.");
+ Assert.IsTrue (ic.CanConvertTo (typeof (double)), "CanConvertToDouble must be true.");
+ Assert.IsTrue (ic.CanConvertTo (typeof (string)), "CanConvertToString must be true.");
+ Assert.IsFalse (ic.CanConvertTo (typeof (object)), "CanConvertToObject must be false.");
+ }
+
+ [Test]
+ public void TestConvertFrom ()
+ {
+ Assert.AreEqual (-12, (int) ic.ConvertFrom (null, CultureInfo.InvariantCulture, "-12"), "ConvertFromStr -12");
+ Assert.AreEqual (-1, (int) ic.ConvertFrom (null, CultureInfo.InvariantCulture, "-1"), "ConvertFromStr -1");
+ Assert.AreEqual (1, (int) ic.ConvertFrom (null, CultureInfo.InvariantCulture, "1"), "ConvertFromStr 1");
+
+ try {
+ ic.ConvertFrom (null, CultureInfo.InvariantCulture, 1.2f);
+ Assert.Fail ("ConvertFromFloat did not throw exception.");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "ConvertFromFloat did not throw NotSupportedException.");
+ }
+
+ try {
+ ic.ConvertFrom (null, CultureInfo.InvariantCulture, 1);
+ Assert.Fail ("ConvertFromInt did not throw exception.");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "ConvertFromInt did not throw NotSupportedException.");
+ }
+ }
+
+ [Test]
+ public void TestConvertTo ()
+ {
+ Assert.AreEqual ("(none)", ic.ConvertTo (null, CultureInfo.InvariantCulture, -1, typeof (string)), "ConvertInt_Minus1_ToStr");
+ Assert.AreEqual ("0", ic.ConvertTo (null, CultureInfo.InvariantCulture, 0, typeof (string)), "ConvertInt_0_ToStr");
+ Assert.AreEqual ("1", ic.ConvertTo (null, CultureInfo.InvariantCulture, 1, typeof (string)), "ConvertInt_1_ToStr");
+ Assert.AreEqual (0, ic.ConvertTo (null, CultureInfo.InvariantCulture, 0, typeof (int)), "ConvertInt_0_ToInt");
+ Assert.AreEqual ("(none)", ic.ConvertTo (null, CultureInfo.InvariantCulture, "(none)", typeof (string)), "ConvertStr_none_ToStr");
+ Assert.AreEqual ("-1", ic.ConvertTo (null, CultureInfo.InvariantCulture, "-1", typeof (string)), "ConvertStr_Minus1_ToStr");
+ Assert.AreEqual (-1, ic.ConvertTo (null, CultureInfo.InvariantCulture, -1, typeof (int)), "ConvertInt_Minus1_ToInt");
+ Assert.AreEqual (1, ic.ConvertTo (null, CultureInfo.InvariantCulture, 1, typeof (int)), "ConvertInt_1_ToInt");
+ Assert.AreEqual (-1, ic.ConvertTo (null, CultureInfo.InvariantCulture, "-1", typeof (int)), "ConvertStr_Minus1_ToInt");
+ Assert.AreEqual (0, ic.ConvertTo (null, CultureInfo.InvariantCulture, "0", typeof (int)), "ConvertStr_0_ToInt");
+ Assert.AreEqual (1, ic.ConvertTo (null, CultureInfo.InvariantCulture, "1", typeof (int)), "ConvertStr_1_ToInt");
+
+ Assert.AreEqual (2, ic.ConvertTo (null, CultureInfo.InvariantCulture, 1.5f, typeof (int)), "ConvertFloat_1_5_ToInt must return 2.");
+
+ try {
+ ic.ConvertTo (null, CultureInfo.InvariantCulture, "-1.5f", typeof (int));
+ Assert.Fail("ConvertFloatStrToInt must throw exception.");
+ } catch (Exception e) {
+ Assert.IsTrue (e is FormatException, "ConvertFloatStrToInt must throw FormatException.");
+ }
+
+ Assert.AreEqual (1.5, ic.ConvertTo (null, CultureInfo.InvariantCulture, 1.5f, typeof (float)), "ConvertFloat_1_5_ToFloat");
+ }
+
+ [Test]
+ public void TestGetCreateInstanceSupported ()
+ {
+ Assert.IsFalse (ic.GetCreateInstanceSupported (), "GetCreateInstance must return false.");
+ }
+
+ [Test]
+ public void TestGetStandardValuesSupported ()
+ {
+ Assert.IsTrue (ic.GetStandardValuesSupported (), "GetStandardValuesSupported must return true.");
+ }
+
+ [Test]
+ public void TestGetStandardValuesExclusive ()
+ {
+ Assert.IsFalse (ic.GetStandardValuesExclusive (), "GetStandardValuesExclusive must return false.");
+ }
+
+ [Test]
+ public void TestGetStandardValues ()
+ {
+ TypeConverter.StandardValuesCollection stdVals = ic.GetStandardValues (null);
+ Assert.AreEqual (1, stdVals.Count, "StandardValues count must be 1.");
+ Assert.AreEqual (-1, stdVals [0], "Standard Value count must be -1.");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TextBoxTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TextBoxTest.cs
new file mode 100644
index 00000000000..0d2d0fc77ae
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TextBoxTest.cs
@@ -0,0 +1,202 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class TextBoxBaseTest
+ {
+ TextBox textBox;
+
+ [SetUp]
+ public void SetUp()
+ {
+ textBox = new TextBox();
+ }
+
+ [Test]
+ public void TextBoxBasePropertyTest ()
+ {
+ Assert.AreEqual (false, textBox.AcceptsTab, "#1a");
+ textBox.Multiline = true;
+ textBox.AcceptsTab = true;
+ SendKeys.SendWait ("^%");
+ Assert.AreEqual (true, textBox.AcceptsTab, "#1b");
+ Assert.AreEqual (true, textBox.AutoSize, "#2");
+ Assert.AreEqual ("Window", textBox.BackColor.Name, "#3a");
+ textBox.BackColor = Color.White;
+ Assert.AreEqual ("White", textBox.BackColor.Name, "#3b");
+ Assert.AreEqual (null, textBox.BackgroundImage, "#4a");
+ string gif = "M.gif";
+ textBox.BackgroundImage = Image.FromFile (gif);
+ // comparing image objects fails on MS .Net so using Size property
+ Assert.AreEqual (Image.FromFile(gif, true).Size, textBox.BackgroundImage.Size, "#4b");
+
+ Assert.AreEqual (BorderStyle.Fixed3D, textBox.BorderStyle, "#5");
+ Assert.AreEqual (false, textBox.CanUndo, "#6a");
+ textBox.Paste ();
+ Assert.AreEqual (true, textBox.CanUndo, "#6b");
+ textBox.ClearUndo ();
+ Assert.AreEqual (false, textBox.CanUndo, "#6c");
+ Assert.AreEqual ("WindowText", textBox.ForeColor.Name, "#7");
+ Assert.AreEqual (true, textBox.HideSelection, "#8");
+ Assert.AreEqual (1, textBox.Lines.Length, "#9");
+ Assert.AreEqual (32767, textBox.MaxLength, "#10");
+ Assert.AreEqual (true, textBox.Modified, "#11");
+ Assert.AreEqual (true, textBox.Multiline, "#12a");
+ textBox.WordWrap = false;
+ Assert.AreEqual (true, textBox.Multiline, "#12b");
+ textBox.AcceptsReturn = true;
+ Assert.AreEqual (true, textBox.Multiline, "#12c");
+ Assert.AreEqual (20, textBox.PreferredHeight, "#13");
+ Assert.AreEqual (false, textBox.ReadOnly, "#14");
+ Assert.AreEqual ("", textBox.SelectedText, "#15");
+ textBox.Text = "sample TextBox";
+ Assert.AreEqual (0, textBox.SelectionLength, "#16b");
+ Assert.AreEqual (0, textBox.SelectionStart, "#17");
+ textBox.WordWrap = false;
+ textBox.AcceptsReturn = true;
+ Assert.AreEqual ("sample TextBox", textBox.Text, "#18");
+ Assert.AreEqual (14, textBox.TextLength, "#19");
+ Assert.AreEqual (false, textBox.WordWrap, "#20");
+ }
+
+ [Test]
+ public void TextBoxPropertyTest ()
+ {
+ Assert.AreEqual (false, textBox.AcceptsReturn, "#21");
+ Assert.AreEqual (CharacterCasing.Normal, textBox.CharacterCasing, "#22");
+ Assert.AreEqual ('\0', textBox.PasswordChar, "#23");
+ textBox.PasswordChar = '*';
+ Assert.AreEqual ('*', textBox.PasswordChar, "#23b");
+ Assert.AreEqual (ScrollBars.None, textBox.ScrollBars, "#24");
+ Assert.AreEqual (-1, textBox.SelectionLength, "#25");
+ Assert.AreEqual (HorizontalAlignment.Left , textBox.TextAlign, "#26");
+ }
+
+#if NET_2_0
+ [Test]
+ public void UseSystemPasswordCharDefault()
+ {
+ Assert.IsFalse(textBox.UseSystemPasswordChar);
+ }
+
+ [Test]
+ public void UseSystemPasswordCharOverridesPasswordChar()
+ {
+ textBox.PasswordChar = '!';
+ textBox.UseSystemPasswordChar = true;
+ Assert.AreEqual('*', textBox.PasswordChar);
+ }
+#endif
+
+ [Test]
+ public void AppendTextTest ()
+ {
+ Form f = new Form ();
+ f.Visible = true;
+ textBox.Visible = true;
+ textBox.Text = "TextBox1";
+ TextBox textBox2 = new TextBox ();
+ textBox2.Visible = true;
+ f.Controls.Add (textBox);
+ f.Controls.Add (textBox2);
+ textBox2.AppendText (textBox.Text);
+ Assert.AreEqual ("TextBox1", textBox2.Text, "#27");
+ }
+
+ [Test]
+ public void ClearTest ()
+ {
+ textBox.Text = "TextBox1";
+ Assert.AreEqual ("TextBox1", textBox.Text, "#28a" );
+ textBox.Clear ();
+ Assert.AreEqual ("", textBox.Text, "#28b");
+ }
+
+ [Test]
+ public void ClearUndoTest ()
+ {
+ textBox.Text = "TextBox1";
+ textBox.SelectionLength = 4;
+ textBox.Copy ();
+ Assert.AreEqual ("Text", textBox.SelectedText, "#29a");
+ textBox.Paste ();
+ Assert.AreEqual (true, textBox.CanUndo, "#29b");
+ textBox.ClearUndo ();
+ Assert.AreEqual (false, textBox.CanUndo, "#29c");
+ }
+
+ [Test]
+ public void CopyTest ()
+ {
+ textBox.Text = "ABCDE";
+ textBox.SelectionLength = 4;
+ textBox.Copy ();
+ Assert.AreEqual ("ABCD", textBox.SelectedText, "#30");
+ }
+
+ [Test]
+ public void CutTest ()
+ {
+ textBox.Text = "ABCDE";
+ textBox.SelectionLength = 4;
+ textBox.Cut ();
+ Assert.AreEqual ("E", textBox.Text, "#31");
+ }
+
+ [Test]
+ public void PasteTest ()
+ {
+ textBox.Text = "ABCDE";
+ textBox.SelectionLength = 4;
+ textBox.SelectionStart = textBox.SelectionStart + textBox.SelectionLength;
+ textBox.Paste ();
+ Assert.AreEqual ("ABCDABCD", textBox.Text, "#32");
+ }
+
+ [Test]
+ public void SelectTest ()
+ {
+ textBox.Text = "This is a sample test.";
+ textBox.Select (0, 4);
+ Assert.AreEqual ("This", textBox.SelectedText, "#33");
+ }
+
+ [Test]
+ public void SelectAllTest ()
+ {
+ textBox.Text = "This is a sample test.";
+ textBox.SelectAll ();
+ Assert.AreEqual ("This is a sample test.", textBox.SelectedText, "#34");
+ }
+
+ [Test]
+ public void ToStringTest ()
+ {
+ Assert.AreEqual ("System.Windows.Forms.TextBox, Text: ", textBox.ToString(), "#35");
+ }
+
+ [Test]
+ public void UndoTest1 ()
+ {
+ textBox.Text = "ABCDE";
+ textBox.SelectionLength = 4;
+ textBox.Copy ();
+ textBox.SelectionStart = textBox.SelectionStart + textBox.SelectionLength;
+ textBox.Paste ();
+ textBox.Undo ();
+ Assert.AreEqual ("ABCDE", textBox.Text, "#36");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolBarTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolBarTest.cs
new file mode 100644
index 00000000000..271671a0825
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolBarTest.cs
@@ -0,0 +1,97 @@
+//
+// ToolBarTest.cs: Test cases for ToolBar.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Runtime.Remoting;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class ToolBarTest
+ {
+
+ [Test]
+ public void ToolBarPropertyTest ()
+ {
+ Form myform = new Form ();
+ ToolBar myToolBar = new ToolBar ();
+ ToolBarButton myToolBarButton1 = new ToolBarButton ();
+ ToolBarButton myToolBarButton2 = new ToolBarButton ();
+ myToolBarButton1.Text = "A";
+ myToolBarButton2.Text = "B";
+ myToolBar.Buttons.Add (myToolBarButton1);
+ myToolBar.Buttons.Add (myToolBarButton2);
+ myform.Controls.Add (myToolBar);
+
+ // A
+ Assert.AreEqual (ToolBarAppearance.Normal, myToolBar.Appearance, "#A1");
+ Assert.AreEqual (true, myToolBar.AutoSize, "#A2");
+
+ // B
+ Assert.AreEqual ("Control", myToolBar.BackColor.Name, "#B1");
+ myToolBar.BackColor = Color.Red;
+ Assert.AreEqual (255, myToolBar.BackColor.R, "#B2");
+ myToolBar.BackgroundImage = Image.FromFile ("M.gif");
+ Assert.AreEqual (60, myToolBar.BackgroundImage.Height, "#B3");
+ Assert.AreEqual (BorderStyle.None, myToolBar.BorderStyle, "#B4");
+ myToolBar.BorderStyle = BorderStyle.Fixed3D;
+ Assert.AreEqual (BorderStyle.Fixed3D, myToolBar.BorderStyle, "#B5");
+ Assert.AreEqual (2, myToolBar.Buttons.Count, "#B6");
+ Assert.AreEqual ("B", myToolBar.Buttons [1].Text, "#B7");
+ Assert.AreEqual (39, myToolBar.ButtonSize.Width, "#B8");
+ Assert.AreEqual (36, myToolBar.ButtonSize.Height, "#B9");
+
+ // D
+ Assert.AreEqual (DockStyle.Top, myToolBar.Dock, "#D1");
+ Assert.AreEqual (true, myToolBar.Divider, "#D2");
+ Assert.AreEqual (true, myToolBar.DropDownArrows, "#D3");
+
+ // F
+ Assert.AreEqual ("ControlText", myToolBar.ForeColor.Name, "#F2");
+
+ // I
+ ImageList myImageList = new ImageList ();
+ myImageList.Images.Add (Image.FromFile ("M.gif"));
+ myToolBar.ImageList = myImageList;
+ Assert.AreEqual (1, myToolBar.ImageList.Images.Count, "#I1");
+ Assert.AreEqual (16, myToolBar.ImageSize.Height, "#I2");
+ Assert.AreEqual (16, myToolBar.ImageSize.Width, "#I3");
+ Assert.AreEqual (ImeMode.Disable, myToolBar.ImeMode, "#I4");
+
+ // R
+ Assert.AreEqual (RightToLeft.No, myToolBar.RightToLeft, "#R1");
+
+ // S
+ Assert.AreEqual (true, myToolBar.ShowToolTips, "#S1");
+
+ // T
+ Assert.AreEqual ("", myToolBar.Text, "#T1");
+ myToolBar.Text = "MONO TOOLBAR";
+ Assert.AreEqual ("MONO TOOLBAR", myToolBar.Text, "#T2");
+ Assert.AreEqual (ToolBarTextAlign.Underneath, myToolBar.TextAlign, "#T3");
+
+ // WXYZ
+ Assert.AreEqual (true, myToolBar.Wrappable, "#W1");
+ }
+
+ [Test]
+ public void ToStringMethodTest ()
+ {
+ ToolBar myToolBar = new ToolBar ();
+ myToolBar.Text = "New ToolBar";
+ Assert.AreEqual ("System.Windows.Forms.ToolBar, Buttons.Count: 0", myToolBar.ToString (), "#T3");
+ }
+ }
+ // [MonoTODO ("Add test for ButtonClickEvent (Visual Test)"]
+ // [MonoTODO ("Add test for ButtonDropDownEvent (Visual Test)"]
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolTipTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolTipTest.cs
new file mode 100644
index 00000000000..8287bf30ccf
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolTipTest.cs
@@ -0,0 +1,71 @@
+//
+// ToolTipTest.cs: Test cases for ToolTip.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Runtime.Remoting;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class ToolTipTest
+ {
+
+ [Test]
+ public void ToolTipPropertyTest ()
+ {
+ ToolTip myToolTip = new ToolTip ();
+
+ // A
+ Assert.AreEqual (true, myToolTip.Active, "#A1");
+ Assert.AreEqual (5000, myToolTip.AutoPopDelay, "#A2");
+ Assert.AreEqual (5000, myToolTip.AutoPopDelay, "#A3");
+
+ // I
+ Assert.AreEqual (500, myToolTip.InitialDelay, "#I1");
+
+ // R
+ Assert.AreEqual (100, myToolTip.ReshowDelay, "#R1");
+
+ // S
+ Assert.AreEqual (false, myToolTip.ShowAlways, "#S1");
+ }
+
+ [Test]
+ public void GetAndSetToolTipTest ()
+ {
+ ToolTip myToolTip = new ToolTip ();
+ Button myButton = new Button ();
+ myToolTip.ShowAlways = true;
+ myToolTip.SetToolTip (myButton, "My Button");
+ string myString = myToolTip.GetToolTip (myButton);
+ Assert.AreEqual ("My Button", myString, "#Mtd1");
+ }
+
+ [Test]
+ public void RemoveToolTipTest ()
+ {
+ ToolTip myToolTip = new ToolTip ();
+ Button myButton = new Button ();
+ myToolTip.ShowAlways = true;
+ myToolTip.SetToolTip (myButton, "My Button");
+ myToolTip.RemoveAll ();
+ Assert.AreEqual ("", myToolTip.GetToolTip (myButton), "#Mtd2");
+ }
+
+ [Test]
+ public void ToStringTest ()
+ {
+ ToolTip myToolTip = new ToolTip ();
+ Assert.AreEqual ("System.Windows.Forms.ToolTip InitialDelay: 500, ShowAlways: False", myToolTip.ToString (), "#Mtd3");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TrackBarTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TrackBarTest.cs
new file mode 100644
index 00000000000..ad36f4712ba
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TrackBarTest.cs
@@ -0,0 +1,79 @@
+//
+// TrackBarTest.cs: Test cases for TrackBar.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class TrackBarBaseTest
+ {
+ [Test]
+ public void TrackBarPropertyTest ()
+ {
+ TrackBar myTrackBar = new TrackBar ();
+
+ // A
+ Assert.AreEqual (true, myTrackBar.AutoSize, "#A1");
+
+ // L
+ Assert.AreEqual (5, myTrackBar.LargeChange, "#L1");
+
+ // M
+ Assert.AreEqual (10, myTrackBar.Maximum, "#M1");
+ Assert.AreEqual (0, myTrackBar.Minimum, "#M2");
+
+ // O
+ Assert.AreEqual (Orientation.Horizontal, myTrackBar.Orientation, "#O1");
+
+ // S
+ Assert.AreEqual (1, myTrackBar.SmallChange, "#S1");
+
+ // T
+ Assert.AreEqual (1, myTrackBar.TickFrequency, "#T1");
+ Assert.AreEqual (TickStyle.BottomRight, myTrackBar.TickStyle, "#T2");
+ Assert.AreEqual ("", myTrackBar.Text, "#T3");
+ myTrackBar.Text = "New TrackBar";
+ Assert.AreEqual ("New TrackBar", myTrackBar.Text, "#T4");
+
+ // V
+ Assert.AreEqual (0, myTrackBar.Value, "#V1");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void LargeChangeTest ()
+ {
+ TrackBar myTrackBar = new TrackBar ();
+ myTrackBar.LargeChange = -1;
+ }
+
+ [Test]
+ public void SetRangeTest ()
+ {
+ TrackBar myTrackBar = new TrackBar ();
+ myTrackBar.SetRange (2,9);
+ Assert.AreEqual (9, myTrackBar.Maximum, "#setM1");
+ Assert.AreEqual (2, myTrackBar.Minimum, "#setM2");
+ }
+
+ [Test]
+ public void ToStringMethodTest ()
+ {
+ TrackBar myTrackBar = new TrackBar ();
+ myTrackBar.Text = "New TrackBar";
+ Assert.AreEqual ("System.Windows.Forms.TrackBar, Minimum: 0, Maximum: 10, Value: 0", myTrackBar.ToString (), "#T3");
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeNodeTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeNodeTest.cs
new file mode 100644
index 00000000000..d269db9c720
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeNodeTest.cs
@@ -0,0 +1,162 @@
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using SystemDrawingNamespace = System.Drawing;
+
+namespace MonoTests.System.Windows.Forms {
+
+
+ [TestFixture]
+ public class TreeNodeTest {
+
+ [Test]
+ public void EmptyCtorTest ()
+ {
+ TreeNode tn = new TreeNode ();
+ Assert.AreEqual ("", tn.Text, "#1");
+ Assert.AreEqual (0, tn.Nodes.Count, "#2");
+ Assert.AreEqual (-1, tn.ImageIndex, "#3");
+ Assert.AreEqual (-1, tn.SelectedImageIndex, "#4");
+
+ // Set simple properties
+ tn.Text = null;
+ Assert.AreEqual ("", tn.Text, "#5");
+ tn.ImageIndex = 67;
+ Assert.AreEqual (67, tn.ImageIndex, "#6");
+ tn.SelectedImageIndex = 99;
+ Assert.AreEqual (99, tn.SelectedImageIndex, "#7");
+ }
+
+ [Test]
+ public void CtorTest () {
+ TreeNode tn = new TreeNode ("label1");
+
+ Assert.AreEqual ("label1", tn.Text);
+ Assert.AreEqual (0, tn.Nodes.Count);
+ Assert.AreEqual (-1, tn.ImageIndex, "II");
+ Assert.AreEqual (-1, tn.SelectedImageIndex, "SI");
+
+ Assert.IsNull (tn.FirstNode);
+ Assert.IsNull (tn.LastNode);
+ Assert.AreEqual ("", new TreeNode (null).Text);
+ }
+
+ [Test]
+ public void CtorTest2 ()
+ {
+ TreeNode tn = new TreeNode ("a1", new TreeNode[] { new TreeNode ("aa1"), new TreeNode ("aa2") } );
+
+ Assert.AreEqual ("a1", tn.Text);
+ Assert.AreEqual (-1, tn.ImageIndex, "II");
+ Assert.AreEqual (-1, tn.SelectedImageIndex, "SI");
+
+ Assert.AreEqual ("aa1", tn.Nodes [0].Text, "#1");
+ Assert.AreEqual ("aa2", tn.Nodes [1].Text, "#2");
+ Assert.AreSame (tn.FirstNode, tn.Nodes [0], "#3");
+ Assert.AreSame (tn.LastNode, tn.Nodes [1], "#4");
+ }
+
+ [Test]
+ public void CtorTest3 ()
+ {
+ TreeNode tn = new TreeNode ("a", 5, 9);
+
+ Assert.AreEqual ("a", tn.Text);
+ Assert.IsNotNull (tn.Nodes);
+ Assert.AreEqual (5, tn.ImageIndex);
+ Assert.AreEqual (9, tn.SelectedImageIndex);
+ Assert.AreEqual ("", new TreeNode (null, 0, 0).Text);
+ }
+
+ [Test, ExpectedException (typeof (ArgumentNullException))]
+ public void CtorException1 ()
+ {
+ new TreeNode ("", 1, 1, null);
+ }
+
+ [Test, ExpectedException (typeof (ArgumentNullException))]
+ public void CtorException2 () {
+ new TreeNode ("tt", null);
+ }
+
+ [Test]
+ public void Traverse ()
+ {
+ TreeNode tn_1 = new TreeNode ("1");
+ TreeNode tn_2 = new TreeNode ("2");
+ TreeNode tn_3 = new TreeNode ("3");
+ TreeNode tn = new TreeNode ("lev1");
+ tn.Nodes.Add (tn_1);
+ Assert.AreSame (tn, tn_1.Parent, "#1");
+ Assert.IsNull (tn_1.NextNode, "#2");
+ Assert.AreEqual (0, tn_1.Parent.Index, "#3");
+ tn.Nodes.Add (tn_2);
+ Assert.IsNull (tn_1.NextNode.NextNode, "#33");
+ tn.Nodes.Add (tn_3);
+ Assert.AreEqual (2, tn_3.Index, "#4");
+
+ Assert.AreEqual (3, tn.Nodes.Count, "#5");
+ Assert.AreSame (tn_2, tn_2.NextNode.PrevNode, "#6");
+ Assert.IsNull (tn_1.PrevNode, "#7");
+ }
+
+ [Test, ExpectedException (typeof (Exception))]
+ public void FullPathException ()
+ {
+ string s = new TreeNode ("").FullPath;
+ // Prevent CS0219, will never write anything
+ // due to previous statement throwing Exception
+ Console.WriteLine(s);
+ }
+
+ [Test]
+ public void FullPathTest ()
+ {
+ TreeNode tn_1 = new TreeNode ("A");
+ TreeNode tn_2 = new TreeNode ("B");
+ tn_2.Nodes.Add (tn_1);
+
+ TreeView tv = new TreeView ();
+ tv.Nodes.Add (tn_1);
+ tv.Nodes [0].Nodes.Add (tn_2);
+
+ Assert.AreEqual ("A", tn_1.FullPath, "#1");
+ Assert.AreEqual ("A", tv.Nodes[0].FullPath, "#2");
+ Assert.AreEqual (@"A\B", tn_2.FullPath, "#3");
+ tv.PathSeparator = "_separator_";
+ Assert.AreEqual ("A_separator_B", tn_2.FullPath, "#4");
+ }
+
+ [Test]
+ public void CloneTest ()
+ {
+ TreeNode orig = new TreeNode ("text", 2, 3, new TreeNode [] { new TreeNode ("child", 22, 33) });
+ orig.Tag = FlatStyle.Flat;
+ orig.Checked = true;
+ orig.BackColor = SystemDrawingNamespace.Color.AliceBlue;
+ orig.ForeColor = SystemDrawingNamespace.Color.Beige;
+
+ TreeNode clone = (TreeNode)orig.Clone ();
+ Assert.AreEqual ("text", clone.Text, "#1");
+ Assert.AreEqual (2, clone.ImageIndex, "#2");
+ Assert.AreEqual (3, clone.SelectedImageIndex, "#3");
+ Assert.AreEqual (1, clone.Nodes.Count, "#4");
+ Assert.AreEqual (FlatStyle.Flat, clone.Tag, "#5");
+ Assert.IsTrue (clone.Checked, "#6");
+ Assert.AreEqual ("child", clone.Nodes [0].Text, "#10");
+ Assert.AreEqual (22, clone.Nodes [0].ImageIndex, "#11");
+ Assert.AreEqual (SystemDrawingNamespace.Color.AliceBlue, clone.BackColor, "#12");
+ Assert.AreEqual (SystemDrawingNamespace.Color.Beige, clone.ForeColor, "#13");
+ }
+
+ [Test]
+ public void SingleNodeIndexTest ()
+ {
+ TreeNode tn_1 = new TreeNode ("A");
+ Assert.AreEqual (0, tn_1.Index, "#1");
+ TreeView tv = new TreeView ();
+ tv.Nodes.Add (tn_1);
+ Assert.AreEqual (0, tn_1.Index, "#2");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeViewTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeViewTest.cs
new file mode 100644
index 00000000000..226fccf1774
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeViewTest.cs
@@ -0,0 +1,34 @@
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+
+[TestFixture]
+public class TreeViewTest {
+
+ [Test]
+ [Ignore ("This test has to be completly reviewed")]
+ public void DefaultCtor ()
+ {
+ TreeView tv = new TreeView ();
+ Assert.AreEqual (121, tv.Width, "#1");
+ Assert.AreEqual (97, tv.Height, "#2");
+ //Assert.AreEqual (BorderStyle.Fixed3D, tv.BorderStyle, "#3");
+
+ // Windows specific
+ Assert.AreEqual (SystemColors.Window, tv.BackColor);
+ }
+
+ [Test]
+ public void SimpleShowTest ()
+ {
+ Form f = new Form ();
+ TreeView tv = new TreeView ();
+ //tv.BorderStyle = BorderStyle.FixedSingle;
+ tv.Location = new Point (20, 20);
+ //tv.Text = "adssssss";
+
+ f.Controls.Add (tv);
+ f.Show ();
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/bitmaps/a.png b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/bitmaps/a.png
new file mode 100644
index 00000000000..c3eb05e9767
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/bitmaps/a.png
Binary files differ
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/tests-ms.sh b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/tests-ms.sh
new file mode 100755
index 00000000000..a3fe29033b4
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/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.Windows.Forms.ListViewItemTest"
+ echo "or"
+ echo "$0 all"
+ exit 1
+fi
+
+export MSNet=Yes
+cp ../../System.Windows.Forms_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.Windows.Forms_test_default.dll $fixture
+done
+
+
+
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/tests.sh b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/tests.sh
new file mode 100755
index 00000000000..d440326d899
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/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.Windows.Forms.ListViewItemTest"
+ echo "or"
+ echo "$0 all"
+ exit 1
+fi
+
+cp ../../System.Windows.Forms_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.Windows.Forms_test_default.dll $fixture
+done
+
+
+
diff --git a/mcs/class/Managed.Windows.Forms/Test/resources/a.cur b/mcs/class/Managed.Windows.Forms/Test/resources/a.cur
new file mode 100644
index 00000000000..f82e40ac462
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/resources/a.cur
Binary files differ
diff --git a/mcs/class/Managed.Windows.Forms/build-csproj b/mcs/class/Managed.Windows.Forms/build-csproj
new file mode 100755
index 00000000000..63fc8be1b8e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/build-csproj
@@ -0,0 +1,215 @@
+#!/bin/sh
+#
+# I got tired of editing the SWF.csproj
+# This script will generated it from our System.Windows.Forms.dll.sources
+#
+#
+
+tr=tr
+OutFile=SWF.csproj
+Source=System.Windows.Forms.dll.sources
+Resource=System.Windows.Forms.dll.resources
+
+SWFhead()
+{
+cat << EOT
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{5E6430B2-6B9F-4E76-802E-20207EF80391}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "System.Windows.Forms"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Library"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = ""
+ 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 = "Debug 2.0"
+ AllowUnsafeBlocks = "true"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "NET_2_0"
+ 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 = "true"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "NET_1_1"
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = "bin\Release\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "1"
+ />
+ <Config
+ Name = "Release 2.0"
+ AllowUnsafeBlocks = "true"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "NET_2_0"
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = "bin\Release\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "1"
+ />
+ </Settings>
+ <References>
+ <Reference
+ Name = "Accessibility"
+ AssemblyName = "Accessibility"
+ HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Accessibility.dll"
+ />
+ <Reference
+ Name = "System"
+ AssemblyName = "System"
+ HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
+ />
+ <Reference
+ Name = "System.Data"
+ AssemblyName = "System.Data"
+ HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
+ />
+ <Reference
+ Name = "System.Drawing"
+ AssemblyName = "System.Drawing"
+ HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Drawing.dll"
+ />
+ <Reference
+ Name = "System.XML"
+ AssemblyName = "System.XML"
+ HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+EOT
+}
+
+SWFfilelist()
+{
+cat $Source | while read SRC; do
+# Don't do AssemblyInfo, it's got signing requests and such that we don't want
+if [ "x$SRC" != "xAssembly/AssemblyInfo.cs" ] ; then
+SRC=`echo $SRC | $tr '/' '\\\\'`
+cat << EOT
+ <File
+ RelPath = "$SRC"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+EOT
+fi
+done
+}
+
+SWFresourcelist()
+{
+cat $Resource | while read SRC; do
+# Don't do AssemblyInfo, it's got signing requests and such that we don't want
+if [ "x$SRC" != "xAssembly/AssemblyInfo.cs" ] ; then
+SRC=`echo $SRC | $tr '/' '\\\\'`
+SRC=`echo $SRC | $tr '/' '\\\\' | sed 's/-resource://' | awk -F , '{print " RelPath = \"" $1 "\"\n CustomToolNameSpace = \"" $2 "\""}' | fgrep -v \"\"`
+
+cat << EOT
+ <File
+$SRC
+ BuildAction = "EmbeddedResource"
+ />
+EOT
+fi
+done
+}
+
+SWFtail()
+{
+cat << EOT
+ <File
+ RelPath = "Consts.cs"
+ Link = "../../build/common/Consts.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "MonoTODOAttribute.cs"
+ Link = "../../build/common/MonoTODOAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+EOT
+}
+
+SWFhead > $OutFile
+SWFfilelist >> $OutFile
+SWFresourcelist >> $OutFile
+SWFtail >> $OutFile
+
diff --git a/mcs/class/Managed.Windows.Forms/resources/ChangeLog b/mcs/class/Managed.Windows.Forms/resources/ChangeLog
new file mode 100644
index 00000000000..791361e1ea3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/resources/ChangeLog
@@ -0,0 +1,53 @@
+2006-03-21 Jackson Harper <jackson@ximian.com>
+
+ * keyboards.resx: The keyboards files.
+ * create_keyboards.cs: A little app used to create the keyboards
+ resource file. Compile with mcs /r:System.Windows.Forms.dll
+ create_keyboards.cs then run and you will get the keyboards.resx
+ file.
+
+2005-11-01 Peter Dennis Bartok <pbartok@novell.com>
+
+ * DnDLink.cur: Added
+
+2005-10-31 Peter Dennis Bartok <pbartok@novell.com>
+
+ * DnDNo.cur: Added
+ * DnDCopy.cur: Added
+ * DnDMove.cur: Added
+
+2005-10-13 Peter Dennis Bartok <pbartok@novell.com>
+
+ * SplitterNS.cur: Added
+ * SplitterWE.cur: Added
+
+2005-10-06 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.resx: Created and added mono default icon
+ * System.Windows.Forms.resources.prebuilt: Updated
+
+2005-09-07 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * System.Windows.Forms.resources.prebuilt: Update
+ * System.Windows.Forms.resx: Added images and strings for PropertyGrid
+ toolbar buttons.
+
+2005-05-05 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.resx, System.Windows.Forms.en.resx,
+ System.Windows.Forms.de.resx: Added errorProvider icon
+ * System.Windows.Forms.resources.prebuilt,
+ System.Windows.Forms.en.resources.prebuilt,
+ System.Windows.Forms.de.resources.prebuilt: Updated
+
+2005-03-16 Alexander Olk <xenomorph2@onlinehome.de>
+
+ * System.Windows.Forms.resx, System.Windows.Forms.en.resx,
+ System.Windows.Forms.de.resx:
+ - Corrected one FileDialog bitmap
+
+2005-02-13 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.resx: Added
+ * System.Windows.Forms.en.resx: Added
+ * System.Windows.Forms.de.resx: Added
diff --git a/mcs/class/Managed.Windows.Forms/resources/DnDCopy.cur b/mcs/class/Managed.Windows.Forms/resources/DnDCopy.cur
new file mode 100644
index 00000000000..99b5574f801
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/resources/DnDCopy.cur
Binary files differ
diff --git a/mcs/class/Managed.Windows.Forms/resources/DnDLink.cur b/mcs/class/Managed.Windows.Forms/resources/DnDLink.cur
new file mode 100644
index 00000000000..3ba787aa39d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/resources/DnDLink.cur
Binary files differ
diff --git a/mcs/class/Managed.Windows.Forms/resources/DnDMove.cur b/mcs/class/Managed.Windows.Forms/resources/DnDMove.cur
new file mode 100644
index 00000000000..0150e0e5236
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/resources/DnDMove.cur
Binary files differ
diff --git a/mcs/class/Managed.Windows.Forms/resources/DnDNo.cur b/mcs/class/Managed.Windows.Forms/resources/DnDNo.cur
new file mode 100644
index 00000000000..b002e96b36d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/resources/DnDNo.cur
Binary files differ
diff --git a/mcs/class/Managed.Windows.Forms/resources/SplitterNS.cur b/mcs/class/Managed.Windows.Forms/resources/SplitterNS.cur
new file mode 100644
index 00000000000..2f32171d33c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/resources/SplitterNS.cur
Binary files differ
diff --git a/mcs/class/Managed.Windows.Forms/resources/SplitterWE.cur b/mcs/class/Managed.Windows.Forms/resources/SplitterWE.cur
new file mode 100644
index 00000000000..64fa72d497c
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/resources/SplitterWE.cur
Binary files differ
diff --git a/mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.de.resources.prebuilt b/mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.de.resources.prebuilt
new file mode 100644
index 00000000000..03e50c81c30
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.de.resources.prebuilt
Binary files differ
diff --git a/mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.de.resx b/mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.de.resx
new file mode 100644
index 00000000000..75bee5ab207
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.de.resx
@@ -0,0 +1,831 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 1.3
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">1.3</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1">this is my long string</data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ [base64 mime encoded serialized .NET Framework object]
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ [base64 mime encoded string representing a byte array form of the .NET Framework object]
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used forserialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>1.3</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="last_open" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAADftJREFUaEPVmntY
+ 1FUax0efbbtaarr12D5bu6WbopZ5SVs1a3fV2rQsUcu8FJqlKCZkF9t1H7VUFBQVCXVFzTIIROU+DJoK
+ iCggKgjC3JgZ5sZlbiAzot993zMMgjLjpT/W5Xk+npnf5Zz3e8573vOeM3YaGG0ddv89nX7fWSLpJKG/
+ zuJf91+nTq3XWq/SffdntHtOfGm91/bdlnrb1t2J/q4CpvT3usiu1XKHn+YkNRwuNV2GN0qMLvjivNEJ
+ X5wzONERX2VZry5IdWwCIPk1SIIyGjKuXr0Kb1y5cgU3o7m5Gd64fPkyOiK+xAGZvOkKiVj1fyuAheVr
+ m5oDUx1L71TE/3QEWICLKDU2XZmb5PjoTkTcVAC71q9xIXYtby7kEWBpdOKIvKF59kGH/+2KuGsElOjt
+ iCu2Xp6e6Bh3OyLuCgHWRop0JEBWVoetefUu/3j78FsVcXcIuORCqYEElNfh+1NGfHu4pum1H+39bkXE
+ XSUgq0VAaFYVlqaaGl+KsT15MxF3rYCQAwp8ctBo/9Nma09fIv5nAgp1jQjKuCxYlOHCwnQXAltYQOWC
+ NDcTfrLuvSsFcAiVKZoFmfLLXnk3wb7zjgV44r+vVMFbnG8b+10uF3zhdDrREY2XmvDefvsOnwIWptmk
+ 3vIVz/U7NcBjVFNTE3xx6dIlNDY23oC9oRHT99u3+xaQapV664HbMcCbEWxYQ0ODTxwOBzrCYm/AjET7
+ Np8CApPrpdw4s7vYgJAs1TVkSoTcAsGZCtyMT9MrMG1DHEbODsbgie/Db9RYPP3cMPiNHIshE6Zj1Owl
+ eC98H/YUqGGz2QS1FjtmHrBH+xQw/1BNpsPRQD3gHbvdAV/YbHZqsGNyc09gypSpeLT7oxj8wmAsXvwp
+ wsPC8eOP+5CeniHK8PANWLIkGEOGDEX3bt0xebI/jh49BlOdDbNuKuBgTaYvA/ie1WrzicViRX19ewoK
+ ivDOO5Px5B+exLrQdSgpKYXRaLoppaUXhKCnnvojJkx8C6+vztzncwQ+OWDOtFhsYOKKqxF6XIV1zDEF
+ wo4rEZ5NcHlcgQ1UbqTvETkqQolNxOZcFSJPEFRupTKK+GD5BvTo+RhWrFyFqiqNMFqvNyA5OQVBixbj
+ r6/+Fc8/9zx69+6N5wY+h1fGvIp5H32M+PgE6HTV4nmtVofVq9egW/eernt/e6/XVFvy8X6jrLbWAqZS
+ V4PzVTU4pzbjLFGsMhFmFClNKFQaUaAw4jRxisiXG3CSyKs0ILfCgJyLBhy9oMXUmXPRt28/nDyZ39rb
+ UVFR8OvXHwEfBiAxMREqlUpEnK+//lpEJ7VajaSkJMz/ZD4G9B+AVatWCcEs5PTpAvR+prf9kYcf2UXb
+ 8d9cPxqSefH6LLO5Hr4wmergC4OhBsycOXMxbux4KJUq0fiZM8UYP+41zJo5i9433bAW8ES9PkTztc9C
+ luKlES8hOztH1KNWV2Hs2HENJOL7GwR89LM+y2isowfroNbVQqGtcaMxQ0WlmkZFrTNDrTWjikptdQ10
+ AjOqqdTra6g0Y+WKbzBo0AvUu2rRaHh4uHCTtLQ0n4tYR2vMkSNHkJCQgBHDR4hRqq7WC1ccOGCg/YH7
+ H1jWVoRkbmx1FhvCbCP//jylDEuJz5LLEJx0AcHJF7DkUCmW0OdPqVx86AKCDpZiEbHwQCkCiSnr4/G7
+ x5/A+XPnhfHr1q2HP0WS+vr62zbeYrHgiSeeQGlpqQjtn1LUWrp0qaiXJ3iPR3vYyZVGeERI5v6kO6yl
+ 3vWFRmOCL14cNgJRUd+JRjhsDnp+EAUFy20bz6MREBCAwMDA1nd5joweNRqpqWmi/pidMXi4y8PnSUQn
+ FiGZs093WK1mP/OOSmUk1+iY6O9iyOAXaA4YRQQZNnQY8vLy7sj42NhY9O/fXyxibV3r4sWLwh0VCqUQ
+ QZHLSgLeFQICftAeVlKEYWRnNEg6VYVk5nQVUgsILok0+pxOZBDSwipkFmqQWaTBsBGjsWf3HlFxMC1G
+ Kyl03ix34vtOpwd3IieXy9GrVy8UFRWJe9fXsWPHDsx4f4ZoJzY2Dt26disSAj78XnNELjdSBUbspTi/
+ RVaJzbIKbCIiiI2ZFQiXXkRYRjnCqFyfXo7QtHKsTS3Hv2Lz0KVLVzHBuHe4l3jIfWeeLnrGiaZLTvJx
+ Ll2UJ7ndZEP4xpZrdJ2euV7Iy6NfRn7+KTHSDz34UCONQk/JB3s0Ry5SDPdFebkeHbF69Ua89eYk0Svb
+ tm3HV19+5dV4NoaNYqMvkdGNtJFvaCAcLiz/1wqMH/+6+MzX+B4/wyKdbYRERkZixYoVor23J73d0LlT
+ 5zmS2bs0v5SVGeCLCxf06Ig5AQsofK4UFU6bOs2r77caT+c/wnAy1G5zwmZxIkuWTVHn96is0MJa777G
+ 9/gZIYTeYeE8qlqtFjwK3N7ataHo+kjXbZJZMZpfSksNFKIM+OGoEttlcuyQKbAzy02MQI5dVO6mUnBY
+ jj3EqL9NxE6KClzh8BeHdxg2Pca7XcVtuJWMLDmvwI7teymdeBY/x6agxuRCrdmFuloXLPUuIcRhJ8H0
+ DovwuFN/v/6iPZ53PXv0lEpm7tQcPXdOD+bHI0r8J5MEENuJbVI5ojPk+C69kpBja1olIoktqRXYQuWz
+ A4aKjJIrpEWmQ/cRbsM932K8hXq5WmfDM0/3xqwZs/GP197CsV/O4vTJSpSc1UEpp1Xf0IR6EsIjwoL5
+ XY8Azp24Pak0kzPcEsmMHVVHi4v18MWZM3pKC25k8ODhrQIoX0FISIjIcTyTWPQ++zy5AvcmG1RX40JB
+ fjlG/WW0iDh+/QYiInw31nwTheX/DMMXS1ciaOEXFO9j3SLESNC5ES1iXD/nSpwnZWRIeVE7L5mxXXOs
+ qMhAlXmnsFAPpqCgug16vDZ+EnbF7BI9MmTwELHrahuBeAJy77M/26xO1Ne5YKbfG/QaJ+bPC4Zf34GI
+ 2Z6M8nNOQUWpE8oK8nWlCwatEzX0rIXesdO7TU3u0Opxod27dqMHu9D70Zpjp08bKOsz4D/pKmxJkiMy
+ WYGodpAb0ffoZHKrFAW2p7p53X8evv12tRAw4Y0JYvlv1/tCAPe+2x3Yx43VTuhULigvuoTRJYUunD1J
+ 5NPxYoETF887oWIRaidMeveI8SjwaPLqzh3F7a1ZsxaU3G2TTP9Oeyw/30Dx1YCYNMrpk5SIJLYwhyjf
+ P6hAxAE5ocDGRDk2EOGJlYQc7y5ahzcmvCUq5Nw9LCysQwF2ch9LHfUoTVQ99WyVwoVK6m02uDDXhbwj
+ Tpz8xYkzeeQqZ2hRK3NBw6Ogc4vmCc0dExcXJ3Ijbm/SpLcdtA58IHlvq/Z4Xp6RQqB3TpwwgMnNbU96
+ ehn1QleR7p49ew5jXh7TsQCaiK0CyH2q5C5UlLh7/3S2C9lSJ3JlbjGlhSTggrOdgAaHW8BU2ppy0ODN
+ zoMPPMgLWQ/Ju5Ha4zk5RvgiO9tAuXnHDH9xjEiwuFfenPim2LB4UgV3BHJPYI4+3Jvs29y78jKn6G12
+ nwISUZBDbnTKhbKzTijKXcLN2N34Pa4vOzsbI/8yUrTD++hu3boXilRi2hZd9vHjJjBrYpVYG6tCKJXr
+ 4mhbSaz/maAyLI62lfQ5PF6FDS1EUBnwWTT6USThZI4jBe+8eMHhRt0rr3vhYjdgf2a/1pF/qytpFMiN
+ yordrlRCPc/Gc+/zCFVXkWByOfZ9Tss5TeE0ggX49fOztSZz0zZXZx89aqZTADMiE6oQuV+DzVRuiid+
+ dpcbqQyPVSOshfVUrv9JjdCfSCyVffxeRETEptbeGT9ufMsouFOHa2sALVZklJF8myepmgxV0GTm0WB4
+ YvP8YIFGEtpIEUyk2LQV9dQfHb3tapeHulxLp6dG6HMOHzbDTU2HZGWZ4YuoKBkef6yX2EJyD334QQBC
+ Q0NF710/ChwWeTKze1TTfNCpKeKQu7DLsOEcYuvI1Xjk2HhOsSdOmCjq5Q0TLV7tNzRTNhpyZLJa+CIz
+ swa+kErNCApaR0M7QGSlvK2cTEcqDGeOIoHjHIjCKbsSpwrsThznTfQ7sonEsGvxd54vbDi7TeCCQIz9
+ +1jK08pFnXRYYL/vvvuD220p/cONOVJpHS3N7cnIqKPVzk16eq1P0tJqae9bC3//QIpEr1JqrhA9tnfv
+ D2Ll5MXOSQsRC2mbD/EEFSutjefJtXyHTyjY5z1uw4cEY8a84qCd2A3npJLJYabctLR6MsA7qan1tKXz
+ TkpKHZikpBpM8Q/C00/3oaiWK0RUVsoxc8ZMcRa0Z8+e1tMJdi+ZTNYadmtra4W7vPP2O3jjH2+IsMzv
+ 5+WdxFNPPmUn46No4na+4VRi8vqa3JQUKxngneRkCx1KeScpqZ6Mt7Ty+ecxlCk+jmXL/tl6SnHs2HH6
+ vkycNLxApxejRo5C32f7ivSY99BD6VgxJDhEJGmeo5Tly/+Nrt0edd7zm3tmeDudk0z9wbpsXrwt8eN4
+ 2wHi4CdMgu0QMz/BlsQsSLAlB+63pbSQunC/LXVhoi2NyvRFTKItPchNxuJEm3TxAZv0/Y0nsvsMHWvq
+ 0fPx5pUrv7laXHxWGOZBoVCIw6+Kisp218/RRF397Rr87rFeV/487O9107+MmOnzaPFmP6L92vs07ANp
+ 47GPVk4LZazWBQsCmzmP4cXv4MFDYn7w98DAhc19+vzZQuc+Vno+lt4bdCtt/6r/KXIrDXie4WMQYght
+ A0Mojm+lcJhC5NNpdCp9j6Lrn9H9YZ7jklut+7/JKVwBwotNkwAAAABJRU5ErkJggg==
+</value>
+ </data>
+ <data name="Red">
+ <value>Rot</value>
+ </data>
+ <data name="folder_with_paper" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALEwAA
+ CxMBAJqcGAAAD0tJREFUaEPFmQlUVFeaxx/IUguKRo12MkmnuxM98cwkJmPapMdsRpOMY5bOMn1cMsak
+ R4OmoygtoJSC7IqyFzsoigIqKEsha0GxF1XUvldRFEUJKGuxC9Q330NRcAFcMqlz/tz77rvvvf/vu+t7
+ WBG/wu8/N26k4m3fHhgYeHkQ/3R3d6vUSqUSywZQll/hkU/vlv9w3kdlHPVezoxP2Oty0DN0j6v3cXdv
+ 5h6v46f/6h92/hM3r7B1+9x93nFjeP7p6T31Kd1pv5u7raev3wpmXPwhoVLVfIlVdvNMZhWcyuRbQhIK
+ bgZEZpo9/KKvM3xOcv1PhHh5+vrORVk/pcc/+W0Q4K3UjMwglaHJ1Dk4NNLc2WPJ4aggIEkKgam9lqPx
+ 6rGUXPEoX6kfUjUZFYHBwQzUs0/+5KdwBzcG44M8NjsSjWk6BgZHe8csYB4dA1VzJ5wv0MAvx4VwmqWB
+ InUraMwD0D4wOCDV6eSJKSm/eAcG/uEpWHi8W7gxjtA9vLw/YBWXxqsajbqO/qGx3lGACXUOjoBY3wGJ
+ uUpIl5sg63oPcPuH4drwKHQMDI/WiiRV6Veydx4+6vv7x3Pw+FdZMY74zA9jxr2fkp55Xtfc1tbZP2Ix
+ DwNMVjcetwyOgbjvJpxp74OEG2bI6OwHXu8wtA9ZoLVnYLSaLy48nZK+3fXgkUWPb+cRrlyyZCmx5bvt
+ 9n6BJ9cnp1zMacUwd/VboHsApqgLj1uwvBYpIlt7IPl6H5y+3gtxbWZIwbzSPAo38Hzzjd6RGr6s2NM7
+ 4Nt9LgdtUFaPYOfRqyKAfcDx0E2sgnKWsaXX3NFjsXSaATp7p8rYMwbF7UOQ1NoLZ1Hx18zjSmwxw6lW
+ TFHKrhFo6x61NDZ3d1VzZUVo/hOU46O7msUVb7+9Zg7KISw88Uc2R8DSNnS0t3cBdJDqvqsbeKzvGANW
+ 6wCcudYLSaZeSEDFN99OTWaIQ53Gc+ev9YGo/Sa03BgZ0zV23Shm87Ijmac+ddrl/MwsLM2+yrp1G2wP
+ HvR9MSrq7LaiYj5bo+3sutEOcK9a2i2guj4KLNMgJDaZIRaVaETz9yjBaIYkLIvB85dN/SBqG4GWtpEx
+ taa972p+bWJsXOrH27btfHot8e033z3j7x/x+eXMUpFe3zfQ1gZA6vokmdosIGtB88ZBCNX3QGIj9ncU
+ sxG7jAEHcBMaNmArYD4JFYnlZ5v6IBrTi8Z+ULWOjt9PIr7WyWJVM48FRq/55uutFNTsI/2wmruc/rk8
+ MiKFIRG3DRubRiwt13CAolonSdI8Chca+8FP1wXp+j4Ib+iB6AbsKo1oVo/9H9NkVKweobA8HeuebOiG
+ U3icSJ5HTdxPwG++fjmDE4PmX0HNfrX+5BNiqZMT8QGDQfzv8ePEfiaT8E5KIiLOnLG9dO7cH4QX0reP
+ iOqlFkPDMJiMANdui9c4Aucb+oGpw2jr+iBI0wNxWow4HkfoeiAey2IbeiFKh90JlYD5EG03JDcgHNaJ
+ QqVgPhHPKZrGoKnh5oiAZ9KmnStkbvvO6aVPP/7Cbtpm2LaNsEGtuHKF8CgvJ7K5XIJbV0eIeDxCzecT
+ xvp6op3Pt+2rrfndWGnJARDV88GgG4UGvQXKdMNwVtsHcRo0qDFDuNoM0epeiMSUicfRWM5ERWM+BtNx
+ IVw8ppHj52+JzCdq+uCKbhBE+lHQqQaH6qqNmqT4bD9fb+aK/3hn7cMhXFwIKmpzZSVRo9MRoyYTAQ9T
+ Tc3LUMnxBBFPChLNKISpelAYRRUCKDGyyh6IwTRCiQBYHo3lEXhM5mPIOigyH4dpONaNwjx5HIb141UY
+ CBRLMwRi7RjoFMPDZUXqhuTEq64+R5ivvvynV+c8sCUCAwkHlLtIRCinMz9xrqryVSgp8IIqQTN4yzsh
+ TtEHEYpeCJbj7IL5QFk3xOBxFCpUgbMRppGYhiMIWRaNOibvHq8bosAA4LlEzAfgdXFyHOSKfriqHAaD
+ CsaVny2WJ0RlO//ixHj+gQBBQYQDioEA6tkANDVZQ13tCsi8cBSUkiE4I+uHBBlGD+WLJpKlfXBSisZk
+ GGk0dFLWAxEy7Dp4PhzTECkObrzGH+vGShEKy/wwf07aD0EkPB4Xy4dBL8c1BaWTjY3lZYqE/l4x+xHg
+ /lYICCDoKFcEUMwGgKyj01GBx30NcjPDoKLWCGniAQgXo2FJHxwX90Ak5iMkZghFg0wsC8d8CIpMmeLe
+ 8ToxYoS7XR4jQQhxNyRg3WLJTRALb4KophtKcmWQlV4yFnwsUPb37WujN2yw+2bVKhs6gtzdcnh5EXTU
+ XgSQzhaguRkhtFSoKFsFZQVxkF+hg1TBAIQK0bQAzQp6IITMC7EbiTDqIiybEFle3wP+FQbwKhTD0bwa
+ 8L9aDgFXi+BsfiHk518FTkEWcApToTSfOZqdccCYmrKxICT495G7d1NdNm+2nzsF4MABgobaIRQSotkC
+ kPVIiIYGKygrXg+c/NNQWN4Msbw+YPIxwrUdEFBhggC2DnzZcvAvlUBQqRCOlfLgWFkNRJVWgm/BZQjK
+ TYbg7CgIzwmGizlBcDXXD4pyD0Nx3gFLWeHu4drKLSZuzepCheLF2MrKBf5eXnRnFNkCd3+7dhFU1FYE
+ 4M8WwGgkoLGRBCBALLaFwrz/grxL53GGaoPAKgOcLFGAT1YpuKWmgVdKPHifDwOf1AA4lnYYQtP/CSGZ
+ P8MFzl7IER8AjuoQSJWHQa88Mq4GBQOUov0j/JqtbTVV/5qj1T4XYTItOlZRseCoiwvtRxT54eDub+tW
+ goL6CgFqZwPQ1ESATEZAaSkBOTkEZGVZQ1rqXEiKXwlxkT/B6WQGxFx2hXNl7sASMiBX4gEsySHIxzRP
+ ehBYUjcolbpDjtwVKuUHQSY/DDo5Gr8tuWAv1Fb+tZNd8kqVXr80tLl58XESoLx8AeOHHyj/jaJMAfjs
+ M8Ie9TEuWJVkt5gMoVAQUFNjBWy2NWrOuEpLbaCqyhYEAjsEsUdRQCKhAp+3CMpLXwdO8fdQXrUP2EI3
+ KJS7Q7HiIJSgilAT+XyFO1TLMfIyBmhkR3CmuSUpfzeI69fjvV5pq65aVGA0LgoizZPicBa44iD+FGU/
+ BWDNGsIW9RauwCV6/VQALtdq3DCXa39HdXUU7DZU7D40hL0rY5MDaLWLQCxYDZL67cAXu0IFmiRNTxYb
+ o16F5TLZYdBI0ThKI0YY3i40vxaU8pdALndsraubdwdAq10YlJ8/3/nNN23eQNlOAVi2jJiDegm3Ebkq
+ FWGZ3ALl5dZQWWk3xehk0/fmjUY6qFXPgETwHpr5O9RjVylTkBDuwEaQUhQZeTWa194x7w6y+p0gqPsQ
+ lIrnwGCYi4Gg3+Dx5rGxBU6Q0edynzmZmjpv1+LFVktQ923wyDnVsaCAuCAWEyNTAeZgd7GfNcAEkFKx
+ GFvhfYTYDQKZB3ButwJX7nEn6mTktTgupPwdUM99FzRqRyADQN4DAToQoGICgMWaHxQc7LBtyvR5z7Js
+ k5VFJOEmrn8qANnfKY8MYDQ6gAqjKeS9B1LBfuDJDoEE+7v6dtRJ86RE3O9BxP8zGl6I0/It87cBuuvr
+ 53InALKzHX18fenfTLcrtbp0iYiqqSG6JuZ4jYYYH6w83qMDkCYMhnkI8SJG9yOQCJ1BLWGMm74VeQYI
+ a7eAVPjvoNU8eyfykwDMCCAwGheOd6HLlx0PubnRNky7rU5LI4Krq4m2CYDaWgLN24JKRX3kFpgwYmic
+ B3LpC7h73QhK4R40fhjUOPeLeVtxsK9E84vR/NTJ4HYL9AsEDjIEOEkCXLzouH/nTsr70wKkpBABVVWE
+ kQQgFyocEyAS2WHT3v+A6Qby/QPbAUTCF0HC/xLk9U4grd8C9bwVoNfPf+i9dTraoFDooCYBmpsXHcMB
+ 7PTFF3arpgVITiY88Z1ANwGQn2+NAI8+gB8GJxL8EaorXkPzy2YMCgLcRAA9CaDXLzyekjJv2+uv2yyb
+ FiAxkXBHgPEdKdkCTxuAHBONGHWDwXHGLolrzKhE4mBC82FFRfNDExLmfrZ0qTW5iXv4LyaGcMa1YHxD
+ dwvABlvg8Qbwo3SxB9VtbKRZlEr6Dbl8QWxa2rwT4eEOax/4LjAZJzyccOJwiDoSwGAgoLDQFlfc3waA
+ HNg6Hb2Lz5+fgtH3DQx0eGfa6JMnT5wgfigrIyrJzRquyMDh2OGS/vgz0JO2gsFA76mtdcxkMh08PDzo
+ b8wI4OdHbMEdJlurvbXTlErtccv8ZDPQk0AggBkBWCEhdOeff6aumBEAvwd9zWYT+WT08/KsQKOhzDhb
+ PInBma5FgF4ud16Rvz9t51df2f9xRoD9+4mNJSVEllJpBbm51uPvvTM95Nc8j63fX1bmUOHjQ/129Wqb
+ JTMC7NhBrCsqIi6qVCSAzW8OgGvBQGYmrS4wkLL2hResaTMC/O1vxJrCQuIcCcBi2f5WAGPYqjdRQ2o1
+ rTMujlIdFUWZeQCTdOvWEatw+5B0C8DutwDAdxG6GdVsMjnI1GoHTlQUNSksjLp8xuiTFVauJJZlZBDh
+ PJ41VFRQcK/yq8xAGF16D8qEJlUGg0O9WOxQVVhIL7l0iZ6Zmko/lZxMD4uLo/kGB9Ncdu+2/+qnn+xn
+ 9/+zpUuJJfHxhH9hofWYUkl94C5xFoMWo0h2AXoP7u/b9Hq6QSSiaaqqaGIOh1bJZtPyioroqVev0mNz
+ cuhBGRl0j3Pn6D/FxNC/PnGCvu7oUfq7rq60Pzs5Ud/YtIny6kcf2T734Ye203+dntQ8DiEhVocyMuaQ
+ fXC6GWi8n6LBPtyzdMvltHaJhGYSi2laNCsWCulV9fX0vLo6emp5OT36yhWaX2IizQUj+qOnJ+1bZ2fa
+ BvyysPbLL+3e+ctfbF5bvnzOv6CHqS/qs+oz91eyCQ21dk5Pt+lDgxbcRo8aDLQR7EpDqAGUGdWFplsa
+ Guga7KO8mhp68eXL1EunTlFjw8OpPp6e1J9x0dmyeTPli/Xr7T7CHeTKBQusFqIe/GX5MY0+9LKwMJt/
+ pKbadWMXGNJo6NcrKmgNWVlUQVoapeDUKUpyWBgFv45R9u7ZY/8/339v9/mmTbZvenjY/y4+nuqIAHMR
+ gIYAVASgIIAdAtiieWvU07b64Pvt22fzHoNh63v6NNUjIYGy48wZyufnz1PeTU6mvMVkUv7N25vy8q5d
+ 9i/gy8XS1attFz7/vDXt2Wet/3+ie4/l/wOchKPj6Tjd4QAAAABJRU5ErkJggg==
+</value>
+ </data>
+ <data name="monitor-computer" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAD31JREFUaEPVmQdY
+ VHe6xvFe9+59dJPsJttMTNas2WQfs4nuborGGzVmLdHYwIKiG0VAI6BIH5A6dJDelCkgRXrvvXcQaYJU
+ UXoRLAgMzHu/cxRkaJZr7j7L87xMOTPnvL//+/2/859zFgGQ+rf+YwD+nfWTm9/p2fTWWk7c5x+f4v+w
+ +ke+7V9VfGLWnA8t/VQrtv5TrbiWT7TiOz7WiO1b/flXx15mIF8KQFDQ958eOb3L9P2KvlKyDVdQtA11
+ UrwYmXDaJaVcyS2jTskts1nBNevOSdesHiWX1AHNS6n3nMKLxyILGlB9ewiDw+MQizGlkZFRrF+/Xuf/
+ DNBzX/Tft++OrsipaNzkF5PxozA81Z0fkZFyJb7omjC+pJYXV9J0Obb0tkdUcbdbWE6fV2TOvcjMClFx
+ zS103h3GqEgsYWzS5NiYCM3NLUhLS4e3tw94PP6UzM0t2O9s3LjR5KUACgoKLlbV3Gi6VlnbVlRe1ZWe
+ W9SbllM4VFJRI2pu68TDR2OYmJjb2KRBZntHRyfy8vLh7x8APl/AijHq5cWHUOiD1NR0FkIkkhx9Hk/A
+ Amzbts3ypQDS09O9Ozq7MD6BBdXXfxclpeUICQkDjzHHGnxsVCAQIi4uAbW1NzA8/GjOFKaXzPTnzPeJ
+ H7t377Z7KYDExESlkrKKMRpoVNc2ICIqjsx5w4svpEcSTwg+GQwLi0B5eQUGB4deyOB8xiffZwZiRATI
+ 7D/o8lIA1dXVq5NS0gfvjQBGxlx0dnW/UoPPArjsJQBz7O+OHLvxmzV/k6Nz0pIXAZFqbGxcmpSS1tP/
+ EHD14OERjQYzIqPjwBhJ9KS0mJifZeZltntRGTLHPukpEKs0d4p3efBavlbXjl2143vz1377u0+eBcO2
+ 0dj4xDud9wB7Vx6GHoEdkfukB6PAQ9IwlRejnwLOi0q0i4592kMg5g5DbENTyInkPjwu1s/Mvy9rZlm6
+ 5aSS4MPPPj9O6bw2E4gFCA4Nb2i7C9g689D7AKz6aFSYkRkYBqhDYpDA5oNj5g+bGolJ7UWS8/bxQ3Pv
+ GFQJwJ6Mu5F4IxD7koJHIY4iJY5BHN3dLzb09m2T5+jH/2PvPsvfv7P8M3YZxPzzueJX1dQH2Ln5oJV2
+ 1j4EdJCYVJjR6b4P9JBYMBILRmLAXhSOuijb7SZITMkFh4SjomUQ590F4ktk2pt0lUyHk+LIeCopRwRx
+ CamSOnCdaEJsLfAZfvvbPb3/9dcNoSyAg5NzakXrfVyJyEBmWRNa+oHWAeAWiUnmNunOINDOaCG450iN
+ LctpJRkVm4jsqg6cd/SEP5kOJcWQksl4FqmQjF8jCVLSRWsOnej6hZx6h5RDygOpbDGkpJUDWABTrplN
+ bNZ1JBa3QBiahvoe4GbvYzVQMo2kJoJqJrUQFAtHUCwcQbFwc4CxyT2jJBNSsxFf2IRT5/RH9x0+cWeX
+ vFIPr7xyPI9Mh1bfEK//56neX8qe7ZAyCRqUyhiDVA4ZnpS0ylUWwMjIaO8l34jholYRuI4+qOwEqkjV
+ XUANqbYbuEGqI7BJuAaCY8FIDNiLwk2WZEp2KYJTq2Bq40UnwiHk5DSAo2fTu2H73p5FWp79Ukn3JU1P
+ B5BRDWQBeDzeO9aOngOFtwADWz5KbwNld4By0rV2oIJ0vQOoJLFgLwg3V0lOJpdZXAthdBGMbXgswKTO
+ apr1SIw2Y5zK5meuWfilggmkMkSQ2n82iAVwdnZexLWy785pBjhWfOS3AgUkBqiIURtQTCohsOeBY1Mj
+ sak9I7ncila4BWXCcAGA/whsxFu6Xlil54UDYfVYa34VUqmPGIDgqeW0nqHZrfRGQMuSjwx6zGwCskjZ
+ BMWA5bYAeaSZcCwYaRKMTY4SY5OjxNjkFijJfKpPa3489KzmTuC36i7Y4p4KxZIJHM8ahEzAtacAB849
+ BVDT1K1PqgfULQRgHpNvAimk1AYgjcTAzQRj4QiKhaPEWDhKjE3uOVJj4Aob78PIJRS6NHBzldAHF4Q4
+ FHETGwx42GTsjb/p8/A7NSdIZU1A6oBayFQCCqeVy6KqxqBh44eI66OIrQXibgDxpIQ6IJERgT0v3Fyp
+ zQVXfGsCWja+0LKYAaDBZefASiqbb1wS8D7nMpaahUAq5eHTSX1Q7fF5gNEB2aMhvKRGmPlkwy22AWFV
+ QDgpohqIJEXVANGkGAKbC44FI7GpPSO5mXDqlj7QsPBGTc3g00n8BODnNnFYFH5n7k508HzYFMD273Zo
+ GLpFit2TboPjmYKr14DACiCIFHwdCCGFVgJhJBaMxIK9BBxTkil1IriFFEDTSggDzyRo2wWirKxzFsCs
+ TkSpLAppfdyFDqmHPwXYvn2dgob5/SulE1A09oFPKXCF5FsG+JH8y4EAEgM2C46gWLgFUoupnoBTWDnO
+ 0Ugrc4VQNveFXXgdu19GGrYhyM9vmQJQfZLAFED8XbxuFICVVEqrFAwhFdnJAERMAUhLSy/d/88z/cIS
+ 4LiBEF5FAI9RMcAnCeh9Zps3QbFwBMXCPTFAzWEWmH1ELc6YXcEpEyGUTHxgGlABQbGY3Q+/aAKGgnyo
+ Gl2GtoknHFyuSpTQJMDP3fOwXOcS1loEQT73AZTomN/SnGABZDWfAjDzYIe0XOelQuAYzXzXPMAtH3An
+ eRQAniRm22XSJBwLRmLBSLZRzVDi+kPeQIATNAgcfiE888bZ7zCyiW2Hipk/1IwuwcDsMqKjiyU6z/Qu
+ pKph2suM/grywpjeH1zFdqKdHin4VO0i/Qbog9ThGQCbtu1pYYwf4Qhhnw04kBxpJ04k51zAhcSCkRgw
+ y+h2KJgG4Zi+AMf0BFBzzYRT5ii7nZEzrcY0XNNwxuAytIw94e4ZTj9Lu+Y1PR/AkdhWbKCy/ojK51cc
+ PhaFtT2e1Ee0oiSuC32xfnMNY/qQjhBW6YB1Bo0ayTbzsUxj+nDCLByyOgLI6gpwyi4JVkkPWNBJ6QU2
+ YI+KGz7ba4Jz2jZITq58LsPTzTPPVdUfJ/CWih1+T2fhxbzS2Z3oiLYkwKrVn2ebRPXh8IWrMIgfgX7U
+ EI6ZxUJaS4D92gL8YB4Nk5i7sCGYSZknDUPOOHx4vazF+AdbbPHG5gy8tncUr22rh7IyR5yUVCGeae55
+ Xk8CzNWFpt47oh0tkcCKlX/2ULRLwVl+DXaqukHWMBSc0G6Yp0FCZ/lVY9sUrdp2HdMe+Pjrkw+XSbdj
+ udyEpPbWIDGxgq4LRcLIyAFcrut4UdHt507juQDkdGIkAN588025bQoWY0bJgPE06UYM4aCe39j3ikYj
+ MkoaY2ZuHhMZdXVw9vKH3Gl78SrFcczUhwcr6EpczZThkpJ22NsLoa9vI3Zx8RdVVfUvCKNy3rRvwdFn
+ 5oCMSpIEwOuvv/7Hv2yQGeLEi3HCsXBit+rFcWVzD1gLA2id04qawUEJCcNioMflY91Z0SytOVIk3rJz
+ d5uRseNAVdWAhFkGzNzcDZqapqLg4MzxuUpqXgD/OqzYp9j3P1v39Ur9+p2tEgDL3n33vZWfrh06Z+GM
+ 0Ny8WYZnAvhEx8HK3hfbdMZmadOpYmTdvAknX9/732zbkX327IXy1NQq0UyzQUEZTCrQ0bEYSU+vm5ov
+ yudNniaQOY5fnLa4t+nQqQ6uhcdARUUPXRGMekBXKVZMAXy2fv1WjpVVw0yT872uHBhAbPk1uhjmCBmD
+ IRwwGZXQTpU8pNfXg/1cSen49n37rnz44SdHDx9WCLe39+6cWUKVlf3w8AjBuXOGYzRfHskraT+UulQ4
+ /mdphW75M5wu6mZP4W+PSAKsWr16h1tg4N1nma/o70dJTw/yOzqQfecO0qisuBau2HkqGidtRiQkcz4L
+ 0ZWV7OcKOjuR1dyMnQcOxDEnzCVLlizbuPE7a+pSxQkJ5aMzUymk9biCsh6+3ys3UF19d9ZcqWoephJ0
+ 76cE3mUTkFNSKlnIPGO8uLsbOazpW0hsakJM/U1E3LgBF14IpOVtoO76SEJHtVPhX1KCGCoj5vPpt27B
+ LzNzfM3atbKTK2AysOijj1btOXhQPsjGxquNKY3pMPLyZ9unvy4t7YCJiXODtPRRwYoVH6xnrwvR36/t
+ +ILR+QDKenvZEWcMJDQ2IZK6T3B1NfwqKuBdVgbry/5QVLeHMX9YQif1E3ApNxf+FdcRQp+PqqtnQbbJ
+ 7E+c63Ih+Xjr66+3mP74o25uTEzRI8b4JEBgYPo9JSWNtC+/3KBJn1s6/ftSixcv/ktAcop4LgDGfB6Z
+ Z0olroF+I9TUsoYEpaW0PiqkJUYu9Fy8oGHoAvurDyV0xjgGF9PS4FlYCGFpGQKuX0d4bS2kj5+gXw0L
+ 35d7//0/bdm//wffr77a3Lxnz2H+8uUrvpjvO0wCSzmW1qKZANepbAqpdjNutSG+sZE9OGOeT2XhSjcy
+ LmZmwjwlFWdsHWFkdQn8yAcSOm8aDm5iIuyzsmjdlE+r2VL4XbuGb7/fS78gXt2NRXYOyMge6ynv6pJo
+ m8zo57a3I6WlBdHUTYKqqtiS8SgoIFPZrHmDuHgouLmDY2SP4MQhhNA1nElpmwfDIDYOlqlpcMzOoZVs
+ IdRt7PHl2k0vdR9g3gSYDevWfeOoY2hOl1KenqxKqdswkzaZukcU1X1gZRVbCu75BTT6WTBLToE+GTwX
+ HEILLyO4C/ORlHMPkcmd0LW6gh/0LVlABpQBVrvoCMUzmv3Llr373itPgLmpICsrn2ls7ojI3Hw2iXKm
+ /imB1JZWtpMwE9envJwdSWZErai+jalEODExOKFvin2yilA2dcRRrjXUQ8OgFxsLk0RaraakQIFjBDsH
+ 7webN+/Qe5Xm2S40raUtoQkT4uDkPcF1cEVUYRGKqKwy29rY7sG0zKvU15kUPNkJnAOb9Aw2CQZENyIC
+ F2jEDeMTWOPGlI6SuRVU9c1ga8vvXLt246lXbV4C4ElPXbR1624HX9+EQf+AZJhau8LUyR3BBBNPXSjy
+ Rh07F67QGZhXXMLOB2dqlQ5UIkxZWSYlQcXBGWcucGFq5Y709Fpa73Br1qz54tufwvwsgMmDvP32u2t2
+ 7TroyeFYVZMJscA7GlZ2l8G1caeO4wyOpQM0zW2hybWFDvci9Kn0jCxcYEcXhpOTr9O94Nh7Cgrn09at
+ 26Qz112VVwkjsZibuWM6+OK//33diePHVYPV1AwzdXUtq8zM3O54e8cNM0YjIwvErq5XBy5csGvS0uKW
+ qKhwEnfuPOD13nt/XP0qTS60rwUB5jlj/ozA3v/DH1Z+98Ybv/qSnv/m/8vsnH7+lQd/Fcf+X104LlAR
+ 5z/iAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="paper" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAYAAACoPemuAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAChxJREFUWEfNmPl3
+ lPUVxmvX32p/6p/gsdqqgCxCIlpwqxU3IgWDtaBAlYTsxEjAEFBCksmiEEDBgBANmx7coIh7gklm35dk
+ 9n3L7DOJTZ4+b0LSOTXIkNPT05zznPedmTfJJ/fe5977zQ0AfvJ/+SWA/afmzll4+4svVB4sKqruKC6m
+ tlR3bCmhSqs7SgSVUeXVHaWCKqo7yiqpquqO8q1X14MPP9w40++62ns/gBIeXLggf63FnIbXA/h8gD8A
+ BIJAMAyEIkA4SsWB4SQQSQHRDBAbBeLfA4kxavyH2lxRO7Z02f3HcoW7Kph5MA2PC/+G82fBDRNwCi6R
+ BTdydbiG/Wewq+3s94uX/nF3LnAzgi2Yn7/WbEzD7cR/Da626TSOXgLKtu9PL1qc//y14K4KNqRPw2UH
+ 3I4sOC/TOhW5EFN7jcjFs9JaVHcKO44DnZ8B6za/Eps3f/6yH4ObEWz+nXmFJm0KLityh4ux5qbSmmbN
+ XUlr/J+T9VZYcRIFTGLtUeDIhXE88XRR6Kabb77puop//ry8QqMmBacZcF4DLpAduRngYjSEALemrBs3
+ M4ErdwE1nUDHxyN4YMUz7l/feONvZoKbOWICmCoFxyDgmIKzZaXVTbdOpVVw7BSc4NgpODo2eiVygmMr
+ 6jvxl9JurC47iU21p1G15wyqXz2Ce5c9NJA72Ny8QoMiBbuJYDnATbSTH4GLMq0T7eRKWrPbyR5RS2/O
+ YHfOWbJGJ03CZgB+KzdgpdqNzboAKg0h1BjCqDYGUWrwY73Rhwe0dtyvc+BBnR3PDvlQbg2h1h5GvSOM
+ bfYgSmx+rDa78SeTfUIFFhc8349N97oGUcvl6wLTipOw6oDfKczYoglgpz6CRkMELcYIRINR7DEN42UC
+ bjB48Te9B88ZPaixhLDXFkG7PYIDzihed0XQ4BpGlT2AjVYv/m7zotThh390fLoR721p/S5nsHmMmGYg
+ CYsGaFVHcVAbxzFDEu9QXaYkTlDHTQm8bY6jfZCw5gjaqKP2BN5zJXHKncJZ6pSbr718zhNDhzuCDm8E
+ b/miCIyMT6aV7aSxra0vd7A7lqxR9yVhVgF5SjueVHvxoiaIrbphbNOFUaMLoVwfxLN6H5ZrHLhbY8cy
+ ar3Jj/KhEHZYwqizMpVMa7E5gKdMbtxncGC50Y7Hh9xwpsama66xtf36wFSXkxhSAu8rUzivGsHn2lF8
+ rhM0gi/0GXxp4pU6P5TGec7VC5Y0vnaM4FvnKHpcGVx2p3HZw6tvFF9507joT+FiIIUvQmkEBcdema8E
+ y92Vc29fslrRk8CgHJgns+BhpQvrlH4Uq4MoZ+TKtUFsZt2tUnsYURsWKC3IU1mxlvX2gokmGQyhajDI
+ awAbhvxYYXAiX2tFnsaCh4wO2GJj08O/sfX16wOTf5OASQpskvtQIw+hURVFuzqGfaoY3tDE0K6L4lWm
+ tlzjR5HOhzKdH3tpiPYh1qQ5hkOWGA5aaQAbn2Nqq5nSlyx+1NmC8MTGp6dEU+sb4pxrbO5tS1bLvkrA
+ yG+ploWwW04nKqOEiuOgJoH9BNyvjaFZG8UObYh1F0SdPox2YxQdQ3G8SVMcpo5Y4uiw8jnLMF6xBFFP
+ 1zbah+GKjE+uTRxhTa37JDmDzSGY9MsEDP0sfpkNTyo82KQIoko5jBpVGC+pQqig1tIUy2iOfJUN96kc
+ WMeolbHXbTOFUUttM4VQxNQWGNw0iA33am0ooBGsobHJtYlToqllH/Pyw2V1xpE05w+LV4kvxaGnX84O
+ pPGxOIML0lF8Jh+Z0CXVKC5qRvCJOo0PtEl8oEvhnJ7FbcrgkmAK8yi+NGfwjYWFb+V79gw+cdBEjiQ+
+ d2fgyZqvzS0dspzB7vj94lUDF+PQsSffKbXiEbkbz8rZCuRhlCtCKFMGsZFmeIqRvFthxwKFFUsZuUIN
+ 2wrTWsW0VhnYXhi9DWwpj+pcWKRm8VOPGVww+8amR1iz6DrB+i/Eoe0BqgZYGwOsMTGLWprAQUkch2QJ
+ dMhiaFNEUa8MYwfTuksdxj7W3WF9nI04ManBBA6ZomgzRVDPtL7K9Lax3py+8cl1nZFrFh1QXFfE+s/H
+ ofkGeF7sQ8VACHUEa5LG0CiJYq+UQLIItjOCRYzkJqUPxaoAdmjC2KPlJKBjRVQrR9geA0cXo/eiwYdS
+ ox/b2EosboJx4RTgmppnA/Y1cJfYisclLH4JUyMdxkvUVmkYm2UBFMo8WCazI09uw3KFA39V8Zezz9Wy
+ jWzXsvg5JV6gIQo0LtwtGERtx0qmdcg1NrE2CQedZtEhtvEci/+OW+8q6D8fg4Zgx3s4+3oz+KB3BB9d
+ HsWHfWl81D+CczTFOUkGp6UpdMuTOM016WP1CD6lLtAYF7UZXOSEOG9g4ZvSeJ/z9dxgCv/ghHByXfdy
+ p/MSrrn5EAffLMAWSGz4s8SN9eIASsVhlFGlYha1JIDVMi/yGbGFjNhSRmwNI1aiDqGS9VapYUth9Naz
+ pazQuHEXI3YPI/ao1gWjbQweHnQEuOamN9WzAnutl2tML5tmbxKdvQkc4ww99l0CR/oTeKs/PmGKvRKa
+ g3X3pjyBE5ytXYoE3lUn8S6bcaeGZqEpWnURvKHnM4YYLNZxuHnQEeBEzW9xh5lFxFb1e7BxIICqfrqv
+ LzKh7f0RbOXrUjr2abEHq6QePCP1oljO+lJG8IpiGDtV3ETo1irO1w1qHwpUbqymNmp9MJjH4BJWdcKJ
+ mg5rcwa7/dZFK/s+jU7U2HKxA0+JvdhMZ1b1sfivqJhQ6+jY+/n5vVIHHpG5sJFgNYTaTtVxSrzMVlKi
+ pElUXjygdOAhpRNPc/DrB8fgtPAExoOOqPEw19EcI5YN1sniP9GTwkka4HRPBmd7RnCG15NUd28anZe5
+ CDKt7/TTJBIaQkpjSDP4UJHBOUGqDE6pUzjBtHZpEzjDKWE2jsMxxBMY4USNb88OLF/iwAqm6jm2iy0D
+ YVT0D6OkP4Tn+7n2MJJLxDYskthxj8yJQva0LRz6lexvldxIShjBDQo/HlO6sZgTQtBjTKfGMDZ50CEc
+ wXiymEXEDnIv62Thd/WyLfSk0f1tGu99ywjw/hijeaAnjgOM2iHqeB+fYRs5Q52WcL2W8cp2cpzt5LAy
+ MaEummJQNz5x0BHgRHs7cwe77ZaFT3z3SWSixnKVllNCGGHCfNXzeCFsJsLaZOJSM8gxPcTBI2zEZjYH
+ C8tdOOgIcKKGTmPOEZsN2MQfcA24wRngRA1HGbccUzlrsFnAifYc45H6fwGWDccz9nRaudkLaTUxrcJZ
+ YiqtBKMFcgS75aZ5jzbUHve1737fK6ht11lPtlrrz3im1LLzlHtKorqT7mnt5P3ObpeovtvVsovX3e+5
+ WgS9JqjLKai1ocu56snn9DmD8Z/FN1C/ytIveZ+tX/D1lH7O+yn9jPfZ+ilfT0n4mRO61j/thM//BR1x
+ NCLR9Yu7AAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="mbox_error.png" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAABcQwAA
+ XEMBOS4mtwAABChJREFUaEPVmVuITVEYx5fLmXGdaTSa3Br3mDAeCIlxeRAiRBE6pWQy5dJMETURDZHL
+ FHIrzYuEGCK5ZR4kxIMm5VqIcnkh0ZAs/2/sc2adddl77bP32efMqX9n5uy91/r/1rfWty67A+ectesP
+ AbRntWvzrb0n7NZHd+wHzYaqoO3QPmgvVAuthqZDRWHVGwoADE2BDnZk7Dm+aVDZ6KEDOCoITCAAGIh3
+ YuyRpWE3qGsUtXRA0gJAZTM7M0YtaNPSfu65gDLL/ID4BkAFu7yMTwTYKgidnqPz8z3QFmgFVG4HXWUL
+ YQ0A0z3zGKNQa1t0MX4/D/2gvOChT7h+AprhDnPYBsIKAKZ75zP2WGc+DhNPLUyboJrw7CwzyGkvCE8A
+ mI51YeyBbH4gKr0SwLgMdAxlYVzpotvgBuEJEGPsnGyeWuxziOYTMAgxH6GH2GGCcAWA8RrZ/MIMGBej
+ 8d480OfpIIwAMD5SNl+RYfMJkFeop68aiRe+ANB1kFTa+mQB/n4dEQCBIN3pxkOtDKGNAIxPklv/ZITm
+ E5GoViG+UzoXIbQAWNM0iABRdR05M9GcUqxCVLsCECH0VwRozELrJ2B2qgBPvACWi+aHZ9E8QXzUj4Ux
+ CQilC8H8KRFgc5YBCGKOCrHBCID1zksR4HYOAOxXAc5oAWjZIGcfDPu2xVkRNlLxeDQqKUnWe1cFaDYB
+ DBUBBsitX16O5yL6VFQkAb5o0qkJYIIIMC5HAGgcaBZ6ecqmHuanigDY6Kau7bMUAQJAbpdn5gIdQMoM
+ jHDkDACW9DJAVx1AygJuSI4AfFPNt5jGQA85C/0RIWIxzktLo1F+fjL6tE+QfCVXpspEhnXQW/Hm+zkw
+ DxxXARrdZuKzIkBdDgAsVQG2ugFUigDKQI4Y6Bfq66YCTHYD6C+PA5oJvY5KMnX9qGr+jed+AACXRYgl
+ WQQoUwHqbADmy1G4mgUIHGvrtpWDPQFaJwjGmkQITBD8d4QQzagLGVEGOGK1J3YAcPKXWsDKiABo7qHk
+ IdVP++E+1gAOxAEZgjbamRqwiXIX6LtOpWxeWUpob2DsngyBVy8ZgaAlw1y9eePxoufRIswPgz7IEHS8
+ iK1baCB3UJYm41A3atI1rHEeMERhPArCviK1X2L7xncHhKDNykZ9q5N5OlQuDgzgjIexKOyZDEH/0zHg
+ NggvyKwjAmd8HYQ9uC5V0m/XoUI381ZjICXnojVQKL0GMlXKR+PaGqgewo38FnQDwgKr9W0NZbJBLs87
+ Zdd7GffVhZTU9f8V6lc3kDSvUYQX2Zr3HQEpGr1QGV5/sZ9pmhWj+A5l1PgxHigCEkh3VL4WwhGSr7eW
+ Lbj/IrQsHeOhAUgwhTCEgzS2CcI+hF1ywG46Y+cQvtdD06COQYxnBCAMQ37L8JzI/BYY9f3/AJQMVypF
+ n/EwAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="No">
+ <value>Nein</value>
+ </data>
+ <data name="folder" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAABMNJREFUaEPtmW1o
+ U1cYx5+mSZPcvHax6GTIGBNfPlUp6FBERIeonTCoyHBWOuyLVKE207UYCY3isszg2iTFpJ2hXW1ybReb
+ tkq0nQhN04rECSW0VavWFtlg3YeBjK3b2TkdnV1y09x7d+dtsIHny3055/87z8t9zkkGQgjS+kcA0tnS
+ WvxM9KTz6i8CLATvvT4hhEutdNkyWLtzJxw4ehQ+PXsWvnS5oKWhAXouXYLwsWPgEMMjjB7AYlWFhVBh
+ s4H74kUINDXBYHs7TEaj8MfEBKDJyUQbHIQXGzfCerYQeA5q1SrIy8+HT8rK4JTJBE4837f19dBfWQmj
+ +L6CzViMABYLhJ49YxbKJH72WnU12GcnxQIyly6Fd7Ztg4JDh+B4VRXYrFb4xuGA3sZGiAUCMHXvHvMc
+ fX0wrdfD27wA8MRZHR3wfD6hye4NDMBPdXVwDYfV3dZWmAyHYfrpU+4LMTwMaMMGeJ8vgD4Ugl/4AAj5
+ zu7dUMQXQNrWBj8KKYbPWCTs5gKQyFi5Upa7ejUY/nWdiRIn7WM+kwrxDsmLQECCSktlvSYTVXf+vCbg
+ dmvv+v26511d+t9WrMhamxIAl8X7QohJNsaDB4Bu3MhAPl8mNhk2OfL7KWxqdOuWHj15sgRXukRratI9
+ xp7ISAngdkPffwUgVSwSAXTligQLlM6I9PmU2FQoGNSioSEDo0gm4bPXnE5tT3zEMJZRpxOusQWIxQB1
+ dUlQa6sUWxY2BTYK0bQG9fdno/Fx5tWcT2iyexaL2s0KwG4HPxOAz0eEyrDJsSmxqdH16zo0MsJ9NfkA
+ FBcrP2MFcO4ceOIB7twBdPu2nrPb+QhleufhQwPavFmezwrg9GmwxwP4/RJBw4ErWDCo+xknsJYVgNEI
+ 5niAy5dloq0+gfV4tFGmks+YxMXFUJkIoBAVwGZTt7EG2LcPDicCUKICGI2qL1gDkA5ybjdKPjwdHVpR
+ AfbulZewBli3Dt4j9X3WC93dEjQ8/GpKJVNyRyLZ0/EtxD9tOyMVwFukJ58FIB8prlVDyOe93sQWIhUA
+ FQzC1EsAuagAtbXq3mStddJNfUsLjL8EUIoKYDarGjgDeL0wRADIHph0iUKGBNexiooU1ZwBPB6IEADS
+ UZKmjOukQj0/OsrcQsybA+QmPjIJEQCazsReEK6j5Ap29SpzC5ES4MIFaCMAZMPBdVIhn3e5NPfn2xsn
+ TWJ8BPI1AfD7xW0hampUIV4AZjN89TeASlQPlJUpfbwATp4Ey8gIoO5ucVqIsTEDunlT/+uuXcwtRMoc
+ OHIETnR2ShDZSAgZ03PHItvNcDh7urlZN4FjfcBqVbdXVVG1hYXKE1u2ZH1IUfBmqrOhpDmwfz+U0rQw
+ LUQ0+safNK2bcrs139vtmk6TSV1fUqI4tWOH7OOcHHgXb1QkqYRy/g5s3w4f0TT7FiIWM+DTBt0Lr1c7
+ 5nBoe86cUTWWl1M1e/YoDq9ZI1uPRcr5iuSVA3l5sJWcLsx1+aNHM3H5e3Oz5gePRx21WlV+o1H5eUGB
+ vDw3V7oVi9T8HyJ5ASxfDksqKuSjTqfqO7OZch08qDy+aZP8Aywy51WL5AWwkEQuAixkb7w+f/ItVC8s
+ ekBsz6S9B/4C+eG8h3vJrfkAAAAASUVORK5CYII=
+</value>
+ </data>
+ <data name="Green">
+ <value>Grün</value>
+ </data>
+ <data name="Define Colours &gt;&gt;">
+ <value>Farben definieren &gt;&gt;</value>
+ </data>
+ <data name="Ignore">
+ <value>Ignorieren</value>
+ </data>
+ <data name="Help">
+ <value>Hilfe</value>
+ </data>
+ <data name="Add Colours">
+ <value>Farben hinzufügen</value>
+ </data>
+ <data name="Retry">
+ <value>Wiederholen</value>
+ </data>
+ <data name="mbox_info.png" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAABcQwAA
+ XEMBOS4mtwAABL5JREFUaEPVmX1olVUcx0+3ba6VDmP7w15w+TJ0rJc/EhuytuqP0Gz4UqhoDoLYcOAW
+ TpQFW2KaKFZihbMg/CdCxTeU0VK2P0SdzD9CGlsrfGtg7Y81pFjiPH5/u7vee16fc577aHcXvmz3uec5
+ 5/s5v3N+5zzneYRzzib0hwAmsia0+bHRE3XvYzg+DS2E6qAt0G5oF9QMfQC9Bk2Nqt1IAGCoHPqCsVgf
+ /tKkctHFccDSdGDSAoCBasYe7XY0bINqo6iFAQkFgMbeYCyLetClp33KHEGdJT4g3gBo4NNg46/A9PtQ
+ M7QL2gk1QWugF12A6lwhnAFgejJjORRqg4F3cP0w9M9YarDrT/z+DfS6DeYrFwgnAJguZGzSJb35apj4
+ xcG0CaoT975pAvk+CCIQAKazGcvtUs0XodGTaRiXgVpRV5YO5IANwgEg+5Bqnnrsr0DzM2ZwvnEj5ytW
+ BA2pxO+XUOccHcRWE4QVAMYbVfNLA43T+C8q4nx4GM2Of/budYX4wzTR39ZBGAFgfK5qvsLJPAHU1yfN
+ 039DQ64AVO436Ck5Er96AmQfFgGmoMLfnQEWLxYBurt9AKhsm24oNcsQ2gjAeJna+986m0+k0G3bOB8Y
+ 4Pz8ec5LsWEITq9ymQ0yxC1K56kQBoDYARHAfej4m7SB0ZpSIENssALEFyx2VwQ4FqL3wvS47p5PZICf
+ gwBWi+aL/0fzBHRTNxdeSEAoQwjmvxMBNnsDlJVxXlGhV2FhmMgskiEaLAA5/SLAGS+Aqiox+8jfenvD
+ AHwmA/ygBYhvG+TN2i0vgAULOB8dNUN0dIQBOCsDXDYBzBIBnvUyn8hAxcWcL1/O+eBgEqS1lfPKSs6z
+ ssIADCrp1AQwXwR4ORRAAuTKlSRATU0Y46n3KBu9HIIQJjHMvyoClGcQwGQ5ClN0ANIKPD+DAHJlgMd0
+ ANIGbmaGAAzL5kdMc+AJNQvdCQ0R3Ryg5wQhO97fmWoWstg1sfCFDADYLwMcs63EB0WA7RkAsFIG+MgG
+ UCsChJ/I0Qyh/2A+TwbAchk/lNbthZ5R5wGthP55PBqAfbL5qw7PA+yECPGuM0BuLufTp8d140ZyIWtq
+ il8rKPDtiBIZYLsLQJUahVNOEO3t9s0c7ZNoS+EW0d2yefqOs47kOw3bQ32nCDEXN98ObLinxw5Av65d
+ 6wJwGW3FZICvU81r58D9yYFzPzUK7wUClJdz3tJiVgN28nl5QQC09lDyEHI/PQ9PcwYYo2PscxWCHrSD
+ DKT7+xLd0KmVzVsjkBKJcypE3QOCoC3DWzrzxuNFh6NFNhsAAyoEHS/2RwjSgbqUjEMwnbqeN64D2jAx
+ Ng8VDaoQ2WhgR5oQ9LDyoa7X6RodKiPxmt+kBkYgZSi9hMp6VQiaaHQM+DHU5wHThbLroRyT+R/RVr7N
+ vNMcEHIuegOV0msgU6O4/jxUA+2BjkCnoXboIERvayiTPWe5f6zuPUHGvYaQkrrir1D/toOEen9GEV7m
+ at47AlI0nkRjO6F/IwC5jjoafYynFQEJ5HE0vg464wkygvJHoVVhjEcGIMHkw9AiaBO0Hzo+DvbT+Nz5
+ En/roUoolo7xBwIQhSHfOpzTqG/FD6v8PRJO78MpB02PAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="desktop" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAACj1JREFUaEPtmQtQ
+ E3cex9eKr7vO2evUu/Zs72F7147edTrezdmWdmyvnfM8q5718BwRX1WEU4vYIohKtYjhKSQ8E0ICojwl
+ ikAtiqL4FpQozxACBAiEEBIgLIIC3/vvQtLwTBC8a2eOme8kM1l2P9/v7/vf3WymAKB+0H+MgR+yftDw
+ bHu+z+lT1PZn58zZ/dbixd5bV22J4qz2yUz+RHjr1ofRd2pmHinY+D83QABnzJ69a76t7WGHVfahh+0O
+ nT6xQnD96ieJUtmnkqJG+wvlHTultX1u1Rp4qrTgNGvANzTCt1KO6cIq36dugADaTJ/uPG/Roq/sVnwa
+ dNDOMyVmZfiV3GUnCsv+kfZA9a9zZe1OBcpe18omfFHbAi91M47pmwikekwdliswPabaf8IGCOAzRC8v
+ XHjwk6V/9/VY82VC1Cruxexlx+8WrUy9X2eXWdq69WZNj4usCS7VOrjXa+Gj0YBLII06pqnHgfzrcE2N
+ h3uCEPvjwnFYenvQNubbM+89y6sZAwFWGSCAP58/f99fliw5usdul5i3OjA7c5k4X7oiSar89EyJbtO1
+ qkc7itXYqdDBRanrH3WTBr4E1ChOUxM87t3DzrQUfC7mY19cJHziw8A9GYq4U+G4k58GvT4fNC1lFSvh
+ Y883GYP2Yb6/PSVKYqAmaOASsP1Hr766992PPvLZZbeNH2h3NEtCFkrBigRp1SpJsXZ9rqJr+/1GOMt1
+ cFbosVtJRq1qxqGG4XIrKoNTegYco/lwFYbDSxQKX3EIIk9wkXP5JBobr5kgjbCjvebeTIWzKHrE4+x4
+ UEvWgPIYa+A9x3j+unw1HMtbsEXWiu1yPb6saYE7AR1Ju0tq8FlmDjZECeAUEQa3qBB8LQxGkDAQkkwh
+ 5PLzVkNaMiFXXIRjkD++lDcOYtlaWM8YCGYN2O7LEDmUtsKlklTAgrbweIhLDkVh4Wm0thZMGuhYRphq
+ fRHMgePNUhOfQ34DpglrQ/oNeGSI1txvg2Opfkw5RMejsCjriaGb2h/gVrMMSXW1ECsbIarRELUQtcGH
+ 1NPSNIJiebA/ncsyrrmhxrToWp7JwMqCdmyQto6qtSeykH0lyeJBFPpiXGioRHytCnFKNWKVzRDX6Mlr
+ O1LraORrOqFtp9HRMVhiYsSSAeZzSXY81vATsfKKBtMEdQMGSIWW3OiA3e32EbUy+RbiJNFjHuCwrA1x
+ NQZ820CjQtcJwxDAocBPaoAxcfd+FhYHJDIGwkwT+OBKB5bnGYbpb6dl4AhCLKYjJvCWIMf63NoJGAz3
+ cD4pGPZvvo2tz72kXUtR/2TXwDsXaHx8oWOQPjyrhosfxyI8k8rTNnDzjgQhCQI4bFoPLbl9yyNqIIqg
+ qPOsgYVZD/FeZqdJtukG2B/0QXv7vadqwGCg0U4kqh6+BhSKHEQkRsErIR5H7skQ2Qa4+fmjj4D3EgmJ
+ 3CgqlzWwIK0Lf0x9aNIyj0BoNDetgh/vBBhoFpws5rY2Gq1ERgPNzTcRlyaAd4IYB3KustDmCiSL3c1h
+ HQ7MfQ3v/3n13V9T1M8oW/cM0WsJ3VhwvIvVBx4CVFRetBreWgMmaCN4Kw09kbbFAPfUb+B3Uoh9krPg
+ abqGgYeoDPBKSwMvOQZXriVhoWs0poU1CPoXMTHwsqgb8/jd+JOnBNfvnB4X/FgGRoPW62nkXS9AQHwy
+ 3E+mIUChGQYdru/FV+fOIzBJBElWDLlwfnev9OauGNiENkSbDMyJeIzfeN5CSmb8uOGHGjD22rwiTNIM
+ tI4oIycP++NT8XVB2TBopi7eN+7CJzEW4pRIqFR5I/IscBbChtcYYzLwk2M9eH1b7BPBGw0M7XWrGXSL
+ jkZLCwN/FQezh3ebU65iF2t4QgSKijMtcsx3JBMIaRSZDMw42ot5m57cgKja0L8gB3rNJK1joIm0BLxZ
+ SyP928vwzLhoSp3p9b6kdPjFJsPjVLZFaPMr9etbRLA5phabDFAHgV+uOz6unZjvUFhlYOthDq0l0Ay4
+ ppnGEcld7OSlQXA8FTxxMgLjUiBOTEdVjQ715OrNl1t3K2E85m83xMImUB03eQYUBjZpY9oMNKMmDQ11
+ E41L8k48e6IPaSUPoWqkWeh6FY06otp6YqBifAZ+t9HcwN6z4olOILrSwAKbQzcS8EY1jQYCzEAfud2N
+ 2Sf7kFvRyUIzUpIbvJpaGlHjNPD6RrHZBCbBgIAYUA+kzUITMdAqJmkiJuk6AvzXrMd4JbkXBZX94NVK
+ mtSIRqTM+gkUSM/h+c2XzQ2kiyY6AX6FgYU2pm2CHqgImzSRVEHjxcRe2Gb0oIy8V1TTqCSKJN8Grbmd
+ ZrZZvpsLag8m10AUMTC01wy0sSJs0gNpSx48xFtne+F67RFkZBIVxEiElQbSshIxa2vx5BuIlBmG9bra
+ rCIKUhMm6coqGnIibkEX1l7uAb+wC+VyGuFllifQ0VGId7fyWPhJn0B4uYHttHmvGWi2IgPQTNIVJHEm
+ 9dIKGr753eR50CNkFj9EeKllA4H8CDzjpH5KBkoNpooYe80kLWegiRhoJmlGZQS+VEa+XpbRCJN2Q3C/
+ G0ElY38n1mpvY8EGvgl+yATOTHgRhxIDTEWGQsuGQDPgJeU0igl8fimNaGknOA86yFlIPeYidvEOALWr
+ 8ykaKDGYkjamzSY9kPZdApxQRINX1I6IUi2EcjWSa5SoJA8BLJ19Ksmt/SvrEwfBT/oEuMUGUz0KScIM
+ LJfAMotTUNEPK9eXWIQdycwaF29Qrr2WDdg4N2D5jqPk8d/1cR/IqbAdYeU6ckVVI0lZC5nuyWDNDVRX
+ X0SEMAjPb7gwDH7QBN7b278G2NPT7h78fkMEzl1KHbcJS1UY7XPmydv1GynghAZjm9cxLHUJwx828vHC
+ +kxQjg2D4Q/0YYZfV+cs/1bVFH77jv5no+YGBs6xL2y+hP1B3Ek3UVWVg/gUAb44GoQ1e0Px7vZI/Mr+
+ OKZvkoJyefQd7F5gqvfjxzMDOnQzfVvKqED9Kep4zwHqDGypHMw0/1VpRAPMNKY6NWCpMwf19VfHbYRJ
+ Ne9aKry5wfjMi4slLpGYv1GI59Zng3LSDE21b4bfQ3qWX2v9NF/tNSqCDqNSsJGAzrXm569RDbCVIovn
+ DQcBzp5PHtUE8/gjhjyzcT3KxWq3cCzaHo256xIwdVMRqeTj4an6k1Q5LaUk1VSSqieVjncI7AxrYEfa
+ hnp/hAoZL9fG159uzsNefy4u5aXiUAgPm73C8fHnAjC3tT+2vwjKuWV4qr4kVV993TSONo+kyiWpOhDQ
+ Xzwp6Gj/Z5UBxsiUf2sxZXP54FOaW39XZ/l3tMzkaEumBOiTqPgeD5Lq2xNJdTwmrTZAHejrm9Gfai1J
+ 9TIV0RlMUl1PQF8azwEne9vhBvpTfTTLz6AlqRaTVBNJV92ps1hEYKdPNsBE90e9sSfTaWZwm8qGo82l
+ IjsDSarrCOiLE93xf+v/v9e/1FsTwv8NWJPS09zmP/rAGm4g64OPAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="Hue">
+ <value>Farbt</value>
+ </data>
+ <data name="mbox_warn.png" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAABcQwAA
+ XEMBOS4mtwAABLtJREFUaEPtmWtoVEcUx+/efb9ujGAKtoKk1mekUgkV+1KkSH1QlYjUZ7C2FcUiVTAF
+ BQWr9V0q0jaIQbSUBFrFKGpFUPCB+EA/aLW11EdbTW1Sq631k6fn3Oy4s3PP7p3s3phdMPBPZvfeu/P/
+ zTkzZ2bjAwCjpH8IoJT1RMxjhEOdNUidAoCGN6HQs52e9Ku+ZADQ7LiUaTIua1pnQHgaATQcQf2UBaAN
+ 3+/lNYTXAF9mMS8isbtoAdD4ZNX8K6/61TSi1x95CeFJBNBUd9SvMsCQl/xw92EZvDk6wEEM9QrCK4Dt
+ 6ujvPxy3Ac7/kIREImMyE9CJogFAMzNV83VLw7Z5oS31US4Kn3oBUVAE0HhPVKsMMGx4e+qomjYzyEGM
+ KRSiUIAmdfSPnEiwAL+1WtC70lQhfsbn44VA5A2AHX+gml++MsKaF9Fo2h3jotDwxAHQeB/UAxlgxKhA
+ TvMCYuGiMAdRmy9EXhFA483q6J88x6cONx+qX3bUh/v4eZX5QHQYADtaqJpfs4FPnTv3LSCwU+cT0PbA
+ ehwhmidMxd7X6QDYaZXa8Vtj+dRZvT4CZWXp9b9qsAm376YhVq6JcBBLOgrRoQig+UMyQCxm2IVKTZNN
+ m1lzoK5QY8axVXpYRyC0AdB4nTr6n22JOsy3/mtBxTM+x+gGgwZcb0lHgKAvXk1Ct3LHvWc8B0Dj1ar5
+ iTVBdtU5fobNb5hRy99f38BW6Y26EFoRQPPHZYDy7j64/IszdWhUv93jXOsty4Afr/P30zO174a4+fC2
+ DoQrABpfoY7+V9ucqSPmwRdbnSNKE5ZbTsV7f9yz4IW+jip9A/std4PICYAf8LpqfuoMPhWEmeWfZE7g
+ vv1M+POfzNznYHbtZav0zkIBzsoAzz7nc0xE1cz8DzPT4bvmmFaFps9ZXMdW6fdyQWSNABpfq47+9m/c
+ zdRMSe86x47X217IgzDceYp7iD76ZYNgAfCB0ar52e+HtEbyjZHt24RwmK8RueYCXTt2ml3FvtcGwM79
+ qEsyQOXzJrT87Z7HZKD/gPbJSOngZjbb9bUb2UK4lINwRAA736yOPm2Ddc3cvGPZ80Te++g+K983YRJ7
+ AHpNhcgAQOMTVPPzFuilzo7GGNBB3jQN+wy8bEX+ESCQK9eS0KPCUaUvZAVA40nUNRlgUJWpNfKr1vF7
+ n6s3sxcvnag07GSr9OcyxOMIoPGt6ujvOdD+zUIu0dygTZ36LFVr2k67Pe92fc5ctkrXCAgbAH/eUQ0s
+ WqKXAr+3WfaKIz8fChlAKeVmTuf6X/9ZMHCQo0rfwv4qUt6NHviiRTYwtJr/ZiFbh427YkDr94tDTJg+
+ K2gfYnTM6d7TfDDO7ZUaBcDX6ugfOuqeOrqde3Xfx8vYKj2P0scR/mTSABKtJkLxuAFClPNC0agBpEgk
+ LUopIUonIToTCAUCBgj5/QaQaAUT8vkMEFI9Sq8fOQBy3MyFsevfS+VR1xtRMkF7IEsZwPaeAuiGxGUp
+ WfhXiIqbUALbQnFsC8WwTYpKov/UCIWxLRTCtlAQ20IBbJNoHyZkYlvIh21bObcSboeHYrzueqQsRtPs
+ VqLYjWqfB0oN5GkKdXXEnkagqyPwP76kA5sYKmTOAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="monitor-planet" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAD6JJREFUaEPVmXdU
+ VNfaxo/GfBo1GuONuUmMJTHGllhCchV74VOxtxgrKkhVFCkWlEAAEQQB6SoggrRh6EMZemfoAlKkqiBg
+ A0VABH3uew5CBtCgN/pHZq1nTTtzzvPbb9l7n+kHgPlHP1iAf7L+0ea57HnT0S8tLR1cWFi4Li8v74Iw
+ WZRgGO5RrRXk0awf4HffIyg+OzQ03Cc4OPiAv7//mDc957s4rk+AysrKcQXFpS7qwX7PJnvK4XOfORgX
+ NAUTQydhsnAyJgknYYJgGr7ykcTXHqsh6ayF85f5Oa6urmvehcG+zvFagKqqqsGFZcVWOwU27R86zsZI
+ 388xIWQCZkXMwoKYBZCKk8KK+BVYHr8cS2KXYHbUbEwNn4rRwaPx0dWxGGu/E7oOVhm2trYz+jLxd75/
+ JQCZH+eeGVU83GktGPdBGBU4ClPCpmB+zHysTVyL7anbIZsuC4UMBchnyEMmTQabkzdzUBKREhgnGIeB
+ /IFgHMdhkdWhNjMzs23/i8mV50uGTTtwRWLinvN7f1RwsJhxwCVohrpvyiyNwOwZshZJr6wBMj/9ckxR
+ Qz/b6WB4DD7x/wSTwiZhYcxCziRrWuuaFvSu6+F04WkYFBjgZN5JHMo+hN2i3ZBOkOYg2Ej04/UD4zIU
+ X+nJw8DA4ORLiH52SbWjNGzD58qe9pBXNPGyUTIPDFGxjkhRsY3KVrGLLlSxj61QtourOWwf/cDQPemJ
+ e0zBC9GNu7jb2Ib258CLF4CdnV1pLwAy/0V4enXNB7P5YFyHYoDPAIwVjOXSY0PSBihlKkEnXweWNyzh
+ VOGEqzev4krlFdiX2cOk0AR6+frQTD2Og2GaUA/ShXaQOfQEF2Ho6Q8Lj2Q4ByXfdRKk1TgGJt33jkhr
+ jM8ueV5eU4/m1uecKXG1tDxFUVExQkPD4OPD7xKPx4eb21U4Ojreovmrf1cKkfkBafm3M4ctuA5mVBwY
+ q18wzG8YJodNxrK4ZVyaHM89jvMl5+F5yxPCWiES7iUg9m4sknOSkZ6Xhbi0ZCRmiFBYUo6HDY1do9XT
+ HPu+ra0dFRWViI6OAZ/v2yUfn47XQUEC5Obmo7HxSS849nsvL+8aAhjSBUDdRvHn/WVghoSCmV8JRm8/
+ RgaMxHThdKxOXM2ljn6BPpwrnBFeE47chlzcarqFksYSxKXG4TmZ6qnqOzVITEqGr58/fH39OPH5Hc8B
+ AYHIyMjCw4f1vQy+Clj8MxZAIBA8IIDPOAAy/7GFW0kD82EAmO8ywPx/NZgDzvjM7wvMjJjJFa5ypjKX
+ 866Vroipi+GMt7S3oK6lDsL4CLQ8A4SRsfDhk1nWsF8AUlJSUVtb99YG+wLgUZQiY+IbCWAMB1BSUqL6
+ 5TwyzviCmX0DzOoaML/exKdXJbkIrEpYxXWbP67/AcdyR4TWhCLrYRZKG0tR+KgQfKEvqu89hqs7j4tC
+ Xwb+7vee3r6IT8lsI4DvOYCY1OJk5qNgMB/4g1lBo7+hDsy2+xhqK4fvQ7/n+vxO0U6u+5wrPge3SjcI
+ bicg6nYehOUFuBIqRGJ6Ljx9Bbjf0MRF42kb0Ep61k75Tp2D7R7vCs7T2w8p2UUYMmToLIaWB6MOW914
+ wY3+iIiO0d9yF8zuB+h/oByjA2bil8hfuDTan7EfJ/JOwPS6GxySWuCc1ArH2Kew8a+Eu28oYkTXkZJV
+ gPpm4FEL8Pgp0Eh60go0kZoJrAuOwP5XOE+eH9Lyb+KbCROXMrm5uVILD1LasACfRoJZWwtm6z0wex+C
+ UX6EoQ6a+C70O8yLnof1SeuxL30f1DKNoC3yhm5qIHTSXOm1FRzc3FBQ1QQ3nxDUNgJ1pHtPgPukB03A
+ QxIL1kBgr4WjiHGRewnHRe1l3xdPOw8CyKR5YeqPMzcxWVlZu6bJFHcAsCm0hiLQCaDyCMyxWnzqs4DW
+ PhMxJ2oOt3zYkrIFu0S7sDdtL/ak7cG21G0wv2yHG/cAG2cf3KwHbpFuNwBVpOpHQM1joJbEgt3tCUdg
+ r4PrFrWXKXnVyw85lU8w82fJfYxIJNL8Vr6qA4DVgtKuFGIUCOBwI5g/sjDEYxE3qf0Q/gM3sbEzM1sb
+ i2MXc9HRtTuN/BrA8pIPB1JCKr0PlD0AykkVD4FKEgdG6gS78zo4ihgXOTG4xxQ9NiWvePgh985zSMxZ
+ qMYkJSUdmXaUUobx6wCYktVVxMzeejBKLyF0RejvsghDfIdwa6PxgvH4NuRbbt3zeeDnUDE9jKwqwPQC
+ H3kEwsJcrwUK6oBCUtFdoJjEwREYC8eBkViwm51wYlHrBUfpyKalk7s/sqqBOQuXH2fi4uK2LzaitBmT
+ 1AEwlCayldSJNlEhb7/fUQvyDR0gahSdS8u4NVJPbTPYhZSK5zjjwEfGbSCTYFigbLpQDunaHSCXoDg4
+ AuuEKyK4LrDOqPWE65GSF9z8IboJLFy+/ncmMjJyyeZz5WCWi6XRl/EdtcBCsPWw4wHXlRgZgjkSCMbr
+ o14A8/QWgp9QBn07PpIqgORKIIWUShdiL5Z2C0gnsF5wBNYJ1xU1AuwVNTE4e7cgxJU+x9LVvxkyYWFh
+ w/WcU9oYFZoQJoj+rIXJlErSd8Cso660keYFFmYziX22XdALYLzhdJg4BsHIMRQhec2IprViLCmuDIgv
+ BxJIiQTWBUdQHByB9YTrFjUC7JmSl7wjEZzTiOUb95hyE5k3PyBksGorpUo7mJFRHRD9qSamXQMjRZFh
+ J7eVBMMCsc/aR3sBDNfeApXjlnAQFMIhpBChRUBYMS0vWN0AIklRJUA0KYaFI7BecBQxLnJicOkE2DNq
+ lwNT4JFUB+mtCuc5AB6PJ7NMn+YCNgq7msAMolm5syt9QpObBLXZRbfBLCYtukV14dQdwJHW/lL+2KWk
+ B6+MZpyyD4N/PhBwHQgkBRUAwSTi6gAjhb+Ei2DhCIqDI7BecOJRe5mSbmHXcEFYgVU7DtpzAO7u7h9a
+ XuKVDzz4rANiPeX94JA/IfpRRP6dAGZ6AZj/UL3MzQPj0/9PCDUFMJMKsW7bMXhfA9TN/eCVA+41Lxfw
+ IfHzAF+SHwv2Ei6I4FgwClpvOAIThxMWtsLcIx4nLXnQOOsOl6RHWCuj4dS1nKYNwsb1+lQDLACr/W00
+ 8rQ3+IBWqJ3RYJ/7UWp9RHBugzsATKeAGRbEHbd0hQrcsoBDpn64kgG4ZoJ7f5Xkng14kDwJTByOT3Ac
+ GEk8agF57TDzFEHzHA/qZjxoWgbCNqKWO9elhMc4fJZfM1d6x9lue2Ira1v/qVq0J+iEYJ9lmsFMTO8O
+ wYJc+pQgBlFEqB5eAv5nriyc0gEVEz9cFNGFSI5p1LdJzvT5ZZILgV0hMHE4Fswj+wWMiezQWR5UTUg0
+ CKbBt7jfOaW9gK5rZssOTaus5TvUnSf/vESOVqIf99pSWlhYDDEwOZ/z5WFqoeIQnSCr6HNJqpVJmdSJ
+ vgajKN2xAfqa5pDpufh+/kGYR9RD4Yw/rGjLbUOyTab9K8k+BXBIBS6QOuEMvAuhfMYHikY8KJ7hw4BX
+ wh3Dyiz8PmT1rt5cK/9HsMTSXw3+9eX4H151Y6DXXQkjI6PRJ/RMiieqFfWGEIdyWUKbHkozsc8+k7aC
+ mnU0ZE/7wzSOTJDM4wGLBFpikHS8y7Hf0Bf79HmQNfDBiSv5sEoEJ8u4dqhax7cu23uufu46BZdvfpi7
+ jUZ5UF93M155W0VHR2fY8eMnBPPVwjBAhdprz2iw742ce30+aHMM1imbQf5sOHRDmnGMV41d+tSddH2w
+ W88HahcycTbmOQfG6pRP1Yv1Rxwf/bz5bP3XSx3ah60sx7AVJe1k/F99Ge/8/rU3trS0tPqr0WPfQe0H
+ 05SiMED56V9HhKD6y9VDYpUCjnlXY/NxNyhaJcMgog1G0eCkH96KvWdCm1bK6Ves36XRNHqecfvYnS0Y
+ t7u9S6PXF7QSwIi/DdB5AkVFxWFycnK6O2X2VyyUOYtvZCMxUu46hshXY4DSEwyUv4uP9xVh5M5YjF9j
+ jMm/SL3QiwA6pepS8mKzhl37DnXjdo0zlgi7lovrDQ1wdA/Esh22mKHU1k2Tfs15SgDD3xmA+Im2bt06
+ ZdOmTepr1661lZaW9peSkkpdvHixcP78+Zdnz55tICEhsfyriT9VbdHhP910yPSZhukluAqjkPfwIWda
+ XI5egdiv6YhF6s+6SVIuE0rHjqVLrVun8CYQfd7cfZOTdB4zb+nS1crHtOuSKyt7Ge4J4MQPxCkjV2zQ
+ ae2mlarpyKypgfDatfZ1v/3mRNH4v7/y8M4A1mzdetArMupJT6Pi7/Pq65F57x5EtbVwFIRCz+gC9ho/
+ 7abNmimIpQEQ0e2Y1Dt3aHmilPhX3eidANAFPtDUN6h5nflrlEJpdXVIqKpCFJkLLS2DV1YWlFS1oWbV
+ 0k0yJxIQUFCAsLIyRN+8ifCiIkhISmq+LgrvBEBi3rzd8TduvDJt2BFPrK5GJBkXlJSAT+Y8qJCvEIDa
+ UX0o66VAz6m5S4q60XDJzIJnbh78CgsRUlKKrfIKtFp69V9h7wRg8Urpq/mUHj0jwJpnR11YXo4AGknW
+ 1OXMTNinptLElgBDa2fsUbXEea+mLqkZCnE+MREXRCK4EKR3Xj5ktY7R7YD3CDDtx1maTv6B3QByHjxA
+ MuUwO/KBxcWceeeMDNgkJ8M0Nhb6QiGOWzhAWescrgQ96dKJs2EwjIjEubg42KWkcNHYuGsfbTzfIwDV
+ wEClI0ebxCPQOfrhlMu+BYVwy87hRtU8Pp4zqB0sgKLxOWjoWCIwurFL2sY8nAoJgVFkFM4nJOLERWq1
+ S1a6vVcA9uQbN+700je1RjrlOwvSCcAWoziABQGcJoCTAgHkLK2hpK6L8Nga6Fl40sLOGgr2F6ATEooz
+ UVFQt7SB1knj5jFjJkx97wAjRowYvn27Qujps7bwiopBVwrRfwDiKWRLKWQWG0dRiOBGeo+BMRTMraDp
+ 74/jQcH4nf7QOOXnB2UdQxiZXLwnJbXmLye0d1LEXQsraqcbNmy3u+wiaDWzcsYZm4vwIsPhVMT+XBHn
+ ckXsQEXMFioLYhwdzaWLPhlXNjaD1mlzWDt4019SNoWSkguW9DWRvlOAzov99NOc9QoKR9ytrT2qrnoI
+ YWLhiNMWF6FPRatrYQ9tC1ucOGcNbVMbnDKxwe/GNnTMZfrTI6Xt6NEzotWrfzs9bty4f/dlvteG5k1+
+ 8DbHsKtKKan1p1RVT/GOHTOK0dW1yDM3d6nm8WKfOjsHNxga2padOmWapqFhELJnz0HHGTN+WvU253/v
+ AK/cQTHMYAKbSPqC1O9tDfc8/r2k0N819Ta//8cD/Bf1OK6O+/e5egAAAABJRU5ErkJggg==
+</value>
+ </data>
+ <data name="User Colors">
+ <value>Benutzerdefinierte Farben</value>
+ </data>
+ <data name="Sat">
+ <value>Sätt</value>
+ </data>
+ <data name="OK">
+ <value>Ok</value>
+ </data>
+ <data name="Blue">
+ <value>Blau</value>
+ </data>
+ <data name="Base Colours">
+ <value>Grundfarben</value>
+ </data>
+ <data name="back_arrow" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAACTtJREFUaEPVmXls
+ VUUYxVtrLJFUTZTFJUgQgooouEAxGheM/qMREo0b0aCJ0bA0smihRUE0alwQlQfiAu67uOPCYlUoguKK
+ Ii4gsgikaGmLRoz1/B73NNPb+15f+4wJvhzv5c52zvd9M/PNtLCxsbFgj/4PAXsy/jPyBXMLOghHCqXC
+ 2cKFwlUReOcbZdTp8F8ZLS8BInKocI4wVpgpzBYeEh6O8Iiehr9RTl3a0PbQfMS0WYAGLBT6CZMCwpB8
+ VJgj+PeY3uJwGfWoTzsE0Rd9FrZVTM4CEohjUUjwg+jjwhPCk8JTwtMJ4Dvl1KM+7fjRD/21WUhOAtRx
+ R2GUQIiExCFhws/o/VnhOeH5CC/oafgb5dSjvgXRTyiEsTrm4o1WBaij7sJtAq62xU0cK0MGchB9UXg5
+ wjw943AZ9ahPO9rTD4YIhdzO2K2JyCpAHZwipASsTtzicgZiQCwZkn5F/35VeE14XXgjAXynnHrUR5DF
+ 0J+FMA7jzYJDNhEZBaghS96DAXmsg8tt8Zf0joVNGsJvCvOFtyO8o6fhb5RTj/oWQz/0Z48wDuMhAs+X
+ ZhKRKEAN+ggsdawS/Jh0odWxHBbEoiYN0XeF94QFwsIE8J1y6lHfYujHHsGr9gbj8mPu9UkS0UKAKh4u
+ 3C8QNnHyuBtrYTksCAGIQArCi4T3haoIH+hp+Bvl1KM+7SzEHqF/xomLmAG3uIhmAlRhL2FKRB734UZb
+ nk6xEuSxOiFh4osjwh8WzCio7jm+90/9xh2/Qd+qAyzV+xLhI+HDqD7tLIT+6Jf+GScU4XC6GY6hiLiA
+ waqAu1htHPNYwuRx9VuR1QgHLIllIbTkoKmdvqmYMblh09baxrLU+Fp9WxHDcv3740gUYiyEfugPb9C/
+ Q8oiPCfgNThRgApKhHsF4t6rDROWmHTYhOSxHuEBkepjr++/Yd6C+bu2/bazEYxOjduh758H+EzvK4VP
+ I1GhEPqhv1AEnmBcxocHqx+8CO8Si2jygD5eIjDjCR0mDxsNqwIT1mGDhRiEwbDeUi10y8+dMGT7mrUb
+ 08SNUalx9SpfFeBrvX8lfBGJspBl6X529xeKcDgxPjzgAy/4XdpMgD4UCaH1cVkYOkwwx7wtv7RwZuEn
+ l065onZLTX0z8ogYlRrboDbfBVit92+FbwTEIASvfCLgDUTYE8wtxmPccD7Ay14oSp9l0v+bW9BXIPZD
+ 68dDh6WPWE2HTdEDRZ9eecvVdVu3N7Qgj4CRqbE7Ve+nAD/q/QdhjYAYvPNlTAThSP+Mw3iEbBhKoRf6
+ hgKGq6KXTWKNmPPEtfUJHZbAj4rvK1454vay+jBk4u8jU2P+UN31wi/R82c910WCvtcT7+ANi2DCE06s
+ UozDeHEveC6wvF+5+zS5Oz2eLnjy4qYw9rFCk/WLphetGH3H2IZs5CkbkbruT7XbHGCT3llaEbVWwBuI
+ wBOEExOcVcqhFPeC54LD6IE0d/1vfyFcOnGTw4fljM2KmHxfU3zJBeUX1bZGnvIJqZt2nThpwE7jpMqB
+ DUK9UCfUDqgs/X1ARen2ARWDagZWDNo2sOLkLaUTT94sbDxsUjdCDC8wLuPDwysS/FjiWVL3RwA7b3z1
+ iYcPm03VqWWnbd3w6/bEmM9FVK51zrt56BbGExg3HkbhPOiOgH6BgDD+SdJYylg6F/YZ03fd59+u+SdX
+ EvnUO2/qEAQwmRHA+PCAD4b1PGDB6Y+AMyIBTAwLIDNsEnBI5WFfvb5oQdMmlQ+5XNoGApgHoQB4hRP5
+ DAScJsRXoFDAu8eW9/sxvlHlQqS9dWICWEDsgbiA0xFwXGseUPmiiyZfVtNeQm1t1wYPHIeAbrnMgX2m
+ 71M97ckZf7SVTHvqRwI8ibPNgW4IIIlL2oXZwsNNrKr7lB7fvf1B1d+5kNq8bUcjK1Z7cO6U870KxTcz
+ lvdwFSrxRnaPCpxCk/8n7QPpBK7nxF5r36pa3KqIa+4YuatzeZcdQl305L228w1dfhNqhG1dru/6q7Cp
+ y/iuvwjru447eK3wQ8nU/chiGS9pH4Af+8B9QqFzoWH6R7gTk8g5C222E+v70iMm9Fz35uKFWUWMSI2J
+ 78Qb1ZadmJTCO7FzInZistPWdmJ4eSe+PMyFeiesRBlzIdWt7lF+xLqn3ngp49Ia5EKkDsDESerIheIJ
+ HbkQJ7hcc6HeoQDyobtiYZQpH2JykTUuO+DWA1aX3TW+ISmdjrJRyJKROhN1EkdaHc9GSeTol/4z5UEO
+ n2mET5OAKKUeEoRRpoyUmAxPYst0d7HyrBvOqfls1epmu3SW8wDEfbAhgeM8YPLZzgPhqWxo0omsOPJC
+ eJi3F7wrk5f4RObjJIOv6DWx9/o5857+KzhS1uk7BxcD0qTOPsiEJzKfA3wi8wGfcZ2FhtYvbiEg8gKX
+ WfFdOTzYODcKRRCzxO7HHW8rWXXtnWV1LKHRmZgTFysKT5+JsTjx7jMx7eNnYh8n42di0p1B2W4lmAvl
+ AksqRzdmvA83PtiHVyq+B0rfSqSFzC5YfvqEwVsurhwWv5XwjQQeQ7BvJXxP5GNkSN7Jm1eeCrVrdgWf
+ dLHVSZXuFsJQ8vk4LoI8hYwR1zP5sCQWXVI8uQOhwuEkBKRtcerTjvb0E94LMU78XohDV6esF1tNcbU7
+ veDEk0kEscku7WsWCPieCFLh7RxEDb5T7nsgXzHSD/3RbxJ5rjlb3Mo1W4VaKJtbcJQazQpEOJyYE74b
+ 5cBtIVjQ14yIAeH9qL/5OpH6Ju7bOPr1PRDjseNy2Dq6TZe7gSeOUWO2bHuCTn1fhIvjQohfSIU31BA1
+ +E459XwXSs5FP/Tn+x+TJwrStw/tEhCtTAeqk0rBE9s31UxuBrQQXE8IYE3AOTYOlzlUQuL0x1JJ/ywg
+ NwoH5fUHjsATe6uzywRft+NaNjsGZGAmOa5HDIcOiAFEGf5GOfWoTzsTpz/65Udutndr5LPOgaTG6pTJ
+ PVLAG/wYEIvhcsQk/Z3MfxvjacLUoz7taG/ioxgjF+KJG1muDSMhI/T0bQYutxgsCbFMoNykaYdXMUqb
+ iOclIAitfTXwicJwwWcKJrx/EDT8jXKSMdqcJOybq+ESoyKfxglLL5tgT+EE4UxhaATe+UZZi80oHw6t
+ /pk1n87/j7Z7vIB/AbqI4PWoWfWuAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="Color">
+ <value>Farbe</value>
+ </data>
+ <data name="Abort">
+ <value>Abbrechen</value>
+ </data>
+ <data name="folder_arrow_up" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAB6pJREFUaEO9mQtQ
+ lFUUx/+77LJP3o32HMvUIqxMe/hEGlHTMTVSS53M8UFoTWmDItSWGiMWkQgLu6CwmbtLigpJVgrjjFkO
+ A6mlkZQUmNRMNb2cqWzSbucu7bIL34tlF2eu7Hzf/b57fvece8//nk/FGMNA/1NFq25kl1hnSMblAAPZ
+ MBGzkIvvMRuFBBDZ37EH1njAiJdwEmfA8Am159GIB/BgfyAGFmABbDhNhnMAb3PjF8zBdvKGLhiQAQPA
+ BMxALX4PMN4LcZKAMj3emNJXiAEBoNk1wEJB4z/zQr/34Fekoagv3hgYgAUo7RU6YjDcG1lowlikKvFG
+ 2AEodKajRiR0pDxSTd54FFbyhl4KpM8A9EKtVouhd9+Nh1NSsOKmm3AXXVMLDcIHp9Bplg0dMZBT5I1s
+ 8sY4TBODEASggQcnJWHGtGlYt3Qp3sjMhPOVV3B42zacdjjQeewY/m5rA+vsBPvwQ1xJTcVTggALaAZ7
+ 7jpy60Do/n78hnko4Wup5zgegMREjFm5EuUFBThhteLrAwdw6dNPwb77TlnLycG7vV48HlNxgAYOxmD+
+ DIFrDtDfreig3NGADDiQiPm9xiEqVW4uzis1VqjfoUP49frrMdz7ck/o5AQXOje4wZ6qAMvfDbavBmzY
+ MKRIroHbb8e9J07gSn8A+LOvvYYTNBHuwkIcnfAcfgaP3yBmf62t2+vffAM2bhxWSAKMHYsVFy4oCxUl
+ kG9/ABZd62f8cbDBlWBG/2sSYBvKA22ZORPZkgBjxmBea2toAPiMjcwAG0VGpFEYrH8TrKoOjF+3VoFp
+ 6+W98lxZoC2LF+NVSYARI/DgKXK3ktmV6/Pll2BSkzGlSB4gvQfAqlWw+62tG0aP1syfO1dnWb3aYEtO
+ 1i6jTR0jjh7t/xqQg+P391J46Q9JQyy2gn1A/RwONaus1LCsLF3Hli2mY0VF5ra6upg/WlvjabKvYR0d
+ CWzyZG06P1MkVFfjNyUGhKLPJFqkUos7ZZOGNTfHUY5J8Bgq1urrYy/HxqqGcwC13Y7OUBjX8x0tLWB1
+ tAbeektNTcN27dKxaZYISYDZtkhJw71AxcXm8zwFeBLZ9u1oDRagowOMMjNzu9XM6dRQi2S7d+upGdnB
+ g9Hs88+7XO5thU4zowwhCjG9VBlAbq6p3nMc5v+9/jqa5QA++wyspkZFhkZQ01LTMZfLyPbsMbPGxlh2
+ 8aK0y70ALS3xLHaXOEByiVaRB9auNZT7APLycFQI4OxZMLtdz6qqTKy+Poa1tSkzUip2+b17SzSiHrif
+ 7sk9z++npelyfAAbN+KgEMD+/Sraw0NjtL9RC206UYC7rBGyAGfOxLOkpIipPoDsbLiEAHi4KJmNvvbZ
+ VGHyiDWh3WhEsVp2TKcz+kdawCYfwJo1sAsDKFtQfQVobIpl+reFAYYoACgoMDf7khv/kZ6OfGEAg+xs
+ 9NV4b//EIuHtNKlY3usWi7E6AGDhQrzcE4ALvL17TWEDSBZZyJOs8os4PV3v00eebZQU3/M9ARoawE6d
+ igsbwOyySME1MFsmD1y4kMCmTNGuDPDA+PFY9u23gYKOJ6Zgw0PJc09WCO9ES216yXEbGmIvx8WphgYA
+ 0JEyle/5/l7gyUqJIcH2yXDoe3uAkuWLFUbJcW22qPP+8toTQqRIbzt+HFcDAXRhBVi6s7cHzHvBmmiH
+ kpqUrVu7JESAB2hPvaa2NlCRut3SMxHszHufe7y8N4CSLLx+vbFMCCBi585uRcp1z+HD0WH1wBx770W8
+ rFQ6/jn8Y4/pNvQC4BdKSroVaXW1irW3h15C+HstlURbQCYmRevYFyU5aWfPxrNRozQBBWBfLFE1wadI
+ XS75vbi/IXQnJSx/gJspA/NTltR73e7on3oWt3wAVBbxKVKXKzwSwmscF4iD7KpuANJFq2S2T/4sHSub
+ BCtz/CLVdN7x7kIuV/gkBDfk/YYYpnqvWwsNK1UrkuqbN5v2iAJYLHBygPZ2LiHMYV3AWypJjVLp0hNC
+ jWCWSmU73tNPG/JEAdatg40DHDkCdvp0+CQE98AzOwy+8BldqFF0muMSYvr0yOWiAKtXdylSlyu8EoID
+ zPs/B0RQoaukWpm3Gxpirl53nfpmUYAnnoClCyC8EoIDTCzvOlJOLlA+Vnm5+QehCp1vF5ozB2s4gNMZ
+ XgnBAYba1cy0D2z/Eelkee5cPJVlYv4qLY1qz8gwuCQBJk7Esi4AZQsq2DzQ1BTHoqn6tr6ia6fjhQIq
+ GPxTVhZ1kU5aTRs3mmqefdZQMn++7oUJE7Rpej2ulayNem+OHImH6GuLp/oQrHFiz/EF+NFHsVcdjqgf
+ snMMX4xaEPE1lUV2LFqk25SSol0yaJDqVrHPVFLG+87E/IfBgDtKS1X/ymVDMSN5KZCXBKuqoi4VFprP
+ 8cJTZqZx15Il+jw6gKwaMkR9T18+n8oZHqBGPSTAoPx8zd9ys8/1SG1t9GWr1XQxL8/0cVaWsWr5cn0B
+ bXFrExMjkuk9UUoHD0W/bl0NaPLzdX9ygK++SqAKccwVu938c0GBscViMdTRObR41qzIDSSmZnHYUAwe
+ incEfKWcO1f7xiOP6F6+7z7NoshI3BJsXIbCMKXv+A8bjZ++/ZSOlAAAAABJRU5ErkJggg==
+</value>
+ </data>
+ <data name="mbox_question.png" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAABcQwAA
+ XEMBOS4mtwAAA1pJREFUaEPtl11oUmEYx/2aigx30ag2XXURYQwTkiBDMaSrugi61CBidhVaKUF4M6Iy
+ ugga9kHBRqMkKiq6ihYYMYqtj6tiUBch0UAq4oSY0Nbs/4xz4PBybJ4v5wGFP8ej7/ue/+99nvO872tu
+ NBomQ38IwMgytPnl7DHy7HcBOiF63RQSRwHlOAaN9fb2vnW5XN+dTudvfK95vd5v4XD4/ejo6KNqtZpD
+ n4PQdsiqNoqaRACmh6E3EC0q/5Xb7ebS6fRYxwDAcADiVjIu/t9sNjcSicQsIE5DATVRUBUBmLJAH+SY
+ F7fN5XLPYJ6isVcphFqA/UrNUz+8H3WO467wEDuVQKgFuMEC2O32xWQy+XJmZuZmpVK5Vi6XrxeLxfs+
+ n++rFGyhUHjMA5zHtUcuhFqAV6ypeDz+mjd0Edc9UD/kHBkZGUTbRbZ9KpV6wbenVBpuN8BH1tDU1NRt
+ 3tA+psT2oO0ftn0mk3kuAoi2G2BWbGhoaOiHyMwgA3BAKoUmJiYeiPqE2w0QHRgYqGDRqvn9/i+lUumW
+ FACM26E5FqCvr69Wr9cLqwbAz1YWVxLlsKBTzOxfZc1bLJalfD7/hOm3pa0R4B+2GVcSmaZKchRaLxiB
+ 8ROseZvNtoBtxVPG/Fncy95aqKpCK80WjFPe/xUDYH/E3cOHMX8J97Q3ku1HdodWHwLTG6FfYvMOh+Pn
+ 9PT0JGOeyu2OVsdl2+kJcJdNHabi0PtyDtqk1Dz10wUAxtdAC2IA2jZI5PxaNeb1BIiysx8MBj+rrThS
+ sHpFYBsLkM1mS4YBWA6tyXSHIGjvHwqFPtVqtcsiACq3mkyeJoM0M4NqGaQdKTPz9PIeMQQATNJ+SLxC
+ C99l73maAesaAf6hhxiIw7iXveK2FQC53w8dE4SD/EmPx7MLJpxapY4wjuYRgGk6J7+T2DrTqhwwAoBD
+ at/P/3a8C8CUXz1SqGkEIpEIHV6i0AatIqEHgBXpMs+mkdVqXRofH3/IV6QLuHq0gNAcgF+Ft+LQMhmL
+ xeYESZy+dncsAG/M1mQRExazLsBytLUIY5MxLPj9TJMo0BFS9gFe6jl6AtDY66CEhBSdf1cDQO8J0jWF
+ dDev9zvQBWilwLRllloxorRNF0DpzGnVz/AR+AcOBL1o7Kmu0QAAAABJRU5ErkJggg==
+</value>
+ </data>
+ <data name="Yes">
+ <value>Ja</value>
+ </data>
+ <data name="Bri">
+ <value>Hell</value>
+ </data>
+ <data name="Cancel">
+ <value>Abbrechen</value>
+ </data>
+ <data name="window" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAfNJREFUaEPtmk8o
+ REEcxxe7J/9WbvawVxcpBzkhpUi5OLg67EWSFAclxcnJHrW5UFw4iDO2uMiKZ6WltSVa689jd7Nr/6j3
+ NbslntFr9Gqnec3W57avme98f7/vTO9NGQCb0L+CAJEhi49WgiYo4wUBneXlRQGklsTBbi/OeVpcAQ4p
+ gG+52aUDnBu+4mcTO+uQb2oBRKLGiQ+SQqPFFOrqhXpPdjOR6BvAC5l7jxTAyzVrO3AcPMHG4gJFKHrH
+ 1CcrCjCyThPOsvXZEeZwiCkdCpZ0Yxs6cLC/C9/kMEXw+opJgGeNbHJDNEqCTcA26rEJu44ddEkBkA7I
+ EvruIdnERhsY9xS6Sb2hkPm/uc1lmWJ0KwzM79FEcmwxeoZlnMKn4wLb7DHK63jwn3GtfZT4z0rw+q90
+ gNfKf41rcQfSaTzEYhT3uRxTjJbCHUMHEl7vny99VL+fScDE7AJc7laK8yeV6fnGlya4VLeO/uQg+z5g
+ VoBnbIa8Z22gUGKPTAKqn2phe7TpaHvtkALAWkLSAVlCJlOIewm9rq4i39xM8RwIMKUIdwFmN6LIewah
+ eJIiqmlMC3CpJRDS4jrC2ht7jJoVUIrnLX4WEuBVu3SgFHVuNIalHGh3OJCprEJKJMics+QTU7fQFz2K
+ N21EvqlSmPsn8UKYLq/+Q1MAAAAASUVORK5CYII=
+</value>
+ </data>
+ <data name="folder_star" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAACKZJREFUaEPVmg1M
+ lPcdx//3fs9z99yBEJt1WzqTrc2SZmk6a+K2LpvGtGE1jd1qRnWmXRpaK77WicU5GOCqgnIg4AsHihYq
+ xyFUsWoEkbM4DirH+/sd9waKAqIyqw3+f/s9d0B5u+OgGK4kv+S457k/38/v/3v7P4cAAMgP+ocH+CHb
+ vIqvWK3+HZrYmwPxuszb9XkFMIaqMyvXqT//+u8q4VQiq95VLTKuVRv9FuBGmKrUtIGjNVu4zNqPOcFY
+ oTVbuT+ZNnJ91R+qHvktQO02zlq/U0kbditpY7QihRfaFKMQNv1bEdf4L+WT+kglrfsHN+iXAHURSgmK
+ HGreo6Ct+xW07SBL2zRscruGvdyWyNLWBJa2fKqgCDPglwDo6Z/zwtuTWGo+zFBLOkM7M4dNy1DzUYZ2
+ pCDUAbZ3XgGwivwULaTqPdUKUzj3BwyZ36L4JejhDzpSUXAGQ22fyan9tJw68mTUqZdRhw5/z5FT6wk5
+ D9Iz5wDY+KRoCl/6B4pXGNeoG258qKK12zmMdSVtjWdpRxrjEujIldOuQhm9+aWU3rrktpsXpLT7nBuG
+ h7McY+5jeNViuBXWf6I8iMm9CR2yEtdWT1lGUZyYZcnzS5eSNaGhZOeWLUQTHU1yEhJIyeHDpCE7m/To
+ dKR/82ZyDe8dVz2mLIfvqX5p2sTd55OyGeO6/RDrChdePC+0p1hK71yT0DvXJbT3upj2lkvo7VI3iPMM
+ QpzCnTjCuPKCdwBWLIoV7DMsw2IXwEsvkRe3bSOavXvJ+eRkUnn8OLEbDOSxzUagq8uzNTcT+tpr5C++
+ 7ARWnNDGKCVticfYPiJHz6KHv5DCrWIJ3Lkuhv5qEQzUozUI4W6tmPZXiumdMolrZ/jQ4oHbk1nKJz2G
+ obZ6A+fqHYRhyMKsLNLrTai3a1FRJGcsAL97zz5LfrFiBQl9/32yIzKSaPbvJ7kpKaSsNEE60JbEgCVT
+ Do48Kdy8iOK/QvE1IrjfJoRBmwAG7QJ4YBbRe40i2meU0J4SKe36YngXMOxa9ilSGv6pHN11EhJC3p3O
+ 094AjEZyf98+cjotjZzHnTPl5pJbFRXkid0+eeec+J75lBysWTJwFri932sUw71mIfzPIYBHfQQe3yXw
+ 8KaQPugQ0bsm3AWDhHYXyaj9c1dCx0/cbbJmDYmYrfdn+jmbSQgdRxiwnpRBVyECXJFAX5UI7rUK4WG3
+ AL4dJDD0LYFHvQI62CmkAxhKfG7wYYRV6gkm8/JJAKtWkc0zFTKb+61GETTvY6HjEAJMuwMCTzvQgxXs
+ x+NCdvlyEjYbQTP5jOWaCOoiFdAUy0K7hoHO4RzonioHMJQemIWYzCLaWyGht4ql4CyU4a7JoSNVDpgD
+ XzXsUkpGIMjLL5O3LBbv1WYmYife21EshhvrOajdpoTGKAW0JjBgPioHezbmwbgqJMYqhNYggrs1YujD
+ 3LhdJoHuL6WY8DKEZqAtiYXhKpQ4CrBwIfl1dfXTA2i+IoKyoxK4+KkMru5loPIACw0pfCViwJ4rh65z
+ MkxmKdw2YEX677CVS6CnVArdF9D7Z2SAfQCwDwBfgvlSPNwHVo+cJn9SXEwefh8vO50EsBrB6dMCyMoS
+ o0nhJG75iRMs6HQcVFUtAKczGHvKd2a9ogLsxIDNDBNaBt3nsaxechsvnAfDTgy2IhYcTYHQVhkIcX+T
+ R2An/j124mXYiZeOALBY+np8AWhqIlBUJEBhIhQpQZPhawbFKqCkJAAslqBxIscKnvi686IaYxrzIYMB
+ HBcAq4wrVHjROAsBzkIuQOslzrVmQYG6H3tM4KQqxL+Rnk7MUwHk5YlQoBSN96YCF1FBXd0Cn0V6AzCf
+ VQNOo4DTKOA0ChZ0hL1cDZ0nEUrL5wkDOI2CtUTt+nupqarqqTq+a5RITSU1UwMo5kTsVCBtOjXgeYBP
+ SmjXKsHR6naMvQ7D5RCLyc4CngfAWh7oej8uTnnGI4BGQ65NBGhpIXARt9mbF7/PtZasAKxMHLSdUoPT
+ Pj70bF8HQmOMEnD4A5vJDbZxI3PAIwDOKhcmApw7J4TOTt9jeqYwzRmB0H7e7d2prLN8AZi2cOAwB7kK
+ QEiIbINHgNhYopsIkJ8veWre5wU7bdM7x2Jwe7+8PHDomWfIix4Bdu0iGRMB9FgNZurVp3W/VqvqxAo0
+ 5aMXVxLzZ4HJAKzfAMTHK0s9nTlcAGFhJHYsgMNBID/fXX/9wSIj2eNeAfDYuGMsgMEggOrquan3c+GA
+ devkUV4B8Fi4fixAfr7ILzzPw7e0BMGSJdJVXgFeeYX8deypLA+Pe3PhublYIz8/YAATOMArwHPPkd/U
+ 1X03ker1OGD5SfwnJ3O13h4auJIYf35WVkYej4SRXv/0RoiZOiYmRlnoC4AqP9/9ZKKxkcDlywF+swPh
+ 4QrNtAD8DVotsfIAZ88KwWr1j/LpcATDypWyTT4B4GOReh4gL0/sN943GAKfLFok/ZVPAElJ5DoPoNP5
+ zwiRmqrs8zRCjJ6JR17gc89LPIBe7z8jRGwsa/HmfVcBGrlhzx6i55+mFRT4zwixc6f8rM8Au3eTE1ev
+ CqCmZn5GCJstGAyGgG+ys1Xm9HTu6sGD3Km33/bcgSeF0Pbt5BB/Bp5pnZ7J/XxVMRoXDOXkqJzHjnEV
+ Go1SHxWlSAwLYz5etky6Ch/p/2g6j0+8PhpC69eT/+j1czNCmPAYqNer+rVarjYxkSuKjlYe/ugj+a7X
+ X5euDQ4mz2NiimYq1OsowV9cu5Z8otMxPu9AY2MQ9gz1NxkZnCUpSVkSE6M4Hh7Oxr35puyDF16QLEaR
+ Xr+gnnOAN94g4Xl540eI9vYg/mA/lJmpuJ2WpjBhVdBt3apIWL2a2bp4sWwFilTPlZDZrjMaQvgtzR8j
+ IpjOhATWsGMHk/7OO/LIV1+V/nk2cTlbMbP53Lz+q8FsBHtM4rlYbD7W+D9MzRR6eEGuxwAAAABJRU5E
+ rkJggg==
+</value>
+ </data>
+ <data name="errorProvider.ico" type="System.Drawing.Icon, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ AAABAAEAEBAAAAAAAABoAwAAFgAAACgAAAAQAAAAIAAAAAEAGAAAAAAAQAMAAAAAAAAAAAAAAAAAAAAA
+ AAD////////////////////8/v7F/fuc/PiW+/ix/Prt/v3/////////////////////////////////
+ //+a/Pgl+PEP+PAP+PAP+PAP+PAT+PBn+vXp/v3////////////////////6/v5a+vQP+PAP+PAP+PAP
+ +PAP+PAP+PAP+PAP+PAl+PHU/fz///////////////9v+vYP+PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP
+ +PAP+PAo+PHt/v3////////M/fsP+PAP+PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP+PAP+PAP+PBx+vb/
+ //////9p+vUP+PAP+PAP+PAP+PAP+PAP+PAP+PAP+PAP+PAP+PAP+PAP+PAZ+PD2/v7///8t+PEP+PAP
+ +PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP+PAP+PAP+PAP+PDD/fv///8V+PAP+PAP+PAP+PAP+PAP+PAA
+ AAAAAAAP+PAP+PAP+PAP+PAP+PAP+PCs/Pn///8f+PEP+PAP+PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP
+ +PAP+PAP+PAP+PC1/Pr///9K+fMP+PAP+PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP+PAP+PAP+PAP+PDg
+ /v3///+c/PgP+PAP+PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP+PAP+PAP+PBB+fP////////4/v4v+PIP
+ +PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP+PAP+PAP+PC+/fr////////////Q/fwc+PAP+PAP+PAP+PAP
+ +PAP+PAP+PAP+PAP+PAP+PCC+/f////////////////////T/fw1+fIP+PAP+PAP+PAP+PAP+PAP+PAX
+ +PCW+/j////////////////////////////7/v6p/Plc+vQy+fIt+PFI+fOH+/fm/v3/////////////
+ //////////////////////////////////////////////////////////////////8AAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+</value>
+ </data>
+</root> \ No newline at end of file
diff --git a/mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.en.resources.prebuilt b/mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.en.resources.prebuilt
new file mode 100644
index 00000000000..1419b4dc48d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.en.resources.prebuilt
Binary files differ
diff --git a/mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.en.resx b/mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.en.resx
new file mode 100644
index 00000000000..6f6e7e4c1f3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.en.resx
@@ -0,0 +1,831 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 1.3
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">1.3</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1">this is my long string</data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ [base64 mime encoded serialized .NET Framework object]
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ [base64 mime encoded string representing a byte array form of the .NET Framework object]
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used forserialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>1.3</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="last_open" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAADftJREFUaEPVmntY
+ 1FUax0efbbtaarr12D5bu6WbopZ5SVs1a3fV2rQsUcu8FJqlKCZkF9t1H7VUFBQVCXVFzTIIROU+DJoK
+ iCggKgjC3JgZ5sZlbiAzot993zMMgjLjpT/W5Xk+npnf5Zz3e8573vOeM3YaGG0ddv89nX7fWSLpJKG/
+ zuJf91+nTq3XWq/SffdntHtOfGm91/bdlnrb1t2J/q4CpvT3usiu1XKHn+YkNRwuNV2GN0qMLvjivNEJ
+ X5wzONERX2VZry5IdWwCIPk1SIIyGjKuXr0Kb1y5cgU3o7m5Gd64fPkyOiK+xAGZvOkKiVj1fyuAheVr
+ m5oDUx1L71TE/3QEWICLKDU2XZmb5PjoTkTcVAC71q9xIXYtby7kEWBpdOKIvKF59kGH/+2KuGsElOjt
+ iCu2Xp6e6Bh3OyLuCgHWRop0JEBWVoetefUu/3j78FsVcXcIuORCqYEElNfh+1NGfHu4pum1H+39bkXE
+ XSUgq0VAaFYVlqaaGl+KsT15MxF3rYCQAwp8ctBo/9Nma09fIv5nAgp1jQjKuCxYlOHCwnQXAltYQOWC
+ NDcTfrLuvSsFcAiVKZoFmfLLXnk3wb7zjgV44r+vVMFbnG8b+10uF3zhdDrREY2XmvDefvsOnwIWptmk
+ 3vIVz/U7NcBjVFNTE3xx6dIlNDY23oC9oRHT99u3+xaQapV664HbMcCbEWxYQ0ODTxwOBzrCYm/AjET7
+ Np8CApPrpdw4s7vYgJAs1TVkSoTcAsGZCtyMT9MrMG1DHEbODsbgie/Db9RYPP3cMPiNHIshE6Zj1Owl
+ eC98H/YUqGGz2QS1FjtmHrBH+xQw/1BNpsPRQD3gHbvdAV/YbHZqsGNyc09gypSpeLT7oxj8wmAsXvwp
+ wsPC8eOP+5CeniHK8PANWLIkGEOGDEX3bt0xebI/jh49BlOdDbNuKuBgTaYvA/ie1WrzicViRX19ewoK
+ ivDOO5Px5B+exLrQdSgpKYXRaLoppaUXhKCnnvojJkx8C6+vztzncwQ+OWDOtFhsYOKKqxF6XIV1zDEF
+ wo4rEZ5NcHlcgQ1UbqTvETkqQolNxOZcFSJPEFRupTKK+GD5BvTo+RhWrFyFqiqNMFqvNyA5OQVBixbj
+ r6/+Fc8/9zx69+6N5wY+h1fGvIp5H32M+PgE6HTV4nmtVofVq9egW/eernt/e6/XVFvy8X6jrLbWAqZS
+ V4PzVTU4pzbjLFGsMhFmFClNKFQaUaAw4jRxisiXG3CSyKs0ILfCgJyLBhy9oMXUmXPRt28/nDyZ39rb
+ UVFR8OvXHwEfBiAxMREqlUpEnK+//lpEJ7VajaSkJMz/ZD4G9B+AVatWCcEs5PTpAvR+prf9kYcf2UXb
+ 8d9cPxqSefH6LLO5Hr4wmergC4OhBsycOXMxbux4KJUq0fiZM8UYP+41zJo5i9433bAW8ES9PkTztc9C
+ luKlES8hOztH1KNWV2Hs2HENJOL7GwR89LM+y2isowfroNbVQqGtcaMxQ0WlmkZFrTNDrTWjikptdQ10
+ AjOqqdTra6g0Y+WKbzBo0AvUu2rRaHh4uHCTtLQ0n4tYR2vMkSNHkJCQgBHDR4hRqq7WC1ccOGCg/YH7
+ H1jWVoRkbmx1FhvCbCP//jylDEuJz5LLEJx0AcHJF7DkUCmW0OdPqVx86AKCDpZiEbHwQCkCiSnr4/G7
+ x5/A+XPnhfHr1q2HP0WS+vr62zbeYrHgiSeeQGlpqQjtn1LUWrp0qaiXJ3iPR3vYyZVGeERI5v6kO6yl
+ 3vWFRmOCL14cNgJRUd+JRjhsDnp+EAUFy20bz6MREBCAwMDA1nd5joweNRqpqWmi/pidMXi4y8PnSUQn
+ FiGZs093WK1mP/OOSmUk1+iY6O9iyOAXaA4YRQQZNnQY8vLy7sj42NhY9O/fXyxibV3r4sWLwh0VCqUQ
+ QZHLSgLeFQICftAeVlKEYWRnNEg6VYVk5nQVUgsILok0+pxOZBDSwipkFmqQWaTBsBGjsWf3HlFxMC1G
+ Kyl03ix34vtOpwd3IieXy9GrVy8UFRWJe9fXsWPHDsx4f4ZoJzY2Dt26disSAj78XnNELjdSBUbspTi/
+ RVaJzbIKbCIiiI2ZFQiXXkRYRjnCqFyfXo7QtHKsTS3Hv2Lz0KVLVzHBuHe4l3jIfWeeLnrGiaZLTvJx
+ Ll2UJ7ndZEP4xpZrdJ2euV7Iy6NfRn7+KTHSDz34UCONQk/JB3s0Ry5SDPdFebkeHbF69Ua89eYk0Svb
+ tm3HV19+5dV4NoaNYqMvkdGNtJFvaCAcLiz/1wqMH/+6+MzX+B4/wyKdbYRERkZixYoVor23J73d0LlT
+ 5zmS2bs0v5SVGeCLCxf06Ig5AQsofK4UFU6bOs2r77caT+c/wnAy1G5zwmZxIkuWTVHn96is0MJa777G
+ 9/gZIYTeYeE8qlqtFjwK3N7ataHo+kjXbZJZMZpfSksNFKIM+OGoEttlcuyQKbAzy02MQI5dVO6mUnBY
+ jj3EqL9NxE6KClzh8BeHdxg2Pca7XcVtuJWMLDmvwI7teymdeBY/x6agxuRCrdmFuloXLPUuIcRhJ8H0
+ DovwuFN/v/6iPZ53PXv0lEpm7tQcPXdOD+bHI0r8J5MEENuJbVI5ojPk+C69kpBja1olIoktqRXYQuWz
+ A4aKjJIrpEWmQ/cRbsM932K8hXq5WmfDM0/3xqwZs/GP197CsV/O4vTJSpSc1UEpp1Xf0IR6EsIjwoL5
+ XY8Azp24Pak0kzPcEsmMHVVHi4v18MWZM3pKC25k8ODhrQIoX0FISIjIcTyTWPQ++zy5AvcmG1RX40JB
+ fjlG/WW0iDh+/QYiInw31nwTheX/DMMXS1ciaOEXFO9j3SLESNC5ES1iXD/nSpwnZWRIeVE7L5mxXXOs
+ qMhAlXmnsFAPpqCgug16vDZ+EnbF7BI9MmTwELHrahuBeAJy77M/26xO1Ne5YKbfG/QaJ+bPC4Zf34GI
+ 2Z6M8nNOQUWpE8oK8nWlCwatEzX0rIXesdO7TU3u0Opxod27dqMHu9D70Zpjp08bKOsz4D/pKmxJkiMy
+ WYGodpAb0ffoZHKrFAW2p7p53X8evv12tRAw4Y0JYvlv1/tCAPe+2x3Yx43VTuhULigvuoTRJYUunD1J
+ 5NPxYoETF887oWIRaidMeveI8SjwaPLqzh3F7a1ZsxaU3G2TTP9Oeyw/30Dx1YCYNMrpk5SIJLYwhyjf
+ P6hAxAE5ocDGRDk2EOGJlYQc7y5ahzcmvCUq5Nw9LCysQwF2ch9LHfUoTVQ99WyVwoVK6m02uDDXhbwj
+ Tpz8xYkzeeQqZ2hRK3NBw6Ogc4vmCc0dExcXJ3Ijbm/SpLcdtA58IHlvq/Z4Xp6RQqB3TpwwgMnNbU96
+ ehn1QleR7p49ew5jXh7TsQCaiK0CyH2q5C5UlLh7/3S2C9lSJ3JlbjGlhSTggrOdgAaHW8BU2ppy0ODN
+ zoMPPMgLWQ/Ju5Ha4zk5RvgiO9tAuXnHDH9xjEiwuFfenPim2LB4UgV3BHJPYI4+3Jvs29y78jKn6G12
+ nwISUZBDbnTKhbKzTijKXcLN2N34Pa4vOzsbI/8yUrTD++hu3boXilRi2hZd9vHjJjBrYpVYG6tCKJXr
+ 4mhbSaz/maAyLI62lfQ5PF6FDS1EUBnwWTT6USThZI4jBe+8eMHhRt0rr3vhYjdgf2a/1pF/qytpFMiN
+ yordrlRCPc/Gc+/zCFVXkWByOfZ9Tss5TeE0ggX49fOztSZz0zZXZx89aqZTADMiE6oQuV+DzVRuiid+
+ dpcbqQyPVSOshfVUrv9JjdCfSCyVffxeRETEptbeGT9ufMsouFOHa2sALVZklJF8myepmgxV0GTm0WB4
+ YvP8YIFGEtpIEUyk2LQV9dQfHb3tapeHulxLp6dG6HMOHzbDTU2HZGWZ4YuoKBkef6yX2EJyD334QQBC
+ Q0NF710/ChwWeTKze1TTfNCpKeKQu7DLsOEcYuvI1Xjk2HhOsSdOmCjq5Q0TLV7tNzRTNhpyZLJa+CIz
+ swa+kErNCApaR0M7QGSlvK2cTEcqDGeOIoHjHIjCKbsSpwrsThznTfQ7sonEsGvxd54vbDi7TeCCQIz9
+ +1jK08pFnXRYYL/vvvuD220p/cONOVJpHS3N7cnIqKPVzk16eq1P0tJqae9bC3//QIpEr1JqrhA9tnfv
+ D2Ll5MXOSQsRC2mbD/EEFSutjefJtXyHTyjY5z1uw4cEY8a84qCd2A3npJLJYabctLR6MsA7qan1tKXz
+ TkpKHZikpBpM8Q/C00/3oaiWK0RUVsoxc8ZMcRa0Z8+e1tMJdi+ZTNYadmtra4W7vPP2O3jjH2+IsMzv
+ 5+WdxFNPPmUn46No4na+4VRi8vqa3JQUKxngneRkCx1KeScpqZ6Mt7Ty+ecxlCk+jmXL/tl6SnHs2HH6
+ vkycNLxApxejRo5C32f7ivSY99BD6VgxJDhEJGmeo5Tly/+Nrt0edd7zm3tmeDudk0z9wbpsXrwt8eN4
+ 2wHi4CdMgu0QMz/BlsQsSLAlB+63pbSQunC/LXVhoi2NyvRFTKItPchNxuJEm3TxAZv0/Y0nsvsMHWvq
+ 0fPx5pUrv7laXHxWGOZBoVCIw6+Kisp218/RRF397Rr87rFeV/487O9107+MmOnzaPFmP6L92vs07ANp
+ 47GPVk4LZazWBQsCmzmP4cXv4MFDYn7w98DAhc19+vzZQuc+Vno+lt4bdCtt/6r/KXIrDXie4WMQYght
+ A0Mojm+lcJhC5NNpdCp9j6Lrn9H9YZ7jklut+7/JKVwBwotNkwAAAABJRU5ErkJggg==
+</value>
+ </data>
+ <data name="Red">
+ <value>Red</value>
+ </data>
+ <data name="folder_with_paper" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALEwAA
+ CxMBAJqcGAAAD0tJREFUaEPFmQlUVFeaxx/IUguKRo12MkmnuxM98cwkJmPapMdsRpOMY5bOMn1cMsak
+ R4OmoygtoJSC7IqyFzsoigIqKEsha0GxF1XUvldRFEUJKGuxC9Q330NRcAFcMqlz/tz77rvvvf/vu+t7
+ WBG/wu8/N26k4m3fHhgYeHkQ/3R3d6vUSqUSywZQll/hkU/vlv9w3kdlHPVezoxP2Oty0DN0j6v3cXdv
+ 5h6v46f/6h92/hM3r7B1+9x93nFjeP7p6T31Kd1pv5u7raev3wpmXPwhoVLVfIlVdvNMZhWcyuRbQhIK
+ bgZEZpo9/KKvM3xOcv1PhHh5+vrORVk/pcc/+W0Q4K3UjMwglaHJ1Dk4NNLc2WPJ4aggIEkKgam9lqPx
+ 6rGUXPEoX6kfUjUZFYHBwQzUs0/+5KdwBzcG44M8NjsSjWk6BgZHe8csYB4dA1VzJ5wv0MAvx4VwmqWB
+ InUraMwD0D4wOCDV6eSJKSm/eAcG/uEpWHi8W7gxjtA9vLw/YBWXxqsajbqO/qGx3lGACXUOjoBY3wGJ
+ uUpIl5sg63oPcPuH4drwKHQMDI/WiiRV6Veydx4+6vv7x3Pw+FdZMY74zA9jxr2fkp55Xtfc1tbZP2Ix
+ DwNMVjcetwyOgbjvJpxp74OEG2bI6OwHXu8wtA9ZoLVnYLSaLy48nZK+3fXgkUWPb+cRrlyyZCmx5bvt
+ 9n6BJ9cnp1zMacUwd/VboHsApqgLj1uwvBYpIlt7IPl6H5y+3gtxbWZIwbzSPAo38Hzzjd6RGr6s2NM7
+ 4Nt9LgdtUFaPYOfRqyKAfcDx0E2sgnKWsaXX3NFjsXSaATp7p8rYMwbF7UOQ1NoLZ1Hx18zjSmwxw6lW
+ TFHKrhFo6x61NDZ3d1VzZUVo/hOU46O7msUVb7+9Zg7KISw88Uc2R8DSNnS0t3cBdJDqvqsbeKzvGANW
+ 6wCcudYLSaZeSEDFN99OTWaIQ53Gc+ev9YGo/Sa03BgZ0zV23Shm87Ijmac+ddrl/MwsLM2+yrp1G2wP
+ HvR9MSrq7LaiYj5bo+3sutEOcK9a2i2guj4KLNMgJDaZIRaVaETz9yjBaIYkLIvB85dN/SBqG4GWtpEx
+ taa972p+bWJsXOrH27btfHot8e033z3j7x/x+eXMUpFe3zfQ1gZA6vokmdosIGtB88ZBCNX3QGIj9ncU
+ sxG7jAEHcBMaNmArYD4JFYnlZ5v6IBrTi8Z+ULWOjt9PIr7WyWJVM48FRq/55uutFNTsI/2wmruc/rk8
+ MiKFIRG3DRubRiwt13CAolonSdI8Chca+8FP1wXp+j4Ib+iB6AbsKo1oVo/9H9NkVKweobA8HeuebOiG
+ U3icSJ5HTdxPwG++fjmDE4PmX0HNfrX+5BNiqZMT8QGDQfzv8ePEfiaT8E5KIiLOnLG9dO7cH4QX0reP
+ iOqlFkPDMJiMANdui9c4Aucb+oGpw2jr+iBI0wNxWow4HkfoeiAey2IbeiFKh90JlYD5EG03JDcgHNaJ
+ QqVgPhHPKZrGoKnh5oiAZ9KmnStkbvvO6aVPP/7Cbtpm2LaNsEGtuHKF8CgvJ7K5XIJbV0eIeDxCzecT
+ xvp6op3Pt+2rrfndWGnJARDV88GgG4UGvQXKdMNwVtsHcRo0qDFDuNoM0epeiMSUicfRWM5ERWM+BtNx
+ IVw8ppHj52+JzCdq+uCKbhBE+lHQqQaH6qqNmqT4bD9fb+aK/3hn7cMhXFwIKmpzZSVRo9MRoyYTAQ9T
+ Tc3LUMnxBBFPChLNKISpelAYRRUCKDGyyh6IwTRCiQBYHo3lEXhM5mPIOigyH4dpONaNwjx5HIb141UY
+ CBRLMwRi7RjoFMPDZUXqhuTEq64+R5ivvvynV+c8sCUCAwkHlLtIRCinMz9xrqryVSgp8IIqQTN4yzsh
+ TtEHEYpeCJbj7IL5QFk3xOBxFCpUgbMRppGYhiMIWRaNOibvHq8bosAA4LlEzAfgdXFyHOSKfriqHAaD
+ CsaVny2WJ0RlO//ixHj+gQBBQYQDioEA6tkANDVZQ13tCsi8cBSUkiE4I+uHBBlGD+WLJpKlfXBSisZk
+ GGk0dFLWAxEy7Dp4PhzTECkObrzGH+vGShEKy/wwf07aD0EkPB4Xy4dBL8c1BaWTjY3lZYqE/l4x+xHg
+ /lYICCDoKFcEUMwGgKyj01GBx30NcjPDoKLWCGniAQgXo2FJHxwX90Ak5iMkZghFg0wsC8d8CIpMmeLe
+ 8ToxYoS7XR4jQQhxNyRg3WLJTRALb4KophtKcmWQlV4yFnwsUPb37WujN2yw+2bVKhs6gtzdcnh5EXTU
+ XgSQzhaguRkhtFSoKFsFZQVxkF+hg1TBAIQK0bQAzQp6IITMC7EbiTDqIiybEFle3wP+FQbwKhTD0bwa
+ 8L9aDgFXi+BsfiHk518FTkEWcApToTSfOZqdccCYmrKxICT495G7d1NdNm+2nzsF4MABgobaIRQSotkC
+ kPVIiIYGKygrXg+c/NNQWN4Msbw+YPIxwrUdEFBhggC2DnzZcvAvlUBQqRCOlfLgWFkNRJVWgm/BZQjK
+ TYbg7CgIzwmGizlBcDXXD4pyD0Nx3gFLWeHu4drKLSZuzepCheLF2MrKBf5eXnRnFNkCd3+7dhFU1FYE
+ 4M8WwGgkoLGRBCBALLaFwrz/grxL53GGaoPAKgOcLFGAT1YpuKWmgVdKPHifDwOf1AA4lnYYQtP/CSGZ
+ P8MFzl7IER8AjuoQSJWHQa88Mq4GBQOUov0j/JqtbTVV/5qj1T4XYTItOlZRseCoiwvtRxT54eDub+tW
+ goL6CgFqZwPQ1ESATEZAaSkBOTkEZGVZQ1rqXEiKXwlxkT/B6WQGxFx2hXNl7sASMiBX4gEsySHIxzRP
+ ehBYUjcolbpDjtwVKuUHQSY/DDo5Gr8tuWAv1Fb+tZNd8kqVXr80tLl58XESoLx8AeOHHyj/jaJMAfjs
+ M8Ie9TEuWJVkt5gMoVAQUFNjBWy2NWrOuEpLbaCqyhYEAjsEsUdRQCKhAp+3CMpLXwdO8fdQXrUP2EI3
+ KJS7Q7HiIJSgilAT+XyFO1TLMfIyBmhkR3CmuSUpfzeI69fjvV5pq65aVGA0LgoizZPicBa44iD+FGU/
+ BWDNGsIW9RauwCV6/VQALtdq3DCXa39HdXUU7DZU7D40hL0rY5MDaLWLQCxYDZL67cAXu0IFmiRNTxYb
+ o16F5TLZYdBI0ThKI0YY3i40vxaU8pdALndsraubdwdAq10YlJ8/3/nNN23eQNlOAVi2jJiDegm3Ebkq
+ FWGZ3ALl5dZQWWk3xehk0/fmjUY6qFXPgETwHpr5O9RjVylTkBDuwEaQUhQZeTWa194x7w6y+p0gqPsQ
+ lIrnwGCYi4Gg3+Dx5rGxBU6Q0edynzmZmjpv1+LFVktQ923wyDnVsaCAuCAWEyNTAeZgd7GfNcAEkFKx
+ GFvhfYTYDQKZB3ButwJX7nEn6mTktTgupPwdUM99FzRqRyADQN4DAToQoGICgMWaHxQc7LBtyvR5z7Js
+ k5VFJOEmrn8qANnfKY8MYDQ6gAqjKeS9B1LBfuDJDoEE+7v6dtRJ86RE3O9BxP8zGl6I0/It87cBuuvr
+ 53InALKzHX18fenfTLcrtbp0iYiqqSG6JuZ4jYYYH6w83qMDkCYMhnkI8SJG9yOQCJ1BLWGMm74VeQYI
+ a7eAVPjvoNU8eyfykwDMCCAwGheOd6HLlx0PubnRNky7rU5LI4Krq4m2CYDaWgLN24JKRX3kFpgwYmic
+ B3LpC7h73QhK4R40fhjUOPeLeVtxsK9E84vR/NTJ4HYL9AsEDjIEOEkCXLzouH/nTsr70wKkpBABVVWE
+ kQQgFyocEyAS2WHT3v+A6Qby/QPbAUTCF0HC/xLk9U4grd8C9bwVoNfPf+i9dTraoFDooCYBmpsXHcMB
+ 7PTFF3arpgVITiY88Z1ANwGQn2+NAI8+gB8GJxL8EaorXkPzy2YMCgLcRAA9CaDXLzyekjJv2+uv2yyb
+ FiAxkXBHgPEdKdkCTxuAHBONGHWDwXHGLolrzKhE4mBC82FFRfNDExLmfrZ0qTW5iXv4LyaGcMa1YHxD
+ dwvABlvg8Qbwo3SxB9VtbKRZlEr6Dbl8QWxa2rwT4eEOax/4LjAZJzyccOJwiDoSwGAgoLDQFlfc3waA
+ HNg6Hb2Lz5+fgtH3DQx0eGfa6JMnT5wgfigrIyrJzRquyMDh2OGS/vgz0JO2gsFA76mtdcxkMh08PDzo
+ b8wI4OdHbMEdJlurvbXTlErtccv8ZDPQk0AggBkBWCEhdOeff6aumBEAvwd9zWYT+WT08/KsQKOhzDhb
+ PInBma5FgF4ud16Rvz9t51df2f9xRoD9+4mNJSVEllJpBbm51uPvvTM95Nc8j63fX1bmUOHjQ/129Wqb
+ JTMC7NhBrCsqIi6qVCSAzW8OgGvBQGYmrS4wkLL2hResaTMC/O1vxJrCQuIcCcBi2f5WAGPYqjdRQ2o1
+ rTMujlIdFUWZeQCTdOvWEatw+5B0C8DutwDAdxG6GdVsMjnI1GoHTlQUNSksjLp8xuiTFVauJJZlZBDh
+ PJ41VFRQcK/yq8xAGF16D8qEJlUGg0O9WOxQVVhIL7l0iZ6Zmko/lZxMD4uLo/kGB9Ncdu+2/+qnn+xn
+ 9/+zpUuJJfHxhH9hofWYUkl94C5xFoMWo0h2AXoP7u/b9Hq6QSSiaaqqaGIOh1bJZtPyioroqVev0mNz
+ cuhBGRl0j3Pn6D/FxNC/PnGCvu7oUfq7rq60Pzs5Ud/YtIny6kcf2T734Ye203+dntQ8DiEhVocyMuaQ
+ fXC6GWi8n6LBPtyzdMvltHaJhGYSi2laNCsWCulV9fX0vLo6emp5OT36yhWaX2IizQUj+qOnJ+1bZ2fa
+ BvyysPbLL+3e+ctfbF5bvnzOv6CHqS/qs+oz91eyCQ21dk5Pt+lDgxbcRo8aDLQR7EpDqAGUGdWFplsa
+ Guga7KO8mhp68eXL1EunTlFjw8OpPp6e1J9x0dmyeTPli/Xr7T7CHeTKBQusFqIe/GX5MY0+9LKwMJt/
+ pKbadWMXGNJo6NcrKmgNWVlUQVoapeDUKUpyWBgFv45R9u7ZY/8/339v9/mmTbZvenjY/y4+nuqIAHMR
+ gIYAVASgIIAdAtiieWvU07b64Pvt22fzHoNh63v6NNUjIYGy48wZyufnz1PeTU6mvMVkUv7N25vy8q5d
+ 9i/gy8XS1attFz7/vDXt2Wet/3+ie4/l/wOchKPj6Tjd4QAAAABJRU5ErkJggg==
+</value>
+ </data>
+ <data name="monitor-computer" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAD31JREFUaEPVmQdY
+ VHe6xvFe9+59dJPsJttMTNas2WQfs4nuborGGzVmLdHYwIKiG0VAI6BIH5A6dJDelCkgRXrvvXcQaYJU
+ UXoRLAgMzHu/cxRkaJZr7j7L87xMOTPnvL//+/2/859zFgGQ+rf+YwD+nfWTm9/p2fTWWk7c5x+f4v+w
+ +ke+7V9VfGLWnA8t/VQrtv5TrbiWT7TiOz7WiO1b/flXx15mIF8KQFDQ958eOb3L9P2KvlKyDVdQtA11
+ UrwYmXDaJaVcyS2jTskts1nBNevOSdesHiWX1AHNS6n3nMKLxyILGlB9ewiDw+MQizGlkZFRrF+/Xuf/
+ DNBzX/Tft++OrsipaNzkF5PxozA81Z0fkZFyJb7omjC+pJYXV9J0Obb0tkdUcbdbWE6fV2TOvcjMClFx
+ zS103h3GqEgsYWzS5NiYCM3NLUhLS4e3tw94PP6UzM0t2O9s3LjR5KUACgoKLlbV3Gi6VlnbVlRe1ZWe
+ W9SbllM4VFJRI2pu68TDR2OYmJjb2KRBZntHRyfy8vLh7x8APl/AijHq5cWHUOiD1NR0FkIkkhx9Hk/A
+ Amzbts3ypQDS09O9Ozq7MD6BBdXXfxclpeUICQkDjzHHGnxsVCAQIi4uAbW1NzA8/GjOFKaXzPTnzPeJ
+ H7t377Z7KYDExESlkrKKMRpoVNc2ICIqjsx5w4svpEcSTwg+GQwLi0B5eQUGB4deyOB8xiffZwZiRATI
+ 7D/o8lIA1dXVq5NS0gfvjQBGxlx0dnW/UoPPArjsJQBz7O+OHLvxmzV/k6Nz0pIXAZFqbGxcmpSS1tP/
+ EHD14OERjQYzIqPjwBhJ9KS0mJifZeZltntRGTLHPukpEKs0d4p3efBavlbXjl2143vz1377u0+eBcO2
+ 0dj4xDud9wB7Vx6GHoEdkfukB6PAQ9IwlRejnwLOi0q0i4592kMg5g5DbENTyInkPjwu1s/Mvy9rZlm6
+ 5aSS4MPPPj9O6bw2E4gFCA4Nb2i7C9g689D7AKz6aFSYkRkYBqhDYpDA5oNj5g+bGolJ7UWS8/bxQ3Pv
+ GFQJwJ6Mu5F4IxD7koJHIY4iJY5BHN3dLzb09m2T5+jH/2PvPsvfv7P8M3YZxPzzueJX1dQH2Ln5oJV2
+ 1j4EdJCYVJjR6b4P9JBYMBILRmLAXhSOuijb7SZITMkFh4SjomUQ590F4ktk2pt0lUyHk+LIeCopRwRx
+ CamSOnCdaEJsLfAZfvvbPb3/9dcNoSyAg5NzakXrfVyJyEBmWRNa+oHWAeAWiUnmNunOINDOaCG450iN
+ LctpJRkVm4jsqg6cd/SEP5kOJcWQksl4FqmQjF8jCVLSRWsOnej6hZx6h5RDygOpbDGkpJUDWABTrplN
+ bNZ1JBa3QBiahvoe4GbvYzVQMo2kJoJqJrUQFAtHUCwcQbFwc4CxyT2jJBNSsxFf2IRT5/RH9x0+cWeX
+ vFIPr7xyPI9Mh1bfEK//56neX8qe7ZAyCRqUyhiDVA4ZnpS0ylUWwMjIaO8l34jholYRuI4+qOwEqkjV
+ XUANqbYbuEGqI7BJuAaCY8FIDNiLwk2WZEp2KYJTq2Bq40UnwiHk5DSAo2fTu2H73p5FWp79Ukn3JU1P
+ B5BRDWQBeDzeO9aOngOFtwADWz5KbwNld4By0rV2oIJ0vQOoJLFgLwg3V0lOJpdZXAthdBGMbXgswKTO
+ apr1SIw2Y5zK5meuWfilggmkMkSQ2n82iAVwdnZexLWy785pBjhWfOS3AgUkBqiIURtQTCohsOeBY1Mj
+ sak9I7ncila4BWXCcAGA/whsxFu6Xlil54UDYfVYa34VUqmPGIDgqeW0nqHZrfRGQMuSjwx6zGwCskjZ
+ BMWA5bYAeaSZcCwYaRKMTY4SY5OjxNjkFijJfKpPa3489KzmTuC36i7Y4p4KxZIJHM8ahEzAtacAB849
+ BVDT1K1PqgfULQRgHpNvAimk1AYgjcTAzQRj4QiKhaPEWDhKjE3uOVJj4Aob78PIJRS6NHBzldAHF4Q4
+ FHETGwx42GTsjb/p8/A7NSdIZU1A6oBayFQCCqeVy6KqxqBh44eI66OIrQXibgDxpIQ6IJERgT0v3Fyp
+ zQVXfGsCWja+0LKYAaDBZefASiqbb1wS8D7nMpaahUAq5eHTSX1Q7fF5gNEB2aMhvKRGmPlkwy22AWFV
+ QDgpohqIJEXVANGkGAKbC44FI7GpPSO5mXDqlj7QsPBGTc3g00n8BODnNnFYFH5n7k508HzYFMD273Zo
+ GLpFit2TboPjmYKr14DACiCIFHwdCCGFVgJhJBaMxIK9BBxTkil1IriFFEDTSggDzyRo2wWirKxzFsCs
+ TkSpLAppfdyFDqmHPwXYvn2dgob5/SulE1A09oFPKXCF5FsG+JH8y4EAEgM2C46gWLgFUoupnoBTWDnO
+ 0Ugrc4VQNveFXXgdu19GGrYhyM9vmQJQfZLAFED8XbxuFICVVEqrFAwhFdnJAERMAUhLSy/d/88z/cIS
+ 4LiBEF5FAI9RMcAnCeh9Zps3QbFwBMXCPTFAzWEWmH1ELc6YXcEpEyGUTHxgGlABQbGY3Q+/aAKGgnyo
+ Gl2GtoknHFyuSpTQJMDP3fOwXOcS1loEQT73AZTomN/SnGABZDWfAjDzYIe0XOelQuAYzXzXPMAtH3An
+ eRQAniRm22XSJBwLRmLBSLZRzVDi+kPeQIATNAgcfiE888bZ7zCyiW2Hipk/1IwuwcDsMqKjiyU6z/Qu
+ pKph2suM/grywpjeH1zFdqKdHin4VO0i/Qbog9ThGQCbtu1pYYwf4Qhhnw04kBxpJ04k51zAhcSCkRgw
+ y+h2KJgG4Zi+AMf0BFBzzYRT5ii7nZEzrcY0XNNwxuAytIw94e4ZTj9Lu+Y1PR/AkdhWbKCy/ojK51cc
+ PhaFtT2e1Ee0oiSuC32xfnMNY/qQjhBW6YB1Bo0ayTbzsUxj+nDCLByyOgLI6gpwyi4JVkkPWNBJ6QU2
+ YI+KGz7ba4Jz2jZITq58LsPTzTPPVdUfJ/CWih1+T2fhxbzS2Z3oiLYkwKrVn2ebRPXh8IWrMIgfgX7U
+ EI6ZxUJaS4D92gL8YB4Nk5i7sCGYSZknDUPOOHx4vazF+AdbbPHG5gy8tncUr22rh7IyR5yUVCGeae55
+ Xk8CzNWFpt47oh0tkcCKlX/2ULRLwVl+DXaqukHWMBSc0G6Yp0FCZ/lVY9sUrdp2HdMe+Pjrkw+XSbdj
+ udyEpPbWIDGxgq4LRcLIyAFcrut4UdHt507juQDkdGIkAN588025bQoWY0bJgPE06UYM4aCe39j3ikYj
+ MkoaY2ZuHhMZdXVw9vKH3Gl78SrFcczUhwcr6EpczZThkpJ22NsLoa9vI3Zx8RdVVfUvCKNy3rRvwdFn
+ 5oCMSpIEwOuvv/7Hv2yQGeLEi3HCsXBit+rFcWVzD1gLA2id04qawUEJCcNioMflY91Z0SytOVIk3rJz
+ d5uRseNAVdWAhFkGzNzcDZqapqLg4MzxuUpqXgD/OqzYp9j3P1v39Ur9+p2tEgDL3n33vZWfrh06Z+GM
+ 0Ny8WYZnAvhEx8HK3hfbdMZmadOpYmTdvAknX9/732zbkX327IXy1NQq0UyzQUEZTCrQ0bEYSU+vm5ov
+ yudNniaQOY5fnLa4t+nQqQ6uhcdARUUPXRGMekBXKVZMAXy2fv1WjpVVw0yT872uHBhAbPk1uhjmCBmD
+ IRwwGZXQTpU8pNfXg/1cSen49n37rnz44SdHDx9WCLe39+6cWUKVlf3w8AjBuXOGYzRfHskraT+UulQ4
+ /mdphW75M5wu6mZP4W+PSAKsWr16h1tg4N1nma/o70dJTw/yOzqQfecO0qisuBau2HkqGidtRiQkcz4L
+ 0ZWV7OcKOjuR1dyMnQcOxDEnzCVLlizbuPE7a+pSxQkJ5aMzUymk9biCsh6+3ys3UF19d9ZcqWoephJ0
+ 76cE3mUTkFNSKlnIPGO8uLsbOazpW0hsakJM/U1E3LgBF14IpOVtoO76SEJHtVPhX1KCGCoj5vPpt27B
+ LzNzfM3atbKTK2AysOijj1btOXhQPsjGxquNKY3pMPLyZ9unvy4t7YCJiXODtPRRwYoVH6xnrwvR36/t
+ +ILR+QDKenvZEWcMJDQ2IZK6T3B1NfwqKuBdVgbry/5QVLeHMX9YQif1E3ApNxf+FdcRQp+PqqtnQbbJ
+ 7E+c63Ih+Xjr66+3mP74o25uTEzRI8b4JEBgYPo9JSWNtC+/3KBJn1s6/ftSixcv/ktAcop4LgDGfB6Z
+ Z0olroF+I9TUsoYEpaW0PiqkJUYu9Fy8oGHoAvurDyV0xjgGF9PS4FlYCGFpGQKuX0d4bS2kj5+gXw0L
+ 35d7//0/bdm//wffr77a3Lxnz2H+8uUrvpjvO0wCSzmW1qKZANepbAqpdjNutSG+sZE9OGOeT2XhSjcy
+ LmZmwjwlFWdsHWFkdQn8yAcSOm8aDm5iIuyzsmjdlE+r2VL4XbuGb7/fS78gXt2NRXYOyMge6ynv6pJo
+ m8zo57a3I6WlBdHUTYKqqtiS8SgoIFPZrHmDuHgouLmDY2SP4MQhhNA1nElpmwfDIDYOlqlpcMzOoZVs
+ IdRt7PHl2k0vdR9g3gSYDevWfeOoY2hOl1KenqxKqdswkzaZukcU1X1gZRVbCu75BTT6WTBLToE+GTwX
+ HEILLyO4C/ORlHMPkcmd0LW6gh/0LVlABpQBVrvoCMUzmv3Llr373itPgLmpICsrn2ls7ojI3Hw2iXKm
+ /imB1JZWtpMwE9envJwdSWZErai+jalEODExOKFvin2yilA2dcRRrjXUQ8OgFxsLk0RaraakQIFjBDsH
+ 7webN+/Qe5Xm2S40raUtoQkT4uDkPcF1cEVUYRGKqKwy29rY7sG0zKvU15kUPNkJnAOb9Aw2CQZENyIC
+ F2jEDeMTWOPGlI6SuRVU9c1ga8vvXLt246lXbV4C4ElPXbR1624HX9+EQf+AZJhau8LUyR3BBBNPXSjy
+ Rh07F67QGZhXXMLOB2dqlQ5UIkxZWSYlQcXBGWcucGFq5Y709Fpa73Br1qz54tufwvwsgMmDvP32u2t2
+ 7TroyeFYVZMJscA7GlZ2l8G1caeO4wyOpQM0zW2hybWFDvci9Kn0jCxcYEcXhpOTr9O94Nh7Cgrn09at
+ 26Qz112VVwkjsZibuWM6+OK//33diePHVYPV1AwzdXUtq8zM3O54e8cNM0YjIwvErq5XBy5csGvS0uKW
+ qKhwEnfuPOD13nt/XP0qTS60rwUB5jlj/ozA3v/DH1Z+98Ybv/qSnv/m/8vsnH7+lQd/Fcf+X104LlAR
+ 5z/iAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="paper" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAYAAACoPemuAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAChxJREFUWEfNmPl3
+ lPUVxmvX32p/6p/gsdqqgCxCIlpwqxU3IgWDtaBAlYTsxEjAEFBCksmiEEDBgBANmx7coIh7gklm35dk
+ 9n3L7DOJTZ4+b0LSOTXIkNPT05zznPedmTfJJ/fe5977zQ0AfvJ/+SWA/afmzll4+4svVB4sKqruKC6m
+ tlR3bCmhSqs7SgSVUeXVHaWCKqo7yiqpquqO8q1X14MPP9w40++62ns/gBIeXLggf63FnIbXA/h8gD8A
+ BIJAMAyEIkA4SsWB4SQQSQHRDBAbBeLfA4kxavyH2lxRO7Z02f3HcoW7Kph5MA2PC/+G82fBDRNwCi6R
+ BTdydbiG/Wewq+3s94uX/nF3LnAzgi2Yn7/WbEzD7cR/Da626TSOXgLKtu9PL1qc//y14K4KNqRPw2UH
+ 3I4sOC/TOhW5EFN7jcjFs9JaVHcKO44DnZ8B6za/Eps3f/6yH4ObEWz+nXmFJm0KLityh4ux5qbSmmbN
+ XUlr/J+T9VZYcRIFTGLtUeDIhXE88XRR6Kabb77puop//ry8QqMmBacZcF4DLpAduRngYjSEALemrBs3
+ M4ErdwE1nUDHxyN4YMUz7l/feONvZoKbOWICmCoFxyDgmIKzZaXVTbdOpVVw7BSc4NgpODo2eiVygmMr
+ 6jvxl9JurC47iU21p1G15wyqXz2Ce5c9NJA72Ny8QoMiBbuJYDnATbSTH4GLMq0T7eRKWrPbyR5RS2/O
+ YHfOWbJGJ03CZgB+KzdgpdqNzboAKg0h1BjCqDYGUWrwY73Rhwe0dtyvc+BBnR3PDvlQbg2h1h5GvSOM
+ bfYgSmx+rDa78SeTfUIFFhc8349N97oGUcvl6wLTipOw6oDfKczYoglgpz6CRkMELcYIRINR7DEN42UC
+ bjB48Te9B88ZPaixhLDXFkG7PYIDzihed0XQ4BpGlT2AjVYv/m7zotThh390fLoR721p/S5nsHmMmGYg
+ CYsGaFVHcVAbxzFDEu9QXaYkTlDHTQm8bY6jfZCw5gjaqKP2BN5zJXHKncJZ6pSbr718zhNDhzuCDm8E
+ b/miCIyMT6aV7aSxra0vd7A7lqxR9yVhVgF5SjueVHvxoiaIrbphbNOFUaMLoVwfxLN6H5ZrHLhbY8cy
+ ar3Jj/KhEHZYwqizMpVMa7E5gKdMbtxncGC50Y7Hh9xwpsama66xtf36wFSXkxhSAu8rUzivGsHn2lF8
+ rhM0gi/0GXxp4pU6P5TGec7VC5Y0vnaM4FvnKHpcGVx2p3HZw6tvFF9507joT+FiIIUvQmkEBcdema8E
+ y92Vc29fslrRk8CgHJgns+BhpQvrlH4Uq4MoZ+TKtUFsZt2tUnsYURsWKC3IU1mxlvX2gokmGQyhajDI
+ awAbhvxYYXAiX2tFnsaCh4wO2GJj08O/sfX16wOTf5OASQpskvtQIw+hURVFuzqGfaoY3tDE0K6L4lWm
+ tlzjR5HOhzKdH3tpiPYh1qQ5hkOWGA5aaQAbn2Nqq5nSlyx+1NmC8MTGp6dEU+sb4pxrbO5tS1bLvkrA
+ yG+ploWwW04nKqOEiuOgJoH9BNyvjaFZG8UObYh1F0SdPox2YxQdQ3G8SVMcpo5Y4uiw8jnLMF6xBFFP
+ 1zbah+GKjE+uTRxhTa37JDmDzSGY9MsEDP0sfpkNTyo82KQIoko5jBpVGC+pQqig1tIUy2iOfJUN96kc
+ WMeolbHXbTOFUUttM4VQxNQWGNw0iA33am0ooBGsobHJtYlToqllH/Pyw2V1xpE05w+LV4kvxaGnX84O
+ pPGxOIML0lF8Jh+Z0CXVKC5qRvCJOo0PtEl8oEvhnJ7FbcrgkmAK8yi+NGfwjYWFb+V79gw+cdBEjiQ+
+ d2fgyZqvzS0dspzB7vj94lUDF+PQsSffKbXiEbkbz8rZCuRhlCtCKFMGsZFmeIqRvFthxwKFFUsZuUIN
+ 2wrTWsW0VhnYXhi9DWwpj+pcWKRm8VOPGVww+8amR1iz6DrB+i/Eoe0BqgZYGwOsMTGLWprAQUkch2QJ
+ dMhiaFNEUa8MYwfTuksdxj7W3WF9nI04ManBBA6ZomgzRVDPtL7K9Lax3py+8cl1nZFrFh1QXFfE+s/H
+ ofkGeF7sQ8VACHUEa5LG0CiJYq+UQLIItjOCRYzkJqUPxaoAdmjC2KPlJKBjRVQrR9geA0cXo/eiwYdS
+ ox/b2EosboJx4RTgmppnA/Y1cJfYisclLH4JUyMdxkvUVmkYm2UBFMo8WCazI09uw3KFA39V8Zezz9Wy
+ jWzXsvg5JV6gIQo0LtwtGERtx0qmdcg1NrE2CQedZtEhtvEci/+OW+8q6D8fg4Zgx3s4+3oz+KB3BB9d
+ HsWHfWl81D+CczTFOUkGp6UpdMuTOM016WP1CD6lLtAYF7UZXOSEOG9g4ZvSeJ/z9dxgCv/ghHByXfdy
+ p/MSrrn5EAffLMAWSGz4s8SN9eIASsVhlFGlYha1JIDVMi/yGbGFjNhSRmwNI1aiDqGS9VapYUth9Naz
+ pazQuHEXI3YPI/ao1gWjbQweHnQEuOamN9WzAnutl2tML5tmbxKdvQkc4ww99l0CR/oTeKs/PmGKvRKa
+ g3X3pjyBE5ytXYoE3lUn8S6bcaeGZqEpWnURvKHnM4YYLNZxuHnQEeBEzW9xh5lFxFb1e7BxIICqfrqv
+ LzKh7f0RbOXrUjr2abEHq6QePCP1oljO+lJG8IpiGDtV3ETo1irO1w1qHwpUbqymNmp9MJjH4BJWdcKJ
+ mg5rcwa7/dZFK/s+jU7U2HKxA0+JvdhMZ1b1sfivqJhQ6+jY+/n5vVIHHpG5sJFgNYTaTtVxSrzMVlKi
+ pElUXjygdOAhpRNPc/DrB8fgtPAExoOOqPEw19EcI5YN1sniP9GTwkka4HRPBmd7RnCG15NUd28anZe5
+ CDKt7/TTJBIaQkpjSDP4UJHBOUGqDE6pUzjBtHZpEzjDKWE2jsMxxBMY4USNb88OLF/iwAqm6jm2iy0D
+ YVT0D6OkP4Tn+7n2MJJLxDYskthxj8yJQva0LRz6lexvldxIShjBDQo/HlO6sZgTQtBjTKfGMDZ50CEc
+ wXiymEXEDnIv62Thd/WyLfSk0f1tGu99ywjw/hijeaAnjgOM2iHqeB+fYRs5Q52WcL2W8cp2cpzt5LAy
+ MaEummJQNz5x0BHgRHs7cwe77ZaFT3z3SWSixnKVllNCGGHCfNXzeCFsJsLaZOJSM8gxPcTBI2zEZjYH
+ C8tdOOgIcKKGTmPOEZsN2MQfcA24wRngRA1HGbccUzlrsFnAifYc45H6fwGWDccz9nRaudkLaTUxrcJZ
+ YiqtBKMFcgS75aZ5jzbUHve1737fK6ht11lPtlrrz3im1LLzlHtKorqT7mnt5P3ObpeovtvVsovX3e+5
+ WgS9JqjLKai1ocu56snn9DmD8Z/FN1C/ytIveZ+tX/D1lH7O+yn9jPfZ+ilfT0n4mRO61j/thM//BR1x
+ NCLR9Yu7AAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="mbox_error.png" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAABcQwAA
+ XEMBOS4mtwAABChJREFUaEPVmVuITVEYx5fLmXGdaTSa3Br3mDAeCIlxeRAiRBE6pWQy5dJMETURDZHL
+ FHIrzYuEGCK5ZR4kxIMm5VqIcnkh0ZAs/2/sc2adddl77bP32efMqX9n5uy91/r/1rfWty67A+ectesP
+ AbRntWvzrb0n7NZHd+wHzYaqoO3QPmgvVAuthqZDRWHVGwoADE2BDnZk7Dm+aVDZ6KEDOCoITCAAGIh3
+ YuyRpWE3qGsUtXRA0gJAZTM7M0YtaNPSfu65gDLL/ID4BkAFu7yMTwTYKgidnqPz8z3QFmgFVG4HXWUL
+ YQ0A0z3zGKNQa1t0MX4/D/2gvOChT7h+AprhDnPYBsIKAKZ75zP2WGc+DhNPLUyboJrw7CwzyGkvCE8A
+ mI51YeyBbH4gKr0SwLgMdAxlYVzpotvgBuEJEGPsnGyeWuxziOYTMAgxH6GH2GGCcAWA8RrZ/MIMGBej
+ 8d480OfpIIwAMD5SNl+RYfMJkFeop68aiRe+ANB1kFTa+mQB/n4dEQCBIN3pxkOtDKGNAIxPklv/ZITm
+ E5GoViG+UzoXIbQAWNM0iABRdR05M9GcUqxCVLsCECH0VwRozELrJ2B2qgBPvACWi+aHZ9E8QXzUj4Ux
+ CQilC8H8KRFgc5YBCGKOCrHBCID1zksR4HYOAOxXAc5oAWjZIGcfDPu2xVkRNlLxeDQqKUnWe1cFaDYB
+ DBUBBsitX16O5yL6VFQkAb5o0qkJYIIIMC5HAGgcaBZ6ecqmHuanigDY6Kau7bMUAQJAbpdn5gIdQMoM
+ jHDkDACW9DJAVx1AygJuSI4AfFPNt5jGQA85C/0RIWIxzktLo1F+fjL6tE+QfCVXpspEhnXQW/Hm+zkw
+ DxxXARrdZuKzIkBdDgAsVQG2ugFUigDKQI4Y6Bfq66YCTHYD6C+PA5oJvY5KMnX9qGr+jed+AACXRYgl
+ WQQoUwHqbADmy1G4mgUIHGvrtpWDPQFaJwjGmkQITBD8d4QQzagLGVEGOGK1J3YAcPKXWsDKiABo7qHk
+ IdVP++E+1gAOxAEZgjbamRqwiXIX6LtOpWxeWUpob2DsngyBVy8ZgaAlw1y9eePxoufRIswPgz7IEHS8
+ iK1baCB3UJYm41A3atI1rHEeMERhPArCviK1X2L7xncHhKDNykZ9q5N5OlQuDgzgjIexKOyZDEH/0zHg
+ NggvyKwjAmd8HYQ9uC5V0m/XoUI381ZjICXnojVQKL0GMlXKR+PaGqgewo38FnQDwgKr9W0NZbJBLs87
+ Zdd7GffVhZTU9f8V6lc3kDSvUYQX2Zr3HQEpGr1QGV5/sZ9pmhWj+A5l1PgxHigCEkh3VL4WwhGSr7eW
+ Lbj/IrQsHeOhAUgwhTCEgzS2CcI+hF1ywG46Y+cQvtdD06COQYxnBCAMQ37L8JzI/BYY9f3/AJQMVypF
+ n/EwAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="No">
+ <value>No</value>
+ </data>
+ <data name="folder" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAABMNJREFUaEPtmW1o
+ U1cYx5+mSZPcvHax6GTIGBNfPlUp6FBERIeonTCoyHBWOuyLVKE207UYCY3isszg2iTFpJ2hXW1ybReb
+ tkq0nQhN04rECSW0VavWFtlg3YeBjK3b2TkdnV1y09x7d+dtsIHny3055/87z8t9zkkGQgjS+kcA0tnS
+ WvxM9KTz6i8CLATvvT4hhEutdNkyWLtzJxw4ehQ+PXsWvnS5oKWhAXouXYLwsWPgEMMjjB7AYlWFhVBh
+ s4H74kUINDXBYHs7TEaj8MfEBKDJyUQbHIQXGzfCerYQeA5q1SrIy8+HT8rK4JTJBE4837f19dBfWQmj
+ +L6CzViMABYLhJ49YxbKJH72WnU12GcnxQIyly6Fd7Ztg4JDh+B4VRXYrFb4xuGA3sZGiAUCMHXvHvMc
+ fX0wrdfD27wA8MRZHR3wfD6hye4NDMBPdXVwDYfV3dZWmAyHYfrpU+4LMTwMaMMGeJ8vgD4Ugl/4AAj5
+ zu7dUMQXQNrWBj8KKYbPWCTs5gKQyFi5Upa7ejUY/nWdiRIn7WM+kwrxDsmLQECCSktlvSYTVXf+vCbg
+ dmvv+v26511d+t9WrMhamxIAl8X7QohJNsaDB4Bu3MhAPl8mNhk2OfL7KWxqdOuWHj15sgRXukRratI9
+ xp7ISAngdkPffwUgVSwSAXTligQLlM6I9PmU2FQoGNSioSEDo0gm4bPXnE5tT3zEMJZRpxOusQWIxQB1
+ dUlQa6sUWxY2BTYK0bQG9fdno/Fx5tWcT2iyexaL2s0KwG4HPxOAz0eEyrDJsSmxqdH16zo0MsJ9NfkA
+ FBcrP2MFcO4ceOIB7twBdPu2nrPb+QhleufhQwPavFmezwrg9GmwxwP4/RJBw4ErWDCo+xknsJYVgNEI
+ 5niAy5dloq0+gfV4tFGmks+YxMXFUJkIoBAVwGZTt7EG2LcPDicCUKICGI2qL1gDkA5ybjdKPjwdHVpR
+ AfbulZewBli3Dt4j9X3WC93dEjQ8/GpKJVNyRyLZ0/EtxD9tOyMVwFukJ58FIB8prlVDyOe93sQWIhUA
+ FQzC1EsAuagAtbXq3mStddJNfUsLjL8EUIoKYDarGjgDeL0wRADIHph0iUKGBNexiooU1ZwBPB6IEADS
+ UZKmjOukQj0/OsrcQsybA+QmPjIJEQCazsReEK6j5Ap29SpzC5ES4MIFaCMAZMPBdVIhn3e5NPfn2xsn
+ TWJ8BPI1AfD7xW0hampUIV4AZjN89TeASlQPlJUpfbwATp4Ey8gIoO5ucVqIsTEDunlT/+uuXcwtRMoc
+ OHIETnR2ShDZSAgZ03PHItvNcDh7urlZN4FjfcBqVbdXVVG1hYXKE1u2ZH1IUfBmqrOhpDmwfz+U0rQw
+ LUQ0+safNK2bcrs139vtmk6TSV1fUqI4tWOH7OOcHHgXb1QkqYRy/g5s3w4f0TT7FiIWM+DTBt0Lr1c7
+ 5nBoe86cUTWWl1M1e/YoDq9ZI1uPRcr5iuSVA3l5sJWcLsx1+aNHM3H5e3Oz5gePRx21WlV+o1H5eUGB
+ vDw3V7oVi9T8HyJ5ASxfDksqKuSjTqfqO7OZch08qDy+aZP8Aywy51WL5AWwkEQuAixkb7w+f/ItVC8s
+ ekBsz6S9B/4C+eG8h3vJrfkAAAAASUVORK5CYII=
+</value>
+ </data>
+ <data name="Green">
+ <value>Geen</value>
+ </data>
+ <data name="Define Colours &gt;&gt;">
+ <value>Define Colours &gt;&gt;</value>
+ </data>
+ <data name="Ignore">
+ <value>Ignore</value>
+ </data>
+ <data name="Help">
+ <value>Help</value>
+ </data>
+ <data name="Add Colours">
+ <value>Add Colours</value>
+ </data>
+ <data name="Retry">
+ <value>Retry</value>
+ </data>
+ <data name="mbox_info.png" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAABcQwAA
+ XEMBOS4mtwAABL5JREFUaEPVmX1olVUcx0+3ba6VDmP7w15w+TJ0rJc/EhuytuqP0Gz4UqhoDoLYcOAW
+ TpQFW2KaKFZihbMg/CdCxTeU0VK2P0SdzD9CGlsrfGtg7Y81pFjiPH5/u7vee16fc577aHcXvmz3uec5
+ 5/s5v3N+5zzneYRzzib0hwAmsia0+bHRE3XvYzg+DS2E6qAt0G5oF9QMfQC9Bk2Nqt1IAGCoHPqCsVgf
+ /tKkctHFccDSdGDSAoCBasYe7XY0bINqo6iFAQkFgMbeYCyLetClp33KHEGdJT4g3gBo4NNg46/A9PtQ
+ M7QL2gk1QWugF12A6lwhnAFgejJjORRqg4F3cP0w9M9YarDrT/z+DfS6DeYrFwgnAJguZGzSJb35apj4
+ xcG0CaoT975pAvk+CCIQAKazGcvtUs0XodGTaRiXgVpRV5YO5IANwgEg+5Bqnnrsr0DzM2ZwvnEj5ytW
+ BA2pxO+XUOccHcRWE4QVAMYbVfNLA43T+C8q4nx4GM2Of/budYX4wzTR39ZBGAFgfK5qvsLJPAHU1yfN
+ 039DQ64AVO436Ck5Er96AmQfFgGmoMLfnQEWLxYBurt9AKhsm24oNcsQ2gjAeJna+986m0+k0G3bOB8Y
+ 4Pz8ec5LsWEITq9ymQ0yxC1K56kQBoDYARHAfej4m7SB0ZpSIENssALEFyx2VwQ4FqL3wvS47p5PZICf
+ gwBWi+aL/0fzBHRTNxdeSEAoQwjmvxMBNnsDlJVxXlGhV2FhmMgskiEaLAA5/SLAGS+Aqiox+8jfenvD
+ AHwmA/ygBYhvG+TN2i0vgAULOB8dNUN0dIQBOCsDXDYBzBIBnvUyn8hAxcWcL1/O+eBgEqS1lfPKSs6z
+ ssIADCrp1AQwXwR4ORRAAuTKlSRATU0Y46n3KBu9HIIQJjHMvyoClGcQwGQ5ClN0ANIKPD+DAHJlgMd0
+ ANIGbmaGAAzL5kdMc+AJNQvdCQ0R3Ryg5wQhO97fmWoWstg1sfCFDADYLwMcs63EB0WA7RkAsFIG+MgG
+ UCsChJ/I0Qyh/2A+TwbAchk/lNbthZ5R5wGthP55PBqAfbL5qw7PA+yECPGuM0BuLufTp8d140ZyIWtq
+ il8rKPDtiBIZYLsLQJUahVNOEO3t9s0c7ZNoS+EW0d2yefqOs47kOw3bQ32nCDEXN98ObLinxw5Av65d
+ 6wJwGW3FZICvU81r58D9yYFzPzUK7wUClJdz3tJiVgN28nl5QQC09lDyEHI/PQ9PcwYYo2PscxWCHrSD
+ DKT7+xLd0KmVzVsjkBKJcypE3QOCoC3DWzrzxuNFh6NFNhsAAyoEHS/2RwjSgbqUjEMwnbqeN64D2jAx
+ Ng8VDaoQ2WhgR5oQ9LDyoa7X6RodKiPxmt+kBkYgZSi9hMp6VQiaaHQM+DHU5wHThbLroRyT+R/RVr7N
+ vNMcEHIuegOV0msgU6O4/jxUA+2BjkCnoXboIERvayiTPWe5f6zuPUHGvYaQkrrir1D/toOEen9GEV7m
+ at47AlI0nkRjO6F/IwC5jjoafYynFQEJ5HE0vg464wkygvJHoVVhjEcGIMHkw9AiaBO0Hzo+DvbT+Nz5
+ En/roUoolo7xBwIQhSHfOpzTqG/FD6v8PRJO78MpB02PAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="desktop" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAACj1JREFUaEPtmQtQ
+ E3cex9eKr7vO2evUu/Zs72F7147edTrezdmWdmyvnfM8q5718BwRX1WEU4vYIohKtYjhKSQ8E0ICojwl
+ ikAtiqL4FpQozxACBAiEEBIgLIIC3/vvQtLwTBC8a2eOme8kM1l2P9/v7/vf3WymAKB+0H+MgR+yftDw
+ bHu+z+lT1PZn58zZ/dbixd5bV22J4qz2yUz+RHjr1ofRd2pmHinY+D83QABnzJ69a76t7WGHVfahh+0O
+ nT6xQnD96ieJUtmnkqJG+wvlHTultX1u1Rp4qrTgNGvANzTCt1KO6cIq36dugADaTJ/uPG/Roq/sVnwa
+ dNDOMyVmZfiV3GUnCsv+kfZA9a9zZe1OBcpe18omfFHbAi91M47pmwikekwdliswPabaf8IGCOAzRC8v
+ XHjwk6V/9/VY82VC1Cruxexlx+8WrUy9X2eXWdq69WZNj4usCS7VOrjXa+Gj0YBLII06pqnHgfzrcE2N
+ h3uCEPvjwnFYenvQNubbM+89y6sZAwFWGSCAP58/f99fliw5usdul5i3OjA7c5k4X7oiSar89EyJbtO1
+ qkc7itXYqdDBRanrH3WTBr4E1ChOUxM87t3DzrQUfC7mY19cJHziw8A9GYq4U+G4k58GvT4fNC1lFSvh
+ Y883GYP2Yb6/PSVKYqAmaOASsP1Hr766992PPvLZZbeNH2h3NEtCFkrBigRp1SpJsXZ9rqJr+/1GOMt1
+ cFbosVtJRq1qxqGG4XIrKoNTegYco/lwFYbDSxQKX3EIIk9wkXP5JBobr5kgjbCjvebeTIWzKHrE4+x4
+ UEvWgPIYa+A9x3j+unw1HMtbsEXWiu1yPb6saYE7AR1Ju0tq8FlmDjZECeAUEQa3qBB8LQxGkDAQkkwh
+ 5PLzVkNaMiFXXIRjkD++lDcOYtlaWM8YCGYN2O7LEDmUtsKlklTAgrbweIhLDkVh4Wm0thZMGuhYRphq
+ fRHMgePNUhOfQ34DpglrQ/oNeGSI1txvg2Opfkw5RMejsCjriaGb2h/gVrMMSXW1ECsbIarRELUQtcGH
+ 1NPSNIJiebA/ncsyrrmhxrToWp7JwMqCdmyQto6qtSeykH0lyeJBFPpiXGioRHytCnFKNWKVzRDX6Mlr
+ O1LraORrOqFtp9HRMVhiYsSSAeZzSXY81vATsfKKBtMEdQMGSIWW3OiA3e32EbUy+RbiJNFjHuCwrA1x
+ NQZ820CjQtcJwxDAocBPaoAxcfd+FhYHJDIGwkwT+OBKB5bnGYbpb6dl4AhCLKYjJvCWIMf63NoJGAz3
+ cD4pGPZvvo2tz72kXUtR/2TXwDsXaHx8oWOQPjyrhosfxyI8k8rTNnDzjgQhCQI4bFoPLbl9yyNqIIqg
+ qPOsgYVZD/FeZqdJtukG2B/0QXv7vadqwGCg0U4kqh6+BhSKHEQkRsErIR5H7skQ2Qa4+fmjj4D3EgmJ
+ 3CgqlzWwIK0Lf0x9aNIyj0BoNDetgh/vBBhoFpws5rY2Gq1ERgPNzTcRlyaAd4IYB3KustDmCiSL3c1h
+ HQ7MfQ3v/3n13V9T1M8oW/cM0WsJ3VhwvIvVBx4CVFRetBreWgMmaCN4Kw09kbbFAPfUb+B3Uoh9krPg
+ abqGgYeoDPBKSwMvOQZXriVhoWs0poU1CPoXMTHwsqgb8/jd+JOnBNfvnB4X/FgGRoPW62nkXS9AQHwy
+ 3E+mIUChGQYdru/FV+fOIzBJBElWDLlwfnev9OauGNiENkSbDMyJeIzfeN5CSmb8uOGHGjD22rwiTNIM
+ tI4oIycP++NT8XVB2TBopi7eN+7CJzEW4pRIqFR5I/IscBbChtcYYzLwk2M9eH1b7BPBGw0M7XWrGXSL
+ jkZLCwN/FQezh3ebU65iF2t4QgSKijMtcsx3JBMIaRSZDMw42ot5m57cgKja0L8gB3rNJK1joIm0BLxZ
+ SyP928vwzLhoSp3p9b6kdPjFJsPjVLZFaPMr9etbRLA5phabDFAHgV+uOz6unZjvUFhlYOthDq0l0Ay4
+ ppnGEcld7OSlQXA8FTxxMgLjUiBOTEdVjQ715OrNl1t3K2E85m83xMImUB03eQYUBjZpY9oMNKMmDQ11
+ E41L8k48e6IPaSUPoWqkWeh6FY06otp6YqBifAZ+t9HcwN6z4olOILrSwAKbQzcS8EY1jQYCzEAfud2N
+ 2Sf7kFvRyUIzUpIbvJpaGlHjNPD6RrHZBCbBgIAYUA+kzUITMdAqJmkiJuk6AvzXrMd4JbkXBZX94NVK
+ mtSIRqTM+gkUSM/h+c2XzQ2kiyY6AX6FgYU2pm2CHqgImzSRVEHjxcRe2Gb0oIy8V1TTqCSKJN8Grbmd
+ ZrZZvpsLag8m10AUMTC01wy0sSJs0gNpSx48xFtne+F67RFkZBIVxEiElQbSshIxa2vx5BuIlBmG9bra
+ rCIKUhMm6coqGnIibkEX1l7uAb+wC+VyGuFllifQ0VGId7fyWPhJn0B4uYHttHmvGWi2IgPQTNIVJHEm
+ 9dIKGr753eR50CNkFj9EeKllA4H8CDzjpH5KBkoNpooYe80kLWegiRhoJmlGZQS+VEa+XpbRCJN2Q3C/
+ G0ElY38n1mpvY8EGvgl+yATOTHgRhxIDTEWGQsuGQDPgJeU0igl8fimNaGknOA86yFlIPeYidvEOALWr
+ 8ykaKDGYkjamzSY9kPZdApxQRINX1I6IUi2EcjWSa5SoJA8BLJ19Ksmt/SvrEwfBT/oEuMUGUz0KScIM
+ LJfAMotTUNEPK9eXWIQdycwaF29Qrr2WDdg4N2D5jqPk8d/1cR/IqbAdYeU6ckVVI0lZC5nuyWDNDVRX
+ X0SEMAjPb7gwDH7QBN7b278G2NPT7h78fkMEzl1KHbcJS1UY7XPmydv1GynghAZjm9cxLHUJwx828vHC
+ +kxQjg2D4Q/0YYZfV+cs/1bVFH77jv5no+YGBs6xL2y+hP1B3Ek3UVWVg/gUAb44GoQ1e0Px7vZI/Mr+
+ OKZvkoJyefQd7F5gqvfjxzMDOnQzfVvKqED9Kep4zwHqDGypHMw0/1VpRAPMNKY6NWCpMwf19VfHbYRJ
+ Ne9aKry5wfjMi4slLpGYv1GI59Zng3LSDE21b4bfQ3qWX2v9NF/tNSqCDqNSsJGAzrXm569RDbCVIovn
+ DQcBzp5PHtUE8/gjhjyzcT3KxWq3cCzaHo256xIwdVMRqeTj4an6k1Q5LaUk1VSSqieVjncI7AxrYEfa
+ hnp/hAoZL9fG159uzsNefy4u5aXiUAgPm73C8fHnAjC3tT+2vwjKuWV4qr4kVV993TSONo+kyiWpOhDQ
+ Xzwp6Gj/Z5UBxsiUf2sxZXP54FOaW39XZ/l3tMzkaEumBOiTqPgeD5Lq2xNJdTwmrTZAHejrm9Gfai1J
+ 9TIV0RlMUl1PQF8azwEne9vhBvpTfTTLz6AlqRaTVBNJV92ps1hEYKdPNsBE90e9sSfTaWZwm8qGo82l
+ IjsDSarrCOiLE93xf+v/v9e/1FsTwv8NWJPS09zmP/rAGm4g64OPAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="Hue">
+ <value>Hue</value>
+ </data>
+ <data name="mbox_warn.png" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAABcQwAA
+ XEMBOS4mtwAABLtJREFUaEPtmWtoVEcUx+/efb9ujGAKtoKk1mekUgkV+1KkSH1QlYjUZ7C2FcUiVTAF
+ BQWr9V0q0jaIQbSUBFrFKGpFUPCB+EA/aLW11EdbTW1Sq631k6fn3Oy4s3PP7p3s3phdMPBPZvfeu/P/
+ zTkzZ2bjAwCjpH8IoJT1RMxjhEOdNUidAoCGN6HQs52e9Ku+ZADQ7LiUaTIua1pnQHgaATQcQf2UBaAN
+ 3+/lNYTXAF9mMS8isbtoAdD4ZNX8K6/61TSi1x95CeFJBNBUd9SvMsCQl/xw92EZvDk6wEEM9QrCK4Dt
+ 6ujvPxy3Ac7/kIREImMyE9CJogFAMzNV83VLw7Z5oS31US4Kn3oBUVAE0HhPVKsMMGx4e+qomjYzyEGM
+ KRSiUIAmdfSPnEiwAL+1WtC70lQhfsbn44VA5A2AHX+gml++MsKaF9Fo2h3jotDwxAHQeB/UAxlgxKhA
+ TvMCYuGiMAdRmy9EXhFA483q6J88x6cONx+qX3bUh/v4eZX5QHQYADtaqJpfs4FPnTv3LSCwU+cT0PbA
+ ehwhmidMxd7X6QDYaZXa8Vtj+dRZvT4CZWXp9b9qsAm376YhVq6JcBBLOgrRoQig+UMyQCxm2IVKTZNN
+ m1lzoK5QY8axVXpYRyC0AdB4nTr6n22JOsy3/mtBxTM+x+gGgwZcb0lHgKAvXk1Ct3LHvWc8B0Dj1ar5
+ iTVBdtU5fobNb5hRy99f38BW6Y26EFoRQPPHZYDy7j64/IszdWhUv93jXOsty4Afr/P30zO174a4+fC2
+ DoQrABpfoY7+V9ucqSPmwRdbnSNKE5ZbTsV7f9yz4IW+jip9A/std4PICYAf8LpqfuoMPhWEmeWfZE7g
+ vv1M+POfzNznYHbtZav0zkIBzsoAzz7nc0xE1cz8DzPT4bvmmFaFps9ZXMdW6fdyQWSNABpfq47+9m/c
+ zdRMSe86x47X217IgzDceYp7iD76ZYNgAfCB0ar52e+HtEbyjZHt24RwmK8RueYCXTt2ml3FvtcGwM79
+ qEsyQOXzJrT87Z7HZKD/gPbJSOngZjbb9bUb2UK4lINwRAA736yOPm2Ddc3cvGPZ80Te++g+K983YRJ7
+ AHpNhcgAQOMTVPPzFuilzo7GGNBB3jQN+wy8bEX+ESCQK9eS0KPCUaUvZAVA40nUNRlgUJWpNfKr1vF7
+ n6s3sxcvnag07GSr9OcyxOMIoPGt6ujvOdD+zUIu0dygTZ36LFVr2k67Pe92fc5ctkrXCAgbAH/eUQ0s
+ WqKXAr+3WfaKIz8fChlAKeVmTuf6X/9ZMHCQo0rfwv4qUt6NHviiRTYwtJr/ZiFbh427YkDr94tDTJg+
+ K2gfYnTM6d7TfDDO7ZUaBcDX6ugfOuqeOrqde3Xfx8vYKj2P0scR/mTSABKtJkLxuAFClPNC0agBpEgk
+ LUopIUonIToTCAUCBgj5/QaQaAUT8vkMEFI9Sq8fOQBy3MyFsevfS+VR1xtRMkF7IEsZwPaeAuiGxGUp
+ WfhXiIqbUALbQnFsC8WwTYpKov/UCIWxLRTCtlAQ20IBbJNoHyZkYlvIh21bObcSboeHYrzueqQsRtPs
+ VqLYjWqfB0oN5GkKdXXEnkagqyPwP76kA5sYKmTOAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="monitor-planet" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAD6JJREFUaEPVmXdU
+ VNfaxo/GfBo1GuONuUmMJTHGllhCchV74VOxtxgrKkhVFCkWlEAAEQQB6SoggrRh6EMZemfoAlKkqiBg
+ A0VABH3uew5CBtCgN/pHZq1nTTtzzvPbb9l7n+kHgPlHP1iAf7L+0ea57HnT0S8tLR1cWFi4Li8v74Iw
+ WZRgGO5RrRXk0awf4HffIyg+OzQ03Cc4OPiAv7//mDc957s4rk+AysrKcQXFpS7qwX7PJnvK4XOfORgX
+ NAUTQydhsnAyJgknYYJgGr7ykcTXHqsh6ayF85f5Oa6urmvehcG+zvFagKqqqsGFZcVWOwU27R86zsZI
+ 388xIWQCZkXMwoKYBZCKk8KK+BVYHr8cS2KXYHbUbEwNn4rRwaPx0dWxGGu/E7oOVhm2trYz+jLxd75/
+ JQCZH+eeGVU83GktGPdBGBU4ClPCpmB+zHysTVyL7anbIZsuC4UMBchnyEMmTQabkzdzUBKREhgnGIeB
+ /IFgHMdhkdWhNjMzs23/i8mV50uGTTtwRWLinvN7f1RwsJhxwCVohrpvyiyNwOwZshZJr6wBMj/9ckxR
+ Qz/b6WB4DD7x/wSTwiZhYcxCziRrWuuaFvSu6+F04WkYFBjgZN5JHMo+hN2i3ZBOkOYg2Ej04/UD4zIU
+ X+nJw8DA4ORLiH52SbWjNGzD58qe9pBXNPGyUTIPDFGxjkhRsY3KVrGLLlSxj61QtourOWwf/cDQPemJ
+ e0zBC9GNu7jb2Ib258CLF4CdnV1pLwAy/0V4enXNB7P5YFyHYoDPAIwVjOXSY0PSBihlKkEnXweWNyzh
+ VOGEqzev4krlFdiX2cOk0AR6+frQTD2Og2GaUA/ShXaQOfQEF2Ho6Q8Lj2Q4ByXfdRKk1TgGJt33jkhr
+ jM8ueV5eU4/m1uecKXG1tDxFUVExQkPD4OPD7xKPx4eb21U4Ojreovmrf1cKkfkBafm3M4ctuA5mVBwY
+ q18wzG8YJodNxrK4ZVyaHM89jvMl5+F5yxPCWiES7iUg9m4sknOSkZ6Xhbi0ZCRmiFBYUo6HDY1do9XT
+ HPu+ra0dFRWViI6OAZ/v2yUfn47XQUEC5Obmo7HxSS849nsvL+8aAhjSBUDdRvHn/WVghoSCmV8JRm8/
+ RgaMxHThdKxOXM2ljn6BPpwrnBFeE47chlzcarqFksYSxKXG4TmZ6qnqOzVITEqGr58/fH39OPH5Hc8B
+ AYHIyMjCw4f1vQy+Clj8MxZAIBA8IIDPOAAy/7GFW0kD82EAmO8ywPx/NZgDzvjM7wvMjJjJFa5ypjKX
+ 866Vroipi+GMt7S3oK6lDsL4CLQ8A4SRsfDhk1nWsF8AUlJSUVtb99YG+wLgUZQiY+IbCWAMB1BSUqL6
+ 5TwyzviCmX0DzOoaML/exKdXJbkIrEpYxXWbP67/AcdyR4TWhCLrYRZKG0tR+KgQfKEvqu89hqs7j4tC
+ Xwb+7vee3r6IT8lsI4DvOYCY1OJk5qNgMB/4g1lBo7+hDsy2+xhqK4fvQ7/n+vxO0U6u+5wrPge3SjcI
+ bicg6nYehOUFuBIqRGJ6Ljx9Bbjf0MRF42kb0Ep61k75Tp2D7R7vCs7T2w8p2UUYMmToLIaWB6MOW914
+ wY3+iIiO0d9yF8zuB+h/oByjA2bil8hfuDTan7EfJ/JOwPS6GxySWuCc1ArH2Kew8a+Eu28oYkTXkZJV
+ gPpm4FEL8Pgp0Eh60go0kZoJrAuOwP5XOE+eH9Lyb+KbCROXMrm5uVILD1LasACfRoJZWwtm6z0wex+C
+ UX6EoQ6a+C70O8yLnof1SeuxL30f1DKNoC3yhm5qIHTSXOm1FRzc3FBQ1QQ3nxDUNgJ1pHtPgPukB03A
+ QxIL1kBgr4WjiHGRewnHRe1l3xdPOw8CyKR5YeqPMzcxWVlZu6bJFHcAsCm0hiLQCaDyCMyxWnzqs4DW
+ PhMxJ2oOt3zYkrIFu0S7sDdtL/ak7cG21G0wv2yHG/cAG2cf3KwHbpFuNwBVpOpHQM1joJbEgt3tCUdg
+ r4PrFrWXKXnVyw85lU8w82fJfYxIJNL8Vr6qA4DVgtKuFGIUCOBwI5g/sjDEYxE3qf0Q/gM3sbEzM1sb
+ i2MXc9HRtTuN/BrA8pIPB1JCKr0PlD0AykkVD4FKEgdG6gS78zo4ihgXOTG4xxQ9NiWvePgh985zSMxZ
+ qMYkJSUdmXaUUobx6wCYktVVxMzeejBKLyF0RejvsghDfIdwa6PxgvH4NuRbbt3zeeDnUDE9jKwqwPQC
+ H3kEwsJcrwUK6oBCUtFdoJjEwREYC8eBkViwm51wYlHrBUfpyKalk7s/sqqBOQuXH2fi4uK2LzaitBmT
+ 1AEwlCayldSJNlEhb7/fUQvyDR0gahSdS8u4NVJPbTPYhZSK5zjjwEfGbSCTYFigbLpQDunaHSCXoDg4
+ AuuEKyK4LrDOqPWE65GSF9z8IboJLFy+/ncmMjJyyeZz5WCWi6XRl/EdtcBCsPWw4wHXlRgZgjkSCMbr
+ o14A8/QWgp9QBn07PpIqgORKIIWUShdiL5Z2C0gnsF5wBNYJ1xU1AuwVNTE4e7cgxJU+x9LVvxkyYWFh
+ w/WcU9oYFZoQJoj+rIXJlErSd8Cso660keYFFmYziX22XdALYLzhdJg4BsHIMRQhec2IprViLCmuDIgv
+ BxJIiQTWBUdQHByB9YTrFjUC7JmSl7wjEZzTiOUb95hyE5k3PyBksGorpUo7mJFRHRD9qSamXQMjRZFh
+ J7eVBMMCsc/aR3sBDNfeApXjlnAQFMIhpBChRUBYMS0vWN0AIklRJUA0KYaFI7BecBQxLnJicOkE2DNq
+ lwNT4JFUB+mtCuc5AB6PJ7NMn+YCNgq7msAMolm5syt9QpObBLXZRbfBLCYtukV14dQdwJHW/lL+2KWk
+ B6+MZpyyD4N/PhBwHQgkBRUAwSTi6gAjhb+Ei2DhCIqDI7BecOJRe5mSbmHXcEFYgVU7DtpzAO7u7h9a
+ XuKVDzz4rANiPeX94JA/IfpRRP6dAGZ6AZj/UL3MzQPj0/9PCDUFMJMKsW7bMXhfA9TN/eCVA+41Lxfw
+ IfHzAF+SHwv2Ei6I4FgwClpvOAIThxMWtsLcIx4nLXnQOOsOl6RHWCuj4dS1nKYNwsb1+lQDLACr/W00
+ 8rQ3+IBWqJ3RYJ/7UWp9RHBugzsATKeAGRbEHbd0hQrcsoBDpn64kgG4ZoJ7f5Xkng14kDwJTByOT3Ac
+ GEk8agF57TDzFEHzHA/qZjxoWgbCNqKWO9elhMc4fJZfM1d6x9lue2Ira1v/qVq0J+iEYJ9lmsFMTO8O
+ wYJc+pQgBlFEqB5eAv5nriyc0gEVEz9cFNGFSI5p1LdJzvT5ZZILgV0hMHE4Fswj+wWMiezQWR5UTUg0
+ CKbBt7jfOaW9gK5rZssOTaus5TvUnSf/vESOVqIf99pSWlhYDDEwOZ/z5WFqoeIQnSCr6HNJqpVJmdSJ
+ vgajKN2xAfqa5pDpufh+/kGYR9RD4Yw/rGjLbUOyTab9K8k+BXBIBS6QOuEMvAuhfMYHikY8KJ7hw4BX
+ wh3Dyiz8PmT1rt5cK/9HsMTSXw3+9eX4H151Y6DXXQkjI6PRJ/RMiieqFfWGEIdyWUKbHkozsc8+k7aC
+ mnU0ZE/7wzSOTJDM4wGLBFpikHS8y7Hf0Bf79HmQNfDBiSv5sEoEJ8u4dqhax7cu23uufu46BZdvfpi7
+ jUZ5UF93M155W0VHR2fY8eMnBPPVwjBAhdprz2iw742ce30+aHMM1imbQf5sOHRDmnGMV41d+tSddH2w
+ W88HahcycTbmOQfG6pRP1Yv1Rxwf/bz5bP3XSx3ah60sx7AVJe1k/F99Ge/8/rU3trS0tPqr0WPfQe0H
+ 05SiMED56V9HhKD6y9VDYpUCjnlXY/NxNyhaJcMgog1G0eCkH96KvWdCm1bK6Ves36XRNHqecfvYnS0Y
+ t7u9S6PXF7QSwIi/DdB5AkVFxWFycnK6O2X2VyyUOYtvZCMxUu46hshXY4DSEwyUv4uP9xVh5M5YjF9j
+ jMm/SL3QiwA6pepS8mKzhl37DnXjdo0zlgi7lovrDQ1wdA/Esh22mKHU1k2Tfs15SgDD3xmA+Im2bt06
+ ZdOmTepr1661lZaW9peSkkpdvHixcP78+Zdnz55tICEhsfyriT9VbdHhP910yPSZhukluAqjkPfwIWda
+ XI5egdiv6YhF6s+6SVIuE0rHjqVLrVun8CYQfd7cfZOTdB4zb+nS1crHtOuSKyt7Ge4J4MQPxCkjV2zQ
+ ae2mlarpyKypgfDatfZ1v/3mRNH4v7/y8M4A1mzdetArMupJT6Pi7/Pq65F57x5EtbVwFIRCz+gC9ho/
+ 7abNmimIpQEQ0e2Y1Dt3aHmilPhX3eidANAFPtDUN6h5nflrlEJpdXVIqKpCFJkLLS2DV1YWlFS1oWbV
+ 0k0yJxIQUFCAsLIyRN+8ifCiIkhISmq+LgrvBEBi3rzd8TduvDJt2BFPrK5GJBkXlJSAT+Y8qJCvEIDa
+ UX0o66VAz6m5S4q60XDJzIJnbh78CgsRUlKKrfIKtFp69V9h7wRg8Urpq/mUHj0jwJpnR11YXo4AGknW
+ 1OXMTNinptLElgBDa2fsUbXEea+mLqkZCnE+MREXRCK4EKR3Xj5ktY7R7YD3CDDtx1maTv6B3QByHjxA
+ MuUwO/KBxcWceeeMDNgkJ8M0Nhb6QiGOWzhAWescrgQ96dKJs2EwjIjEubg42KWkcNHYuGsfbTzfIwDV
+ wEClI0ebxCPQOfrhlMu+BYVwy87hRtU8Pp4zqB0sgKLxOWjoWCIwurFL2sY8nAoJgVFkFM4nJOLERWq1
+ S1a6vVcA9uQbN+700je1RjrlOwvSCcAWoziABQGcJoCTAgHkLK2hpK6L8Nga6Fl40sLOGgr2F6ATEooz
+ UVFQt7SB1knj5jFjJkx97wAjRowYvn27Qujps7bwiopBVwrRfwDiKWRLKWQWG0dRiOBGeo+BMRTMraDp
+ 74/jQcH4nf7QOOXnB2UdQxiZXLwnJbXmLye0d1LEXQsraqcbNmy3u+wiaDWzcsYZm4vwIsPhVMT+XBHn
+ ckXsQEXMFioLYhwdzaWLPhlXNjaD1mlzWDt4019SNoWSkguW9DWRvlOAzov99NOc9QoKR9ytrT2qrnoI
+ YWLhiNMWF6FPRatrYQ9tC1ucOGcNbVMbnDKxwe/GNnTMZfrTI6Xt6NEzotWrfzs9bty4f/dlvteG5k1+
+ 8DbHsKtKKan1p1RVT/GOHTOK0dW1yDM3d6nm8WKfOjsHNxga2padOmWapqFhELJnz0HHGTN+WvU253/v
+ AK/cQTHMYAKbSPqC1O9tDfc8/r2k0N819Ta//8cD/Bf1OK6O+/e5egAAAABJRU5ErkJggg==
+</value>
+ </data>
+ <data name="User Colors">
+ <value>User Colors</value>
+ </data>
+ <data name="Sat">
+ <value>Sat</value>
+ </data>
+ <data name="OK">
+ <value>OK</value>
+ </data>
+ <data name="Blue">
+ <value>Blue</value>
+ </data>
+ <data name="Base Colours">
+ <value>Base Colours</value>
+ </data>
+ <data name="back_arrow" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAACTtJREFUaEPVmXls
+ VUUYxVtrLJFUTZTFJUgQgooouEAxGheM/qMREo0b0aCJ0bA0smihRUE0alwQlQfiAu67uOPCYlUoguKK
+ Ii4gsgikaGmLRoz1/B73NNPb+15f+4wJvhzv5c52zvd9M/PNtLCxsbFgj/4PAXsy/jPyBXMLOghHCqXC
+ 2cKFwlUReOcbZdTp8F8ZLS8BInKocI4wVpgpzBYeEh6O8Iiehr9RTl3a0PbQfMS0WYAGLBT6CZMCwpB8
+ VJgj+PeY3uJwGfWoTzsE0Rd9FrZVTM4CEohjUUjwg+jjwhPCk8JTwtMJ4Dvl1KM+7fjRD/21WUhOAtRx
+ R2GUQIiExCFhws/o/VnhOeH5CC/oafgb5dSjvgXRTyiEsTrm4o1WBaij7sJtAq62xU0cK0MGchB9UXg5
+ wjw943AZ9ahPO9rTD4YIhdzO2K2JyCpAHZwipASsTtzicgZiQCwZkn5F/35VeE14XXgjAXynnHrUR5DF
+ 0J+FMA7jzYJDNhEZBaghS96DAXmsg8tt8Zf0joVNGsJvCvOFtyO8o6fhb5RTj/oWQz/0Z48wDuMhAs+X
+ ZhKRKEAN+ggsdawS/Jh0odWxHBbEoiYN0XeF94QFwsIE8J1y6lHfYujHHsGr9gbj8mPu9UkS0UKAKh4u
+ 3C8QNnHyuBtrYTksCAGIQArCi4T3haoIH+hp+Bvl1KM+7SzEHqF/xomLmAG3uIhmAlRhL2FKRB734UZb
+ nk6xEuSxOiFh4osjwh8WzCio7jm+90/9xh2/Qd+qAyzV+xLhI+HDqD7tLIT+6Jf+GScU4XC6GY6hiLiA
+ waqAu1htHPNYwuRx9VuR1QgHLIllIbTkoKmdvqmYMblh09baxrLU+Fp9WxHDcv3740gUYiyEfugPb9C/
+ Q8oiPCfgNThRgApKhHsF4t6rDROWmHTYhOSxHuEBkepjr++/Yd6C+bu2/bazEYxOjduh758H+EzvK4VP
+ I1GhEPqhv1AEnmBcxocHqx+8CO8Si2jygD5eIjDjCR0mDxsNqwIT1mGDhRiEwbDeUi10y8+dMGT7mrUb
+ 08SNUalx9SpfFeBrvX8lfBGJspBl6X529xeKcDgxPjzgAy/4XdpMgD4UCaH1cVkYOkwwx7wtv7RwZuEn
+ l065onZLTX0z8ogYlRrboDbfBVit92+FbwTEIASvfCLgDUTYE8wtxmPccD7Ay14oSp9l0v+bW9BXIPZD
+ 68dDh6WPWE2HTdEDRZ9eecvVdVu3N7Qgj4CRqbE7Ve+nAD/q/QdhjYAYvPNlTAThSP+Mw3iEbBhKoRf6
+ hgKGq6KXTWKNmPPEtfUJHZbAj4rvK1454vay+jBk4u8jU2P+UN31wi/R82c910WCvtcT7+ANi2DCE06s
+ UozDeHEveC6wvF+5+zS5Oz2eLnjy4qYw9rFCk/WLphetGH3H2IZs5CkbkbruT7XbHGCT3llaEbVWwBuI
+ wBOEExOcVcqhFPeC54LD6IE0d/1vfyFcOnGTw4fljM2KmHxfU3zJBeUX1bZGnvIJqZt2nThpwE7jpMqB
+ DUK9UCfUDqgs/X1ARen2ARWDagZWDNo2sOLkLaUTT94sbDxsUjdCDC8wLuPDwysS/FjiWVL3RwA7b3z1
+ iYcPm03VqWWnbd3w6/bEmM9FVK51zrt56BbGExg3HkbhPOiOgH6BgDD+SdJYylg6F/YZ03fd59+u+SdX
+ EvnUO2/qEAQwmRHA+PCAD4b1PGDB6Y+AMyIBTAwLIDNsEnBI5WFfvb5oQdMmlQ+5XNoGApgHoQB4hRP5
+ DAScJsRXoFDAu8eW9/sxvlHlQqS9dWICWEDsgbiA0xFwXGseUPmiiyZfVtNeQm1t1wYPHIeAbrnMgX2m
+ 71M97ckZf7SVTHvqRwI8ibPNgW4IIIlL2oXZwsNNrKr7lB7fvf1B1d+5kNq8bUcjK1Z7cO6U870KxTcz
+ lvdwFSrxRnaPCpxCk/8n7QPpBK7nxF5r36pa3KqIa+4YuatzeZcdQl305L228w1dfhNqhG1dru/6q7Cp
+ y/iuvwjru447eK3wQ8nU/chiGS9pH4Af+8B9QqFzoWH6R7gTk8g5C222E+v70iMm9Fz35uKFWUWMSI2J
+ 78Qb1ZadmJTCO7FzInZistPWdmJ4eSe+PMyFeiesRBlzIdWt7lF+xLqn3ngp49Ia5EKkDsDESerIheIJ
+ HbkQJ7hcc6HeoQDyobtiYZQpH2JykTUuO+DWA1aX3TW+ISmdjrJRyJKROhN1EkdaHc9GSeTol/4z5UEO
+ n2mET5OAKKUeEoRRpoyUmAxPYst0d7HyrBvOqfls1epmu3SW8wDEfbAhgeM8YPLZzgPhqWxo0omsOPJC
+ eJi3F7wrk5f4RObjJIOv6DWx9/o5857+KzhS1uk7BxcD0qTOPsiEJzKfA3wi8wGfcZ2FhtYvbiEg8gKX
+ WfFdOTzYODcKRRCzxO7HHW8rWXXtnWV1LKHRmZgTFysKT5+JsTjx7jMx7eNnYh8n42di0p1B2W4lmAvl
+ AksqRzdmvA83PtiHVyq+B0rfSqSFzC5YfvqEwVsurhwWv5XwjQQeQ7BvJXxP5GNkSN7Jm1eeCrVrdgWf
+ dLHVSZXuFsJQ8vk4LoI8hYwR1zP5sCQWXVI8uQOhwuEkBKRtcerTjvb0E94LMU78XohDV6esF1tNcbU7
+ veDEk0kEscku7WsWCPieCFLh7RxEDb5T7nsgXzHSD/3RbxJ5rjlb3Mo1W4VaKJtbcJQazQpEOJyYE74b
+ 5cBtIVjQ14yIAeH9qL/5OpH6Ju7bOPr1PRDjseNy2Dq6TZe7gSeOUWO2bHuCTn1fhIvjQohfSIU31BA1
+ +E459XwXSs5FP/Tn+x+TJwrStw/tEhCtTAeqk0rBE9s31UxuBrQQXE8IYE3AOTYOlzlUQuL0x1JJ/ywg
+ NwoH5fUHjsATe6uzywRft+NaNjsGZGAmOa5HDIcOiAFEGf5GOfWoTzsTpz/65Udutndr5LPOgaTG6pTJ
+ PVLAG/wYEIvhcsQk/Z3MfxvjacLUoz7taG/ioxgjF+KJG1muDSMhI/T0bQYutxgsCbFMoNykaYdXMUqb
+ iOclIAitfTXwicJwwWcKJrx/EDT8jXKSMdqcJOybq+ESoyKfxglLL5tgT+EE4UxhaATe+UZZi80oHw6t
+ /pk1n87/j7Z7vIB/AbqI4PWoWfWuAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="Color">
+ <value>Color</value>
+ </data>
+ <data name="Abort">
+ <value>Abort</value>
+ </data>
+ <data name="folder_arrow_up" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAB6pJREFUaEO9mQtQ
+ lFUUx/+77LJP3o32HMvUIqxMe/hEGlHTMTVSS53M8UFoTWmDItSWGiMWkQgLu6CwmbtLigpJVgrjjFkO
+ A6mlkZQUmNRMNb2cqWzSbucu7bIL34tlF2eu7Hzf/b57fvece8//nk/FGMNA/1NFq25kl1hnSMblAAPZ
+ MBGzkIvvMRuFBBDZ37EH1njAiJdwEmfA8Am159GIB/BgfyAGFmABbDhNhnMAb3PjF8zBdvKGLhiQAQPA
+ BMxALX4PMN4LcZKAMj3emNJXiAEBoNk1wEJB4z/zQr/34Fekoagv3hgYgAUo7RU6YjDcG1lowlikKvFG
+ 2AEodKajRiR0pDxSTd54FFbyhl4KpM8A9EKtVouhd9+Nh1NSsOKmm3AXXVMLDcIHp9Bplg0dMZBT5I1s
+ 8sY4TBODEASggQcnJWHGtGlYt3Qp3sjMhPOVV3B42zacdjjQeewY/m5rA+vsBPvwQ1xJTcVTggALaAZ7
+ 7jpy60Do/n78hnko4Wup5zgegMREjFm5EuUFBThhteLrAwdw6dNPwb77TlnLycG7vV48HlNxgAYOxmD+
+ DIFrDtDfreig3NGADDiQiPm9xiEqVW4uzis1VqjfoUP49frrMdz7ck/o5AQXOje4wZ6qAMvfDbavBmzY
+ MKRIroHbb8e9J07gSn8A+LOvvYYTNBHuwkIcnfAcfgaP3yBmf62t2+vffAM2bhxWSAKMHYsVFy4oCxUl
+ kG9/ABZd62f8cbDBlWBG/2sSYBvKA22ZORPZkgBjxmBea2toAPiMjcwAG0VGpFEYrH8TrKoOjF+3VoFp
+ 6+W98lxZoC2LF+NVSYARI/DgKXK3ktmV6/Pll2BSkzGlSB4gvQfAqlWw+62tG0aP1syfO1dnWb3aYEtO
+ 1i6jTR0jjh7t/xqQg+P391J46Q9JQyy2gn1A/RwONaus1LCsLF3Hli2mY0VF5ra6upg/WlvjabKvYR0d
+ CWzyZG06P1MkVFfjNyUGhKLPJFqkUos7ZZOGNTfHUY5J8Bgq1urrYy/HxqqGcwC13Y7OUBjX8x0tLWB1
+ tAbeektNTcN27dKxaZYISYDZtkhJw71AxcXm8zwFeBLZ9u1oDRagowOMMjNzu9XM6dRQi2S7d+upGdnB
+ g9Hs88+7XO5thU4zowwhCjG9VBlAbq6p3nMc5v+9/jqa5QA++wyspkZFhkZQ01LTMZfLyPbsMbPGxlh2
+ 8aK0y70ALS3xLHaXOEByiVaRB9auNZT7APLycFQI4OxZMLtdz6qqTKy+Poa1tSkzUip2+b17SzSiHrif
+ 7sk9z++npelyfAAbN+KgEMD+/Sraw0NjtL9RC206UYC7rBGyAGfOxLOkpIipPoDsbLiEAHi4KJmNvvbZ
+ VGHyiDWh3WhEsVp2TKcz+kdawCYfwJo1sAsDKFtQfQVobIpl+reFAYYoACgoMDf7khv/kZ6OfGEAg+xs
+ 9NV4b//EIuHtNKlY3usWi7E6AGDhQrzcE4ALvL17TWEDSBZZyJOs8os4PV3v00eebZQU3/M9ARoawE6d
+ igsbwOyySME1MFsmD1y4kMCmTNGuDPDA+PFY9u23gYKOJ6Zgw0PJc09WCO9ES216yXEbGmIvx8WphgYA
+ 0JEyle/5/l7gyUqJIcH2yXDoe3uAkuWLFUbJcW22qPP+8toTQqRIbzt+HFcDAXRhBVi6s7cHzHvBmmiH
+ kpqUrVu7JESAB2hPvaa2NlCRut3SMxHszHufe7y8N4CSLLx+vbFMCCBi585uRcp1z+HD0WH1wBx770W8
+ rFQ6/jn8Y4/pNvQC4BdKSroVaXW1irW3h15C+HstlURbQCYmRevYFyU5aWfPxrNRozQBBWBfLFE1wadI
+ XS75vbi/IXQnJSx/gJspA/NTltR73e7on3oWt3wAVBbxKVKXKzwSwmscF4iD7KpuANJFq2S2T/4sHSub
+ BCtz/CLVdN7x7kIuV/gkBDfk/YYYpnqvWwsNK1UrkuqbN5v2iAJYLHBygPZ2LiHMYV3AWypJjVLp0hNC
+ jWCWSmU73tNPG/JEAdatg40DHDkCdvp0+CQE98AzOwy+8BldqFF0muMSYvr0yOWiAKtXdylSlyu8EoID
+ zPs/B0RQoaukWpm3Gxpirl53nfpmUYAnnoClCyC8EoIDTCzvOlJOLlA+Vnm5+QehCp1vF5ozB2s4gNMZ
+ XgnBAYba1cy0D2z/Eelkee5cPJVlYv4qLY1qz8gwuCQBJk7Esi4AZQsq2DzQ1BTHoqn6tr6ia6fjhQIq
+ GPxTVhZ1kU5aTRs3mmqefdZQMn++7oUJE7Rpej2ulayNem+OHImH6GuLp/oQrHFiz/EF+NFHsVcdjqgf
+ snMMX4xaEPE1lUV2LFqk25SSol0yaJDqVrHPVFLG+87E/IfBgDtKS1X/ymVDMSN5KZCXBKuqoi4VFprP
+ 8cJTZqZx15Il+jw6gKwaMkR9T18+n8oZHqBGPSTAoPx8zd9ys8/1SG1t9GWr1XQxL8/0cVaWsWr5cn0B
+ bXFrExMjkuk9UUoHD0W/bl0NaPLzdX9ygK++SqAKccwVu938c0GBscViMdTRObR41qzIDSSmZnHYUAwe
+ incEfKWcO1f7xiOP6F6+7z7NoshI3BJsXIbCMKXv+A8bjZ++/ZSOlAAAAABJRU5ErkJggg==
+</value>
+ </data>
+ <data name="mbox_question.png" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAABcQwAA
+ XEMBOS4mtwAAA1pJREFUaEPtl11oUmEYx/2aigx30ag2XXURYQwTkiBDMaSrugi61CBidhVaKUF4M6Iy
+ ugga9kHBRqMkKiq6ihYYMYqtj6tiUBch0UAq4oSY0Nbs/4xz4PBybJ4v5wGFP8ej7/ue/+99nvO872tu
+ NBomQ38IwMgytPnl7DHy7HcBOiF63RQSRwHlOAaN9fb2vnW5XN+dTudvfK95vd5v4XD4/ejo6KNqtZpD
+ n4PQdsiqNoqaRACmh6E3EC0q/5Xb7ebS6fRYxwDAcADiVjIu/t9sNjcSicQsIE5DATVRUBUBmLJAH+SY
+ F7fN5XLPYJ6isVcphFqA/UrNUz+8H3WO467wEDuVQKgFuMEC2O32xWQy+XJmZuZmpVK5Vi6XrxeLxfs+
+ n++rFGyhUHjMA5zHtUcuhFqAV6ypeDz+mjd0Edc9UD/kHBkZGUTbRbZ9KpV6wbenVBpuN8BH1tDU1NRt
+ 3tA+psT2oO0ftn0mk3kuAoi2G2BWbGhoaOiHyMwgA3BAKoUmJiYeiPqE2w0QHRgYqGDRqvn9/i+lUumW
+ FACM26E5FqCvr69Wr9cLqwbAz1YWVxLlsKBTzOxfZc1bLJalfD7/hOm3pa0R4B+2GVcSmaZKchRaLxiB
+ 8ROseZvNtoBtxVPG/Fncy95aqKpCK80WjFPe/xUDYH/E3cOHMX8J97Q3ku1HdodWHwLTG6FfYvMOh+Pn
+ 9PT0JGOeyu2OVsdl2+kJcJdNHabi0PtyDtqk1Dz10wUAxtdAC2IA2jZI5PxaNeb1BIiysx8MBj+rrThS
+ sHpFYBsLkM1mS4YBWA6tyXSHIGjvHwqFPtVqtcsiACq3mkyeJoM0M4NqGaQdKTPz9PIeMQQATNJ+SLxC
+ C99l73maAesaAf6hhxiIw7iXveK2FQC53w8dE4SD/EmPx7MLJpxapY4wjuYRgGk6J7+T2DrTqhwwAoBD
+ at/P/3a8C8CUXz1SqGkEIpEIHV6i0AatIqEHgBXpMs+mkdVqXRofH3/IV6QLuHq0gNAcgF+Ft+LQMhmL
+ xeYESZy+dncsAG/M1mQRExazLsBytLUIY5MxLPj9TJMo0BFS9gFe6jl6AtDY66CEhBSdf1cDQO8J0jWF
+ dDev9zvQBWilwLRllloxorRNF0DpzGnVz/AR+AcOBL1o7Kmu0QAAAABJRU5ErkJggg==
+</value>
+ </data>
+ <data name="Yes">
+ <value>Yes</value>
+ </data>
+ <data name="Bri">
+ <value>Bri</value>
+ </data>
+ <data name="Cancel">
+ <value>Cancel</value>
+ </data>
+ <data name="window" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAfNJREFUaEPtmk8o
+ REEcxxe7J/9WbvawVxcpBzkhpUi5OLg67EWSFAclxcnJHrW5UFw4iDO2uMiKZ6WltSVa689jd7Nr/6j3
+ NbslntFr9Gqnec3W57avme98f7/vTO9NGQCb0L+CAJEhi49WgiYo4wUBneXlRQGklsTBbi/OeVpcAQ4p
+ gG+52aUDnBu+4mcTO+uQb2oBRKLGiQ+SQqPFFOrqhXpPdjOR6BvAC5l7jxTAyzVrO3AcPMHG4gJFKHrH
+ 1CcrCjCyThPOsvXZEeZwiCkdCpZ0Yxs6cLC/C9/kMEXw+opJgGeNbHJDNEqCTcA26rEJu44ddEkBkA7I
+ EvruIdnERhsY9xS6Sb2hkPm/uc1lmWJ0KwzM79FEcmwxeoZlnMKn4wLb7DHK63jwn3GtfZT4z0rw+q90
+ gNfKf41rcQfSaTzEYhT3uRxTjJbCHUMHEl7vny99VL+fScDE7AJc7laK8yeV6fnGlya4VLeO/uQg+z5g
+ VoBnbIa8Z22gUGKPTAKqn2phe7TpaHvtkALAWkLSAVlCJlOIewm9rq4i39xM8RwIMKUIdwFmN6LIewah
+ eJIiqmlMC3CpJRDS4jrC2ht7jJoVUIrnLX4WEuBVu3SgFHVuNIalHGh3OJCprEJKJMics+QTU7fQFz2K
+ N21EvqlSmPsn8UKYLq/+Q1MAAAAASUVORK5CYII=
+</value>
+ </data>
+ <data name="folder_star" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAACKZJREFUaEPVmg1M
+ lPcdx//3fs9z99yBEJt1WzqTrc2SZmk6a+K2LpvGtGE1jd1qRnWmXRpaK77WicU5GOCqgnIg4AsHihYq
+ xyFUsWoEkbM4DirH+/sd9waKAqIyqw3+f/s9d0B5u+OgGK4kv+S457k/38/v/3v7P4cAAMgP+ocH+CHb
+ vIqvWK3+HZrYmwPxuszb9XkFMIaqMyvXqT//+u8q4VQiq95VLTKuVRv9FuBGmKrUtIGjNVu4zNqPOcFY
+ oTVbuT+ZNnJ91R+qHvktQO02zlq/U0kbditpY7QihRfaFKMQNv1bEdf4L+WT+kglrfsHN+iXAHURSgmK
+ HGreo6Ct+xW07SBL2zRscruGvdyWyNLWBJa2fKqgCDPglwDo6Z/zwtuTWGo+zFBLOkM7M4dNy1DzUYZ2
+ pCDUAbZ3XgGwivwULaTqPdUKUzj3BwyZ36L4JejhDzpSUXAGQ22fyan9tJw68mTUqZdRhw5/z5FT6wk5
+ D9Iz5wDY+KRoCl/6B4pXGNeoG258qKK12zmMdSVtjWdpRxrjEujIldOuQhm9+aWU3rrktpsXpLT7nBuG
+ h7McY+5jeNViuBXWf6I8iMm9CR2yEtdWT1lGUZyYZcnzS5eSNaGhZOeWLUQTHU1yEhJIyeHDpCE7m/To
+ dKR/82ZyDe8dVz2mLIfvqX5p2sTd55OyGeO6/RDrChdePC+0p1hK71yT0DvXJbT3upj2lkvo7VI3iPMM
+ QpzCnTjCuPKCdwBWLIoV7DMsw2IXwEsvkRe3bSOavXvJ+eRkUnn8OLEbDOSxzUagq8uzNTcT+tpr5C++
+ 7ARWnNDGKCVticfYPiJHz6KHv5DCrWIJ3Lkuhv5qEQzUozUI4W6tmPZXiumdMolrZ/jQ4oHbk1nKJz2G
+ obZ6A+fqHYRhyMKsLNLrTai3a1FRJGcsAL97zz5LfrFiBQl9/32yIzKSaPbvJ7kpKaSsNEE60JbEgCVT
+ Do48Kdy8iOK/QvE1IrjfJoRBmwAG7QJ4YBbRe40i2meU0J4SKe36YngXMOxa9ilSGv6pHN11EhJC3p3O
+ 094AjEZyf98+cjotjZzHnTPl5pJbFRXkid0+eeec+J75lBysWTJwFri932sUw71mIfzPIYBHfQQe3yXw
+ 8KaQPugQ0bsm3AWDhHYXyaj9c1dCx0/cbbJmDYmYrfdn+jmbSQgdRxiwnpRBVyECXJFAX5UI7rUK4WG3
+ AL4dJDD0LYFHvQI62CmkAxhKfG7wYYRV6gkm8/JJAKtWkc0zFTKb+61GETTvY6HjEAJMuwMCTzvQgxXs
+ x+NCdvlyEjYbQTP5jOWaCOoiFdAUy0K7hoHO4RzonioHMJQemIWYzCLaWyGht4ql4CyU4a7JoSNVDpgD
+ XzXsUkpGIMjLL5O3LBbv1WYmYife21EshhvrOajdpoTGKAW0JjBgPioHezbmwbgqJMYqhNYggrs1YujD
+ 3LhdJoHuL6WY8DKEZqAtiYXhKpQ4CrBwIfl1dfXTA2i+IoKyoxK4+KkMru5loPIACw0pfCViwJ4rh65z
+ MkxmKdw2YEX677CVS6CnVArdF9D7Z2SAfQCwDwBfgvlSPNwHVo+cJn9SXEwefh8vO50EsBrB6dMCyMoS
+ o0nhJG75iRMs6HQcVFUtAKczGHvKd2a9ogLsxIDNDBNaBt3nsaxechsvnAfDTgy2IhYcTYHQVhkIcX+T
+ R2An/j124mXYiZeOALBY+np8AWhqIlBUJEBhIhQpQZPhawbFKqCkJAAslqBxIscKnvi686IaYxrzIYMB
+ HBcAq4wrVHjROAsBzkIuQOslzrVmQYG6H3tM4KQqxL+Rnk7MUwHk5YlQoBSN96YCF1FBXd0Cn0V6AzCf
+ VQNOo4DTKOA0ChZ0hL1cDZ0nEUrL5wkDOI2CtUTt+nupqarqqTq+a5RITSU1UwMo5kTsVCBtOjXgeYBP
+ SmjXKsHR6naMvQ7D5RCLyc4CngfAWh7oej8uTnnGI4BGQ65NBGhpIXARt9mbF7/PtZasAKxMHLSdUoPT
+ Pj70bF8HQmOMEnD4A5vJDbZxI3PAIwDOKhcmApw7J4TOTt9jeqYwzRmB0H7e7d2prLN8AZi2cOAwB7kK
+ QEiIbINHgNhYopsIkJ8veWre5wU7bdM7x2Jwe7+8PHDomWfIix4Bdu0iGRMB9FgNZurVp3W/VqvqxAo0
+ 5aMXVxLzZ4HJAKzfAMTHK0s9nTlcAGFhJHYsgMNBID/fXX/9wSIj2eNeAfDYuGMsgMEggOrquan3c+GA
+ devkUV4B8Fi4fixAfr7ILzzPw7e0BMGSJdJVXgFeeYX8deypLA+Pe3PhublYIz8/YAATOMArwHPPkd/U
+ 1X03ker1OGD5SfwnJ3O13h4auJIYf35WVkYej4SRXv/0RoiZOiYmRlnoC4AqP9/9ZKKxkcDlywF+swPh
+ 4QrNtAD8DVotsfIAZ88KwWr1j/LpcATDypWyTT4B4GOReh4gL0/sN943GAKfLFok/ZVPAElJ5DoPoNP5
+ zwiRmqrs8zRCjJ6JR17gc89LPIBe7z8jRGwsa/HmfVcBGrlhzx6i55+mFRT4zwixc6f8rM8Au3eTE1ev
+ CqCmZn5GCJstGAyGgG+ys1Xm9HTu6sGD3Km33/bcgSeF0Pbt5BB/Bp5pnZ7J/XxVMRoXDOXkqJzHjnEV
+ Go1SHxWlSAwLYz5etky6Ch/p/2g6j0+8PhpC69eT/+j1czNCmPAYqNer+rVarjYxkSuKjlYe/ugj+a7X
+ X5euDQ4mz2NiimYq1OsowV9cu5Z8otMxPu9AY2MQ9gz1NxkZnCUpSVkSE6M4Hh7Oxr35puyDF16QLEaR
+ Xr+gnnOAN94g4Xl540eI9vYg/mA/lJmpuJ2WpjBhVdBt3apIWL2a2bp4sWwFilTPlZDZrjMaQvgtzR8j
+ IpjOhATWsGMHk/7OO/LIV1+V/nk2cTlbMbP53Lz+q8FsBHtM4rlYbD7W+D9MzRR6eEGuxwAAAABJRU5E
+ rkJggg==
+</value>
+ </data>
+ <data name="errorProvider.ico" type="System.Drawing.Icon, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ AAABAAEAEBAAAAAAAABoAwAAFgAAACgAAAAQAAAAIAAAAAEAGAAAAAAAQAMAAAAAAAAAAAAAAAAAAAAA
+ AAD////////////////////8/v7F/fuc/PiW+/ix/Prt/v3/////////////////////////////////
+ //+a/Pgl+PEP+PAP+PAP+PAP+PAT+PBn+vXp/v3////////////////////6/v5a+vQP+PAP+PAP+PAP
+ +PAP+PAP+PAP+PAP+PAl+PHU/fz///////////////9v+vYP+PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP
+ +PAP+PAo+PHt/v3////////M/fsP+PAP+PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP+PAP+PAP+PBx+vb/
+ //////9p+vUP+PAP+PAP+PAP+PAP+PAP+PAP+PAP+PAP+PAP+PAP+PAP+PAZ+PD2/v7///8t+PEP+PAP
+ +PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP+PAP+PAP+PAP+PDD/fv///8V+PAP+PAP+PAP+PAP+PAP+PAA
+ AAAAAAAP+PAP+PAP+PAP+PAP+PAP+PCs/Pn///8f+PEP+PAP+PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP
+ +PAP+PAP+PAP+PC1/Pr///9K+fMP+PAP+PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP+PAP+PAP+PAP+PDg
+ /v3///+c/PgP+PAP+PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP+PAP+PAP+PBB+fP////////4/v4v+PIP
+ +PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP+PAP+PAP+PC+/fr////////////Q/fwc+PAP+PAP+PAP+PAP
+ +PAP+PAP+PAP+PAP+PAP+PCC+/f////////////////////T/fw1+fIP+PAP+PAP+PAP+PAP+PAP+PAX
+ +PCW+/j////////////////////////////7/v6p/Plc+vQy+fIt+PFI+fOH+/fm/v3/////////////
+ //////////////////////////////////////////////////////////////////8AAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+</value>
+ </data>
+</root> \ No newline at end of file
diff --git a/mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.resources.prebuilt b/mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.resources.prebuilt
new file mode 100644
index 00000000000..b116fd0683a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.resources.prebuilt
Binary files differ
diff --git a/mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.resx b/mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.resx
new file mode 100644
index 00000000000..3102f93b4cb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/resources/System.Windows.Forms.resx
@@ -0,0 +1,844 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 1.3
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">1.3</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1">this is my long string</data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ [base64 mime encoded serialized .NET Framework object]
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ [base64 mime encoded string representing a byte array form of the .NET Framework object]
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used forserialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>1.3</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="monitor-planet" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAD6JJREFUaEPVmXdU
+ VNfaxo/GfBo1GuONuUmMJTHGllhCchV74VOxtxgrKkhVFCkWlEAAEQQB6SoggrRh6EMZemfoAlKkqiBg
+ A0VABH3uew5CBtCgN/pHZq1nTTtzzvPbb9l7n+kHgPlHP1iAf7L+0ea57HnT0S8tLR1cWFi4Li8v74Iw
+ WZRgGO5RrRXk0awf4HffIyg+OzQ03Cc4OPiAv7//mDc957s4rk+AysrKcQXFpS7qwX7PJnvK4XOfORgX
+ NAUTQydhsnAyJgknYYJgGr7ykcTXHqsh6ayF85f5Oa6urmvehcG+zvFagKqqqsGFZcVWOwU27R86zsZI
+ 388xIWQCZkXMwoKYBZCKk8KK+BVYHr8cS2KXYHbUbEwNn4rRwaPx0dWxGGu/E7oOVhm2trYz+jLxd75/
+ JQCZH+eeGVU83GktGPdBGBU4ClPCpmB+zHysTVyL7anbIZsuC4UMBchnyEMmTQabkzdzUBKREhgnGIeB
+ /IFgHMdhkdWhNjMzs23/i8mV50uGTTtwRWLinvN7f1RwsJhxwCVohrpvyiyNwOwZshZJr6wBMj/9ckxR
+ Qz/b6WB4DD7x/wSTwiZhYcxCziRrWuuaFvSu6+F04WkYFBjgZN5JHMo+hN2i3ZBOkOYg2Ej04/UD4zIU
+ X+nJw8DA4ORLiH52SbWjNGzD58qe9pBXNPGyUTIPDFGxjkhRsY3KVrGLLlSxj61QtourOWwf/cDQPemJ
+ e0zBC9GNu7jb2Ib258CLF4CdnV1pLwAy/0V4enXNB7P5YFyHYoDPAIwVjOXSY0PSBihlKkEnXweWNyzh
+ VOGEqzev4krlFdiX2cOk0AR6+frQTD2Og2GaUA/ShXaQOfQEF2Ho6Q8Lj2Q4ByXfdRKk1TgGJt33jkhr
+ jM8ueV5eU4/m1uecKXG1tDxFUVExQkPD4OPD7xKPx4eb21U4Ojreovmrf1cKkfkBafm3M4ctuA5mVBwY
+ q18wzG8YJodNxrK4ZVyaHM89jvMl5+F5yxPCWiES7iUg9m4sknOSkZ6Xhbi0ZCRmiFBYUo6HDY1do9XT
+ HPu+ra0dFRWViI6OAZ/v2yUfn47XQUEC5Obmo7HxSS849nsvL+8aAhjSBUDdRvHn/WVghoSCmV8JRm8/
+ RgaMxHThdKxOXM2ljn6BPpwrnBFeE47chlzcarqFksYSxKXG4TmZ6qnqOzVITEqGr58/fH39OPH5Hc8B
+ AYHIyMjCw4f1vQy+Clj8MxZAIBA8IIDPOAAy/7GFW0kD82EAmO8ywPx/NZgDzvjM7wvMjJjJFa5ypjKX
+ 866Vroipi+GMt7S3oK6lDsL4CLQ8A4SRsfDhk1nWsF8AUlJSUVtb99YG+wLgUZQiY+IbCWAMB1BSUqL6
+ 5TwyzviCmX0DzOoaML/exKdXJbkIrEpYxXWbP67/AcdyR4TWhCLrYRZKG0tR+KgQfKEvqu89hqs7j4tC
+ Xwb+7vee3r6IT8lsI4DvOYCY1OJk5qNgMB/4g1lBo7+hDsy2+xhqK4fvQ7/n+vxO0U6u+5wrPge3SjcI
+ bicg6nYehOUFuBIqRGJ6Ljx9Bbjf0MRF42kb0Ep61k75Tp2D7R7vCs7T2w8p2UUYMmToLIaWB6MOW914
+ wY3+iIiO0d9yF8zuB+h/oByjA2bil8hfuDTan7EfJ/JOwPS6GxySWuCc1ArH2Kew8a+Eu28oYkTXkZJV
+ gPpm4FEL8Pgp0Eh60go0kZoJrAuOwP5XOE+eH9Lyb+KbCROXMrm5uVILD1LasACfRoJZWwtm6z0wex+C
+ UX6EoQ6a+C70O8yLnof1SeuxL30f1DKNoC3yhm5qIHTSXOm1FRzc3FBQ1QQ3nxDUNgJ1pHtPgPukB03A
+ QxIL1kBgr4WjiHGRewnHRe1l3xdPOw8CyKR5YeqPMzcxWVlZu6bJFHcAsCm0hiLQCaDyCMyxWnzqs4DW
+ PhMxJ2oOt3zYkrIFu0S7sDdtL/ak7cG21G0wv2yHG/cAG2cf3KwHbpFuNwBVpOpHQM1joJbEgt3tCUdg
+ r4PrFrWXKXnVyw85lU8w82fJfYxIJNL8Vr6qA4DVgtKuFGIUCOBwI5g/sjDEYxE3qf0Q/gM3sbEzM1sb
+ i2MXc9HRtTuN/BrA8pIPB1JCKr0PlD0AykkVD4FKEgdG6gS78zo4ihgXOTG4xxQ9NiWvePgh985zSMxZ
+ qMYkJSUdmXaUUobx6wCYktVVxMzeejBKLyF0RejvsghDfIdwa6PxgvH4NuRbbt3zeeDnUDE9jKwqwPQC
+ H3kEwsJcrwUK6oBCUtFdoJjEwREYC8eBkViwm51wYlHrBUfpyKalk7s/sqqBOQuXH2fi4uK2LzaitBmT
+ 1AEwlCayldSJNlEhb7/fUQvyDR0gahSdS8u4NVJPbTPYhZSK5zjjwEfGbSCTYFigbLpQDunaHSCXoDg4
+ AuuEKyK4LrDOqPWE65GSF9z8IboJLFy+/ncmMjJyyeZz5WCWi6XRl/EdtcBCsPWw4wHXlRgZgjkSCMbr
+ o14A8/QWgp9QBn07PpIqgORKIIWUShdiL5Z2C0gnsF5wBNYJ1xU1AuwVNTE4e7cgxJU+x9LVvxkyYWFh
+ w/WcU9oYFZoQJoj+rIXJlErSd8Cso660keYFFmYziX22XdALYLzhdJg4BsHIMRQhec2IprViLCmuDIgv
+ BxJIiQTWBUdQHByB9YTrFjUC7JmSl7wjEZzTiOUb95hyE5k3PyBksGorpUo7mJFRHRD9qSamXQMjRZFh
+ J7eVBMMCsc/aR3sBDNfeApXjlnAQFMIhpBChRUBYMS0vWN0AIklRJUA0KYaFI7BecBQxLnJicOkE2DNq
+ lwNT4JFUB+mtCuc5AB6PJ7NMn+YCNgq7msAMolm5syt9QpObBLXZRbfBLCYtukV14dQdwJHW/lL+2KWk
+ B6+MZpyyD4N/PhBwHQgkBRUAwSTi6gAjhb+Ei2DhCIqDI7BecOJRe5mSbmHXcEFYgVU7DtpzAO7u7h9a
+ XuKVDzz4rANiPeX94JA/IfpRRP6dAGZ6AZj/UL3MzQPj0/9PCDUFMJMKsW7bMXhfA9TN/eCVA+41Lxfw
+ IfHzAF+SHwv2Ei6I4FgwClpvOAIThxMWtsLcIx4nLXnQOOsOl6RHWCuj4dS1nKYNwsb1+lQDLACr/W00
+ 8rQ3+IBWqJ3RYJ/7UWp9RHBugzsATKeAGRbEHbd0hQrcsoBDpn64kgG4ZoJ7f5Xkng14kDwJTByOT3Ac
+ GEk8agF57TDzFEHzHA/qZjxoWgbCNqKWO9elhMc4fJZfM1d6x9lue2Ira1v/qVq0J+iEYJ9lmsFMTO8O
+ wYJc+pQgBlFEqB5eAv5nriyc0gEVEz9cFNGFSI5p1LdJzvT5ZZILgV0hMHE4Fswj+wWMiezQWR5UTUg0
+ CKbBt7jfOaW9gK5rZssOTaus5TvUnSf/vESOVqIf99pSWlhYDDEwOZ/z5WFqoeIQnSCr6HNJqpVJmdSJ
+ vgajKN2xAfqa5pDpufh+/kGYR9RD4Yw/rGjLbUOyTab9K8k+BXBIBS6QOuEMvAuhfMYHikY8KJ7hw4BX
+ wh3Dyiz8PmT1rt5cK/9HsMTSXw3+9eX4H151Y6DXXQkjI6PRJ/RMiieqFfWGEIdyWUKbHkozsc8+k7aC
+ mnU0ZE/7wzSOTJDM4wGLBFpikHS8y7Hf0Bf79HmQNfDBiSv5sEoEJ8u4dqhax7cu23uufu46BZdvfpi7
+ jUZ5UF93M155W0VHR2fY8eMnBPPVwjBAhdprz2iw742ce30+aHMM1imbQf5sOHRDmnGMV41d+tSddH2w
+ W88HahcycTbmOQfG6pRP1Yv1Rxwf/bz5bP3XSx3ah60sx7AVJe1k/F99Ge/8/rU3trS0tPqr0WPfQe0H
+ 05SiMED56V9HhKD6y9VDYpUCjnlXY/NxNyhaJcMgog1G0eCkH96KvWdCm1bK6Ves36XRNHqecfvYnS0Y
+ t7u9S6PXF7QSwIi/DdB5AkVFxWFycnK6O2X2VyyUOYtvZCMxUu46hshXY4DSEwyUv4uP9xVh5M5YjF9j
+ jMm/SL3QiwA6pepS8mKzhl37DnXjdo0zlgi7lovrDQ1wdA/Esh22mKHU1k2Tfs15SgDD3xmA+Im2bt06
+ ZdOmTepr1661lZaW9peSkkpdvHixcP78+Zdnz55tICEhsfyriT9VbdHhP910yPSZhukluAqjkPfwIWda
+ XI5egdiv6YhF6s+6SVIuE0rHjqVLrVun8CYQfd7cfZOTdB4zb+nS1crHtOuSKyt7Ge4J4MQPxCkjV2zQ
+ ae2mlarpyKypgfDatfZ1v/3mRNH4v7/y8M4A1mzdetArMupJT6Pi7/Pq65F57x5EtbVwFIRCz+gC9ho/
+ 7abNmimIpQEQ0e2Y1Dt3aHmilPhX3eidANAFPtDUN6h5nflrlEJpdXVIqKpCFJkLLS2DV1YWlFS1oWbV
+ 0k0yJxIQUFCAsLIyRN+8ifCiIkhISmq+LgrvBEBi3rzd8TduvDJt2BFPrK5GJBkXlJSAT+Y8qJCvEIDa
+ UX0o66VAz6m5S4q60XDJzIJnbh78CgsRUlKKrfIKtFp69V9h7wRg8Urpq/mUHj0jwJpnR11YXo4AGknW
+ 1OXMTNinptLElgBDa2fsUbXEea+mLqkZCnE+MREXRCK4EKR3Xj5ktY7R7YD3CDDtx1maTv6B3QByHjxA
+ MuUwO/KBxcWceeeMDNgkJ8M0Nhb6QiGOWzhAWescrgQ96dKJs2EwjIjEubg42KWkcNHYuGsfbTzfIwDV
+ wEClI0ebxCPQOfrhlMu+BYVwy87hRtU8Pp4zqB0sgKLxOWjoWCIwurFL2sY8nAoJgVFkFM4nJOLERWq1
+ S1a6vVcA9uQbN+700je1RjrlOwvSCcAWoziABQGcJoCTAgHkLK2hpK6L8Nga6Fl40sLOGgr2F6ATEooz
+ UVFQt7SB1knj5jFjJkx97wAjRowYvn27Qujps7bwiopBVwrRfwDiKWRLKWQWG0dRiOBGeo+BMRTMraDp
+ 74/jQcH4nf7QOOXnB2UdQxiZXLwnJbXmLye0d1LEXQsraqcbNmy3u+wiaDWzcsYZm4vwIsPhVMT+XBHn
+ ckXsQEXMFioLYhwdzaWLPhlXNjaD1mlzWDt4019SNoWSkguW9DWRvlOAzov99NOc9QoKR9ytrT2qrnoI
+ YWLhiNMWF6FPRatrYQ9tC1ucOGcNbVMbnDKxwe/GNnTMZfrTI6Xt6NEzotWrfzs9bty4f/dlvteG5k1+
+ 8DbHsKtKKan1p1RVT/GOHTOK0dW1yDM3d6nm8WKfOjsHNxga2padOmWapqFhELJnz0HHGTN+WvU253/v
+ AK/cQTHMYAKbSPqC1O9tDfc8/r2k0N819Ta//8cD/Bf1OK6O+/e5egAAAABJRU5ErkJggg==
+</value>
+ </data>
+ <data name="folder_arrow_up" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAB6pJREFUaEO9mQtQ
+ lFUUx/+77LJP3o32HMvUIqxMe/hEGlHTMTVSS53M8UFoTWmDItSWGiMWkQgLu6CwmbtLigpJVgrjjFkO
+ A6mlkZQUmNRMNb2cqWzSbucu7bIL34tlF2eu7Hzf/b57fvece8//nk/FGMNA/1NFq25kl1hnSMblAAPZ
+ MBGzkIvvMRuFBBDZ37EH1njAiJdwEmfA8Am159GIB/BgfyAGFmABbDhNhnMAb3PjF8zBdvKGLhiQAQPA
+ BMxALX4PMN4LcZKAMj3emNJXiAEBoNk1wEJB4z/zQr/34Fekoagv3hgYgAUo7RU6YjDcG1lowlikKvFG
+ 2AEodKajRiR0pDxSTd54FFbyhl4KpM8A9EKtVouhd9+Nh1NSsOKmm3AXXVMLDcIHp9Bplg0dMZBT5I1s
+ 8sY4TBODEASggQcnJWHGtGlYt3Qp3sjMhPOVV3B42zacdjjQeewY/m5rA+vsBPvwQ1xJTcVTggALaAZ7
+ 7jpy60Do/n78hnko4Wup5zgegMREjFm5EuUFBThhteLrAwdw6dNPwb77TlnLycG7vV48HlNxgAYOxmD+
+ DIFrDtDfreig3NGADDiQiPm9xiEqVW4uzis1VqjfoUP49frrMdz7ck/o5AQXOje4wZ6qAMvfDbavBmzY
+ MKRIroHbb8e9J07gSn8A+LOvvYYTNBHuwkIcnfAcfgaP3yBmf62t2+vffAM2bhxWSAKMHYsVFy4oCxUl
+ kG9/ABZd62f8cbDBlWBG/2sSYBvKA22ZORPZkgBjxmBea2toAPiMjcwAG0VGpFEYrH8TrKoOjF+3VoFp
+ 6+W98lxZoC2LF+NVSYARI/DgKXK3ktmV6/Pll2BSkzGlSB4gvQfAqlWw+62tG0aP1syfO1dnWb3aYEtO
+ 1i6jTR0jjh7t/xqQg+P391J46Q9JQyy2gn1A/RwONaus1LCsLF3Hli2mY0VF5ra6upg/WlvjabKvYR0d
+ CWzyZG06P1MkVFfjNyUGhKLPJFqkUos7ZZOGNTfHUY5J8Bgq1urrYy/HxqqGcwC13Y7OUBjX8x0tLWB1
+ tAbeektNTcN27dKxaZYISYDZtkhJw71AxcXm8zwFeBLZ9u1oDRagowOMMjNzu9XM6dRQi2S7d+upGdnB
+ g9Hs88+7XO5thU4zowwhCjG9VBlAbq6p3nMc5v+9/jqa5QA++wyspkZFhkZQ01LTMZfLyPbsMbPGxlh2
+ 8aK0y70ALS3xLHaXOEByiVaRB9auNZT7APLycFQI4OxZMLtdz6qqTKy+Poa1tSkzUip2+b17SzSiHrif
+ 7sk9z++npelyfAAbN+KgEMD+/Sraw0NjtL9RC206UYC7rBGyAGfOxLOkpIipPoDsbLiEAHi4KJmNvvbZ
+ VGHyiDWh3WhEsVp2TKcz+kdawCYfwJo1sAsDKFtQfQVobIpl+reFAYYoACgoMDf7khv/kZ6OfGEAg+xs
+ 9NV4b//EIuHtNKlY3usWi7E6AGDhQrzcE4ALvL17TWEDSBZZyJOs8os4PV3v00eebZQU3/M9ARoawE6d
+ igsbwOyySME1MFsmD1y4kMCmTNGuDPDA+PFY9u23gYKOJ6Zgw0PJc09WCO9ES216yXEbGmIvx8WphgYA
+ 0JEyle/5/l7gyUqJIcH2yXDoe3uAkuWLFUbJcW22qPP+8toTQqRIbzt+HFcDAXRhBVi6s7cHzHvBmmiH
+ kpqUrVu7JESAB2hPvaa2NlCRut3SMxHszHufe7y8N4CSLLx+vbFMCCBi585uRcp1z+HD0WH1wBx770W8
+ rFQ6/jn8Y4/pNvQC4BdKSroVaXW1irW3h15C+HstlURbQCYmRevYFyU5aWfPxrNRozQBBWBfLFE1wadI
+ XS75vbi/IXQnJSx/gJspA/NTltR73e7on3oWt3wAVBbxKVKXKzwSwmscF4iD7KpuANJFq2S2T/4sHSub
+ BCtz/CLVdN7x7kIuV/gkBDfk/YYYpnqvWwsNK1UrkuqbN5v2iAJYLHBygPZ2LiHMYV3AWypJjVLp0hNC
+ jWCWSmU73tNPG/JEAdatg40DHDkCdvp0+CQE98AzOwy+8BldqFF0muMSYvr0yOWiAKtXdylSlyu8EoID
+ zPs/B0RQoaukWpm3Gxpirl53nfpmUYAnnoClCyC8EoIDTCzvOlJOLlA+Vnm5+QehCp1vF5ozB2s4gNMZ
+ XgnBAYba1cy0D2z/Eelkee5cPJVlYv4qLY1qz8gwuCQBJk7Esi4AZQsq2DzQ1BTHoqn6tr6ia6fjhQIq
+ GPxTVhZ1kU5aTRs3mmqefdZQMn++7oUJE7Rpej2ulayNem+OHImH6GuLp/oQrHFiz/EF+NFHsVcdjqgf
+ snMMX4xaEPE1lUV2LFqk25SSol0yaJDqVrHPVFLG+87E/IfBgDtKS1X/ymVDMSN5KZCXBKuqoi4VFprP
+ 8cJTZqZx15Il+jw6gKwaMkR9T18+n8oZHqBGPSTAoPx8zd9ys8/1SG1t9GWr1XQxL8/0cVaWsWr5cn0B
+ bXFrExMjkuk9UUoHD0W/bl0NaPLzdX9ygK++SqAKccwVu938c0GBscViMdTRObR41qzIDSSmZnHYUAwe
+ incEfKWcO1f7xiOP6F6+7z7NoshI3BJsXIbCMKXv+A8bjZ++/ZSOlAAAAABJRU5ErkJggg==
+</value>
+ </data>
+ <data name="propertygrid_sort_category" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAIZJREFUOE+tUgkO
+ wCAI237ma3inP2NCwlIRdIuaEA+waQt3rZVLKVe2Wj7NaUIA2say+8jesW4AwE/+LHcLA+kAfMExBkTE
+ Uaj8Yx4g/UirZ9B5gK5KYdSR7E0lbANk9LELUwlSGK1fbTQABDOAT20UAJRi95Wh7xzMGNisTEd524PV
+ IGVSHnpbhD8B8EhyAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="Yes">
+ <value>Yes</value>
+ </data>
+ <data name="folder_with_paper" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALEwAA
+ CxMBAJqcGAAAD0tJREFUaEPFmQlUVFeaxx/IUguKRo12MkmnuxM98cwkJmPapMdsRpOMY5bOMn1cMsak
+ R4OmoygtoJSC7IqyFzsoigIqKEsha0GxF1XUvldRFEUJKGuxC9Q330NRcAFcMqlz/tz77rvvvf/vu+t7
+ WBG/wu8/N26k4m3fHhgYeHkQ/3R3d6vUSqUSywZQll/hkU/vlv9w3kdlHPVezoxP2Oty0DN0j6v3cXdv
+ 5h6v46f/6h92/hM3r7B1+9x93nFjeP7p6T31Kd1pv5u7raev3wpmXPwhoVLVfIlVdvNMZhWcyuRbQhIK
+ bgZEZpo9/KKvM3xOcv1PhHh5+vrORVk/pcc/+W0Q4K3UjMwglaHJ1Dk4NNLc2WPJ4aggIEkKgam9lqPx
+ 6rGUXPEoX6kfUjUZFYHBwQzUs0/+5KdwBzcG44M8NjsSjWk6BgZHe8csYB4dA1VzJ5wv0MAvx4VwmqWB
+ InUraMwD0D4wOCDV6eSJKSm/eAcG/uEpWHi8W7gxjtA9vLw/YBWXxqsajbqO/qGx3lGACXUOjoBY3wGJ
+ uUpIl5sg63oPcPuH4drwKHQMDI/WiiRV6Veydx4+6vv7x3Pw+FdZMY74zA9jxr2fkp55Xtfc1tbZP2Ix
+ DwNMVjcetwyOgbjvJpxp74OEG2bI6OwHXu8wtA9ZoLVnYLSaLy48nZK+3fXgkUWPb+cRrlyyZCmx5bvt
+ 9n6BJ9cnp1zMacUwd/VboHsApqgLj1uwvBYpIlt7IPl6H5y+3gtxbWZIwbzSPAo38Hzzjd6RGr6s2NM7
+ 4Nt9LgdtUFaPYOfRqyKAfcDx0E2sgnKWsaXX3NFjsXSaATp7p8rYMwbF7UOQ1NoLZ1Hx18zjSmwxw6lW
+ TFHKrhFo6x61NDZ3d1VzZUVo/hOU46O7msUVb7+9Zg7KISw88Uc2R8DSNnS0t3cBdJDqvqsbeKzvGANW
+ 6wCcudYLSaZeSEDFN99OTWaIQ53Gc+ev9YGo/Sa03BgZ0zV23Shm87Ijmac+ddrl/MwsLM2+yrp1G2wP
+ HvR9MSrq7LaiYj5bo+3sutEOcK9a2i2guj4KLNMgJDaZIRaVaETz9yjBaIYkLIvB85dN/SBqG4GWtpEx
+ taa972p+bWJsXOrH27btfHot8e033z3j7x/x+eXMUpFe3zfQ1gZA6vokmdosIGtB88ZBCNX3QGIj9ncU
+ sxG7jAEHcBMaNmArYD4JFYnlZ5v6IBrTi8Z+ULWOjt9PIr7WyWJVM48FRq/55uutFNTsI/2wmruc/rk8
+ MiKFIRG3DRubRiwt13CAolonSdI8Chca+8FP1wXp+j4Ib+iB6AbsKo1oVo/9H9NkVKweobA8HeuebOiG
+ U3icSJ5HTdxPwG++fjmDE4PmX0HNfrX+5BNiqZMT8QGDQfzv8ePEfiaT8E5KIiLOnLG9dO7cH4QX0reP
+ iOqlFkPDMJiMANdui9c4Aucb+oGpw2jr+iBI0wNxWow4HkfoeiAey2IbeiFKh90JlYD5EG03JDcgHNaJ
+ QqVgPhHPKZrGoKnh5oiAZ9KmnStkbvvO6aVPP/7Cbtpm2LaNsEGtuHKF8CgvJ7K5XIJbV0eIeDxCzecT
+ xvp6op3Pt+2rrfndWGnJARDV88GgG4UGvQXKdMNwVtsHcRo0qDFDuNoM0epeiMSUicfRWM5ERWM+BtNx
+ IVw8ppHj52+JzCdq+uCKbhBE+lHQqQaH6qqNmqT4bD9fb+aK/3hn7cMhXFwIKmpzZSVRo9MRoyYTAQ9T
+ Tc3LUMnxBBFPChLNKISpelAYRRUCKDGyyh6IwTRCiQBYHo3lEXhM5mPIOigyH4dpONaNwjx5HIb141UY
+ CBRLMwRi7RjoFMPDZUXqhuTEq64+R5ivvvynV+c8sCUCAwkHlLtIRCinMz9xrqryVSgp8IIqQTN4yzsh
+ TtEHEYpeCJbj7IL5QFk3xOBxFCpUgbMRppGYhiMIWRaNOibvHq8bosAA4LlEzAfgdXFyHOSKfriqHAaD
+ CsaVny2WJ0RlO//ixHj+gQBBQYQDioEA6tkANDVZQ13tCsi8cBSUkiE4I+uHBBlGD+WLJpKlfXBSisZk
+ GGk0dFLWAxEy7Dp4PhzTECkObrzGH+vGShEKy/wwf07aD0EkPB4Xy4dBL8c1BaWTjY3lZYqE/l4x+xHg
+ /lYICCDoKFcEUMwGgKyj01GBx30NcjPDoKLWCGniAQgXo2FJHxwX90Ak5iMkZghFg0wsC8d8CIpMmeLe
+ 8ToxYoS7XR4jQQhxNyRg3WLJTRALb4KophtKcmWQlV4yFnwsUPb37WujN2yw+2bVKhs6gtzdcnh5EXTU
+ XgSQzhaguRkhtFSoKFsFZQVxkF+hg1TBAIQK0bQAzQp6IITMC7EbiTDqIiybEFle3wP+FQbwKhTD0bwa
+ 8L9aDgFXi+BsfiHk518FTkEWcApToTSfOZqdccCYmrKxICT495G7d1NdNm+2nzsF4MABgobaIRQSotkC
+ kPVIiIYGKygrXg+c/NNQWN4Msbw+YPIxwrUdEFBhggC2DnzZcvAvlUBQqRCOlfLgWFkNRJVWgm/BZQjK
+ TYbg7CgIzwmGizlBcDXXD4pyD0Nx3gFLWeHu4drKLSZuzepCheLF2MrKBf5eXnRnFNkCd3+7dhFU1FYE
+ 4M8WwGgkoLGRBCBALLaFwrz/grxL53GGaoPAKgOcLFGAT1YpuKWmgVdKPHifDwOf1AA4lnYYQtP/CSGZ
+ P8MFzl7IER8AjuoQSJWHQa88Mq4GBQOUov0j/JqtbTVV/5qj1T4XYTItOlZRseCoiwvtRxT54eDub+tW
+ goL6CgFqZwPQ1ESATEZAaSkBOTkEZGVZQ1rqXEiKXwlxkT/B6WQGxFx2hXNl7sASMiBX4gEsySHIxzRP
+ ehBYUjcolbpDjtwVKuUHQSY/DDo5Gr8tuWAv1Fb+tZNd8kqVXr80tLl58XESoLx8AeOHHyj/jaJMAfjs
+ M8Ie9TEuWJVkt5gMoVAQUFNjBWy2NWrOuEpLbaCqyhYEAjsEsUdRQCKhAp+3CMpLXwdO8fdQXrUP2EI3
+ KJS7Q7HiIJSgilAT+XyFO1TLMfIyBmhkR3CmuSUpfzeI69fjvV5pq65aVGA0LgoizZPicBa44iD+FGU/
+ BWDNGsIW9RauwCV6/VQALtdq3DCXa39HdXUU7DZU7D40hL0rY5MDaLWLQCxYDZL67cAXu0IFmiRNTxYb
+ o16F5TLZYdBI0ThKI0YY3i40vxaU8pdALndsraubdwdAq10YlJ8/3/nNN23eQNlOAVi2jJiDegm3Ebkq
+ FWGZ3ALl5dZQWWk3xehk0/fmjUY6qFXPgETwHpr5O9RjVylTkBDuwEaQUhQZeTWa194x7w6y+p0gqPsQ
+ lIrnwGCYi4Gg3+Dx5rGxBU6Q0edynzmZmjpv1+LFVktQ923wyDnVsaCAuCAWEyNTAeZgd7GfNcAEkFKx
+ GFvhfYTYDQKZB3ButwJX7nEn6mTktTgupPwdUM99FzRqRyADQN4DAToQoGICgMWaHxQc7LBtyvR5z7Js
+ k5VFJOEmrn8qANnfKY8MYDQ6gAqjKeS9B1LBfuDJDoEE+7v6dtRJ86RE3O9BxP8zGl6I0/It87cBuuvr
+ 53InALKzHX18fenfTLcrtbp0iYiqqSG6JuZ4jYYYH6w83qMDkCYMhnkI8SJG9yOQCJ1BLWGMm74VeQYI
+ a7eAVPjvoNU8eyfykwDMCCAwGheOd6HLlx0PubnRNky7rU5LI4Krq4m2CYDaWgLN24JKRX3kFpgwYmic
+ B3LpC7h73QhK4R40fhjUOPeLeVtxsK9E84vR/NTJ4HYL9AsEDjIEOEkCXLzouH/nTsr70wKkpBABVVWE
+ kQQgFyocEyAS2WHT3v+A6Qby/QPbAUTCF0HC/xLk9U4grd8C9bwVoNfPf+i9dTraoFDooCYBmpsXHcMB
+ 7PTFF3arpgVITiY88Z1ANwGQn2+NAI8+gB8GJxL8EaorXkPzy2YMCgLcRAA9CaDXLzyekjJv2+uv2yyb
+ FiAxkXBHgPEdKdkCTxuAHBONGHWDwXHGLolrzKhE4mBC82FFRfNDExLmfrZ0qTW5iXv4LyaGcMa1YHxD
+ dwvABlvg8Qbwo3SxB9VtbKRZlEr6Dbl8QWxa2rwT4eEOax/4LjAZJzyccOJwiDoSwGAgoLDQFlfc3waA
+ HNg6Hb2Lz5+fgtH3DQx0eGfa6JMnT5wgfigrIyrJzRquyMDh2OGS/vgz0JO2gsFA76mtdcxkMh08PDzo
+ b8wI4OdHbMEdJlurvbXTlErtccv8ZDPQk0AggBkBWCEhdOeff6aumBEAvwd9zWYT+WT08/KsQKOhzDhb
+ PInBma5FgF4ud16Rvz9t51df2f9xRoD9+4mNJSVEllJpBbm51uPvvTM95Nc8j63fX1bmUOHjQ/129Wqb
+ JTMC7NhBrCsqIi6qVCSAzW8OgGvBQGYmrS4wkLL2hResaTMC/O1vxJrCQuIcCcBi2f5WAGPYqjdRQ2o1
+ rTMujlIdFUWZeQCTdOvWEatw+5B0C8DutwDAdxG6GdVsMjnI1GoHTlQUNSksjLp8xuiTFVauJJZlZBDh
+ PJ41VFRQcK/yq8xAGF16D8qEJlUGg0O9WOxQVVhIL7l0iZ6Zmko/lZxMD4uLo/kGB9Ncdu+2/+qnn+xn
+ 9/+zpUuJJfHxhH9hofWYUkl94C5xFoMWo0h2AXoP7u/b9Hq6QSSiaaqqaGIOh1bJZtPyioroqVev0mNz
+ cuhBGRl0j3Pn6D/FxNC/PnGCvu7oUfq7rq60Pzs5Ud/YtIny6kcf2T734Ye203+dntQ8DiEhVocyMuaQ
+ fXC6GWi8n6LBPtyzdMvltHaJhGYSi2laNCsWCulV9fX0vLo6emp5OT36yhWaX2IizQUj+qOnJ+1bZ2fa
+ BvyysPbLL+3e+ctfbF5bvnzOv6CHqS/qs+oz91eyCQ21dk5Pt+lDgxbcRo8aDLQR7EpDqAGUGdWFplsa
+ Guga7KO8mhp68eXL1EunTlFjw8OpPp6e1J9x0dmyeTPli/Xr7T7CHeTKBQusFqIe/GX5MY0+9LKwMJt/
+ pKbadWMXGNJo6NcrKmgNWVlUQVoapeDUKUpyWBgFv45R9u7ZY/8/339v9/mmTbZvenjY/y4+nuqIAHMR
+ gIYAVASgIIAdAtiieWvU07b64Pvt22fzHoNh63v6NNUjIYGy48wZyufnz1PeTU6mvMVkUv7N25vy8q5d
+ 9i/gy8XS1attFz7/vDXt2Wet/3+ie4/l/wOchKPj6Tjd4QAAAABJRU5ErkJggg==
+</value>
+ </data>
+ <data name="propertygrid_tab_properties" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAGVJREFUOE9jPHDg
+ wH8GIoCjoyMjsrL9+/dD9IEMoATDDQCaBTKRaAyzFMUAYl0CsginATBXQMMGw0Uw8VEXIAUiIyMjOCaQ
+ Q5ZQbKDEAroBJMcCVV1AVkqEuYCQv3HJUy8zkesCAKyXZMNS2ukhAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="mbox_warn.png" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAABcQwAA
+ XEMBOS4mtwAABLtJREFUaEPtmWtoVEcUx+/efb9ujGAKtoKk1mekUgkV+1KkSH1QlYjUZ7C2FcUiVTAF
+ BQWr9V0q0jaIQbSUBFrFKGpFUPCB+EA/aLW11EdbTW1Sq631k6fn3Oy4s3PP7p3s3phdMPBPZvfeu/P/
+ zTkzZ2bjAwCjpH8IoJT1RMxjhEOdNUidAoCGN6HQs52e9Ku+ZADQ7LiUaTIua1pnQHgaATQcQf2UBaAN
+ 3+/lNYTXAF9mMS8isbtoAdD4ZNX8K6/61TSi1x95CeFJBNBUd9SvMsCQl/xw92EZvDk6wEEM9QrCK4Dt
+ 6ujvPxy3Ac7/kIREImMyE9CJogFAMzNV83VLw7Z5oS31US4Kn3oBUVAE0HhPVKsMMGx4e+qomjYzyEGM
+ KRSiUIAmdfSPnEiwAL+1WtC70lQhfsbn44VA5A2AHX+gml++MsKaF9Fo2h3jotDwxAHQeB/UAxlgxKhA
+ TvMCYuGiMAdRmy9EXhFA483q6J88x6cONx+qX3bUh/v4eZX5QHQYADtaqJpfs4FPnTv3LSCwU+cT0PbA
+ ehwhmidMxd7X6QDYaZXa8Vtj+dRZvT4CZWXp9b9qsAm376YhVq6JcBBLOgrRoQig+UMyQCxm2IVKTZNN
+ m1lzoK5QY8axVXpYRyC0AdB4nTr6n22JOsy3/mtBxTM+x+gGgwZcb0lHgKAvXk1Ct3LHvWc8B0Dj1ar5
+ iTVBdtU5fobNb5hRy99f38BW6Y26EFoRQPPHZYDy7j64/IszdWhUv93jXOsty4Afr/P30zO174a4+fC2
+ DoQrABpfoY7+V9ucqSPmwRdbnSNKE5ZbTsV7f9yz4IW+jip9A/std4PICYAf8LpqfuoMPhWEmeWfZE7g
+ vv1M+POfzNznYHbtZav0zkIBzsoAzz7nc0xE1cz8DzPT4bvmmFaFps9ZXMdW6fdyQWSNABpfq47+9m/c
+ zdRMSe86x47X217IgzDceYp7iD76ZYNgAfCB0ar52e+HtEbyjZHt24RwmK8RueYCXTt2ml3FvtcGwM79
+ qEsyQOXzJrT87Z7HZKD/gPbJSOngZjbb9bUb2UK4lINwRAA736yOPm2Ddc3cvGPZ80Te++g+K983YRJ7
+ AHpNhcgAQOMTVPPzFuilzo7GGNBB3jQN+wy8bEX+ESCQK9eS0KPCUaUvZAVA40nUNRlgUJWpNfKr1vF7
+ n6s3sxcvnag07GSr9OcyxOMIoPGt6ujvOdD+zUIu0dygTZ36LFVr2k67Pe92fc5ctkrXCAgbAH/eUQ0s
+ WqKXAr+3WfaKIz8fChlAKeVmTuf6X/9ZMHCQo0rfwv4qUt6NHviiRTYwtJr/ZiFbh427YkDr94tDTJg+
+ K2gfYnTM6d7TfDDO7ZUaBcDX6ugfOuqeOrqde3Xfx8vYKj2P0scR/mTSABKtJkLxuAFClPNC0agBpEgk
+ LUopIUonIToTCAUCBgj5/QaQaAUT8vkMEFI9Sq8fOQBy3MyFsevfS+VR1xtRMkF7IEsZwPaeAuiGxGUp
+ WfhXiIqbUALbQnFsC8WwTYpKov/UCIWxLRTCtlAQ20IBbJNoHyZkYlvIh21bObcSboeHYrzueqQsRtPs
+ VqLYjWqfB0oN5GkKdXXEnkagqyPwP76kA5sYKmTOAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="back_arrow" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAACTtJREFUaEPVmXls
+ VUUYxVtrLJFUTZTFJUgQgooouEAxGheM/qMREo0b0aCJ0bA0smihRUE0alwQlQfiAu67uOPCYlUoguKK
+ Ii4gsgikaGmLRoz1/B73NNPb+15f+4wJvhzv5c52zvd9M/PNtLCxsbFgj/4PAXsy/jPyBXMLOghHCqXC
+ 2cKFwlUReOcbZdTp8F8ZLS8BInKocI4wVpgpzBYeEh6O8Iiehr9RTl3a0PbQfMS0WYAGLBT6CZMCwpB8
+ VJgj+PeY3uJwGfWoTzsE0Rd9FrZVTM4CEohjUUjwg+jjwhPCk8JTwtMJ4Dvl1KM+7fjRD/21WUhOAtRx
+ R2GUQIiExCFhws/o/VnhOeH5CC/oafgb5dSjvgXRTyiEsTrm4o1WBaij7sJtAq62xU0cK0MGchB9UXg5
+ wjw943AZ9ahPO9rTD4YIhdzO2K2JyCpAHZwipASsTtzicgZiQCwZkn5F/35VeE14XXgjAXynnHrUR5DF
+ 0J+FMA7jzYJDNhEZBaghS96DAXmsg8tt8Zf0joVNGsJvCvOFtyO8o6fhb5RTj/oWQz/0Z48wDuMhAs+X
+ ZhKRKEAN+ggsdawS/Jh0odWxHBbEoiYN0XeF94QFwsIE8J1y6lHfYujHHsGr9gbj8mPu9UkS0UKAKh4u
+ 3C8QNnHyuBtrYTksCAGIQArCi4T3haoIH+hp+Bvl1KM+7SzEHqF/xomLmAG3uIhmAlRhL2FKRB734UZb
+ nk6xEuSxOiFh4osjwh8WzCio7jm+90/9xh2/Qd+qAyzV+xLhI+HDqD7tLIT+6Jf+GScU4XC6GY6hiLiA
+ waqAu1htHPNYwuRx9VuR1QgHLIllIbTkoKmdvqmYMblh09baxrLU+Fp9WxHDcv3740gUYiyEfugPb9C/
+ Q8oiPCfgNThRgApKhHsF4t6rDROWmHTYhOSxHuEBkepjr++/Yd6C+bu2/bazEYxOjduh758H+EzvK4VP
+ I1GhEPqhv1AEnmBcxocHqx+8CO8Si2jygD5eIjDjCR0mDxsNqwIT1mGDhRiEwbDeUi10y8+dMGT7mrUb
+ 08SNUalx9SpfFeBrvX8lfBGJspBl6X529xeKcDgxPjzgAy/4XdpMgD4UCaH1cVkYOkwwx7wtv7RwZuEn
+ l065onZLTX0z8ogYlRrboDbfBVit92+FbwTEIASvfCLgDUTYE8wtxmPccD7Ay14oSp9l0v+bW9BXIPZD
+ 68dDh6WPWE2HTdEDRZ9eecvVdVu3N7Qgj4CRqbE7Ve+nAD/q/QdhjYAYvPNlTAThSP+Mw3iEbBhKoRf6
+ hgKGq6KXTWKNmPPEtfUJHZbAj4rvK1454vay+jBk4u8jU2P+UN31wi/R82c910WCvtcT7+ANi2DCE06s
+ UozDeHEveC6wvF+5+zS5Oz2eLnjy4qYw9rFCk/WLphetGH3H2IZs5CkbkbruT7XbHGCT3llaEbVWwBuI
+ wBOEExOcVcqhFPeC54LD6IE0d/1vfyFcOnGTw4fljM2KmHxfU3zJBeUX1bZGnvIJqZt2nThpwE7jpMqB
+ DUK9UCfUDqgs/X1ARen2ARWDagZWDNo2sOLkLaUTT94sbDxsUjdCDC8wLuPDwysS/FjiWVL3RwA7b3z1
+ iYcPm03VqWWnbd3w6/bEmM9FVK51zrt56BbGExg3HkbhPOiOgH6BgDD+SdJYylg6F/YZ03fd59+u+SdX
+ EvnUO2/qEAQwmRHA+PCAD4b1PGDB6Y+AMyIBTAwLIDNsEnBI5WFfvb5oQdMmlQ+5XNoGApgHoQB4hRP5
+ DAScJsRXoFDAu8eW9/sxvlHlQqS9dWICWEDsgbiA0xFwXGseUPmiiyZfVtNeQm1t1wYPHIeAbrnMgX2m
+ 71M97ckZf7SVTHvqRwI8ibPNgW4IIIlL2oXZwsNNrKr7lB7fvf1B1d+5kNq8bUcjK1Z7cO6U870KxTcz
+ lvdwFSrxRnaPCpxCk/8n7QPpBK7nxF5r36pa3KqIa+4YuatzeZcdQl305L228w1dfhNqhG1dru/6q7Cp
+ y/iuvwjru447eK3wQ8nU/chiGS9pH4Af+8B9QqFzoWH6R7gTk8g5C222E+v70iMm9Fz35uKFWUWMSI2J
+ 78Qb1ZadmJTCO7FzInZistPWdmJ4eSe+PMyFeiesRBlzIdWt7lF+xLqn3ngp49Ia5EKkDsDESerIheIJ
+ HbkQJ7hcc6HeoQDyobtiYZQpH2JykTUuO+DWA1aX3TW+ISmdjrJRyJKROhN1EkdaHc9GSeTol/4z5UEO
+ n2mET5OAKKUeEoRRpoyUmAxPYst0d7HyrBvOqfls1epmu3SW8wDEfbAhgeM8YPLZzgPhqWxo0omsOPJC
+ eJi3F7wrk5f4RObjJIOv6DWx9/o5857+KzhS1uk7BxcD0qTOPsiEJzKfA3wi8wGfcZ2FhtYvbiEg8gKX
+ WfFdOTzYODcKRRCzxO7HHW8rWXXtnWV1LKHRmZgTFysKT5+JsTjx7jMx7eNnYh8n42di0p1B2W4lmAvl
+ AksqRzdmvA83PtiHVyq+B0rfSqSFzC5YfvqEwVsurhwWv5XwjQQeQ7BvJXxP5GNkSN7Jm1eeCrVrdgWf
+ dLHVSZXuFsJQ8vk4LoI8hYwR1zP5sCQWXVI8uQOhwuEkBKRtcerTjvb0E94LMU78XohDV6esF1tNcbU7
+ veDEk0kEscku7WsWCPieCFLh7RxEDb5T7nsgXzHSD/3RbxJ5rjlb3Mo1W4VaKJtbcJQazQpEOJyYE74b
+ 5cBtIVjQ14yIAeH9qL/5OpH6Ju7bOPr1PRDjseNy2Dq6TZe7gSeOUWO2bHuCTn1fhIvjQohfSIU31BA1
+ +E459XwXSs5FP/Tn+x+TJwrStw/tEhCtTAeqk0rBE9s31UxuBrQQXE8IYE3AOTYOlzlUQuL0x1JJ/ywg
+ NwoH5fUHjsATe6uzywRft+NaNjsGZGAmOa5HDIcOiAFEGf5GOfWoTzsTpz/65Udutndr5LPOgaTG6pTJ
+ PVLAG/wYEIvhcsQk/Z3MfxvjacLUoz7taG/ioxgjF+KJG1muDSMhI/T0bQYutxgsCbFMoNykaYdXMUqb
+ iOclIAitfTXwicJwwWcKJrx/EDT8jXKSMdqcJOybq+ESoyKfxglLL5tgT+EE4UxhaATe+UZZi80oHw6t
+ /pk1n87/j7Z7vIB/AbqI4PWoWfWuAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="mbox_error.png" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAABcQwAA
+ XEMBOS4mtwAABChJREFUaEPVmVuITVEYx5fLmXGdaTSa3Br3mDAeCIlxeRAiRBE6pWQy5dJMETURDZHL
+ FHIrzYuEGCK5ZR4kxIMm5VqIcnkh0ZAs/2/sc2adddl77bP32efMqX9n5uy91/r/1rfWty67A+ectesP
+ AbRntWvzrb0n7NZHd+wHzYaqoO3QPmgvVAuthqZDRWHVGwoADE2BDnZk7Dm+aVDZ6KEDOCoITCAAGIh3
+ YuyRpWE3qGsUtXRA0gJAZTM7M0YtaNPSfu65gDLL/ID4BkAFu7yMTwTYKgidnqPz8z3QFmgFVG4HXWUL
+ YQ0A0z3zGKNQa1t0MX4/D/2gvOChT7h+AprhDnPYBsIKAKZ75zP2WGc+DhNPLUyboJrw7CwzyGkvCE8A
+ mI51YeyBbH4gKr0SwLgMdAxlYVzpotvgBuEJEGPsnGyeWuxziOYTMAgxH6GH2GGCcAWA8RrZ/MIMGBej
+ 8d480OfpIIwAMD5SNl+RYfMJkFeop68aiRe+ANB1kFTa+mQB/n4dEQCBIN3pxkOtDKGNAIxPklv/ZITm
+ E5GoViG+UzoXIbQAWNM0iABRdR05M9GcUqxCVLsCECH0VwRozELrJ2B2qgBPvACWi+aHZ9E8QXzUj4Ux
+ CQilC8H8KRFgc5YBCGKOCrHBCID1zksR4HYOAOxXAc5oAWjZIGcfDPu2xVkRNlLxeDQqKUnWe1cFaDYB
+ DBUBBsitX16O5yL6VFQkAb5o0qkJYIIIMC5HAGgcaBZ6ecqmHuanigDY6Kau7bMUAQJAbpdn5gIdQMoM
+ jHDkDACW9DJAVx1AygJuSI4AfFPNt5jGQA85C/0RIWIxzktLo1F+fjL6tE+QfCVXpspEhnXQW/Hm+zkw
+ DxxXARrdZuKzIkBdDgAsVQG2ugFUigDKQI4Y6Bfq66YCTHYD6C+PA5oJvY5KMnX9qGr+jed+AACXRYgl
+ WQQoUwHqbADmy1G4mgUIHGvrtpWDPQFaJwjGmkQITBD8d4QQzagLGVEGOGK1J3YAcPKXWsDKiABo7qHk
+ IdVP++E+1gAOxAEZgjbamRqwiXIX6LtOpWxeWUpob2DsngyBVy8ZgaAlw1y9eePxoufRIswPgz7IEHS8
+ iK1baCB3UJYm41A3atI1rHEeMERhPArCviK1X2L7xncHhKDNykZ9q5N5OlQuDgzgjIexKOyZDEH/0zHg
+ NggvyKwjAmd8HYQ9uC5V0m/XoUI381ZjICXnojVQKL0GMlXKR+PaGqgewo38FnQDwgKr9W0NZbJBLs87
+ Zdd7GffVhZTU9f8V6lc3kDSvUYQX2Zr3HQEpGr1QGV5/sZ9pmhWj+A5l1PgxHigCEkh3VL4WwhGSr7eW
+ Lbj/IrQsHeOhAUgwhTCEgzS2CcI+hF1ywG46Y+cQvtdD06COQYxnBCAMQ37L8JzI/BYY9f3/AJQMVypF
+ n/EwAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="folder" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAABMNJREFUaEPtmW1o
+ U1cYx5+mSZPcvHax6GTIGBNfPlUp6FBERIeonTCoyHBWOuyLVKE207UYCY3isszg2iTFpJ2hXW1ybReb
+ tkq0nQhN04rECSW0VavWFtlg3YeBjK3b2TkdnV1y09x7d+dtsIHny3055/87z8t9zkkGQgjS+kcA0tnS
+ WvxM9KTz6i8CLATvvT4hhEutdNkyWLtzJxw4ehQ+PXsWvnS5oKWhAXouXYLwsWPgEMMjjB7AYlWFhVBh
+ s4H74kUINDXBYHs7TEaj8MfEBKDJyUQbHIQXGzfCerYQeA5q1SrIy8+HT8rK4JTJBE4837f19dBfWQmj
+ +L6CzViMABYLhJ49YxbKJH72WnU12GcnxQIyly6Fd7Ztg4JDh+B4VRXYrFb4xuGA3sZGiAUCMHXvHvMc
+ fX0wrdfD27wA8MRZHR3wfD6hye4NDMBPdXVwDYfV3dZWmAyHYfrpU+4LMTwMaMMGeJ8vgD4Ugl/4AAj5
+ zu7dUMQXQNrWBj8KKYbPWCTs5gKQyFi5Upa7ejUY/nWdiRIn7WM+kwrxDsmLQECCSktlvSYTVXf+vCbg
+ dmvv+v26511d+t9WrMhamxIAl8X7QohJNsaDB4Bu3MhAPl8mNhk2OfL7KWxqdOuWHj15sgRXukRratI9
+ xp7ISAngdkPffwUgVSwSAXTligQLlM6I9PmU2FQoGNSioSEDo0gm4bPXnE5tT3zEMJZRpxOusQWIxQB1
+ dUlQa6sUWxY2BTYK0bQG9fdno/Fx5tWcT2iyexaL2s0KwG4HPxOAz0eEyrDJsSmxqdH16zo0MsJ9NfkA
+ FBcrP2MFcO4ceOIB7twBdPu2nrPb+QhleufhQwPavFmezwrg9GmwxwP4/RJBw4ErWDCo+xknsJYVgNEI
+ 5niAy5dloq0+gfV4tFGmks+YxMXFUJkIoBAVwGZTt7EG2LcPDicCUKICGI2qL1gDkA5ybjdKPjwdHVpR
+ AfbulZewBli3Dt4j9X3WC93dEjQ8/GpKJVNyRyLZ0/EtxD9tOyMVwFukJ58FIB8prlVDyOe93sQWIhUA
+ FQzC1EsAuagAtbXq3mStddJNfUsLjL8EUIoKYDarGjgDeL0wRADIHph0iUKGBNexiooU1ZwBPB6IEADS
+ UZKmjOukQj0/OsrcQsybA+QmPjIJEQCazsReEK6j5Ap29SpzC5ES4MIFaCMAZMPBdVIhn3e5NPfn2xsn
+ TWJ8BPI1AfD7xW0hampUIV4AZjN89TeASlQPlJUpfbwATp4Ey8gIoO5ucVqIsTEDunlT/+uuXcwtRMoc
+ OHIETnR2ShDZSAgZ03PHItvNcDh7urlZN4FjfcBqVbdXVVG1hYXKE1u2ZH1IUfBmqrOhpDmwfz+U0rQw
+ LUQ0+safNK2bcrs139vtmk6TSV1fUqI4tWOH7OOcHHgXb1QkqYRy/g5s3w4f0TT7FiIWM+DTBt0Lr1c7
+ 5nBoe86cUTWWl1M1e/YoDq9ZI1uPRcr5iuSVA3l5sJWcLsx1+aNHM3H5e3Oz5gePRx21WlV+o1H5eUGB
+ vDw3V7oVi9T8HyJ5ASxfDksqKuSjTqfqO7OZch08qDy+aZP8Aywy51WL5AWwkEQuAixkb7w+f/ItVC8s
+ ekBsz6S9B/4C+eG8h3vJrfkAAAAASUVORK5CYII=
+</value>
+ </data>
+ <data name="Cancel">
+ <value>Cancel</value>
+ </data>
+ <data name="propertygrid_categorized">
+ <value>Categorized</value>
+ </data>
+ <data name="last_open" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAADftJREFUaEPVmntY
+ 1FUax0efbbtaarr12D5bu6WbopZ5SVs1a3fV2rQsUcu8FJqlKCZkF9t1H7VUFBQVCXVFzTIIROU+DJoK
+ iCggKgjC3JgZ5sZlbiAzot993zMMgjLjpT/W5Xk+npnf5Zz3e8573vOeM3YaGG0ddv89nX7fWSLpJKG/
+ zuJf91+nTq3XWq/SffdntHtOfGm91/bdlnrb1t2J/q4CpvT3usiu1XKHn+YkNRwuNV2GN0qMLvjivNEJ
+ X5wzONERX2VZry5IdWwCIPk1SIIyGjKuXr0Kb1y5cgU3o7m5Gd64fPkyOiK+xAGZvOkKiVj1fyuAheVr
+ m5oDUx1L71TE/3QEWICLKDU2XZmb5PjoTkTcVAC71q9xIXYtby7kEWBpdOKIvKF59kGH/+2KuGsElOjt
+ iCu2Xp6e6Bh3OyLuCgHWRop0JEBWVoetefUu/3j78FsVcXcIuORCqYEElNfh+1NGfHu4pum1H+39bkXE
+ XSUgq0VAaFYVlqaaGl+KsT15MxF3rYCQAwp8ctBo/9Nma09fIv5nAgp1jQjKuCxYlOHCwnQXAltYQOWC
+ NDcTfrLuvSsFcAiVKZoFmfLLXnk3wb7zjgV44r+vVMFbnG8b+10uF3zhdDrREY2XmvDefvsOnwIWptmk
+ 3vIVz/U7NcBjVFNTE3xx6dIlNDY23oC9oRHT99u3+xaQapV664HbMcCbEWxYQ0ODTxwOBzrCYm/AjET7
+ Np8CApPrpdw4s7vYgJAs1TVkSoTcAsGZCtyMT9MrMG1DHEbODsbgie/Db9RYPP3cMPiNHIshE6Zj1Owl
+ eC98H/YUqGGz2QS1FjtmHrBH+xQw/1BNpsPRQD3gHbvdAV/YbHZqsGNyc09gypSpeLT7oxj8wmAsXvwp
+ wsPC8eOP+5CeniHK8PANWLIkGEOGDEX3bt0xebI/jh49BlOdDbNuKuBgTaYvA/ie1WrzicViRX19ewoK
+ ivDOO5Px5B+exLrQdSgpKYXRaLoppaUXhKCnnvojJkx8C6+vztzncwQ+OWDOtFhsYOKKqxF6XIV1zDEF
+ wo4rEZ5NcHlcgQ1UbqTvETkqQolNxOZcFSJPEFRupTKK+GD5BvTo+RhWrFyFqiqNMFqvNyA5OQVBixbj
+ r6/+Fc8/9zx69+6N5wY+h1fGvIp5H32M+PgE6HTV4nmtVofVq9egW/eernt/e6/XVFvy8X6jrLbWAqZS
+ V4PzVTU4pzbjLFGsMhFmFClNKFQaUaAw4jRxisiXG3CSyKs0ILfCgJyLBhy9oMXUmXPRt28/nDyZ39rb
+ UVFR8OvXHwEfBiAxMREqlUpEnK+//lpEJ7VajaSkJMz/ZD4G9B+AVatWCcEs5PTpAvR+prf9kYcf2UXb
+ 8d9cPxqSefH6LLO5Hr4wmergC4OhBsycOXMxbux4KJUq0fiZM8UYP+41zJo5i9433bAW8ES9PkTztc9C
+ luKlES8hOztH1KNWV2Hs2HENJOL7GwR89LM+y2isowfroNbVQqGtcaMxQ0WlmkZFrTNDrTWjikptdQ10
+ AjOqqdTra6g0Y+WKbzBo0AvUu2rRaHh4uHCTtLQ0n4tYR2vMkSNHkJCQgBHDR4hRqq7WC1ccOGCg/YH7
+ H1jWVoRkbmx1FhvCbCP//jylDEuJz5LLEJx0AcHJF7DkUCmW0OdPqVx86AKCDpZiEbHwQCkCiSnr4/G7
+ x5/A+XPnhfHr1q2HP0WS+vr62zbeYrHgiSeeQGlpqQjtn1LUWrp0qaiXJ3iPR3vYyZVGeERI5v6kO6yl
+ 3vWFRmOCL14cNgJRUd+JRjhsDnp+EAUFy20bz6MREBCAwMDA1nd5joweNRqpqWmi/pidMXi4y8PnSUQn
+ FiGZs093WK1mP/OOSmUk1+iY6O9iyOAXaA4YRQQZNnQY8vLy7sj42NhY9O/fXyxibV3r4sWLwh0VCqUQ
+ QZHLSgLeFQICftAeVlKEYWRnNEg6VYVk5nQVUgsILok0+pxOZBDSwipkFmqQWaTBsBGjsWf3HlFxMC1G
+ Kyl03ix34vtOpwd3IieXy9GrVy8UFRWJe9fXsWPHDsx4f4ZoJzY2Dt26disSAj78XnNELjdSBUbspTi/
+ RVaJzbIKbCIiiI2ZFQiXXkRYRjnCqFyfXo7QtHKsTS3Hv2Lz0KVLVzHBuHe4l3jIfWeeLnrGiaZLTvJx
+ Ll2UJ7ndZEP4xpZrdJ2euV7Iy6NfRn7+KTHSDz34UCONQk/JB3s0Ry5SDPdFebkeHbF69Ua89eYk0Svb
+ tm3HV19+5dV4NoaNYqMvkdGNtJFvaCAcLiz/1wqMH/+6+MzX+B4/wyKdbYRERkZixYoVor23J73d0LlT
+ 5zmS2bs0v5SVGeCLCxf06Ig5AQsofK4UFU6bOs2r77caT+c/wnAy1G5zwmZxIkuWTVHn96is0MJa777G
+ 9/gZIYTeYeE8qlqtFjwK3N7ataHo+kjXbZJZMZpfSksNFKIM+OGoEttlcuyQKbAzy02MQI5dVO6mUnBY
+ jj3EqL9NxE6KClzh8BeHdxg2Pca7XcVtuJWMLDmvwI7teymdeBY/x6agxuRCrdmFuloXLPUuIcRhJ8H0
+ DovwuFN/v/6iPZ53PXv0lEpm7tQcPXdOD+bHI0r8J5MEENuJbVI5ojPk+C69kpBja1olIoktqRXYQuWz
+ A4aKjJIrpEWmQ/cRbsM932K8hXq5WmfDM0/3xqwZs/GP197CsV/O4vTJSpSc1UEpp1Xf0IR6EsIjwoL5
+ XY8Azp24Pak0kzPcEsmMHVVHi4v18MWZM3pKC25k8ODhrQIoX0FISIjIcTyTWPQ++zy5AvcmG1RX40JB
+ fjlG/WW0iDh+/QYiInw31nwTheX/DMMXS1ciaOEXFO9j3SLESNC5ES1iXD/nSpwnZWRIeVE7L5mxXXOs
+ qMhAlXmnsFAPpqCgug16vDZ+EnbF7BI9MmTwELHrahuBeAJy77M/26xO1Ne5YKbfG/QaJ+bPC4Zf34GI
+ 2Z6M8nNOQUWpE8oK8nWlCwatEzX0rIXesdO7TU3u0Opxod27dqMHu9D70Zpjp08bKOsz4D/pKmxJkiMy
+ WYGodpAb0ffoZHKrFAW2p7p53X8evv12tRAw4Y0JYvlv1/tCAPe+2x3Yx43VTuhULigvuoTRJYUunD1J
+ 5NPxYoETF887oWIRaidMeveI8SjwaPLqzh3F7a1ZsxaU3G2TTP9Oeyw/30Dx1YCYNMrpk5SIJLYwhyjf
+ P6hAxAE5ocDGRDk2EOGJlYQc7y5ahzcmvCUq5Nw9LCysQwF2ch9LHfUoTVQ99WyVwoVK6m02uDDXhbwj
+ Tpz8xYkzeeQqZ2hRK3NBw6Ogc4vmCc0dExcXJ3Ijbm/SpLcdtA58IHlvq/Z4Xp6RQqB3TpwwgMnNbU96
+ ehn1QleR7p49ew5jXh7TsQCaiK0CyH2q5C5UlLh7/3S2C9lSJ3JlbjGlhSTggrOdgAaHW8BU2ppy0ODN
+ zoMPPMgLWQ/Ju5Ha4zk5RvgiO9tAuXnHDH9xjEiwuFfenPim2LB4UgV3BHJPYI4+3Jvs29y78jKn6G12
+ nwISUZBDbnTKhbKzTijKXcLN2N34Pa4vOzsbI/8yUrTD++hu3boXilRi2hZd9vHjJjBrYpVYG6tCKJXr
+ 4mhbSaz/maAyLI62lfQ5PF6FDS1EUBnwWTT6USThZI4jBe+8eMHhRt0rr3vhYjdgf2a/1pF/qytpFMiN
+ yordrlRCPc/Gc+/zCFVXkWByOfZ9Tss5TeE0ggX49fOztSZz0zZXZx89aqZTADMiE6oQuV+DzVRuiid+
+ dpcbqQyPVSOshfVUrv9JjdCfSCyVffxeRETEptbeGT9ufMsouFOHa2sALVZklJF8myepmgxV0GTm0WB4
+ YvP8YIFGEtpIEUyk2LQV9dQfHb3tapeHulxLp6dG6HMOHzbDTU2HZGWZ4YuoKBkef6yX2EJyD334QQBC
+ Q0NF710/ChwWeTKze1TTfNCpKeKQu7DLsOEcYuvI1Xjk2HhOsSdOmCjq5Q0TLV7tNzRTNhpyZLJa+CIz
+ swa+kErNCApaR0M7QGSlvK2cTEcqDGeOIoHjHIjCKbsSpwrsThznTfQ7sonEsGvxd54vbDi7TeCCQIz9
+ +1jK08pFnXRYYL/vvvuD220p/cONOVJpHS3N7cnIqKPVzk16eq1P0tJqae9bC3//QIpEr1JqrhA9tnfv
+ D2Ll5MXOSQsRC2mbD/EEFSutjefJtXyHTyjY5z1uw4cEY8a84qCd2A3npJLJYabctLR6MsA7qan1tKXz
+ TkpKHZikpBpM8Q/C00/3oaiWK0RUVsoxc8ZMcRa0Z8+e1tMJdi+ZTNYadmtra4W7vPP2O3jjH2+IsMzv
+ 5+WdxFNPPmUn46No4na+4VRi8vqa3JQUKxngneRkCx1KeScpqZ6Mt7Ty+ecxlCk+jmXL/tl6SnHs2HH6
+ vkycNLxApxejRo5C32f7ivSY99BD6VgxJDhEJGmeo5Tly/+Nrt0edd7zm3tmeDudk0z9wbpsXrwt8eN4
+ 2wHi4CdMgu0QMz/BlsQsSLAlB+63pbSQunC/LXVhoi2NyvRFTKItPchNxuJEm3TxAZv0/Y0nsvsMHWvq
+ 0fPx5pUrv7laXHxWGOZBoVCIw6+Kisp218/RRF397Rr87rFeV/487O9107+MmOnzaPFmP6L92vs07ANp
+ 47GPVk4LZazWBQsCmzmP4cXv4MFDYn7w98DAhc19+vzZQuc+Vno+lt4bdCtt/6r/KXIrDXie4WMQYght
+ A0Mojm+lcJhC5NNpdCp9j6Lrn9H9YZ7jklut+7/JKVwBwotNkwAAAABJRU5ErkJggg==
+</value>
+ </data>
+ <data name="Abort">
+ <value>Abort</value>
+ </data>
+ <data name="OK">
+ <value>OK</value>
+ </data>
+ <data name="paper" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAYAAACoPemuAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAChxJREFUWEfNmPl3
+ lPUVxmvX32p/6p/gsdqqgCxCIlpwqxU3IgWDtaBAlYTsxEjAEFBCksmiEEDBgBANmx7coIh7gklm35dk
+ 9n3L7DOJTZ4+b0LSOTXIkNPT05zznPedmTfJJ/fe5977zQ0AfvJ/+SWA/afmzll4+4svVB4sKqruKC6m
+ tlR3bCmhSqs7SgSVUeXVHaWCKqo7yiqpquqO8q1X14MPP9w40++62ns/gBIeXLggf63FnIbXA/h8gD8A
+ BIJAMAyEIkA4SsWB4SQQSQHRDBAbBeLfA4kxavyH2lxRO7Z02f3HcoW7Kph5MA2PC/+G82fBDRNwCi6R
+ BTdydbiG/Wewq+3s94uX/nF3LnAzgi2Yn7/WbEzD7cR/Da626TSOXgLKtu9PL1qc//y14K4KNqRPw2UH
+ 3I4sOC/TOhW5EFN7jcjFs9JaVHcKO44DnZ8B6za/Eps3f/6yH4ObEWz+nXmFJm0KLityh4ux5qbSmmbN
+ XUlr/J+T9VZYcRIFTGLtUeDIhXE88XRR6Kabb77puop//ry8QqMmBacZcF4DLpAduRngYjSEALemrBs3
+ M4ErdwE1nUDHxyN4YMUz7l/feONvZoKbOWICmCoFxyDgmIKzZaXVTbdOpVVw7BSc4NgpODo2eiVygmMr
+ 6jvxl9JurC47iU21p1G15wyqXz2Ce5c9NJA72Ny8QoMiBbuJYDnATbSTH4GLMq0T7eRKWrPbyR5RS2/O
+ YHfOWbJGJ03CZgB+KzdgpdqNzboAKg0h1BjCqDYGUWrwY73Rhwe0dtyvc+BBnR3PDvlQbg2h1h5GvSOM
+ bfYgSmx+rDa78SeTfUIFFhc8349N97oGUcvl6wLTipOw6oDfKczYoglgpz6CRkMELcYIRINR7DEN42UC
+ bjB48Te9B88ZPaixhLDXFkG7PYIDzihed0XQ4BpGlT2AjVYv/m7zotThh390fLoR721p/S5nsHmMmGYg
+ CYsGaFVHcVAbxzFDEu9QXaYkTlDHTQm8bY6jfZCw5gjaqKP2BN5zJXHKncJZ6pSbr718zhNDhzuCDm8E
+ b/miCIyMT6aV7aSxra0vd7A7lqxR9yVhVgF5SjueVHvxoiaIrbphbNOFUaMLoVwfxLN6H5ZrHLhbY8cy
+ ar3Jj/KhEHZYwqizMpVMa7E5gKdMbtxncGC50Y7Hh9xwpsama66xtf36wFSXkxhSAu8rUzivGsHn2lF8
+ rhM0gi/0GXxp4pU6P5TGec7VC5Y0vnaM4FvnKHpcGVx2p3HZw6tvFF9507joT+FiIIUvQmkEBcdema8E
+ y92Vc29fslrRk8CgHJgns+BhpQvrlH4Uq4MoZ+TKtUFsZt2tUnsYURsWKC3IU1mxlvX2gokmGQyhajDI
+ awAbhvxYYXAiX2tFnsaCh4wO2GJj08O/sfX16wOTf5OASQpskvtQIw+hURVFuzqGfaoY3tDE0K6L4lWm
+ tlzjR5HOhzKdH3tpiPYh1qQ5hkOWGA5aaQAbn2Nqq5nSlyx+1NmC8MTGp6dEU+sb4pxrbO5tS1bLvkrA
+ yG+ploWwW04nKqOEiuOgJoH9BNyvjaFZG8UObYh1F0SdPox2YxQdQ3G8SVMcpo5Y4uiw8jnLMF6xBFFP
+ 1zbah+GKjE+uTRxhTa37JDmDzSGY9MsEDP0sfpkNTyo82KQIoko5jBpVGC+pQqig1tIUy2iOfJUN96kc
+ WMeolbHXbTOFUUttM4VQxNQWGNw0iA33am0ooBGsobHJtYlToqllH/Pyw2V1xpE05w+LV4kvxaGnX84O
+ pPGxOIML0lF8Jh+Z0CXVKC5qRvCJOo0PtEl8oEvhnJ7FbcrgkmAK8yi+NGfwjYWFb+V79gw+cdBEjiQ+
+ d2fgyZqvzS0dspzB7vj94lUDF+PQsSffKbXiEbkbz8rZCuRhlCtCKFMGsZFmeIqRvFthxwKFFUsZuUIN
+ 2wrTWsW0VhnYXhi9DWwpj+pcWKRm8VOPGVww+8amR1iz6DrB+i/Eoe0BqgZYGwOsMTGLWprAQUkch2QJ
+ dMhiaFNEUa8MYwfTuksdxj7W3WF9nI04ManBBA6ZomgzRVDPtL7K9Lax3py+8cl1nZFrFh1QXFfE+s/H
+ ofkGeF7sQ8VACHUEa5LG0CiJYq+UQLIItjOCRYzkJqUPxaoAdmjC2KPlJKBjRVQrR9geA0cXo/eiwYdS
+ ox/b2EosboJx4RTgmppnA/Y1cJfYisclLH4JUyMdxkvUVmkYm2UBFMo8WCazI09uw3KFA39V8Zezz9Wy
+ jWzXsvg5JV6gIQo0LtwtGERtx0qmdcg1NrE2CQedZtEhtvEci/+OW+8q6D8fg4Zgx3s4+3oz+KB3BB9d
+ HsWHfWl81D+CczTFOUkGp6UpdMuTOM016WP1CD6lLtAYF7UZXOSEOG9g4ZvSeJ/z9dxgCv/ghHByXfdy
+ p/MSrrn5EAffLMAWSGz4s8SN9eIASsVhlFGlYha1JIDVMi/yGbGFjNhSRmwNI1aiDqGS9VapYUth9Naz
+ pazQuHEXI3YPI/ao1gWjbQweHnQEuOamN9WzAnutl2tML5tmbxKdvQkc4ww99l0CR/oTeKs/PmGKvRKa
+ g3X3pjyBE5ytXYoE3lUn8S6bcaeGZqEpWnURvKHnM4YYLNZxuHnQEeBEzW9xh5lFxFb1e7BxIICqfrqv
+ LzKh7f0RbOXrUjr2abEHq6QePCP1oljO+lJG8IpiGDtV3ETo1irO1w1qHwpUbqymNmp9MJjH4BJWdcKJ
+ mg5rcwa7/dZFK/s+jU7U2HKxA0+JvdhMZ1b1sfivqJhQ6+jY+/n5vVIHHpG5sJFgNYTaTtVxSrzMVlKi
+ pElUXjygdOAhpRNPc/DrB8fgtPAExoOOqPEw19EcI5YN1sniP9GTwkka4HRPBmd7RnCG15NUd28anZe5
+ CDKt7/TTJBIaQkpjSDP4UJHBOUGqDE6pUzjBtHZpEzjDKWE2jsMxxBMY4USNb88OLF/iwAqm6jm2iy0D
+ YVT0D6OkP4Tn+7n2MJJLxDYskthxj8yJQva0LRz6lexvldxIShjBDQo/HlO6sZgTQtBjTKfGMDZ50CEc
+ wXiymEXEDnIv62Thd/WyLfSk0f1tGu99ywjw/hijeaAnjgOM2iHqeB+fYRs5Q52WcL2W8cp2cpzt5LAy
+ MaEummJQNz5x0BHgRHs7cwe77ZaFT3z3SWSixnKVllNCGGHCfNXzeCFsJsLaZOJSM8gxPcTBI2zEZjYH
+ C8tdOOgIcKKGTmPOEZsN2MQfcA24wRngRA1HGbccUzlrsFnAifYc45H6fwGWDccz9nRaudkLaTUxrcJZ
+ YiqtBKMFcgS75aZ5jzbUHve1737fK6ht11lPtlrrz3im1LLzlHtKorqT7mnt5P3ObpeovtvVsovX3e+5
+ WgS9JqjLKai1ocu56snn9DmD8Z/FN1C/ytIveZ+tX/D1lH7O+yn9jPfZ+ilfT0n4mRO61j/thM//BR1x
+ NCLR9Yu7AAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="monitor-computer" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAD31JREFUaEPVmQdY
+ VHe6xvFe9+59dJPsJttMTNas2WQfs4nuborGGzVmLdHYwIKiG0VAI6BIH5A6dJDelCkgRXrvvXcQaYJU
+ UXoRLAgMzHu/cxRkaJZr7j7L87xMOTPnvL//+/2/859zFgGQ+rf+YwD+nfWTm9/p2fTWWk7c5x+f4v+w
+ +ke+7V9VfGLWnA8t/VQrtv5TrbiWT7TiOz7WiO1b/flXx15mIF8KQFDQ958eOb3L9P2KvlKyDVdQtA11
+ UrwYmXDaJaVcyS2jTskts1nBNevOSdesHiWX1AHNS6n3nMKLxyILGlB9ewiDw+MQizGlkZFRrF+/Xuf/
+ DNBzX/Tft++OrsipaNzkF5PxozA81Z0fkZFyJb7omjC+pJYXV9J0Obb0tkdUcbdbWE6fV2TOvcjMClFx
+ zS103h3GqEgsYWzS5NiYCM3NLUhLS4e3tw94PP6UzM0t2O9s3LjR5KUACgoKLlbV3Gi6VlnbVlRe1ZWe
+ W9SbllM4VFJRI2pu68TDR2OYmJjb2KRBZntHRyfy8vLh7x8APl/AijHq5cWHUOiD1NR0FkIkkhx9Hk/A
+ Amzbts3ypQDS09O9Ozq7MD6BBdXXfxclpeUICQkDjzHHGnxsVCAQIi4uAbW1NzA8/GjOFKaXzPTnzPeJ
+ H7t377Z7KYDExESlkrKKMRpoVNc2ICIqjsx5w4svpEcSTwg+GQwLi0B5eQUGB4deyOB8xiffZwZiRATI
+ 7D/o8lIA1dXVq5NS0gfvjQBGxlx0dnW/UoPPArjsJQBz7O+OHLvxmzV/k6Nz0pIXAZFqbGxcmpSS1tP/
+ EHD14OERjQYzIqPjwBhJ9KS0mJifZeZltntRGTLHPukpEKs0d4p3efBavlbXjl2143vz1377u0+eBcO2
+ 0dj4xDud9wB7Vx6GHoEdkfukB6PAQ9IwlRejnwLOi0q0i4592kMg5g5DbENTyInkPjwu1s/Mvy9rZlm6
+ 5aSS4MPPPj9O6bw2E4gFCA4Nb2i7C9g689D7AKz6aFSYkRkYBqhDYpDA5oNj5g+bGolJ7UWS8/bxQ3Pv
+ GFQJwJ6Mu5F4IxD7koJHIY4iJY5BHN3dLzb09m2T5+jH/2PvPsvfv7P8M3YZxPzzueJX1dQH2Ln5oJV2
+ 1j4EdJCYVJjR6b4P9JBYMBILRmLAXhSOuijb7SZITMkFh4SjomUQ590F4ktk2pt0lUyHk+LIeCopRwRx
+ CamSOnCdaEJsLfAZfvvbPb3/9dcNoSyAg5NzakXrfVyJyEBmWRNa+oHWAeAWiUnmNunOINDOaCG450iN
+ LctpJRkVm4jsqg6cd/SEP5kOJcWQksl4FqmQjF8jCVLSRWsOnej6hZx6h5RDygOpbDGkpJUDWABTrplN
+ bNZ1JBa3QBiahvoe4GbvYzVQMo2kJoJqJrUQFAtHUCwcQbFwc4CxyT2jJBNSsxFf2IRT5/RH9x0+cWeX
+ vFIPr7xyPI9Mh1bfEK//56neX8qe7ZAyCRqUyhiDVA4ZnpS0ylUWwMjIaO8l34jholYRuI4+qOwEqkjV
+ XUANqbYbuEGqI7BJuAaCY8FIDNiLwk2WZEp2KYJTq2Bq40UnwiHk5DSAo2fTu2H73p5FWp79Ukn3JU1P
+ B5BRDWQBeDzeO9aOngOFtwADWz5KbwNld4By0rV2oIJ0vQOoJLFgLwg3V0lOJpdZXAthdBGMbXgswKTO
+ apr1SIw2Y5zK5meuWfilggmkMkSQ2n82iAVwdnZexLWy785pBjhWfOS3AgUkBqiIURtQTCohsOeBY1Mj
+ sak9I7ncila4BWXCcAGA/whsxFu6Xlil54UDYfVYa34VUqmPGIDgqeW0nqHZrfRGQMuSjwx6zGwCskjZ
+ BMWA5bYAeaSZcCwYaRKMTY4SY5OjxNjkFijJfKpPa3489KzmTuC36i7Y4p4KxZIJHM8ahEzAtacAB849
+ BVDT1K1PqgfULQRgHpNvAimk1AYgjcTAzQRj4QiKhaPEWDhKjE3uOVJj4Aob78PIJRS6NHBzldAHF4Q4
+ FHETGwx42GTsjb/p8/A7NSdIZU1A6oBayFQCCqeVy6KqxqBh44eI66OIrQXibgDxpIQ6IJERgT0v3Fyp
+ zQVXfGsCWja+0LKYAaDBZefASiqbb1wS8D7nMpaahUAq5eHTSX1Q7fF5gNEB2aMhvKRGmPlkwy22AWFV
+ QDgpohqIJEXVANGkGAKbC44FI7GpPSO5mXDqlj7QsPBGTc3g00n8BODnNnFYFH5n7k508HzYFMD273Zo
+ GLpFit2TboPjmYKr14DACiCIFHwdCCGFVgJhJBaMxIK9BBxTkil1IriFFEDTSggDzyRo2wWirKxzFsCs
+ TkSpLAppfdyFDqmHPwXYvn2dgob5/SulE1A09oFPKXCF5FsG+JH8y4EAEgM2C46gWLgFUoupnoBTWDnO
+ 0Ugrc4VQNveFXXgdu19GGrYhyM9vmQJQfZLAFED8XbxuFICVVEqrFAwhFdnJAERMAUhLSy/d/88z/cIS
+ 4LiBEF5FAI9RMcAnCeh9Zps3QbFwBMXCPTFAzWEWmH1ELc6YXcEpEyGUTHxgGlABQbGY3Q+/aAKGgnyo
+ Gl2GtoknHFyuSpTQJMDP3fOwXOcS1loEQT73AZTomN/SnGABZDWfAjDzYIe0XOelQuAYzXzXPMAtH3An
+ eRQAniRm22XSJBwLRmLBSLZRzVDi+kPeQIATNAgcfiE888bZ7zCyiW2Hipk/1IwuwcDsMqKjiyU6z/Qu
+ pKph2suM/grywpjeH1zFdqKdHin4VO0i/Qbog9ThGQCbtu1pYYwf4Qhhnw04kBxpJ04k51zAhcSCkRgw
+ y+h2KJgG4Zi+AMf0BFBzzYRT5ii7nZEzrcY0XNNwxuAytIw94e4ZTj9Lu+Y1PR/AkdhWbKCy/ojK51cc
+ PhaFtT2e1Ee0oiSuC32xfnMNY/qQjhBW6YB1Bo0ayTbzsUxj+nDCLByyOgLI6gpwyi4JVkkPWNBJ6QU2
+ YI+KGz7ba4Jz2jZITq58LsPTzTPPVdUfJ/CWih1+T2fhxbzS2Z3oiLYkwKrVn2ebRPXh8IWrMIgfgX7U
+ EI6ZxUJaS4D92gL8YB4Nk5i7sCGYSZknDUPOOHx4vazF+AdbbPHG5gy8tncUr22rh7IyR5yUVCGeae55
+ Xk8CzNWFpt47oh0tkcCKlX/2ULRLwVl+DXaqukHWMBSc0G6Yp0FCZ/lVY9sUrdp2HdMe+Pjrkw+XSbdj
+ udyEpPbWIDGxgq4LRcLIyAFcrut4UdHt507juQDkdGIkAN588025bQoWY0bJgPE06UYM4aCe39j3ikYj
+ MkoaY2ZuHhMZdXVw9vKH3Gl78SrFcczUhwcr6EpczZThkpJ22NsLoa9vI3Zx8RdVVfUvCKNy3rRvwdFn
+ 5oCMSpIEwOuvv/7Hv2yQGeLEi3HCsXBit+rFcWVzD1gLA2id04qawUEJCcNioMflY91Z0SytOVIk3rJz
+ d5uRseNAVdWAhFkGzNzcDZqapqLg4MzxuUpqXgD/OqzYp9j3P1v39Ur9+p2tEgDL3n33vZWfrh06Z+GM
+ 0Ny8WYZnAvhEx8HK3hfbdMZmadOpYmTdvAknX9/732zbkX327IXy1NQq0UyzQUEZTCrQ0bEYSU+vm5ov
+ yudNniaQOY5fnLa4t+nQqQ6uhcdARUUPXRGMekBXKVZMAXy2fv1WjpVVw0yT872uHBhAbPk1uhjmCBmD
+ IRwwGZXQTpU8pNfXg/1cSen49n37rnz44SdHDx9WCLe39+6cWUKVlf3w8AjBuXOGYzRfHskraT+UulQ4
+ /mdphW75M5wu6mZP4W+PSAKsWr16h1tg4N1nma/o70dJTw/yOzqQfecO0qisuBau2HkqGidtRiQkcz4L
+ 0ZWV7OcKOjuR1dyMnQcOxDEnzCVLlizbuPE7a+pSxQkJ5aMzUymk9biCsh6+3ys3UF19d9ZcqWoephJ0
+ 76cE3mUTkFNSKlnIPGO8uLsbOazpW0hsakJM/U1E3LgBF14IpOVtoO76SEJHtVPhX1KCGCoj5vPpt27B
+ LzNzfM3atbKTK2AysOijj1btOXhQPsjGxquNKY3pMPLyZ9unvy4t7YCJiXODtPRRwYoVH6xnrwvR36/t
+ +ILR+QDKenvZEWcMJDQ2IZK6T3B1NfwqKuBdVgbry/5QVLeHMX9YQif1E3ApNxf+FdcRQp+PqqtnQbbJ
+ 7E+c63Ih+Xjr66+3mP74o25uTEzRI8b4JEBgYPo9JSWNtC+/3KBJn1s6/ftSixcv/ktAcop4LgDGfB6Z
+ Z0olroF+I9TUsoYEpaW0PiqkJUYu9Fy8oGHoAvurDyV0xjgGF9PS4FlYCGFpGQKuX0d4bS2kj5+gXw0L
+ 35d7//0/bdm//wffr77a3Lxnz2H+8uUrvpjvO0wCSzmW1qKZANepbAqpdjNutSG+sZE9OGOeT2XhSjcy
+ LmZmwjwlFWdsHWFkdQn8yAcSOm8aDm5iIuyzsmjdlE+r2VL4XbuGb7/fS78gXt2NRXYOyMge6ynv6pJo
+ m8zo57a3I6WlBdHUTYKqqtiS8SgoIFPZrHmDuHgouLmDY2SP4MQhhNA1nElpmwfDIDYOlqlpcMzOoZVs
+ IdRt7PHl2k0vdR9g3gSYDevWfeOoY2hOl1KenqxKqdswkzaZukcU1X1gZRVbCu75BTT6WTBLToE+GTwX
+ HEILLyO4C/ORlHMPkcmd0LW6gh/0LVlABpQBVrvoCMUzmv3Llr373itPgLmpICsrn2ls7ojI3Hw2iXKm
+ /imB1JZWtpMwE9envJwdSWZErai+jalEODExOKFvin2yilA2dcRRrjXUQ8OgFxsLk0RaraakQIFjBDsH
+ 7webN+/Qe5Xm2S40raUtoQkT4uDkPcF1cEVUYRGKqKwy29rY7sG0zKvU15kUPNkJnAOb9Aw2CQZENyIC
+ F2jEDeMTWOPGlI6SuRVU9c1ga8vvXLt246lXbV4C4ElPXbR1624HX9+EQf+AZJhau8LUyR3BBBNPXSjy
+ Rh07F67QGZhXXMLOB2dqlQ5UIkxZWSYlQcXBGWcucGFq5Y709Fpa73Br1qz54tufwvwsgMmDvP32u2t2
+ 7TroyeFYVZMJscA7GlZ2l8G1caeO4wyOpQM0zW2hybWFDvci9Kn0jCxcYEcXhpOTr9O94Nh7Cgrn09at
+ 26Qz112VVwkjsZibuWM6+OK//33diePHVYPV1AwzdXUtq8zM3O54e8cNM0YjIwvErq5XBy5csGvS0uKW
+ qKhwEnfuPOD13nt/XP0qTS60rwUB5jlj/ozA3v/DH1Z+98Ybv/qSnv/m/8vsnH7+lQd/Fcf+X104LlAR
+ 5z/iAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="window" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAfNJREFUaEPtmk8o
+ REEcxxe7J/9WbvawVxcpBzkhpUi5OLg67EWSFAclxcnJHrW5UFw4iDO2uMiKZ6WltSVa689jd7Nr/6j3
+ NbslntFr9Gqnec3W57avme98f7/vTO9NGQCb0L+CAJEhi49WgiYo4wUBneXlRQGklsTBbi/OeVpcAQ4p
+ gG+52aUDnBu+4mcTO+uQb2oBRKLGiQ+SQqPFFOrqhXpPdjOR6BvAC5l7jxTAyzVrO3AcPMHG4gJFKHrH
+ 1CcrCjCyThPOsvXZEeZwiCkdCpZ0Yxs6cLC/C9/kMEXw+opJgGeNbHJDNEqCTcA26rEJu44ddEkBkA7I
+ EvruIdnERhsY9xS6Sb2hkPm/uc1lmWJ0KwzM79FEcmwxeoZlnMKn4wLb7DHK63jwn3GtfZT4z0rw+q90
+ gNfKf41rcQfSaTzEYhT3uRxTjJbCHUMHEl7vny99VL+fScDE7AJc7laK8yeV6fnGlya4VLeO/uQg+z5g
+ VoBnbIa8Z22gUGKPTAKqn2phe7TpaHvtkALAWkLSAVlCJlOIewm9rq4i39xM8RwIMKUIdwFmN6LIewah
+ eJIiqmlMC3CpJRDS4jrC2ht7jJoVUIrnLX4WEuBVu3SgFHVuNIalHGh3OJCprEJKJMics+QTU7fQFz2K
+ N21EvqlSmPsn8UKYLq/+Q1MAAAAASUVORK5CYII=
+</value>
+ </data>
+ <data name="propertygrid_sort_alphabetical" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAI5JREFUOE+tklEO
+ gCAMQ/XfK3j/E/gNN1NLLCljRoeaLGZQXrfBnHPepy8fACmlGieryS8DmHRR9hSgIkKtAdehdQEQaBUe
+ gPsNgO4EqOiuxQ7gCW2LmrsV2DnwAHtWk8cKIOAteLOoAOuq+atrpNPIv7yDSKzL1ujDAJgppACwMBJ1
+ iJEW3AoigF9moIYHlA+UIAsfXwEAAAAASUVORK5CYII=
+</value>
+ </data>
+ <data name="errorProvider.ico" type="System.Drawing.Icon, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ AAABAAEAEBAAAAAAAABoAwAAFgAAACgAAAAQAAAAIAAAAAEAGAAAAAAAQAMAAAAAAAAAAAAAAAAAAAAA
+ AAD////////////////////8/v7F/fuc/PiW+/ix/Prt/v3/////////////////////////////////
+ //+a/Pgl+PEP+PAP+PAP+PAP+PAT+PBn+vXp/v3////////////////////6/v5a+vQP+PAP+PAP+PAP
+ +PAP+PAP+PAP+PAP+PAl+PHU/fz///////////////9v+vYP+PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP
+ +PAP+PAo+PHt/v3////////M/fsP+PAP+PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP+PAP+PAP+PBx+vb/
+ //////9p+vUP+PAP+PAP+PAP+PAP+PAP+PAP+PAP+PAP+PAP+PAP+PAP+PAZ+PD2/v7///8t+PEP+PAP
+ +PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP+PAP+PAP+PAP+PDD/fv///8V+PAP+PAP+PAP+PAP+PAP+PAA
+ AAAAAAAP+PAP+PAP+PAP+PAP+PAP+PCs/Pn///8f+PEP+PAP+PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP
+ +PAP+PAP+PAP+PC1/Pr///9K+fMP+PAP+PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP+PAP+PAP+PAP+PDg
+ /v3///+c/PgP+PAP+PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP+PAP+PAP+PBB+fP////////4/v4v+PIP
+ +PAP+PAP+PAP+PAAAAAAAAAP+PAP+PAP+PAP+PAP+PC+/fr////////////Q/fwc+PAP+PAP+PAP+PAP
+ +PAP+PAP+PAP+PAP+PAP+PCC+/f////////////////////T/fw1+fIP+PAP+PAP+PAP+PAP+PAP+PAX
+ +PCW+/j////////////////////////////7/v6p/Plc+vQy+fIt+PFI+fOH+/fm/v3/////////////
+ //////////////////////////////////////////////////////////////////8AAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+</value>
+ </data>
+ <data name="propertygrid_alphabetic">
+ <value>Alphabetic</value>
+ </data>
+ <data name="Ignore">
+ <value>Ignore</value>
+ </data>
+ <data name="folder_star" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAACKZJREFUaEPVmg1M
+ lPcdx//3fs9z99yBEJt1WzqTrc2SZmk6a+K2LpvGtGE1jd1qRnWmXRpaK77WicU5GOCqgnIg4AsHihYq
+ xyFUsWoEkbM4DirH+/sd9waKAqIyqw3+f/s9d0B5u+OgGK4kv+S457k/38/v/3v7P4cAAMgP+ocH+CHb
+ vIqvWK3+HZrYmwPxuszb9XkFMIaqMyvXqT//+u8q4VQiq95VLTKuVRv9FuBGmKrUtIGjNVu4zNqPOcFY
+ oTVbuT+ZNnJ91R+qHvktQO02zlq/U0kbditpY7QihRfaFKMQNv1bEdf4L+WT+kglrfsHN+iXAHURSgmK
+ HGreo6Ct+xW07SBL2zRscruGvdyWyNLWBJa2fKqgCDPglwDo6Z/zwtuTWGo+zFBLOkM7M4dNy1DzUYZ2
+ pCDUAbZ3XgGwivwULaTqPdUKUzj3BwyZ36L4JejhDzpSUXAGQ22fyan9tJw68mTUqZdRhw5/z5FT6wk5
+ D9Iz5wDY+KRoCl/6B4pXGNeoG258qKK12zmMdSVtjWdpRxrjEujIldOuQhm9+aWU3rrktpsXpLT7nBuG
+ h7McY+5jeNViuBXWf6I8iMm9CR2yEtdWT1lGUZyYZcnzS5eSNaGhZOeWLUQTHU1yEhJIyeHDpCE7m/To
+ dKR/82ZyDe8dVz2mLIfvqX5p2sTd55OyGeO6/RDrChdePC+0p1hK71yT0DvXJbT3upj2lkvo7VI3iPMM
+ QpzCnTjCuPKCdwBWLIoV7DMsw2IXwEsvkRe3bSOavXvJ+eRkUnn8OLEbDOSxzUagq8uzNTcT+tpr5C++
+ 7ARWnNDGKCVticfYPiJHz6KHv5DCrWIJ3Lkuhv5qEQzUozUI4W6tmPZXiumdMolrZ/jQ4oHbk1nKJz2G
+ obZ6A+fqHYRhyMKsLNLrTai3a1FRJGcsAL97zz5LfrFiBQl9/32yIzKSaPbvJ7kpKaSsNEE60JbEgCVT
+ Do48Kdy8iOK/QvE1IrjfJoRBmwAG7QJ4YBbRe40i2meU0J4SKe36YngXMOxa9ilSGv6pHN11EhJC3p3O
+ 094AjEZyf98+cjotjZzHnTPl5pJbFRXkid0+eeec+J75lBysWTJwFri932sUw71mIfzPIYBHfQQe3yXw
+ 8KaQPugQ0bsm3AWDhHYXyaj9c1dCx0/cbbJmDYmYrfdn+jmbSQgdRxiwnpRBVyECXJFAX5UI7rUK4WG3
+ AL4dJDD0LYFHvQI62CmkAxhKfG7wYYRV6gkm8/JJAKtWkc0zFTKb+61GETTvY6HjEAJMuwMCTzvQgxXs
+ x+NCdvlyEjYbQTP5jOWaCOoiFdAUy0K7hoHO4RzonioHMJQemIWYzCLaWyGht4ql4CyU4a7JoSNVDpgD
+ XzXsUkpGIMjLL5O3LBbv1WYmYife21EshhvrOajdpoTGKAW0JjBgPioHezbmwbgqJMYqhNYggrs1YujD
+ 3LhdJoHuL6WY8DKEZqAtiYXhKpQ4CrBwIfl1dfXTA2i+IoKyoxK4+KkMru5loPIACw0pfCViwJ4rh65z
+ MkxmKdw2YEX677CVS6CnVArdF9D7Z2SAfQCwDwBfgvlSPNwHVo+cJn9SXEwefh8vO50EsBrB6dMCyMoS
+ o0nhJG75iRMs6HQcVFUtAKczGHvKd2a9ogLsxIDNDBNaBt3nsaxechsvnAfDTgy2IhYcTYHQVhkIcX+T
+ R2An/j124mXYiZeOALBY+np8AWhqIlBUJEBhIhQpQZPhawbFKqCkJAAslqBxIscKnvi686IaYxrzIYMB
+ HBcAq4wrVHjROAsBzkIuQOslzrVmQYG6H3tM4KQqxL+Rnk7MUwHk5YlQoBSN96YCF1FBXd0Cn0V6AzCf
+ VQNOo4DTKOA0ChZ0hL1cDZ0nEUrL5wkDOI2CtUTt+nupqarqqTq+a5RITSU1UwMo5kTsVCBtOjXgeYBP
+ SmjXKsHR6naMvQ7D5RCLyc4CngfAWh7oej8uTnnGI4BGQ65NBGhpIXARt9mbF7/PtZasAKxMHLSdUoPT
+ Pj70bF8HQmOMEnD4A5vJDbZxI3PAIwDOKhcmApw7J4TOTt9jeqYwzRmB0H7e7d2prLN8AZi2cOAwB7kK
+ QEiIbINHgNhYopsIkJ8veWre5wU7bdM7x2Jwe7+8PHDomWfIix4Bdu0iGRMB9FgNZurVp3W/VqvqxAo0
+ 5aMXVxLzZ4HJAKzfAMTHK0s9nTlcAGFhJHYsgMNBID/fXX/9wSIj2eNeAfDYuGMsgMEggOrquan3c+GA
+ devkUV4B8Fi4fixAfr7ILzzPw7e0BMGSJdJVXgFeeYX8deypLA+Pe3PhublYIz8/YAATOMArwHPPkd/U
+ 1X03ker1OGD5SfwnJ3O13h4auJIYf35WVkYej4SRXv/0RoiZOiYmRlnoC4AqP9/9ZKKxkcDlywF+swPh
+ 4QrNtAD8DVotsfIAZ88KwWr1j/LpcATDypWyTT4B4GOReh4gL0/sN943GAKfLFok/ZVPAElJ5DoPoNP5
+ zwiRmqrs8zRCjJ6JR17gc89LPIBe7z8jRGwsa/HmfVcBGrlhzx6i55+mFRT4zwixc6f8rM8Au3eTE1ev
+ CqCmZn5GCJstGAyGgG+ys1Xm9HTu6sGD3Km33/bcgSeF0Pbt5BB/Bp5pnZ7J/XxVMRoXDOXkqJzHjnEV
+ Go1SHxWlSAwLYz5etky6Ch/p/2g6j0+8PhpC69eT/+j1czNCmPAYqNer+rVarjYxkSuKjlYe/ugj+a7X
+ X5euDQ4mz2NiimYq1OsowV9cu5Z8otMxPu9AY2MQ9gz1NxkZnCUpSVkSE6M4Hh7Oxr35puyDF16QLEaR
+ Xr+gnnOAN94g4Xl540eI9vYg/mA/lJmpuJ2WpjBhVdBt3apIWL2a2bp4sWwFilTPlZDZrjMaQvgtzR8j
+ IpjOhATWsGMHk/7OO/LIV1+V/nk2cTlbMbP53Lz+q8FsBHtM4rlYbD7W+D9MzRR6eEGuxwAAAABJRU5E
+ rkJggg==
+</value>
+ </data>
+ <data name="mbox_info.png" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAABcQwAA
+ XEMBOS4mtwAABL5JREFUaEPVmX1olVUcx0+3ba6VDmP7w15w+TJ0rJc/EhuytuqP0Gz4UqhoDoLYcOAW
+ TpQFW2KaKFZihbMg/CdCxTeU0VK2P0SdzD9CGlsrfGtg7Y81pFjiPH5/u7vee16fc577aHcXvmz3uec5
+ 5/s5v3N+5zzneYRzzib0hwAmsia0+bHRE3XvYzg+DS2E6qAt0G5oF9QMfQC9Bk2Nqt1IAGCoHPqCsVgf
+ /tKkctHFccDSdGDSAoCBasYe7XY0bINqo6iFAQkFgMbeYCyLetClp33KHEGdJT4g3gBo4NNg46/A9PtQ
+ M7QL2gk1QWugF12A6lwhnAFgejJjORRqg4F3cP0w9M9YarDrT/z+DfS6DeYrFwgnAJguZGzSJb35apj4
+ xcG0CaoT975pAvk+CCIQAKazGcvtUs0XodGTaRiXgVpRV5YO5IANwgEg+5Bqnnrsr0DzM2ZwvnEj5ytW
+ BA2pxO+XUOccHcRWE4QVAMYbVfNLA43T+C8q4nx4GM2Of/budYX4wzTR39ZBGAFgfK5qvsLJPAHU1yfN
+ 039DQ64AVO436Ck5Er96AmQfFgGmoMLfnQEWLxYBurt9AKhsm24oNcsQ2gjAeJna+986m0+k0G3bOB8Y
+ 4Pz8ec5LsWEITq9ymQ0yxC1K56kQBoDYARHAfej4m7SB0ZpSIENssALEFyx2VwQ4FqL3wvS47p5PZICf
+ gwBWi+aL/0fzBHRTNxdeSEAoQwjmvxMBNnsDlJVxXlGhV2FhmMgskiEaLAA5/SLAGS+Aqiox+8jfenvD
+ AHwmA/ygBYhvG+TN2i0vgAULOB8dNUN0dIQBOCsDXDYBzBIBnvUyn8hAxcWcL1/O+eBgEqS1lfPKSs6z
+ ssIADCrp1AQwXwR4ORRAAuTKlSRATU0Y46n3KBu9HIIQJjHMvyoClGcQwGQ5ClN0ANIKPD+DAHJlgMd0
+ ANIGbmaGAAzL5kdMc+AJNQvdCQ0R3Ryg5wQhO97fmWoWstg1sfCFDADYLwMcs63EB0WA7RkAsFIG+MgG
+ UCsChJ/I0Qyh/2A+TwbAchk/lNbthZ5R5wGthP55PBqAfbL5qw7PA+yECPGuM0BuLufTp8d140ZyIWtq
+ il8rKPDtiBIZYLsLQJUahVNOEO3t9s0c7ZNoS+EW0d2yefqOs47kOw3bQ32nCDEXN98ObLinxw5Av65d
+ 6wJwGW3FZICvU81r58D9yYFzPzUK7wUClJdz3tJiVgN28nl5QQC09lDyEHI/PQ9PcwYYo2PscxWCHrSD
+ DKT7+xLd0KmVzVsjkBKJcypE3QOCoC3DWzrzxuNFh6NFNhsAAyoEHS/2RwjSgbqUjEMwnbqeN64D2jAx
+ Ng8VDaoQ2WhgR5oQ9LDyoa7X6RodKiPxmt+kBkYgZSi9hMp6VQiaaHQM+DHU5wHThbLroRyT+R/RVr7N
+ vNMcEHIuegOV0msgU6O4/jxUA+2BjkCnoXboIERvayiTPWe5f6zuPUHGvYaQkrrir1D/toOEen9GEV7m
+ at47AlI0nkRjO6F/IwC5jjoafYynFQEJ5HE0vg464wkygvJHoVVhjEcGIMHkw9AiaBO0Hzo+DvbT+Nz5
+ En/roUoolo7xBwIQhSHfOpzTqG/FD6v8PRJO78MpB02PAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="No">
+ <value>No</value>
+ </data>
+ <data name="mbox_question.png" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAABcQwAA
+ XEMBOS4mtwAAA1pJREFUaEPtl11oUmEYx/2aigx30ag2XXURYQwTkiBDMaSrugi61CBidhVaKUF4M6Iy
+ ugga9kHBRqMkKiq6ihYYMYqtj6tiUBch0UAq4oSY0Nbs/4xz4PBybJ4v5wGFP8ej7/ue/+99nvO872tu
+ NBomQ38IwMgytPnl7DHy7HcBOiF63RQSRwHlOAaN9fb2vnW5XN+dTudvfK95vd5v4XD4/ejo6KNqtZpD
+ n4PQdsiqNoqaRACmh6E3EC0q/5Xb7ebS6fRYxwDAcADiVjIu/t9sNjcSicQsIE5DATVRUBUBmLJAH+SY
+ F7fN5XLPYJ6isVcphFqA/UrNUz+8H3WO467wEDuVQKgFuMEC2O32xWQy+XJmZuZmpVK5Vi6XrxeLxfs+
+ n++rFGyhUHjMA5zHtUcuhFqAV6ypeDz+mjd0Edc9UD/kHBkZGUTbRbZ9KpV6wbenVBpuN8BH1tDU1NRt
+ 3tA+psT2oO0ftn0mk3kuAoi2G2BWbGhoaOiHyMwgA3BAKoUmJiYeiPqE2w0QHRgYqGDRqvn9/i+lUumW
+ FACM26E5FqCvr69Wr9cLqwbAz1YWVxLlsKBTzOxfZc1bLJalfD7/hOm3pa0R4B+2GVcSmaZKchRaLxiB
+ 8ROseZvNtoBtxVPG/Fncy95aqKpCK80WjFPe/xUDYH/E3cOHMX8J97Q3ku1HdodWHwLTG6FfYvMOh+Pn
+ 9PT0JGOeyu2OVsdl2+kJcJdNHabi0PtyDtqk1Dz10wUAxtdAC2IA2jZI5PxaNeb1BIiysx8MBj+rrThS
+ sHpFYBsLkM1mS4YBWA6tyXSHIGjvHwqFPtVqtcsiACq3mkyeJoM0M4NqGaQdKTPz9PIeMQQATNJ+SLxC
+ C99l73maAesaAf6hhxiIw7iXveK2FQC53w8dE4SD/EmPx7MLJpxapY4wjuYRgGk6J7+T2DrTqhwwAoBD
+ at/P/3a8C8CUXz1SqGkEIpEIHV6i0AatIqEHgBXpMs+mkdVqXRofH3/IV6QLuHq0gNAcgF+Ft+LQMhmL
+ xeYESZy+dncsAG/M1mQRExazLsBytLUIY5MxLPj9TJMo0BFS9gFe6jl6AtDY66CEhBSdf1cDQO8J0jWF
+ dDev9zvQBWilwLRllloxorRNF0DpzGnVz/AR+AcOBL1o7Kmu0QAAAABJRU5ErkJggg==
+</value>
+ </data>
+ <data name="Retry">
+ <value>Retry</value>
+ </data>
+ <data name="desktop" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAACj1JREFUaEPtmQtQ
+ E3cex9eKr7vO2evUu/Zs72F7147edTrezdmWdmyvnfM8q5718BwRX1WEU4vYIohKtYjhKSQ8E0ICojwl
+ ikAtiqL4FpQozxACBAiEEBIgLIIC3/vvQtLwTBC8a2eOme8kM1l2P9/v7/vf3WymAKB+0H+MgR+yftDw
+ bHu+z+lT1PZn58zZ/dbixd5bV22J4qz2yUz+RHjr1ofRd2pmHinY+D83QABnzJ69a76t7WGHVfahh+0O
+ nT6xQnD96ieJUtmnkqJG+wvlHTultX1u1Rp4qrTgNGvANzTCt1KO6cIq36dugADaTJ/uPG/Roq/sVnwa
+ dNDOMyVmZfiV3GUnCsv+kfZA9a9zZe1OBcpe18omfFHbAi91M47pmwikekwdliswPabaf8IGCOAzRC8v
+ XHjwk6V/9/VY82VC1Cruxexlx+8WrUy9X2eXWdq69WZNj4usCS7VOrjXa+Gj0YBLII06pqnHgfzrcE2N
+ h3uCEPvjwnFYenvQNubbM+89y6sZAwFWGSCAP58/f99fliw5usdul5i3OjA7c5k4X7oiSar89EyJbtO1
+ qkc7itXYqdDBRanrH3WTBr4E1ChOUxM87t3DzrQUfC7mY19cJHziw8A9GYq4U+G4k58GvT4fNC1lFSvh
+ Y883GYP2Yb6/PSVKYqAmaOASsP1Hr766992PPvLZZbeNH2h3NEtCFkrBigRp1SpJsXZ9rqJr+/1GOMt1
+ cFbosVtJRq1qxqGG4XIrKoNTegYco/lwFYbDSxQKX3EIIk9wkXP5JBobr5kgjbCjvebeTIWzKHrE4+x4
+ UEvWgPIYa+A9x3j+unw1HMtbsEXWiu1yPb6saYE7AR1Ju0tq8FlmDjZECeAUEQa3qBB8LQxGkDAQkkwh
+ 5PLzVkNaMiFXXIRjkD++lDcOYtlaWM8YCGYN2O7LEDmUtsKlklTAgrbweIhLDkVh4Wm0thZMGuhYRphq
+ fRHMgePNUhOfQ34DpglrQ/oNeGSI1txvg2Opfkw5RMejsCjriaGb2h/gVrMMSXW1ECsbIarRELUQtcGH
+ 1NPSNIJiebA/ncsyrrmhxrToWp7JwMqCdmyQto6qtSeykH0lyeJBFPpiXGioRHytCnFKNWKVzRDX6Mlr
+ O1LraORrOqFtp9HRMVhiYsSSAeZzSXY81vATsfKKBtMEdQMGSIWW3OiA3e32EbUy+RbiJNFjHuCwrA1x
+ NQZ820CjQtcJwxDAocBPaoAxcfd+FhYHJDIGwkwT+OBKB5bnGYbpb6dl4AhCLKYjJvCWIMf63NoJGAz3
+ cD4pGPZvvo2tz72kXUtR/2TXwDsXaHx8oWOQPjyrhosfxyI8k8rTNnDzjgQhCQI4bFoPLbl9yyNqIIqg
+ qPOsgYVZD/FeZqdJtukG2B/0QXv7vadqwGCg0U4kqh6+BhSKHEQkRsErIR5H7skQ2Qa4+fmjj4D3EgmJ
+ 3CgqlzWwIK0Lf0x9aNIyj0BoNDetgh/vBBhoFpws5rY2Gq1ERgPNzTcRlyaAd4IYB3KustDmCiSL3c1h
+ HQ7MfQ3v/3n13V9T1M8oW/cM0WsJ3VhwvIvVBx4CVFRetBreWgMmaCN4Kw09kbbFAPfUb+B3Uoh9krPg
+ abqGgYeoDPBKSwMvOQZXriVhoWs0poU1CPoXMTHwsqgb8/jd+JOnBNfvnB4X/FgGRoPW62nkXS9AQHwy
+ 3E+mIUChGQYdru/FV+fOIzBJBElWDLlwfnev9OauGNiENkSbDMyJeIzfeN5CSmb8uOGHGjD22rwiTNIM
+ tI4oIycP++NT8XVB2TBopi7eN+7CJzEW4pRIqFR5I/IscBbChtcYYzLwk2M9eH1b7BPBGw0M7XWrGXSL
+ jkZLCwN/FQezh3ebU65iF2t4QgSKijMtcsx3JBMIaRSZDMw42ot5m57cgKja0L8gB3rNJK1joIm0BLxZ
+ SyP928vwzLhoSp3p9b6kdPjFJsPjVLZFaPMr9etbRLA5phabDFAHgV+uOz6unZjvUFhlYOthDq0l0Ay4
+ ppnGEcld7OSlQXA8FTxxMgLjUiBOTEdVjQ715OrNl1t3K2E85m83xMImUB03eQYUBjZpY9oMNKMmDQ11
+ E41L8k48e6IPaSUPoWqkWeh6FY06otp6YqBifAZ+t9HcwN6z4olOILrSwAKbQzcS8EY1jQYCzEAfud2N
+ 2Sf7kFvRyUIzUpIbvJpaGlHjNPD6RrHZBCbBgIAYUA+kzUITMdAqJmkiJuk6AvzXrMd4JbkXBZX94NVK
+ mtSIRqTM+gkUSM/h+c2XzQ2kiyY6AX6FgYU2pm2CHqgImzSRVEHjxcRe2Gb0oIy8V1TTqCSKJN8Grbmd
+ ZrZZvpsLag8m10AUMTC01wy0sSJs0gNpSx48xFtne+F67RFkZBIVxEiElQbSshIxa2vx5BuIlBmG9bra
+ rCIKUhMm6coqGnIibkEX1l7uAb+wC+VyGuFllifQ0VGId7fyWPhJn0B4uYHttHmvGWi2IgPQTNIVJHEm
+ 9dIKGr753eR50CNkFj9EeKllA4H8CDzjpH5KBkoNpooYe80kLWegiRhoJmlGZQS+VEa+XpbRCJN2Q3C/
+ G0ElY38n1mpvY8EGvgl+yATOTHgRhxIDTEWGQsuGQDPgJeU0igl8fimNaGknOA86yFlIPeYidvEOALWr
+ 8ykaKDGYkjamzSY9kPZdApxQRINX1I6IUi2EcjWSa5SoJA8BLJ19Ksmt/SvrEwfBT/oEuMUGUz0KScIM
+ LJfAMotTUNEPK9eXWIQdycwaF29Qrr2WDdg4N2D5jqPk8d/1cR/IqbAdYeU6ckVVI0lZC5nuyWDNDVRX
+ X0SEMAjPb7gwDH7QBN7b278G2NPT7h78fkMEzl1KHbcJS1UY7XPmydv1GynghAZjm9cxLHUJwx828vHC
+ +kxQjg2D4Q/0YYZfV+cs/1bVFH77jv5no+YGBs6xL2y+hP1B3Ek3UVWVg/gUAb44GoQ1e0Px7vZI/Mr+
+ OKZvkoJyefQd7F5gqvfjxzMDOnQzfVvKqED9Kep4zwHqDGypHMw0/1VpRAPMNKY6NWCpMwf19VfHbYRJ
+ Ne9aKry5wfjMi4slLpGYv1GI59Zng3LSDE21b4bfQ3qWX2v9NF/tNSqCDqNSsJGAzrXm569RDbCVIovn
+ DQcBzp5PHtUE8/gjhjyzcT3KxWq3cCzaHo256xIwdVMRqeTj4an6k1Q5LaUk1VSSqieVjncI7AxrYEfa
+ hnp/hAoZL9fG159uzsNefy4u5aXiUAgPm73C8fHnAjC3tT+2vwjKuWV4qr4kVV993TSONo+kyiWpOhDQ
+ Xzwp6Gj/Z5UBxsiUf2sxZXP54FOaW39XZ/l3tMzkaEumBOiTqPgeD5Lq2xNJdTwmrTZAHejrm9Gfai1J
+ 9TIV0RlMUl1PQF8azwEne9vhBvpTfTTLz6AlqRaTVBNJV92ps1hEYKdPNsBE90e9sSfTaWZwm8qGo82l
+ IjsDSarrCOiLE93xf+v/v9e/1FsTwv8NWJPS09zmP/rAGm4g64OPAAAAAElFTkSuQmCC
+</value>
+ </data>
+ <data name="mono.ico" type="System.Drawing.Icon, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ AAABAAEAICAQAAAAAADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAgAIAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP//
+ AAD///8Ad3gAAAAAAAAAAAAAAAAAAHd3AAAAAAAAAAAAAAAAAAB3d4AAAAAAAAAACIAAAAAAd3d4AAAA
+ AAAACIeAAAAAAHd3d4AAAAAACId3eAAAAAB3d3d4AAAACId3d3cAAAAAd3d3dwAAiHd3d3d3gAAAAHd3
+ d3eAiHd3d3d3eAAAAAB3d3d3eHd3d3d3d4iAAAAAd3d3d3d3d3d3d3iHeAAAAHd3d3d3d3d3d3eId3gA
+ AAB3d3d3d3d3d3d4h3d4AAAAd3d3d3d3d3d3eHd3eAAAAHd3d3d3d3d3d3d3d3gAAAB3d3d3d3d3d3d3
+ d3dwAAAAd3d3d3d3d3d3d3d3gAAAAHd3d3d3d3d3d3d3d4AAAAB3d3d3d3d3d3d3d3eAAAAAd3d3d3d3
+ d3d3d3d4AAAAAIh3d3d4d3d3d3eIiHgAAAAAiIiIh3d3d3d3d3d4AAAAAAAAh3d3d3d3d3d3eAAAAAAA
+ CHd3d3d3d3d3d3gAAAAAAId3d3d3d3d3d3eAAAAAAACHd3d3d3d3d3d3gAAAAAAAh3d3d3d3d3d3d4AA
+ AAAAAId3d3d3d3d3d3gAAAAAAAAIiIiHd3d3d4iAAAAAAAAAAAAAiIiIiAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH////B//5/wP/wP8A/wB/APwAfwBw
+ AD8AQAA/AAAAfwAAAD8AAAAfAAAAHwAAAB8AAAAfAAAAHwAAAB8AAAA/AAAAPwAAAD8AAAAfAAAAHwAA
+ AB/AAAAf4AAAH+AAAB/gAAA/4AAAP+AAAH/wAAD/+AAB///AP////////////w==
+</value>
+ </data>
+</root>
diff --git a/mcs/class/Managed.Windows.Forms/resources/create-keyboards.cs b/mcs/class/Managed.Windows.Forms/resources/create-keyboards.cs
new file mode 100644
index 00000000000..6023d60c1fb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/resources/create-keyboards.cs
@@ -0,0 +1,2069 @@
+
+using System;
+using System.Resources;
+using System.Windows.Forms;
+
+
+
+public class CreateKeyboards
+{
+ public static void Main()
+ {
+ ResXResourceWriter rsxw = new ResXResourceWriter ("keyboards.resx");
+ KeyboardLayout [] table = new KeyboardLayout [64];
+
+ table [0] = new KeyboardLayout (1033, "United States keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0x5b, 0x7b, },
+ new uint [] {0x5d, 0x7d, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0x3b, 0x3a, }, new uint [] {0x27, 0x22, },
+ new uint [] {0x5c, 0x7c, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3c, }, new uint [] {0x2e, 0x3e, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {},
+ new uint [] {}, });
+ table [1] = new KeyboardLayout (1033, "United States keyboard layout (phantom key version)", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0x5b, 0x7b, },
+ new uint [] {0x5d, 0x7d, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0x3b, 0x3a, }, new uint [] {0x27, 0x22, },
+ new uint [] {0x5c, 0x7c, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3c, }, new uint [] {0x2e, 0x3e, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [2] = new KeyboardLayout (1033, "United States keyboard layout (dvorak)", 1, 2, new uint [][] {
+ new uint [] {0x60, 0x7e, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x5b, 0x7b, },
+ new uint [] {0x5d, 0x7d, }, new uint [] {0x27, 0x22, },
+ new uint [] {0x2c, 0x3c, }, new uint [] {0x2e, 0x3e, },
+ new uint [] {0x70, 0x50, }, new uint [] {0x79, 0x59, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x63, 0x43, }, new uint [] {0x72, 0x52, },
+ new uint [] {0x6c, 0x4c, }, new uint [] {0x2f, 0x3f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x6f, 0x4f, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x75, 0x55, }, new uint [] {0x69, 0x49, },
+ new uint [] {0x64, 0x44, }, new uint [] {0x68, 0x48, },
+ new uint [] {0x74, 0x54, }, new uint [] {0x6e, 0x4e, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x5c, 0x7c, }, new uint [] {0x3b, 0x3a, },
+ new uint [] {0x71, 0x51, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x78, 0x58, },
+ new uint [] {0x62, 0x42, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x76, 0x56, },
+ new uint [] {0x7a, 0x5a, }, new uint [] {},
+ new uint [] {}, });
+ table [3] = new KeyboardLayout (1033, "United States International keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x5c, 0x7c, },
+ new uint [] {0x71, 0x51, }, new uint [] {0x77, 0x57, },
+ new uint [] {0x65, 0x45, }, new uint [] {0x72, 0x52, },
+ new uint [] {0x74, 0x54, }, new uint [] {0x79, 0x59, },
+ new uint [] {0x75, 0x55, }, new uint [] {0x69, 0x49, },
+ new uint [] {0x6f, 0x4f, }, new uint [] {0x70, 0x50, },
+ new uint [] {0x5b, 0x7b, }, new uint [] {0x5d, 0x7d, },
+ new uint [] {0x61, 0x41, }, new uint [] {0x73, 0x53, },
+ new uint [] {0x64, 0x44, }, new uint [] {0x66, 0x46, },
+ new uint [] {0x67, 0x47, }, new uint [] {0x68, 0x48, },
+ new uint [] {0x6a, 0x4a, }, new uint [] {0x6b, 0x4b, },
+ new uint [] {0x6c, 0x4c, }, new uint [] {0x3b, 0x3a, },
+ new uint [] {0x27, 0x22, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3c, }, new uint [] {0x2e, 0x3e, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {},
+ new uint [] {}, });
+ table [4] = new KeyboardLayout (2057, "British keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x60, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0xffffffa3, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0x5b, 0x7b, },
+ new uint [] {0x5d, 0x7d, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0x3b, 0x3a, }, new uint [] {0x27, 0x40, },
+ new uint [] {0x23, 0x7e, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3c, }, new uint [] {0x2e, 0x3e, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {0x5c, 0x7c, },
+ new uint [] {}, });
+ table [5] = new KeyboardLayout (1031, "German keyboard layout", 0, 1, new uint [][] {
+ new uint [] {0x5e, 0xffffffb0, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0xffffffa7, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, },
+ new uint [] {0x38, 0x28, }, new uint [] {0x39, 0x29, },
+ new uint [] {0x30, 0x3d, }, new uint [] {0xffffffdf, 0x3f, },
+ new uint [] {0xffffffb4, 0x60, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x7a, 0x5a, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xfffffffc, 0xffffffdc, },
+ new uint [] {0x2b, 0x2a, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xfffffff6, 0xffffffd6, }, new uint [] {0xffffffe4, 0xffffffc4, },
+ new uint [] {0x23, 0x27, }, new uint [] {0x79, 0x59, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x3c, 0x3e, 0x7c, },
+ new uint [] {}, });
+ table [6] = new KeyboardLayout (1031, "German keyboard layout without dead keys", 0, 1, new uint [][] {
+ new uint [] {0x5e, 0xffffffb0, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0xffffffa7, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, 0x7b, },
+ new uint [] {0x38, 0x28, 0x5b, }, new uint [] {0x39, 0x29, 0x5d, },
+ new uint [] {0x30, 0x3d, 0x7d, }, new uint [] {0xffffffdf, 0x3f, 0x5c, },
+ new uint [] {0xffffffb4, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x7a, 0x5a, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xfffffffc, 0xffffffdc, },
+ new uint [] {0x2b, 0x2a, 0x7e, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xfffffff6, 0xffffffd6, }, new uint [] {0xffffffe4, 0xffffffc4, },
+ new uint [] {0x23, 0x27, }, new uint [] {0x79, 0x59, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [7] = new KeyboardLayout (1031, "German keyboard layout for logitech desktop pro", 0, 1, new uint [][] {
+ new uint [] {0x5e, 0xffffffb0, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0xffffffa7, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, 0x7b, },
+ new uint [] {0x38, 0x28, 0x5b, }, new uint [] {0x39, 0x29, 0x5d, },
+ new uint [] {0x30, 0x3d, 0x7d, }, new uint [] {0xffffffdf, 0x3f, 0x5c, },
+ new uint [] {0x27, 0x60, }, new uint [] {0x71, 0x51, 0x40, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x7a, 0x5a, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xfffffffc, 0xffffffdc, },
+ new uint [] {0x2b, 0x2a, 0x7e, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xfffffff6, 0xffffffd6, }, new uint [] {0xffffffe4, 0xffffffc4, },
+ new uint [] {0x23, 0x27, }, new uint [] {0x79, 0x59, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x3c, 0x3e, 0x7c, },
+ new uint [] {}, });
+ table [8] = new KeyboardLayout (1031, "German keyboard layout without dead keys 105", 0, 3, new uint [][] {
+ new uint [] {0x5e, 0xffffffb0, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, 0xffffffb2, }, new uint [] {0x33, 0xffffffa7, 0xffffffb3, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, 0x7b, },
+ new uint [] {0x38, 0x28, 0x5b, }, new uint [] {0x39, 0x29, 0x5d, },
+ new uint [] {0x30, 0x3d, 0x7d, }, new uint [] {0xffffffdf, 0x3f, 0x5c, },
+ new uint [] {0x27, 0x60, }, new uint [] {0x71, 0x51, 0x40, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x7a, 0x5a, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xfffffffc, 0xffffffdc, },
+ new uint [] {0x2b, 0x2a, 0x7e, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xfffffff6, 0xffffffd6, }, new uint [] {0xffffffe4, 0xffffffc4, },
+ new uint [] {0x23, 0x27, }, new uint [] {0x3c, 0x3e, 0x7c, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x78, 0x58, },
+ new uint [] {0x63, 0x43, }, new uint [] {0x76, 0x56, },
+ new uint [] {0x62, 0x42, }, new uint [] {0x6e, 0x4e, },
+ new uint [] {0x6d, 0x4d, }, new uint [] {0x2c, 0x3b, },
+ new uint [] {0x2e, 0x3a, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {}, });
+ table [9] = new KeyboardLayout (2055, "Swiss German keyboard layout", 0, 1, new uint [][] {
+ new uint [] {0xffffffa7, 0xffffffb0, }, new uint [] {0x31, 0x2b, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0x2a, },
+ new uint [] {0x34, 0xffffffe7, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, },
+ new uint [] {0x38, 0x28, }, new uint [] {0x39, 0x29, },
+ new uint [] {0x30, 0x3d, }, new uint [] {0x27, 0x3f, },
+ new uint [] {0x5e, 0x60, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x7a, 0x5a, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xfffffffc, 0xffffffe8, },
+ new uint [] {0xffffffa8, 0x21, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xfffffff6, 0xffffffe9, }, new uint [] {0xffffffe4, 0xffffffe0, },
+ new uint [] {0x24, 0xffffffa3, }, new uint [] {0x79, 0x59, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [10] = new KeyboardLayout (4108, "Swiss French keyboard layout", 0, 1, new uint [][] {
+ new uint [] {0xffffffa7, 0xffffffb0, }, new uint [] {0x31, 0x2b, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0x2a, },
+ new uint [] {0x34, 0xffffffe7, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, },
+ new uint [] {0x38, 0x28, }, new uint [] {0x39, 0x29, },
+ new uint [] {0x30, 0x3d, }, new uint [] {0x27, 0x3f, },
+ new uint [] {0x5e, 0x60, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x7a, 0x5a, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xffffffe8, 0xfffffffc, },
+ new uint [] {0xffffffa8, 0x21, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xffffffe9, 0xfffffff6, }, new uint [] {0xffffffe0, 0xffffffe4, },
+ new uint [] {0x24, 0xffffffa3, }, new uint [] {0x79, 0x59, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [11] = new KeyboardLayout (1053, "Swedish keyboard layout", 0, 5, new uint [][] {
+ new uint [] {0xffffffa7, 0xffffffbd, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0xffffffa4, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, },
+ new uint [] {0x38, 0x28, }, new uint [] {0x39, 0x29, },
+ new uint [] {0x30, 0x3d, }, new uint [] {0x2b, 0x3f, },
+ new uint [] {0xffffffb4, 0x60, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xffffffe5, 0xffffffc5, },
+ new uint [] {0xffffffa8, 0x5e, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xfffffff6, 0xffffffd6, }, new uint [] {0xffffffe4, 0xffffffc4, },
+ new uint [] {0x27, 0x2a, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [12] = new KeyboardLayout (1061, "Estonian keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0xffffffb7, 0x7e, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0xffffffa4, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, },
+ new uint [] {0x38, 0x28, }, new uint [] {0x39, 0x29, },
+ new uint [] {0x30, 0x3d, }, new uint [] {0x2b, 0x3f, },
+ new uint [] {0xffffffb4, 0x60, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xfffffffc, 0xffffffdc, },
+ new uint [] {0xfffffff5, 0xffffffd5, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xfffffff6, 0xffffffd6, }, new uint [] {0xffffffe4, 0xffffffc4, },
+ new uint [] {0x27, 0x2a, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [13] = new KeyboardLayout (1044, "Norwegian keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x7c, 0xffffffa7, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, 0x40, }, new uint [] {0x33, 0x23, 0xffffffa3, },
+ new uint [] {0x34, 0xffffffa4, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, 0x7b, },
+ new uint [] {0x38, 0x28, 0x5b, }, new uint [] {0x39, 0x29, 0x5d, },
+ new uint [] {0x30, 0x3d, 0x7d, }, new uint [] {0x2b, 0x3f, },
+ new uint [] {0x5c, 0x60, 0xffffffb4, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xffffffe5, 0xffffffc5, },
+ new uint [] {0xffffffa8, 0x5e, 0x7e, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xfffffff8, 0xffffffd8, }, new uint [] {0xffffffe6, 0xffffffc6, },
+ new uint [] {0x27, 0x2a, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [14] = new KeyboardLayout (1030, "Danish keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0xffffffbd, 0xffffffa7, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0xffffffa4, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, },
+ new uint [] {0x38, 0x28, }, new uint [] {0x39, 0x29, },
+ new uint [] {0x30, 0x3d, }, new uint [] {0x2b, 0x3f, },
+ new uint [] {0xffffffb4, 0x60, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xffffffe5, 0xffffffc5, },
+ new uint [] {0xffffffa8, 0x5e, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xffffffe6, 0xffffffc6, }, new uint [] {0xfffffff8, 0xffffffd8, },
+ new uint [] {0x27, 0x2a, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [15] = new KeyboardLayout (1036, "French keyboard layout", 0, 4, new uint [][] {
+ new uint [] {0xffffffb2, }, new uint [] {0x26, 0x31, },
+ new uint [] {0xffffffe9, 0x32, 0x7e, }, new uint [] {0x22, 0x33, 0x23, },
+ new uint [] {0x27, 0x34, 0x7b, }, new uint [] {0x28, 0x35, 0x5b, },
+ new uint [] {0x2d, 0x36, 0x7c, }, new uint [] {0xffffffe8, 0x37, 0x60, },
+ new uint [] {0x5f, 0x38, 0x5c, }, new uint [] {0xffffffe7, 0x39, 0x5e, 0xffffffb1, },
+ new uint [] {0xffffffe0, 0x30, 0x40, }, new uint [] {0x29, 0xffffffb0, 0x5d, },
+ new uint [] {0x3d, 0x2b, 0x7d, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x7a, 0x5a, }, new uint [] {0x65, 0x45, 0xffffffbf, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0x5e, 0xffffffa8, },
+ new uint [] {0x24, 0xffffffa3, 0xffffffa4, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x73, 0x53, 0xffffffdf, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0x6d, 0x4d, }, new uint [] {0xfffffff9, 0x25, },
+ new uint [] {0x2a, 0xffffffb5, }, new uint [] {0x77, 0x57, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x2c, 0x3f, },
+ new uint [] {0x3b, 0x2e, }, new uint [] {0x3a, 0x2f, },
+ new uint [] {0x21, 0xffffffa7, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [16] = new KeyboardLayout (3084, "Canadian French keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x23, 0x7c, 0x5c, }, new uint [] {0x31, 0x21, 0xffffffb1, },
+ new uint [] {0x32, 0x22, 0x40, }, new uint [] {0x33, 0x2f, 0xffffffa3, },
+ new uint [] {0x34, 0x24, 0xffffffa2, }, new uint [] {0x35, 0x25, 0xffffffa4, },
+ new uint [] {0x36, 0x3f, 0xffffffac, }, new uint [] {0x37, 0x26, 0xffffffa6, },
+ new uint [] {0x38, 0x2a, 0xffffffb2, }, new uint [] {0x39, 0x28, 0xffffffb3, },
+ new uint [] {0x30, 0x29, 0xffffffbc, }, new uint [] {0x2d, 0x5f, 0xffffffbd, },
+ new uint [] {0x3d, 0x2b, 0xffffffbe, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, 0xffffffa7, },
+ new uint [] {0x70, 0x50, 0xffffffb6, }, new uint [] {0x5e, 0x5e, 0x5b, },
+ new uint [] {0xffffffb8, 0xffffffa8, 0x5d, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0x3b, 0x3a, 0x7e, }, new uint [] {0x60, 0x60, 0x7b, },
+ new uint [] {0x3c, 0x3e, 0x7d, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x27, 0x2d, }, new uint [] {0x2e, },
+ new uint [] {0xffffffe9, 0xffffffc9, }, new uint [] {0xffffffab, 0xffffffbb, 0xffffffb0, },
+ new uint [] {}, });
+ table [17] = new KeyboardLayout (3084, "Canadian French keyboard layout (CA_fr)", 0, 0, new uint [][] {
+ new uint [] {0x23, 0x7c, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0x2f, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x3f, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0x5e, 0x5e, },
+ new uint [] {0xffffffb8, 0xffffffa8, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0x3b, 0x3a, }, new uint [] {0x60, 0x60, },
+ new uint [] {0x3c, 0x3e, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x27, }, new uint [] {0x2e, },
+ new uint [] {0xffffffe9, 0xffffffc9, }, new uint [] {0xffffffab, 0xffffffbb, },
+ new uint [] {}, });
+ table [18] = new KeyboardLayout (3084, "Canadian keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x2f, 0x5c, }, new uint [] {0x31, 0x21, 0xffffffb9, 0xffffffa1, },
+ new uint [] {0x32, 0x40, 0xffffffb2, }, new uint [] {0x33, 0x23, 0xffffffb3, 0xffffffa3, },
+ new uint [] {0x34, 0x24, 0xffffffbc, 0xffffffa4, }, new uint [] {0x35, 0x25, 0xffffffbd, },
+ new uint [] {0x36, 0x3f, 0xffffffbe, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, 0xfffffff8, 0xffffffd8, },
+ new uint [] {0x70, 0x50, 0xfffffffe, 0xffffffde, }, new uint [] {0x5e, 0xffffffa8, 0xffffffa8, },
+ new uint [] {0xffffffe7, 0xffffffc7, 0x7e, }, new uint [] {0x61, 0x41, 0xffffffe6, 0xffffffc6, },
+ new uint [] {0x73, 0x53, 0xffffffdf, 0xffffffa7, }, new uint [] {0x64, 0x44, 0xfffffff0, 0xffffffd0, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0x3b, 0x3a, 0xffffffb4, }, new uint [] {0xffffffe8, 0xffffffc8, },
+ new uint [] {0xffffffe0, 0xffffffc0, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, 0xffffffa2, 0xffffffa9, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, 0xffffffb5, 0xffffffba, },
+ new uint [] {0x2c, 0x27, }, new uint [] {0x2e, 0x22, 0xffffffb7, 0xfffffff7, },
+ new uint [] {0xffffffe9, 0xffffffc9, }, new uint [] {0xfffffff9, 0xffffffd9, },
+ new uint [] {}, });
+ table [19] = new KeyboardLayout (2060, "Belgian keyboard layout", 0, 4, new uint [][] {
+ new uint [] {}, new uint [] {0x26, 0x31, 0x7c, },
+ new uint [] {0xffffffe9, 0x32, 0x40, }, new uint [] {0x22, 0x33, 0x23, },
+ new uint [] {0x27, 0x34, }, new uint [] {0x28, 0x35, },
+ new uint [] {0xffffffa7, 0x36, 0x5e, }, new uint [] {0xffffffe8, 0x37, },
+ new uint [] {0x21, 0x38, }, new uint [] {0xffffffe7, 0x39, 0x7b, },
+ new uint [] {0xffffffe0, 0x30, 0x7d, }, new uint [] {0x29, 0xffffffb0, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x7a, 0x5a, }, new uint [] {0x65, 0x45, 0xffffffa4, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0x5e, 0xffffffa8, 0x5b, },
+ new uint [] {0x24, 0x2a, 0x5d, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x73, 0x53, 0xffffffdf, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0x6d, 0x4d, }, new uint [] {0xfffffff9, 0x25, 0xffffffb4, },
+ new uint [] {0xffffffb5, 0xffffffa3, 0x60, }, new uint [] {0x77, 0x57, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x2c, 0x3f, },
+ new uint [] {0x3b, 0x2e, }, new uint [] {0x3a, 0x2f, },
+ new uint [] {0x3d, 0x2b, 0x7e, }, new uint [] {0x3c, 0x3e, 0x5c, },
+ new uint [] {}, });
+ table [20] = new KeyboardLayout (2070, "Portuguese keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x5c, 0x7c, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, },
+ new uint [] {0x38, 0x28, }, new uint [] {0x39, 0x29, },
+ new uint [] {0x30, 0x3d, }, new uint [] {0x27, 0x3f, },
+ new uint [] {0xffffffab, 0xffffffbb, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0x2b, 0x2a, },
+ new uint [] {0xffffffb4, 0x60, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xffffffe7, 0xffffffc7, }, new uint [] {0xffffffba, 0xffffffaa, },
+ new uint [] {0x7e, 0x5e, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [21] = new KeyboardLayout (1046, "Brazilian ABNT-2 keyboard layout", 2, 6, new uint [][] {
+ new uint [] {0x27, 0x22, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0xffffffa8, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xffffffb4, 0x60, },
+ new uint [] {0x5b, 0x7b, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xffffffe7, 0xffffffc7, }, new uint [] {0x7e, 0x5e, },
+ new uint [] {0x5d, 0x7d, }, new uint [] {0x5c, 0x7c, },
+ new uint [] {0x7a, 0x5a, }, new uint [] {0x78, 0x58, },
+ new uint [] {0x63, 0x43, }, new uint [] {0x76, 0x56, },
+ new uint [] {0x62, 0x42, }, new uint [] {0x6e, 0x4e, },
+ new uint [] {0x6d, 0x4d, }, new uint [] {0x2c, 0x3c, },
+ new uint [] {0x2e, 0x3e, }, new uint [] {0x3b, 0x3a, },
+ new uint [] {0x2f, 0x3f, }, });
+ table [22] = new KeyboardLayout (1046, "Brazilian ABNT-2 keyboard layout ALT GR", 2, 6, new uint [][] {
+ new uint [] {0x27, 0x22, }, new uint [] {0x31, 0x21, 0x39, },
+ new uint [] {0x32, 0x40, 0x32, }, new uint [] {0x33, 0x23, 0x33, },
+ new uint [] {0x34, 0x24, 0x23, }, new uint [] {0x35, 0x25, 0x22, },
+ new uint [] {0x36, 0x28, 0x2c, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, 0x27, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0x34, 0x60, },
+ new uint [] {0x5b, 0x7b, 0x2a, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0x67, 0x47, }, new uint [] {0x7e, 0x5e, },
+ new uint [] {0x5d, 0x7d, 0x3a, }, new uint [] {0x5c, 0x7c, },
+ new uint [] {0x7a, 0x5a, }, new uint [] {0x78, 0x58, },
+ new uint [] {0x63, 0x43, }, new uint [] {0x76, 0x56, },
+ new uint [] {0x62, 0x42, }, new uint [] {0x6e, 0x4e, },
+ new uint [] {0x6d, 0x4d, }, new uint [] {0x2c, 0x3c, },
+ new uint [] {0x2e, 0x3e, }, new uint [] {0x3b, 0x3a, },
+ new uint [] {0x2f, 0x3f, 0x30, }, });
+ table [23] = new KeyboardLayout (1035, "Finnish keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0xffffffa7, 0xffffffbd, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0xffffffa4, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, },
+ new uint [] {0x38, 0x28, }, new uint [] {0x39, 0x29, },
+ new uint [] {0x30, 0x3d, }, new uint [] {0x2b, 0x3f, },
+ new uint [] {0xffffffb4, 0x60, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xffffffe5, 0xffffffc5, },
+ new uint [] {0xffffffa8, 0x5e, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xfffffff6, 0xffffffd6, }, new uint [] {0xffffffe4, 0xffffffc4, },
+ new uint [] {0x27, 0x2a, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [24] = new KeyboardLayout (1026, "Bulgarian bds keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, 0x28, 0x29, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, 0x32, 0x3f, }, new uint [] {0x33, 0x23, 0x33, 0x2b, },
+ new uint [] {0x34, 0x24, 0x34, 0x22, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, 0x36, 0x3d, }, new uint [] {0x37, 0x26, 0x37, 0x3a, },
+ new uint [] {0x38, 0x2a, 0x38, 0x2f, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, 0x2d, 0x49, },
+ new uint [] {0x3d, 0x2b, 0x2e, 0x56, }, new uint [] {0x71, 0x51, 0x2c, 0xfffffffb, },
+ new uint [] {0x77, 0x57, 0xfffffff3, 0xffffffd3, }, new uint [] {0x65, 0x45, 0xffffffe5, 0xffffffc5, },
+ new uint [] {0x72, 0x52, 0xffffffe8, 0xffffffc8, }, new uint [] {0x74, 0x54, 0xfffffff8, 0xffffffd8, },
+ new uint [] {0x79, 0x59, 0xfffffff9, 0xffffffd9, }, new uint [] {0x75, 0x55, 0xffffffea, 0xffffffca, },
+ new uint [] {0x69, 0x49, 0xfffffff1, 0xffffffd1, }, new uint [] {0x6f, 0x4f, 0xffffffe4, 0xffffffc4, },
+ new uint [] {0x70, 0x50, 0xffffffe7, 0xffffffc7, }, new uint [] {0x5b, 0x7b, 0xfffffff6, 0xffffffd6, },
+ new uint [] {0x5d, 0x7d, 0x3b, }, new uint [] {0x61, 0x41, 0xfffffffc, 0xffffffdc, },
+ new uint [] {0x73, 0x53, 0xffffffff, 0xffffffdf, }, new uint [] {0x64, 0x44, 0xffffffe0, 0xffffffc0, },
+ new uint [] {0x66, 0x46, 0xffffffee, 0xffffffce, }, new uint [] {0x67, 0x47, 0xffffffe6, 0xffffffc6, },
+ new uint [] {0x68, 0x48, 0xffffffe3, 0xffffffc3, }, new uint [] {0x6a, 0x4a, 0xfffffff2, 0xffffffd2, },
+ new uint [] {0x6b, 0x4b, 0xffffffed, 0xffffffcd, }, new uint [] {0x6c, 0x4c, 0xffffffe2, 0xffffffc2, },
+ new uint [] {0x3b, 0x3a, 0xffffffec, 0xffffffcc, }, new uint [] {0x27, 0x22, 0xfffffff7, 0xffffffd7, },
+ new uint [] {0x5c, 0x7c, 0x27, 0xffffffdb, }, new uint [] {0x7a, 0x5a, 0xfffffffe, 0xffffffde, },
+ new uint [] {0x78, 0x58, 0xffffffe9, 0xffffffc9, }, new uint [] {0x63, 0x43, 0xfffffffa, 0xffffffda, },
+ new uint [] {0x76, 0x56, 0xfffffffd, 0xffffffdd, }, new uint [] {0x62, 0x42, 0xfffffff4, 0xffffffd4, },
+ new uint [] {0x6e, 0x4e, 0xfffffff5, 0xffffffd5, }, new uint [] {0x6d, 0x4d, 0xffffffef, 0xffffffcf, },
+ new uint [] {0x2c, 0x3c, 0xfffffff0, 0xffffffd0, }, new uint [] {0x2e, 0x3e, 0xffffffeb, 0xffffffcb, },
+ new uint [] {0x2f, 0x3f, 0xffffffe1, 0xffffffc1, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [25] = new KeyboardLayout (1026, "Bulgarian phonetic keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, 0xfffffff7, 0xffffffd7, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x71, 0x51, 0xffffffff, 0xffffffdf, },
+ new uint [] {0x77, 0x57, 0xffffffe2, 0xffffffc2, }, new uint [] {0x65, 0x45, 0xffffffe5, 0xffffffc5, },
+ new uint [] {0x72, 0x52, 0xfffffff0, 0xffffffd0, }, new uint [] {0x74, 0x54, 0xfffffff2, 0xffffffd2, },
+ new uint [] {0x79, 0x59, 0xfffffffa, 0xffffffda, }, new uint [] {0x75, 0x55, 0xfffffff3, 0xffffffd3, },
+ new uint [] {0x69, 0x49, 0xffffffe8, 0xffffffc8, }, new uint [] {0x6f, 0x4f, 0xffffffee, 0xffffffce, },
+ new uint [] {0x70, 0x50, 0xffffffef, 0xffffffcf, }, new uint [] {0x5b, 0x7b, 0xfffffff8, 0xffffffd8, },
+ new uint [] {0x5d, 0x7d, 0xfffffff9, 0xffffffd9, }, new uint [] {0x61, 0x41, 0xffffffe0, 0xffffffc0, },
+ new uint [] {0x73, 0x53, 0xfffffff1, 0xffffffd1, }, new uint [] {0x64, 0x44, 0xffffffe4, 0xffffffc4, },
+ new uint [] {0x66, 0x46, 0xfffffff4, 0xffffffd4, }, new uint [] {0x67, 0x47, 0xffffffe3, 0xffffffc3, },
+ new uint [] {0x68, 0x48, 0xfffffff5, 0xffffffd5, }, new uint [] {0x6a, 0x4a, 0xffffffe9, 0xffffffc9, },
+ new uint [] {0x6b, 0x4b, 0xffffffea, 0xffffffca, }, new uint [] {0x6c, 0x4c, 0xffffffeb, 0xffffffcb, },
+ new uint [] {0x3b, 0x3a, }, new uint [] {0x27, 0x22, },
+ new uint [] {0x5c, 0x7c, 0xfffffffe, 0xffffffde, }, new uint [] {0x7a, 0x5a, 0xffffffe7, 0xffffffc7, },
+ new uint [] {0x78, 0x58, 0xfffffffc, 0xffffffdc, }, new uint [] {0x63, 0x43, 0xfffffff6, 0xffffffd6, },
+ new uint [] {0x76, 0x56, 0xffffffe6, 0xffffffc6, }, new uint [] {0x62, 0x42, 0xffffffe1, 0xffffffc1, },
+ new uint [] {0x6e, 0x4e, 0xffffffed, 0xffffffcd, }, new uint [] {0x6d, 0x4d, 0xffffffec, 0xffffffcc, },
+ new uint [] {0x2c, 0x3c, }, new uint [] {0x2e, 0x3e, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [26] = new KeyboardLayout (1059, "Belarusian keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, 0xffffffa3, 0xffffffb3, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x71, 0x51, 0xffffffca, 0xffffffea, },
+ new uint [] {0x77, 0x57, 0xffffffc3, 0xffffffe3, }, new uint [] {0x65, 0x45, 0xffffffd5, 0xfffffff5, },
+ new uint [] {0x72, 0x52, 0xffffffcb, 0xffffffeb, }, new uint [] {0x74, 0x54, 0xffffffc5, 0xffffffe5, },
+ new uint [] {0x79, 0x59, 0xffffffce, 0xffffffee, }, new uint [] {0x75, 0x55, 0xffffffc7, 0xffffffe7, },
+ new uint [] {0x69, 0x49, 0xffffffdb, 0xfffffffb, }, new uint [] {0x6f, 0x4f, 0xffffffae, 0xffffffbe, },
+ new uint [] {0x70, 0x50, 0xffffffda, 0xfffffffa, }, new uint [] {0x5b, 0x7b, 0xffffffc8, 0xffffffe8, },
+ new uint [] {0x5d, 0x7d, 0x27, 0x27, }, new uint [] {0x61, 0x41, 0xffffffc6, 0xffffffe6, },
+ new uint [] {0x73, 0x53, 0xffffffd9, 0xfffffff9, }, new uint [] {0x64, 0x44, 0xffffffd7, 0xfffffff7, },
+ new uint [] {0x66, 0x46, 0xffffffc1, 0xffffffe1, }, new uint [] {0x67, 0x47, 0xffffffd0, 0xfffffff0, },
+ new uint [] {0x68, 0x48, 0xffffffd2, 0xfffffff2, }, new uint [] {0x6a, 0x4a, 0xffffffcf, 0xffffffef, },
+ new uint [] {0x6b, 0x4b, 0xffffffcc, 0xffffffec, }, new uint [] {0x6c, 0x4c, 0xffffffc4, 0xffffffe4, },
+ new uint [] {0x3b, 0x3a, 0xffffffd6, 0xfffffff6, }, new uint [] {0x27, 0x22, 0xffffffdc, 0xfffffffc, },
+ new uint [] {0x5c, 0x7c, 0x2f, 0x7c, }, new uint [] {0x7a, 0x5a, 0xffffffd1, 0xfffffff1, },
+ new uint [] {0x78, 0x58, 0xffffffde, 0xfffffffe, }, new uint [] {0x63, 0x43, 0xffffffd3, 0xfffffff3, },
+ new uint [] {0x76, 0x56, 0xffffffcd, 0xffffffed, }, new uint [] {0x62, 0x42, 0xffffffa6, 0xffffffb6, },
+ new uint [] {0x6e, 0x4e, 0xffffffd4, 0xfffffff4, }, new uint [] {0x6d, 0x4d, 0xffffffd8, 0xfffffff8, },
+ new uint [] {0x2c, 0x3c, 0xffffffc2, 0xffffffe2, }, new uint [] {0x2e, 0x3e, 0xffffffc0, 0xffffffe0, },
+ new uint [] {0x2f, 0x3f, 0x2e, 0x2c, }, new uint [] {0x3c, 0x3e, 0x7c, 0xffffffa6, },
+ new uint [] {}, });
+ table [27] = new KeyboardLayout (1049, "Russian keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x71, 0x51, 0xffffffca, 0xffffffea, },
+ new uint [] {0x77, 0x57, 0xffffffc3, 0xffffffe3, }, new uint [] {0x65, 0x45, 0xffffffd5, 0xfffffff5, },
+ new uint [] {0x72, 0x52, 0xffffffcb, 0xffffffeb, }, new uint [] {0x74, 0x54, 0xffffffc5, 0xffffffe5, },
+ new uint [] {0x79, 0x59, 0xffffffce, 0xffffffee, }, new uint [] {0x75, 0x55, 0xffffffc7, 0xffffffe7, },
+ new uint [] {0x69, 0x49, 0xffffffdb, 0xfffffffb, }, new uint [] {0x6f, 0x4f, 0xffffffdd, 0xfffffffd, },
+ new uint [] {0x70, 0x50, 0xffffffda, 0xfffffffa, }, new uint [] {0x5b, 0x7b, 0xffffffc8, 0xffffffe8, },
+ new uint [] {0x5d, 0x7d, 0xffffffdf, 0xffffffff, }, new uint [] {0x61, 0x41, 0xffffffc6, 0xffffffe6, },
+ new uint [] {0x73, 0x53, 0xffffffd9, 0xfffffff9, }, new uint [] {0x64, 0x44, 0xffffffd7, 0xfffffff7, },
+ new uint [] {0x66, 0x46, 0xffffffc1, 0xffffffe1, }, new uint [] {0x67, 0x47, 0xffffffd0, 0xfffffff0, },
+ new uint [] {0x68, 0x48, 0xffffffd2, 0xfffffff2, }, new uint [] {0x6a, 0x4a, 0xffffffcf, 0xffffffef, },
+ new uint [] {0x6b, 0x4b, 0xffffffcc, 0xffffffec, }, new uint [] {0x6c, 0x4c, 0xffffffc4, 0xffffffe4, },
+ new uint [] {0x3b, 0x3a, 0xffffffd6, 0xfffffff6, }, new uint [] {0x27, 0x22, 0xffffffdc, 0xfffffffc, },
+ new uint [] {0x5c, 0x7c, }, new uint [] {0x7a, 0x5a, 0xffffffd1, 0xfffffff1, },
+ new uint [] {0x78, 0x58, 0xffffffde, 0xfffffffe, }, new uint [] {0x63, 0x43, 0xffffffd3, 0xfffffff3, },
+ new uint [] {0x76, 0x56, 0xffffffcd, 0xffffffed, }, new uint [] {0x62, 0x42, 0xffffffc9, 0xffffffe9, },
+ new uint [] {0x6e, 0x4e, 0xffffffd4, 0xfffffff4, }, new uint [] {0x6d, 0x4d, 0xffffffd8, 0xfffffff8, },
+ new uint [] {0x2c, 0x3c, 0xffffffc2, 0xffffffe2, }, new uint [] {0x2e, 0x3e, 0xffffffc0, 0xffffffe0, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {},
+ new uint [] {}, });
+ table [28] = new KeyboardLayout (1049, "Russian keyboard layout (phantom key version)", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x71, 0x51, 0xffffffca, 0xffffffea, },
+ new uint [] {0x77, 0x57, 0xffffffc3, 0xffffffe3, }, new uint [] {0x65, 0x45, 0xffffffd5, 0xfffffff5, },
+ new uint [] {0x72, 0x52, 0xffffffcb, 0xffffffeb, }, new uint [] {0x74, 0x54, 0xffffffc5, 0xffffffe5, },
+ new uint [] {0x79, 0x59, 0xffffffce, 0xffffffee, }, new uint [] {0x75, 0x55, 0xffffffc7, 0xffffffe7, },
+ new uint [] {0x69, 0x49, 0xffffffdb, 0xfffffffb, }, new uint [] {0x6f, 0x4f, 0xffffffdd, 0xfffffffd, },
+ new uint [] {0x70, 0x50, 0xffffffda, 0xfffffffa, }, new uint [] {0x5b, 0x7b, 0xffffffc8, 0xffffffe8, },
+ new uint [] {0x5d, 0x7d, 0xffffffdf, 0xffffffff, }, new uint [] {0x61, 0x41, 0xffffffc6, 0xffffffe6, },
+ new uint [] {0x73, 0x53, 0xffffffd9, 0xfffffff9, }, new uint [] {0x64, 0x44, 0xffffffd7, 0xfffffff7, },
+ new uint [] {0x66, 0x46, 0xffffffc1, 0xffffffe1, }, new uint [] {0x67, 0x47, 0xffffffd0, 0xfffffff0, },
+ new uint [] {0x68, 0x48, 0xffffffd2, 0xfffffff2, }, new uint [] {0x6a, 0x4a, 0xffffffcf, 0xffffffef, },
+ new uint [] {0x6b, 0x4b, 0xffffffcc, 0xffffffec, }, new uint [] {0x6c, 0x4c, 0xffffffc4, 0xffffffe4, },
+ new uint [] {0x3b, 0x3a, 0xffffffd6, 0xfffffff6, }, new uint [] {0x27, 0x22, 0xffffffdc, 0xfffffffc, },
+ new uint [] {0x5c, 0x7c, }, new uint [] {0x7a, 0x5a, 0xffffffd1, 0xfffffff1, },
+ new uint [] {0x78, 0x58, 0xffffffde, 0xfffffffe, }, new uint [] {0x63, 0x43, 0xffffffd3, 0xfffffff3, },
+ new uint [] {0x76, 0x56, 0xffffffcd, 0xffffffed, }, new uint [] {0x62, 0x42, 0xffffffc9, 0xffffffe9, },
+ new uint [] {0x6e, 0x4e, 0xffffffd4, 0xfffffff4, }, new uint [] {0x6d, 0x4d, 0xffffffd8, 0xfffffff8, },
+ new uint [] {0x2c, 0x3c, 0xffffffc2, 0xffffffe2, }, new uint [] {0x2e, 0x3e, 0xffffffc0, 0xffffffe0, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [29] = new KeyboardLayout (1049, "Russian keyboard layout KOI8-R", 0, 0, new uint [][] {
+ new uint [] {0x28, 0x29, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0x2f, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x3a, },
+ new uint [] {0x36, 0x2c, }, new uint [] {0x37, 0x2e, },
+ new uint [] {0x38, 0x3b, }, new uint [] {0x39, 0x3f, },
+ new uint [] {0x30, 0x25, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0xffffffca, 0xffffffea, },
+ new uint [] {0xffffffc3, 0xffffffe3, }, new uint [] {0xffffffd5, 0xfffffff5, },
+ new uint [] {0xffffffcb, 0xffffffeb, }, new uint [] {0xffffffc5, 0xffffffe5, },
+ new uint [] {0xffffffce, 0xffffffee, }, new uint [] {0xffffffc7, 0xffffffe7, },
+ new uint [] {0xffffffdb, 0xfffffffb, }, new uint [] {0xffffffdd, 0xfffffffd, },
+ new uint [] {0xffffffda, 0xfffffffa, }, new uint [] {0xffffffc8, 0xffffffe8, },
+ new uint [] {0xffffffdf, 0xffffffff, }, new uint [] {0xffffffc6, 0xffffffe6, },
+ new uint [] {0xffffffd9, 0xfffffff9, }, new uint [] {0xffffffd7, 0xfffffff7, },
+ new uint [] {0xffffffc1, 0xffffffe1, }, new uint [] {0xffffffd0, 0xfffffff0, },
+ new uint [] {0xffffffd2, 0xfffffff2, }, new uint [] {0xffffffcf, 0xffffffef, },
+ new uint [] {0xffffffcc, 0xffffffec, }, new uint [] {0xffffffc4, 0xffffffe4, },
+ new uint [] {0xffffffd6, 0xfffffff6, }, new uint [] {0xffffffdc, 0xfffffffc, },
+ new uint [] {0x5c, 0x7c, }, new uint [] {0xffffffd1, 0xfffffff1, },
+ new uint [] {0xffffffde, 0xfffffffe, }, new uint [] {0xffffffd3, 0xfffffff3, },
+ new uint [] {0xffffffcd, 0xffffffed, }, new uint [] {0xffffffc9, 0xffffffe9, },
+ new uint [] {0xffffffd4, 0xfffffff4, }, new uint [] {0xffffffd8, 0xfffffff8, },
+ new uint [] {0xffffffc2, 0xffffffe2, }, new uint [] {0xffffffc0, 0xffffffe0, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [30] = new KeyboardLayout (1049, "Russian keyboard layout cp1251", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x71, 0x51, 0xffffffe9, 0xffffffc9, },
+ new uint [] {0x77, 0x57, 0xfffffff6, 0xffffffd6, }, new uint [] {0x65, 0x45, 0xfffffff3, 0xffffffd3, },
+ new uint [] {0x72, 0x52, 0xffffffea, 0xffffffca, }, new uint [] {0x74, 0x54, 0xffffffe5, 0xffffffc5, },
+ new uint [] {0x79, 0x59, 0xffffffed, 0xffffffcd, }, new uint [] {0x75, 0x55, 0xffffffe3, 0xffffffc3, },
+ new uint [] {0x69, 0x49, 0xfffffff8, 0xffffffd8, }, new uint [] {0x6f, 0x4f, 0xfffffff9, 0xffffffd9, },
+ new uint [] {0x70, 0x50, 0xffffffe7, 0xffffffc7, }, new uint [] {0x5b, 0x7b, 0xfffffff5, 0xffffffd5, },
+ new uint [] {0x5d, 0x7d, 0xfffffffa, 0xffffffda, }, new uint [] {0x61, 0x41, 0xfffffff4, 0xffffffd4, },
+ new uint [] {0x73, 0x53, 0xfffffffb, 0xffffffdb, }, new uint [] {0x64, 0x44, 0xffffffe2, 0xffffffc2, },
+ new uint [] {0x66, 0x46, 0xffffffe0, 0xffffffc0, }, new uint [] {0x67, 0x47, 0xffffffef, 0xffffffcf, },
+ new uint [] {0x68, 0x48, 0xfffffff0, 0xffffffd0, }, new uint [] {0x6a, 0x4a, 0xffffffee, 0xffffffce, },
+ new uint [] {0x6b, 0x4b, 0xffffffeb, 0xffffffcb, }, new uint [] {0x6c, 0x4c, 0xffffffe4, 0xffffffc4, },
+ new uint [] {0x3b, 0x3a, 0xffffffe6, 0xffffffc6, }, new uint [] {0x27, 0x22, 0xfffffffd, 0xffffffdd, },
+ new uint [] {0x5c, 0x7c, }, new uint [] {0x7a, 0x5a, 0xffffffff, 0xffffffdf, },
+ new uint [] {0x78, 0x58, 0xfffffff7, 0xffffffd7, }, new uint [] {0x63, 0x43, 0xfffffff1, 0xffffffd1, },
+ new uint [] {0x76, 0x56, 0xffffffec, 0xffffffcc, }, new uint [] {0x62, 0x42, 0xffffffe8, 0xffffffc8, },
+ new uint [] {0x6e, 0x4e, 0xfffffff2, 0xffffffd2, }, new uint [] {0x6d, 0x4d, 0xfffffffc, 0xffffffdc, },
+ new uint [] {0x2c, 0x3c, 0xffffffe1, 0xffffffc1, }, new uint [] {0x2e, 0x3e, 0xfffffffe, 0xffffffde, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [31] = new KeyboardLayout (1049, "Russian phonetic keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x71, 0x51, 0xffffffd1, 0xfffffff1, },
+ new uint [] {0x77, 0x57, 0xffffffd7, 0xfffffff7, }, new uint [] {0x65, 0x45, 0xffffffc5, 0xffffffe5, },
+ new uint [] {0x72, 0x52, 0xffffffd2, 0xfffffff2, }, new uint [] {0x74, 0x54, 0xffffffd4, 0xfffffff4, },
+ new uint [] {0x79, 0x59, 0xffffffd9, 0xfffffff9, }, new uint [] {0x75, 0x55, 0xffffffd5, 0xfffffff5, },
+ new uint [] {0x69, 0x49, 0xffffffc9, 0xffffffe9, }, new uint [] {0x6f, 0x4f, 0xffffffcf, 0xffffffef, },
+ new uint [] {0x70, 0x50, 0xffffffd0, 0xfffffff0, }, new uint [] {0x5b, 0x7b, 0xffffffdb, 0xfffffffb, },
+ new uint [] {0x5d, 0x7d, 0xffffffdd, 0xfffffffd, }, new uint [] {0x61, 0x41, 0xffffffc1, 0xffffffe1, },
+ new uint [] {0x73, 0x53, 0xffffffd3, 0xfffffff3, }, new uint [] {0x64, 0x44, 0xffffffc4, 0xffffffe4, },
+ new uint [] {0x66, 0x46, 0xffffffc6, 0xffffffe6, }, new uint [] {0x67, 0x47, 0xffffffc7, 0xffffffe7, },
+ new uint [] {0x68, 0x48, 0xffffffc8, 0xffffffe8, }, new uint [] {0x6a, 0x4a, 0xffffffca, 0xffffffea, },
+ new uint [] {0x6b, 0x4b, 0xffffffcb, 0xffffffeb, }, new uint [] {0x6c, 0x4c, 0xffffffcc, 0xffffffec, },
+ new uint [] {0x3b, 0x3a, }, new uint [] {0x27, 0x22, },
+ new uint [] {0x5c, 0x7c, }, new uint [] {0x7a, 0x5a, 0xffffffda, 0xfffffffa, },
+ new uint [] {0x78, 0x58, 0xffffffd8, 0xfffffff8, }, new uint [] {0x63, 0x43, 0xffffffc3, 0xffffffe3, },
+ new uint [] {0x76, 0x56, 0xffffffd6, 0xfffffff6, }, new uint [] {0x62, 0x42, 0xffffffc2, 0xffffffe2, },
+ new uint [] {0x6e, 0x4e, 0xffffffce, 0xffffffee, }, new uint [] {0x6d, 0x4d, 0xffffffcd, 0xffffffed, },
+ new uint [] {0x2c, 0x3c, }, new uint [] {0x2e, 0x3e, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [32] = new KeyboardLayout (1058, "Ukrainian keyboard layout KOI8-U", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, 0xffffffad, 0xffffffbd, }, new uint [] {0x31, 0x21, 0x31, 0x21, },
+ new uint [] {0x32, 0x40, 0x32, 0x22, }, new uint [] {0x33, 0x23, 0x33, 0x27, },
+ new uint [] {0x34, 0x24, 0x34, 0x2a, }, new uint [] {0x35, 0x25, 0x35, 0x3a, },
+ new uint [] {0x36, 0x5e, 0x36, 0x2c, }, new uint [] {0x37, 0x26, 0x37, 0x2e, },
+ new uint [] {0x38, 0x2a, 0x38, 0x3b, }, new uint [] {0x39, 0x28, 0x39, 0x28, },
+ new uint [] {0x30, 0x29, 0x30, 0x29, }, new uint [] {0x2d, 0x5f, 0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, 0x3d, 0x2b, }, new uint [] {0x71, 0x51, 0xffffffca, 0xffffffea, },
+ new uint [] {0x77, 0x57, 0xffffffc3, 0xffffffe3, }, new uint [] {0x65, 0x45, 0xffffffd5, 0xfffffff5, },
+ new uint [] {0x72, 0x52, 0xffffffcb, 0xffffffeb, }, new uint [] {0x74, 0x54, 0xffffffc5, 0xffffffe5, },
+ new uint [] {0x79, 0x59, 0xffffffce, 0xffffffee, }, new uint [] {0x75, 0x55, 0xffffffc7, 0xffffffe7, },
+ new uint [] {0x69, 0x49, 0xffffffdb, 0xfffffffb, }, new uint [] {0x6f, 0x4f, 0xffffffdd, 0xfffffffd, },
+ new uint [] {0x70, 0x50, 0xffffffda, 0xfffffffa, }, new uint [] {0x5b, 0x7b, 0xffffffc8, 0xffffffe8, },
+ new uint [] {0x5d, 0x7d, 0xffffffa7, 0xffffffb7, }, new uint [] {0x61, 0x41, 0xffffffc6, 0xffffffe6, },
+ new uint [] {0x73, 0x53, 0xffffffa6, 0xffffffb6, }, new uint [] {0x64, 0x44, 0xffffffd7, 0xfffffff7, },
+ new uint [] {0x66, 0x46, 0xffffffc1, 0xffffffe1, }, new uint [] {0x67, 0x47, 0xffffffd0, 0xfffffff0, },
+ new uint [] {0x68, 0x48, 0xffffffd2, 0xfffffff2, }, new uint [] {0x6a, 0x4a, 0xffffffcf, 0xffffffef, },
+ new uint [] {0x6b, 0x4b, 0xffffffcc, 0xffffffec, }, new uint [] {0x6c, 0x4c, 0xffffffc4, 0xffffffe4, },
+ new uint [] {0x3b, 0x3a, 0xffffffd6, 0xfffffff6, }, new uint [] {0x27, 0x22, 0xffffffa4, 0xffffffb4, },
+ new uint [] {0x5c, 0x7c, 0x5c, 0x7c, }, new uint [] {0x7a, 0x5a, 0xffffffd1, 0xfffffff1, },
+ new uint [] {0x78, 0x58, 0xffffffde, 0xfffffffe, }, new uint [] {0x63, 0x43, 0xffffffd3, 0xfffffff3, },
+ new uint [] {0x76, 0x56, 0xffffffcd, 0xffffffed, }, new uint [] {0x62, 0x42, 0xffffffc9, 0xffffffe9, },
+ new uint [] {0x6e, 0x4e, 0xffffffd4, 0xfffffff4, }, new uint [] {0x6d, 0x4d, 0xffffffd8, 0xfffffff8, },
+ new uint [] {0x2c, 0x3c, 0xffffffc2, 0xffffffe2, }, new uint [] {0x2e, 0x3e, 0xffffffc0, 0xffffffe0, },
+ new uint [] {0x2f, 0x3f, 0x2f, 0x3f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [33] = new KeyboardLayout (1058, "Ukrainian keyboard layout (standard)", 0, 0, new uint [][] {
+ new uint [] {0xffffffad, 0xffffffbd, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0x27, },
+ new uint [] {0x34, 0x3b, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x3a, }, new uint [] {0x37, 0x3f, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0xffffffca, 0xffffffea, },
+ new uint [] {0xffffffc3, 0xffffffe3, }, new uint [] {0xffffffd5, 0xfffffff5, },
+ new uint [] {0xffffffcb, 0xffffffeb, }, new uint [] {0xffffffc5, 0xffffffe5, },
+ new uint [] {0xffffffce, 0xffffffee, }, new uint [] {0xffffffc7, 0xffffffe7, },
+ new uint [] {0xffffffdb, 0xfffffffb, }, new uint [] {0xffffffdd, 0xfffffffd, },
+ new uint [] {0xffffffda, 0xfffffffa, }, new uint [] {0xffffffc8, 0xffffffe8, },
+ new uint [] {0xffffffa7, 0xffffffb7, }, new uint [] {0xffffffc6, 0xffffffe6, },
+ new uint [] {0xffffffa6, 0xffffffb6, }, new uint [] {0xffffffd7, 0xfffffff7, },
+ new uint [] {0xffffffc1, 0xffffffe1, }, new uint [] {0xffffffd0, 0xfffffff0, },
+ new uint [] {0xffffffd2, 0xfffffff2, }, new uint [] {0xffffffcf, 0xffffffef, },
+ new uint [] {0xffffffcc, 0xffffffec, }, new uint [] {0xffffffc4, 0xffffffe4, },
+ new uint [] {0xffffffd6, 0xfffffff6, }, new uint [] {0xffffffa4, 0xffffffb4, },
+ new uint [] {0x5c, 0x2f, }, new uint [] {0xffffffd1, 0xfffffff1, },
+ new uint [] {0xffffffde, 0xfffffffe, }, new uint [] {0xffffffd3, 0xfffffff3, },
+ new uint [] {0xffffffcd, 0xffffffed, }, new uint [] {0xffffffc9, 0xffffffe9, },
+ new uint [] {0xffffffd4, 0xfffffff4, }, new uint [] {0xffffffd8, 0xfffffff8, },
+ new uint [] {0xffffffc2, 0xffffffe2, }, new uint [] {0xffffffc0, 0xffffffe0, },
+ new uint [] {0x2e, 0x2c, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [34] = new KeyboardLayout (1049, "Russian keyboard layout (standard)", 0, 0, new uint [][] {
+ new uint [] {0xffffffa3, 0xffffffb3, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0x27, },
+ new uint [] {0x34, 0x3b, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x3a, }, new uint [] {0x37, 0x3f, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0xffffffca, 0xffffffea, },
+ new uint [] {0xffffffc3, 0xffffffe3, }, new uint [] {0xffffffd5, 0xfffffff5, },
+ new uint [] {0xffffffcb, 0xffffffeb, }, new uint [] {0xffffffc5, 0xffffffe5, },
+ new uint [] {0xffffffce, 0xffffffee, }, new uint [] {0xffffffc7, 0xffffffe7, },
+ new uint [] {0xffffffdb, 0xfffffffb, }, new uint [] {0xffffffdd, 0xfffffffd, },
+ new uint [] {0xffffffda, 0xfffffffa, }, new uint [] {0xffffffc8, 0xffffffe8, },
+ new uint [] {0xffffffdf, 0xffffffff, }, new uint [] {0xffffffc6, 0xffffffe6, },
+ new uint [] {0xffffffd9, 0xfffffff9, }, new uint [] {0xffffffd7, 0xfffffff7, },
+ new uint [] {0xffffffc1, 0xffffffe1, }, new uint [] {0xffffffd0, 0xfffffff0, },
+ new uint [] {0xffffffd2, 0xfffffff2, }, new uint [] {0xffffffcf, 0xffffffef, },
+ new uint [] {0xffffffcc, 0xffffffec, }, new uint [] {0xffffffc4, 0xffffffe4, },
+ new uint [] {0xffffffd6, 0xfffffff6, }, new uint [] {0xffffffdc, 0xfffffffc, },
+ new uint [] {0x5c, 0x2f, }, new uint [] {0xffffffd1, 0xfffffff1, },
+ new uint [] {0xffffffde, 0xfffffffe, }, new uint [] {0xffffffd3, 0xfffffff3, },
+ new uint [] {0xffffffcd, 0xffffffed, }, new uint [] {0xffffffc9, 0xffffffe9, },
+ new uint [] {0xffffffd4, 0xfffffff4, }, new uint [] {0xffffffd8, 0xfffffff8, },
+ new uint [] {0xffffffc2, 0xffffffe2, }, new uint [] {0xffffffc0, 0xffffffe0, },
+ new uint [] {0x2e, 0x2c, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [35] = new KeyboardLayout (1034, "Spanish keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0xffffffba, 0xffffffaa, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0xffffffb7, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, },
+ new uint [] {0x38, 0x28, }, new uint [] {0x39, 0x29, },
+ new uint [] {0x30, 0x3d, }, new uint [] {0x27, 0x3f, },
+ new uint [] {0xffffffa1, 0xffffffbf, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0x60, 0x5e, },
+ new uint [] {0x2b, 0x2a, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xfffffff1, 0xffffffd1, }, new uint [] {0xffffffb4, 0xffffffa8, },
+ new uint [] {0xffffffe7, 0xffffffc7, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [36] = new KeyboardLayout (1040, "Italian keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x5c, 0x7c, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0xffffffa3, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, },
+ new uint [] {0x38, 0x28, }, new uint [] {0x39, 0x29, },
+ new uint [] {0x30, 0x3d, }, new uint [] {0x27, 0x3f, },
+ new uint [] {0xffffffec, 0x5e, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xffffffe8, 0xffffffe9, },
+ new uint [] {0x2b, 0x2a, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xfffffff2, 0xffffffe7, }, new uint [] {0xffffffe0, 0xffffffb0, },
+ new uint [] {0xfffffff9, 0xffffffa7, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [37] = new KeyboardLayout (1039, "Icelandic keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0xffffffb0, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, },
+ new uint [] {0x38, 0x28, }, new uint [] {0x39, 0x29, },
+ new uint [] {0x30, 0x3d, }, new uint [] {0xfffffff6, 0xffffffd6, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xfffffff0, 0xffffffd0, },
+ new uint [] {0x27, 0x3f, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xffffffe6, 0xffffffc6, }, new uint [] {0xffffffb4, 0xffffffc4, },
+ new uint [] {0x2b, 0x2a, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0xfffffffe, 0xffffffde, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [38] = new KeyboardLayout (1038, "Hungarian keyboard layout", 0, 1, new uint [][] {
+ new uint [] {0x30, 0xffffffa7, }, new uint [] {0x31, 0x27, 0x7e, },
+ new uint [] {0x32, 0x22, 0xffffffb7, }, new uint [] {0x33, 0x2b, 0x5e, },
+ new uint [] {0x34, 0x21, 0xffffffa2, }, new uint [] {0x35, 0x25, 0x30, 0xffffffb0, },
+ new uint [] {0x36, 0x2f, 0xffffffb2, }, new uint [] {0x37, 0x3d, 0x60, },
+ new uint [] {0x38, 0x28, 0xffffffff, }, new uint [] {0x39, 0x29, 0xffffffb4, },
+ new uint [] {0xfffffff6, 0xffffffd6, 0xffffffbd, }, new uint [] {0xfffffffc, 0xffffffdc, 0xffffffa8, },
+ new uint [] {0xfffffff3, 0xffffffd3, 0xffffffb8, }, new uint [] {0x71, 0x51, 0x5c, },
+ new uint [] {0x77, 0x57, 0x7c, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x7a, 0x5a, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, 0xffffffcd, }, new uint [] {0x6f, 0x4f, 0xfffffff8, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xfffffff5, 0xffffffd5, 0xfffffff7, },
+ new uint [] {0xfffffffa, 0xffffffda, 0xffffffd7, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, 0xfffffff0, }, new uint [] {0x64, 0x44, 0xffffffd0, },
+ new uint [] {0x66, 0x46, 0x5b, }, new uint [] {0x67, 0x47, 0x5d, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, 0xffffffed, },
+ new uint [] {0x6b, 0x4b, 0xffffffb3, }, new uint [] {0x6c, 0x4c, 0xffffffa3, },
+ new uint [] {0xffffffe9, 0xffffffc9, 0x24, }, new uint [] {0xffffffe1, 0xffffffc1, 0xffffffdf, },
+ new uint [] {0xfffffffb, 0xffffffdb, 0xffffffa4, }, new uint [] {0x79, 0x59, 0x3e, },
+ new uint [] {0x78, 0x58, 0x23, }, new uint [] {0x63, 0x43, 0x26, },
+ new uint [] {0x76, 0x56, 0x40, }, new uint [] {0x62, 0x42, 0x7b, },
+ new uint [] {0x6e, 0x4e, 0x7d, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3f, 0x3b, }, new uint [] {0x2e, 0x3a, 0x3e, },
+ new uint [] {0x2d, 0x5f, 0x2a, }, new uint [] {0xffffffed, 0xffffffcd, 0x3c, },
+ new uint [] {}, });
+ table [39] = new KeyboardLayout (1045, "Polish (programmer's) keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, }, new uint [] {0x37, 0x26, 0xffffffa7, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, 0xffffffea, 0xffffffca, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, 0xfffffff3, 0xffffffd3, },
+ new uint [] {0x70, 0x50, }, new uint [] {0x5b, 0x7b, },
+ new uint [] {0x5d, 0x7d, }, new uint [] {0x61, 0x41, 0xffffffb1, 0xffffffa1, },
+ new uint [] {0x73, 0x53, 0xffffffb6, 0xffffffa6, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, 0xffffffb3, 0xffffffa3, },
+ new uint [] {0x3b, 0x3a, }, new uint [] {0x27, 0x22, },
+ new uint [] {0x5c, 0x7c, }, new uint [] {0x7a, 0x5a, 0xffffffbf, 0xffffffaf, },
+ new uint [] {0x78, 0x58, 0xffffffbc, 0xffffffac, }, new uint [] {0x63, 0x43, 0xffffffe6, 0xffffffc6, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, 0xfffffff1, 0xffffffd1, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3c, }, new uint [] {0x2e, 0x3e, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {0x3c, 0x3e, 0x7c, },
+ new uint [] {}, });
+ table [40] = new KeyboardLayout (1060, "Slovenian keyboard layout", 0, 1, new uint [][] {
+ new uint [] {0xffffffb8, 0xffffffa8, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, },
+ new uint [] {0x38, 0x28, }, new uint [] {0x39, 0x29, },
+ new uint [] {0x30, 0x3d, }, new uint [] {0x27, 0x3f, },
+ new uint [] {0x2b, 0x2a, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x7a, 0x5a, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xffffffb9, 0xffffffa9, },
+ new uint [] {0xfffffff0, 0xffffffd0, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xffffffe8, 0xffffffc8, }, new uint [] {0xffffffe6, 0xffffffc6, },
+ new uint [] {0xffffffbe, 0xffffffae, }, new uint [] {0x79, 0x59, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [41] = new KeyboardLayout (3098, "Serbian keyboard layout sr", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, },
+ new uint [] {0x38, 0x28, }, new uint [] {0x39, 0x29, },
+ new uint [] {0x30, 0x3d, }, new uint [] {0x27, 0x3f, },
+ new uint [] {0x2b, 0x2a, }, new uint [] {0xffffffa9, 0xffffffb9, },
+ new uint [] {0xffffffaa, 0xffffffba, }, new uint [] {0xffffffc5, 0xffffffe5, },
+ new uint [] {0xffffffd2, 0xfffffff2, }, new uint [] {0xffffffd4, 0xfffffff4, },
+ new uint [] {0xffffffda, 0xfffffffa, }, new uint [] {0xffffffd5, 0xfffffff5, },
+ new uint [] {0xffffffc9, 0xffffffe9, }, new uint [] {0xffffffcf, 0xffffffef, },
+ new uint [] {0xffffffd0, 0xfffffff0, }, new uint [] {0xffffffdb, 0xfffffffb, },
+ new uint [] {0x5b, 0x5d, }, new uint [] {0xffffffc1, 0xffffffe1, },
+ new uint [] {0xffffffd3, 0xfffffff3, }, new uint [] {0xffffffc4, 0xffffffe4, },
+ new uint [] {0xffffffc6, 0xffffffe6, }, new uint [] {0xffffffc7, 0xffffffe7, },
+ new uint [] {0xffffffc8, 0xffffffe8, }, new uint [] {0xffffffa8, 0xffffffb8, },
+ new uint [] {0xffffffcb, 0xffffffeb, }, new uint [] {0xffffffcc, 0xffffffec, },
+ new uint [] {0xffffffde, 0xfffffffe, }, new uint [] {0xffffffab, 0xffffffbb, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0xffffffa1, 0xffffffb1, },
+ new uint [] {0xffffffaf, 0xffffffbf, }, new uint [] {0xffffffc3, 0xffffffe3, },
+ new uint [] {0xffffffd7, 0xfffffff7, }, new uint [] {0xffffffc2, 0xffffffe2, },
+ new uint [] {0xffffffce, 0xffffffee, }, new uint [] {0xffffffcd, 0xffffffed, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0xffffffd6, 0xfffffff6, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [42] = new KeyboardLayout (3098, "Serbian keyboard layout us,sr", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, 0x32, 0x22, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, 0x36, 0x26, }, new uint [] {0x37, 0x26, 0x37, 0x2f, },
+ new uint [] {0x38, 0x2a, 0x38, 0x28, }, new uint [] {0x39, 0x28, 0x39, 0x29, },
+ new uint [] {0x30, 0x29, 0x30, 0x3d, }, new uint [] {0x2d, 0x5f, 0x27, 0x3f, },
+ new uint [] {0x3d, 0x2b, 0x2b, 0x2a, }, new uint [] {0x71, 0x51, 0xffffffa9, 0xffffffb9, },
+ new uint [] {0x77, 0x57, 0xffffffaa, 0xffffffba, }, new uint [] {0x65, 0x45, 0xffffffc5, 0xffffffe5, },
+ new uint [] {0x72, 0x52, 0xffffffd2, 0xfffffff2, }, new uint [] {0x74, 0x54, 0xffffffd4, 0xfffffff4, },
+ new uint [] {0x79, 0x59, 0xffffffda, 0xfffffffa, }, new uint [] {0x75, 0x55, 0xffffffd5, 0xfffffff5, },
+ new uint [] {0x69, 0x49, 0xffffffc9, 0xffffffe9, }, new uint [] {0x6f, 0x4f, 0xffffffcf, 0xffffffef, },
+ new uint [] {0x70, 0x50, 0xffffffd0, 0xfffffff0, }, new uint [] {0x5b, 0x7b, 0xffffffdb, 0xfffffffb, },
+ new uint [] {0x5d, 0x7d, 0x5b, 0x5d, }, new uint [] {0x61, 0x41, 0xffffffc1, 0xffffffe1, },
+ new uint [] {0x73, 0x53, 0xffffffd3, 0xfffffff3, }, new uint [] {0x64, 0x44, 0xffffffc4, 0xffffffe4, },
+ new uint [] {0x66, 0x46, 0xffffffc6, 0xffffffe6, }, new uint [] {0x67, 0x47, 0xffffffc7, 0xffffffe7, },
+ new uint [] {0x68, 0x48, 0xffffffc8, 0xffffffe8, }, new uint [] {0x6a, 0x4a, 0xffffffa8, 0xffffffb8, },
+ new uint [] {0x6b, 0x4b, 0xffffffcb, 0xffffffeb, }, new uint [] {0x6c, 0x4c, 0xffffffcc, 0xffffffec, },
+ new uint [] {0x3b, 0x3a, 0xffffffde, 0xfffffffe, }, new uint [] {0x27, 0x22, 0xffffffab, 0xffffffbb, },
+ new uint [] {0x5c, 0x7c, 0x2d, 0x5f, }, new uint [] {0x7a, 0x5a, 0xffffffa1, 0xffffffb1, },
+ new uint [] {0x78, 0x58, 0xffffffaf, 0xffffffbf, }, new uint [] {0x63, 0x43, 0xffffffc3, 0xffffffe3, },
+ new uint [] {0x76, 0x56, 0xffffffd7, 0xfffffff7, }, new uint [] {0x62, 0x42, 0xffffffc2, 0xffffffe2, },
+ new uint [] {0x6e, 0x4e, 0xffffffce, 0xffffffee, }, new uint [] {0x6d, 0x4d, 0xffffffcd, 0xffffffed, },
+ new uint [] {0x2c, 0x3c, 0x2c, 0x3b, }, new uint [] {0x2e, 0x3e, 0x2e, 0x3a, },
+ new uint [] {0x2f, 0x3f, 0xffffffd6, 0xfffffff6, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [43] = new KeyboardLayout (1050, "Croatian keyboard layout", 0, 1, new uint [][] {
+ new uint [] {0xffffffb8, 0xffffffa8, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, },
+ new uint [] {0x38, 0x28, }, new uint [] {0x39, 0x29, },
+ new uint [] {0x30, 0x3d, }, new uint [] {0x27, 0x3f, },
+ new uint [] {0x2b, 0x2a, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x7a, 0x5a, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xffffffb9, 0xffffffa9, },
+ new uint [] {0xfffffff0, 0xffffffd0, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xffffffe8, 0xffffffc8, }, new uint [] {0xffffffe6, 0xffffffc6, },
+ new uint [] {0xffffffbe, 0xffffffae, }, new uint [] {0x79, 0x59, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [44] = new KeyboardLayout (1050, "Croatian keyboard layout (specific)", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0x5b, 0x7b, 0xffffffb9, 0xffffffa9, },
+ new uint [] {0x5d, 0x7d, 0xfffffff0, 0xffffffd0, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0x3b, 0x3a, 0xffffffe8, 0xffffffc8, }, new uint [] {0x27, 0x22, 0xffffffe6, 0xffffffc6, },
+ new uint [] {0x5c, 0x7c, 0xffffffbe, 0xffffffae, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3c, }, new uint [] {0x2e, 0x3e, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {0x3c, 0x3e, 0x7c, },
+ new uint [] {}, });
+ table [45] = new KeyboardLayout (1041, "Japanese 106 keyboard layout", 3, 7, new uint [][] {
+ new uint [] {0x31, 0x21, }, new uint [] {0x32, 0x22, },
+ new uint [] {0x33, 0x23, }, new uint [] {0x34, 0x24, },
+ new uint [] {0x35, 0x25, }, new uint [] {0x36, 0x26, },
+ new uint [] {0x37, 0x27, }, new uint [] {0x38, 0x28, },
+ new uint [] {0x39, 0x29, }, new uint [] {0x30, 0x7e, },
+ new uint [] {0x2d, 0x3d, }, new uint [] {0x5e, 0x7e, },
+ new uint [] {0x5c, 0x7c, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0x40, 0x60, },
+ new uint [] {0x5b, 0x7b, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0x3b, 0x2b, }, new uint [] {0x3a, 0x2a, },
+ new uint [] {0x5d, 0x7d, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3c, }, new uint [] {0x2e, 0x3e, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {0x5c, 0x5f, },
+ new uint [] {}, });
+ table [46] = new KeyboardLayout (1041, "Japanese pc98x1 keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x31, 0x21, }, new uint [] {0x32, 0x22, },
+ new uint [] {0x33, 0x23, }, new uint [] {0x34, 0x24, },
+ new uint [] {0x35, 0x25, }, new uint [] {0x36, 0x26, },
+ new uint [] {0x37, 0x27, }, new uint [] {0x38, 0x28, },
+ new uint [] {0x39, 0x29, }, new uint [] {0x30, },
+ new uint [] {0x2d, 0x3d, }, new uint [] {0x5e, 0x60, },
+ new uint [] {0x5c, 0x7c, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0x40, 0x7e, },
+ new uint [] {0x5b, 0x7b, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0x3b, 0x2b, }, new uint [] {0x3a, 0x2a, },
+ new uint [] {0x5d, 0x7d, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3c, }, new uint [] {0x2e, 0x3e, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {0x5c, 0x5f, },
+ new uint [] {}, });
+ table [47] = new KeyboardLayout (1051, "Slovak keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x3b, 0x30, }, new uint [] {0x2b, 0x31, },
+ new uint [] {0xffffffb5, 0x32, }, new uint [] {0xffffffb9, 0x33, },
+ new uint [] {0xffffffe8, 0x34, }, new uint [] {0xffffffbb, 0x35, },
+ new uint [] {0xffffffbe, 0x36, }, new uint [] {0xfffffffd, 0x37, },
+ new uint [] {0xffffffe1, 0x38, }, new uint [] {0xffffffed, 0x39, },
+ new uint [] {0xffffffe9, 0x30, }, new uint [] {0x3d, 0x25, },
+ new uint [] {0x27, 0x76, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xfffffffa, 0x2f, },
+ new uint [] {0xffffffe4, 0x28, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xfffffff4, 0x22, }, new uint [] {0xffffffa7, 0x21, },
+ new uint [] {0xfffffff2, 0x29, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3f, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [48] = new KeyboardLayout (1051, "Slovak and Czech keyboard layout without dead keys", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x71, 0x51, 0xffffffe4, 0xffffffc4, },
+ new uint [] {0x77, 0x57, 0xffffffec, 0xffffffcc, }, new uint [] {0x65, 0x45, 0xffffffe9, 0xffffffc9, },
+ new uint [] {0x72, 0x52, 0xfffffff8, 0xffffffd8, }, new uint [] {0x74, 0x54, 0xffffffbb, 0xffffffab, },
+ new uint [] {0x79, 0x59, 0xfffffffd, 0xffffffdd, }, new uint [] {0x75, 0x55, 0xfffffff9, 0xffffffd9, },
+ new uint [] {0x69, 0x49, 0xffffffed, 0xffffffcd, }, new uint [] {0x6f, 0x4f, 0xfffffff3, 0xffffffd3, },
+ new uint [] {0x70, 0x50, 0xfffffff6, 0xffffffd6, }, new uint [] {0x5b, 0x7b, },
+ new uint [] {0x5d, 0x7d, }, new uint [] {0x61, 0x41, 0xffffffe1, 0xffffffc1, },
+ new uint [] {0x73, 0x53, 0xffffffb9, 0xffffffa9, }, new uint [] {0x64, 0x44, 0xffffffef, 0xffffffcf, },
+ new uint [] {0x66, 0x46, 0xffffffeb, 0xffffffcb, }, new uint [] {0x67, 0x47, 0xffffffe0, 0xffffffc0, },
+ new uint [] {0x68, 0x48, 0xfffffffa, 0xffffffda, }, new uint [] {0x6a, 0x4a, 0xfffffffc, 0xffffffdc, },
+ new uint [] {0x6b, 0x4b, 0xfffffff4, 0xffffffd4, }, new uint [] {0x6c, 0x4c, 0xffffffb5, 0xffffffa5, },
+ new uint [] {0x3b, 0x3a, }, new uint [] {0x27, 0x22, },
+ new uint [] {0x5c, 0x7c, }, new uint [] {0x7a, 0x5a, 0xffffffbe, 0xffffffae, },
+ new uint [] {0x78, 0x58, 0xffffffa4, }, new uint [] {0x63, 0x43, 0xffffffe8, 0xffffffc8, },
+ new uint [] {0x76, 0x56, 0xffffffe7, 0xffffffc7, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, 0xfffffff2, 0xffffffd2, }, new uint [] {0x6d, 0x4d, 0xffffffe5, 0xffffffc5, },
+ new uint [] {0x2c, 0x3c, }, new uint [] {0x2e, 0x3e, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [49] = new KeyboardLayout (1029, "Czech keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x3b, }, new uint [] {0x2b, 0x31, },
+ new uint [] {0xffffffec, 0x32, }, new uint [] {0xffffffb9, 0x33, },
+ new uint [] {0xffffffe8, 0x34, }, new uint [] {0xfffffff8, 0x35, },
+ new uint [] {0xffffffbe, 0x36, }, new uint [] {0xfffffffd, 0x37, },
+ new uint [] {0xffffffe1, 0x38, }, new uint [] {0xffffffed, 0x39, },
+ new uint [] {0xffffffe9, 0x30, 0xffffffbd, 0x29, }, new uint [] {0x3d, 0x25, },
+ new uint [] {}, new uint [] {0x71, 0x51, 0x5c, },
+ new uint [] {0x77, 0x57, 0x7c, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xfffffffa, 0x2f, 0x5b, 0x7b, },
+ new uint [] {0x29, 0x28, 0x5d, 0x7d, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, 0xfffffff0, }, new uint [] {0x64, 0x44, 0xffffffd0, },
+ new uint [] {0x66, 0x46, 0x5b, }, new uint [] {0x67, 0x47, 0x5d, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, 0xffffffb3, }, new uint [] {0x6c, 0x4c, 0xffffffa3, },
+ new uint [] {0xfffffff9, 0x22, 0x24, }, new uint [] {0xffffffa7, 0x21, 0xffffffdf, },
+ new uint [] {0xffffffa8, 0x27, }, new uint [] {0x7a, 0x5a, 0x3e, },
+ new uint [] {0x78, 0x58, 0x23, }, new uint [] {0x63, 0x43, 0x26, },
+ new uint [] {0x76, 0x56, 0x40, }, new uint [] {0x62, 0x42, 0x7b, },
+ new uint [] {0x6e, 0x4e, 0x7d, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3f, 0x3c, }, new uint [] {0x2e, 0x3a, 0x3e, },
+ new uint [] {0x2d, 0x5f, 0x2a, }, new uint [] {0x3c, 0x3e, 0x5c, 0x7c, },
+ new uint [] {}, });
+ table [50] = new KeyboardLayout (1029, "Czech keyboard layout cz", 0, 1, new uint [][] {
+ new uint [] {0x3b, }, new uint [] {0x2b, 0x31, },
+ new uint [] {0xffffffec, 0x32, }, new uint [] {0xffffffb9, 0x33, },
+ new uint [] {0xffffffe8, 0x34, }, new uint [] {0xfffffff8, 0x35, },
+ new uint [] {0xffffffbe, 0x36, }, new uint [] {0xfffffffd, 0x37, },
+ new uint [] {0xffffffe1, 0x38, }, new uint [] {0xffffffed, 0x39, },
+ new uint [] {0xffffffe9, 0x30, }, new uint [] {0x3d, 0x25, },
+ new uint [] {0xffffffb4, 0xffffffb7, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x7a, 0x5a, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xfffffffa, 0x2f, },
+ new uint [] {0x29, 0x28, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xfffffff9, 0x22, }, new uint [] {0xffffffa7, 0x21, },
+ new uint [] {0xffffffa8, 0x27, }, new uint [] {0x79, 0x59, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3f, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x5c, },
+ new uint [] {}, });
+ table [51] = new KeyboardLayout (1029, "Czech keyboard layout cz_qwerty", 0, 0, new uint [][] {
+ new uint [] {0x3b, }, new uint [] {0x2b, 0x31, },
+ new uint [] {0xffffffec, 0x32, }, new uint [] {0xffffffb9, 0x33, },
+ new uint [] {0xffffffe8, 0x34, }, new uint [] {0xfffffff8, 0x35, },
+ new uint [] {0xffffffbe, 0x36, }, new uint [] {0xfffffffd, 0x37, },
+ new uint [] {0xffffffe1, 0x38, }, new uint [] {0xffffffed, 0x39, },
+ new uint [] {0xffffffe9, 0x30, }, new uint [] {0x3d, 0x25, },
+ new uint [] {0xffffffb4, 0xffffffb7, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xfffffffa, 0x2f, },
+ new uint [] {0x29, 0x28, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xfffffff9, 0x22, }, new uint [] {0xffffffa7, 0x21, },
+ new uint [] {0xffffffa8, 0x27, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3f, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x5c, },
+ new uint [] {}, });
+ table [52] = new KeyboardLayout (1034, "Latin American keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x7c, 0xffffffb0, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, },
+ new uint [] {0x38, 0x28, }, new uint [] {0x39, 0x29, },
+ new uint [] {0x30, 0x3d, }, new uint [] {0x27, 0x3f, },
+ new uint [] {0xffffffbf, 0xffffffa1, }, new uint [] {0x71, 0x51, 0x40, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xffffffb4, 0xffffffa8, },
+ new uint [] {0x2b, 0x2a, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xfffffff1, 0xffffffd1, }, new uint [] {0x7b, 0x5b, 0x5e, },
+ new uint [] {0x7d, 0x5d, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [53] = new KeyboardLayout (1063, "Lithuanian (Baltic) keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, }, new uint [] {0xffffffe0, 0xffffffc0, },
+ new uint [] {0xffffffe8, 0xffffffc8, }, new uint [] {0xffffffe6, 0xffffffc6, },
+ new uint [] {0xffffffeb, 0xffffffcb, }, new uint [] {0xffffffe1, 0xffffffc1, },
+ new uint [] {0xfffffff0, 0xffffffd0, }, new uint [] {0xfffffff8, 0xffffffd8, },
+ new uint [] {0xfffffffb, 0xffffffdb, }, new uint [] {0xffffffa5, 0x28, },
+ new uint [] {0xffffffb4, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0xfffffffe, 0xffffffde, }, new uint [] {0x5c, 0x7c, },
+ new uint [] {0x71, 0x51, }, new uint [] {0x77, 0x57, },
+ new uint [] {0x65, 0x45, }, new uint [] {0x72, 0x52, },
+ new uint [] {0x74, 0x54, }, new uint [] {0x79, 0x59, },
+ new uint [] {0x75, 0x55, }, new uint [] {0x69, 0x49, },
+ new uint [] {0x6f, 0x4f, }, new uint [] {0x70, 0x50, },
+ new uint [] {0x5b, 0x7b, }, new uint [] {0x5d, 0x7d, },
+ new uint [] {0x61, 0x41, }, new uint [] {0x73, 0x53, },
+ new uint [] {0x64, 0x44, }, new uint [] {0x66, 0x46, },
+ new uint [] {0x67, 0x47, }, new uint [] {0x68, 0x48, },
+ new uint [] {0x6a, 0x4a, }, new uint [] {0x6b, 0x4b, },
+ new uint [] {0x6c, 0x4c, }, new uint [] {0x3b, 0x3a, },
+ new uint [] {0x27, 0x22, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3c, }, new uint [] {0x2e, 0x3e, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {},
+ new uint [] {}, });
+ table [54] = new KeyboardLayout (1055, "Turkish keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x22, 0xffffffe9, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x27, }, new uint [] {0x33, 0x5e, 0x23, },
+ new uint [] {0x34, 0x2b, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, 0x7b, },
+ new uint [] {0x38, 0x28, 0x5b, }, new uint [] {0x39, 0x29, 0x5d, },
+ new uint [] {0x30, 0x3d, 0x7d, }, new uint [] {0x2a, 0x3f, 0x5c, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x71, 0x51, 0x40, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0xfffffffd, 0x49, 0xffffffee, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xfffffff0, 0xffffffd0, },
+ new uint [] {0xfffffffc, 0xffffffdc, 0x7e, }, new uint [] {0x61, 0x41, 0xffffffe6, },
+ new uint [] {0x73, 0x53, 0xffffffdf, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xfffffffe, 0xffffffde, }, new uint [] {0x69, 0xffffffdd, },
+ new uint [] {0x2c, 0x3b, 0x60, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0xfffffff6, 0xffffffd6, }, new uint [] {0xffffffe7, 0xffffffc7, },
+ new uint [] {0x2e, 0x3a, }, new uint [] {},
+ new uint [] {}, });
+ table [55] = new KeyboardLayout (1055, "Turkish keyboard layout tr", 0, 0, new uint [][] {
+ new uint [] {0x22, 0x5c, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x27, }, new uint [] {0x33, 0x5e, },
+ new uint [] {0x34, 0x2b, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x2f, },
+ new uint [] {0x38, 0x28, }, new uint [] {0x39, 0x29, },
+ new uint [] {0x30, 0x3d, }, new uint [] {0x2a, 0x3f, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0xffffffb9, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xffffffbb, 0xffffffab, },
+ new uint [] {0xfffffffc, 0xffffffdc, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0xffffffba, 0xffffffaa, }, new uint [] {0x69, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0xfffffff6, 0xffffffd6, }, new uint [] {0xffffffe7, 0xffffffc7, },
+ new uint [] {0x2e, 0x3a, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [56] = new KeyboardLayout (1055, "Turkish keyboard layout trf", 0, 0, new uint [][] {
+ new uint [] {0x2b, 0x2a, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0x5e, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x27, },
+ new uint [] {0x38, 0x28, }, new uint [] {0x39, 0x29, },
+ new uint [] {0x30, 0x3d, }, new uint [] {0x2f, 0x3f, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x66, 0x46, },
+ new uint [] {0x67, 0x47, }, new uint [] {0xffffffbb, 0xffffffab, },
+ new uint [] {0xffffffb9, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x64, 0x44, }, new uint [] {0x72, 0x52, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x68, 0x48, },
+ new uint [] {0x70, 0x50, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x61, 0x41, }, new uint [] {0xfffffffc, 0xffffffdc, },
+ new uint [] {0x74, 0x54, }, new uint [] {0x6b, 0x4b, },
+ new uint [] {0x6d, 0x4d, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0x79, 0x59, }, new uint [] {0xffffffba, 0xffffffaa, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0xfffffff6, 0xffffffd6, }, new uint [] {0x76, 0x56, },
+ new uint [] {0x63, 0x43, }, new uint [] {0xffffffe7, 0xffffffc7, },
+ new uint [] {0x7a, 0x5a, }, new uint [] {0x73, 0x53, },
+ new uint [] {0x62, 0x42, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [57] = new KeyboardLayout (1037, "Israelian keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, 0x3b, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x71, 0x51, 0x2f, },
+ new uint [] {0x77, 0x57, 0x27, }, new uint [] {0x65, 0x45, 0xfffffff7, },
+ new uint [] {0x72, 0x52, 0xfffffff8, }, new uint [] {0x74, 0x54, 0xffffffe0, },
+ new uint [] {0x79, 0x59, 0xffffffe8, }, new uint [] {0x75, 0x55, 0xffffffe5, },
+ new uint [] {0x69, 0x49, 0xffffffef, }, new uint [] {0x6f, 0x4f, 0xffffffed, },
+ new uint [] {0x70, 0x50, 0xfffffff4, }, new uint [] {0x5b, 0x7b, },
+ new uint [] {0x5d, 0x7d, }, new uint [] {0x61, 0x41, 0xfffffff9, },
+ new uint [] {0x73, 0x53, 0xffffffe3, }, new uint [] {0x64, 0x44, 0xffffffe2, },
+ new uint [] {0x66, 0x46, 0xffffffeb, }, new uint [] {0x67, 0x47, 0xfffffff2, },
+ new uint [] {0x68, 0x48, 0xffffffe9, }, new uint [] {0x6a, 0x4a, 0xffffffe7, },
+ new uint [] {0x6b, 0x4b, 0xffffffec, }, new uint [] {0x6c, 0x4c, 0xffffffea, },
+ new uint [] {0x3b, 0x3a, 0xfffffff3, }, new uint [] {0x27, 0x22, 0x2c, },
+ new uint [] {0x5c, 0x7c, }, new uint [] {0x7a, 0x5a, 0xffffffe6, },
+ new uint [] {0x78, 0x58, 0xfffffff1, }, new uint [] {0x63, 0x43, 0xffffffe1, },
+ new uint [] {0x76, 0x56, 0xffffffe4, }, new uint [] {0x62, 0x42, 0xfffffff0, },
+ new uint [] {0x6e, 0x4e, 0xffffffee, }, new uint [] {0x6d, 0x4d, 0xfffffff6, },
+ new uint [] {0x2c, 0x3c, 0xfffffffa, }, new uint [] {0x2e, 0x3e, 0xfffffff5, },
+ new uint [] {0x2f, 0x3f, 0x2e, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [58] = new KeyboardLayout (1037, "Israelian phonetic keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x71, 0x51, 0xfffffff7, },
+ new uint [] {0x77, 0x57, 0xffffffe5, }, new uint [] {0x65, 0x45, 0xffffffe0, },
+ new uint [] {0x72, 0x52, 0xfffffff8, }, new uint [] {0x74, 0x54, 0xfffffffa, },
+ new uint [] {0x79, 0x59, 0xfffffff2, }, new uint [] {0x75, 0x55, 0xffffffe5, },
+ new uint [] {0x69, 0x49, 0xffffffe9, }, new uint [] {0x6f, 0x4f, 0xfffffff1, },
+ new uint [] {0x70, 0x50, 0xfffffff4, }, new uint [] {0x5b, 0x7b, },
+ new uint [] {0x5d, 0x7d, }, new uint [] {0x61, 0x41, 0xffffffe0, },
+ new uint [] {0x73, 0x53, 0xfffffff9, }, new uint [] {0x64, 0x44, 0xffffffe3, },
+ new uint [] {0x66, 0x46, 0xfffffff4, }, new uint [] {0x67, 0x47, 0xffffffe2, },
+ new uint [] {0x68, 0x48, 0xffffffe4, }, new uint [] {0x6a, 0x4a, 0xffffffe9, },
+ new uint [] {0x6b, 0x4b, 0xffffffeb, }, new uint [] {0x6c, 0x4c, 0xffffffec, },
+ new uint [] {0x3b, 0x3a, }, new uint [] {0x27, 0x22, },
+ new uint [] {0x5c, 0x7c, }, new uint [] {0x7a, 0x5a, 0xffffffe6, },
+ new uint [] {0x78, 0x58, 0xffffffe7, }, new uint [] {0x63, 0x43, 0xfffffff6, },
+ new uint [] {0x76, 0x56, 0xffffffe5, }, new uint [] {0x62, 0x42, 0xffffffe1, },
+ new uint [] {0x6e, 0x4e, 0xfffffff0, }, new uint [] {0x6d, 0x4d, 0xffffffee, },
+ new uint [] {0x2c, 0x3c, }, new uint [] {0x2e, 0x3e, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [59] = new KeyboardLayout (1037, "Israelian Saharon keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x71, 0x51, 0xfffffff7, },
+ new uint [] {0x77, 0x57, 0xfffffff1, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, 0xfffffff8, }, new uint [] {0x74, 0x54, 0xffffffe8, },
+ new uint [] {0x79, 0x59, 0xffffffe3, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, 0xfffffff4, }, new uint [] {0x5b, 0x7b, },
+ new uint [] {0x5d, 0x7d, }, new uint [] {0x61, 0x41, 0xffffffe0, },
+ new uint [] {0x73, 0x53, 0xffffffe5, }, new uint [] {0x64, 0x44, 0xffffffec, },
+ new uint [] {0x66, 0x46, 0xfffffffa, }, new uint [] {0x67, 0x47, 0xffffffe2, },
+ new uint [] {0x68, 0x48, 0xffffffe4, }, new uint [] {0x6a, 0x4a, 0xfffffff9, },
+ new uint [] {0x6b, 0x4b, 0xffffffeb, }, new uint [] {0x6c, 0x4c, 0xffffffe9, },
+ new uint [] {0x3b, 0x3a, }, new uint [] {0x27, 0x22, },
+ new uint [] {0x5c, 0x7c, }, new uint [] {0x7a, 0x5a, 0xffffffe6, },
+ new uint [] {0x78, 0x58, 0xffffffe7, }, new uint [] {0x63, 0x43, 0xfffffff6, },
+ new uint [] {0x76, 0x56, 0xfffffff2, }, new uint [] {0x62, 0x42, 0xffffffe1, },
+ new uint [] {0x6e, 0x4e, 0xfffffff0, }, new uint [] {0x6d, 0x4d, 0xffffffee, },
+ new uint [] {0x2c, 0x3c, }, new uint [] {0x2e, 0x3e, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [60] = new KeyboardLayout (1033, "VNC keyboard layout", 4, 8, new uint [][] {
+ new uint [] {0x31, 0x21, }, new uint [] {0x32, 0x40, },
+ new uint [] {0x33, 0x23, }, new uint [] {0x34, 0x24, },
+ new uint [] {0x35, 0x25, }, new uint [] {0x36, 0x5e, },
+ new uint [] {0x37, 0x26, }, new uint [] {0x38, 0x2a, },
+ new uint [] {0x39, 0x28, }, new uint [] {0x30, 0x29, },
+ new uint [] {0x2d, 0x5f, }, new uint [] {0x3d, 0x2b, },
+ new uint [] {0x5b, 0x7b, }, new uint [] {0x5d, 0x7d, },
+ new uint [] {0x3b, 0x3a, }, new uint [] {0x27, 0x22, },
+ new uint [] {0x60, 0x7e, }, new uint [] {0x2c, 0x3c, },
+ new uint [] {0x2e, 0x3e, }, new uint [] {0x2f, 0x3f, },
+ new uint [] {0x5c, 0x7c, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x62, 0x42, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x64, 0x44, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x69, 0x49, },
+ new uint [] {0x6a, 0x4a, }, new uint [] {0x6b, 0x4b, },
+ new uint [] {0x6c, 0x4c, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x73, 0x53, },
+ new uint [] {0x74, 0x54, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x77, 0x57, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x79, 0x59, },
+ new uint [] {0x7a, 0x5a, }, new uint [] {},
+ new uint [] {}, });
+ table [61] = new KeyboardLayout (1032, "Greek keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x40, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x5e, }, new uint [] {0x37, 0x26, },
+ new uint [] {0x38, 0x2a, }, new uint [] {0x39, 0x28, },
+ new uint [] {0x30, 0x29, }, new uint [] {0x2d, 0x5f, },
+ new uint [] {0x3d, 0x2b, }, new uint [] {0x71, 0x51, 0x3b, 0x3a, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, 0xffffffe5, 0xffffffc5, },
+ new uint [] {0x72, 0x52, 0xfffffff1, 0xffffffd1, }, new uint [] {0x74, 0x54, 0xfffffff4, 0xffffffd4, },
+ new uint [] {0x79, 0x59, 0xfffffff5, 0xffffffd5, }, new uint [] {0x75, 0x55, 0xffffffe8, 0xffffffc8, },
+ new uint [] {0x69, 0x49, 0xffffffe9, 0xffffffc9, }, new uint [] {0x6f, 0x4f, 0xffffffef, 0xffffffcf, },
+ new uint [] {0x70, 0x50, 0xfffffff0, 0xffffffd0, }, new uint [] {0x5b, 0x7b, },
+ new uint [] {0x5d, 0x7d, }, new uint [] {0x61, 0x41, 0xffffffe1, 0xffffffc1, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, 0xffffffe4, 0xffffffc4, },
+ new uint [] {0x66, 0x46, 0xfffffff6, 0xffffffd6, }, new uint [] {0x67, 0x47, 0xffffffe3, 0xffffffc3, },
+ new uint [] {0x68, 0x48, 0xffffffe7, 0xffffffc7, }, new uint [] {0x6a, 0x4a, 0xffffffee, 0xffffffce, },
+ new uint [] {0x6b, 0x4b, 0xffffffea, 0xffffffca, }, new uint [] {0x6c, 0x4c, 0xffffffeb, 0xffffffcb, },
+ new uint [] {0x3b, 0x3a, 0xffffffb4, 0xffffffa8, }, new uint [] {0x27, 0x22, },
+ new uint [] {0x5c, 0x7c, }, new uint [] {0x7a, 0x5a, 0xffffffe6, 0xffffffc6, },
+ new uint [] {0x78, 0x58, 0xfffffff7, 0xffffffd7, }, new uint [] {0x63, 0x43, 0xfffffff8, 0xffffffd8, },
+ new uint [] {0x76, 0x56, 0xfffffff9, 0xffffffd9, }, new uint [] {0x62, 0x42, 0xffffffe2, 0xffffffc2, },
+ new uint [] {0x6e, 0x4e, 0xffffffed, 0xffffffcd, }, new uint [] {0x6d, 0x4d, 0xffffffec, 0xffffffcc, },
+ new uint [] {0x2c, 0x3c, }, new uint [] {0x2e, 0x3e, },
+ new uint [] {0x2f, 0x3f, }, new uint [] {0x3c, 0x3e, },
+ new uint [] {}, });
+ table [62] = new KeyboardLayout (1054, "Thai (Kedmanee) keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x60, 0x7e, 0x5f, 0x25, }, new uint [] {0x31, 0x21, 0xffffffe5, 0x2b, },
+ new uint [] {0x32, 0x40, 0x2f, 0xfffffff1, }, new uint [] {0x33, 0x23, 0x2d, 0xfffffff2, },
+ new uint [] {0x34, 0x24, 0xffffffc0, 0xfffffff3, }, new uint [] {0x35, 0x25, 0xffffffb6, 0xfffffff4, },
+ new uint [] {0x36, 0x5e, 0xffffffd8, 0xffffffd9, }, new uint [] {0x37, 0x26, 0xffffffd6, 0xffffffdf, },
+ new uint [] {0x38, 0x2a, 0xffffffa4, 0xfffffff5, }, new uint [] {0x39, 0x28, 0xffffffb5, 0xfffffff6, },
+ new uint [] {0x30, 0x29, 0xffffffa8, 0xfffffff7, }, new uint [] {0x2d, 0x5f, 0xffffffa2, 0xfffffff8, },
+ new uint [] {0x3d, 0x2b, 0xffffffaa, 0xfffffff9, }, new uint [] {0x71, 0x51, 0xffffffe6, 0xfffffff0, },
+ new uint [] {0x77, 0x57, 0xffffffe4, 0x22, }, new uint [] {0x65, 0x45, 0xffffffd3, 0xffffffae, },
+ new uint [] {0x72, 0x52, 0xffffffbe, 0xffffffb1, }, new uint [] {0x74, 0x54, 0xffffffd0, 0xffffffb8, },
+ new uint [] {0x79, 0x59, 0xffffffd1, 0xffffffed, }, new uint [] {0x75, 0x55, 0xffffffd5, 0xffffffea, },
+ new uint [] {0x69, 0x49, 0xffffffc3, 0xffffffb3, }, new uint [] {0x6f, 0x4f, 0xffffffb9, 0xffffffcf, },
+ new uint [] {0x70, 0x50, 0xffffffc2, 0xffffffad, }, new uint [] {0x5b, 0x7b, 0xffffffba, 0xffffffb0, },
+ new uint [] {0x5d, 0x7d, 0xffffffc5, 0x2c, }, new uint [] {0x61, 0x41, 0xffffffbf, 0xffffffc4, },
+ new uint [] {0x73, 0x53, 0xffffffcb, 0xffffffa6, }, new uint [] {0x64, 0x44, 0xffffffa1, 0xffffffaf, },
+ new uint [] {0x66, 0x46, 0xffffffb4, 0xffffffe2, }, new uint [] {0x67, 0x47, 0xffffffe0, 0xffffffac, },
+ new uint [] {0x68, 0x48, 0xffffffe9, 0xffffffe7, }, new uint [] {0x6a, 0x4a, 0xffffffe8, 0xffffffeb, },
+ new uint [] {0x6b, 0x4b, 0xffffffd2, 0xffffffc9, }, new uint [] {0x6c, 0x4c, 0xffffffca, 0xffffffc8, },
+ new uint [] {0x3b, 0x3a, 0xffffffc7, 0xffffffab, }, new uint [] {0x27, 0x22, 0xffffffa7, 0x2e, },
+ new uint [] {0x5c, 0x7c, 0xffffffa3, 0xffffffa5, }, new uint [] {0x7a, 0x5a, 0xffffffbc, 0x28, },
+ new uint [] {0x78, 0x58, 0xffffffbb, 0x29, }, new uint [] {0x63, 0x43, 0xffffffe1, 0xffffffa9, },
+ new uint [] {0x76, 0x56, 0xffffffcd, 0xffffffce, }, new uint [] {0x62, 0x42, 0xffffffda, },
+ new uint [] {0x6e, 0x4e, 0xffffffd7, 0xffffffec, }, new uint [] {0x6d, 0x4d, 0xffffffb7, 0x3f, },
+ new uint [] {0x2c, 0x3c, 0xffffffc1, 0xffffffb2, }, new uint [] {0x2e, 0x3e, 0xffffffe3, 0xffffffcc, },
+ new uint [] {0x2f, 0x3f, 0xffffffbd, 0xffffffc6, }, new uint [] {},
+ new uint [] {}, });
+ table [63] = new KeyboardLayout (1043, "Dutch keyboard layout", 0, 0, new uint [][] {
+ new uint [] {0x40, 0xffffffa7, }, new uint [] {0x31, 0x21, },
+ new uint [] {0x32, 0x22, }, new uint [] {0x33, 0x23, },
+ new uint [] {0x34, 0x24, }, new uint [] {0x35, 0x25, },
+ new uint [] {0x36, 0x26, }, new uint [] {0x37, 0x5f, },
+ new uint [] {0x38, 0x28, }, new uint [] {0x39, 0x29, },
+ new uint [] {0x30, 0x27, }, new uint [] {0x2f, 0x3f, },
+ new uint [] {0xffffffb0, 0x7e, }, new uint [] {0x71, 0x51, },
+ new uint [] {0x77, 0x57, }, new uint [] {0x65, 0x45, },
+ new uint [] {0x72, 0x52, }, new uint [] {0x74, 0x54, },
+ new uint [] {0x79, 0x59, }, new uint [] {0x75, 0x55, },
+ new uint [] {0x69, 0x49, }, new uint [] {0x6f, 0x4f, },
+ new uint [] {0x70, 0x50, }, new uint [] {0xffffffa8, 0x7e, },
+ new uint [] {0x2a, 0x7c, }, new uint [] {0x61, 0x41, },
+ new uint [] {0x73, 0x53, }, new uint [] {0x64, 0x44, },
+ new uint [] {0x66, 0x46, }, new uint [] {0x67, 0x47, },
+ new uint [] {0x68, 0x48, }, new uint [] {0x6a, 0x4a, },
+ new uint [] {0x6b, 0x4b, }, new uint [] {0x6c, 0x4c, },
+ new uint [] {0x2b, 0xffffffb1, }, new uint [] {0x27, 0x60, },
+ new uint [] {0x3c, 0x3e, }, new uint [] {0x7a, 0x5a, },
+ new uint [] {0x78, 0x58, }, new uint [] {0x63, 0x43, },
+ new uint [] {0x76, 0x56, }, new uint [] {0x62, 0x42, },
+ new uint [] {0x6e, 0x4e, }, new uint [] {0x6d, 0x4d, },
+ new uint [] {0x2c, 0x3b, }, new uint [] {0x2e, 0x3a, },
+ new uint [] {0x2d, 0x3d, }, new uint [] {0x5b, 0x5d, },
+ new uint [] {}, });
+
+
+ rsxw.AddResource ("keyboard_table", table);
+
+ short [][] scan_table = new short [][] {
+ main_key_scan_qwerty, main_key_scan_dvorak, main_key_scan_abnt_qwerty,
+ main_key_scan_qwerty_jp106, main_key_scan_vnc
+ };
+ rsxw.AddResource ("scan_table", scan_table);
+
+ VirtualKeys [][] vkeys = new VirtualKeys [][] {
+ main_key_vkey_qwerty, main_key_vkey_qwertz, main_key_vkey_dvorak,
+ main_key_vkey_qwertz_105, main_key_vkey_azerty, main_key_vkey_qwerty_v2,
+ main_key_vkey_abnt_qwerty, main_key_vkey_qwerty_jp106, main_key_vkey_vnc
+ };
+ int [][] vkey_table = new int [vkeys.Length][];
+ for (int i = 0; i < vkeys.Length; i++) {
+ int [] cp = new int [vkeys [i].Length];
+ for (int r = 0; r < vkeys [i].Length; r++)
+ cp [r] = (int) vkeys [i][r];
+ vkey_table [i] = cp;
+ }
+
+ rsxw.AddResource ("vkey_table", vkey_table);
+
+ rsxw.Close ();
+ }
+
+ private static readonly short [] main_key_scan_vnc = new short []
+ {
+ 0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x1A,0x1B,0x27,0x28,0x29,0x33,0x34,0x35,0x2B,
+ 0x1E,0x30,0x2E,0x20,0x12,0x21,0x22,0x23,0x17,0x24,0x25,0x26,0x32,0x31,0x18,0x19,0x10,0x13,0x1F,0x14,0x16,0x2F,0x11,0x2D,0x15,0x2C,
+ 0x56
+ };
+
+ private static readonly short [] main_key_scan_qwerty_jp106 = new short []
+ {
+ 0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x29,
+ 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,
+ 0x1E,0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x2B,
+ 0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,
+ 0x56 /* the 102nd key (actually to the right of l-shift) */
+ };
+
+ private static readonly VirtualKeys [] main_key_vkey_vnc = new VirtualKeys []
+ {
+ VirtualKeys.VK_1, VirtualKeys.VK_2, VirtualKeys.VK_3, VirtualKeys.VK_4, VirtualKeys.VK_5, VirtualKeys.VK_6,
+ VirtualKeys.VK_7, VirtualKeys.VK_8, VirtualKeys.VK_9, VirtualKeys.VK_0, VirtualKeys.VK_OEM_MINUS,
+ VirtualKeys.VK_OEM_PLUS, VirtualKeys.VK_OEM_4, VirtualKeys.VK_OEM_6, VirtualKeys.VK_OEM_1,
+ VirtualKeys.VK_OEM_7, VirtualKeys.VK_OEM_3, VirtualKeys.VK_OEM_COMMA, VirtualKeys.VK_OEM_PERIOD,
+ VirtualKeys.VK_OEM_2, VirtualKeys.VK_OEM_5, VirtualKeys.VK_A, VirtualKeys.VK_B, VirtualKeys.VK_C,
+ VirtualKeys.VK_D, VirtualKeys.VK_E, VirtualKeys.VK_F, VirtualKeys.VK_G, VirtualKeys.VK_H,
+ VirtualKeys.VK_I, VirtualKeys.VK_J, VirtualKeys.VK_K, VirtualKeys.VK_L, VirtualKeys.VK_M,
+ VirtualKeys.VK_N, VirtualKeys.VK_O, VirtualKeys.VK_P, VirtualKeys.VK_Q, VirtualKeys.VK_R,
+ VirtualKeys.VK_S, VirtualKeys.VK_T, VirtualKeys.VK_U, VirtualKeys.VK_V, VirtualKeys.VK_W,
+ VirtualKeys.VK_X, VirtualKeys.VK_Y, VirtualKeys.VK_Z, VirtualKeys.VK_OEM_102
+ };
+
+ private static readonly short [] main_key_scan_qwerty = new short []
+ {
+ /* this is my (102-key) keyboard layout, sorry if it doesn't quite match yours */
+ /* ` 1 2 3 4 5 6 7 8 9 0 - = */
+ 0x29,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,
+ /* q w e r t y u i o p [ ] */
+ 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,
+ /* a s d f g h j k l ; ' \ */
+ 0x1E,0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x2B,
+ /* z x c v b n m , . / */
+ 0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,
+ 0x56 /* the 102nd key (actually to the right of l-shift) */
+ };
+
+ private static readonly short [] main_key_scan_dvorak = new short []
+ {
+ /* ` 1 2 3 4 5 6 7 8 9 0 [ ] */
+ 0x29,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x1A,0x1B,
+ /* ' , . p y f g c r l / = */
+ 0x28,0x33,0x34,0x19,0x15,0x21,0x22,0x2E,0x13,0x26,0x35,0x0D,
+ /* a o e u i d h t n s - \ */
+ 0x1E,0x18,0x12,0x16,0x17,0x20,0x23,0x14,0x31,0x1F,0x0C,0x2B,
+ /* ; q j k x b m w v z */
+ 0x27,0x10,0x24,0x25,0x2D,0x30,0x32,0x11,0x2F,0x2C,
+ 0x56 /* the 102nd key (actually to the right of l-shift) */
+ };
+
+ private static readonly short [] main_key_scan_abnt_qwerty = new short []
+ {
+ 0x29,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,
+ 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,
+ 0x1E,0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x2B,
+ 0x5e,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,
+ 0x56,
+ };
+
+ private static readonly VirtualKeys [] main_key_vkey_qwerty = new VirtualKeys []
+ {
+ // NOTE: this layout must concur with the scan codes layout above
+ VirtualKeys.VK_OEM_3, VirtualKeys.VK_1, VirtualKeys.VK_2, VirtualKeys.VK_3, VirtualKeys.VK_4,
+ VirtualKeys.VK_5, VirtualKeys.VK_6, VirtualKeys.VK_7, VirtualKeys.VK_8, VirtualKeys.VK_9,
+ VirtualKeys.VK_0, VirtualKeys.VK_OEM_MINUS, VirtualKeys.VK_OEM_PLUS, VirtualKeys.VK_Q,
+ VirtualKeys.VK_W, VirtualKeys.VK_E, VirtualKeys.VK_R, VirtualKeys.VK_T, VirtualKeys.VK_Y,
+ VirtualKeys.VK_U, VirtualKeys.VK_I, VirtualKeys.VK_O, VirtualKeys.VK_P, VirtualKeys.VK_OEM_4,
+ VirtualKeys.VK_OEM_6, VirtualKeys.VK_A, VirtualKeys.VK_S, VirtualKeys.VK_D, VirtualKeys.VK_F,
+ VirtualKeys.VK_G, VirtualKeys.VK_H, VirtualKeys.VK_J, VirtualKeys.VK_K, VirtualKeys.VK_L,
+ VirtualKeys.VK_OEM_1, VirtualKeys.VK_OEM_7, VirtualKeys.VK_OEM_5, VirtualKeys.VK_Z,
+ VirtualKeys.VK_X, VirtualKeys.VK_C, VirtualKeys.VK_V, VirtualKeys.VK_B, VirtualKeys.VK_N,
+ VirtualKeys.VK_M, VirtualKeys.VK_OEM_COMMA, VirtualKeys.VK_OEM_PERIOD, VirtualKeys.VK_OEM_2,
+ VirtualKeys.VK_OEM_102 // the 102nd key (actually to the right of l-shift)
+ };
+
+ private static readonly VirtualKeys [] main_key_vkey_qwertz = new VirtualKeys []
+ {
+ VirtualKeys.VK_OEM_3, VirtualKeys.VK_1, VirtualKeys.VK_2, VirtualKeys.VK_3, VirtualKeys.VK_4,
+ VirtualKeys.VK_5, VirtualKeys.VK_6, VirtualKeys.VK_7, VirtualKeys.VK_8, VirtualKeys.VK_9,
+ VirtualKeys.VK_0, VirtualKeys.VK_OEM_MINUS, VirtualKeys.VK_OEM_PLUS,
+ VirtualKeys.VK_Q, VirtualKeys.VK_W, VirtualKeys.VK_E, VirtualKeys.VK_R, VirtualKeys.VK_T, VirtualKeys.VK_Z,
+ VirtualKeys.VK_U, VirtualKeys.VK_I, VirtualKeys.VK_O, VirtualKeys.VK_P, VirtualKeys.VK_OEM_4,
+ VirtualKeys.VK_OEM_6, VirtualKeys.VK_A, VirtualKeys.VK_S, VirtualKeys.VK_D, VirtualKeys.VK_F,
+ VirtualKeys.VK_G, VirtualKeys.VK_H, VirtualKeys.VK_J, VirtualKeys.VK_K, VirtualKeys.VK_L,
+ VirtualKeys.VK_OEM_1, VirtualKeys.VK_OEM_7, VirtualKeys.VK_OEM_5, VirtualKeys.VK_Y,
+ VirtualKeys.VK_X, VirtualKeys.VK_C, VirtualKeys.VK_V, VirtualKeys.VK_B, VirtualKeys.VK_N,
+ VirtualKeys.VK_M, VirtualKeys.VK_OEM_COMMA, VirtualKeys.VK_OEM_PERIOD, VirtualKeys.VK_OEM_2,
+ VirtualKeys.VK_OEM_102 // the 102nd key (actually to the right of l-shift)
+ };
+
+ private static readonly VirtualKeys [] main_key_vkey_dvorak = new VirtualKeys []
+ {
+ // NOTE: this layout must concur with the scan codes layout above
+ VirtualKeys.VK_OEM_3, VirtualKeys.VK_1, VirtualKeys.VK_2, VirtualKeys.VK_3, VirtualKeys.VK_4,
+ VirtualKeys.VK_5, VirtualKeys.VK_6, VirtualKeys.VK_7, VirtualKeys.VK_8, VirtualKeys.VK_9,
+ VirtualKeys.VK_0, VirtualKeys.VK_OEM_4, VirtualKeys.VK_OEM_6, VirtualKeys.VK_OEM_7,
+ VirtualKeys.VK_OEM_COMMA, VirtualKeys.VK_OEM_PERIOD, VirtualKeys.VK_P, VirtualKeys.VK_Y,
+ VirtualKeys.VK_F, VirtualKeys.VK_G, VirtualKeys.VK_C, VirtualKeys.VK_R, VirtualKeys.VK_L,
+ VirtualKeys.VK_OEM_2, VirtualKeys.VK_OEM_PLUS, VirtualKeys.VK_A, VirtualKeys.VK_O,
+ VirtualKeys.VK_E, VirtualKeys.VK_U, VirtualKeys.VK_I, VirtualKeys.VK_D, VirtualKeys.VK_H,
+ VirtualKeys.VK_T, VirtualKeys.VK_N, VirtualKeys.VK_S, VirtualKeys.VK_OEM_MINUS, VirtualKeys.VK_OEM_5,
+ VirtualKeys.VK_OEM_1, VirtualKeys.VK_Q, VirtualKeys.VK_J, VirtualKeys.VK_K, VirtualKeys.VK_X,
+ VirtualKeys.VK_B, VirtualKeys.VK_M, VirtualKeys.VK_W, VirtualKeys.VK_V, VirtualKeys.VK_Z,
+ VirtualKeys.VK_OEM_102 // the 102nd key (actually to the right of l-shift)
+ };
+
+ private static readonly VirtualKeys [] main_key_vkey_azerty = new VirtualKeys []
+ {
+ // NOTE: this layout must concur with the scan codes layout above
+ VirtualKeys.VK_OEM_7, VirtualKeys.VK_1, VirtualKeys.VK_2, VirtualKeys.VK_3, VirtualKeys.VK_4,
+ VirtualKeys.VK_5, VirtualKeys.VK_6, VirtualKeys.VK_7, VirtualKeys.VK_8, VirtualKeys.VK_9,
+ VirtualKeys.VK_0, VirtualKeys.VK_OEM_4, VirtualKeys.VK_OEM_PLUS, VirtualKeys.VK_A, VirtualKeys.VK_Z,
+ VirtualKeys.VK_E, VirtualKeys.VK_R, VirtualKeys.VK_T, VirtualKeys.VK_Y, VirtualKeys.VK_U,
+ VirtualKeys.VK_I, VirtualKeys.VK_O, VirtualKeys.VK_P, VirtualKeys.VK_OEM_6, VirtualKeys.VK_OEM_1,
+ VirtualKeys.VK_Q, VirtualKeys.VK_S, VirtualKeys.VK_D, VirtualKeys.VK_F, VirtualKeys.VK_G,
+ VirtualKeys.VK_H, VirtualKeys.VK_J, VirtualKeys.VK_K, VirtualKeys.VK_L, VirtualKeys.VK_M,
+ VirtualKeys.VK_OEM_3, VirtualKeys.VK_OEM_5, VirtualKeys.VK_W, VirtualKeys.VK_X, VirtualKeys.VK_C,
+ VirtualKeys.VK_V, VirtualKeys.VK_B, VirtualKeys.VK_N, VirtualKeys.VK_OEM_COMMA, VirtualKeys.VK_OEM_PERIOD,
+ VirtualKeys.VK_OEM_2, VirtualKeys.VK_OEM_8,
+ VirtualKeys.VK_OEM_102 // the 102nd key (actually to the right of l-shift)
+ };
+
+
+ //// WRONG
+ private static readonly VirtualKeys [] main_key_vkey_qwerty_jp106 = new VirtualKeys []
+ {
+ // NOTE: this layout must concur with the scan codes layout above
+ VirtualKeys.VK_OEM_7, VirtualKeys.VK_1, VirtualKeys.VK_2, VirtualKeys.VK_3, VirtualKeys.VK_4,
+ VirtualKeys.VK_5, VirtualKeys.VK_6, VirtualKeys.VK_7, VirtualKeys.VK_8, VirtualKeys.VK_9,
+ VirtualKeys.VK_0, VirtualKeys.VK_OEM_4, VirtualKeys.VK_OEM_PLUS, VirtualKeys.VK_A, VirtualKeys.VK_Z,
+ VirtualKeys.VK_E, VirtualKeys.VK_R, VirtualKeys.VK_T, VirtualKeys.VK_Y, VirtualKeys.VK_U,
+ VirtualKeys.VK_I, VirtualKeys.VK_O, VirtualKeys.VK_P, VirtualKeys.VK_OEM_6, VirtualKeys.VK_OEM_1,
+ VirtualKeys.VK_Q, VirtualKeys.VK_S, VirtualKeys.VK_D, VirtualKeys.VK_F, VirtualKeys.VK_G,
+ VirtualKeys.VK_H, VirtualKeys.VK_J, VirtualKeys.VK_K, VirtualKeys.VK_L, VirtualKeys.VK_M,
+ VirtualKeys.VK_OEM_3, VirtualKeys.VK_OEM_5, VirtualKeys.VK_W, VirtualKeys.VK_X, VirtualKeys.VK_C,
+ VirtualKeys.VK_V, VirtualKeys.VK_B, VirtualKeys.VK_N, VirtualKeys.VK_OEM_COMMA, VirtualKeys.VK_OEM_PERIOD,
+ VirtualKeys.VK_OEM_2, VirtualKeys.VK_OEM_8,
+ VirtualKeys.VK_OEM_102 // the 102nd key (actually to the right of l-shift)
+ };
+
+ //// WRONG
+ private static readonly VirtualKeys [] main_key_vkey_qwertz_105 = new VirtualKeys []
+ {
+ // NOTE: this layout must concur with the scan codes layout above
+ VirtualKeys.VK_OEM_7, VirtualKeys.VK_1, VirtualKeys.VK_2, VirtualKeys.VK_3, VirtualKeys.VK_4,
+ VirtualKeys.VK_5, VirtualKeys.VK_6, VirtualKeys.VK_7, VirtualKeys.VK_8, VirtualKeys.VK_9,
+ VirtualKeys.VK_0, VirtualKeys.VK_OEM_4, VirtualKeys.VK_OEM_PLUS, VirtualKeys.VK_A, VirtualKeys.VK_Z,
+ VirtualKeys.VK_E, VirtualKeys.VK_R, VirtualKeys.VK_T, VirtualKeys.VK_Y, VirtualKeys.VK_U,
+ VirtualKeys.VK_I, VirtualKeys.VK_O, VirtualKeys.VK_P, VirtualKeys.VK_OEM_6, VirtualKeys.VK_OEM_1,
+ VirtualKeys.VK_Q, VirtualKeys.VK_S, VirtualKeys.VK_D, VirtualKeys.VK_F, VirtualKeys.VK_G,
+ VirtualKeys.VK_H, VirtualKeys.VK_J, VirtualKeys.VK_K, VirtualKeys.VK_L, VirtualKeys.VK_M,
+ VirtualKeys.VK_OEM_3, VirtualKeys.VK_OEM_5, VirtualKeys.VK_W, VirtualKeys.VK_X, VirtualKeys.VK_C,
+ VirtualKeys.VK_V, VirtualKeys.VK_B, VirtualKeys.VK_N, VirtualKeys.VK_OEM_COMMA, VirtualKeys.VK_OEM_PERIOD,
+ VirtualKeys.VK_OEM_2, VirtualKeys.VK_OEM_8,
+ VirtualKeys.VK_OEM_102 // the 102nd key (actually to the right of l-shift)
+ };
+
+ //// WRONG
+ private static readonly VirtualKeys [] main_key_vkey_qwerty_v2 = new VirtualKeys []
+ {
+ // NOTE: this layout must concur with the scan codes layout above
+ VirtualKeys.VK_OEM_7, VirtualKeys.VK_1, VirtualKeys.VK_2, VirtualKeys.VK_3, VirtualKeys.VK_4,
+ VirtualKeys.VK_5, VirtualKeys.VK_6, VirtualKeys.VK_7, VirtualKeys.VK_8, VirtualKeys.VK_9,
+ VirtualKeys.VK_0, VirtualKeys.VK_OEM_4, VirtualKeys.VK_OEM_PLUS, VirtualKeys.VK_A, VirtualKeys.VK_Z,
+ VirtualKeys.VK_E, VirtualKeys.VK_R, VirtualKeys.VK_T, VirtualKeys.VK_Y, VirtualKeys.VK_U,
+ VirtualKeys.VK_I, VirtualKeys.VK_O, VirtualKeys.VK_P, VirtualKeys.VK_OEM_6, VirtualKeys.VK_OEM_1,
+ VirtualKeys.VK_Q, VirtualKeys.VK_S, VirtualKeys.VK_D, VirtualKeys.VK_F, VirtualKeys.VK_G,
+ VirtualKeys.VK_H, VirtualKeys.VK_J, VirtualKeys.VK_K, VirtualKeys.VK_L, VirtualKeys.VK_M,
+ VirtualKeys.VK_OEM_3, VirtualKeys.VK_OEM_5, VirtualKeys.VK_W, VirtualKeys.VK_X, VirtualKeys.VK_C,
+ VirtualKeys.VK_V, VirtualKeys.VK_B, VirtualKeys.VK_N, VirtualKeys.VK_OEM_COMMA, VirtualKeys.VK_OEM_PERIOD,
+ VirtualKeys.VK_OEM_2, VirtualKeys.VK_OEM_8,
+ VirtualKeys.VK_OEM_102 // the 102nd key (actually to the right of l-shift)
+ };
+
+ //// WRONG
+ private static readonly VirtualKeys [] main_key_vkey_abnt_qwerty = new VirtualKeys []
+ {
+ // NOTE: this layout must concur with the scan codes layout above
+ VirtualKeys.VK_OEM_7, VirtualKeys.VK_1, VirtualKeys.VK_2, VirtualKeys.VK_3, VirtualKeys.VK_4,
+ VirtualKeys.VK_5, VirtualKeys.VK_6, VirtualKeys.VK_7, VirtualKeys.VK_8, VirtualKeys.VK_9,
+ VirtualKeys.VK_0, VirtualKeys.VK_OEM_4, VirtualKeys.VK_OEM_PLUS, VirtualKeys.VK_A, VirtualKeys.VK_Z,
+ VirtualKeys.VK_E, VirtualKeys.VK_R, VirtualKeys.VK_T, VirtualKeys.VK_Y, VirtualKeys.VK_U,
+ VirtualKeys.VK_I, VirtualKeys.VK_O, VirtualKeys.VK_P, VirtualKeys.VK_OEM_6, VirtualKeys.VK_OEM_1,
+ VirtualKeys.VK_Q, VirtualKeys.VK_S, VirtualKeys.VK_D, VirtualKeys.VK_F, VirtualKeys.VK_G,
+ VirtualKeys.VK_H, VirtualKeys.VK_J, VirtualKeys.VK_K, VirtualKeys.VK_L, VirtualKeys.VK_M,
+ VirtualKeys.VK_OEM_3, VirtualKeys.VK_OEM_5, VirtualKeys.VK_W, VirtualKeys.VK_X, VirtualKeys.VK_C,
+ VirtualKeys.VK_V, VirtualKeys.VK_B, VirtualKeys.VK_N, VirtualKeys.VK_OEM_COMMA, VirtualKeys.VK_OEM_PERIOD,
+ VirtualKeys.VK_OEM_2, VirtualKeys.VK_OEM_8,
+ VirtualKeys.VK_OEM_102 // the 102nd key (actually to the right of l-shift)
+ };
+ /*
+ private static readonly VirtualKeys [] main_key_vkey_qwerty_jp = new VirtualKeys []
+ {
+ VirtualKeys.VK_1, VirtualKeys.VK_2, VirtualKeys.VK_3, VirtualKeys.VK_4,
+ VirtualKeys.VK_5, VirtualKeys.VK_6, VirtualKeys.VK_7, VirtualKeys.VK_8, VirtualKeys.VK_9,
+ VirtualKeys.VK_0, VirtualKeys.VK_OEM_MINUS, VirtualKeys.VK_OEM_PLUS,VirtualKeys.VK_OEM_3,
+ VirtualKeys.VK_Q, VirtualKeys.VK_W, VirtualKeys.VK_E, VirtualKeys.VK_R, VirtualKeys.VK_T
+ VirtualKeys.VK_Y, VirtualKeys.VK_U, VirtualKeys.VK_I, VirtualKeys.VK_O, VirtualKeys.VK_P
+ VirtualKeys.VK_OEM_4,VirtualKeys.VK_OEM_6,
+ VirtualKeys.VK_A, VirtualKeys.VK_S, VirtualKeys.VK_D, VirtualKeys.VK_F,
+ VirtualKeys.VK_G, VirtualKeys.VK_H, VirtualKeys.VK_J, VirtualKeys.VK_K, VirtualKeys.VK_L,
+ VirtualKeys.VK_OEM_1, VirtualKeys.VK_OEM_7, VirtualKeys.VK_OEM_5, VirtualKeys.VK_Z,
+ VirtualKeys.VK_X, VirtualKeys.VK_C, VirtualKeys.VK_V, VirtualKeys.VK_B, VirtualKeys.VK_N,
+ VirtualKeys.VK_M, VirtualKeys.VK_OEM_COMMA, VirtualKeys.VK_OEM_PERIOD, VirtualKeys.VK_OEM_2,
+ VirtualKeys.VK_OEM_102
+ };*/
+
+ internal enum VirtualKeys {
+ VK_LBUTTON = 0x01,
+ VK_RBUTTON = 0x02,
+ VK_CANCEL = 0x03,
+ VK_MBUTTON = 0x04,
+ VK_XBUTTON1 = 0x05,
+ VK_XBUTTON2 = 0x06,
+ VK_BACK = 0x08,
+ VK_TAB = 0x09,
+ VK_CLEAR = 0x0C,
+ VK_RETURN = 0x0D,
+ VK_SHIFT = 0x10,
+ VK_CONTROL = 0x11,
+ VK_MENU = 0x12,
+ VK_PAUSE = 0x13,
+ VK_CAPITAL = 0x14,
+ VK_ESCAPE = 0x1B,
+ VK_SPACE = 0x20,
+ VK_PRIOR = 0x21,
+ VK_NEXT = 0x22,
+ VK_END = 0x23,
+ VK_HOME = 0x24,
+ VK_LEFT = 0x25,
+ VK_UP = 0x26,
+ VK_RIGHT = 0x27,
+ VK_DOWN = 0x28,
+ VK_SELECT = 0x29,
+ VK_PRINT = 0x2A,
+ VK_EXECUTE = 0x2B,
+ VK_SNAPSHOT = 0x2C,
+ VK_INSERT = 0x2D,
+ VK_DELETE = 0x2E,
+ VK_HELP = 0x2F,
+ VK_0 = 0x30,
+ VK_1 = 0x31,
+ VK_2 = 0x32,
+ VK_3 = 0x33,
+ VK_4 = 0x34,
+ VK_5 = 0x35,
+ VK_6 = 0x36,
+ VK_7 = 0x37,
+ VK_8 = 0x38,
+ VK_9 = 0x39,
+ VK_A = 0x41,
+ VK_B = 0x42,
+ VK_C = 0x43,
+ VK_D = 0x44,
+ VK_E = 0x45,
+ VK_F = 0x46,
+ VK_G = 0x47,
+ VK_H = 0x48,
+ VK_I = 0x49,
+ VK_J = 0x4A,
+ VK_K = 0x4B,
+ VK_L = 0x4C,
+ VK_M = 0x4D,
+ VK_N = 0x4E,
+ VK_O = 0x4F,
+ VK_P = 0x50,
+ VK_Q = 0x51,
+ VK_R = 0x52,
+ VK_S = 0x53,
+ VK_T = 0x54,
+ VK_U = 0x55,
+ VK_V = 0x56,
+ VK_W = 0x57,
+ VK_X = 0x58,
+ VK_Y = 0x59,
+ VK_Z = 0x5A,
+ VK_LWIN = 0x5B,
+ VK_RWIN = 0x5C,
+ VK_APPS = 0x5D,
+ VK_NUMPAD0 = 0x60,
+ VK_NUMPAD1 = 0x61,
+ VK_NUMPAD2 = 0x62,
+ VK_NUMPAD3 = 0x63,
+ VK_NUMPAD4 = 0x64,
+ VK_NUMPAD5 = 0x65,
+ VK_NUMPAD6 = 0x66,
+ VK_NUMPAD7 = 0x67,
+ VK_NUMPAD8 = 0x68,
+ VK_NUMPAD9 = 0x69,
+ VK_MULTIPLY = 0x6A,
+ VK_ADD = 0x6B,
+ VK_SEPARATOR = 0x6C,
+ VK_SUBTRACT = 0x6D,
+ VK_DECIMAL = 0x6E,
+ VK_DIVIDE = 0x6F,
+ VK_F1 = 0x70,
+ VK_F2 = 0x71,
+ VK_F3 = 0x72,
+ VK_F4 = 0x73,
+ VK_F5 = 0x74,
+ VK_F6 = 0x75,
+ VK_F7 = 0x76,
+ VK_F8 = 0x77,
+ VK_F9 = 0x78,
+ VK_F10 = 0x79,
+ VK_F11 = 0x7A,
+ VK_F12 = 0x7B,
+ VK_F13 = 0x7C,
+ VK_F14 = 0x7D,
+ VK_F15 = 0x7E,
+ VK_F16 = 0x7F,
+ VK_F17 = 0x80,
+ VK_F18 = 0x81,
+ VK_F19 = 0x82,
+ VK_F20 = 0x83,
+ VK_F21 = 0x84,
+ VK_F22 = 0x85,
+ VK_F23 = 0x86,
+ VK_F24 = 0x87,
+ VK_NUMLOCK = 0x90,
+ VK_SCROLL = 0x91,
+ VK_LSHIFT = 0xA0,
+ VK_RSHIFT = 0xA1,
+ VK_LCONTROL = 0xA2,
+ VK_RCONTROL = 0xA3,
+ VK_LMENU = 0xA4,
+ VK_RMENU = 0xA5,
+ VK_OEM_1 = 0xBA,
+ VK_OEM_PLUS = 0xBB,
+ VK_OEM_COMMA = 0xBC,
+ VK_OEM_MINUS = 0xBD,
+ VK_OEM_PERIOD = 0xBE,
+ VK_OEM_2 = 0xBF,
+ VK_OEM_3 = 0xC0,
+ VK_OEM_4 = 0xDB,
+ VK_OEM_5 = 0xDC,
+ VK_OEM_6 = 0xDD,
+ VK_OEM_7 = 0xDE,
+ VK_OEM_8 = 0xDF,
+ VK_OEM_AX = 0xE1,
+ VK_OEM_102 = 0xE2,
+ VK_ICO_HELP = 0xE3,
+ VK_ICO_00 = 0xE4,
+ VK_PROCESSKEY = 0xE5,
+ VK_ATTN = 0xF6,
+ VK_CRSEL = 0xF7,
+ VK_EXSEL = 0xF8,
+ VK_EREOF = 0xF9,
+ VK_PLAY = 0xFA,
+ VK_ZOOM = 0xFB,
+ VK_NONAME = 0xFC,
+ VK_PA1 = 0xFD,
+ VK_OEM_CLEAR = 0xFE,
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/resources/keyboards.resources.prebuilt b/mcs/class/Managed.Windows.Forms/resources/keyboards.resources.prebuilt
new file mode 100644
index 00000000000..6f999ecce99
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/resources/keyboards.resources.prebuilt
Binary files differ
diff --git a/mcs/class/Managed.Windows.Forms/resources/keyboards.resx b/mcs/class/Managed.Windows.Forms/resources/keyboards.resx
new file mode 100644
index 00000000000..5c39b5f3af7
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/resources/keyboards.resx
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+<resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader><resheader name="version">
+ <value>1.3</value>
+ </resheader><resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader><resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader><data name="keyboard_table" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>AAEAAAD/////AQAAAAAAAAAMAgAAAFpTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0xLjAuNTAwMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkHAQAAAAABAAAAQAAAAAQjU3lzdGVtLldpbmRvd3MuRm9ybXMuS2V5Ym9hcmRMYXlvdXQCAAAACQMAAAAJBAAAAAkFAAAACQYAAAAJBwAAAAkIAAAACQkAAAAJCgAAAAkLAAAACQwAAAAJDQAAAAkOAAAACQ8AAAAJEAAAAAkRAAAACRIAAAAJEwAAAAkUAAAACRUAAAAJFgAAAAkXAAAACRgAAAAJGQAAAAkaAAAACRsAAAAJHAAAAAkdAAAACR4AAAAJHwAAAAkgAAAACSEAAAAJIgAAAAkjAAAACSQAAAAJJQAAAAkmAAAACScAAAAJKAAAAAkpAAAACSoAAAAJKwAAAAksAAAACS0AAAAJLgAAAAkvAAAACTAAAAAJMQAAAAkyAAAACTMAAAAJNAAAAAk1AAAACTYAAAAJNwAAAAk4AAAACTkAAAAJOgAAAAk7AAAACTwAAAAJPQAAAAk+AAAACT8AAAAJQAAAAAlBAAAACUIAAAAFAwAAACNTeXN0ZW0uV2luZG93cy5Gb3Jtcy5LZXlib2FyZExheW91dAUAAAAETGNpZAROYW1lCVNjYW5JbmRleAlWS2V5SW5kZXgES2V5cwABBAQDCCNTeXN0ZW0uV2luZG93cy5Gb3Jtcy5TY2FuVGFibGVJbmRleAIAAAAjU3lzdGVtLldpbmRvd3MuRm9ybXMuVktleVRhYmxlSW5kZXgCAAAAEVN5c3RlbS5VSW50MzJbXVtdAgAAAAkEAAAGQwAAAB1Vbml0ZWQgU3RhdGVzIGtleWJvYXJkIGxheW91dAVEAAAAI1N5c3RlbS5XaW5kb3dzLkZvcm1zLlNjYW5UYWJsZUluZGV4AQAAAAd2YWx1ZV9fAAgCAAAAAAAAAAVFAAAAI1N5c3RlbS5XaW5kb3dzLkZvcm1zLlZLZXlUYWJsZUluZGV4AQAAAAd2YWx1ZV9fAAgCAAAAAAAAAAlGAAAAAQQAAAADAAAACQQAAAZHAAAAM1VuaXRlZCBTdGF0ZXMga2V5Ym9hcmQgbGF5b3V0IChwaGFudG9tIGtleSB2ZXJzaW9uKQFIAAAARAAAAAAAAAABSQAAAEUAAAAAAAAACUoAAAABBQAAAAMAAAAJBAAABksAAAAmVW5pdGVkIFN0YXRlcyBrZXlib2FyZCBsYXlvdXQgKGR2b3JhaykBTAAAAEQAAAABAAAAAU0AAABFAAAAAgAAAAlOAAAAAQYAAAADAAAACQQAAAZPAAAAK1VuaXRlZCBTdGF0ZXMgSW50ZXJuYXRpb25hbCBrZXlib2FyZCBsYXlvdXQBUAAAAEQAAAAAAAAAAVEAAABFAAAAAAAAAAlSAAAAAQcAAAADAAAACQgAAAZTAAAAF0JyaXRpc2gga2V5Ym9hcmQgbGF5b3V0AVQAAABEAAAAAAAAAAFVAAAARQAAAAAAAAAJVgAAAAEIAAAAAwAAAAcEAAAGVwAAABZHZXJtYW4ga2V5Ym9hcmQgbGF5b3V0AVgAAABEAAAAAAAAAAFZAAAARQAAAAEAAAAJWgAAAAEJAAAAAwAAAAcEAAAGWwAAAChHZXJtYW4ga2V5Ym9hcmQgbGF5b3V0IHdpdGhvdXQgZGVhZCBrZXlzAVwAAABEAAAAAAAAAAFdAAAARQAAAAEAAAAJXgAAAAEKAAAAAwAAAAcEAAAGXwAAAC9HZXJtYW4ga2V5Ym9hcmQgbGF5b3V0IGZvciBsb2dpdGVjaCBkZXNrdG9wIHBybwFgAAAARAAAAAAAAAABYQAAAEUAAAABAAAACWIAAAABCwAAAAMAAAAHBAAABmMAAAAsR2VybWFuIGtleWJvYXJkIGxheW91dCB3aXRob3V0IGRlYWQga2V5cyAxMDUBZAAAAEQAAAAAAAAAAWUAAABFAAAAAwAAAAlmAAAAAQwAAAADAAAABwgAAAZnAAAAHFN3aXNzIEdlcm1hbiBrZXlib2FyZCBsYXlvdXQBaAAAAEQAAAAAAAAAAWkAAABFAAAAAQAAAAlqAAAAAQ0AAAADAAAADBAAAAZrAAAAHFN3aXNzIEZyZW5jaCBrZXlib2FyZCBsYXlvdXQBbAAAAEQAAAAAAAAAAW0AAABFAAAAAQAAAAluAAAAAQ4AAAADAAAAHQQAAAZvAAAAF1N3ZWRpc2gga2V5Ym9hcmQgbGF5b3V0AXAAAABEAAAAAAAAAAFxAAAARQAAAAUAAAAJcgAAAAEPAAAAAwAAACUEAAAGcwAAABhFc3RvbmlhbiBrZXlib2FyZCBsYXlvdXQBdAAAAEQAAAAAAAAAAXUAAABFAAAAAAAAAAl2AAAAARAAAAADAAAAFAQAAAZ3AAAAGU5vcndlZ2lhbiBrZXlib2FyZCBsYXlvdXQBeAAAAEQAAAAAAAAAAXkAAABFAAAAAAAAAAl6AAAAAREAAAADAAAABgQAAAZ7AAAAFkRhbmlzaCBrZXlib2FyZCBsYXlvdXQBfAAAAEQAAAAAAAAAAX0AAABFAAAAAAAAAAl+AAAAARIAAAADAAAADAQAAAZ/AAAAFkZyZW5jaCBrZXlib2FyZCBsYXlvdXQBgAAAAEQAAAAAAAAAAYEAAABFAAAABAAAAAmCAAAAARMAAAADAAAADAwAAAaDAAAAH0NhbmFkaWFuIEZyZW5jaCBrZXlib2FyZCBsYXlvdXQBhAAAAEQAAAAAAAAAAYUAAABFAAAAAAAAAAmGAAAAARQAAAADAAAADAwAAAaHAAAAJ0NhbmFkaWFuIEZyZW5jaCBrZXlib2FyZCBsYXlvdXQgKENBX2ZyKQGIAAAARAAAAAAAAAABiQAAAEUAAAAAAAAACYoAAAABFQAAAAMAAAAMDAAABosAAAAYQ2FuYWRpYW4ga2V5Ym9hcmQgbGF5b3V0AYwAAABEAAAAAAAAAAGNAAAARQAAAAAAAAAJjgAAAAEWAAAAAwAAAAwIAAAGjwAAABdCZWxnaWFuIGtleWJvYXJkIGxheW91dAGQAAAARAAAAAAAAAABkQAAAEUAAAAEAAAACZIAAAABFwAAAAMAAAAWCAAABpMAAAAaUG9ydHVndWVzZSBrZXlib2FyZCBsYXlvdXQBlAAAAEQAAAAAAAAAAZUAAABFAAAAAAAAAAmWAAAAARgAAAADAAAAFgQAAAaXAAAAIEJyYXppbGlhbiBBQk5ULTIga2V5Ym9hcmQgbGF5b3V0AZgAAABEAAAAAgAAAAGZAAAARQAAAAYAAAAJmgAAAAEZAAAAAwAAABYEAAAGmwAAACdCcmF6aWxpYW4gQUJOVC0yIGtleWJvYXJkIGxheW91dCBBTFQgR1IBnAAAAEQAAAACAAAAAZ0AAABFAAAABgAAAAmeAAAAARoAAAADAAAACwQAAAafAAAAF0Zpbm5pc2gga2V5Ym9hcmQgbGF5b3V0AaAAAABEAAAAAAAAAAGhAAAARQAAAAAAAAAJogAAAAEbAAAAAwAAAAIEAAAGowAAAB1CdWxnYXJpYW4gYmRzIGtleWJvYXJkIGxheW91dAGkAAAARAAAAAAAAAABpQAAAEUAAAAAAAAACaYAAAABHAAAAAMAAAACBAAABqcAAAAiQnVsZ2FyaWFuIHBob25ldGljIGtleWJvYXJkIGxheW91dAGoAAAARAAAAAAAAAABqQAAAEUAAAAAAAAACaoAAAABHQAAAAMAAAAjBAAABqsAAAAaQmVsYXJ1c2lhbiBrZXlib2FyZCBsYXlvdXQBrAAAAEQAAAAAAAAAAa0AAABFAAAAAAAAAAmuAAAAAR4AAAADAAAAGQQAAAavAAAAF1J1c3NpYW4ga2V5Ym9hcmQgbGF5b3V0AbAAAABEAAAAAAAAAAGxAAAARQAAAAAAAAAJsgAAAAEfAAAAAwAAABkEAAAGswAAAC1SdXNzaWFuIGtleWJvYXJkIGxheW91dCAocGhhbnRvbSBrZXkgdmVyc2lvbikBtAAAAEQAAAAAAAAAAbUAAABFAAAAAAAAAAm2AAAAASAAAAADAAAAGQQAAAa3AAAAHlJ1c3NpYW4ga2V5Ym9hcmQgbGF5b3V0IEtPSTgtUgG4AAAARAAAAAAAAAABuQAAAEUAAAAAAAAACboAAAABIQAAAAMAAAAZBAAABrsAAAAeUnVzc2lhbiBrZXlib2FyZCBsYXlvdXQgY3AxMjUxAbwAAABEAAAAAAAAAAG9AAAARQAAAAAAAAAJvgAAAAEiAAAAAwAAABkEAAAGvwAAACBSdXNzaWFuIHBob25ldGljIGtleWJvYXJkIGxheW91dAHAAAAARAAAAAAAAAABwQAAAEUAAAAAAAAACcIAAAABIwAAAAMAAAAiBAAABsMAAAAgVWtyYWluaWFuIGtleWJvYXJkIGxheW91dCBLT0k4LVUBxAAAAEQAAAAAAAAAAcUAAABFAAAAAAAAAAnGAAAAASQAAAADAAAAIgQAAAbHAAAAJFVrcmFpbmlhbiBrZXlib2FyZCBsYXlvdXQgKHN0YW5kYXJkKQHIAAAARAAAAAAAAAAByQAAAEUAAAAAAAAACcoAAAABJQAAAAMAAAAZBAAABssAAAAiUnVzc2lhbiBrZXlib2FyZCBsYXlvdXQgKHN0YW5kYXJkKQHMAAAARAAAAAAAAAABzQAAAEUAAAAAAAAACc4AAAABJgAAAAMAAAAKBAAABs8AAAAXU3BhbmlzaCBrZXlib2FyZCBsYXlvdXQB0AAAAEQAAAAAAAAAAdEAAABFAAAAAAAAAAnSAAAAAScAAAADAAAAEAQAAAbTAAAAF0l0YWxpYW4ga2V5Ym9hcmQgbGF5b3V0AdQAAABEAAAAAAAAAAHVAAAARQAAAAAAAAAJ1gAAAAEoAAAAAwAAAA8EAAAG1wAAABlJY2VsYW5kaWMga2V5Ym9hcmQgbGF5b3V0AdgAAABEAAAAAAAAAAHZAAAARQAAAAAAAAAJ2gAAAAEpAAAAAwAAAA4EAAAG2wAAABlIdW5nYXJpYW4ga2V5Ym9hcmQgbGF5b3V0AdwAAABEAAAAAAAAAAHdAAAARQAAAAEAAAAJ3gAAAAEqAAAAAwAAABUEAAAG3wAAACVQb2xpc2ggKHByb2dyYW1tZXIncykga2V5Ym9hcmQgbGF5b3V0AeAAAABEAAAAAAAAAAHhAAAARQAAAAAAAAAJ4gAAAAErAAAAAwAAACQEAAAG4wAAABlTbG92ZW5pYW4ga2V5Ym9hcmQgbGF5b3V0AeQAAABEAAAAAAAAAAHlAAAARQAAAAEAAAAJ5gAAAAEsAAAAAwAAABoMAAAG5wAAABpTZXJiaWFuIGtleWJvYXJkIGxheW91dCBzcgHoAAAARAAAAAAAAAAB6QAAAEUAAAAAAAAACeoAAAABLQAAAAMAAAAaDAAABusAAAAdU2VyYmlhbiBrZXlib2FyZCBsYXlvdXQgdXMsc3IB7AAAAEQAAAAAAAAAAe0AAABFAAAAAAAAAAnuAAAAAS4AAAADAAAAGgQAAAbvAAAAGENyb2F0aWFuIGtleWJvYXJkIGxheW91dAHwAAAARAAAAAAAAAAB8QAAAEUAAAABAAAACfIAAAABLwAAAAMAAAAaBAAABvMAAAAjQ3JvYXRpYW4ga2V5Ym9hcmQgbGF5b3V0IChzcGVjaWZpYykB9AAAAEQAAAAAAAAAAfUAAABFAAAAAAAAAAn2AAAAATAAAAADAAAAEQQAAAb3AAAAHEphcGFuZXNlIDEwNiBrZXlib2FyZCBsYXlvdXQB+AAAAEQAAAADAAAAAfkAAABFAAAABwAAAAn6AAAAATEAAAADAAAAEQQAAAb7AAAAH0phcGFuZXNlIHBjOTh4MSBrZXlib2FyZCBsYXlvdXQB/AAAAEQAAAAAAAAAAf0AAABFAAAAAAAAAAn+AAAAATIAAAADAAAAGwQAAAb/AAAAFlNsb3ZhayBrZXlib2FyZCBsYXlvdXQBAAEAAEQAAAAAAAAAAQEBAABFAAAAAAAAAAkCAQAAATMAAAADAAAAGwQAAAYDAQAAMlNsb3ZhayBhbmQgQ3plY2gga2V5Ym9hcmQgbGF5b3V0IHdpdGhvdXQgZGVhZCBrZXlzAQQBAABEAAAAAAAAAAEFAQAARQAAAAAAAAAJBgEAAAE0AAAAAwAAAAUEAAAGBwEAABVDemVjaCBrZXlib2FyZCBsYXlvdXQBCAEAAEQAAAAAAAAAAQkBAABFAAAAAAAAAAkKAQAAATUAAAADAAAABQQAAAYLAQAAGEN6ZWNoIGtleWJvYXJkIGxheW91dCBjegEMAQAARAAAAAAAAAABDQEAAEUAAAABAAAACQ4BAAABNgAAAAMAAAAFBAAABg8BAAAfQ3plY2gga2V5Ym9hcmQgbGF5b3V0IGN6X3F3ZXJ0eQEQAQAARAAAAAAAAAABEQEAAEUAAAAAAAAACRIBAAABNwAAAAMAAAAKBAAABhMBAAAeTGF0aW4gQW1lcmljYW4ga2V5Ym9hcmQgbGF5b3V0ARQBAABEAAAAAAAAAAEVAQAARQAAAAAAAAAJFgEAAAE4AAAAAwAAACcEAAAGFwEAACNMaXRodWFuaWFuIChCYWx0aWMpIGtleWJvYXJkIGxheW91dAEYAQAARAAAAAAAAAABGQEAAEUAAAAAAAAACRoBAAABOQAAAAMAAAAfBAAABhsBAAAXVHVya2lzaCBrZXlib2FyZCBsYXlvdXQBHAEAAEQAAAAAAAAAAR0BAABFAAAAAAAAAAkeAQAAAToAAAADAAAAHwQAAAYfAQAAGlR1cmtpc2gga2V5Ym9hcmQgbGF5b3V0IHRyASABAABEAAAAAAAAAAEhAQAARQAAAAAAAAAJIgEAAAE7AAAAAwAAAB8EAAAGIwEAABtUdXJraXNoIGtleWJvYXJkIGxheW91dCB0cmYBJAEAAEQAAAAAAAAAASUBAABFAAAAAAAAAAkmAQAAATwAAAADAAAADQQAAAYnAQAAGUlzcmFlbGlhbiBrZXlib2FyZCBsYXlvdXQBKAEAAEQAAAAAAAAAASkBAABFAAAAAAAAAAkqAQAAAT0AAAADAAAADQQAAAYrAQAAIklzcmFlbGlhbiBwaG9uZXRpYyBrZXlib2FyZCBsYXlvdXQBLAEAAEQAAAAAAAAAAS0BAABFAAAAAAAAAAkuAQAAAT4AAAADAAAADQQAAAYvAQAAIUlzcmFlbGlhbiBTYWhhcm9uIGtleWJvYXJkIGxheW91dAEwAQAARAAAAAAAAAABMQEAAEUAAAAAAAAACTIBAAABPwAAAAMAAAAJBAAABjMBAAATVk5DIGtleWJvYXJkIGxheW91dAE0AQAARAAAAAQAAAABNQEAAEUAAAAIAAAACTYBAAABQAAAAAMAAAAIBAAABjcBAAAVR3JlZWsga2V5Ym9hcmQgbGF5b3V0ATgBAABEAAAAAAAAAAE5AQAARQAAAAAAAAAJOgEAAAFBAAAAAwAAAB4EAAAGOwEAACBUaGFpIChLZWRtYW5lZSkgIGtleWJvYXJkIGxheW91dAE8AQAARAAAAAAAAAABPQEAAEUAAAAAAAAACT4BAAABQgAAAAMAAAATBAAABj8BAAAVRHV0Y2gga2V5Ym9hcmQgbGF5b3V0AUABAABEAAAAAAAAAAFBAQAARQAAAAAAAAAJQgEAAAdGAAAAAQEAAAAxAAAABw8JQwEAAAlEAQAACUUBAAAJRgEAAAlHAQAACUgBAAAJSQEAAAlKAQAACUsBAAAJTAEAAAlNAQAACU4BAAAJTwEAAAlQAQAACVEBAAAJUgEAAAlTAQAACVQBAAAJVQEAAAlWAQAACVcBAAAJWAEAAAlZAQAACVoBAAAJWwEAAAlcAQAACV0BAAAJXgEAAAlfAQAACWABAAAJYQEAAAliAQAACWMBAAAJZAEAAAllAQAACWYBAAAJZwEAAAloAQAACWkBAAAJagEAAAlrAQAACWwBAAAJbQEAAAluAQAACW8BAAAJcAEAAAlxAQAACXIBAAAJcwEAAAdKAAAAAQEAAAAxAAAABw8JdAEAAAl1AQAACXYBAAAJdwEAAAl4AQAACXkBAAAJegEAAAl7AQAACXwBAAAJfQEAAAl+AQAACX8BAAAJgAEAAAmBAQAACYIBAAAJgwEAAAmEAQAACYUBAAAJhgEAAAmHAQAACYgBAAAJiQEAAAmKAQAACYsBAAAJjAEAAAmNAQAACY4BAAAJjwEAAAmQAQAACZEBAAAJkgEAAAmTAQAACZQBAAAJlQEAAAmWAQAACZcBAAAJmAEAAAmZAQAACZoBAAAJmwEAAAmcAQAACZ0BAAAJngEAAAmfAQAACaABAAAJoQEAAAmiAQAACaMBAAAJpAEAAAdOAAAAAQEAAAAxAAAABw8JpQEAAAmmAQAACacBAAAJqAEAAAmpAQAACaoBAAAJqwEAAAmsAQAACa0BAAAJrgEAAAmvAQAACbABAAAJsQEAAAmyAQAACbMBAAAJtAEAAAm1AQAACbYBAAAJtwEAAAm4AQAACbkBAAAJugEAAAm7AQAACbwBAAAJvQEAAAm+AQAACb8BAAAJwAEAAAnBAQAACcIBAAAJwwEAAAnEAQAACcUBAAAJxgEAAAnHAQAACcgBAAAJyQEAAAnKAQAACcsBAAAJzAEAAAnNAQAACc4BAAAJzwEAAAnQAQAACdEBAAAJ0gEAAAnTAQAACdQBAAAJ1QEAAAdSAAAAAQEAAAAxAAAABw8J1gEAAAnXAQAACdgBAAAJ2QEAAAnaAQAACdsBAAAJ3AEAAAndAQAACd4BAAAJ3wEAAAngAQAACeEBAAAJ4gEAAAnjAQAACeQBAAAJ5QEAAAnmAQAACecBAAAJ6AEAAAnpAQAACeoBAAAJ6wEAAAnsAQAACe0BAAAJ7gEAAAnvAQAACfABAAAJ8QEAAAnyAQAACfMBAAAJ9AEAAAn1AQAACfYBAAAJ9wEAAAn4AQAACfkBAAAJ+gEAAAn7AQAACfwBAAAJ/QEAAAn+AQAACf8BAAAJAAIAAAkBAgAACQICAAAJAwIAAAkEAgAACQUCAAAJBgIAAAdWAAAAAQEAAAAxAAAABw8JBwIAAAkIAgAACQkCAAAJCgIAAAkLAgAACQwCAAAJDQIAAAkOAgAACQ8CAAAJEAIAAAkRAgAACRICAAAJEwIAAAkUAgAACRUCAAAJFgIAAAkXAgAACRgCAAAJGQIAAAkaAgAACRsCAAAJHAIAAAkdAgAACR4CAAAJHwIAAAkgAgAACSECAAAJIgIAAAkjAgAACSQCAAAJJQIAAAkmAgAACScCAAAJKAIAAAkpAgAACSoCAAAJKwIAAAksAgAACS0CAAAJLgIAAAkvAgAACTACAAAJMQIAAAkyAgAACTMCAAAJNAIAAAk1AgAACTYCAAAJNwIAAAdaAAAAAQEAAAAxAAAABw8JOAIAAAk5AgAACToCAAAJOwIAAAk8AgAACT0CAAAJPgIAAAk/AgAACUACAAAJQQIAAAlCAgAACUMCAAAJRAIAAAlFAgAACUYCAAAJRwIAAAlIAgAACUkCAAAJSgIAAAlLAgAACUwCAAAJTQIAAAlOAgAACU8CAAAJUAIAAAlRAgAACVICAAAJUwIAAAlUAgAACVUCAAAJVgIAAAlXAgAACVgCAAAJWQIAAAlaAgAACVsCAAAJXAIAAAldAgAACV4CAAAJXwIAAAlgAgAACWECAAAJYgIAAAljAgAACWQCAAAJZQIAAAlmAgAACWcCAAAJaAIAAAdeAAAAAQEAAAAxAAAABw8JaQIAAAlqAgAACWsCAAAJbAIAAAltAgAACW4CAAAJbwIAAAlwAgAACXECAAAJcgIAAAlzAgAACXQCAAAJdQIAAAl2AgAACXcCAAAJeAIAAAl5AgAACXoCAAAJewIAAAl8AgAACX0CAAAJfgIAAAl/AgAACYACAAAJgQIAAAmCAgAACYMCAAAJhAIAAAmFAgAACYYCAAAJhwIAAAmIAgAACYkCAAAJigIAAAmLAgAACYwCAAAJjQIAAAmOAgAACY8CAAAJkAIAAAmRAgAACZICAAAJkwIAAAmUAgAACZUCAAAJlgIAAAmXAgAACZgCAAAJmQIAAAdiAAAAAQEAAAAxAAAABw8JmgIAAAmbAgAACZwCAAAJnQIAAAmeAgAACZ8CAAAJoAIAAAmhAgAACaICAAAJowIAAAmkAgAACaUCAAAJpgIAAAmnAgAACagCAAAJqQIAAAmqAgAACasCAAAJrAIAAAmtAgAACa4CAAAJrwIAAAmwAgAACbECAAAJsgIAAAmzAgAACbQCAAAJtQIAAAm2AgAACbcCAAAJuAIAAAm5AgAACboCAAAJuwIAAAm8AgAACb0CAAAJvgIAAAm/AgAACcACAAAJwQIAAAnCAgAACcMCAAAJxAIAAAnFAgAACcYCAAAJxwIAAAnIAgAACckCAAAJygIAAAdmAAAAAQEAAAAxAAAABw8JywIAAAnMAgAACc0CAAAJzgIAAAnPAgAACdACAAAJ0QIAAAnSAgAACdMCAAAJ1AIAAAnVAgAACdYCAAAJ1wIAAAnYAgAACdkCAAAJ2gIAAAnbAgAACdwCAAAJ3QIAAAneAgAACd8CAAAJ4AIAAAnhAgAACeICAAAJ4wIAAAnkAgAACeUCAAAJ5gIAAAnnAgAACegCAAAJ6QIAAAnqAgAACesCAAAJ7AIAAAntAgAACe4CAAAJ7wIAAAnwAgAACfECAAAJ8gIAAAnzAgAACfQCAAAJ9QIAAAn2AgAACfcCAAAJ+AIAAAn5AgAACfoCAAAJ+wIAAAdqAAAAAQEAAAAxAAAABw8J/AIAAAn9AgAACf4CAAAJ/wIAAAkAAwAACQEDAAAJAgMAAAkDAwAACQQDAAAJBQMAAAkGAwAACQcDAAAJCAMAAAkJAwAACQoDAAAJCwMAAAkMAwAACQ0DAAAJDgMAAAkPAwAACRADAAAJEQMAAAkSAwAACRMDAAAJFAMAAAkVAwAACRYDAAAJFwMAAAkYAwAACRkDAAAJGgMAAAkbAwAACRwDAAAJHQMAAAkeAwAACR8DAAAJIAMAAAkhAwAACSIDAAAJIwMAAAkkAwAACSUDAAAJJgMAAAknAwAACSgDAAAJKQMAAAkqAwAACSsDAAAJLAMAAAduAAAAAQEAAAAxAAAABw8JLQMAAAkuAwAACS8DAAAJMAMAAAkxAwAACTIDAAAJMwMAAAk0AwAACTUDAAAJNgMAAAk3AwAACTgDAAAJOQMAAAk6AwAACTsDAAAJPAMAAAk9AwAACT4DAAAJPwMAAAlAAwAACUEDAAAJQgMAAAlDAwAACUQDAAAJRQMAAAlGAwAACUcDAAAJSAMAAAlJAwAACUoDAAAJSwMAAAlMAwAACU0DAAAJTgMAAAlPAwAACVADAAAJUQMAAAlSAwAACVMDAAAJVAMAAAlVAwAACVYDAAAJVwMAAAlYAwAACVkDAAAJWgMAAAlbAwAACVwDAAAJXQMAAAdyAAAAAQEAAAAxAAAABw8JXgMAAAlfAwAACWADAAAJYQMAAAliAwAACWMDAAAJZAMAAAllAwAACWYDAAAJZwMAAAloAwAACWkDAAAJagMAAAlrAwAACWwDAAAJbQMAAAluAwAACW8DAAAJcAMAAAlxAwAACXIDAAAJcwMAAAl0AwAACXUDAAAJdgMAAAl3AwAACXgDAAAJeQMAAAl6AwAACXsDAAAJfAMAAAl9AwAACX4DAAAJfwMAAAmAAwAACYEDAAAJggMAAAmDAwAACYQDAAAJhQMAAAmGAwAACYcDAAAJiAMAAAmJAwAACYoDAAAJiwMAAAmMAwAACY0DAAAJjgMAAAd2AAAAAQEAAAAxAAAABw8JjwMAAAmQAwAACZEDAAAJkgMAAAmTAwAACZQDAAAJlQMAAAmWAwAACZcDAAAJmAMAAAmZAwAACZoDAAAJmwMAAAmcAwAACZ0DAAAJngMAAAmfAwAACaADAAAJoQMAAAmiAwAACaMDAAAJpAMAAAmlAwAACaYDAAAJpwMAAAmoAwAACakDAAAJqgMAAAmrAwAACawDAAAJrQMAAAmuAwAACa8DAAAJsAMAAAmxAwAACbIDAAAJswMAAAm0AwAACbUDAAAJtgMAAAm3AwAACbgDAAAJuQMAAAm6AwAACbsDAAAJvAMAAAm9AwAACb4DAAAJvwMAAAd6AAAAAQEAAAAxAAAABw8JwAMAAAnBAwAACcIDAAAJwwMAAAnEAwAACcUDAAAJxgMAAAnHAwAACcgDAAAJyQMAAAnKAwAACcsDAAAJzAMAAAnNAwAACc4DAAAJzwMAAAnQAwAACdEDAAAJ0gMAAAnTAwAACdQDAAAJ1QMAAAnWAwAACdcDAAAJ2AMAAAnZAwAACdoDAAAJ2wMAAAncAwAACd0DAAAJ3gMAAAnfAwAACeADAAAJ4QMAAAniAwAACeMDAAAJ5AMAAAnlAwAACeYDAAAJ5wMAAAnoAwAACekDAAAJ6gMAAAnrAwAACewDAAAJ7QMAAAnuAwAACe8DAAAJ8AMAAAd+AAAAAQEAAAAxAAAABw8J8QMAAAnyAwAACfMDAAAJ9AMAAAn1AwAACfYDAAAJ9wMAAAn4AwAACfkDAAAJ+gMAAAn7AwAACfwDAAAJ/QMAAAn+AwAACf8DAAAJAAQAAAkBBAAACQIEAAAJAwQAAAkEBAAACQUEAAAJBgQAAAkHBAAACQgEAAAJCQQAAAkKBAAACQsEAAAJDAQAAAkNBAAACQ4EAAAJDwQAAAkQBAAACREEAAAJEgQAAAkTBAAACRQEAAAJFQQAAAkWBAAACRcEAAAJGAQAAAkZBAAACRoEAAAJGwQAAAkcBAAACR0EAAAJHgQAAAkfBAAACSAEAAAJIQQAAAeCAAAAAQEAAAAxAAAABw8JIgQAAAkjBAAACSQEAAAJJQQAAAkmBAAACScEAAAJKAQAAAkpBAAACSoEAAAJKwQAAAksBAAACS0EAAAJLgQAAAkvBAAACTAEAAAJMQQAAAkyBAAACTMEAAAJNAQAAAk1BAAACTYEAAAJNwQAAAk4BAAACTkEAAAJOgQAAAk7BAAACTwEAAAJPQQAAAk+BAAACT8EAAAJQAQAAAlBBAAACUIEAAAJQwQAAAlEBAAACUUEAAAJRgQAAAlHBAAACUgEAAAJSQQAAAlKBAAACUsEAAAJTAQAAAlNBAAACU4EAAAJTwQAAAlQBAAACVEEAAAJUgQAAAeGAAAAAQEAAAAxAAAABw8JUwQAAAlUBAAACVUEAAAJVgQAAAlXBAAACVgEAAAJWQQAAAlaBAAACVsEAAAJXAQAAAldBAAACV4EAAAJXwQAAAlgBAAACWEEAAAJYgQAAAljBAAACWQEAAAJZQQAAAlmBAAACWcEAAAJaAQAAAlpBAAACWoEAAAJawQAAAlsBAAACW0EAAAJbgQAAAlvBAAACXAEAAAJcQQAAAlyBAAACXMEAAAJdAQAAAl1BAAACXYEAAAJdwQAAAl4BAAACXkEAAAJegQAAAl7BAAACXwEAAAJfQQAAAl+BAAACX8EAAAJgAQAAAmBBAAACYIEAAAJgwQAAAeKAAAAAQEAAAAxAAAABw8JhAQAAAmFBAAACYYEAAAJhwQAAAmIBAAACYkEAAAJigQAAAmLBAAACYwEAAAJjQQAAAmOBAAACY8EAAAJkAQAAAmRBAAACZIEAAAJkwQAAAmUBAAACZUEAAAJlgQAAAmXBAAACZgEAAAJmQQAAAmaBAAACZsEAAAJnAQAAAmdBAAACZ4EAAAJnwQAAAmgBAAACaEEAAAJogQAAAmjBAAACaQEAAAJpQQAAAmmBAAACacEAAAJqAQAAAmpBAAACaoEAAAJqwQAAAmsBAAACa0EAAAJrgQAAAmvBAAACbAEAAAJsQQAAAmyBAAACbMEAAAJtAQAAAeOAAAAAQEAAAAxAAAABw8JtQQAAAm2BAAACbcEAAAJuAQAAAm5BAAACboEAAAJuwQAAAm8BAAACb0EAAAJvgQAAAm/BAAACcAEAAAJwQQAAAnCBAAACcMEAAAJxAQAAAnFBAAACcYEAAAJxwQAAAnIBAAACckEAAAJygQAAAnLBAAACcwEAAAJzQQAAAnOBAAACc8EAAAJ0AQAAAnRBAAACdIEAAAJ0wQAAAnUBAAACdUEAAAJ1gQAAAnXBAAACdgEAAAJ2QQAAAnaBAAACdsEAAAJ3AQAAAndBAAACd4EAAAJ3wQAAAngBAAACeEEAAAJ4gQAAAnjBAAACeQEAAAJ5QQAAAeSAAAAAQEAAAAxAAAABw8J5gQAAAnnBAAACegEAAAJ6QQAAAnqBAAACesEAAAJ7AQAAAntBAAACe4EAAAJ7wQAAAnwBAAACfEEAAAJ8gQAAAnzBAAACfQEAAAJ9QQAAAn2BAAACfcEAAAJ+AQAAAn5BAAACfoEAAAJ+wQAAAn8BAAACf0EAAAJ/gQAAAn/BAAACQAFAAAJAQUAAAkCBQAACQMFAAAJBAUAAAkFBQAACQYFAAAJBwUAAAkIBQAACQkFAAAJCgUAAAkLBQAACQwFAAAJDQUAAAkOBQAACQ8FAAAJEAUAAAkRBQAACRIFAAAJEwUAAAkUBQAACRUFAAAJFgUAAAeWAAAAAQEAAAAxAAAABw8JFwUAAAkYBQAACRkFAAAJGgUAAAkbBQAACRwFAAAJHQUAAAkeBQAACR8FAAAJIAUAAAkhBQAACSIFAAAJIwUAAAkkBQAACSUFAAAJJgUAAAknBQAACSgFAAAJKQUAAAkqBQAACSsFAAAJLAUAAAktBQAACS4FAAAJLwUAAAkwBQAACTEFAAAJMgUAAAkzBQAACTQFAAAJNQUAAAk2BQAACTcFAAAJOAUAAAk5BQAACToFAAAJOwUAAAk8BQAACT0FAAAJPgUAAAk/BQAACUAFAAAJQQUAAAlCBQAACUMFAAAJRAUAAAlFBQAACUYFAAAJRwUAAAeaAAAAAQEAAAAxAAAABw8JSAUAAAlJBQAACUoFAAAJSwUAAAlMBQAACU0FAAAJTgUAAAlPBQAACVAFAAAJUQUAAAlSBQAACVMFAAAJVAUAAAlVBQAACVYFAAAJVwUAAAlYBQAACVkFAAAJWgUAAAlbBQAACVwFAAAJXQUAAAleBQAACV8FAAAJYAUAAAlhBQAACWIFAAAJYwUAAAlkBQAACWUFAAAJZgUAAAlnBQAACWgFAAAJaQUAAAlqBQAACWsFAAAJbAUAAAltBQAACW4FAAAJbwUAAAlwBQAACXEFAAAJcgUAAAlzBQAACXQFAAAJdQUAAAl2BQAACXcFAAAJeAUAAAeeAAAAAQEAAAAxAAAABw8JeQUAAAl6BQAACXsFAAAJfAUAAAl9BQAACX4FAAAJfwUAAAmABQAACYEFAAAJggUAAAmDBQAACYQFAAAJhQUAAAmGBQAACYcFAAAJiAUAAAmJBQAACYoFAAAJiwUAAAmMBQAACY0FAAAJjgUAAAmPBQAACZAFAAAJkQUAAAmSBQAACZMFAAAJlAUAAAmVBQAACZYFAAAJlwUAAAmYBQAACZkFAAAJmgUAAAmbBQAACZwFAAAJnQUAAAmeBQAACZ8FAAAJoAUAAAmhBQAACaIFAAAJowUAAAmkBQAACaUFAAAJpgUAAAmnBQAACagFAAAJqQUAAAeiAAAAAQEAAAAxAAAABw8JqgUAAAmrBQAACawFAAAJrQUAAAmuBQAACa8FAAAJsAUAAAmxBQAACbIFAAAJswUAAAm0BQAACbUFAAAJtgUAAAm3BQAACbgFAAAJuQUAAAm6BQAACbsFAAAJvAUAAAm9BQAACb4FAAAJvwUAAAnABQAACcEFAAAJwgUAAAnDBQAACcQFAAAJxQUAAAnGBQAACccFAAAJyAUAAAnJBQAACcoFAAAJywUAAAnMBQAACc0FAAAJzgUAAAnPBQAACdAFAAAJ0QUAAAnSBQAACdMFAAAJ1AUAAAnVBQAACdYFAAAJ1wUAAAnYBQAACdkFAAAJ2gUAAAemAAAAAQEAAAAxAAAABw8J2wUAAAncBQAACd0FAAAJ3gUAAAnfBQAACeAFAAAJ4QUAAAniBQAACeMFAAAJ5AUAAAnlBQAACeYFAAAJ5wUAAAnoBQAACekFAAAJ6gUAAAnrBQAACewFAAAJ7QUAAAnuBQAACe8FAAAJ8AUAAAnxBQAACfIFAAAJ8wUAAAn0BQAACfUFAAAJ9gUAAAn3BQAACfgFAAAJ+QUAAAn6BQAACfsFAAAJ/AUAAAn9BQAACf4FAAAJ/wUAAAkABgAACQEGAAAJAgYAAAkDBgAACQQGAAAJBQYAAAkGBgAACQcGAAAJCAYAAAkJBgAACQoGAAAJCwYAAAeqAAAAAQEAAAAxAAAABw8JDAYAAAkNBgAACQ4GAAAJDwYAAAkQBgAACREGAAAJEgYAAAkTBgAACRQGAAAJFQYAAAkWBgAACRcGAAAJGAYAAAkZBgAACRoGAAAJGwYAAAkcBgAACR0GAAAJHgYAAAkfBgAACSAGAAAJIQYAAAkiBgAACSMGAAAJJAYAAAklBgAACSYGAAAJJwYAAAkoBgAACSkGAAAJKgYAAAkrBgAACSwGAAAJLQYAAAkuBgAACS8GAAAJMAYAAAkxBgAACTIGAAAJMwYAAAk0BgAACTUGAAAJNgYAAAk3BgAACTgGAAAJOQYAAAk6BgAACTsGAAAJPAYAAAeuAAAAAQEAAAAxAAAABw8JPQYAAAk+BgAACT8GAAAJQAYAAAlBBgAACUIGAAAJQwYAAAlEBgAACUUGAAAJRgYAAAlHBgAACUgGAAAJSQYAAAlKBgAACUsGAAAJTAYAAAlNBgAACU4GAAAJTwYAAAlQBgAACVEGAAAJUgYAAAlTBgAACVQGAAAJVQYAAAlWBgAACVcGAAAJWAYAAAlZBgAACVoGAAAJWwYAAAlcBgAACV0GAAAJXgYAAAlfBgAACWAGAAAJYQYAAAliBgAACWMGAAAJZAYAAAllBgAACWYGAAAJZwYAAAloBgAACWkGAAAJagYAAAlrBgAACWwGAAAJbQYAAAeyAAAAAQEAAAAxAAAABw8JbgYAAAlvBgAACXAGAAAJcQYAAAlyBgAACXMGAAAJdAYAAAl1BgAACXYGAAAJdwYAAAl4BgAACXkGAAAJegYAAAl7BgAACXwGAAAJfQYAAAl+BgAACX8GAAAJgAYAAAmBBgAACYIGAAAJgwYAAAmEBgAACYUGAAAJhgYAAAmHBgAACYgGAAAJiQYAAAmKBgAACYsGAAAJjAYAAAmNBgAACY4GAAAJjwYAAAmQBgAACZEGAAAJkgYAAAmTBgAACZQGAAAJlQYAAAmWBgAACZcGAAAJmAYAAAmZBgAACZoGAAAJmwYAAAmcBgAACZ0GAAAJngYAAAe2AAAAAQEAAAAxAAAABw8JnwYAAAmgBgAACaEGAAAJogYAAAmjBgAACaQGAAAJpQYAAAmmBgAACacGAAAJqAYAAAmpBgAACaoGAAAJqwYAAAmsBgAACa0GAAAJrgYAAAmvBgAACbAGAAAJsQYAAAmyBgAACbMGAAAJtAYAAAm1BgAACbYGAAAJtwYAAAm4BgAACbkGAAAJugYAAAm7BgAACbwGAAAJvQYAAAm+BgAACb8GAAAJwAYAAAnBBgAACcIGAAAJwwYAAAnEBgAACcUGAAAJxgYAAAnHBgAACcgGAAAJyQYAAAnKBgAACcsGAAAJzAYAAAnNBgAACc4GAAAJzwYAAAe6AAAAAQEAAAAxAAAABw8J0AYAAAnRBgAACdIGAAAJ0wYAAAnUBgAACdUGAAAJ1gYAAAnXBgAACdgGAAAJ2QYAAAnaBgAACdsGAAAJ3AYAAAndBgAACd4GAAAJ3wYAAAngBgAACeEGAAAJ4gYAAAnjBgAACeQGAAAJ5QYAAAnmBgAACecGAAAJ6AYAAAnpBgAACeoGAAAJ6wYAAAnsBgAACe0GAAAJ7gYAAAnvBgAACfAGAAAJ8QYAAAnyBgAACfMGAAAJ9AYAAAn1BgAACfYGAAAJ9wYAAAn4BgAACfkGAAAJ+gYAAAn7BgAACfwGAAAJ/QYAAAn+BgAACf8GAAAJAAcAAAe+AAAAAQEAAAAxAAAABw8JAQcAAAkCBwAACQMHAAAJBAcAAAkFBwAACQYHAAAJBwcAAAkIBwAACQkHAAAJCgcAAAkLBwAACQwHAAAJDQcAAAkOBwAACQ8HAAAJEAcAAAkRBwAACRIHAAAJEwcAAAkUBwAACRUHAAAJFgcAAAkXBwAACRgHAAAJGQcAAAkaBwAACRsHAAAJHAcAAAkdBwAACR4HAAAJHwcAAAkgBwAACSEHAAAJIgcAAAkjBwAACSQHAAAJJQcAAAkmBwAACScHAAAJKAcAAAkpBwAACSoHAAAJKwcAAAksBwAACS0HAAAJLgcAAAkvBwAACTAHAAAJMQcAAAfCAAAAAQEAAAAxAAAABw8JMgcAAAkzBwAACTQHAAAJNQcAAAk2BwAACTcHAAAJOAcAAAk5BwAACToHAAAJOwcAAAk8BwAACT0HAAAJPgcAAAk/BwAACUAHAAAJQQcAAAlCBwAACUMHAAAJRAcAAAlFBwAACUYHAAAJRwcAAAlIBwAACUkHAAAJSgcAAAlLBwAACUwHAAAJTQcAAAlOBwAACU8HAAAJUAcAAAlRBwAACVIHAAAJUwcAAAlUBwAACVUHAAAJVgcAAAlXBwAACVgHAAAJWQcAAAlaBwAACVsHAAAJXAcAAAldBwAACV4HAAAJXwcAAAlgBwAACWEHAAAJYgcAAAfGAAAAAQEAAAAxAAAABw8JYwcAAAlkBwAACWUHAAAJZgcAAAlnBwAACWgHAAAJaQcAAAlqBwAACWsHAAAJbAcAAAltBwAACW4HAAAJbwcAAAlwBwAACXEHAAAJcgcAAAlzBwAACXQHAAAJdQcAAAl2BwAACXcHAAAJeAcAAAl5BwAACXoHAAAJewcAAAl8BwAACX0HAAAJfgcAAAl/BwAACYAHAAAJgQcAAAmCBwAACYMHAAAJhAcAAAmFBwAACYYHAAAJhwcAAAmIBwAACYkHAAAJigcAAAmLBwAACYwHAAAJjQcAAAmOBwAACY8HAAAJkAcAAAmRBwAACZIHAAAJkwcAAAfKAAAAAQEAAAAxAAAABw8JlAcAAAmVBwAACZYHAAAJlwcAAAmYBwAACZkHAAAJmgcAAAmbBwAACZwHAAAJnQcAAAmeBwAACZ8HAAAJoAcAAAmhBwAACaIHAAAJowcAAAmkBwAACaUHAAAJpgcAAAmnBwAACagHAAAJqQcAAAmqBwAACasHAAAJrAcAAAmtBwAACa4HAAAJrwcAAAmwBwAACbEHAAAJsgcAAAmzBwAACbQHAAAJtQcAAAm2BwAACbcHAAAJuAcAAAm5BwAACboHAAAJuwcAAAm8BwAACb0HAAAJvgcAAAm/BwAACcAHAAAJwQcAAAnCBwAACcMHAAAJxAcAAAfOAAAAAQEAAAAxAAAABw8JxQcAAAnGBwAACccHAAAJyAcAAAnJBwAACcoHAAAJywcAAAnMBwAACc0HAAAJzgcAAAnPBwAACdAHAAAJ0QcAAAnSBwAACdMHAAAJ1AcAAAnVBwAACdYHAAAJ1wcAAAnYBwAACdkHAAAJ2gcAAAnbBwAACdwHAAAJ3QcAAAneBwAACd8HAAAJ4AcAAAnhBwAACeIHAAAJ4wcAAAnkBwAACeUHAAAJ5gcAAAnnBwAACegHAAAJ6QcAAAnqBwAACesHAAAJ7AcAAAntBwAACe4HAAAJ7wcAAAnwBwAACfEHAAAJ8gcAAAnzBwAACfQHAAAJ9QcAAAfSAAAAAQEAAAAxAAAABw8J9gcAAAn3BwAACfgHAAAJ+QcAAAn6BwAACfsHAAAJ/AcAAAn9BwAACf4HAAAJ/wcAAAkACAAACQEIAAAJAggAAAkDCAAACQQIAAAJBQgAAAkGCAAACQcIAAAJCAgAAAkJCAAACQoIAAAJCwgAAAkMCAAACQ0IAAAJDggAAAkPCAAACRAIAAAJEQgAAAkSCAAACRMIAAAJFAgAAAkVCAAACRYIAAAJFwgAAAkYCAAACRkIAAAJGggAAAkbCAAACRwIAAAJHQgAAAkeCAAACR8IAAAJIAgAAAkhCAAACSIIAAAJIwgAAAkkCAAACSUIAAAJJggAAAfWAAAAAQEAAAAxAAAABw8JJwgAAAkoCAAACSkIAAAJKggAAAkrCAAACSwIAAAJLQgAAAkuCAAACS8IAAAJMAgAAAkxCAAACTIIAAAJMwgAAAk0CAAACTUIAAAJNggAAAk3CAAACTgIAAAJOQgAAAk6CAAACTsIAAAJPAgAAAk9CAAACT4IAAAJPwgAAAlACAAACUEIAAAJQggAAAlDCAAACUQIAAAJRQgAAAlGCAAACUcIAAAJSAgAAAlJCAAACUoIAAAJSwgAAAlMCAAACU0IAAAJTggAAAlPCAAACVAIAAAJUQgAAAlSCAAACVMIAAAJVAgAAAlVCAAACVYIAAAJVwgAAAfaAAAAAQEAAAAxAAAABw8JWAgAAAlZCAAACVoIAAAJWwgAAAlcCAAACV0IAAAJXggAAAlfCAAACWAIAAAJYQgAAAliCAAACWMIAAAJZAgAAAllCAAACWYIAAAJZwgAAAloCAAACWkIAAAJaggAAAlrCAAACWwIAAAJbQgAAAluCAAACW8IAAAJcAgAAAlxCAAACXIIAAAJcwgAAAl0CAAACXUIAAAJdggAAAl3CAAACXgIAAAJeQgAAAl6CAAACXsIAAAJfAgAAAl9CAAACX4IAAAJfwgAAAmACAAACYEIAAAJgggAAAmDCAAACYQIAAAJhQgAAAmGCAAACYcIAAAJiAgAAAfeAAAAAQEAAAAxAAAABw8JiQgAAAmKCAAACYsIAAAJjAgAAAmNCAAACY4IAAAJjwgAAAmQCAAACZEIAAAJkggAAAmTCAAACZQIAAAJlQgAAAmWCAAACZcIAAAJmAgAAAmZCAAACZoIAAAJmwgAAAmcCAAACZ0IAAAJnggAAAmfCAAACaAIAAAJoQgAAAmiCAAACaMIAAAJpAgAAAmlCAAACaYIAAAJpwgAAAmoCAAACakIAAAJqggAAAmrCAAACawIAAAJrQgAAAmuCAAACa8IAAAJsAgAAAmxCAAACbIIAAAJswgAAAm0CAAACbUIAAAJtggAAAm3CAAACbgIAAAJuQgAAAfiAAAAAQEAAAAxAAAABw8JuggAAAm7CAAACbwIAAAJvQgAAAm+CAAACb8IAAAJwAgAAAnBCAAACcIIAAAJwwgAAAnECAAACcUIAAAJxggAAAnHCAAACcgIAAAJyQgAAAnKCAAACcsIAAAJzAgAAAnNCAAACc4IAAAJzwgAAAnQCAAACdEIAAAJ0ggAAAnTCAAACdQIAAAJ1QgAAAnWCAAACdcIAAAJ2AgAAAnZCAAACdoIAAAJ2wgAAAncCAAACd0IAAAJ3ggAAAnfCAAACeAIAAAJ4QgAAAniCAAACeMIAAAJ5AgAAAnlCAAACeYIAAAJ5wgAAAnoCAAACekIAAAJ6ggAAAfmAAAAAQEAAAAxAAAABw8J6wgAAAnsCAAACe0IAAAJ7ggAAAnvCAAACfAIAAAJ8QgAAAnyCAAACfMIAAAJ9AgAAAn1CAAACfYIAAAJ9wgAAAn4CAAACfkIAAAJ+ggAAAn7CAAACfwIAAAJ/QgAAAn+CAAACf8IAAAJAAkAAAkBCQAACQIJAAAJAwkAAAkECQAACQUJAAAJBgkAAAkHCQAACQgJAAAJCQkAAAkKCQAACQsJAAAJDAkAAAkNCQAACQ4JAAAJDwkAAAkQCQAACREJAAAJEgkAAAkTCQAACRQJAAAJFQkAAAkWCQAACRcJAAAJGAkAAAkZCQAACRoJAAAJGwkAAAfqAAAAAQEAAAAxAAAABw8JHAkAAAkdCQAACR4JAAAJHwkAAAkgCQAACSEJAAAJIgkAAAkjCQAACSQJAAAJJQkAAAkmCQAACScJAAAJKAkAAAkpCQAACSoJAAAJKwkAAAksCQAACS0JAAAJLgkAAAkvCQAACTAJAAAJMQkAAAkyCQAACTMJAAAJNAkAAAk1CQAACTYJAAAJNwkAAAk4CQAACTkJAAAJOgkAAAk7CQAACTwJAAAJPQkAAAk+CQAACT8JAAAJQAkAAAlBCQAACUIJAAAJQwkAAAlECQAACUUJAAAJRgkAAAlHCQAACUgJAAAJSQkAAAlKCQAACUsJAAAJTAkAAAfuAAAAAQEAAAAxAAAABw8JTQkAAAlOCQAACU8JAAAJUAkAAAlRCQAACVIJAAAJUwkAAAlUCQAACVUJAAAJVgkAAAlXCQAACVgJAAAJWQkAAAlaCQAACVsJAAAJXAkAAAldCQAACV4JAAAJXwkAAAlgCQAACWEJAAAJYgkAAAljCQAACWQJAAAJZQkAAAlmCQAACWcJAAAJaAkAAAlpCQAACWoJAAAJawkAAAlsCQAACW0JAAAJbgkAAAlvCQAACXAJAAAJcQkAAAlyCQAACXMJAAAJdAkAAAl1CQAACXYJAAAJdwkAAAl4CQAACXkJAAAJegkAAAl7CQAACXwJAAAJfQkAAAfyAAAAAQEAAAAxAAAABw8JfgkAAAl/CQAACYAJAAAJgQkAAAmCCQAACYMJAAAJhAkAAAmFCQAACYYJAAAJhwkAAAmICQAACYkJAAAJigkAAAmLCQAACYwJAAAJjQkAAAmOCQAACY8JAAAJkAkAAAmRCQAACZIJAAAJkwkAAAmUCQAACZUJAAAJlgkAAAmXCQAACZgJAAAJmQkAAAmaCQAACZsJAAAJnAkAAAmdCQAACZ4JAAAJnwkAAAmgCQAACaEJAAAJogkAAAmjCQAACaQJAAAJpQkAAAmmCQAACacJAAAJqAkAAAmpCQAACaoJAAAJqwkAAAmsCQAACa0JAAAJrgkAAAf2AAAAAQEAAAAxAAAABw8JrwkAAAmwCQAACbEJAAAJsgkAAAmzCQAACbQJAAAJtQkAAAm2CQAACbcJAAAJuAkAAAm5CQAACboJAAAJuwkAAAm8CQAACb0JAAAJvgkAAAm/CQAACcAJAAAJwQkAAAnCCQAACcMJAAAJxAkAAAnFCQAACcYJAAAJxwkAAAnICQAACckJAAAJygkAAAnLCQAACcwJAAAJzQkAAAnOCQAACc8JAAAJ0AkAAAnRCQAACdIJAAAJ0wkAAAnUCQAACdUJAAAJ1gkAAAnXCQAACdgJAAAJ2QkAAAnaCQAACdsJAAAJ3AkAAAndCQAACd4JAAAJ3wkAAAf6AAAAAQEAAAAxAAAABw8J4AkAAAnhCQAACeIJAAAJ4wkAAAnkCQAACeUJAAAJ5gkAAAnnCQAACegJAAAJ6QkAAAnqCQAACesJAAAJ7AkAAAntCQAACe4JAAAJ7wkAAAnwCQAACfEJAAAJ8gkAAAnzCQAACfQJAAAJ9QkAAAn2CQAACfcJAAAJ+AkAAAn5CQAACfoJAAAJ+wkAAAn8CQAACf0JAAAJ/gkAAAn/CQAACQAKAAAJAQoAAAkCCgAACQMKAAAJBAoAAAkFCgAACQYKAAAJBwoAAAkICgAACQkKAAAJCgoAAAkLCgAACQwKAAAJDQoAAAkOCgAACQ8KAAAJEAoAAAf+AAAAAQEAAAAxAAAABw8JEQoAAAkSCgAACRMKAAAJFAoAAAkVCgAACRYKAAAJFwoAAAkYCgAACRkKAAAJGgoAAAkbCgAACRwKAAAJHQoAAAkeCgAACR8KAAAJIAoAAAkhCgAACSIKAAAJIwoAAAkkCgAACSUKAAAJJgoAAAknCgAACSgKAAAJKQoAAAkqCgAACSsKAAAJLAoAAAktCgAACS4KAAAJLwoAAAkwCgAACTEKAAAJMgoAAAkzCgAACTQKAAAJNQoAAAk2CgAACTcKAAAJOAoAAAk5CgAACToKAAAJOwoAAAk8CgAACT0KAAAJPgoAAAk/CgAACUAKAAAJQQoAAAcCAQAAAQEAAAAxAAAABw8JQgoAAAlDCgAACUQKAAAJRQoAAAlGCgAACUcKAAAJSAoAAAlJCgAACUoKAAAJSwoAAAlMCgAACU0KAAAJTgoAAAlPCgAACVAKAAAJUQoAAAlSCgAACVMKAAAJVAoAAAlVCgAACVYKAAAJVwoAAAlYCgAACVkKAAAJWgoAAAlbCgAACVwKAAAJXQoAAAleCgAACV8KAAAJYAoAAAlhCgAACWIKAAAJYwoAAAlkCgAACWUKAAAJZgoAAAlnCgAACWgKAAAJaQoAAAlqCgAACWsKAAAJbAoAAAltCgAACW4KAAAJbwoAAAlwCgAACXEKAAAJcgoAAAcGAQAAAQEAAAAxAAAABw8JcwoAAAl0CgAACXUKAAAJdgoAAAl3CgAACXgKAAAJeQoAAAl6CgAACXsKAAAJfAoAAAl9CgAACX4KAAAJfwoAAAmACgAACYEKAAAJggoAAAmDCgAACYQKAAAJhQoAAAmGCgAACYcKAAAJiAoAAAmJCgAACYoKAAAJiwoAAAmMCgAACY0KAAAJjgoAAAmPCgAACZAKAAAJkQoAAAmSCgAACZMKAAAJlAoAAAmVCgAACZYKAAAJlwoAAAmYCgAACZkKAAAJmgoAAAmbCgAACZwKAAAJnQoAAAmeCgAACZ8KAAAJoAoAAAmhCgAACaIKAAAJowoAAAcKAQAAAQEAAAAxAAAABw8JpAoAAAmlCgAACaYKAAAJpwoAAAmoCgAACakKAAAJqgoAAAmrCgAACawKAAAJrQoAAAmuCgAACa8KAAAJsAoAAAmxCgAACbIKAAAJswoAAAm0CgAACbUKAAAJtgoAAAm3CgAACbgKAAAJuQoAAAm6CgAACbsKAAAJvAoAAAm9CgAACb4KAAAJvwoAAAnACgAACcEKAAAJwgoAAAnDCgAACcQKAAAJxQoAAAnGCgAACccKAAAJyAoAAAnJCgAACcoKAAAJywoAAAnMCgAACc0KAAAJzgoAAAnPCgAACdAKAAAJ0QoAAAnSCgAACdMKAAAJ1AoAAAcOAQAAAQEAAAAxAAAABw8J1QoAAAnWCgAACdcKAAAJ2AoAAAnZCgAACdoKAAAJ2woAAAncCgAACd0KAAAJ3goAAAnfCgAACeAKAAAJ4QoAAAniCgAACeMKAAAJ5AoAAAnlCgAACeYKAAAJ5woAAAnoCgAACekKAAAJ6goAAAnrCgAACewKAAAJ7QoAAAnuCgAACe8KAAAJ8AoAAAnxCgAACfIKAAAJ8woAAAn0CgAACfUKAAAJ9goAAAn3CgAACfgKAAAJ+QoAAAn6CgAACfsKAAAJ/AoAAAn9CgAACf4KAAAJ/woAAAkACwAACQELAAAJAgsAAAkDCwAACQQLAAAJBQsAAAcSAQAAAQEAAAAxAAAABw8JBgsAAAkHCwAACQgLAAAJCQsAAAkKCwAACQsLAAAJDAsAAAkNCwAACQ4LAAAJDwsAAAkQCwAACRELAAAJEgsAAAkTCwAACRQLAAAJFQsAAAkWCwAACRcLAAAJGAsAAAkZCwAACRoLAAAJGwsAAAkcCwAACR0LAAAJHgsAAAkfCwAACSALAAAJIQsAAAkiCwAACSMLAAAJJAsAAAklCwAACSYLAAAJJwsAAAkoCwAACSkLAAAJKgsAAAkrCwAACSwLAAAJLQsAAAkuCwAACS8LAAAJMAsAAAkxCwAACTILAAAJMwsAAAk0CwAACTULAAAJNgsAAAcWAQAAAQEAAAAxAAAABw8JNwsAAAk4CwAACTkLAAAJOgsAAAk7CwAACTwLAAAJPQsAAAk+CwAACT8LAAAJQAsAAAlBCwAACUILAAAJQwsAAAlECwAACUULAAAJRgsAAAlHCwAACUgLAAAJSQsAAAlKCwAACUsLAAAJTAsAAAlNCwAACU4LAAAJTwsAAAlQCwAACVELAAAJUgsAAAlTCwAACVQLAAAJVQsAAAlWCwAACVcLAAAJWAsAAAlZCwAACVoLAAAJWwsAAAlcCwAACV0LAAAJXgsAAAlfCwAACWALAAAJYQsAAAliCwAACWMLAAAJZAsAAAllCwAACWYLAAAJZwsAAAcaAQAAAQEAAAAxAAAABw8JaAsAAAlpCwAACWoLAAAJawsAAAlsCwAACW0LAAAJbgsAAAlvCwAACXALAAAJcQsAAAlyCwAACXMLAAAJdAsAAAl1CwAACXYLAAAJdwsAAAl4CwAACXkLAAAJegsAAAl7CwAACXwLAAAJfQsAAAl+CwAACX8LAAAJgAsAAAmBCwAACYILAAAJgwsAAAmECwAACYULAAAJhgsAAAmHCwAACYgLAAAJiQsAAAmKCwAACYsLAAAJjAsAAAmNCwAACY4LAAAJjwsAAAmQCwAACZELAAAJkgsAAAmTCwAACZQLAAAJlQsAAAmWCwAACZcLAAAJmAsAAAceAQAAAQEAAAAxAAAABw8JmQsAAAmaCwAACZsLAAAJnAsAAAmdCwAACZ4LAAAJnwsAAAmgCwAACaELAAAJogsAAAmjCwAACaQLAAAJpQsAAAmmCwAACacLAAAJqAsAAAmpCwAACaoLAAAJqwsAAAmsCwAACa0LAAAJrgsAAAmvCwAACbALAAAJsQsAAAmyCwAACbMLAAAJtAsAAAm1CwAACbYLAAAJtwsAAAm4CwAACbkLAAAJugsAAAm7CwAACbwLAAAJvQsAAAm+CwAACb8LAAAJwAsAAAnBCwAACcILAAAJwwsAAAnECwAACcULAAAJxgsAAAnHCwAACcgLAAAJyQsAAAciAQAAAQEAAAAxAAAABw8JygsAAAnLCwAACcwLAAAJzQsAAAnOCwAACc8LAAAJ0AsAAAnRCwAACdILAAAJ0wsAAAnUCwAACdULAAAJ1gsAAAnXCwAACdgLAAAJ2QsAAAnaCwAACdsLAAAJ3AsAAAndCwAACd4LAAAJ3wsAAAngCwAACeELAAAJ4gsAAAnjCwAACeQLAAAJ5QsAAAnmCwAACecLAAAJ6AsAAAnpCwAACeoLAAAJ6wsAAAnsCwAACe0LAAAJ7gsAAAnvCwAACfALAAAJ8QsAAAnyCwAACfMLAAAJ9AsAAAn1CwAACfYLAAAJ9wsAAAn4CwAACfkLAAAJ+gsAAAcmAQAAAQEAAAAxAAAABw8J+wsAAAn8CwAACf0LAAAJ/gsAAAn/CwAACQAMAAAJAQwAAAkCDAAACQMMAAAJBAwAAAkFDAAACQYMAAAJBwwAAAkIDAAACQkMAAAJCgwAAAkLDAAACQwMAAAJDQwAAAkODAAACQ8MAAAJEAwAAAkRDAAACRIMAAAJEwwAAAkUDAAACRUMAAAJFgwAAAkXDAAACRgMAAAJGQwAAAkaDAAACRsMAAAJHAwAAAkdDAAACR4MAAAJHwwAAAkgDAAACSEMAAAJIgwAAAkjDAAACSQMAAAJJQwAAAkmDAAACScMAAAJKAwAAAkpDAAACSoMAAAJKwwAAAcqAQAAAQEAAAAxAAAABw8JLAwAAAktDAAACS4MAAAJLwwAAAkwDAAACTEMAAAJMgwAAAkzDAAACTQMAAAJNQwAAAk2DAAACTcMAAAJOAwAAAk5DAAACToMAAAJOwwAAAk8DAAACT0MAAAJPgwAAAk/DAAACUAMAAAJQQwAAAlCDAAACUMMAAAJRAwAAAlFDAAACUYMAAAJRwwAAAlIDAAACUkMAAAJSgwAAAlLDAAACUwMAAAJTQwAAAlODAAACU8MAAAJUAwAAAlRDAAACVIMAAAJUwwAAAlUDAAACVUMAAAJVgwAAAlXDAAACVgMAAAJWQwAAAlaDAAACVsMAAAJXAwAAAcuAQAAAQEAAAAxAAAABw8JXQwAAAleDAAACV8MAAAJYAwAAAlhDAAACWIMAAAJYwwAAAlkDAAACWUMAAAJZgwAAAlnDAAACWgMAAAJaQwAAAlqDAAACWsMAAAJbAwAAAltDAAACW4MAAAJbwwAAAlwDAAACXEMAAAJcgwAAAlzDAAACXQMAAAJdQwAAAl2DAAACXcMAAAJeAwAAAl5DAAACXoMAAAJewwAAAl8DAAACX0MAAAJfgwAAAl/DAAACYAMAAAJgQwAAAmCDAAACYMMAAAJhAwAAAmFDAAACYYMAAAJhwwAAAmIDAAACYkMAAAJigwAAAmLDAAACYwMAAAJjQwAAAcyAQAAAQEAAAAxAAAABw8JjgwAAAmPDAAACZAMAAAJkQwAAAmSDAAACZMMAAAJlAwAAAmVDAAACZYMAAAJlwwAAAmYDAAACZkMAAAJmgwAAAmbDAAACZwMAAAJnQwAAAmeDAAACZ8MAAAJoAwAAAmhDAAACaIMAAAJowwAAAmkDAAACaUMAAAJpgwAAAmnDAAACagMAAAJqQwAAAmqDAAACasMAAAJrAwAAAmtDAAACa4MAAAJrwwAAAmwDAAACbEMAAAJsgwAAAmzDAAACbQMAAAJtQwAAAm2DAAACbcMAAAJuAwAAAm5DAAACboMAAAJuwwAAAm8DAAACb0MAAAJvgwAAAc2AQAAAQEAAAAxAAAABw8JvwwAAAnADAAACcEMAAAJwgwAAAnDDAAACcQMAAAJxQwAAAnGDAAACccMAAAJyAwAAAnJDAAACcoMAAAJywwAAAnMDAAACc0MAAAJzgwAAAnPDAAACdAMAAAJ0QwAAAnSDAAACdMMAAAJ1AwAAAnVDAAACdYMAAAJ1wwAAAnYDAAACdkMAAAJ2gwAAAnbDAAACdwMAAAJ3QwAAAneDAAACd8MAAAJ4AwAAAnhDAAACeIMAAAJ4wwAAAnkDAAACeUMAAAJ5gwAAAnnDAAACegMAAAJ6QwAAAnqDAAACesMAAAJ7AwAAAntDAAACe4MAAAJ7wwAAAc6AQAAAQEAAAAxAAAABw8J8AwAAAnxDAAACfIMAAAJ8wwAAAn0DAAACfUMAAAJ9gwAAAn3DAAACfgMAAAJ+QwAAAn6DAAACfsMAAAJ/AwAAAn9DAAACf4MAAAJ/wwAAAkADQAACQENAAAJAg0AAAkDDQAACQQNAAAJBQ0AAAkGDQAACQcNAAAJCA0AAAkJDQAACQoNAAAJCw0AAAkMDQAACQ0NAAAJDg0AAAkPDQAACRANAAAJEQ0AAAkSDQAACRMNAAAJFA0AAAkVDQAACRYNAAAJFw0AAAkYDQAACRkNAAAJGg0AAAkbDQAACRwNAAAJHQ0AAAkeDQAACR8NAAAJIA0AAAc+AQAAAQEAAAAxAAAABw8JIQ0AAAkiDQAACSMNAAAJJA0AAAklDQAACSYNAAAJJw0AAAkoDQAACSkNAAAJKg0AAAkrDQAACSwNAAAJLQ0AAAkuDQAACS8NAAAJMA0AAAkxDQAACTINAAAJMw0AAAk0DQAACTUNAAAJNg0AAAk3DQAACTgNAAAJOQ0AAAk6DQAACTsNAAAJPA0AAAk9DQAACT4NAAAJPw0AAAlADQAACUENAAAJQg0AAAlDDQAACUQNAAAJRQ0AAAlGDQAACUcNAAAJSA0AAAlJDQAACUoNAAAJSw0AAAlMDQAACU0NAAAJTg0AAAlPDQAACVANAAAJUQ0AAAdCAQAAAQEAAAAxAAAABw8JUg0AAAlTDQAACVQNAAAJVQ0AAAlWDQAACVcNAAAJWA0AAAlZDQAACVoNAAAJWw0AAAlcDQAACV0NAAAJXg0AAAlfDQAACWANAAAJYQ0AAAliDQAACWMNAAAJZA0AAAllDQAACWYNAAAJZw0AAAloDQAACWkNAAAJag0AAAlrDQAACWwNAAAJbQ0AAAluDQAACW8NAAAJcA0AAAlxDQAACXINAAAJcw0AAAl0DQAACXUNAAAJdg0AAAl3DQAACXgNAAAJeQ0AAAl6DQAACXsNAAAJfA0AAAl9DQAACX4NAAAJfw0AAAmADQAACYENAAAJgg0AAA9DAQAAAgAAAA9gAAAAfgAAAA9EAQAAAgAAAA8xAAAAIQAAAA9FAQAAAgAAAA8yAAAAQAAAAA9GAQAAAgAAAA8zAAAAIwAAAA9HAQAAAgAAAA80AAAAJAAAAA9IAQAAAgAAAA81AAAAJQAAAA9JAQAAAgAAAA82AAAAXgAAAA9KAQAAAgAAAA83AAAAJgAAAA9LAQAAAgAAAA84AAAAKgAAAA9MAQAAAgAAAA85AAAAKAAAAA9NAQAAAgAAAA8wAAAAKQAAAA9OAQAAAgAAAA8tAAAAXwAAAA9PAQAAAgAAAA89AAAAKwAAAA9QAQAAAgAAAA9xAAAAUQAAAA9RAQAAAgAAAA93AAAAVwAAAA9SAQAAAgAAAA9lAAAARQAAAA9TAQAAAgAAAA9yAAAAUgAAAA9UAQAAAgAAAA90AAAAVAAAAA9VAQAAAgAAAA95AAAAWQAAAA9WAQAAAgAAAA91AAAAVQAAAA9XAQAAAgAAAA9pAAAASQAAAA9YAQAAAgAAAA9vAAAATwAAAA9ZAQAAAgAAAA9wAAAAUAAAAA9aAQAAAgAAAA9bAAAAewAAAA9bAQAAAgAAAA9dAAAAfQAAAA9cAQAAAgAAAA9hAAAAQQAAAA9dAQAAAgAAAA9zAAAAUwAAAA9eAQAAAgAAAA9kAAAARAAAAA9fAQAAAgAAAA9mAAAARgAAAA9gAQAAAgAAAA9nAAAARwAAAA9hAQAAAgAAAA9oAAAASAAAAA9iAQAAAgAAAA9qAAAASgAAAA9jAQAAAgAAAA9rAAAASwAAAA9kAQAAAgAAAA9sAAAATAAAAA9lAQAAAgAAAA87AAAAOgAAAA9mAQAAAgAAAA8nAAAAIgAAAA9nAQAAAgAAAA9cAAAAfAAAAA9oAQAAAgAAAA96AAAAWgAAAA9pAQAAAgAAAA94AAAAWAAAAA9qAQAAAgAAAA9jAAAAQwAAAA9rAQAAAgAAAA92AAAAVgAAAA9sAQAAAgAAAA9iAAAAQgAAAA9tAQAAAgAAAA9uAAAATgAAAA9uAQAAAgAAAA9tAAAATQAAAA9vAQAAAgAAAA8sAAAAPAAAAA9wAQAAAgAAAA8uAAAAPgAAAA9xAQAAAgAAAA8vAAAAPwAAAA9yAQAAAAAAAA8PcwEAAAAAAAAPD3QBAAACAAAAD2AAAAB+AAAAD3UBAAACAAAADzEAAAAhAAAAD3YBAAACAAAADzIAAABAAAAAD3cBAAACAAAADzMAAAAjAAAAD3gBAAACAAAADzQAAAAkAAAAD3kBAAACAAAADzUAAAAlAAAAD3oBAAACAAAADzYAAABeAAAAD3sBAAACAAAADzcAAAAmAAAAD3wBAAACAAAADzgAAAAqAAAAD30BAAACAAAADzkAAAAoAAAAD34BAAACAAAADzAAAAApAAAAD38BAAACAAAADy0AAABfAAAAD4ABAAACAAAADz0AAAArAAAAD4EBAAACAAAAD3EAAABRAAAAD4IBAAACAAAAD3cAAABXAAAAD4MBAAACAAAAD2UAAABFAAAAD4QBAAACAAAAD3IAAABSAAAAD4UBAAACAAAAD3QAAABUAAAAD4YBAAACAAAAD3kAAABZAAAAD4cBAAACAAAAD3UAAABVAAAAD4gBAAACAAAAD2kAAABJAAAAD4kBAAACAAAAD28AAABPAAAAD4oBAAACAAAAD3AAAABQAAAAD4sBAAACAAAAD1sAAAB7AAAAD4wBAAACAAAAD10AAAB9AAAAD40BAAACAAAAD2EAAABBAAAAD44BAAACAAAAD3MAAABTAAAAD48BAAACAAAAD2QAAABEAAAAD5ABAAACAAAAD2YAAABGAAAAD5EBAAACAAAAD2cAAABHAAAAD5IBAAACAAAAD2gAAABIAAAAD5MBAAACAAAAD2oAAABKAAAAD5QBAAACAAAAD2sAAABLAAAAD5UBAAACAAAAD2wAAABMAAAAD5YBAAACAAAADzsAAAA6AAAAD5cBAAACAAAADycAAAAiAAAAD5gBAAACAAAAD1wAAAB8AAAAD5kBAAACAAAAD3oAAABaAAAAD5oBAAACAAAAD3gAAABYAAAAD5sBAAACAAAAD2MAAABDAAAAD5wBAAACAAAAD3YAAABWAAAAD50BAAACAAAAD2IAAABCAAAAD54BAAACAAAAD24AAABOAAAAD58BAAACAAAAD20AAABNAAAAD6ABAAACAAAADywAAAA8AAAAD6EBAAACAAAADy4AAAA+AAAAD6IBAAACAAAADy8AAAA/AAAAD6MBAAACAAAADzwAAAA+AAAAD6QBAAAAAAAADw+lAQAAAgAAAA9gAAAAfgAAAA+mAQAAAgAAAA8xAAAAIQAAAA+nAQAAAgAAAA8yAAAAQAAAAA+oAQAAAgAAAA8zAAAAIwAAAA+pAQAAAgAAAA80AAAAJAAAAA+qAQAAAgAAAA81AAAAJQAAAA+rAQAAAgAAAA82AAAAXgAAAA+sAQAAAgAAAA83AAAAJgAAAA+tAQAAAgAAAA84AAAAKgAAAA+uAQAAAgAAAA85AAAAKAAAAA+vAQAAAgAAAA8wAAAAKQAAAA+wAQAAAgAAAA9bAAAAewAAAA+xAQAAAgAAAA9dAAAAfQAAAA+yAQAAAgAAAA8nAAAAIgAAAA+zAQAAAgAAAA8sAAAAPAAAAA+0AQAAAgAAAA8uAAAAPgAAAA+1AQAAAgAAAA9wAAAAUAAAAA+2AQAAAgAAAA95AAAAWQAAAA+3AQAAAgAAAA9mAAAARgAAAA+4AQAAAgAAAA9nAAAARwAAAA+5AQAAAgAAAA9jAAAAQwAAAA+6AQAAAgAAAA9yAAAAUgAAAA+7AQAAAgAAAA9sAAAATAAAAA+8AQAAAgAAAA8vAAAAPwAAAA+9AQAAAgAAAA89AAAAKwAAAA++AQAAAgAAAA9hAAAAQQAAAA+/AQAAAgAAAA9vAAAATwAAAA/AAQAAAgAAAA9lAAAARQAAAA/BAQAAAgAAAA91AAAAVQAAAA/CAQAAAgAAAA9pAAAASQAAAA/DAQAAAgAAAA9kAAAARAAAAA/EAQAAAgAAAA9oAAAASAAAAA/FAQAAAgAAAA90AAAAVAAAAA/GAQAAAgAAAA9uAAAATgAAAA/HAQAAAgAAAA9zAAAAUwAAAA/IAQAAAgAAAA8tAAAAXwAAAA/JAQAAAgAAAA9cAAAAfAAAAA/KAQAAAgAAAA87AAAAOgAAAA/LAQAAAgAAAA9xAAAAUQAAAA/MAQAAAgAAAA9qAAAASgAAAA/NAQAAAgAAAA9rAAAASwAAAA/OAQAAAgAAAA94AAAAWAAAAA/PAQAAAgAAAA9iAAAAQgAAAA/QAQAAAgAAAA9tAAAATQAAAA/RAQAAAgAAAA93AAAAVwAAAA/SAQAAAgAAAA92AAAAVgAAAA/TAQAAAgAAAA96AAAAWgAAAA/UAQAAAAAAAA8P1QEAAAAAAAAPD9YBAAACAAAAD2AAAAB+AAAAD9cBAAACAAAADzEAAAAhAAAAD9gBAAACAAAADzIAAABAAAAAD9kBAAACAAAADzMAAAAjAAAAD9oBAAACAAAADzQAAAAkAAAAD9sBAAACAAAADzUAAAAlAAAAD9wBAAACAAAADzYAAABeAAAAD90BAAACAAAADzcAAAAmAAAAD94BAAACAAAADzgAAAAqAAAAD98BAAACAAAADzkAAAAoAAAAD+ABAAACAAAADzAAAAApAAAAD+EBAAACAAAADy0AAABfAAAAD+IBAAACAAAADz0AAAArAAAAD+MBAAACAAAAD1wAAAB8AAAAD+QBAAACAAAAD3EAAABRAAAAD+UBAAACAAAAD3cAAABXAAAAD+YBAAACAAAAD2UAAABFAAAAD+cBAAACAAAAD3IAAABSAAAAD+gBAAACAAAAD3QAAABUAAAAD+kBAAACAAAAD3kAAABZAAAAD+oBAAACAAAAD3UAAABVAAAAD+sBAAACAAAAD2kAAABJAAAAD+wBAAACAAAAD28AAABPAAAAD+0BAAACAAAAD3AAAABQAAAAD+4BAAACAAAAD1sAAAB7AAAAD+8BAAACAAAAD10AAAB9AAAAD/ABAAACAAAAD2EAAABBAAAAD/EBAAACAAAAD3MAAABTAAAAD/IBAAACAAAAD2QAAABEAAAAD/MBAAACAAAAD2YAAABGAAAAD/QBAAACAAAAD2cAAABHAAAAD/UBAAACAAAAD2gAAABIAAAAD/YBAAACAAAAD2oAAABKAAAAD/cBAAACAAAAD2sAAABLAAAAD/gBAAACAAAAD2wAAABMAAAAD/kBAAACAAAADzsAAAA6AAAAD/oBAAACAAAADycAAAAiAAAAD/sBAAACAAAAD3oAAABaAAAAD/wBAAACAAAAD3gAAABYAAAAD/0BAAACAAAAD2MAAABDAAAAD/4BAAACAAAAD3YAAABWAAAAD/8BAAACAAAAD2IAAABCAAAADwACAAACAAAAD24AAABOAAAADwECAAACAAAAD20AAABNAAAADwICAAACAAAADywAAAA8AAAADwMCAAACAAAADy4AAAA+AAAADwQCAAACAAAADy8AAAA/AAAADwUCAAAAAAAADw8GAgAAAAAAAA8PBwIAAAEAAAAPYAAAAA8IAgAAAgAAAA8xAAAAIQAAAA8JAgAAAgAAAA8yAAAAIgAAAA8KAgAAAgAAAA8zAAAAo////w8LAgAAAgAAAA80AAAAJAAAAA8MAgAAAgAAAA81AAAAJQAAAA8NAgAAAgAAAA82AAAAXgAAAA8OAgAAAgAAAA83AAAAJgAAAA8PAgAAAgAAAA84AAAAKgAAAA8QAgAAAgAAAA85AAAAKAAAAA8RAgAAAgAAAA8wAAAAKQAAAA8SAgAAAgAAAA8tAAAAXwAAAA8TAgAAAgAAAA89AAAAKwAAAA8UAgAAAgAAAA9xAAAAUQAAAA8VAgAAAgAAAA93AAAAVwAAAA8WAgAAAgAAAA9lAAAARQAAAA8XAgAAAgAAAA9yAAAAUgAAAA8YAgAAAgAAAA90AAAAVAAAAA8ZAgAAAgAAAA95AAAAWQAAAA8aAgAAAgAAAA91AAAAVQAAAA8bAgAAAgAAAA9pAAAASQAAAA8cAgAAAgAAAA9vAAAATwAAAA8dAgAAAgAAAA9wAAAAUAAAAA8eAgAAAgAAAA9bAAAAewAAAA8fAgAAAgAAAA9dAAAAfQAAAA8gAgAAAgAAAA9hAAAAQQAAAA8hAgAAAgAAAA9zAAAAUwAAAA8iAgAAAgAAAA9kAAAARAAAAA8jAgAAAgAAAA9mAAAARgAAAA8kAgAAAgAAAA9nAAAARwAAAA8lAgAAAgAAAA9oAAAASAAAAA8mAgAAAgAAAA9qAAAASgAAAA8nAgAAAgAAAA9rAAAASwAAAA8oAgAAAgAAAA9sAAAATAAAAA8pAgAAAgAAAA87AAAAOgAAAA8qAgAAAgAAAA8nAAAAQAAAAA8rAgAAAgAAAA8jAAAAfgAAAA8sAgAAAgAAAA96AAAAWgAAAA8tAgAAAgAAAA94AAAAWAAAAA8uAgAAAgAAAA9jAAAAQwAAAA8vAgAAAgAAAA92AAAAVgAAAA8wAgAAAgAAAA9iAAAAQgAAAA8xAgAAAgAAAA9uAAAATgAAAA8yAgAAAgAAAA9tAAAATQAAAA8zAgAAAgAAAA8sAAAAPAAAAA80AgAAAgAAAA8uAAAAPgAAAA81AgAAAgAAAA8vAAAAPwAAAA82AgAAAgAAAA9cAAAAfAAAAA83AgAAAAAAAA8POAIAAAIAAAAPXgAAALD///8POQIAAAIAAAAPMQAAACEAAAAPOgIAAAIAAAAPMgAAACIAAAAPOwIAAAIAAAAPMwAAAKf///8PPAIAAAIAAAAPNAAAACQAAAAPPQIAAAIAAAAPNQAAACUAAAAPPgIAAAIAAAAPNgAAACYAAAAPPwIAAAIAAAAPNwAAAC8AAAAPQAIAAAIAAAAPOAAAACgAAAAPQQIAAAIAAAAPOQAAACkAAAAPQgIAAAIAAAAPMAAAAD0AAAAPQwIAAAIAAAAP3////z8AAAAPRAIAAAIAAAAPtP///2AAAAAPRQIAAAIAAAAPcQAAAFEAAAAPRgIAAAIAAAAPdwAAAFcAAAAPRwIAAAIAAAAPZQAAAEUAAAAPSAIAAAIAAAAPcgAAAFIAAAAPSQIAAAIAAAAPdAAAAFQAAAAPSgIAAAIAAAAPegAAAFoAAAAPSwIAAAIAAAAPdQAAAFUAAAAPTAIAAAIAAAAPaQAAAEkAAAAPTQIAAAIAAAAPbwAAAE8AAAAPTgIAAAIAAAAPcAAAAFAAAAAPTwIAAAIAAAAP/P///9z///8PUAIAAAIAAAAPKwAAACoAAAAPUQIAAAIAAAAPYQAAAEEAAAAPUgIAAAIAAAAPcwAAAFMAAAAPUwIAAAIAAAAPZAAAAEQAAAAPVAIAAAIAAAAPZgAAAEYAAAAPVQIAAAIAAAAPZwAAAEcAAAAPVgIAAAIAAAAPaAAAAEgAAAAPVwIAAAIAAAAPagAAAEoAAAAPWAIAAAIAAAAPawAAAEsAAAAPWQIAAAIAAAAPbAAAAEwAAAAPWgIAAAIAAAAP9v///9b///8PWwIAAAIAAAAP5P///8T///8PXAIAAAIAAAAPIwAAACcAAAAPXQIAAAIAAAAPeQAAAFkAAAAPXgIAAAIAAAAPeAAAAFgAAAAPXwIAAAIAAAAPYwAAAEMAAAAPYAIAAAIAAAAPdgAAAFYAAAAPYQIAAAIAAAAPYgAAAEIAAAAPYgIAAAIAAAAPbgAAAE4AAAAPYwIAAAIAAAAPbQAAAE0AAAAPZAIAAAIAAAAPLAAAADsAAAAPZQIAAAIAAAAPLgAAADoAAAAPZgIAAAIAAAAPLQAAAF8AAAAPZwIAAAMAAAAPPAAAAD4AAAB8AAAAD2gCAAAAAAAADw9pAgAAAgAAAA9eAAAAsP///w9qAgAAAgAAAA8xAAAAIQAAAA9rAgAAAgAAAA8yAAAAIgAAAA9sAgAAAgAAAA8zAAAAp////w9tAgAAAgAAAA80AAAAJAAAAA9uAgAAAgAAAA81AAAAJQAAAA9vAgAAAgAAAA82AAAAJgAAAA9wAgAAAwAAAA83AAAALwAAAHsAAAAPcQIAAAMAAAAPOAAAACgAAABbAAAAD3ICAAADAAAADzkAAAApAAAAXQAAAA9zAgAAAwAAAA8wAAAAPQAAAH0AAAAPdAIAAAMAAAAP3////z8AAABcAAAAD3UCAAABAAAAD7T///8PdgIAAAIAAAAPcQAAAFEAAAAPdwIAAAIAAAAPdwAAAFcAAAAPeAIAAAIAAAAPZQAAAEUAAAAPeQIAAAIAAAAPcgAAAFIAAAAPegIAAAIAAAAPdAAAAFQAAAAPewIAAAIAAAAPegAAAFoAAAAPfAIAAAIAAAAPdQAAAFUAAAAPfQIAAAIAAAAPaQAAAEkAAAAPfgIAAAIAAAAPbwAAAE8AAAAPfwIAAAIAAAAPcAAAAFAAAAAPgAIAAAIAAAAP/P///9z///8PgQIAAAMAAAAPKwAAACoAAAB+AAAAD4ICAAACAAAAD2EAAABBAAAAD4MCAAACAAAAD3MAAABTAAAAD4QCAAACAAAAD2QAAABEAAAAD4UCAAACAAAAD2YAAABGAAAAD4YCAAACAAAAD2cAAABHAAAAD4cCAAACAAAAD2gAAABIAAAAD4gCAAACAAAAD2oAAABKAAAAD4kCAAACAAAAD2sAAABLAAAAD4oCAAACAAAAD2wAAABMAAAAD4sCAAACAAAAD/b////W////D4wCAAACAAAAD+T////E////D40CAAACAAAADyMAAAAnAAAAD44CAAACAAAAD3kAAABZAAAAD48CAAACAAAAD3gAAABYAAAAD5ACAAACAAAAD2MAAABDAAAAD5ECAAACAAAAD3YAAABWAAAAD5ICAAACAAAAD2IAAABCAAAAD5MCAAACAAAAD24AAABOAAAAD5QCAAACAAAAD20AAABNAAAAD5UCAAACAAAADywAAAA7AAAAD5YCAAACAAAADy4AAAA6AAAAD5cCAAACAAAADy0AAABfAAAAD5gCAAACAAAADzwAAAA+AAAAD5kCAAAAAAAADw+aAgAAAgAAAA9eAAAAsP///w+bAgAAAgAAAA8xAAAAIQAAAA+cAgAAAgAAAA8yAAAAIgAAAA+dAgAAAgAAAA8zAAAAp////w+eAgAAAgAAAA80AAAAJAAAAA+fAgAAAgAAAA81AAAAJQAAAA+gAgAAAgAAAA82AAAAJgAAAA+hAgAAAwAAAA83AAAALwAAAHsAAAAPogIAAAMAAAAPOAAAACgAAABbAAAAD6MCAAADAAAADzkAAAApAAAAXQAAAA+kAgAAAwAAAA8wAAAAPQAAAH0AAAAPpQIAAAMAAAAP3////z8AAABcAAAAD6YCAAACAAAADycAAABgAAAAD6cCAAADAAAAD3EAAABRAAAAQAAAAA+oAgAAAgAAAA93AAAAVwAAAA+pAgAAAgAAAA9lAAAARQAAAA+qAgAAAgAAAA9yAAAAUgAAAA+rAgAAAgAAAA90AAAAVAAAAA+sAgAAAgAAAA96AAAAWgAAAA+tAgAAAgAAAA91AAAAVQAAAA+uAgAAAgAAAA9pAAAASQAAAA+vAgAAAgAAAA9vAAAATwAAAA+wAgAAAgAAAA9wAAAAUAAAAA+xAgAAAgAAAA/8////3P///w+yAgAAAwAAAA8rAAAAKgAAAH4AAAAPswIAAAIAAAAPYQAAAEEAAAAPtAIAAAIAAAAPcwAAAFMAAAAPtQIAAAIAAAAPZAAAAEQAAAAPtgIAAAIAAAAPZgAAAEYAAAAPtwIAAAIAAAAPZwAAAEcAAAAPuAIAAAIAAAAPaAAAAEgAAAAPuQIAAAIAAAAPagAAAEoAAAAPugIAAAIAAAAPawAAAEsAAAAPuwIAAAIAAAAPbAAAAEwAAAAPvAIAAAIAAAAP9v///9b///8PvQIAAAIAAAAP5P///8T///8PvgIAAAIAAAAPIwAAACcAAAAPvwIAAAIAAAAPeQAAAFkAAAAPwAIAAAIAAAAPeAAAAFgAAAAPwQIAAAIAAAAPYwAAAEMAAAAPwgIAAAIAAAAPdgAAAFYAAAAPwwIAAAIAAAAPYgAAAEIAAAAPxAIAAAIAAAAPbgAAAE4AAAAPxQIAAAIAAAAPbQAAAE0AAAAPxgIAAAIAAAAPLAAAADsAAAAPxwIAAAIAAAAPLgAAADoAAAAPyAIAAAIAAAAPLQAAAF8AAAAPyQIAAAMAAAAPPAAAAD4AAAB8AAAAD8oCAAAAAAAADw/LAgAAAgAAAA9eAAAAsP///w/MAgAAAgAAAA8xAAAAIQAAAA/NAgAAAwAAAA8yAAAAIgAAALL///8PzgIAAAMAAAAPMwAAAKf///+z////D88CAAACAAAADzQAAAAkAAAAD9ACAAACAAAADzUAAAAlAAAAD9ECAAACAAAADzYAAAAmAAAAD9ICAAADAAAADzcAAAAvAAAAewAAAA/TAgAAAwAAAA84AAAAKAAAAFsAAAAP1AIAAAMAAAAPOQAAACkAAABdAAAAD9UCAAADAAAADzAAAAA9AAAAfQAAAA/WAgAAAwAAAA/f////PwAAAFwAAAAP1wIAAAIAAAAPJwAAAGAAAAAP2AIAAAMAAAAPcQAAAFEAAABAAAAAD9kCAAACAAAAD3cAAABXAAAAD9oCAAACAAAAD2UAAABFAAAAD9sCAAACAAAAD3IAAABSAAAAD9wCAAACAAAAD3QAAABUAAAAD90CAAACAAAAD3oAAABaAAAAD94CAAACAAAAD3UAAABVAAAAD98CAAACAAAAD2kAAABJAAAAD+ACAAACAAAAD28AAABPAAAAD+ECAAACAAAAD3AAAABQAAAAD+ICAAACAAAAD/z////c////D+MCAAADAAAADysAAAAqAAAAfgAAAA/kAgAAAgAAAA9hAAAAQQAAAA/lAgAAAgAAAA9zAAAAUwAAAA/mAgAAAgAAAA9kAAAARAAAAA/nAgAAAgAAAA9mAAAARgAAAA/oAgAAAgAAAA9nAAAARwAAAA/pAgAAAgAAAA9oAAAASAAAAA/qAgAAAgAAAA9qAAAASgAAAA/rAgAAAgAAAA9rAAAASwAAAA/sAgAAAgAAAA9sAAAATAAAAA/tAgAAAgAAAA/2////1v///w/uAgAAAgAAAA/k////xP///w/vAgAAAgAAAA8jAAAAJwAAAA/wAgAAAwAAAA88AAAAPgAAAHwAAAAP8QIAAAIAAAAPeQAAAFkAAAAP8gIAAAIAAAAPeAAAAFgAAAAP8wIAAAIAAAAPYwAAAEMAAAAP9AIAAAIAAAAPdgAAAFYAAAAP9QIAAAIAAAAPYgAAAEIAAAAP9gIAAAIAAAAPbgAAAE4AAAAP9wIAAAIAAAAPbQAAAE0AAAAP+AIAAAIAAAAPLAAAADsAAAAP+QIAAAIAAAAPLgAAADoAAAAP+gIAAAIAAAAPLQAAAF8AAAAP+wIAAAAAAAAPD/wCAAACAAAAD6f///+w////D/0CAAACAAAADzEAAAArAAAAD/4CAAACAAAADzIAAAAiAAAAD/8CAAACAAAADzMAAAAqAAAADwADAAACAAAADzQAAADn////DwEDAAACAAAADzUAAAAlAAAADwIDAAACAAAADzYAAAAmAAAADwMDAAACAAAADzcAAAAvAAAADwQDAAACAAAADzgAAAAoAAAADwUDAAACAAAADzkAAAApAAAADwYDAAACAAAADzAAAAA9AAAADwcDAAACAAAADycAAAA/AAAADwgDAAACAAAAD14AAABgAAAADwkDAAACAAAAD3EAAABRAAAADwoDAAACAAAAD3cAAABXAAAADwsDAAACAAAAD2UAAABFAAAADwwDAAACAAAAD3IAAABSAAAADw0DAAACAAAAD3QAAABUAAAADw4DAAACAAAAD3oAAABaAAAADw8DAAACAAAAD3UAAABVAAAADxADAAACAAAAD2kAAABJAAAADxEDAAACAAAAD28AAABPAAAADxIDAAACAAAAD3AAAABQAAAADxMDAAACAAAAD/z////o////DxQDAAACAAAAD6j///8hAAAADxUDAAACAAAAD2EAAABBAAAADxYDAAACAAAAD3MAAABTAAAADxcDAAACAAAAD2QAAABEAAAADxgDAAACAAAAD2YAAABGAAAADxkDAAACAAAAD2cAAABHAAAADxoDAAACAAAAD2gAAABIAAAADxsDAAACAAAAD2oAAABKAAAADxwDAAACAAAAD2sAAABLAAAADx0DAAACAAAAD2wAAABMAAAADx4DAAACAAAAD/b////p////Dx8DAAACAAAAD+T////g////DyADAAACAAAADyQAAACj////DyEDAAACAAAAD3kAAABZAAAADyIDAAACAAAAD3gAAABYAAAADyMDAAACAAAAD2MAAABDAAAADyQDAAACAAAAD3YAAABWAAAADyUDAAACAAAAD2IAAABCAAAADyYDAAACAAAAD24AAABOAAAADycDAAACAAAAD20AAABNAAAADygDAAACAAAADywAAAA7AAAADykDAAACAAAADy4AAAA6AAAADyoDAAACAAAADy0AAABfAAAADysDAAACAAAADzwAAAA+AAAADywDAAAAAAAADw8tAwAAAgAAAA+n////sP///w8uAwAAAgAAAA8xAAAAKwAAAA8vAwAAAgAAAA8yAAAAIgAAAA8wAwAAAgAAAA8zAAAAKgAAAA8xAwAAAgAAAA80AAAA5////w8yAwAAAgAAAA81AAAAJQAAAA8zAwAAAgAAAA82AAAAJgAAAA80AwAAAgAAAA83AAAALwAAAA81AwAAAgAAAA84AAAAKAAAAA82AwAAAgAAAA85AAAAKQAAAA83AwAAAgAAAA8wAAAAPQAAAA84AwAAAgAAAA8nAAAAPwAAAA85AwAAAgAAAA9eAAAAYAAAAA86AwAAAgAAAA9xAAAAUQAAAA87AwAAAgAAAA93AAAAVwAAAA88AwAAAgAAAA9lAAAARQAAAA89AwAAAgAAAA9yAAAAUgAAAA8+AwAAAgAAAA90AAAAVAAAAA8/AwAAAgAAAA96AAAAWgAAAA9AAwAAAgAAAA91AAAAVQAAAA9BAwAAAgAAAA9pAAAASQAAAA9CAwAAAgAAAA9vAAAATwAAAA9DAwAAAgAAAA9wAAAAUAAAAA9EAwAAAgAAAA/o/////P///w9FAwAAAgAAAA+o////IQAAAA9GAwAAAgAAAA9hAAAAQQAAAA9HAwAAAgAAAA9zAAAAUwAAAA9IAwAAAgAAAA9kAAAARAAAAA9JAwAAAgAAAA9mAAAARgAAAA9KAwAAAgAAAA9nAAAARwAAAA9LAwAAAgAAAA9oAAAASAAAAA9MAwAAAgAAAA9qAAAASgAAAA9NAwAAAgAAAA9rAAAASwAAAA9OAwAAAgAAAA9sAAAATAAAAA9PAwAAAgAAAA/p////9v///w9QAwAAAgAAAA/g////5P///w9RAwAAAgAAAA8kAAAAo////w9SAwAAAgAAAA95AAAAWQAAAA9TAwAAAgAAAA94AAAAWAAAAA9UAwAAAgAAAA9jAAAAQwAAAA9VAwAAAgAAAA92AAAAVgAAAA9WAwAAAgAAAA9iAAAAQgAAAA9XAwAAAgAAAA9uAAAATgAAAA9YAwAAAgAAAA9tAAAATQAAAA9ZAwAAAgAAAA8sAAAAOwAAAA9aAwAAAgAAAA8uAAAAOgAAAA9bAwAAAgAAAA8tAAAAXwAAAA9cAwAAAgAAAA88AAAAPgAAAA9dAwAAAAAAAA8PXgMAAAIAAAAPp////73///8PXwMAAAIAAAAPMQAAACEAAAAPYAMAAAIAAAAPMgAAACIAAAAPYQMAAAIAAAAPMwAAACMAAAAPYgMAAAIAAAAPNAAAAKT///8PYwMAAAIAAAAPNQAAACUAAAAPZAMAAAIAAAAPNgAAACYAAAAPZQMAAAIAAAAPNwAAAC8AAAAPZgMAAAIAAAAPOAAAACgAAAAPZwMAAAIAAAAPOQAAACkAAAAPaAMAAAIAAAAPMAAAAD0AAAAPaQMAAAIAAAAPKwAAAD8AAAAPagMAAAIAAAAPtP///2AAAAAPawMAAAIAAAAPcQAAAFEAAAAPbAMAAAIAAAAPdwAAAFcAAAAPbQMAAAIAAAAPZQAAAEUAAAAPbgMAAAIAAAAPcgAAAFIAAAAPbwMAAAIAAAAPdAAAAFQAAAAPcAMAAAIAAAAPeQAAAFkAAAAPcQMAAAIAAAAPdQAAAFUAAAAPcgMAAAIAAAAPaQAAAEkAAAAPcwMAAAIAAAAPbwAAAE8AAAAPdAMAAAIAAAAPcAAAAFAAAAAPdQMAAAIAAAAP5f///8X///8PdgMAAAIAAAAPqP///14AAAAPdwMAAAIAAAAPYQAAAEEAAAAPeAMAAAIAAAAPcwAAAFMAAAAPeQMAAAIAAAAPZAAAAEQAAAAPegMAAAIAAAAPZgAAAEYAAAAPewMAAAIAAAAPZwAAAEcAAAAPfAMAAAIAAAAPaAAAAEgAAAAPfQMAAAIAAAAPagAAAEoAAAAPfgMAAAIAAAAPawAAAEsAAAAPfwMAAAIAAAAPbAAAAEwAAAAPgAMAAAIAAAAP9v///9b///8PgQMAAAIAAAAP5P///8T///8PggMAAAIAAAAPJwAAACoAAAAPgwMAAAIAAAAPegAAAFoAAAAPhAMAAAIAAAAPeAAAAFgAAAAPhQMAAAIAAAAPYwAAAEMAAAAPhgMAAAIAAAAPdgAAAFYAAAAPhwMAAAIAAAAPYgAAAEIAAAAPiAMAAAIAAAAPbgAAAE4AAAAPiQMAAAIAAAAPbQAAAE0AAAAPigMAAAIAAAAPLAAAADsAAAAPiwMAAAIAAAAPLgAAADoAAAAPjAMAAAIAAAAPLQAAAF8AAAAPjQMAAAIAAAAPPAAAAD4AAAAPjgMAAAAAAAAPD48DAAACAAAAD7f///9+AAAAD5ADAAACAAAADzEAAAAhAAAAD5EDAAACAAAADzIAAAAiAAAAD5IDAAACAAAADzMAAAAjAAAAD5MDAAACAAAADzQAAACk////D5QDAAACAAAADzUAAAAlAAAAD5UDAAACAAAADzYAAAAmAAAAD5YDAAACAAAADzcAAAAvAAAAD5cDAAACAAAADzgAAAAoAAAAD5gDAAACAAAADzkAAAApAAAAD5kDAAACAAAADzAAAAA9AAAAD5oDAAACAAAADysAAAA/AAAAD5sDAAACAAAAD7T///9gAAAAD5wDAAACAAAAD3EAAABRAAAAD50DAAACAAAAD3cAAABXAAAAD54DAAACAAAAD2UAAABFAAAAD58DAAACAAAAD3IAAABSAAAAD6ADAAACAAAAD3QAAABUAAAAD6EDAAACAAAAD3kAAABZAAAAD6IDAAACAAAAD3UAAABVAAAAD6MDAAACAAAAD2kAAABJAAAAD6QDAAACAAAAD28AAABPAAAAD6UDAAACAAAAD3AAAABQAAAAD6YDAAACAAAAD/z////c////D6cDAAACAAAAD/X////V////D6gDAAACAAAAD2EAAABBAAAAD6kDAAACAAAAD3MAAABTAAAAD6oDAAACAAAAD2QAAABEAAAAD6sDAAACAAAAD2YAAABGAAAAD6wDAAACAAAAD2cAAABHAAAAD60DAAACAAAAD2gAAABIAAAAD64DAAACAAAAD2oAAABKAAAAD68DAAACAAAAD2sAAABLAAAAD7ADAAACAAAAD2wAAABMAAAAD7EDAAACAAAAD/b////W////D7IDAAACAAAAD+T////E////D7MDAAACAAAADycAAAAqAAAAD7QDAAACAAAAD3oAAABaAAAAD7UDAAACAAAAD3gAAABYAAAAD7YDAAACAAAAD2MAAABDAAAAD7cDAAACAAAAD3YAAABWAAAAD7gDAAACAAAAD2IAAABCAAAAD7kDAAACAAAAD24AAABOAAAAD7oDAAACAAAAD20AAABNAAAAD7sDAAACAAAADywAAAA7AAAAD7wDAAACAAAADy4AAAA6AAAAD70DAAACAAAADy0AAABfAAAAD74DAAACAAAADzwAAAA+AAAAD78DAAAAAAAADw/AAwAAAgAAAA98AAAAp////w/BAwAAAgAAAA8xAAAAIQAAAA/CAwAAAwAAAA8yAAAAIgAAAEAAAAAPwwMAAAMAAAAPMwAAACMAAACj////D8QDAAADAAAADzQAAACk////JAAAAA/FAwAAAgAAAA81AAAAJQAAAA/GAwAAAgAAAA82AAAAJgAAAA/HAwAAAwAAAA83AAAALwAAAHsAAAAPyAMAAAMAAAAPOAAAACgAAABbAAAAD8kDAAADAAAADzkAAAApAAAAXQAAAA/KAwAAAwAAAA8wAAAAPQAAAH0AAAAPywMAAAIAAAAPKwAAAD8AAAAPzAMAAAMAAAAPXAAAAGAAAAC0////D80DAAACAAAAD3EAAABRAAAAD84DAAACAAAAD3cAAABXAAAAD88DAAACAAAAD2UAAABFAAAAD9ADAAACAAAAD3IAAABSAAAAD9EDAAACAAAAD3QAAABUAAAAD9IDAAACAAAAD3kAAABZAAAAD9MDAAACAAAAD3UAAABVAAAAD9QDAAACAAAAD2kAAABJAAAAD9UDAAACAAAAD28AAABPAAAAD9YDAAACAAAAD3AAAABQAAAAD9cDAAACAAAAD+X////F////D9gDAAADAAAAD6j///9eAAAAfgAAAA/ZAwAAAgAAAA9hAAAAQQAAAA/aAwAAAgAAAA9zAAAAUwAAAA/bAwAAAgAAAA9kAAAARAAAAA/cAwAAAgAAAA9mAAAARgAAAA/dAwAAAgAAAA9nAAAARwAAAA/eAwAAAgAAAA9oAAAASAAAAA/fAwAAAgAAAA9qAAAASgAAAA/gAwAAAgAAAA9rAAAASwAAAA/hAwAAAgAAAA9sAAAATAAAAA/iAwAAAgAAAA/4////2P///w/jAwAAAgAAAA/m////xv///w/kAwAAAgAAAA8nAAAAKgAAAA/lAwAAAgAAAA96AAAAWgAAAA/mAwAAAgAAAA94AAAAWAAAAA/nAwAAAgAAAA9jAAAAQwAAAA/oAwAAAgAAAA92AAAAVgAAAA/pAwAAAgAAAA9iAAAAQgAAAA/qAwAAAgAAAA9uAAAATgAAAA/rAwAAAgAAAA9tAAAATQAAAA/sAwAAAgAAAA8sAAAAOwAAAA/tAwAAAgAAAA8uAAAAOgAAAA/uAwAAAgAAAA8tAAAAXwAAAA/vAwAAAgAAAA88AAAAPgAAAA/wAwAAAAAAAA8P8QMAAAIAAAAPvf///6f///8P8gMAAAIAAAAPMQAAACEAAAAP8wMAAAIAAAAPMgAAACIAAAAP9AMAAAIAAAAPMwAAACMAAAAP9QMAAAIAAAAPNAAAAKT///8P9gMAAAIAAAAPNQAAACUAAAAP9wMAAAIAAAAPNgAAACYAAAAP+AMAAAIAAAAPNwAAAC8AAAAP+QMAAAIAAAAPOAAAACgAAAAP+gMAAAIAAAAPOQAAACkAAAAP+wMAAAIAAAAPMAAAAD0AAAAP/AMAAAIAAAAPKwAAAD8AAAAP/QMAAAIAAAAPtP///2AAAAAP/gMAAAIAAAAPcQAAAFEAAAAP/wMAAAIAAAAPdwAAAFcAAAAPAAQAAAIAAAAPZQAAAEUAAAAPAQQAAAIAAAAPcgAAAFIAAAAPAgQAAAIAAAAPdAAAAFQAAAAPAwQAAAIAAAAPeQAAAFkAAAAPBAQAAAIAAAAPdQAAAFUAAAAPBQQAAAIAAAAPaQAAAEkAAAAPBgQAAAIAAAAPbwAAAE8AAAAPBwQAAAIAAAAPcAAAAFAAAAAPCAQAAAIAAAAP5f///8X///8PCQQAAAIAAAAPqP///14AAAAPCgQAAAIAAAAPYQAAAEEAAAAPCwQAAAIAAAAPcwAAAFMAAAAPDAQAAAIAAAAPZAAAAEQAAAAPDQQAAAIAAAAPZgAAAEYAAAAPDgQAAAIAAAAPZwAAAEcAAAAPDwQAAAIAAAAPaAAAAEgAAAAPEAQAAAIAAAAPagAAAEoAAAAPEQQAAAIAAAAPawAAAEsAAAAPEgQAAAIAAAAPbAAAAEwAAAAPEwQAAAIAAAAP5v///8b///8PFAQAAAIAAAAP+P///9j///8PFQQAAAIAAAAPJwAAACoAAAAPFgQAAAIAAAAPegAAAFoAAAAPFwQAAAIAAAAPeAAAAFgAAAAPGAQAAAIAAAAPYwAAAEMAAAAPGQQAAAIAAAAPdgAAAFYAAAAPGgQAAAIAAAAPYgAAAEIAAAAPGwQAAAIAAAAPbgAAAE4AAAAPHAQAAAIAAAAPbQAAAE0AAAAPHQQAAAIAAAAPLAAAADsAAAAPHgQAAAIAAAAPLgAAADoAAAAPHwQAAAIAAAAPLQAAAF8AAAAPIAQAAAIAAAAPPAAAAD4AAAAPIQQAAAAAAAAPDyIEAAABAAAAD7L///8PIwQAAAIAAAAPJgAAADEAAAAPJAQAAAMAAAAP6f///zIAAAB+AAAADyUEAAADAAAADyIAAAAzAAAAIwAAAA8mBAAAAwAAAA8nAAAANAAAAHsAAAAPJwQAAAMAAAAPKAAAADUAAABbAAAADygEAAADAAAADy0AAAA2AAAAfAAAAA8pBAAAAwAAAA/o////NwAAAGAAAAAPKgQAAAMAAAAPXwAAADgAAABcAAAADysEAAAEAAAAD+f///85AAAAXgAAALH///8PLAQAAAMAAAAP4P///zAAAABAAAAADy0EAAADAAAADykAAACw////XQAAAA8uBAAAAwAAAA89AAAAKwAAAH0AAAAPLwQAAAIAAAAPYQAAAEEAAAAPMAQAAAIAAAAPegAAAFoAAAAPMQQAAAMAAAAPZQAAAEUAAAC/////DzIEAAACAAAAD3IAAABSAAAADzMEAAACAAAAD3QAAABUAAAADzQEAAACAAAAD3kAAABZAAAADzUEAAACAAAAD3UAAABVAAAADzYEAAACAAAAD2kAAABJAAAADzcEAAACAAAAD28AAABPAAAADzgEAAACAAAAD3AAAABQAAAADzkEAAACAAAAD14AAACo////DzoEAAADAAAADyQAAACj////pP///w87BAAAAgAAAA9xAAAAUQAAAA88BAAAAwAAAA9zAAAAUwAAAN////8PPQQAAAIAAAAPZAAAAEQAAAAPPgQAAAIAAAAPZgAAAEYAAAAPPwQAAAIAAAAPZwAAAEcAAAAPQAQAAAIAAAAPaAAAAEgAAAAPQQQAAAIAAAAPagAAAEoAAAAPQgQAAAIAAAAPawAAAEsAAAAPQwQAAAIAAAAPbAAAAEwAAAAPRAQAAAIAAAAPbQAAAE0AAAAPRQQAAAIAAAAP+f///yUAAAAPRgQAAAIAAAAPKgAAALX///8PRwQAAAIAAAAPdwAAAFcAAAAPSAQAAAIAAAAPeAAAAFgAAAAPSQQAAAIAAAAPYwAAAEMAAAAPSgQAAAIAAAAPdgAAAFYAAAAPSwQAAAIAAAAPYgAAAEIAAAAPTAQAAAIAAAAPbgAAAE4AAAAPTQQAAAIAAAAPLAAAAD8AAAAPTgQAAAIAAAAPOwAAAC4AAAAPTwQAAAIAAAAPOgAAAC8AAAAPUAQAAAIAAAAPIQAAAKf///8PUQQAAAIAAAAPPAAAAD4AAAAPUgQAAAAAAAAPD1MEAAADAAAADyMAAAB8AAAAXAAAAA9UBAAAAwAAAA8xAAAAIQAAALH///8PVQQAAAMAAAAPMgAAACIAAABAAAAAD1YEAAADAAAADzMAAAAvAAAAo////w9XBAAAAwAAAA80AAAAJAAAAKL///8PWAQAAAMAAAAPNQAAACUAAACk////D1kEAAADAAAADzYAAAA/AAAArP///w9aBAAAAwAAAA83AAAAJgAAAKb///8PWwQAAAMAAAAPOAAAACoAAACy////D1wEAAADAAAADzkAAAAoAAAAs////w9dBAAAAwAAAA8wAAAAKQAAALz///8PXgQAAAMAAAAPLQAAAF8AAAC9////D18EAAADAAAADz0AAAArAAAAvv///w9gBAAAAgAAAA9xAAAAUQAAAA9hBAAAAgAAAA93AAAAVwAAAA9iBAAAAgAAAA9lAAAARQAAAA9jBAAAAgAAAA9yAAAAUgAAAA9kBAAAAgAAAA90AAAAVAAAAA9lBAAAAgAAAA95AAAAWQAAAA9mBAAAAgAAAA91AAAAVQAAAA9nBAAAAgAAAA9pAAAASQAAAA9oBAAAAwAAAA9vAAAATwAAAKf///8PaQQAAAMAAAAPcAAAAFAAAAC2////D2oEAAADAAAAD14AAABeAAAAWwAAAA9rBAAAAwAAAA+4////qP///10AAAAPbAQAAAIAAAAPYQAAAEEAAAAPbQQAAAIAAAAPcwAAAFMAAAAPbgQAAAIAAAAPZAAAAEQAAAAPbwQAAAIAAAAPZgAAAEYAAAAPcAQAAAIAAAAPZwAAAEcAAAAPcQQAAAIAAAAPaAAAAEgAAAAPcgQAAAIAAAAPagAAAEoAAAAPcwQAAAIAAAAPawAAAEsAAAAPdAQAAAIAAAAPbAAAAEwAAAAPdQQAAAMAAAAPOwAAADoAAAB+AAAAD3YEAAADAAAAD2AAAABgAAAAewAAAA93BAAAAwAAAA88AAAAPgAAAH0AAAAPeAQAAAIAAAAPegAAAFoAAAAPeQQAAAIAAAAPeAAAAFgAAAAPegQAAAIAAAAPYwAAAEMAAAAPewQAAAIAAAAPdgAAAFYAAAAPfAQAAAIAAAAPYgAAAEIAAAAPfQQAAAIAAAAPbgAAAE4AAAAPfgQAAAIAAAAPbQAAAE0AAAAPfwQAAAMAAAAPLAAAACcAAAAtAAAAD4AEAAABAAAADy4AAAAPgQQAAAIAAAAP6f///8n///8PggQAAAMAAAAPq////7v///+w////D4MEAAAAAAAADw+EBAAAAgAAAA8jAAAAfAAAAA+FBAAAAgAAAA8xAAAAIQAAAA+GBAAAAgAAAA8yAAAAIgAAAA+HBAAAAgAAAA8zAAAALwAAAA+IBAAAAgAAAA80AAAAJAAAAA+JBAAAAgAAAA81AAAAJQAAAA+KBAAAAgAAAA82AAAAPwAAAA+LBAAAAgAAAA83AAAAJgAAAA+MBAAAAgAAAA84AAAAKgAAAA+NBAAAAgAAAA85AAAAKAAAAA+OBAAAAgAAAA8wAAAAKQAAAA+PBAAAAgAAAA8tAAAAXwAAAA+QBAAAAgAAAA89AAAAKwAAAA+RBAAAAgAAAA9xAAAAUQAAAA+SBAAAAgAAAA93AAAAVwAAAA+TBAAAAgAAAA9lAAAARQAAAA+UBAAAAgAAAA9yAAAAUgAAAA+VBAAAAgAAAA90AAAAVAAAAA+WBAAAAgAAAA95AAAAWQAAAA+XBAAAAgAAAA91AAAAVQAAAA+YBAAAAgAAAA9pAAAASQAAAA+ZBAAAAgAAAA9vAAAATwAAAA+aBAAAAgAAAA9wAAAAUAAAAA+bBAAAAgAAAA9eAAAAXgAAAA+cBAAAAgAAAA+4////qP///w+dBAAAAgAAAA9hAAAAQQAAAA+eBAAAAgAAAA9zAAAAUwAAAA+fBAAAAgAAAA9kAAAARAAAAA+gBAAAAgAAAA9mAAAARgAAAA+hBAAAAgAAAA9nAAAARwAAAA+iBAAAAgAAAA9oAAAASAAAAA+jBAAAAgAAAA9qAAAASgAAAA+kBAAAAgAAAA9rAAAASwAAAA+lBAAAAgAAAA9sAAAATAAAAA+mBAAAAgAAAA87AAAAOgAAAA+nBAAAAgAAAA9gAAAAYAAAAA+oBAAAAgAAAA88AAAAPgAAAA+pBAAAAgAAAA96AAAAWgAAAA+qBAAAAgAAAA94AAAAWAAAAA+rBAAAAgAAAA9jAAAAQwAAAA+sBAAAAgAAAA92AAAAVgAAAA+tBAAAAgAAAA9iAAAAQgAAAA+uBAAAAgAAAA9uAAAATgAAAA+vBAAAAgAAAA9tAAAATQAAAA+wBAAAAgAAAA8sAAAAJwAAAA+xBAAAAQAAAA8uAAAAD7IEAAACAAAAD+n////J////D7MEAAACAAAAD6v///+7////D7QEAAAAAAAADw+1BAAAAgAAAA8vAAAAXAAAAA+2BAAABAAAAA8xAAAAIQAAALn///+h////D7cEAAADAAAADzIAAABAAAAAsv///w+4BAAABAAAAA8zAAAAIwAAALP///+j////D7kEAAAEAAAADzQAAAAkAAAAvP///6T///8PugQAAAMAAAAPNQAAACUAAAC9////D7sEAAADAAAADzYAAAA/AAAAvv///w+8BAAAAgAAAA83AAAAJgAAAA+9BAAAAgAAAA84AAAAKgAAAA++BAAAAgAAAA85AAAAKAAAAA+/BAAAAgAAAA8wAAAAKQAAAA/ABAAAAgAAAA8tAAAAXwAAAA/BBAAAAgAAAA89AAAAKwAAAA/CBAAAAgAAAA9xAAAAUQAAAA/DBAAAAgAAAA93AAAAVwAAAA/EBAAAAgAAAA9lAAAARQAAAA/FBAAAAgAAAA9yAAAAUgAAAA/GBAAAAgAAAA90AAAAVAAAAA/HBAAAAgAAAA95AAAAWQAAAA/IBAAAAgAAAA91AAAAVQAAAA/JBAAAAgAAAA9pAAAASQAAAA/KBAAABAAAAA9vAAAATwAAAPj////Y////D8sEAAAEAAAAD3AAAABQAAAA/v///97///8PzAQAAAMAAAAPXgAAAKj///+o////D80EAAADAAAAD+f////H////fgAAAA/OBAAABAAAAA9hAAAAQQAAAOb////G////D88EAAAEAAAAD3MAAABTAAAA3////6f///8P0AQAAAQAAAAPZAAAAEQAAADw////0P///w/RBAAAAgAAAA9mAAAARgAAAA/SBAAAAgAAAA9nAAAARwAAAA/TBAAAAgAAAA9oAAAASAAAAA/UBAAAAgAAAA9qAAAASgAAAA/VBAAAAgAAAA9rAAAASwAAAA/WBAAAAgAAAA9sAAAATAAAAA/XBAAAAwAAAA87AAAAOgAAALT///8P2AQAAAIAAAAP6P///8j///8P2QQAAAIAAAAP4P///8D///8P2gQAAAIAAAAPegAAAFoAAAAP2wQAAAIAAAAPeAAAAFgAAAAP3AQAAAQAAAAPYwAAAEMAAACi////qf///w/dBAAAAgAAAA92AAAAVgAAAA/eBAAAAgAAAA9iAAAAQgAAAA/fBAAAAgAAAA9uAAAATgAAAA/gBAAABAAAAA9tAAAATQAAALX///+6////D+EEAAACAAAADywAAAAnAAAAD+IEAAAEAAAADy4AAAAiAAAAt/////f///8P4wQAAAIAAAAP6f///8n///8P5AQAAAIAAAAP+f///9n///8P5QQAAAAAAAAPD+YEAAAAAAAADw/nBAAAAwAAAA8mAAAAMQAAAHwAAAAP6AQAAAMAAAAP6f///zIAAABAAAAAD+kEAAADAAAADyIAAAAzAAAAIwAAAA/qBAAAAgAAAA8nAAAANAAAAA/rBAAAAgAAAA8oAAAANQAAAA/sBAAAAwAAAA+n////NgAAAF4AAAAP7QQAAAIAAAAP6P///zcAAAAP7gQAAAIAAAAPIQAAADgAAAAP7wQAAAMAAAAP5////zkAAAB7AAAAD/AEAAADAAAAD+D///8wAAAAfQAAAA/xBAAAAgAAAA8pAAAAsP///w/yBAAAAgAAAA8tAAAAXwAAAA/zBAAAAgAAAA9hAAAAQQAAAA/0BAAAAgAAAA96AAAAWgAAAA/1BAAAAwAAAA9lAAAARQAAAKT///8P9gQAAAIAAAAPcgAAAFIAAAAP9wQAAAIAAAAPdAAAAFQAAAAP+AQAAAIAAAAPeQAAAFkAAAAP+QQAAAIAAAAPdQAAAFUAAAAP+gQAAAIAAAAPaQAAAEkAAAAP+wQAAAIAAAAPbwAAAE8AAAAP/AQAAAIAAAAPcAAAAFAAAAAP/QQAAAMAAAAPXgAAAKj///9bAAAAD/4EAAADAAAADyQAAAAqAAAAXQAAAA//BAAAAgAAAA9xAAAAUQAAAA8ABQAAAwAAAA9zAAAAUwAAAN////8PAQUAAAIAAAAPZAAAAEQAAAAPAgUAAAIAAAAPZgAAAEYAAAAPAwUAAAIAAAAPZwAAAEcAAAAPBAUAAAIAAAAPaAAAAEgAAAAPBQUAAAIAAAAPagAAAEoAAAAPBgUAAAIAAAAPawAAAEsAAAAPBwUAAAIAAAAPbAAAAEwAAAAPCAUAAAIAAAAPbQAAAE0AAAAPCQUAAAMAAAAP+f///yUAAAC0////DwoFAAADAAAAD7X///+j////YAAAAA8LBQAAAgAAAA93AAAAVwAAAA8MBQAAAgAAAA94AAAAWAAAAA8NBQAAAgAAAA9jAAAAQwAAAA8OBQAAAgAAAA92AAAAVgAAAA8PBQAAAgAAAA9iAAAAQgAAAA8QBQAAAgAAAA9uAAAATgAAAA8RBQAAAgAAAA8sAAAAPwAAAA8SBQAAAgAAAA87AAAALgAAAA8TBQAAAgAAAA86AAAALwAAAA8UBQAAAwAAAA89AAAAKwAAAH4AAAAPFQUAAAMAAAAPPAAAAD4AAABcAAAADxYFAAAAAAAADw8XBQAAAgAAAA9cAAAAfAAAAA8YBQAAAgAAAA8xAAAAIQAAAA8ZBQAAAgAAAA8yAAAAIgAAAA8aBQAAAgAAAA8zAAAAIwAAAA8bBQAAAgAAAA80AAAAJAAAAA8cBQAAAgAAAA81AAAAJQAAAA8dBQAAAgAAAA82AAAAJgAAAA8eBQAAAgAAAA83AAAALwAAAA8fBQAAAgAAAA84AAAAKAAAAA8gBQAAAgAAAA85AAAAKQAAAA8hBQAAAgAAAA8wAAAAPQAAAA8iBQAAAgAAAA8nAAAAPwAAAA8jBQAAAgAAAA+r////u////w8kBQAAAgAAAA9xAAAAUQAAAA8lBQAAAgAAAA93AAAAVwAAAA8mBQAAAgAAAA9lAAAARQAAAA8nBQAAAgAAAA9yAAAAUgAAAA8oBQAAAgAAAA90AAAAVAAAAA8pBQAAAgAAAA95AAAAWQAAAA8qBQAAAgAAAA91AAAAVQAAAA8rBQAAAgAAAA9pAAAASQAAAA8sBQAAAgAAAA9vAAAATwAAAA8tBQAAAgAAAA9wAAAAUAAAAA8uBQAAAgAAAA8rAAAAKgAAAA8vBQAAAgAAAA+0////YAAAAA8wBQAAAgAAAA9hAAAAQQAAAA8xBQAAAgAAAA9zAAAAUwAAAA8yBQAAAgAAAA9kAAAARAAAAA8zBQAAAgAAAA9mAAAARgAAAA80BQAAAgAAAA9nAAAARwAAAA81BQAAAgAAAA9oAAAASAAAAA82BQAAAgAAAA9qAAAASgAAAA83BQAAAgAAAA9rAAAASwAAAA84BQAAAgAAAA9sAAAATAAAAA85BQAAAgAAAA/n////x////w86BQAAAgAAAA+6////qv///w87BQAAAgAAAA9+AAAAXgAAAA88BQAAAgAAAA96AAAAWgAAAA89BQAAAgAAAA94AAAAWAAAAA8+BQAAAgAAAA9jAAAAQwAAAA8/BQAAAgAAAA92AAAAVgAAAA9ABQAAAgAAAA9iAAAAQgAAAA9BBQAAAgAAAA9uAAAATgAAAA9CBQAAAgAAAA9tAAAATQAAAA9DBQAAAgAAAA8sAAAAOwAAAA9EBQAAAgAAAA8uAAAAOgAAAA9FBQAAAgAAAA8tAAAAXwAAAA9GBQAAAgAAAA88AAAAPgAAAA9HBQAAAAAAAA8PSAUAAAIAAAAPJwAAACIAAAAPSQUAAAIAAAAPMQAAACEAAAAPSgUAAAIAAAAPMgAAAEAAAAAPSwUAAAIAAAAPMwAAACMAAAAPTAUAAAIAAAAPNAAAACQAAAAPTQUAAAIAAAAPNQAAACUAAAAPTgUAAAIAAAAPNgAAAKj///8PTwUAAAIAAAAPNwAAACYAAAAPUAUAAAIAAAAPOAAAACoAAAAPUQUAAAIAAAAPOQAAACgAAAAPUgUAAAIAAAAPMAAAACkAAAAPUwUAAAIAAAAPLQAAAF8AAAAPVAUAAAIAAAAPPQAAACsAAAAPVQUAAAIAAAAPcQAAAFEAAAAPVgUAAAIAAAAPdwAAAFcAAAAPVwUAAAIAAAAPZQAAAEUAAAAPWAUAAAIAAAAPcgAAAFIAAAAPWQUAAAIAAAAPdAAAAFQAAAAPWgUAAAIAAAAPeQAAAFkAAAAPWwUAAAIAAAAPdQAAAFUAAAAPXAUAAAIAAAAPaQAAAEkAAAAPXQUAAAIAAAAPbwAAAE8AAAAPXgUAAAIAAAAPcAAAAFAAAAAPXwUAAAIAAAAPtP///2AAAAAPYAUAAAIAAAAPWwAAAHsAAAAPYQUAAAIAAAAPYQAAAEEAAAAPYgUAAAIAAAAPcwAAAFMAAAAPYwUAAAIAAAAPZAAAAEQAAAAPZAUAAAIAAAAPZgAAAEYAAAAPZQUAAAIAAAAPZwAAAEcAAAAPZgUAAAIAAAAPaAAAAEgAAAAPZwUAAAIAAAAPagAAAEoAAAAPaAUAAAIAAAAPawAAAEsAAAAPaQUAAAIAAAAPbAAAAEwAAAAPagUAAAIAAAAP5////8f///8PawUAAAIAAAAPfgAAAF4AAAAPbAUAAAIAAAAPXQAAAH0AAAAPbQUAAAIAAAAPXAAAAHwAAAAPbgUAAAIAAAAPegAAAFoAAAAPbwUAAAIAAAAPeAAAAFgAAAAPcAUAAAIAAAAPYwAAAEMAAAAPcQUAAAIAAAAPdgAAAFYAAAAPcgUAAAIAAAAPYgAAAEIAAAAPcwUAAAIAAAAPbgAAAE4AAAAPdAUAAAIAAAAPbQAAAE0AAAAPdQUAAAIAAAAPLAAAADwAAAAPdgUAAAIAAAAPLgAAAD4AAAAPdwUAAAIAAAAPOwAAADoAAAAPeAUAAAIAAAAPLwAAAD8AAAAPeQUAAAIAAAAPJwAAACIAAAAPegUAAAMAAAAPMQAAACEAAAA5AAAAD3sFAAADAAAADzIAAABAAAAAMgAAAA98BQAAAwAAAA8zAAAAIwAAADMAAAAPfQUAAAMAAAAPNAAAACQAAAAjAAAAD34FAAADAAAADzUAAAAlAAAAIgAAAA9/BQAAAwAAAA82AAAAKAAAACwAAAAPgAUAAAIAAAAPNwAAACYAAAAPgQUAAAIAAAAPOAAAACoAAAAPggUAAAIAAAAPOQAAACgAAAAPgwUAAAIAAAAPMAAAACkAAAAPhAUAAAIAAAAPLQAAAF8AAAAPhQUAAAMAAAAPPQAAACsAAAAnAAAAD4YFAAACAAAAD3EAAABRAAAAD4cFAAACAAAAD3cAAABXAAAAD4gFAAACAAAAD2UAAABFAAAAD4kFAAACAAAAD3IAAABSAAAAD4oFAAACAAAAD3QAAABUAAAAD4sFAAACAAAAD3kAAABZAAAAD4wFAAACAAAAD3UAAABVAAAAD40FAAACAAAAD2kAAABJAAAAD44FAAACAAAAD28AAABPAAAAD48FAAACAAAAD3AAAABQAAAAD5AFAAACAAAADzQAAABgAAAAD5EFAAADAAAAD1sAAAB7AAAAKgAAAA+SBQAAAgAAAA9hAAAAQQAAAA+TBQAAAgAAAA9zAAAAUwAAAA+UBQAAAgAAAA9kAAAARAAAAA+VBQAAAgAAAA9mAAAARgAAAA+WBQAAAgAAAA9nAAAARwAAAA+XBQAAAgAAAA9oAAAASAAAAA+YBQAAAgAAAA9qAAAASgAAAA+ZBQAAAgAAAA9rAAAASwAAAA+aBQAAAgAAAA9sAAAATAAAAA+bBQAAAgAAAA9nAAAARwAAAA+cBQAAAgAAAA9+AAAAXgAAAA+dBQAAAwAAAA9dAAAAfQAAADoAAAAPngUAAAIAAAAPXAAAAHwAAAAPnwUAAAIAAAAPegAAAFoAAAAPoAUAAAIAAAAPeAAAAFgAAAAPoQUAAAIAAAAPYwAAAEMAAAAPogUAAAIAAAAPdgAAAFYAAAAPowUAAAIAAAAPYgAAAEIAAAAPpAUAAAIAAAAPbgAAAE4AAAAPpQUAAAIAAAAPbQAAAE0AAAAPpgUAAAIAAAAPLAAAADwAAAAPpwUAAAIAAAAPLgAAAD4AAAAPqAUAAAIAAAAPOwAAADoAAAAPqQUAAAMAAAAPLwAAAD8AAAAwAAAAD6oFAAACAAAAD6f///+9////D6sFAAACAAAADzEAAAAhAAAAD6wFAAACAAAADzIAAAAiAAAAD60FAAACAAAADzMAAAAjAAAAD64FAAACAAAADzQAAACk////D68FAAACAAAADzUAAAAlAAAAD7AFAAACAAAADzYAAAAmAAAAD7EFAAACAAAADzcAAAAvAAAAD7IFAAACAAAADzgAAAAoAAAAD7MFAAACAAAADzkAAAApAAAAD7QFAAACAAAADzAAAAA9AAAAD7UFAAACAAAADysAAAA/AAAAD7YFAAACAAAAD7T///9gAAAAD7cFAAACAAAAD3EAAABRAAAAD7gFAAACAAAAD3cAAABXAAAAD7kFAAACAAAAD2UAAABFAAAAD7oFAAACAAAAD3IAAABSAAAAD7sFAAACAAAAD3QAAABUAAAAD7wFAAACAAAAD3kAAABZAAAAD70FAAACAAAAD3UAAABVAAAAD74FAAACAAAAD2kAAABJAAAAD78FAAACAAAAD28AAABPAAAAD8AFAAACAAAAD3AAAABQAAAAD8EFAAACAAAAD+X////F////D8IFAAACAAAAD6j///9eAAAAD8MFAAACAAAAD2EAAABBAAAAD8QFAAACAAAAD3MAAABTAAAAD8UFAAACAAAAD2QAAABEAAAAD8YFAAACAAAAD2YAAABGAAAAD8cFAAACAAAAD2cAAABHAAAAD8gFAAACAAAAD2gAAABIAAAAD8kFAAACAAAAD2oAAABKAAAAD8oFAAACAAAAD2sAAABLAAAAD8sFAAACAAAAD2wAAABMAAAAD8wFAAACAAAAD/b////W////D80FAAACAAAAD+T////E////D84FAAACAAAADycAAAAqAAAAD88FAAACAAAAD3oAAABaAAAAD9AFAAACAAAAD3gAAABYAAAAD9EFAAACAAAAD2MAAABDAAAAD9IFAAACAAAAD3YAAABWAAAAD9MFAAACAAAAD2IAAABCAAAAD9QFAAACAAAAD24AAABOAAAAD9UFAAACAAAAD20AAABNAAAAD9YFAAACAAAADywAAAA7AAAAD9cFAAACAAAADy4AAAA6AAAAD9gFAAACAAAADy0AAABfAAAAD9kFAAACAAAADzwAAAA+AAAAD9oFAAAAAAAADw/bBQAABAAAAA9gAAAAfgAAACgAAAApAAAAD9wFAAACAAAADzEAAAAhAAAAD90FAAAEAAAADzIAAABAAAAAMgAAAD8AAAAP3gUAAAQAAAAPMwAAACMAAAAzAAAAKwAAAA/fBQAABAAAAA80AAAAJAAAADQAAAAiAAAAD+AFAAACAAAADzUAAAAlAAAAD+EFAAAEAAAADzYAAABeAAAANgAAAD0AAAAP4gUAAAQAAAAPNwAAACYAAAA3AAAAOgAAAA/jBQAABAAAAA84AAAAKgAAADgAAAAvAAAAD+QFAAACAAAADzkAAAAoAAAAD+UFAAACAAAADzAAAAApAAAAD+YFAAAEAAAADy0AAABfAAAALQAAAEkAAAAP5wUAAAQAAAAPPQAAACsAAAAuAAAAVgAAAA/oBQAABAAAAA9xAAAAUQAAACwAAAD7////D+kFAAAEAAAAD3cAAABXAAAA8////9P///8P6gUAAAQAAAAPZQAAAEUAAADl////xf///w/rBQAABAAAAA9yAAAAUgAAAOj////I////D+wFAAAEAAAAD3QAAABUAAAA+P///9j///8P7QUAAAQAAAAPeQAAAFkAAAD5////2f///w/uBQAABAAAAA91AAAAVQAAAOr////K////D+8FAAAEAAAAD2kAAABJAAAA8f///9H///8P8AUAAAQAAAAPbwAAAE8AAADk////xP///w/xBQAABAAAAA9wAAAAUAAAAOf////H////D/IFAAAEAAAAD1sAAAB7AAAA9v///9b///8P8wUAAAMAAAAPXQAAAH0AAAA7AAAAD/QFAAAEAAAAD2EAAABBAAAA/P///9z///8P9QUAAAQAAAAPcwAAAFMAAAD/////3////w/2BQAABAAAAA9kAAAARAAAAOD////A////D/cFAAAEAAAAD2YAAABGAAAA7v///87///8P+AUAAAQAAAAPZwAAAEcAAADm////xv///w/5BQAABAAAAA9oAAAASAAAAOP////D////D/oFAAAEAAAAD2oAAABKAAAA8v///9L///8P+wUAAAQAAAAPawAAAEsAAADt////zf///w/8BQAABAAAAA9sAAAATAAAAOL////C////D/0FAAAEAAAADzsAAAA6AAAA7P///8z///8P/gUAAAQAAAAPJwAAACIAAAD3////1////w//BQAABAAAAA9cAAAAfAAAACcAAADb////DwAGAAAEAAAAD3oAAABaAAAA/v///97///8PAQYAAAQAAAAPeAAAAFgAAADp////yf///w8CBgAABAAAAA9jAAAAQwAAAPr////a////DwMGAAAEAAAAD3YAAABWAAAA/f///93///8PBAYAAAQAAAAPYgAAAEIAAAD0////1P///w8FBgAABAAAAA9uAAAATgAAAPX////V////DwYGAAAEAAAAD20AAABNAAAA7////8////8PBwYAAAQAAAAPLAAAADwAAADw////0P///w8IBgAABAAAAA8uAAAAPgAAAOv////L////DwkGAAAEAAAADy8AAAA/AAAA4f///8H///8PCgYAAAIAAAAPPAAAAD4AAAAPCwYAAAAAAAAPDwwGAAAEAAAAD2AAAAB+AAAA9////9f///8PDQYAAAIAAAAPMQAAACEAAAAPDgYAAAIAAAAPMgAAAEAAAAAPDwYAAAIAAAAPMwAAACMAAAAPEAYAAAIAAAAPNAAAACQAAAAPEQYAAAIAAAAPNQAAACUAAAAPEgYAAAIAAAAPNgAAAF4AAAAPEwYAAAIAAAAPNwAAACYAAAAPFAYAAAIAAAAPOAAAACoAAAAPFQYAAAIAAAAPOQAAACgAAAAPFgYAAAIAAAAPMAAAACkAAAAPFwYAAAIAAAAPLQAAAF8AAAAPGAYAAAIAAAAPPQAAACsAAAAPGQYAAAQAAAAPcQAAAFEAAAD/////3////w8aBgAABAAAAA93AAAAVwAAAOL////C////DxsGAAAEAAAAD2UAAABFAAAA5f///8X///8PHAYAAAQAAAAPcgAAAFIAAADw////0P///w8dBgAABAAAAA90AAAAVAAAAPL////S////Dx4GAAAEAAAAD3kAAABZAAAA+v///9r///8PHwYAAAQAAAAPdQAAAFUAAADz////0////w8gBgAABAAAAA9pAAAASQAAAOj////I////DyEGAAAEAAAAD28AAABPAAAA7v///87///8PIgYAAAQAAAAPcAAAAFAAAADv////z////w8jBgAABAAAAA9bAAAAewAAAPj////Y////DyQGAAAEAAAAD10AAAB9AAAA+f///9n///8PJQYAAAQAAAAPYQAAAEEAAADg////wP///w8mBgAABAAAAA9zAAAAUwAAAPH////R////DycGAAAEAAAAD2QAAABEAAAA5P///8T///8PKAYAAAQAAAAPZgAAAEYAAAD0////1P///w8pBgAABAAAAA9nAAAARwAAAOP////D////DyoGAAAEAAAAD2gAAABIAAAA9f///9X///8PKwYAAAQAAAAPagAAAEoAAADp////yf///w8sBgAABAAAAA9rAAAASwAAAOr////K////Dy0GAAAEAAAAD2wAAABMAAAA6////8v///8PLgYAAAIAAAAPOwAAADoAAAAPLwYAAAIAAAAPJwAAACIAAAAPMAYAAAQAAAAPXAAAAHwAAAD+////3v///w8xBgAABAAAAA96AAAAWgAAAOf////H////DzIGAAAEAAAAD3gAAABYAAAA/P///9z///8PMwYAAAQAAAAPYwAAAEMAAAD2////1v///w80BgAABAAAAA92AAAAVgAAAOb////G////DzUGAAAEAAAAD2IAAABCAAAA4f///8H///8PNgYAAAQAAAAPbgAAAE4AAADt////zf///w83BgAABAAAAA9tAAAATQAAAOz////M////DzgGAAACAAAADywAAAA8AAAADzkGAAACAAAADy4AAAA+AAAADzoGAAACAAAADy8AAAA/AAAADzsGAAACAAAADzwAAAA+AAAADzwGAAAAAAAADw89BgAABAAAAA9gAAAAfgAAAKP///+z////Dz4GAAACAAAADzEAAAAhAAAADz8GAAACAAAADzIAAABAAAAAD0AGAAACAAAADzMAAAAjAAAAD0EGAAACAAAADzQAAAAkAAAAD0IGAAACAAAADzUAAAAlAAAAD0MGAAACAAAADzYAAABeAAAAD0QGAAACAAAADzcAAAAmAAAAD0UGAAACAAAADzgAAAAqAAAAD0YGAAACAAAADzkAAAAoAAAAD0cGAAACAAAADzAAAAApAAAAD0gGAAACAAAADy0AAABfAAAAD0kGAAACAAAADz0AAAArAAAAD0oGAAAEAAAAD3EAAABRAAAAyv///+r///8PSwYAAAQAAAAPdwAAAFcAAADD////4////w9MBgAABAAAAA9lAAAARQAAANX////1////D00GAAAEAAAAD3IAAABSAAAAy////+v///8PTgYAAAQAAAAPdAAAAFQAAADF////5f///w9PBgAABAAAAA95AAAAWQAAAM7////u////D1AGAAAEAAAAD3UAAABVAAAAx////+f///8PUQYAAAQAAAAPaQAAAEkAAADb////+////w9SBgAABAAAAA9vAAAATwAAAK7///++////D1MGAAAEAAAAD3AAAABQAAAA2v////r///8PVAYAAAQAAAAPWwAAAHsAAADI////6P///w9VBgAABAAAAA9dAAAAfQAAACcAAAAnAAAAD1YGAAAEAAAAD2EAAABBAAAAxv///+b///8PVwYAAAQAAAAPcwAAAFMAAADZ////+f///w9YBgAABAAAAA9kAAAARAAAANf////3////D1kGAAAEAAAAD2YAAABGAAAAwf///+H///8PWgYAAAQAAAAPZwAAAEcAAADQ////8P///w9bBgAABAAAAA9oAAAASAAAANL////y////D1wGAAAEAAAAD2oAAABKAAAAz////+////8PXQYAAAQAAAAPawAAAEsAAADM////7P///w9eBgAABAAAAA9sAAAATAAAAMT////k////D18GAAAEAAAADzsAAAA6AAAA1v////b///8PYAYAAAQAAAAPJwAAACIAAADc/////P///w9hBgAABAAAAA9cAAAAfAAAAC8AAAB8AAAAD2IGAAAEAAAAD3oAAABaAAAA0f////H///8PYwYAAAQAAAAPeAAAAFgAAADe/////v///w9kBgAABAAAAA9jAAAAQwAAANP////z////D2UGAAAEAAAAD3YAAABWAAAAzf///+3///8PZgYAAAQAAAAPYgAAAEIAAACm////tv///w9nBgAABAAAAA9uAAAATgAAANT////0////D2gGAAAEAAAAD20AAABNAAAA2P////j///8PaQYAAAQAAAAPLAAAADwAAADC////4v///w9qBgAABAAAAA8uAAAAPgAAAMD////g////D2sGAAAEAAAADy8AAAA/AAAALgAAACwAAAAPbAYAAAQAAAAPPAAAAD4AAAB8AAAApv///w9tBgAAAAAAAA8PbgYAAAIAAAAPYAAAAH4AAAAPbwYAAAIAAAAPMQAAACEAAAAPcAYAAAIAAAAPMgAAAEAAAAAPcQYAAAIAAAAPMwAAACMAAAAPcgYAAAIAAAAPNAAAACQAAAAPcwYAAAIAAAAPNQAAACUAAAAPdAYAAAIAAAAPNgAAAF4AAAAPdQYAAAIAAAAPNwAAACYAAAAPdgYAAAIAAAAPOAAAACoAAAAPdwYAAAIAAAAPOQAAACgAAAAPeAYAAAIAAAAPMAAAACkAAAAPeQYAAAIAAAAPLQAAAF8AAAAPegYAAAIAAAAPPQAAACsAAAAPewYAAAQAAAAPcQAAAFEAAADK////6v///w98BgAABAAAAA93AAAAVwAAAMP////j////D30GAAAEAAAAD2UAAABFAAAA1f////X///8PfgYAAAQAAAAPcgAAAFIAAADL////6////w9/BgAABAAAAA90AAAAVAAAAMX////l////D4AGAAAEAAAAD3kAAABZAAAAzv///+7///8PgQYAAAQAAAAPdQAAAFUAAADH////5////w+CBgAABAAAAA9pAAAASQAAANv////7////D4MGAAAEAAAAD28AAABPAAAA3f////3///8PhAYAAAQAAAAPcAAAAFAAAADa////+v///w+FBgAABAAAAA9bAAAAewAAAMj////o////D4YGAAAEAAAAD10AAAB9AAAA3/////////8PhwYAAAQAAAAPYQAAAEEAAADG////5v///w+IBgAABAAAAA9zAAAAUwAAANn////5////D4kGAAAEAAAAD2QAAABEAAAA1/////f///8PigYAAAQAAAAPZgAAAEYAAADB////4f///w+LBgAABAAAAA9nAAAARwAAAND////w////D4wGAAAEAAAAD2gAAABIAAAA0v////L///8PjQYAAAQAAAAPagAAAEoAAADP////7////w+OBgAABAAAAA9rAAAASwAAAMz////s////D48GAAAEAAAAD2wAAABMAAAAxP///+T///8PkAYAAAQAAAAPOwAAADoAAADW////9v///w+RBgAABAAAAA8nAAAAIgAAANz////8////D5IGAAACAAAAD1wAAAB8AAAAD5MGAAAEAAAAD3oAAABaAAAA0f////H///8PlAYAAAQAAAAPeAAAAFgAAADe/////v///w+VBgAABAAAAA9jAAAAQwAAANP////z////D5YGAAAEAAAAD3YAAABWAAAAzf///+3///8PlwYAAAQAAAAPYgAAAEIAAADJ////6f///w+YBgAABAAAAA9uAAAATgAAANT////0////D5kGAAAEAAAAD20AAABNAAAA2P////j///8PmgYAAAQAAAAPLAAAADwAAADC////4v///w+bBgAABAAAAA8uAAAAPgAAAMD////g////D5wGAAACAAAADy8AAAA/AAAAD50GAAAAAAAADw+eBgAAAAAAAA8PnwYAAAIAAAAPYAAAAH4AAAAPoAYAAAIAAAAPMQAAACEAAAAPoQYAAAIAAAAPMgAAAEAAAAAPogYAAAIAAAAPMwAAACMAAAAPowYAAAIAAAAPNAAAACQAAAAPpAYAAAIAAAAPNQAAACUAAAAPpQYAAAIAAAAPNgAAAF4AAAAPpgYAAAIAAAAPNwAAACYAAAAPpwYAAAIAAAAPOAAAACoAAAAPqAYAAAIAAAAPOQAAACgAAAAPqQYAAAIAAAAPMAAAACkAAAAPqgYAAAIAAAAPLQAAAF8AAAAPqwYAAAIAAAAPPQAAACsAAAAPrAYAAAQAAAAPcQAAAFEAAADK////6v///w+tBgAABAAAAA93AAAAVwAAAMP////j////D64GAAAEAAAAD2UAAABFAAAA1f////X///8PrwYAAAQAAAAPcgAAAFIAAADL////6////w+wBgAABAAAAA90AAAAVAAAAMX////l////D7EGAAAEAAAAD3kAAABZAAAAzv///+7///8PsgYAAAQAAAAPdQAAAFUAAADH////5////w+zBgAABAAAAA9pAAAASQAAANv////7////D7QGAAAEAAAAD28AAABPAAAA3f////3///8PtQYAAAQAAAAPcAAAAFAAAADa////+v///w+2BgAABAAAAA9bAAAAewAAAMj////o////D7cGAAAEAAAAD10AAAB9AAAA3/////////8PuAYAAAQAAAAPYQAAAEEAAADG////5v///w+5BgAABAAAAA9zAAAAUwAAANn////5////D7oGAAAEAAAAD2QAAABEAAAA1/////f///8PuwYAAAQAAAAPZgAAAEYAAADB////4f///w+8BgAABAAAAA9nAAAARwAAAND////w////D70GAAAEAAAAD2gAAABIAAAA0v////L///8PvgYAAAQAAAAPagAAAEoAAADP////7////w+/BgAABAAAAA9rAAAASwAAAMz////s////D8AGAAAEAAAAD2wAAABMAAAAxP///+T///8PwQYAAAQAAAAPOwAAADoAAADW////9v///w/CBgAABAAAAA8nAAAAIgAAANz////8////D8MGAAACAAAAD1wAAAB8AAAAD8QGAAAEAAAAD3oAAABaAAAA0f////H///8PxQYAAAQAAAAPeAAAAFgAAADe/////v///w/GBgAABAAAAA9jAAAAQwAAANP////z////D8cGAAAEAAAAD3YAAABWAAAAzf///+3///8PyAYAAAQAAAAPYgAAAEIAAADJ////6f///w/JBgAABAAAAA9uAAAATgAAANT////0////D8oGAAAEAAAAD20AAABNAAAA2P////j///8PywYAAAQAAAAPLAAAADwAAADC////4v///w/MBgAABAAAAA8uAAAAPgAAAMD////g////D80GAAACAAAADy8AAAA/AAAAD84GAAACAAAADzwAAAA+AAAAD88GAAAAAAAADw/QBgAAAgAAAA8oAAAAKQAAAA/RBgAAAgAAAA8xAAAAIQAAAA/SBgAAAgAAAA8yAAAAIgAAAA/TBgAAAgAAAA8zAAAALwAAAA/UBgAAAgAAAA80AAAAJAAAAA/VBgAAAgAAAA81AAAAOgAAAA/WBgAAAgAAAA82AAAALAAAAA/XBgAAAgAAAA83AAAALgAAAA/YBgAAAgAAAA84AAAAOwAAAA/ZBgAAAgAAAA85AAAAPwAAAA/aBgAAAgAAAA8wAAAAJQAAAA/bBgAAAgAAAA8tAAAAXwAAAA/cBgAAAgAAAA89AAAAKwAAAA/dBgAAAgAAAA/K////6v///w/eBgAAAgAAAA/D////4////w/fBgAAAgAAAA/V////9f///w/gBgAAAgAAAA/L////6////w/hBgAAAgAAAA/F////5f///w/iBgAAAgAAAA/O////7v///w/jBgAAAgAAAA/H////5////w/kBgAAAgAAAA/b////+////w/lBgAAAgAAAA/d/////f///w/mBgAAAgAAAA/a////+v///w/nBgAAAgAAAA/I////6P///w/oBgAAAgAAAA/f/////////w/pBgAAAgAAAA/G////5v///w/qBgAAAgAAAA/Z////+f///w/rBgAAAgAAAA/X////9////w/sBgAAAgAAAA/B////4f///w/tBgAAAgAAAA/Q////8P///w/uBgAAAgAAAA/S////8v///w/vBgAAAgAAAA/P////7////w/wBgAAAgAAAA/M////7P///w/xBgAAAgAAAA/E////5P///w/yBgAAAgAAAA/W////9v///w/zBgAAAgAAAA/c/////P///w/0BgAAAgAAAA9cAAAAfAAAAA/1BgAAAgAAAA/R////8f///w/2BgAAAgAAAA/e/////v///w/3BgAAAgAAAA/T////8////w/4BgAAAgAAAA/N////7f///w/5BgAAAgAAAA/J////6f///w/6BgAAAgAAAA/U////9P///w/7BgAAAgAAAA/Y////+P///w/8BgAAAgAAAA/C////4v///w/9BgAAAgAAAA/A////4P///w/+BgAAAgAAAA8vAAAAPwAAAA//BgAAAgAAAA88AAAAPgAAAA8ABwAAAAAAAA8PAQcAAAIAAAAPYAAAAH4AAAAPAgcAAAIAAAAPMQAAACEAAAAPAwcAAAIAAAAPMgAAAEAAAAAPBAcAAAIAAAAPMwAAACMAAAAPBQcAAAIAAAAPNAAAACQAAAAPBgcAAAIAAAAPNQAAACUAAAAPBwcAAAIAAAAPNgAAAF4AAAAPCAcAAAIAAAAPNwAAACYAAAAPCQcAAAIAAAAPOAAAACoAAAAPCgcAAAIAAAAPOQAAACgAAAAPCwcAAAIAAAAPMAAAACkAAAAPDAcAAAIAAAAPLQAAAF8AAAAPDQcAAAIAAAAPPQAAACsAAAAPDgcAAAQAAAAPcQAAAFEAAADp////yf///w8PBwAABAAAAA93AAAAVwAAAPb////W////DxAHAAAEAAAAD2UAAABFAAAA8////9P///8PEQcAAAQAAAAPcgAAAFIAAADq////yv///w8SBwAABAAAAA90AAAAVAAAAOX////F////DxMHAAAEAAAAD3kAAABZAAAA7f///83///8PFAcAAAQAAAAPdQAAAFUAAADj////w////w8VBwAABAAAAA9pAAAASQAAAPj////Y////DxYHAAAEAAAAD28AAABPAAAA+f///9n///8PFwcAAAQAAAAPcAAAAFAAAADn////x////w8YBwAABAAAAA9bAAAAewAAAPX////V////DxkHAAAEAAAAD10AAAB9AAAA+v///9r///8PGgcAAAQAAAAPYQAAAEEAAAD0////1P///w8bBwAABAAAAA9zAAAAUwAAAPv////b////DxwHAAAEAAAAD2QAAABEAAAA4v///8L///8PHQcAAAQAAAAPZgAAAEYAAADg////wP///w8eBwAABAAAAA9nAAAARwAAAO/////P////Dx8HAAAEAAAAD2gAAABIAAAA8P///9D///8PIAcAAAQAAAAPagAAAEoAAADu////zv///w8hBwAABAAAAA9rAAAASwAAAOv////L////DyIHAAAEAAAAD2wAAABMAAAA5P///8T///8PIwcAAAQAAAAPOwAAADoAAADm////xv///w8kBwAABAAAAA8nAAAAIgAAAP3////d////DyUHAAACAAAAD1wAAAB8AAAADyYHAAAEAAAAD3oAAABaAAAA/////9////8PJwcAAAQAAAAPeAAAAFgAAAD3////1////w8oBwAABAAAAA9jAAAAQwAAAPH////R////DykHAAAEAAAAD3YAAABWAAAA7P///8z///8PKgcAAAQAAAAPYgAAAEIAAADo////yP///w8rBwAABAAAAA9uAAAATgAAAPL////S////DywHAAAEAAAAD20AAABNAAAA/P///9z///8PLQcAAAQAAAAPLAAAADwAAADh////wf///w8uBwAABAAAAA8uAAAAPgAAAP7////e////Dy8HAAACAAAADy8AAAA/AAAADzAHAAACAAAADzwAAAA+AAAADzEHAAAAAAAADw8yBwAAAgAAAA9gAAAAfgAAAA8zBwAAAgAAAA8xAAAAIQAAAA80BwAAAgAAAA8yAAAAQAAAAA81BwAAAgAAAA8zAAAAIwAAAA82BwAAAgAAAA80AAAAJAAAAA83BwAAAgAAAA81AAAAJQAAAA84BwAAAgAAAA82AAAAXgAAAA85BwAAAgAAAA83AAAAJgAAAA86BwAAAgAAAA84AAAAKgAAAA87BwAAAgAAAA85AAAAKAAAAA88BwAAAgAAAA8wAAAAKQAAAA89BwAAAgAAAA8tAAAAXwAAAA8+BwAAAgAAAA89AAAAKwAAAA8/BwAABAAAAA9xAAAAUQAAANH////x////D0AHAAAEAAAAD3cAAABXAAAA1/////f///8PQQcAAAQAAAAPZQAAAEUAAADF////5f///w9CBwAABAAAAA9yAAAAUgAAANL////y////D0MHAAAEAAAAD3QAAABUAAAA1P////T///8PRAcAAAQAAAAPeQAAAFkAAADZ////+f///w9FBwAABAAAAA91AAAAVQAAANX////1////D0YHAAAEAAAAD2kAAABJAAAAyf///+n///8PRwcAAAQAAAAPbwAAAE8AAADP////7////w9IBwAABAAAAA9wAAAAUAAAAND////w////D0kHAAAEAAAAD1sAAAB7AAAA2/////v///8PSgcAAAQAAAAPXQAAAH0AAADd/////f///w9LBwAABAAAAA9hAAAAQQAAAMH////h////D0wHAAAEAAAAD3MAAABTAAAA0/////P///8PTQcAAAQAAAAPZAAAAEQAAADE////5P///w9OBwAABAAAAA9mAAAARgAAAMb////m////D08HAAAEAAAAD2cAAABHAAAAx////+f///8PUAcAAAQAAAAPaAAAAEgAAADI////6P///w9RBwAABAAAAA9qAAAASgAAAMr////q////D1IHAAAEAAAAD2sAAABLAAAAy////+v///8PUwcAAAQAAAAPbAAAAEwAAADM////7P///w9UBwAAAgAAAA87AAAAOgAAAA9VBwAAAgAAAA8nAAAAIgAAAA9WBwAAAgAAAA9cAAAAfAAAAA9XBwAABAAAAA96AAAAWgAAANr////6////D1gHAAAEAAAAD3gAAABYAAAA2P////j///8PWQcAAAQAAAAPYwAAAEMAAADD////4////w9aBwAABAAAAA92AAAAVgAAANb////2////D1sHAAAEAAAAD2IAAABCAAAAwv///+L///8PXAcAAAQAAAAPbgAAAE4AAADO////7v///w9dBwAABAAAAA9tAAAATQAAAM3////t////D14HAAACAAAADywAAAA8AAAAD18HAAACAAAADy4AAAA+AAAAD2AHAAACAAAADy8AAAA/AAAAD2EHAAACAAAADzwAAAA+AAAAD2IHAAAAAAAADw9jBwAABAAAAA9gAAAAfgAAAK3///+9////D2QHAAAEAAAADzEAAAAhAAAAMQAAACEAAAAPZQcAAAQAAAAPMgAAAEAAAAAyAAAAIgAAAA9mBwAABAAAAA8zAAAAIwAAADMAAAAnAAAAD2cHAAAEAAAADzQAAAAkAAAANAAAACoAAAAPaAcAAAQAAAAPNQAAACUAAAA1AAAAOgAAAA9pBwAABAAAAA82AAAAXgAAADYAAAAsAAAAD2oHAAAEAAAADzcAAAAmAAAANwAAAC4AAAAPawcAAAQAAAAPOAAAACoAAAA4AAAAOwAAAA9sBwAABAAAAA85AAAAKAAAADkAAAAoAAAAD20HAAAEAAAADzAAAAApAAAAMAAAACkAAAAPbgcAAAQAAAAPLQAAAF8AAAAtAAAAXwAAAA9vBwAABAAAAA89AAAAKwAAAD0AAAArAAAAD3AHAAAEAAAAD3EAAABRAAAAyv///+r///8PcQcAAAQAAAAPdwAAAFcAAADD////4////w9yBwAABAAAAA9lAAAARQAAANX////1////D3MHAAAEAAAAD3IAAABSAAAAy////+v///8PdAcAAAQAAAAPdAAAAFQAAADF////5f///w91BwAABAAAAA95AAAAWQAAAM7////u////D3YHAAAEAAAAD3UAAABVAAAAx////+f///8PdwcAAAQAAAAPaQAAAEkAAADb////+////w94BwAABAAAAA9vAAAATwAAAN3////9////D3kHAAAEAAAAD3AAAABQAAAA2v////r///8PegcAAAQAAAAPWwAAAHsAAADI////6P///w97BwAABAAAAA9dAAAAfQAAAKf///+3////D3wHAAAEAAAAD2EAAABBAAAAxv///+b///8PfQcAAAQAAAAPcwAAAFMAAACm////tv///w9+BwAABAAAAA9kAAAARAAAANf////3////D38HAAAEAAAAD2YAAABGAAAAwf///+H///8PgAcAAAQAAAAPZwAAAEcAAADQ////8P///w+BBwAABAAAAA9oAAAASAAAANL////y////D4IHAAAEAAAAD2oAAABKAAAAz////+////8PgwcAAAQAAAAPawAAAEsAAADM////7P///w+EBwAABAAAAA9sAAAATAAAAMT////k////D4UHAAAEAAAADzsAAAA6AAAA1v////b///8PhgcAAAQAAAAPJwAAACIAAACk////tP///w+HBwAABAAAAA9cAAAAfAAAAFwAAAB8AAAAD4gHAAAEAAAAD3oAAABaAAAA0f////H///8PiQcAAAQAAAAPeAAAAFgAAADe/////v///w+KBwAABAAAAA9jAAAAQwAAANP////z////D4sHAAAEAAAAD3YAAABWAAAAzf///+3///8PjAcAAAQAAAAPYgAAAEIAAADJ////6f///w+NBwAABAAAAA9uAAAATgAAANT////0////D44HAAAEAAAAD20AAABNAAAA2P////j///8PjwcAAAQAAAAPLAAAADwAAADC////4v///w+QBwAABAAAAA8uAAAAPgAAAMD////g////D5EHAAAEAAAADy8AAAA/AAAALwAAAD8AAAAPkgcAAAIAAAAPPAAAAD4AAAAPkwcAAAAAAAAPD5QHAAACAAAAD63///+9////D5UHAAACAAAADzEAAAAhAAAAD5YHAAACAAAADzIAAAAiAAAAD5cHAAACAAAADzMAAAAnAAAAD5gHAAACAAAADzQAAAA7AAAAD5kHAAACAAAADzUAAAAlAAAAD5oHAAACAAAADzYAAAA6AAAAD5sHAAACAAAADzcAAAA/AAAAD5wHAAACAAAADzgAAAAqAAAAD50HAAACAAAADzkAAAAoAAAAD54HAAACAAAADzAAAAApAAAAD58HAAACAAAADy0AAABfAAAAD6AHAAACAAAADz0AAAArAAAAD6EHAAACAAAAD8r////q////D6IHAAACAAAAD8P////j////D6MHAAACAAAAD9X////1////D6QHAAACAAAAD8v////r////D6UHAAACAAAAD8X////l////D6YHAAACAAAAD87////u////D6cHAAACAAAAD8f////n////D6gHAAACAAAAD9v////7////D6kHAAACAAAAD93////9////D6oHAAACAAAAD9r////6////D6sHAAACAAAAD8j////o////D6wHAAACAAAAD6f///+3////D60HAAACAAAAD8b////m////D64HAAACAAAAD6b///+2////D68HAAACAAAAD9f////3////D7AHAAACAAAAD8H////h////D7EHAAACAAAAD9D////w////D7IHAAACAAAAD9L////y////D7MHAAACAAAAD8/////v////D7QHAAACAAAAD8z////s////D7UHAAACAAAAD8T////k////D7YHAAACAAAAD9b////2////D7cHAAACAAAAD6T///+0////D7gHAAACAAAAD1wAAAAvAAAAD7kHAAACAAAAD9H////x////D7oHAAACAAAAD97////+////D7sHAAACAAAAD9P////z////D7wHAAACAAAAD83////t////D70HAAACAAAAD8n////p////D74HAAACAAAAD9T////0////D78HAAACAAAAD9j////4////D8AHAAACAAAAD8L////i////D8EHAAACAAAAD8D////g////D8IHAAACAAAADy4AAAAsAAAAD8MHAAACAAAADzwAAAA+AAAAD8QHAAAAAAAADw/FBwAAAgAAAA+j////s////w/GBwAAAgAAAA8xAAAAIQAAAA/HBwAAAgAAAA8yAAAAIgAAAA/IBwAAAgAAAA8zAAAAJwAAAA/JBwAAAgAAAA80AAAAOwAAAA/KBwAAAgAAAA81AAAAJQAAAA/LBwAAAgAAAA82AAAAOgAAAA/MBwAAAgAAAA83AAAAPwAAAA/NBwAAAgAAAA84AAAAKgAAAA/OBwAAAgAAAA85AAAAKAAAAA/PBwAAAgAAAA8wAAAAKQAAAA/QBwAAAgAAAA8tAAAAXwAAAA/RBwAAAgAAAA89AAAAKwAAAA/SBwAAAgAAAA/K////6v///w/TBwAAAgAAAA/D////4////w/UBwAAAgAAAA/V////9f///w/VBwAAAgAAAA/L////6////w/WBwAAAgAAAA/F////5f///w/XBwAAAgAAAA/O////7v///w/YBwAAAgAAAA/H////5////w/ZBwAAAgAAAA/b////+////w/aBwAAAgAAAA/d/////f///w/bBwAAAgAAAA/a////+v///w/cBwAAAgAAAA/I////6P///w/dBwAAAgAAAA/f/////////w/eBwAAAgAAAA/G////5v///w/fBwAAAgAAAA/Z////+f///w/gBwAAAgAAAA/X////9////w/hBwAAAgAAAA/B////4f///w/iBwAAAgAAAA/Q////8P///w/jBwAAAgAAAA/S////8v///w/kBwAAAgAAAA/P////7////w/lBwAAAgAAAA/M////7P///w/mBwAAAgAAAA/E////5P///w/nBwAAAgAAAA/W////9v///w/oBwAAAgAAAA/c/////P///w/pBwAAAgAAAA9cAAAALwAAAA/qBwAAAgAAAA/R////8f///w/rBwAAAgAAAA/e/////v///w/sBwAAAgAAAA/T////8////w/tBwAAAgAAAA/N////7f///w/uBwAAAgAAAA/J////6f///w/vBwAAAgAAAA/U////9P///w/wBwAAAgAAAA/Y////+P///w/xBwAAAgAAAA/C////4v///w/yBwAAAgAAAA/A////4P///w/zBwAAAgAAAA8uAAAALAAAAA/0BwAAAgAAAA88AAAAPgAAAA/1BwAAAAAAAA8P9gcAAAIAAAAPuv///6r///8P9wcAAAIAAAAPMQAAACEAAAAP+AcAAAIAAAAPMgAAACIAAAAP+QcAAAIAAAAPMwAAALf///8P+gcAAAIAAAAPNAAAACQAAAAP+wcAAAIAAAAPNQAAACUAAAAP/AcAAAIAAAAPNgAAACYAAAAP/QcAAAIAAAAPNwAAAC8AAAAP/gcAAAIAAAAPOAAAACgAAAAP/wcAAAIAAAAPOQAAACkAAAAPAAgAAAIAAAAPMAAAAD0AAAAPAQgAAAIAAAAPJwAAAD8AAAAPAggAAAIAAAAPof///7////8PAwgAAAIAAAAPcQAAAFEAAAAPBAgAAAIAAAAPdwAAAFcAAAAPBQgAAAIAAAAPZQAAAEUAAAAPBggAAAIAAAAPcgAAAFIAAAAPBwgAAAIAAAAPdAAAAFQAAAAPCAgAAAIAAAAPeQAAAFkAAAAPCQgAAAIAAAAPdQAAAFUAAAAPCggAAAIAAAAPaQAAAEkAAAAPCwgAAAIAAAAPbwAAAE8AAAAPDAgAAAIAAAAPcAAAAFAAAAAPDQgAAAIAAAAPYAAAAF4AAAAPDggAAAIAAAAPKwAAACoAAAAPDwgAAAIAAAAPYQAAAEEAAAAPEAgAAAIAAAAPcwAAAFMAAAAPEQgAAAIAAAAPZAAAAEQAAAAPEggAAAIAAAAPZgAAAEYAAAAPEwgAAAIAAAAPZwAAAEcAAAAPFAgAAAIAAAAPaAAAAEgAAAAPFQgAAAIAAAAPagAAAEoAAAAPFggAAAIAAAAPawAAAEsAAAAPFwgAAAIAAAAPbAAAAEwAAAAPGAgAAAIAAAAP8f///9H///8PGQgAAAIAAAAPtP///6j///8PGggAAAIAAAAP5////8f///8PGwgAAAIAAAAPegAAAFoAAAAPHAgAAAIAAAAPeAAAAFgAAAAPHQgAAAIAAAAPYwAAAEMAAAAPHggAAAIAAAAPdgAAAFYAAAAPHwgAAAIAAAAPYgAAAEIAAAAPIAgAAAIAAAAPbgAAAE4AAAAPIQgAAAIAAAAPbQAAAE0AAAAPIggAAAIAAAAPLAAAADsAAAAPIwgAAAIAAAAPLgAAADoAAAAPJAgAAAIAAAAPLQAAAF8AAAAPJQgAAAIAAAAPPAAAAD4AAAAPJggAAAAAAAAPDycIAAACAAAAD1wAAAB8AAAADygIAAACAAAADzEAAAAhAAAADykIAAACAAAADzIAAAAiAAAADyoIAAACAAAADzMAAACj////DysIAAACAAAADzQAAAAkAAAADywIAAACAAAADzUAAAAlAAAADy0IAAACAAAADzYAAAAmAAAADy4IAAACAAAADzcAAAAvAAAADy8IAAACAAAADzgAAAAoAAAADzAIAAACAAAADzkAAAApAAAADzEIAAACAAAADzAAAAA9AAAADzIIAAACAAAADycAAAA/AAAADzMIAAACAAAAD+z///9eAAAADzQIAAACAAAAD3EAAABRAAAADzUIAAACAAAAD3cAAABXAAAADzYIAAACAAAAD2UAAABFAAAADzcIAAACAAAAD3IAAABSAAAADzgIAAACAAAAD3QAAABUAAAADzkIAAACAAAAD3kAAABZAAAADzoIAAACAAAAD3UAAABVAAAADzsIAAACAAAAD2kAAABJAAAADzwIAAACAAAAD28AAABPAAAADz0IAAACAAAAD3AAAABQAAAADz4IAAACAAAAD+j////p////Dz8IAAACAAAADysAAAAqAAAAD0AIAAACAAAAD2EAAABBAAAAD0EIAAACAAAAD3MAAABTAAAAD0IIAAACAAAAD2QAAABEAAAAD0MIAAACAAAAD2YAAABGAAAAD0QIAAACAAAAD2cAAABHAAAAD0UIAAACAAAAD2gAAABIAAAAD0YIAAACAAAAD2oAAABKAAAAD0cIAAACAAAAD2sAAABLAAAAD0gIAAACAAAAD2wAAABMAAAAD0kIAAACAAAAD/L////n////D0oIAAACAAAAD+D///+w////D0sIAAACAAAAD/n///+n////D0wIAAACAAAAD3oAAABaAAAAD00IAAACAAAAD3gAAABYAAAAD04IAAACAAAAD2MAAABDAAAAD08IAAACAAAAD3YAAABWAAAAD1AIAAACAAAAD2IAAABCAAAAD1EIAAACAAAAD24AAABOAAAAD1IIAAACAAAAD20AAABNAAAAD1MIAAACAAAADywAAAA7AAAAD1QIAAACAAAADy4AAAA6AAAAD1UIAAACAAAADy0AAABfAAAAD1YIAAACAAAADzwAAAA+AAAAD1cIAAAAAAAADw9YCAAAAQAAAA+w////D1kIAAACAAAADzEAAAAhAAAAD1oIAAACAAAADzIAAAAiAAAAD1sIAAACAAAADzMAAAAjAAAAD1wIAAACAAAADzQAAAAkAAAAD10IAAACAAAADzUAAAAlAAAAD14IAAACAAAADzYAAAAmAAAAD18IAAACAAAADzcAAAAvAAAAD2AIAAACAAAADzgAAAAoAAAAD2EIAAACAAAADzkAAAApAAAAD2IIAAACAAAADzAAAAA9AAAAD2MIAAACAAAAD/b////W////D2QIAAACAAAADy0AAABfAAAAD2UIAAACAAAAD3EAAABRAAAAD2YIAAACAAAAD3cAAABXAAAAD2cIAAACAAAAD2UAAABFAAAAD2gIAAACAAAAD3IAAABSAAAAD2kIAAACAAAAD3QAAABUAAAAD2oIAAACAAAAD3kAAABZAAAAD2sIAAACAAAAD3UAAABVAAAAD2wIAAACAAAAD2kAAABJAAAAD20IAAACAAAAD28AAABPAAAAD24IAAACAAAAD3AAAABQAAAAD28IAAACAAAAD/D////Q////D3AIAAACAAAADycAAAA/AAAAD3EIAAACAAAAD2EAAABBAAAAD3IIAAACAAAAD3MAAABTAAAAD3MIAAACAAAAD2QAAABEAAAAD3QIAAACAAAAD2YAAABGAAAAD3UIAAACAAAAD2cAAABHAAAAD3YIAAACAAAAD2gAAABIAAAAD3cIAAACAAAAD2oAAABKAAAAD3gIAAACAAAAD2sAAABLAAAAD3kIAAACAAAAD2wAAABMAAAAD3oIAAACAAAAD+b////G////D3sIAAACAAAAD7T////E////D3wIAAACAAAADysAAAAqAAAAD30IAAACAAAAD3oAAABaAAAAD34IAAACAAAAD3gAAABYAAAAD38IAAACAAAAD2MAAABDAAAAD4AIAAACAAAAD3YAAABWAAAAD4EIAAACAAAAD2IAAABCAAAAD4IIAAACAAAAD24AAABOAAAAD4MIAAACAAAAD20AAABNAAAAD4QIAAACAAAADywAAAA7AAAAD4UIAAACAAAADy4AAAA6AAAAD4YIAAACAAAAD/7////e////D4cIAAACAAAADzwAAAA+AAAAD4gIAAAAAAAADw+JCAAAAgAAAA8wAAAAp////w+KCAAAAwAAAA8xAAAAJwAAAH4AAAAPiwgAAAMAAAAPMgAAACIAAAC3////D4wIAAADAAAADzMAAAArAAAAXgAAAA+NCAAAAwAAAA80AAAAIQAAAKL///8PjggAAAQAAAAPNQAAACUAAAAwAAAAsP///w+PCAAAAwAAAA82AAAALwAAALL///8PkAgAAAMAAAAPNwAAAD0AAABgAAAAD5EIAAADAAAADzgAAAAoAAAA/////w+SCAAAAwAAAA85AAAAKQAAALT///8PkwgAAAMAAAAP9v///9b///+9////D5QIAAADAAAAD/z////c////qP///w+VCAAAAwAAAA/z////0////7j///8PlggAAAMAAAAPcQAAAFEAAABcAAAAD5cIAAADAAAAD3cAAABXAAAAfAAAAA+YCAAAAgAAAA9lAAAARQAAAA+ZCAAAAgAAAA9yAAAAUgAAAA+aCAAAAgAAAA90AAAAVAAAAA+bCAAAAgAAAA96AAAAWgAAAA+cCAAAAgAAAA91AAAAVQAAAA+dCAAAAwAAAA9pAAAASQAAAM3///8PnggAAAMAAAAPbwAAAE8AAAD4////D58IAAACAAAAD3AAAABQAAAAD6AIAAADAAAAD/X////V////9////w+hCAAAAwAAAA/6////2v///9f///8PoggAAAIAAAAPYQAAAEEAAAAPowgAAAMAAAAPcwAAAFMAAADw////D6QIAAADAAAAD2QAAABEAAAA0P///w+lCAAAAwAAAA9mAAAARgAAAFsAAAAPpggAAAMAAAAPZwAAAEcAAABdAAAAD6cIAAACAAAAD2gAAABIAAAAD6gIAAADAAAAD2oAAABKAAAA7f///w+pCAAAAwAAAA9rAAAASwAAALP///8PqggAAAMAAAAPbAAAAEwAAACj////D6sIAAADAAAAD+n////J////JAAAAA+sCAAAAwAAAA/h////wf///9////8PrQgAAAMAAAAP+////9v///+k////D64IAAADAAAAD3kAAABZAAAAPgAAAA+vCAAAAwAAAA94AAAAWAAAACMAAAAPsAgAAAMAAAAPYwAAAEMAAAAmAAAAD7EIAAADAAAAD3YAAABWAAAAQAAAAA+yCAAAAwAAAA9iAAAAQgAAAHsAAAAPswgAAAMAAAAPbgAAAE4AAAB9AAAAD7QIAAACAAAAD20AAABNAAAAD7UIAAADAAAADywAAAA/AAAAOwAAAA+2CAAAAwAAAA8uAAAAOgAAAD4AAAAPtwgAAAMAAAAPLQAAAF8AAAAqAAAAD7gIAAADAAAAD+3////N////PAAAAA+5CAAAAAAAAA8PuggAAAIAAAAPYAAAAH4AAAAPuwgAAAIAAAAPMQAAACEAAAAPvAgAAAIAAAAPMgAAAEAAAAAPvQgAAAIAAAAPMwAAACMAAAAPvggAAAIAAAAPNAAAACQAAAAPvwgAAAIAAAAPNQAAACUAAAAPwAgAAAIAAAAPNgAAAF4AAAAPwQgAAAMAAAAPNwAAACYAAACn////D8IIAAACAAAADzgAAAAqAAAAD8MIAAACAAAADzkAAAAoAAAAD8QIAAACAAAADzAAAAApAAAAD8UIAAACAAAADy0AAABfAAAAD8YIAAACAAAADz0AAAArAAAAD8cIAAACAAAAD3EAAABRAAAAD8gIAAACAAAAD3cAAABXAAAAD8kIAAAEAAAAD2UAAABFAAAA6v///8r///8PyggAAAIAAAAPcgAAAFIAAAAPywgAAAIAAAAPdAAAAFQAAAAPzAgAAAIAAAAPeQAAAFkAAAAPzQgAAAIAAAAPdQAAAFUAAAAPzggAAAIAAAAPaQAAAEkAAAAPzwgAAAQAAAAPbwAAAE8AAADz////0////w/QCAAAAgAAAA9wAAAAUAAAAA/RCAAAAgAAAA9bAAAAewAAAA/SCAAAAgAAAA9dAAAAfQAAAA/TCAAABAAAAA9hAAAAQQAAALH///+h////D9QIAAAEAAAAD3MAAABTAAAAtv///6b///8P1QgAAAIAAAAPZAAAAEQAAAAP1ggAAAIAAAAPZgAAAEYAAAAP1wgAAAIAAAAPZwAAAEcAAAAP2AgAAAIAAAAPaAAAAEgAAAAP2QgAAAIAAAAPagAAAEoAAAAP2ggAAAIAAAAPawAAAEsAAAAP2wgAAAQAAAAPbAAAAEwAAACz////o////w/cCAAAAgAAAA87AAAAOgAAAA/dCAAAAgAAAA8nAAAAIgAAAA/eCAAAAgAAAA9cAAAAfAAAAA/fCAAABAAAAA96AAAAWgAAAL////+v////D+AIAAAEAAAAD3gAAABYAAAAvP///6z///8P4QgAAAQAAAAPYwAAAEMAAADm////xv///w/iCAAAAgAAAA92AAAAVgAAAA/jCAAAAgAAAA9iAAAAQgAAAA/kCAAABAAAAA9uAAAATgAAAPH////R////D+UIAAACAAAAD20AAABNAAAAD+YIAAACAAAADywAAAA8AAAAD+cIAAACAAAADy4AAAA+AAAAD+gIAAACAAAADy8AAAA/AAAAD+kIAAADAAAADzwAAAA+AAAAfAAAAA/qCAAAAAAAAA8P6wgAAAIAAAAPuP///6j///8P7AgAAAIAAAAPMQAAACEAAAAP7QgAAAIAAAAPMgAAACIAAAAP7ggAAAIAAAAPMwAAACMAAAAP7wgAAAIAAAAPNAAAACQAAAAP8AgAAAIAAAAPNQAAACUAAAAP8QgAAAIAAAAPNgAAACYAAAAP8ggAAAIAAAAPNwAAAC8AAAAP8wgAAAIAAAAPOAAAACgAAAAP9AgAAAIAAAAPOQAAACkAAAAP9QgAAAIAAAAPMAAAAD0AAAAP9ggAAAIAAAAPJwAAAD8AAAAP9wgAAAIAAAAPKwAAACoAAAAP+AgAAAIAAAAPcQAAAFEAAAAP+QgAAAIAAAAPdwAAAFcAAAAP+ggAAAIAAAAPZQAAAEUAAAAP+wgAAAIAAAAPcgAAAFIAAAAP/AgAAAIAAAAPdAAAAFQAAAAP/QgAAAIAAAAPegAAAFoAAAAP/ggAAAIAAAAPdQAAAFUAAAAP/wgAAAIAAAAPaQAAAEkAAAAPAAkAAAIAAAAPbwAAAE8AAAAPAQkAAAIAAAAPcAAAAFAAAAAPAgkAAAIAAAAPuf///6n///8PAwkAAAIAAAAP8P///9D///8PBAkAAAIAAAAPYQAAAEEAAAAPBQkAAAIAAAAPcwAAAFMAAAAPBgkAAAIAAAAPZAAAAEQAAAAPBwkAAAIAAAAPZgAAAEYAAAAPCAkAAAIAAAAPZwAAAEcAAAAPCQkAAAIAAAAPaAAAAEgAAAAPCgkAAAIAAAAPagAAAEoAAAAPCwkAAAIAAAAPawAAAEsAAAAPDAkAAAIAAAAPbAAAAEwAAAAPDQkAAAIAAAAP6P///8j///8PDgkAAAIAAAAP5v///8b///8PDwkAAAIAAAAPvv///67///8PEAkAAAIAAAAPeQAAAFkAAAAPEQkAAAIAAAAPeAAAAFgAAAAPEgkAAAIAAAAPYwAAAEMAAAAPEwkAAAIAAAAPdgAAAFYAAAAPFAkAAAIAAAAPYgAAAEIAAAAPFQkAAAIAAAAPbgAAAE4AAAAPFgkAAAIAAAAPbQAAAE0AAAAPFwkAAAIAAAAPLAAAADsAAAAPGAkAAAIAAAAPLgAAADoAAAAPGQkAAAIAAAAPLQAAAF8AAAAPGgkAAAIAAAAPPAAAAD4AAAAPGwkAAAAAAAAPDxwJAAACAAAAD2AAAAB+AAAADx0JAAACAAAADzEAAAAhAAAADx4JAAACAAAADzIAAAAiAAAADx8JAAACAAAADzMAAAAjAAAADyAJAAACAAAADzQAAAAkAAAADyEJAAACAAAADzUAAAAlAAAADyIJAAACAAAADzYAAAAmAAAADyMJAAACAAAADzcAAAAvAAAADyQJAAACAAAADzgAAAAoAAAADyUJAAACAAAADzkAAAApAAAADyYJAAACAAAADzAAAAA9AAAADycJAAACAAAADycAAAA/AAAADygJAAACAAAADysAAAAqAAAADykJAAACAAAAD6n///+5////DyoJAAACAAAAD6r///+6////DysJAAACAAAAD8X////l////DywJAAACAAAAD9L////y////Dy0JAAACAAAAD9T////0////Dy4JAAACAAAAD9r////6////Dy8JAAACAAAAD9X////1////DzAJAAACAAAAD8n////p////DzEJAAACAAAAD8/////v////DzIJAAACAAAAD9D////w////DzMJAAACAAAAD9v////7////DzQJAAACAAAAD1sAAABdAAAADzUJAAACAAAAD8H////h////DzYJAAACAAAAD9P////z////DzcJAAACAAAAD8T////k////DzgJAAACAAAAD8b////m////DzkJAAACAAAAD8f////n////DzoJAAACAAAAD8j////o////DzsJAAACAAAAD6j///+4////DzwJAAACAAAAD8v////r////Dz0JAAACAAAAD8z////s////Dz4JAAACAAAAD97////+////Dz8JAAACAAAAD6v///+7////D0AJAAACAAAADy0AAABfAAAAD0EJAAACAAAAD6H///+x////D0IJAAACAAAAD6////+/////D0MJAAACAAAAD8P////j////D0QJAAACAAAAD9f////3////D0UJAAACAAAAD8L////i////D0YJAAACAAAAD87////u////D0cJAAACAAAAD83////t////D0gJAAACAAAADywAAAA7AAAAD0kJAAACAAAADy4AAAA6AAAAD0oJAAACAAAAD9b////2////D0sJAAACAAAADzwAAAA+AAAAD0wJAAAAAAAADw9NCQAAAgAAAA9gAAAAfgAAAA9OCQAAAgAAAA8xAAAAIQAAAA9PCQAABAAAAA8yAAAAQAAAADIAAAAiAAAAD1AJAAACAAAADzMAAAAjAAAAD1EJAAACAAAADzQAAAAkAAAAD1IJAAACAAAADzUAAAAlAAAAD1MJAAAEAAAADzYAAABeAAAANgAAACYAAAAPVAkAAAQAAAAPNwAAACYAAAA3AAAALwAAAA9VCQAABAAAAA84AAAAKgAAADgAAAAoAAAAD1YJAAAEAAAADzkAAAAoAAAAOQAAACkAAAAPVwkAAAQAAAAPMAAAACkAAAAwAAAAPQAAAA9YCQAABAAAAA8tAAAAXwAAACcAAAA/AAAAD1kJAAAEAAAADz0AAAArAAAAKwAAACoAAAAPWgkAAAQAAAAPcQAAAFEAAACp////uf///w9bCQAABAAAAA93AAAAVwAAAKr///+6////D1wJAAAEAAAAD2UAAABFAAAAxf///+X///8PXQkAAAQAAAAPcgAAAFIAAADS////8v///w9eCQAABAAAAA90AAAAVAAAANT////0////D18JAAAEAAAAD3kAAABZAAAA2v////r///8PYAkAAAQAAAAPdQAAAFUAAADV////9f///w9hCQAABAAAAA9pAAAASQAAAMn////p////D2IJAAAEAAAAD28AAABPAAAAz////+////8PYwkAAAQAAAAPcAAAAFAAAADQ////8P///w9kCQAABAAAAA9bAAAAewAAANv////7////D2UJAAAEAAAAD10AAAB9AAAAWwAAAF0AAAAPZgkAAAQAAAAPYQAAAEEAAADB////4f///w9nCQAABAAAAA9zAAAAUwAAANP////z////D2gJAAAEAAAAD2QAAABEAAAAxP///+T///8PaQkAAAQAAAAPZgAAAEYAAADG////5v///w9qCQAABAAAAA9nAAAARwAAAMf////n////D2sJAAAEAAAAD2gAAABIAAAAyP///+j///8PbAkAAAQAAAAPagAAAEoAAACo////uP///w9tCQAABAAAAA9rAAAASwAAAMv////r////D24JAAAEAAAAD2wAAABMAAAAzP///+z///8PbwkAAAQAAAAPOwAAADoAAADe/////v///w9wCQAABAAAAA8nAAAAIgAAAKv///+7////D3EJAAAEAAAAD1wAAAB8AAAALQAAAF8AAAAPcgkAAAQAAAAPegAAAFoAAACh////sf///w9zCQAABAAAAA94AAAAWAAAAK////+/////D3QJAAAEAAAAD2MAAABDAAAAw////+P///8PdQkAAAQAAAAPdgAAAFYAAADX////9////w92CQAABAAAAA9iAAAAQgAAAML////i////D3cJAAAEAAAAD24AAABOAAAAzv///+7///8PeAkAAAQAAAAPbQAAAE0AAADN////7f///w95CQAABAAAAA8sAAAAPAAAACwAAAA7AAAAD3oJAAAEAAAADy4AAAA+AAAALgAAADoAAAAPewkAAAQAAAAPLwAAAD8AAADW////9v///w98CQAAAgAAAA88AAAAPgAAAA99CQAAAAAAAA8PfgkAAAIAAAAPuP///6j///8PfwkAAAIAAAAPMQAAACEAAAAPgAkAAAIAAAAPMgAAACIAAAAPgQkAAAIAAAAPMwAAACMAAAAPggkAAAIAAAAPNAAAACQAAAAPgwkAAAIAAAAPNQAAACUAAAAPhAkAAAIAAAAPNgAAACYAAAAPhQkAAAIAAAAPNwAAAC8AAAAPhgkAAAIAAAAPOAAAACgAAAAPhwkAAAIAAAAPOQAAACkAAAAPiAkAAAIAAAAPMAAAAD0AAAAPiQkAAAIAAAAPJwAAAD8AAAAPigkAAAIAAAAPKwAAACoAAAAPiwkAAAIAAAAPcQAAAFEAAAAPjAkAAAIAAAAPdwAAAFcAAAAPjQkAAAIAAAAPZQAAAEUAAAAPjgkAAAIAAAAPcgAAAFIAAAAPjwkAAAIAAAAPdAAAAFQAAAAPkAkAAAIAAAAPegAAAFoAAAAPkQkAAAIAAAAPdQAAAFUAAAAPkgkAAAIAAAAPaQAAAEkAAAAPkwkAAAIAAAAPbwAAAE8AAAAPlAkAAAIAAAAPcAAAAFAAAAAPlQkAAAIAAAAPuf///6n///8PlgkAAAIAAAAP8P///9D///8PlwkAAAIAAAAPYQAAAEEAAAAPmAkAAAIAAAAPcwAAAFMAAAAPmQkAAAIAAAAPZAAAAEQAAAAPmgkAAAIAAAAPZgAAAEYAAAAPmwkAAAIAAAAPZwAAAEcAAAAPnAkAAAIAAAAPaAAAAEgAAAAPnQkAAAIAAAAPagAAAEoAAAAPngkAAAIAAAAPawAAAEsAAAAPnwkAAAIAAAAPbAAAAEwAAAAPoAkAAAIAAAAP6P///8j///8PoQkAAAIAAAAP5v///8b///8PogkAAAIAAAAPvv///67///8PowkAAAIAAAAPeQAAAFkAAAAPpAkAAAIAAAAPeAAAAFgAAAAPpQkAAAIAAAAPYwAAAEMAAAAPpgkAAAIAAAAPdgAAAFYAAAAPpwkAAAIAAAAPYgAAAEIAAAAPqAkAAAIAAAAPbgAAAE4AAAAPqQkAAAIAAAAPbQAAAE0AAAAPqgkAAAIAAAAPLAAAADsAAAAPqwkAAAIAAAAPLgAAADoAAAAPrAkAAAIAAAAPLwAAAD8AAAAPrQkAAAIAAAAPPAAAAD4AAAAPrgkAAAAAAAAPD68JAAACAAAAD2AAAAB+AAAAD7AJAAACAAAADzEAAAAhAAAAD7EJAAACAAAADzIAAABAAAAAD7IJAAACAAAADzMAAAAjAAAAD7MJAAACAAAADzQAAAAkAAAAD7QJAAACAAAADzUAAAAlAAAAD7UJAAACAAAADzYAAABeAAAAD7YJAAACAAAADzcAAAAmAAAAD7cJAAACAAAADzgAAAAqAAAAD7gJAAACAAAADzkAAAAoAAAAD7kJAAACAAAADzAAAAApAAAAD7oJAAACAAAADy0AAABfAAAAD7sJAAACAAAADz0AAAArAAAAD7wJAAACAAAAD3EAAABRAAAAD70JAAACAAAAD3cAAABXAAAAD74JAAACAAAAD2UAAABFAAAAD78JAAACAAAAD3IAAABSAAAAD8AJAAACAAAAD3QAAABUAAAAD8EJAAACAAAAD3kAAABZAAAAD8IJAAACAAAAD3UAAABVAAAAD8MJAAACAAAAD2kAAABJAAAAD8QJAAACAAAAD28AAABPAAAAD8UJAAACAAAAD3AAAABQAAAAD8YJAAAEAAAAD1sAAAB7AAAAuf///6n///8PxwkAAAQAAAAPXQAAAH0AAADw////0P///w/ICQAAAgAAAA9hAAAAQQAAAA/JCQAAAgAAAA9zAAAAUwAAAA/KCQAAAgAAAA9kAAAARAAAAA/LCQAAAgAAAA9mAAAARgAAAA/MCQAAAgAAAA9nAAAARwAAAA/NCQAAAgAAAA9oAAAASAAAAA/OCQAAAgAAAA9qAAAASgAAAA/PCQAAAgAAAA9rAAAASwAAAA/QCQAAAgAAAA9sAAAATAAAAA/RCQAABAAAAA87AAAAOgAAAOj////I////D9IJAAAEAAAADycAAAAiAAAA5v///8b///8P0wkAAAQAAAAPXAAAAHwAAAC+////rv///w/UCQAAAgAAAA96AAAAWgAAAA/VCQAAAgAAAA94AAAAWAAAAA/WCQAAAgAAAA9jAAAAQwAAAA/XCQAAAgAAAA92AAAAVgAAAA/YCQAAAgAAAA9iAAAAQgAAAA/ZCQAAAgAAAA9uAAAATgAAAA/aCQAAAgAAAA9tAAAATQAAAA/bCQAAAgAAAA8sAAAAPAAAAA/cCQAAAgAAAA8uAAAAPgAAAA/dCQAAAgAAAA8vAAAAPwAAAA/eCQAAAwAAAA88AAAAPgAAAHwAAAAP3wkAAAAAAAAPD+AJAAACAAAADzEAAAAhAAAAD+EJAAACAAAADzIAAAAiAAAAD+IJAAACAAAADzMAAAAjAAAAD+MJAAACAAAADzQAAAAkAAAAD+QJAAACAAAADzUAAAAlAAAAD+UJAAACAAAADzYAAAAmAAAAD+YJAAACAAAADzcAAAAnAAAAD+cJAAACAAAADzgAAAAoAAAAD+gJAAACAAAADzkAAAApAAAAD+kJAAACAAAADzAAAAB+AAAAD+oJAAACAAAADy0AAAA9AAAAD+sJAAACAAAAD14AAAB+AAAAD+wJAAACAAAAD1wAAAB8AAAAD+0JAAACAAAAD3EAAABRAAAAD+4JAAACAAAAD3cAAABXAAAAD+8JAAACAAAAD2UAAABFAAAAD/AJAAACAAAAD3IAAABSAAAAD/EJAAACAAAAD3QAAABUAAAAD/IJAAACAAAAD3kAAABZAAAAD/MJAAACAAAAD3UAAABVAAAAD/QJAAACAAAAD2kAAABJAAAAD/UJAAACAAAAD28AAABPAAAAD/YJAAACAAAAD3AAAABQAAAAD/cJAAACAAAAD0AAAABgAAAAD/gJAAACAAAAD1sAAAB7AAAAD/kJAAACAAAAD2EAAABBAAAAD/oJAAACAAAAD3MAAABTAAAAD/sJAAACAAAAD2QAAABEAAAAD/wJAAACAAAAD2YAAABGAAAAD/0JAAACAAAAD2cAAABHAAAAD/4JAAACAAAAD2gAAABIAAAAD/8JAAACAAAAD2oAAABKAAAADwAKAAACAAAAD2sAAABLAAAADwEKAAACAAAAD2wAAABMAAAADwIKAAACAAAADzsAAAArAAAADwMKAAACAAAADzoAAAAqAAAADwQKAAACAAAAD10AAAB9AAAADwUKAAACAAAAD3oAAABaAAAADwYKAAACAAAAD3gAAABYAAAADwcKAAACAAAAD2MAAABDAAAADwgKAAACAAAAD3YAAABWAAAADwkKAAACAAAAD2IAAABCAAAADwoKAAACAAAAD24AAABOAAAADwsKAAACAAAAD20AAABNAAAADwwKAAACAAAADywAAAA8AAAADw0KAAACAAAADy4AAAA+AAAADw4KAAACAAAADy8AAAA/AAAADw8KAAACAAAAD1wAAABfAAAADxAKAAAAAAAADw8RCgAAAgAAAA8xAAAAIQAAAA8SCgAAAgAAAA8yAAAAIgAAAA8TCgAAAgAAAA8zAAAAIwAAAA8UCgAAAgAAAA80AAAAJAAAAA8VCgAAAgAAAA81AAAAJQAAAA8WCgAAAgAAAA82AAAAJgAAAA8XCgAAAgAAAA83AAAAJwAAAA8YCgAAAgAAAA84AAAAKAAAAA8ZCgAAAgAAAA85AAAAKQAAAA8aCgAAAQAAAA8wAAAADxsKAAACAAAADy0AAAA9AAAADxwKAAACAAAAD14AAABgAAAADx0KAAACAAAAD1wAAAB8AAAADx4KAAACAAAAD3EAAABRAAAADx8KAAACAAAAD3cAAABXAAAADyAKAAACAAAAD2UAAABFAAAADyEKAAACAAAAD3IAAABSAAAADyIKAAACAAAAD3QAAABUAAAADyMKAAACAAAAD3kAAABZAAAADyQKAAACAAAAD3UAAABVAAAADyUKAAACAAAAD2kAAABJAAAADyYKAAACAAAAD28AAABPAAAADycKAAACAAAAD3AAAABQAAAADygKAAACAAAAD0AAAAB+AAAADykKAAACAAAAD1sAAAB7AAAADyoKAAACAAAAD2EAAABBAAAADysKAAACAAAAD3MAAABTAAAADywKAAACAAAAD2QAAABEAAAADy0KAAACAAAAD2YAAABGAAAADy4KAAACAAAAD2cAAABHAAAADy8KAAACAAAAD2gAAABIAAAADzAKAAACAAAAD2oAAABKAAAADzEKAAACAAAAD2sAAABLAAAADzIKAAACAAAAD2wAAABMAAAADzMKAAACAAAADzsAAAArAAAADzQKAAACAAAADzoAAAAqAAAADzUKAAACAAAAD10AAAB9AAAADzYKAAACAAAAD3oAAABaAAAADzcKAAACAAAAD3gAAABYAAAADzgKAAACAAAAD2MAAABDAAAADzkKAAACAAAAD3YAAABWAAAADzoKAAACAAAAD2IAAABCAAAADzsKAAACAAAAD24AAABOAAAADzwKAAACAAAAD20AAABNAAAADz0KAAACAAAADywAAAA8AAAADz4KAAACAAAADy4AAAA+AAAADz8KAAACAAAADy8AAAA/AAAAD0AKAAACAAAAD1wAAABfAAAAD0EKAAAAAAAADw9CCgAAAgAAAA87AAAAMAAAAA9DCgAAAgAAAA8rAAAAMQAAAA9ECgAAAgAAAA+1////MgAAAA9FCgAAAgAAAA+5////MwAAAA9GCgAAAgAAAA/o////NAAAAA9HCgAAAgAAAA+7////NQAAAA9ICgAAAgAAAA++////NgAAAA9JCgAAAgAAAA/9////NwAAAA9KCgAAAgAAAA/h////OAAAAA9LCgAAAgAAAA/t////OQAAAA9MCgAAAgAAAA/p////MAAAAA9NCgAAAgAAAA89AAAAJQAAAA9OCgAAAgAAAA8nAAAAdgAAAA9PCgAAAgAAAA9xAAAAUQAAAA9QCgAAAgAAAA93AAAAVwAAAA9RCgAAAgAAAA9lAAAARQAAAA9SCgAAAgAAAA9yAAAAUgAAAA9TCgAAAgAAAA90AAAAVAAAAA9UCgAAAgAAAA95AAAAWQAAAA9VCgAAAgAAAA91AAAAVQAAAA9WCgAAAgAAAA9pAAAASQAAAA9XCgAAAgAAAA9vAAAATwAAAA9YCgAAAgAAAA9wAAAAUAAAAA9ZCgAAAgAAAA/6////LwAAAA9aCgAAAgAAAA/k////KAAAAA9bCgAAAgAAAA9hAAAAQQAAAA9cCgAAAgAAAA9zAAAAUwAAAA9dCgAAAgAAAA9kAAAARAAAAA9eCgAAAgAAAA9mAAAARgAAAA9fCgAAAgAAAA9nAAAARwAAAA9gCgAAAgAAAA9oAAAASAAAAA9hCgAAAgAAAA9qAAAASgAAAA9iCgAAAgAAAA9rAAAASwAAAA9jCgAAAgAAAA9sAAAATAAAAA9kCgAAAgAAAA/0////IgAAAA9lCgAAAgAAAA+n////IQAAAA9mCgAAAgAAAA/y////KQAAAA9nCgAAAgAAAA96AAAAWgAAAA9oCgAAAgAAAA94AAAAWAAAAA9pCgAAAgAAAA9jAAAAQwAAAA9qCgAAAgAAAA92AAAAVgAAAA9rCgAAAgAAAA9iAAAAQgAAAA9sCgAAAgAAAA9uAAAATgAAAA9tCgAAAgAAAA9tAAAATQAAAA9uCgAAAgAAAA8sAAAAPwAAAA9vCgAAAgAAAA8uAAAAOgAAAA9wCgAAAgAAAA8tAAAAXwAAAA9xCgAAAgAAAA88AAAAPgAAAA9yCgAAAAAAAA8PcwoAAAIAAAAPYAAAAH4AAAAPdAoAAAIAAAAPMQAAACEAAAAPdQoAAAIAAAAPMgAAAEAAAAAPdgoAAAIAAAAPMwAAACMAAAAPdwoAAAIAAAAPNAAAACQAAAAPeAoAAAIAAAAPNQAAACUAAAAPeQoAAAIAAAAPNgAAAF4AAAAPegoAAAIAAAAPNwAAACYAAAAPewoAAAIAAAAPOAAAACoAAAAPfAoAAAIAAAAPOQAAACgAAAAPfQoAAAIAAAAPMAAAACkAAAAPfgoAAAIAAAAPLQAAAF8AAAAPfwoAAAIAAAAPPQAAACsAAAAPgAoAAAQAAAAPcQAAAFEAAADk////xP///w+BCgAABAAAAA93AAAAVwAAAOz////M////D4IKAAAEAAAAD2UAAABFAAAA6f///8n///8PgwoAAAQAAAAPcgAAAFIAAAD4////2P///w+ECgAABAAAAA90AAAAVAAAALv///+r////D4UKAAAEAAAAD3kAAABZAAAA/f///93///8PhgoAAAQAAAAPdQAAAFUAAAD5////2f///w+HCgAABAAAAA9pAAAASQAAAO3////N////D4gKAAAEAAAAD28AAABPAAAA8////9P///8PiQoAAAQAAAAPcAAAAFAAAAD2////1v///w+KCgAAAgAAAA9bAAAAewAAAA+LCgAAAgAAAA9dAAAAfQAAAA+MCgAABAAAAA9hAAAAQQAAAOH////B////D40KAAAEAAAAD3MAAABTAAAAuf///6n///8PjgoAAAQAAAAPZAAAAEQAAADv////z////w+PCgAABAAAAA9mAAAARgAAAOv////L////D5AKAAAEAAAAD2cAAABHAAAA4P///8D///8PkQoAAAQAAAAPaAAAAEgAAAD6////2v///w+SCgAABAAAAA9qAAAASgAAAPz////c////D5MKAAAEAAAAD2sAAABLAAAA9P///9T///8PlAoAAAQAAAAPbAAAAEwAAAC1////pf///w+VCgAAAgAAAA87AAAAOgAAAA+WCgAAAgAAAA8nAAAAIgAAAA+XCgAAAgAAAA9cAAAAfAAAAA+YCgAABAAAAA96AAAAWgAAAL7///+u////D5kKAAADAAAAD3gAAABYAAAApP///w+aCgAABAAAAA9jAAAAQwAAAOj////I////D5sKAAAEAAAAD3YAAABWAAAA5////8f///8PnAoAAAIAAAAPYgAAAEIAAAAPnQoAAAQAAAAPbgAAAE4AAADy////0v///w+eCgAABAAAAA9tAAAATQAAAOX////F////D58KAAACAAAADywAAAA8AAAAD6AKAAACAAAADy4AAAA+AAAAD6EKAAACAAAADy8AAAA/AAAAD6IKAAACAAAADzwAAAA+AAAAD6MKAAAAAAAADw+kCgAAAQAAAA87AAAAD6UKAAACAAAADysAAAAxAAAAD6YKAAACAAAAD+z///8yAAAAD6cKAAACAAAAD7n///8zAAAAD6gKAAACAAAAD+j///80AAAAD6kKAAACAAAAD/j///81AAAAD6oKAAACAAAAD77///82AAAAD6sKAAACAAAAD/3///83AAAAD6wKAAACAAAAD+H///84AAAAD60KAAACAAAAD+3///85AAAAD64KAAAEAAAAD+n///8wAAAAvf///ykAAAAPrwoAAAIAAAAPPQAAACUAAAAPsAoAAAAAAAAPD7EKAAADAAAAD3EAAABRAAAAXAAAAA+yCgAAAwAAAA93AAAAVwAAAHwAAAAPswoAAAIAAAAPZQAAAEUAAAAPtAoAAAIAAAAPcgAAAFIAAAAPtQoAAAIAAAAPdAAAAFQAAAAPtgoAAAIAAAAPeQAAAFkAAAAPtwoAAAIAAAAPdQAAAFUAAAAPuAoAAAIAAAAPaQAAAEkAAAAPuQoAAAIAAAAPbwAAAE8AAAAPugoAAAIAAAAPcAAAAFAAAAAPuwoAAAQAAAAP+v///y8AAABbAAAAewAAAA+8CgAABAAAAA8pAAAAKAAAAF0AAAB9AAAAD70KAAACAAAAD2EAAABBAAAAD74KAAADAAAAD3MAAABTAAAA8P///w+/CgAAAwAAAA9kAAAARAAAAND///8PwAoAAAMAAAAPZgAAAEYAAABbAAAAD8EKAAADAAAAD2cAAABHAAAAXQAAAA/CCgAAAgAAAA9oAAAASAAAAA/DCgAAAgAAAA9qAAAASgAAAA/ECgAAAwAAAA9rAAAASwAAALP///8PxQoAAAMAAAAPbAAAAEwAAACj////D8YKAAADAAAAD/n///8iAAAAJAAAAA/HCgAAAwAAAA+n////IQAAAN////8PyAoAAAIAAAAPqP///ycAAAAPyQoAAAMAAAAPegAAAFoAAAA+AAAAD8oKAAADAAAAD3gAAABYAAAAIwAAAA/LCgAAAwAAAA9jAAAAQwAAACYAAAAPzAoAAAMAAAAPdgAAAFYAAABAAAAAD80KAAADAAAAD2IAAABCAAAAewAAAA/OCgAAAwAAAA9uAAAATgAAAH0AAAAPzwoAAAIAAAAPbQAAAE0AAAAP0AoAAAMAAAAPLAAAAD8AAAA8AAAAD9EKAAADAAAADy4AAAA6AAAAPgAAAA/SCgAAAwAAAA8tAAAAXwAAACoAAAAP0woAAAQAAAAPPAAAAD4AAABcAAAAfAAAAA/UCgAAAAAAAA8P1QoAAAEAAAAPOwAAAA/WCgAAAgAAAA8rAAAAMQAAAA/XCgAAAgAAAA/s////MgAAAA/YCgAAAgAAAA+5////MwAAAA/ZCgAAAgAAAA/o////NAAAAA/aCgAAAgAAAA/4////NQAAAA/bCgAAAgAAAA++////NgAAAA/cCgAAAgAAAA/9////NwAAAA/dCgAAAgAAAA/h////OAAAAA/eCgAAAgAAAA/t////OQAAAA/fCgAAAgAAAA/p////MAAAAA/gCgAAAgAAAA89AAAAJQAAAA/hCgAAAgAAAA+0////t////w/iCgAAAgAAAA9xAAAAUQAAAA/jCgAAAgAAAA93AAAAVwAAAA/kCgAAAgAAAA9lAAAARQAAAA/lCgAAAgAAAA9yAAAAUgAAAA/mCgAAAgAAAA90AAAAVAAAAA/nCgAAAgAAAA96AAAAWgAAAA/oCgAAAgAAAA91AAAAVQAAAA/pCgAAAgAAAA9pAAAASQAAAA/qCgAAAgAAAA9vAAAATwAAAA/rCgAAAgAAAA9wAAAAUAAAAA/sCgAAAgAAAA/6////LwAAAA/tCgAAAgAAAA8pAAAAKAAAAA/uCgAAAgAAAA9hAAAAQQAAAA/vCgAAAgAAAA9zAAAAUwAAAA/wCgAAAgAAAA9kAAAARAAAAA/xCgAAAgAAAA9mAAAARgAAAA/yCgAAAgAAAA9nAAAARwAAAA/zCgAAAgAAAA9oAAAASAAAAA/0CgAAAgAAAA9qAAAASgAAAA/1CgAAAgAAAA9rAAAASwAAAA/2CgAAAgAAAA9sAAAATAAAAA/3CgAAAgAAAA/5////IgAAAA/4CgAAAgAAAA+n////IQAAAA/5CgAAAgAAAA+o////JwAAAA/6CgAAAgAAAA95AAAAWQAAAA/7CgAAAgAAAA94AAAAWAAAAA/8CgAAAgAAAA9jAAAAQwAAAA/9CgAAAgAAAA92AAAAVgAAAA/+CgAAAgAAAA9iAAAAQgAAAA//CgAAAgAAAA9uAAAATgAAAA8ACwAAAgAAAA9tAAAATQAAAA8BCwAAAgAAAA8sAAAAPwAAAA8CCwAAAgAAAA8uAAAAOgAAAA8DCwAAAgAAAA8tAAAAXwAAAA8ECwAAAQAAAA9cAAAADwULAAAAAAAADw8GCwAAAQAAAA87AAAADwcLAAACAAAADysAAAAxAAAADwgLAAACAAAAD+z///8yAAAADwkLAAACAAAAD7n///8zAAAADwoLAAACAAAAD+j///80AAAADwsLAAACAAAAD/j///81AAAADwwLAAACAAAAD77///82AAAADw0LAAACAAAAD/3///83AAAADw4LAAACAAAAD+H///84AAAADw8LAAACAAAAD+3///85AAAADxALAAACAAAAD+n///8wAAAADxELAAACAAAADz0AAAAlAAAADxILAAACAAAAD7T///+3////DxMLAAACAAAAD3EAAABRAAAADxQLAAACAAAAD3cAAABXAAAADxULAAACAAAAD2UAAABFAAAADxYLAAACAAAAD3IAAABSAAAADxcLAAACAAAAD3QAAABUAAAADxgLAAACAAAAD3kAAABZAAAADxkLAAACAAAAD3UAAABVAAAADxoLAAACAAAAD2kAAABJAAAADxsLAAACAAAAD28AAABPAAAADxwLAAACAAAAD3AAAABQAAAADx0LAAACAAAAD/r///8vAAAADx4LAAACAAAADykAAAAoAAAADx8LAAACAAAAD2EAAABBAAAADyALAAACAAAAD3MAAABTAAAADyELAAACAAAAD2QAAABEAAAADyILAAACAAAAD2YAAABGAAAADyMLAAACAAAAD2cAAABHAAAADyQLAAACAAAAD2gAAABIAAAADyULAAACAAAAD2oAAABKAAAADyYLAAACAAAAD2sAAABLAAAADycLAAACAAAAD2wAAABMAAAADygLAAACAAAAD/n///8iAAAADykLAAACAAAAD6f///8hAAAADyoLAAACAAAAD6j///8nAAAADysLAAACAAAAD3oAAABaAAAADywLAAACAAAAD3gAAABYAAAADy0LAAACAAAAD2MAAABDAAAADy4LAAACAAAAD3YAAABWAAAADy8LAAACAAAAD2IAAABCAAAADzALAAACAAAAD24AAABOAAAADzELAAACAAAAD20AAABNAAAADzILAAACAAAADywAAAA/AAAADzMLAAACAAAADy4AAAA6AAAADzQLAAACAAAADy0AAABfAAAADzULAAABAAAAD1wAAAAPNgsAAAAAAAAPDzcLAAACAAAAD3wAAACw////DzgLAAACAAAADzEAAAAhAAAADzkLAAACAAAADzIAAAAiAAAADzoLAAACAAAADzMAAAAjAAAADzsLAAACAAAADzQAAAAkAAAADzwLAAACAAAADzUAAAAlAAAADz0LAAACAAAADzYAAAAmAAAADz4LAAACAAAADzcAAAAvAAAADz8LAAACAAAADzgAAAAoAAAAD0ALAAACAAAADzkAAAApAAAAD0ELAAACAAAADzAAAAA9AAAAD0ILAAACAAAADycAAAA/AAAAD0MLAAACAAAAD7////+h////D0QLAAADAAAAD3EAAABRAAAAQAAAAA9FCwAAAgAAAA93AAAAVwAAAA9GCwAAAgAAAA9lAAAARQAAAA9HCwAAAgAAAA9yAAAAUgAAAA9ICwAAAgAAAA90AAAAVAAAAA9JCwAAAgAAAA95AAAAWQAAAA9KCwAAAgAAAA91AAAAVQAAAA9LCwAAAgAAAA9pAAAASQAAAA9MCwAAAgAAAA9vAAAATwAAAA9NCwAAAgAAAA9wAAAAUAAAAA9OCwAAAgAAAA+0////qP///w9PCwAAAgAAAA8rAAAAKgAAAA9QCwAAAgAAAA9hAAAAQQAAAA9RCwAAAgAAAA9zAAAAUwAAAA9SCwAAAgAAAA9kAAAARAAAAA9TCwAAAgAAAA9mAAAARgAAAA9UCwAAAgAAAA9nAAAARwAAAA9VCwAAAgAAAA9oAAAASAAAAA9WCwAAAgAAAA9qAAAASgAAAA9XCwAAAgAAAA9rAAAASwAAAA9YCwAAAgAAAA9sAAAATAAAAA9ZCwAAAgAAAA/x////0f///w9aCwAAAwAAAA97AAAAWwAAAF4AAAAPWwsAAAIAAAAPfQAAAF0AAAAPXAsAAAIAAAAPegAAAFoAAAAPXQsAAAIAAAAPeAAAAFgAAAAPXgsAAAIAAAAPYwAAAEMAAAAPXwsAAAIAAAAPdgAAAFYAAAAPYAsAAAIAAAAPYgAAAEIAAAAPYQsAAAIAAAAPbgAAAE4AAAAPYgsAAAIAAAAPbQAAAE0AAAAPYwsAAAIAAAAPLAAAADsAAAAPZAsAAAIAAAAPLgAAADoAAAAPZQsAAAIAAAAPLQAAAF8AAAAPZgsAAAIAAAAPPAAAAD4AAAAPZwsAAAAAAAAPD2gLAAACAAAAD2AAAAB+AAAAD2kLAAACAAAAD+D////A////D2oLAAACAAAAD+j////I////D2sLAAACAAAAD+b////G////D2wLAAACAAAAD+v////L////D20LAAACAAAAD+H////B////D24LAAACAAAAD/D////Q////D28LAAACAAAAD/j////Y////D3ALAAACAAAAD/v////b////D3ELAAACAAAAD6X///8oAAAAD3ILAAACAAAAD7T///8pAAAAD3MLAAACAAAADy0AAABfAAAAD3QLAAACAAAAD/7////e////D3ULAAACAAAAD1wAAAB8AAAAD3YLAAACAAAAD3EAAABRAAAAD3cLAAACAAAAD3cAAABXAAAAD3gLAAACAAAAD2UAAABFAAAAD3kLAAACAAAAD3IAAABSAAAAD3oLAAACAAAAD3QAAABUAAAAD3sLAAACAAAAD3kAAABZAAAAD3wLAAACAAAAD3UAAABVAAAAD30LAAACAAAAD2kAAABJAAAAD34LAAACAAAAD28AAABPAAAAD38LAAACAAAAD3AAAABQAAAAD4ALAAACAAAAD1sAAAB7AAAAD4ELAAACAAAAD10AAAB9AAAAD4ILAAACAAAAD2EAAABBAAAAD4MLAAACAAAAD3MAAABTAAAAD4QLAAACAAAAD2QAAABEAAAAD4ULAAACAAAAD2YAAABGAAAAD4YLAAACAAAAD2cAAABHAAAAD4cLAAACAAAAD2gAAABIAAAAD4gLAAACAAAAD2oAAABKAAAAD4kLAAACAAAAD2sAAABLAAAAD4oLAAACAAAAD2wAAABMAAAAD4sLAAACAAAADzsAAAA6AAAAD4wLAAACAAAADycAAAAiAAAAD40LAAACAAAAD3oAAABaAAAAD44LAAACAAAAD3gAAABYAAAAD48LAAACAAAAD2MAAABDAAAAD5ALAAACAAAAD3YAAABWAAAAD5ELAAACAAAAD2IAAABCAAAAD5ILAAACAAAAD24AAABOAAAAD5MLAAACAAAAD20AAABNAAAAD5QLAAACAAAADywAAAA8AAAAD5ULAAACAAAADy4AAAA+AAAAD5YLAAACAAAADy8AAAA/AAAAD5cLAAAAAAAADw+YCwAAAAAAAA8PmQsAAAIAAAAPIgAAAOn///8PmgsAAAIAAAAPMQAAACEAAAAPmwsAAAIAAAAPMgAAACcAAAAPnAsAAAMAAAAPMwAAAF4AAAAjAAAAD50LAAADAAAADzQAAAArAAAAJAAAAA+eCwAAAgAAAA81AAAAJQAAAA+fCwAAAgAAAA82AAAAJgAAAA+gCwAAAwAAAA83AAAALwAAAHsAAAAPoQsAAAMAAAAPOAAAACgAAABbAAAAD6ILAAADAAAADzkAAAApAAAAXQAAAA+jCwAAAwAAAA8wAAAAPQAAAH0AAAAPpAsAAAMAAAAPKgAAAD8AAABcAAAAD6ULAAACAAAADy0AAABfAAAAD6YLAAADAAAAD3EAAABRAAAAQAAAAA+nCwAAAgAAAA93AAAAVwAAAA+oCwAAAgAAAA9lAAAARQAAAA+pCwAAAgAAAA9yAAAAUgAAAA+qCwAAAgAAAA90AAAAVAAAAA+rCwAAAgAAAA95AAAAWQAAAA+sCwAAAgAAAA91AAAAVQAAAA+tCwAAAwAAAA/9////SQAAAO7///8PrgsAAAIAAAAPbwAAAE8AAAAPrwsAAAIAAAAPcAAAAFAAAAAPsAsAAAIAAAAP8P///9D///8PsQsAAAMAAAAP/P///9z///9+AAAAD7ILAAADAAAAD2EAAABBAAAA5v///w+zCwAAAwAAAA9zAAAAUwAAAN////8PtAsAAAIAAAAPZAAAAEQAAAAPtQsAAAIAAAAPZgAAAEYAAAAPtgsAAAIAAAAPZwAAAEcAAAAPtwsAAAIAAAAPaAAAAEgAAAAPuAsAAAIAAAAPagAAAEoAAAAPuQsAAAIAAAAPawAAAEsAAAAPugsAAAIAAAAPbAAAAEwAAAAPuwsAAAIAAAAP/v///97///8PvAsAAAIAAAAPaQAAAN3///8PvQsAAAMAAAAPLAAAADsAAABgAAAAD74LAAACAAAAD3oAAABaAAAAD78LAAACAAAAD3gAAABYAAAAD8ALAAACAAAAD2MAAABDAAAAD8ELAAACAAAAD3YAAABWAAAAD8ILAAACAAAAD2IAAABCAAAAD8MLAAACAAAAD24AAABOAAAAD8QLAAACAAAAD20AAABNAAAAD8ULAAACAAAAD/b////W////D8YLAAACAAAAD+f////H////D8cLAAACAAAADy4AAAA6AAAAD8gLAAAAAAAADw/JCwAAAAAAAA8PygsAAAIAAAAPIgAAAFwAAAAPywsAAAIAAAAPMQAAACEAAAAPzAsAAAIAAAAPMgAAACcAAAAPzQsAAAIAAAAPMwAAAF4AAAAPzgsAAAIAAAAPNAAAACsAAAAPzwsAAAIAAAAPNQAAACUAAAAP0AsAAAIAAAAPNgAAACYAAAAP0QsAAAIAAAAPNwAAAC8AAAAP0gsAAAIAAAAPOAAAACgAAAAP0wsAAAIAAAAPOQAAACkAAAAP1AsAAAIAAAAPMAAAAD0AAAAP1QsAAAIAAAAPKgAAAD8AAAAP1gsAAAIAAAAPLQAAAF8AAAAP1wsAAAIAAAAPcQAAAFEAAAAP2AsAAAIAAAAPdwAAAFcAAAAP2QsAAAIAAAAPZQAAAEUAAAAP2gsAAAIAAAAPcgAAAFIAAAAP2wsAAAIAAAAPdAAAAFQAAAAP3AsAAAIAAAAPeQAAAFkAAAAP3QsAAAIAAAAPdQAAAFUAAAAP3gsAAAIAAAAPuf///0kAAAAP3wsAAAIAAAAPbwAAAE8AAAAP4AsAAAIAAAAPcAAAAFAAAAAP4QsAAAIAAAAPu////6v///8P4gsAAAIAAAAP/P///9z///8P4wsAAAIAAAAPYQAAAEEAAAAP5AsAAAIAAAAPcwAAAFMAAAAP5QsAAAIAAAAPZAAAAEQAAAAP5gsAAAIAAAAPZgAAAEYAAAAP5wsAAAIAAAAPZwAAAEcAAAAP6AsAAAIAAAAPaAAAAEgAAAAP6QsAAAIAAAAPagAAAEoAAAAP6gsAAAIAAAAPawAAAEsAAAAP6wsAAAIAAAAPbAAAAEwAAAAP7AsAAAIAAAAPuv///6r///8P7QsAAAEAAAAPaQAAAA/uCwAAAgAAAA8sAAAAOwAAAA/vCwAAAgAAAA96AAAAWgAAAA/wCwAAAgAAAA94AAAAWAAAAA/xCwAAAgAAAA9jAAAAQwAAAA/yCwAAAgAAAA92AAAAVgAAAA/zCwAAAgAAAA9iAAAAQgAAAA/0CwAAAgAAAA9uAAAATgAAAA/1CwAAAgAAAA9tAAAATQAAAA/2CwAAAgAAAA/2////1v///w/3CwAAAgAAAA/n////x////w/4CwAAAgAAAA8uAAAAOgAAAA/5CwAAAgAAAA88AAAAPgAAAA/6CwAAAAAAAA8P+wsAAAIAAAAPKwAAACoAAAAP/AsAAAIAAAAPMQAAACEAAAAP/QsAAAIAAAAPMgAAACIAAAAP/gsAAAMAAAAPMwAAAF4AAAAjAAAAD/8LAAACAAAADzQAAAAkAAAADwAMAAACAAAADzUAAAAlAAAADwEMAAACAAAADzYAAAAmAAAADwIMAAACAAAADzcAAAAnAAAADwMMAAACAAAADzgAAAAoAAAADwQMAAACAAAADzkAAAApAAAADwUMAAACAAAADzAAAAA9AAAADwYMAAACAAAADy8AAAA/AAAADwcMAAACAAAADy0AAABfAAAADwgMAAACAAAAD2YAAABGAAAADwkMAAACAAAAD2cAAABHAAAADwoMAAACAAAAD7v///+r////DwsMAAACAAAAD7n///9JAAAADwwMAAACAAAAD28AAABPAAAADw0MAAACAAAAD2QAAABEAAAADw4MAAACAAAAD3IAAABSAAAADw8MAAACAAAAD24AAABOAAAADxAMAAACAAAAD2gAAABIAAAADxEMAAACAAAAD3AAAABQAAAADxIMAAACAAAAD3EAAABRAAAADxMMAAACAAAAD3cAAABXAAAADxQMAAACAAAAD3UAAABVAAAADxUMAAABAAAAD2kAAAAPFgwAAAIAAAAPZQAAAEUAAAAPFwwAAAIAAAAPYQAAAEEAAAAPGAwAAAIAAAAP/P///9z///8PGQwAAAIAAAAPdAAAAFQAAAAPGgwAAAIAAAAPawAAAEsAAAAPGwwAAAIAAAAPbQAAAE0AAAAPHAwAAAIAAAAPbAAAAEwAAAAPHQwAAAIAAAAPeQAAAFkAAAAPHgwAAAIAAAAPuv///6r///8PHwwAAAIAAAAPeAAAAFgAAAAPIAwAAAIAAAAPagAAAEoAAAAPIQwAAAIAAAAP9v///9b///8PIgwAAAIAAAAPdgAAAFYAAAAPIwwAAAIAAAAPYwAAAEMAAAAPJAwAAAIAAAAP5////8f///8PJQwAAAIAAAAPegAAAFoAAAAPJgwAAAIAAAAPcwAAAFMAAAAPJwwAAAIAAAAPYgAAAEIAAAAPKAwAAAIAAAAPLgAAADoAAAAPKQwAAAIAAAAPLAAAADsAAAAPKgwAAAIAAAAPPAAAAD4AAAAPKwwAAAAAAAAPDywMAAADAAAAD2AAAAB+AAAAOwAAAA8tDAAAAgAAAA8xAAAAIQAAAA8uDAAAAgAAAA8yAAAAQAAAAA8vDAAAAgAAAA8zAAAAIwAAAA8wDAAAAgAAAA80AAAAJAAAAA8xDAAAAgAAAA81AAAAJQAAAA8yDAAAAgAAAA82AAAAXgAAAA8zDAAAAgAAAA83AAAAJgAAAA80DAAAAgAAAA84AAAAKgAAAA81DAAAAgAAAA85AAAAKAAAAA82DAAAAgAAAA8wAAAAKQAAAA83DAAAAgAAAA8tAAAAXwAAAA84DAAAAgAAAA89AAAAKwAAAA85DAAAAwAAAA9xAAAAUQAAAC8AAAAPOgwAAAMAAAAPdwAAAFcAAAAnAAAADzsMAAADAAAAD2UAAABFAAAA9////w88DAAAAwAAAA9yAAAAUgAAAPj///8PPQwAAAMAAAAPdAAAAFQAAADg////Dz4MAAADAAAAD3kAAABZAAAA6P///w8/DAAAAwAAAA91AAAAVQAAAOX///8PQAwAAAMAAAAPaQAAAEkAAADv////D0EMAAADAAAAD28AAABPAAAA7f///w9CDAAAAwAAAA9wAAAAUAAAAPT///8PQwwAAAIAAAAPWwAAAHsAAAAPRAwAAAIAAAAPXQAAAH0AAAAPRQwAAAMAAAAPYQAAAEEAAAD5////D0YMAAADAAAAD3MAAABTAAAA4////w9HDAAAAwAAAA9kAAAARAAAAOL///8PSAwAAAMAAAAPZgAAAEYAAADr////D0kMAAADAAAAD2cAAABHAAAA8v///w9KDAAAAwAAAA9oAAAASAAAAOn///8PSwwAAAMAAAAPagAAAEoAAADn////D0wMAAADAAAAD2sAAABLAAAA7P///w9NDAAAAwAAAA9sAAAATAAAAOr///8PTgwAAAMAAAAPOwAAADoAAADz////D08MAAADAAAADycAAAAiAAAALAAAAA9QDAAAAgAAAA9cAAAAfAAAAA9RDAAAAwAAAA96AAAAWgAAAOb///8PUgwAAAMAAAAPeAAAAFgAAADx////D1MMAAADAAAAD2MAAABDAAAA4f///w9UDAAAAwAAAA92AAAAVgAAAOT///8PVQwAAAMAAAAPYgAAAEIAAADw////D1YMAAADAAAAD24AAABOAAAA7v///w9XDAAAAwAAAA9tAAAATQAAAPb///8PWAwAAAMAAAAPLAAAADwAAAD6////D1kMAAADAAAADy4AAAA+AAAA9f///w9aDAAAAwAAAA8vAAAAPwAAAC4AAAAPWwwAAAIAAAAPPAAAAD4AAAAPXAwAAAAAAAAPD10MAAACAAAAD2AAAAB+AAAAD14MAAACAAAADzEAAAAhAAAAD18MAAACAAAADzIAAABAAAAAD2AMAAACAAAADzMAAAAjAAAAD2EMAAACAAAADzQAAAAkAAAAD2IMAAACAAAADzUAAAAlAAAAD2MMAAACAAAADzYAAABeAAAAD2QMAAACAAAADzcAAAAmAAAAD2UMAAACAAAADzgAAAAqAAAAD2YMAAACAAAADzkAAAAoAAAAD2cMAAACAAAADzAAAAApAAAAD2gMAAACAAAADy0AAABfAAAAD2kMAAACAAAADz0AAAArAAAAD2oMAAADAAAAD3EAAABRAAAA9////w9rDAAAAwAAAA93AAAAVwAAAOX///8PbAwAAAMAAAAPZQAAAEUAAADg////D20MAAADAAAAD3IAAABSAAAA+P///w9uDAAAAwAAAA90AAAAVAAAAPr///8PbwwAAAMAAAAPeQAAAFkAAADy////D3AMAAADAAAAD3UAAABVAAAA5f///w9xDAAAAwAAAA9pAAAASQAAAOn///8PcgwAAAMAAAAPbwAAAE8AAADx////D3MMAAADAAAAD3AAAABQAAAA9P///w90DAAAAgAAAA9bAAAAewAAAA91DAAAAgAAAA9dAAAAfQAAAA92DAAAAwAAAA9hAAAAQQAAAOD///8PdwwAAAMAAAAPcwAAAFMAAAD5////D3gMAAADAAAAD2QAAABEAAAA4////w95DAAAAwAAAA9mAAAARgAAAPT///8PegwAAAMAAAAPZwAAAEcAAADi////D3sMAAADAAAAD2gAAABIAAAA5P///w98DAAAAwAAAA9qAAAASgAAAOn///8PfQwAAAMAAAAPawAAAEsAAADr////D34MAAADAAAAD2wAAABMAAAA7P///w9/DAAAAgAAAA87AAAAOgAAAA+ADAAAAgAAAA8nAAAAIgAAAA+BDAAAAgAAAA9cAAAAfAAAAA+CDAAAAwAAAA96AAAAWgAAAOb///8PgwwAAAMAAAAPeAAAAFgAAADn////D4QMAAADAAAAD2MAAABDAAAA9v///w+FDAAAAwAAAA92AAAAVgAAAOX///8PhgwAAAMAAAAPYgAAAEIAAADh////D4cMAAADAAAAD24AAABOAAAA8P///w+IDAAAAwAAAA9tAAAATQAAAO7///8PiQwAAAIAAAAPLAAAADwAAAAPigwAAAIAAAAPLgAAAD4AAAAPiwwAAAIAAAAPLwAAAD8AAAAPjAwAAAIAAAAPPAAAAD4AAAAPjQwAAAAAAAAPD44MAAACAAAAD2AAAAB+AAAAD48MAAACAAAADzEAAAAhAAAAD5AMAAACAAAADzIAAABAAAAAD5EMAAACAAAADzMAAAAjAAAAD5IMAAACAAAADzQAAAAkAAAAD5MMAAACAAAADzUAAAAlAAAAD5QMAAACAAAADzYAAABeAAAAD5UMAAACAAAADzcAAAAmAAAAD5YMAAACAAAADzgAAAAqAAAAD5cMAAACAAAADzkAAAAoAAAAD5gMAAACAAAADzAAAAApAAAAD5kMAAACAAAADy0AAABfAAAAD5oMAAACAAAADz0AAAArAAAAD5sMAAADAAAAD3EAAABRAAAA9////w+cDAAAAwAAAA93AAAAVwAAAPH///8PnQwAAAIAAAAPZQAAAEUAAAAPngwAAAMAAAAPcgAAAFIAAAD4////D58MAAADAAAAD3QAAABUAAAA6P///w+gDAAAAwAAAA95AAAAWQAAAOP///8PoQwAAAIAAAAPdQAAAFUAAAAPogwAAAIAAAAPaQAAAEkAAAAPowwAAAIAAAAPbwAAAE8AAAAPpAwAAAMAAAAPcAAAAFAAAAD0////D6UMAAACAAAAD1sAAAB7AAAAD6YMAAACAAAAD10AAAB9AAAAD6cMAAADAAAAD2EAAABBAAAA4P///w+oDAAAAwAAAA9zAAAAUwAAAOX///8PqQwAAAMAAAAPZAAAAEQAAADs////D6oMAAADAAAAD2YAAABGAAAA+v///w+rDAAAAwAAAA9nAAAARwAAAOL///8PrAwAAAMAAAAPaAAAAEgAAADk////D60MAAADAAAAD2oAAABKAAAA+f///w+uDAAAAwAAAA9rAAAASwAAAOv///8PrwwAAAMAAAAPbAAAAEwAAADp////D7AMAAACAAAADzsAAAA6AAAAD7EMAAACAAAADycAAAAiAAAAD7IMAAACAAAAD1wAAAB8AAAAD7MMAAADAAAAD3oAAABaAAAA5v///w+0DAAAAwAAAA94AAAAWAAAAOf///8PtQwAAAMAAAAPYwAAAEMAAAD2////D7YMAAADAAAAD3YAAABWAAAA8v///w+3DAAAAwAAAA9iAAAAQgAAAOH///8PuAwAAAMAAAAPbgAAAE4AAADw////D7kMAAADAAAAD20AAABNAAAA7v///w+6DAAAAgAAAA8sAAAAPAAAAA+7DAAAAgAAAA8uAAAAPgAAAA+8DAAAAgAAAA8vAAAAPwAAAA+9DAAAAgAAAA88AAAAPgAAAA++DAAAAAAAAA8PvwwAAAIAAAAPMQAAACEAAAAPwAwAAAIAAAAPMgAAAEAAAAAPwQwAAAIAAAAPMwAAACMAAAAPwgwAAAIAAAAPNAAAACQAAAAPwwwAAAIAAAAPNQAAACUAAAAPxAwAAAIAAAAPNgAAAF4AAAAPxQwAAAIAAAAPNwAAACYAAAAPxgwAAAIAAAAPOAAAACoAAAAPxwwAAAIAAAAPOQAAACgAAAAPyAwAAAIAAAAPMAAAACkAAAAPyQwAAAIAAAAPLQAAAF8AAAAPygwAAAIAAAAPPQAAACsAAAAPywwAAAIAAAAPWwAAAHsAAAAPzAwAAAIAAAAPXQAAAH0AAAAPzQwAAAIAAAAPOwAAADoAAAAPzgwAAAIAAAAPJwAAACIAAAAPzwwAAAIAAAAPYAAAAH4AAAAP0AwAAAIAAAAPLAAAADwAAAAP0QwAAAIAAAAPLgAAAD4AAAAP0gwAAAIAAAAPLwAAAD8AAAAP0wwAAAIAAAAPXAAAAHwAAAAP1AwAAAIAAAAPYQAAAEEAAAAP1QwAAAIAAAAPYgAAAEIAAAAP1gwAAAIAAAAPYwAAAEMAAAAP1wwAAAIAAAAPZAAAAEQAAAAP2AwAAAIAAAAPZQAAAEUAAAAP2QwAAAIAAAAPZgAAAEYAAAAP2gwAAAIAAAAPZwAAAEcAAAAP2wwAAAIAAAAPaAAAAEgAAAAP3AwAAAIAAAAPaQAAAEkAAAAP3QwAAAIAAAAPagAAAEoAAAAP3gwAAAIAAAAPawAAAEsAAAAP3wwAAAIAAAAPbAAAAEwAAAAP4AwAAAIAAAAPbQAAAE0AAAAP4QwAAAIAAAAPbgAAAE4AAAAP4gwAAAIAAAAPbwAAAE8AAAAP4wwAAAIAAAAPcAAAAFAAAAAP5AwAAAIAAAAPcQAAAFEAAAAP5QwAAAIAAAAPcgAAAFIAAAAP5gwAAAIAAAAPcwAAAFMAAAAP5wwAAAIAAAAPdAAAAFQAAAAP6AwAAAIAAAAPdQAAAFUAAAAP6QwAAAIAAAAPdgAAAFYAAAAP6gwAAAIAAAAPdwAAAFcAAAAP6wwAAAIAAAAPeAAAAFgAAAAP7AwAAAIAAAAPeQAAAFkAAAAP7QwAAAIAAAAPegAAAFoAAAAP7gwAAAAAAAAPD+8MAAAAAAAADw/wDAAAAgAAAA9gAAAAfgAAAA/xDAAAAgAAAA8xAAAAIQAAAA/yDAAAAgAAAA8yAAAAQAAAAA/zDAAAAgAAAA8zAAAAIwAAAA/0DAAAAgAAAA80AAAAJAAAAA/1DAAAAgAAAA81AAAAJQAAAA/2DAAAAgAAAA82AAAAXgAAAA/3DAAAAgAAAA83AAAAJgAAAA/4DAAAAgAAAA84AAAAKgAAAA/5DAAAAgAAAA85AAAAKAAAAA/6DAAAAgAAAA8wAAAAKQAAAA/7DAAAAgAAAA8tAAAAXwAAAA/8DAAAAgAAAA89AAAAKwAAAA/9DAAABAAAAA9xAAAAUQAAADsAAAA6AAAAD/4MAAACAAAAD3cAAABXAAAAD/8MAAAEAAAAD2UAAABFAAAA5f///8X///8PAA0AAAQAAAAPcgAAAFIAAADx////0f///w8BDQAABAAAAA90AAAAVAAAAPT////U////DwINAAAEAAAAD3kAAABZAAAA9f///9X///8PAw0AAAQAAAAPdQAAAFUAAADo////yP///w8EDQAABAAAAA9pAAAASQAAAOn////J////DwUNAAAEAAAAD28AAABPAAAA7////8////8PBg0AAAQAAAAPcAAAAFAAAADw////0P///w8HDQAAAgAAAA9bAAAAewAAAA8IDQAAAgAAAA9dAAAAfQAAAA8JDQAABAAAAA9hAAAAQQAAAOH////B////DwoNAAACAAAAD3MAAABTAAAADwsNAAAEAAAAD2QAAABEAAAA5P///8T///8PDA0AAAQAAAAPZgAAAEYAAAD2////1v///w8NDQAABAAAAA9nAAAARwAAAOP////D////Dw4NAAAEAAAAD2gAAABIAAAA5////8f///8PDw0AAAQAAAAPagAAAEoAAADu////zv///w8QDQAABAAAAA9rAAAASwAAAOr////K////DxENAAAEAAAAD2wAAABMAAAA6////8v///8PEg0AAAQAAAAPOwAAADoAAAC0////qP///w8TDQAAAgAAAA8nAAAAIgAAAA8UDQAAAgAAAA9cAAAAfAAAAA8VDQAABAAAAA96AAAAWgAAAOb////G////DxYNAAAEAAAAD3gAAABYAAAA9////9f///8PFw0AAAQAAAAPYwAAAEMAAAD4////2P///w8YDQAABAAAAA92AAAAVgAAAPn////Z////DxkNAAAEAAAAD2IAAABCAAAA4v///8L///8PGg0AAAQAAAAPbgAAAE4AAADt////zf///w8bDQAABAAAAA9tAAAATQAAAOz////M////DxwNAAACAAAADywAAAA8AAAADx0NAAACAAAADy4AAAA+AAAADx4NAAACAAAADy8AAAA/AAAADx8NAAACAAAADzwAAAA+AAAADyANAAAAAAAADw8hDQAABAAAAA9gAAAAfgAAAF8AAAAlAAAADyINAAAEAAAADzEAAAAhAAAA5f///ysAAAAPIw0AAAQAAAAPMgAAAEAAAAAvAAAA8f///w8kDQAABAAAAA8zAAAAIwAAAC0AAADy////DyUNAAAEAAAADzQAAAAkAAAAwP////P///8PJg0AAAQAAAAPNQAAACUAAAC2////9P///w8nDQAABAAAAA82AAAAXgAAANj////Z////DygNAAAEAAAADzcAAAAmAAAA1v///9////8PKQ0AAAQAAAAPOAAAACoAAACk////9f///w8qDQAABAAAAA85AAAAKAAAALX////2////DysNAAAEAAAADzAAAAApAAAAqP////f///8PLA0AAAQAAAAPLQAAAF8AAACi////+P///w8tDQAABAAAAA89AAAAKwAAAKr////5////Dy4NAAAEAAAAD3EAAABRAAAA5v////D///8PLw0AAAQAAAAPdwAAAFcAAADk////IgAAAA8wDQAABAAAAA9lAAAARQAAANP///+u////DzENAAAEAAAAD3IAAABSAAAAvv///7H///8PMg0AAAQAAAAPdAAAAFQAAADQ////uP///w8zDQAABAAAAA95AAAAWQAAANH////t////DzQNAAAEAAAAD3UAAABVAAAA1f///+r///8PNQ0AAAQAAAAPaQAAAEkAAADD////s////w82DQAABAAAAA9vAAAATwAAALn////P////DzcNAAAEAAAAD3AAAABQAAAAwv///63///8POA0AAAQAAAAPWwAAAHsAAAC6////sP///w85DQAABAAAAA9dAAAAfQAAAMX///8sAAAADzoNAAAEAAAAD2EAAABBAAAAv////8T///8POw0AAAQAAAAPcwAAAFMAAADL////pv///w88DQAABAAAAA9kAAAARAAAAKH///+v////Dz0NAAAEAAAAD2YAAABGAAAAtP///+L///8PPg0AAAQAAAAPZwAAAEcAAADg////rP///w8/DQAABAAAAA9oAAAASAAAAOn////n////D0ANAAAEAAAAD2oAAABKAAAA6P///+v///8PQQ0AAAQAAAAPawAAAEsAAADS////yf///w9CDQAABAAAAA9sAAAATAAAAMr////I////D0MNAAAEAAAADzsAAAA6AAAAx////6v///8PRA0AAAQAAAAPJwAAACIAAACn////LgAAAA9FDQAABAAAAA9cAAAAfAAAAKP///+l////D0YNAAAEAAAAD3oAAABaAAAAvP///ygAAAAPRw0AAAQAAAAPeAAAAFgAAAC7////KQAAAA9IDQAABAAAAA9jAAAAQwAAAOH///+p////D0kNAAAEAAAAD3YAAABWAAAAzf///87///8PSg0AAAMAAAAPYgAAAEIAAADa////D0sNAAAEAAAAD24AAABOAAAA1////+z///8PTA0AAAQAAAAPbQAAAE0AAAC3////PwAAAA9NDQAABAAAAA8sAAAAPAAAAMH///+y////D04NAAAEAAAADy4AAAA+AAAA4////8z///8PTw0AAAQAAAAPLwAAAD8AAAC9////xv///w9QDQAAAAAAAA8PUQ0AAAAAAAAPD1INAAACAAAAD0AAAACn////D1MNAAACAAAADzEAAAAhAAAAD1QNAAACAAAADzIAAAAiAAAAD1UNAAACAAAADzMAAAAjAAAAD1YNAAACAAAADzQAAAAkAAAAD1cNAAACAAAADzUAAAAlAAAAD1gNAAACAAAADzYAAAAmAAAAD1kNAAACAAAADzcAAABfAAAAD1oNAAACAAAADzgAAAAoAAAAD1sNAAACAAAADzkAAAApAAAAD1wNAAACAAAADzAAAAAnAAAAD10NAAACAAAADy8AAAA/AAAAD14NAAACAAAAD7D///9+AAAAD18NAAACAAAAD3EAAABRAAAAD2ANAAACAAAAD3cAAABXAAAAD2ENAAACAAAAD2UAAABFAAAAD2INAAACAAAAD3IAAABSAAAAD2MNAAACAAAAD3QAAABUAAAAD2QNAAACAAAAD3kAAABZAAAAD2UNAAACAAAAD3UAAABVAAAAD2YNAAACAAAAD2kAAABJAAAAD2cNAAACAAAAD28AAABPAAAAD2gNAAACAAAAD3AAAABQAAAAD2kNAAACAAAAD6j///9+AAAAD2oNAAACAAAADyoAAAB8AAAAD2sNAAACAAAAD2EAAABBAAAAD2wNAAACAAAAD3MAAABTAAAAD20NAAACAAAAD2QAAABEAAAAD24NAAACAAAAD2YAAABGAAAAD28NAAACAAAAD2cAAABHAAAAD3ANAAACAAAAD2gAAABIAAAAD3ENAAACAAAAD2oAAABKAAAAD3INAAACAAAAD2sAAABLAAAAD3MNAAACAAAAD2wAAABMAAAAD3QNAAACAAAADysAAACx////D3UNAAACAAAADycAAABgAAAAD3YNAAACAAAADzwAAAA+AAAAD3cNAAACAAAAD3oAAABaAAAAD3gNAAACAAAAD3gAAABYAAAAD3kNAAACAAAAD2MAAABDAAAAD3oNAAACAAAAD3YAAABWAAAAD3sNAAACAAAAD2IAAABCAAAAD3wNAAACAAAAD24AAABOAAAAD30NAAACAAAAD20AAABNAAAAD34NAAACAAAADywAAAA7AAAAD38NAAACAAAADy4AAAA6AAAAD4ANAAACAAAADy0AAAA9AAAAD4ENAAACAAAAD1sAAABdAAAAD4INAAAAAAAADws=</value>
+ </data><data name="scan_table" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>AAEAAAD/////AQAAAAAAAAAHAQAAAAEBAAAABQAAAAcHCQIAAAAJAwAAAAkEAAAACQUAAAAJBgAAAA8CAAAAMAAAAAcpAAIAAwAEAAUABgAHAAgACQAKAAsADAANABAAEQASABMAFAAVABYAFwAYABkAGgAbAB4AHwAgACEAIgAjACQAJQAmACcAKAArACwALQAuAC8AMAAxADIAMwA0ADUAVgAPAwAAADAAAAAHKQACAAMABAAFAAYABwAIAAkACgALABoAGwAoADMANAAZABUAIQAiAC4AEwAmADUADQAeABgAEgAWABcAIAAjABQAMQAfAAwAKwAnABAAJAAlAC0AMAAyABEALwAsAFYADwQAAAAxAAAABykAAgADAAQABQAGAAcACAAJAAoACwAMAA0AEAARABIAEwAUABUAFgAXABgAGQAaABsAHgAfACAAIQAiACMAJAAlACYAJwAoACsAXgAsAC0ALgAvADAAMQAyADMANAA1AFYADwUAAAAwAAAABwIAAwAEAAUABgAHAAgACQAKAAsADAANACkAEAARABIAEwAUABUAFgAXABgAGQAaABsAHgAfACAAIQAiACMAJAAlACYAJwAoACsALAAtAC4ALwAwADEAMgAzADQANQBWAA8GAAAAMAAAAAcCAAMABAAFAAYABwAIAAkACgALAAwADQAaABsAJwAoACkAMwA0ADUAKwAeADAALgAgABIAIQAiACMAFwAkACUAJgAyADEAGAAZABAAEwAfABQAFgAvABEALQAVACwAVgAL</value>
+ </data><data name="vkey_table" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>AAEAAAD/////AQAAAAAAAAAHAQAAAAEBAAAACQAAAAcICQIAAAAJAwAAAAkEAAAACQUAAAAJBgAAAAkHAAAACQgAAAAJCQAAAAkKAAAADwIAAAAwAAAACMAAAAAxAAAAMgAAADMAAAA0AAAANQAAADYAAAA3AAAAOAAAADkAAAAwAAAAvQAAALsAAABRAAAAVwAAAEUAAABSAAAAVAAAAFkAAABVAAAASQAAAE8AAABQAAAA2wAAAN0AAABBAAAAUwAAAEQAAABGAAAARwAAAEgAAABKAAAASwAAAEwAAAC6AAAA3gAAANwAAABaAAAAWAAAAEMAAABWAAAAQgAAAE4AAABNAAAAvAAAAL4AAAC/AAAA4gAAAA8DAAAAMAAAAAjAAAAAMQAAADIAAAAzAAAANAAAADUAAAA2AAAANwAAADgAAAA5AAAAMAAAAL0AAAC7AAAAUQAAAFcAAABFAAAAUgAAAFQAAABaAAAAVQAAAEkAAABPAAAAUAAAANsAAADdAAAAQQAAAFMAAABEAAAARgAAAEcAAABIAAAASgAAAEsAAABMAAAAugAAAN4AAADcAAAAWQAAAFgAAABDAAAAVgAAAEIAAABOAAAATQAAALwAAAC+AAAAvwAAAOIAAAAPBAAAADAAAAAIwAAAADEAAAAyAAAAMwAAADQAAAA1AAAANgAAADcAAAA4AAAAOQAAADAAAADbAAAA3QAAAN4AAAC8AAAAvgAAAFAAAABZAAAARgAAAEcAAABDAAAAUgAAAEwAAAC/AAAAuwAAAEEAAABPAAAARQAAAFUAAABJAAAARAAAAEgAAABUAAAATgAAAFMAAAC9AAAA3AAAALoAAABRAAAASgAAAEsAAABYAAAAQgAAAE0AAABXAAAAVgAAAFoAAADiAAAADwUAAAAwAAAACN4AAAAxAAAAMgAAADMAAAA0AAAANQAAADYAAAA3AAAAOAAAADkAAAAwAAAA2wAAALsAAABBAAAAWgAAAEUAAABSAAAAVAAAAFkAAABVAAAASQAAAE8AAABQAAAA3QAAALoAAABRAAAAUwAAAEQAAABGAAAARwAAAEgAAABKAAAASwAAAEwAAABNAAAAwAAAANwAAABXAAAAWAAAAEMAAABWAAAAQgAAAE4AAAC8AAAAvgAAAL8AAADfAAAA4gAAAA8GAAAAMAAAAAjeAAAAMQAAADIAAAAzAAAANAAAADUAAAA2AAAANwAAADgAAAA5AAAAMAAAANsAAAC7AAAAQQAAAFoAAABFAAAAUgAAAFQAAABZAAAAVQAAAEkAAABPAAAAUAAAAN0AAAC6AAAAUQAAAFMAAABEAAAARgAAAEcAAABIAAAASgAAAEsAAABMAAAATQAAAMAAAADcAAAAVwAAAFgAAABDAAAAVgAAAEIAAABOAAAAvAAAAL4AAAC/AAAA3wAAAOIAAAAPBwAAADAAAAAI3gAAADEAAAAyAAAAMwAAADQAAAA1AAAANgAAADcAAAA4AAAAOQAAADAAAADbAAAAuwAAAEEAAABaAAAARQAAAFIAAABUAAAAWQAAAFUAAABJAAAATwAAAFAAAADdAAAAugAAAFEAAABTAAAARAAAAEYAAABHAAAASAAAAEoAAABLAAAATAAAAE0AAADAAAAA3AAAAFcAAABYAAAAQwAAAFYAAABCAAAATgAAALwAAAC+AAAAvwAAAN8AAADiAAAADwgAAAAwAAAACN4AAAAxAAAAMgAAADMAAAA0AAAANQAAADYAAAA3AAAAOAAAADkAAAAwAAAA2wAAALsAAABBAAAAWgAAAEUAAABSAAAAVAAAAFkAAABVAAAASQAAAE8AAABQAAAA3QAAALoAAABRAAAAUwAAAEQAAABGAAAARwAAAEgAAABKAAAASwAAAEwAAABNAAAAwAAAANwAAABXAAAAWAAAAEMAAABWAAAAQgAAAE4AAAC8AAAAvgAAAL8AAADfAAAA4gAAAA8JAAAAMAAAAAjeAAAAMQAAADIAAAAzAAAANAAAADUAAAA2AAAANwAAADgAAAA5AAAAMAAAANsAAAC7AAAAQQAAAFoAAABFAAAAUgAAAFQAAABZAAAAVQAAAEkAAABPAAAAUAAAAN0AAAC6AAAAUQAAAFMAAABEAAAARgAAAEcAAABIAAAASgAAAEsAAABMAAAATQAAAMAAAADcAAAAVwAAAFgAAABDAAAAVgAAAEIAAABOAAAAvAAAAL4AAAC/AAAA3wAAAOIAAAAPCgAAADAAAAAIMQAAADIAAAAzAAAANAAAADUAAAA2AAAANwAAADgAAAA5AAAAMAAAAL0AAAC7AAAA2wAAAN0AAAC6AAAA3gAAAMAAAAC8AAAAvgAAAL8AAADcAAAAQQAAAEIAAABDAAAARAAAAEUAAABGAAAARwAAAEgAAABJAAAASgAAAEsAAABMAAAATQAAAE4AAABPAAAAUAAAAFEAAABSAAAAUwAAAFQAAABVAAAAVgAAAFcAAABYAAAAWQAAAFoAAADiAAAACw==</value>
+ </data></root> \ No newline at end of file
diff --git a/mcs/class/Managed.Windows.Forms/samples/Changelog b/mcs/class/Managed.Windows.Forms/samples/Changelog
new file mode 100644
index 00000000000..3c69c1b55db
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/samples/Changelog
@@ -0,0 +1,6 @@
+2005-10-05 Hisham Mardam Bey <hisham.mardambey@gmail.com>
+
+ * Added mailclient.cs which illustrates boxes, multiline text,
+ scrollbars, labels, single line text and combo boxes.
+ * Added notepad.cs which serves as a visual test and sample for
+ scrollbars, menus, file save dialog, and text area.
diff --git a/mcs/class/Managed.Windows.Forms/samples/mailclient.cs b/mcs/class/Managed.Windows.Forms/samples/mailclient.cs
new file mode 100644
index 00000000000..ef66675e2e3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/samples/mailclient.cs
@@ -0,0 +1,280 @@
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Windows.Forms;
+using System.Data;
+
+namespace smtp_csharp
+{
+ public class frmMain : System.Windows.Forms.Form
+ {
+ internal System.Windows.Forms.GroupBox GroupBox2;
+ internal System.Windows.Forms.Label LabelAuthType;
+ internal System.Windows.Forms.ComboBox cmbAuth;
+ internal System.Windows.Forms.Label LabelPopServer;
+ internal System.Windows.Forms.TextBox txtPOPServer;
+ internal System.Windows.Forms.Label LabelPasswd;
+ internal System.Windows.Forms.TextBox txtPassword;
+ internal System.Windows.Forms.Label LabelUsername;
+ internal System.Windows.Forms.TextBox txtUsername;
+ internal System.Windows.Forms.Label LabelServer;
+ internal System.Windows.Forms.TextBox txtServer;
+ internal System.Windows.Forms.GroupBox GroupBox1;
+ internal System.Windows.Forms.Button cmdSend;
+ internal System.Windows.Forms.Label LabelMessage;
+ internal System.Windows.Forms.Label LabelSubject;
+ internal System.Windows.Forms.Label LabelSentTo;
+ internal System.Windows.Forms.Label LabelMailFrom;
+ internal System.Windows.Forms.TextBox txtMessageText;
+ internal System.Windows.Forms.TextBox txtMessageSubject;
+ internal System.Windows.Forms.TextBox txtSendTo;
+ internal System.Windows.Forms.TextBox txtMailFrom;
+
+ private System.ComponentModel.Container components = null;
+
+ public frmMain()
+ {
+ InitializeComponent();
+ }
+
+ protected override void Dispose( bool disposing )
+ {
+ if( disposing )
+ {
+ if (components != null)
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose( disposing );
+ }
+
+ private void InitializeComponent()
+ {
+ this.GroupBox2 = new System.Windows.Forms.GroupBox();
+ this.LabelAuthType = new System.Windows.Forms.Label();
+ this.cmbAuth = new System.Windows.Forms.ComboBox();
+ this.LabelPopServer = new System.Windows.Forms.Label();
+ this.txtPOPServer = new System.Windows.Forms.TextBox();
+ this.LabelPasswd = new System.Windows.Forms.Label();
+ this.txtPassword = new System.Windows.Forms.TextBox();
+ this.LabelUsername = new System.Windows.Forms.Label();
+ this.txtUsername = new System.Windows.Forms.TextBox();
+ this.LabelServer = new System.Windows.Forms.Label();
+ this.txtServer = new System.Windows.Forms.TextBox();
+ this.GroupBox1 = new System.Windows.Forms.GroupBox();
+ this.cmdSend = new System.Windows.Forms.Button();
+ this.LabelMessage = new System.Windows.Forms.Label();
+ this.LabelSubject = new System.Windows.Forms.Label();
+ this.LabelSentTo = new System.Windows.Forms.Label();
+ this.LabelMailFrom = new System.Windows.Forms.Label();
+ this.txtMessageText = new System.Windows.Forms.TextBox();
+ this.txtMessageSubject = new System.Windows.Forms.TextBox();
+ this.txtSendTo = new System.Windows.Forms.TextBox();
+ this.txtMailFrom = new System.Windows.Forms.TextBox();
+ this.GroupBox2.SuspendLayout();
+ this.GroupBox1.SuspendLayout();
+ this.SuspendLayout();
+
+ this.GroupBox2.Controls.Add(this.LabelAuthType);
+ this.GroupBox2.Controls.Add(this.cmbAuth);
+ this.GroupBox2.Controls.Add(this.LabelPopServer);
+ this.GroupBox2.Controls.Add(this.txtPOPServer);
+ this.GroupBox2.Controls.Add(this.LabelPasswd);
+ this.GroupBox2.Controls.Add(this.txtPassword);
+ this.GroupBox2.Controls.Add(this.LabelUsername);
+ this.GroupBox2.Controls.Add(this.txtUsername);
+ this.GroupBox2.Controls.Add(this.LabelServer);
+ this.GroupBox2.Controls.Add(this.txtServer);
+ this.GroupBox2.Location = new System.Drawing.Point(264, 10);
+ this.GroupBox2.Name = "GroupBox2";
+ this.GroupBox2.Size = new System.Drawing.Size(240, 216);
+ this.GroupBox2.TabIndex = 11;
+ this.GroupBox2.TabStop = false;
+ this.GroupBox2.Text = "Connection Settings";
+
+ this.LabelAuthType.AutoSize = true;
+ this.LabelAuthType.Location = new System.Drawing.Point(24, 98);
+ this.LabelAuthType.Name = "LabelAuthType";
+ this.LabelAuthType.Size = new System.Drawing.Size(101, 16);
+ this.LabelAuthType.TabIndex = 14;
+ this.LabelAuthType.Text = "Authentication type";
+ this.LabelAuthType.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+
+ this.cmbAuth.Location = new System.Drawing.Point(128, 96);
+ this.cmbAuth.Name = "cmbAuth";
+ this.cmbAuth.Size = new System.Drawing.Size(96, 21);
+ this.cmbAuth.TabIndex = 13;
+ this.cmbAuth.Text = "ComboBox1";
+
+ this.LabelPopServer.AutoSize = true;
+ this.LabelPopServer.Location = new System.Drawing.Point(24, 122);
+ this.LabelPopServer.Name = "LabelPopServer";
+ this.LabelPopServer.Size = new System.Drawing.Size(71, 16);
+ this.LabelPopServer.TabIndex = 12;
+ this.LabelPopServer.Text = "POP3 Server";
+ this.LabelPopServer.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+
+ this.txtPOPServer.Location = new System.Drawing.Point(104, 120);
+ this.txtPOPServer.Name = "txtPOPServer";
+ this.txtPOPServer.Size = new System.Drawing.Size(120, 20);
+ this.txtPOPServer.TabIndex = 11;
+ this.txtPOPServer.Text = "";
+
+ this.LabelPasswd.AutoSize = true;
+ this.LabelPasswd.Location = new System.Drawing.Point(24, 74);
+ this.LabelPasswd.Name = "LabelPasswd";
+ this.LabelPasswd.Size = new System.Drawing.Size(54, 16);
+ this.LabelPasswd.TabIndex = 10;
+ this.LabelPasswd.Text = "Password";
+ this.LabelPasswd.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+
+ this.txtPassword.Location = new System.Drawing.Point(88, 72);
+ this.txtPassword.Name = "txtPassword";
+ this.txtPassword.Size = new System.Drawing.Size(136, 20);
+ this.txtPassword.TabIndex = 9;
+ this.txtPassword.Text = "";
+
+ this.LabelUsername.AutoSize = true;
+ this.LabelUsername.Location = new System.Drawing.Point(24, 50);
+ this.LabelUsername.Name = "LabelUsername";
+ this.LabelUsername.Size = new System.Drawing.Size(56, 16);
+ this.LabelUsername.TabIndex = 8;
+ this.LabelUsername.Text = "Username";
+ this.LabelUsername.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+
+ this.txtUsername.Location = new System.Drawing.Point(88, 48);
+ this.txtUsername.Name = "txtUsername";
+ this.txtUsername.Size = new System.Drawing.Size(136, 20);
+ this.txtUsername.TabIndex = 7;
+ this.txtUsername.Text = "";
+
+ this.LabelServer.AutoSize = true;
+ this.LabelServer.Location = new System.Drawing.Point(24, 26);
+ this.LabelServer.Name = "LabelServer";
+ this.LabelServer.Size = new System.Drawing.Size(38, 16);
+ this.LabelServer.TabIndex = 6;
+ this.LabelServer.Text = "Server";
+ this.LabelServer.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+
+ this.txtServer.Location = new System.Drawing.Point(88, 24);
+ this.txtServer.Name = "txtServer";
+ this.txtServer.Size = new System.Drawing.Size(136, 20);
+ this.txtServer.TabIndex = 5;
+ this.txtServer.Text = "localhost";
+
+ this.GroupBox1.Controls.Add(this.cmdSend);
+ this.GroupBox1.Controls.Add(this.LabelMessage);
+ this.GroupBox1.Controls.Add(this.LabelSubject);
+ this.GroupBox1.Controls.Add(this.LabelSentTo);
+ this.GroupBox1.Controls.Add(this.LabelMailFrom);
+ this.GroupBox1.Controls.Add(this.txtMessageText);
+ this.GroupBox1.Controls.Add(this.txtMessageSubject);
+ this.GroupBox1.Controls.Add(this.txtSendTo);
+ this.GroupBox1.Controls.Add(this.txtMailFrom);
+ this.GroupBox1.Location = new System.Drawing.Point(8, 10);
+ this.GroupBox1.Name = "GroupBox1";
+ this.GroupBox1.Size = new System.Drawing.Size(240, 216);
+ this.GroupBox1.TabIndex = 10;
+ this.GroupBox1.TabStop = false;
+ this.GroupBox1.Text = "Email Editor";
+
+ this.cmdSend.Location = new System.Drawing.Point(80, 184);
+ this.cmdSend.Name = "cmdSend";
+ this.cmdSend.TabIndex = 8;
+ this.cmdSend.Text = "Send";
+ this.cmdSend.Click += new System.EventHandler(this.cmdSend_Click);
+
+ this.LabelMessage.AutoSize = true;
+ this.LabelMessage.Location = new System.Drawing.Point(16, 104);
+ this.LabelMessage.Name = "LabelMessage";
+ this.LabelMessage.Size = new System.Drawing.Size(50, 16);
+ this.LabelMessage.TabIndex = 7;
+ this.LabelMessage.Text = "Message";
+ this.LabelMessage.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+
+ this.LabelSubject.AutoSize = true;
+ this.LabelSubject.Location = new System.Drawing.Point(16, 74);
+ this.LabelSubject.Name = "LabelSubject";
+ this.LabelSubject.Size = new System.Drawing.Size(42, 16);
+ this.LabelSubject.TabIndex = 6;
+ this.LabelSubject.Text = "Subject";
+ this.LabelSubject.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+
+ this.LabelSentTo.AutoSize = true;
+ this.LabelSentTo.Location = new System.Drawing.Point(16, 50);
+ this.LabelSentTo.Name = "LabelSentTo";
+ this.LabelSentTo.Size = new System.Drawing.Size(43, 16);
+ this.LabelSentTo.TabIndex = 5;
+ this.LabelSentTo.Text = "Send to";
+ this.LabelSentTo.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+
+ this.LabelMailFrom.AutoSize = true;
+ this.LabelMailFrom.Location = new System.Drawing.Point(16, 26);
+ this.LabelMailFrom.Name = "LabelMailFrom";
+ this.LabelMailFrom.Size = new System.Drawing.Size(51, 16);
+ this.LabelMailFrom.TabIndex = 4;
+ this.LabelMailFrom.Text = "Mail from";
+ this.LabelMailFrom.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+
+ this.txtMessageText.Location = new System.Drawing.Point(80, 96);
+ this.txtMessageText.Multiline = true;
+ this.txtMessageText.Name = "txtMessageText";
+ this.txtMessageText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
+ this.txtMessageText.Size = new System.Drawing.Size(136, 80);
+ this.txtMessageText.TabIndex = 3;
+ this.txtMessageText.Text = "this is the\r\nmulti-line test\r\n";
+
+ this.txtMessageSubject.Location = new System.Drawing.Point(80, 72);
+ this.txtMessageSubject.Name = "txtMessageSubject";
+ this.txtMessageSubject.Size = new System.Drawing.Size(136, 20);
+ this.txtMessageSubject.TabIndex = 2;
+ this.txtMessageSubject.Text = "test message";
+
+ this.txtSendTo.Location = new System.Drawing.Point(80, 48);
+ this.txtSendTo.Name = "txtSendTo";
+ this.txtSendTo.Size = new System.Drawing.Size(136, 20);
+ this.txtSendTo.TabIndex = 1;
+ this.txtSendTo.Text = "info";
+
+ this.txtMailFrom.Location = new System.Drawing.Point(80, 24);
+ this.txtMailFrom.Name = "txtMailFrom";
+ this.txtMailFrom.Size = new System.Drawing.Size(136, 20);
+ this.txtMailFrom.TabIndex = 0;
+ this.txtMailFrom.Text = "test";
+
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.ClientSize = new System.Drawing.Size(512, 229);
+ this.Controls.Add(this.GroupBox2);
+ this.Controls.Add(this.GroupBox1);
+ this.Name = "frmMain";
+ this.Text = "Send Email";
+ this.Load += new System.EventHandler(this.frmMain_Load);
+ this.GroupBox2.ResumeLayout(false);
+ this.GroupBox1.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ [STAThread]
+ static void Main()
+ {
+ Application.Run(new frmMain());
+ }
+
+ private void cmdSend_Click(object sender, System.EventArgs e)
+ {
+ // send mail
+ }
+
+ private void frmMain_Load(object sender, System.EventArgs e)
+ {
+ cmbAuth.Items.Add("None");
+ cmbAuth.Items.Add("POP3");
+ cmbAuth.Items.Add("Login");
+ cmbAuth.Items.Add("Plain");
+ cmbAuth.SelectedIndex = 0;
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/samples/notepad.cs b/mcs/class/Managed.Windows.Forms/samples/notepad.cs
new file mode 100644
index 00000000000..6ad148aeb6d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/samples/notepad.cs
@@ -0,0 +1,275 @@
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Windows.Forms;
+using System.Data;
+using System.IO;
+
+namespace NotePadExample
+{
+ public class Notepad : System.Windows.Forms.Form
+ {
+ private System.Windows.Forms.MainMenu mainMenu1;
+ private System.Windows.Forms.MenuItem menuItemFile;
+ private System.Windows.Forms.MenuItem menuItemNew;
+ private System.Windows.Forms.MenuItem menuItemOpen;
+ private System.Windows.Forms.MenuItem menuItemSave;
+ private System.Windows.Forms.MenuItem menuItemExit;
+ private System.Windows.Forms.MenuItem menuItemEdit;
+ private System.Windows.Forms.MenuItem menuItemCut;
+ private System.Windows.Forms.MenuItem menuItemCopy;
+ private System.Windows.Forms.MenuItem menuItemPaste;
+ private System.Windows.Forms.MenuItem menuItemSelectAll;
+ private System.Windows.Forms.MenuItem menuItemHelp;
+ private System.Windows.Forms.MenuItem menuItemAbout;
+ private System.Windows.Forms.TextBox textBox1;
+ private System.Windows.Forms.MenuItem menuItemSep2;
+ private System.Windows.Forms.SaveFileDialog saveFileDialog1;
+ private System.Windows.Forms.MenuItem menuItemSep1;
+ private System.Windows.Forms.OpenFileDialog openFileDialog1;
+ private System.Windows.Forms.MenuItem menuItemBlank;
+ private System.Windows.Forms.MenuItem menuItemGeneral;
+
+ private System.ComponentModel.Container components = null;
+
+ public Notepad()
+ {
+ InitializeComponent();
+ }
+
+ protected override void Dispose( bool disposing )
+ {
+ if( disposing )
+ {
+ if (components != null)
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose( disposing );
+ }
+
+ private void InitializeComponent()
+ {
+ this.mainMenu1 = new System.Windows.Forms.MainMenu();
+ this.menuItemFile = new System.Windows.Forms.MenuItem();
+ this.menuItemNew = new System.Windows.Forms.MenuItem();
+ this.menuItemOpen = new System.Windows.Forms.MenuItem();
+ this.menuItemSep1 = new System.Windows.Forms.MenuItem();
+ this.menuItemSave = new System.Windows.Forms.MenuItem();
+ this.menuItemSep2 = new System.Windows.Forms.MenuItem();
+ this.menuItemExit = new System.Windows.Forms.MenuItem();
+ this.menuItemEdit = new System.Windows.Forms.MenuItem();
+ this.menuItemCut = new System.Windows.Forms.MenuItem();
+ this.menuItemCopy = new System.Windows.Forms.MenuItem();
+ this.menuItemPaste = new System.Windows.Forms.MenuItem();
+ this.menuItemSelectAll = new System.Windows.Forms.MenuItem();
+ this.menuItemHelp = new System.Windows.Forms.MenuItem();
+ this.menuItemAbout = new System.Windows.Forms.MenuItem();
+ this.menuItemBlank = new System.Windows.Forms.MenuItem();
+ this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
+ this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
+ this.textBox1 = new System.Windows.Forms.TextBox();
+ this.menuItemGeneral = new System.Windows.Forms.MenuItem();
+ this.SuspendLayout();
+
+ this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.menuItemFile,
+ this.menuItemEdit,
+ this.menuItemHelp,
+ this.menuItemBlank});
+
+ this.menuItemFile.Index = 0;
+ this.menuItemFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.menuItemNew,
+ this.menuItemOpen,
+ this.menuItemSep1,
+ this.menuItemSave,
+ this.menuItemSep2,
+ this.menuItemExit}
+ );
+ this.menuItemFile.Text = "File";
+
+ this.menuItemNew.Index = 0;
+ this.menuItemNew.Text = "&New";
+ this.menuItemNew.Click += new System.EventHandler(this.menuItemNew_Click);
+
+ this.menuItemOpen.Index = 1;
+ this.menuItemOpen.Text = "&Open";
+ this.menuItemOpen.Click += new System.EventHandler(this.menuItemOpen_Click);
+
+ this.menuItemSep1.Index = 2;
+ this.menuItemSep1.Text = "-";
+
+ this.menuItemSave.Index = 3;
+ this.menuItemSave.Text = "&Save";
+ this.menuItemSave.Click += new System.EventHandler(this.menuItemSave_Click);
+
+ this.menuItemSep2.Index = 4;
+ this.menuItemSep2.Text = "-";
+
+ this.menuItemExit.Index = 5;
+ this.menuItemExit.Text = "Exit";
+ this.menuItemExit.Click += new System.EventHandler(this.menuItemExit_Click_1);
+
+ this.menuItemEdit.Index = 1;
+ this.menuItemEdit.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.menuItemCut,
+ this.menuItemCopy,
+ this.menuItemPaste,
+ this.menuItemSelectAll}
+ );
+ this.menuItemEdit.Text = "Edit";
+
+ this.menuItemCut.Index = 0;
+ this.menuItemCut.Text = "&Cut";
+ this.menuItemCut.Click += new System.EventHandler(this.menuItemCut_Click);
+
+ this.menuItemCopy.Index = 1;
+ this.menuItemCopy.Text = "&Copy";
+ this.menuItemCopy.Click += new System.EventHandler(this.menuItemCopy_Click);
+
+ this.menuItemPaste.Index = 2;
+ this.menuItemPaste.Text = "Paste";
+ this.menuItemPaste.Click += new System.EventHandler(this.menuItemPaste_Click);
+
+ this.menuItemSelectAll.Index = 3;
+ this.menuItemSelectAll.Text = "&Select All";
+ this.menuItemSelectAll.Click += new System.EventHandler(this.menuItemSelectAll_Click);
+
+ this.menuItemHelp.Index = 2;
+ this.menuItemHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.menuItemAbout,
+ this.menuItemGeneral}
+ );
+ this.menuItemHelp.Text = "Help";
+
+ this.menuItemAbout.Index = 0;
+ this.menuItemAbout.Text = "About";
+ this.menuItemAbout.Click += new System.EventHandler(this.menuItemAbout_Click);
+
+ this.menuItemBlank.Index = 3;
+ this.menuItemBlank.Text = "";
+
+ this.saveFileDialog1.FileName = "doc1";
+
+ this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.textBox1.Multiline = true;
+ this.textBox1.Name = "textBox1";
+ this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
+ this.textBox1.Size = new System.Drawing.Size(544, 321);
+ this.textBox1.TabIndex = 0;
+ this.textBox1.Text = "";
+ this.textBox1.TextChanged += new
+ System.EventHandler(this.textBox1_TextChanged_1);
+
+ this.menuItemGeneral.Index = 1;
+ this.menuItemGeneral.Text = "General";
+ this.menuItemGeneral.Click += new System.EventHandler(this.menuItemGeneral_Click);
+
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.ClientSize = new System.Drawing.Size(544, 321);
+ this.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.textBox1}
+ );
+ this.ImeMode = System.Windows.Forms.ImeMode.Off;
+ this.Menu = this.mainMenu1;
+ this.Name = "Notepad";
+ this.Text = "Notepad MWF Example";
+ this.Load += new System.EventHandler(this.Form1_Load);
+ this.ResumeLayout(false);
+ }
+
+ [STAThread]
+ public static void Main()
+ {
+ Application.Run(new Notepad());
+ }
+
+ private void Form1_Load(object sender, System.EventArgs e)
+ {
+
+ }
+
+ private void menuItemOpen_Click(object sender, System.EventArgs e)
+ {
+ openFileDialog1.ShowDialog();
+ StreamReader sr = new StreamReader(openFileDialog1.FileName);
+ textBox1.Text = sr.ReadToEnd();
+ sr.Close();
+ }
+
+ private void menuItemCut_Click(object sender, System.EventArgs e)
+ {
+ Clipboard.SetDataObject(textBox1.SelectedText);
+ textBox1.SelectedText="";
+
+ }
+
+ private void menuItemPaste_Click(object sender, System.EventArgs e)
+ {
+ textBox1.Paste();
+ }
+
+ private void textBox1_TextChanged(object sender, System.EventArgs e)
+ {
+
+ }
+
+ private void menuItemAbout_Click(object sender, System.EventArgs e)
+ {
+ Form helpnew = new Form();
+ helpnew.Show();
+
+ }
+
+ private void textBox1_TextChanged_1(object sender, System.EventArgs e)
+ {
+
+ }
+
+ private void menuItemExit_Click(object sender, System.EventArgs e)
+ {
+
+ }
+
+ private void menuItemExit_Click_1(object sender, System.EventArgs e)
+ {
+ Dispose(true);
+ }
+
+ private void menuItemCopy_Click(object sender, System.EventArgs e)
+ {
+ textBox1.Copy();
+ }
+
+ private void menuItemSelectAll_Click(object sender, System.EventArgs e)
+ {
+ textBox1.SelectAll();
+ }
+
+ private void menuItemNew_Click(object sender, System.EventArgs e)
+ {
+ textBox1.Clear();
+ }
+
+ private void menuItemSave_Click(object sender, System.EventArgs e)
+ {
+ saveFileDialog1.FileName = "*.txt";
+ //saveFileDialog1.FilterIndex ="*.txt";
+ saveFileDialog1.ShowDialog();
+ //MessageBox.Show (saveFileDialog1.FileName);
+ StreamWriter sw = new StreamWriter(saveFileDialog1.FileName);
+ sw.Write (textBox1.Text);
+ sw.Close();
+ }
+
+ private void menuItemGeneral_Click(object sender, System.EventArgs e)
+ {
+ Form gen = new Form ();
+ gen.Show();
+
+ }
+ }
+}
diff --git a/mcs/class/PEAPI/Assembly/AssemblyInfo.cs b/mcs/class/PEAPI/Assembly/AssemblyInfo.cs
new file mode 100644
index 00000000000..a461e90522f
--- /dev/null
+++ b/mcs/class/PEAPI/Assembly/AssemblyInfo.cs
@@ -0,0 +1,30 @@
+//
+// AssemblyInfo.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2003 Ximian, Inc. http://www.ximian.com
+// (C) 2004 Novell (http://www.novell.com)
+//
+
+using System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyVersion (Consts.FxVersion)]
+
+/* TODO COMPLETE INFORMATION
+
+[assembly: AssemblyTitle ("")]
+[assembly: AssemblyDescription ("")]
+
+[assembly: CLSCompliant (true)]
+[assembly: AssemblyFileVersion ("0.0.0.1")]
+
+[assembly: ComVisible (false)]
+
+*/
+
+[assembly: AssemblyDelaySign (true)]
+[assembly: AssemblyKeyFile ("../mono.pub")]
diff --git a/mcs/class/PEAPI/Assembly/ChangeLog b/mcs/class/PEAPI/Assembly/ChangeLog
new file mode 100644
index 00000000000..44f2ba06b33
--- /dev/null
+++ b/mcs/class/PEAPI/Assembly/ChangeLog
@@ -0,0 +1,6 @@
+2004-04-30 Duncan Mak <duncan@ximian.com>
+
+ * AssemblyInfo.cs: Added
+ * ChangeLog: Added
+ * Locale.cs: Added
+
diff --git a/mcs/class/PEAPI/ChangeLog b/mcs/class/PEAPI/ChangeLog
new file mode 100644
index 00000000000..98323b1b74c
--- /dev/null
+++ b/mcs/class/PEAPI/ChangeLog
@@ -0,0 +1,640 @@
+2006-02-22 Ankit Jain <jankit@novell.com>
+
+ * Metadata.cs (TypeAttr): Add [Flags] attribute.
+
+2006-02-20 Ankit Jain <jankit@novell.com>
+
+ * PEAPI.cs (PEFileException): Update error message.
+ * Metadata.cs: Update to throw PEFileException instead of Exception.
+
+2006-02-19 Ankit Jain <jankit@novell.com>
+
+ * Metadata.cs (Module): Implment IExternRef to allow reference to types
+ in 'this' module.
+
+2006-02-15 Raja R Harinath <rharinath@novell.com>
+
+ * Metadata.cs (BoundArray.CompressSignedNum): Document the
+ transformation. Avoid a few casts.
+
+2006-02-15 Ankit Jain <jankit@novell.com>
+
+ * Metadata.cs (BoundArray.CompressSignedNum): New. Encode signed values,
+ used only for encoding lower bounds of arrays.
+ (BoundArray.TypeSig): Use new CompressSignedNum to encode lower bounds.
+
+2006-02-08 Ankit Jain <jankit@novell.com>
+
+ * Metadata.cs (BoundArray.ctor): Change param 'upBounds' to sizes.
+ (MetaData.CompressNum): Fix range check.
+
+2006-01-31 Ankit Jain <jankit@novell.com>
+
+ * Metadata.cs (Op.readonly_): New.
+
+2006-01-19 Ankit Jain <jankit@novell.com>
+
+ * Metadata.cs (GenericParameter.GetCodedIx): Override. Return coded index
+ for HasCustomAttr.
+ (MetaData.BuildMetaData): Sort CustomAttribute table at the end.
+
+2006-01-16 Ankit Jain <jankit@novell.com>
+
+ * Metadata.cs (PInvokeAttr): Add 'bestfit_on', 'bestfit_off', 'bestfit_mask',
+ 'charmaperror_on' & 'charmaperror_off'.
+
+2006-01-13 Ankit Jain <jankit@novell.com>
+
+ * Metadata.cs (GenericMethodSig): Ensure sig is added to the blob only once.
+
+2006-01-10 Ankit Jain <jankit@novell.com>
+
+ * Metadata.cs (GenParam): Don't use GetTypeSpec to create typespec for GenParam.
+ Adding required methods directly to GenParam.
+ * PEAPI.cs (PEFile.AddGenericParam): Add it to the TypeSpec table directly.
+
+2006-01-09 Ankit Jain <jankit@novell.com>
+
+ * PEAPI.cs (PEFile.AddGenricParam): New. Adds a GenParam to the TypeSpec
+ table.
+ * Metadata.cs (GenParam): Inherit from 'Class' instead of 'Type'.
+ (GenParam.name): Rename to param_name as it hides Class.name .
+ (GenParam.GetTypeSpec): Override to create TypeSpec for genparam.
+
+2006-01-08 Ankit Jain <jankit@novell.com>
+
+ * Metadata.cs (TypeOp): Add 'constrained' op.
+
+2006-01-07 Ankit Jain <jankit@novell.com>
+
+ * Metadata.cs (GenericParamAttributes): New.
+ (MetaDataElement.Row): Always set value.
+ (GenericParameter): Update to use GenericParameterAttributes.
+ (GenericParameterConstraint.SortKey): New. override to support sorting.
+ (ClassDef.AddGenericParameter):
+ (MethodDef.AddGenericParameter): New overloads for accepting attributes also.
+
+2006-01-06 Ankit Jain <jankit@novell.com>
+
+ * Metadata.cs (UIntConst): Change constructor param from signed int/sbyte/etc to
+ unsigned.
+ (UIntConst.GetBlobIndex):
+ (UIntConst.Write): Change use of signed types to unsigned ones.
+
+2006-01-06 Ankit Jain <jankit@novell.com>
+
+ * PEAPI.cs (PEFile.AddGenericClass): New. Adds a GenericTypeInst to the TypeSpec table.
+ * Metadata.cs (GenericTypeInst): Change base class from 'Type' to 'Class'.
+ (GenericTypeInst.GetTypeSpec):
+ (GenericTypeInst.BuildTables):
+ (GenericTypeInst.Size):
+ (GenericTypeInst.Write):
+ (GenericTypeInst.GetCodedIx): Implement these for GenericTypeInst.
+ (ClassDef.SetSuper): Set typeIndexChecked to false if 'super' is not GenericTypeInst.
+ Fixup of typeIndex is not required for GenericTypeInst .
+ (ClassDef.CheckTypeIndex): Recursively fix typeIndex if superType is ClassDef.
+ (MetaData.BuildMetaData): BuildTable for TypeSpec.
+
+2005-12-24 Jb Evain <jbevain@gmail.com>
+
+ * Metadata.cs (Property): Add a new 'instance' field.
+ (Property.SetInstance): New mutator for the instance field.
+ (Property.BuildTables): Emit the correct property tag depending on the instance field.
+
+2005-12-14 Ankit Jain <jankit@novell.com>
+
+ * Metadata.cs (BoundArray.ctor): Don't calculate sizes if upBounds is
+ null.
+
+2005-12-12 Ankit Jain <jankit@novell.com>
+
+ * Metadata.cs (TypeAttr): Add VisibilityMask.
+
+2005-12-09 Ankit Jain <jankit@novell.com>
+
+ * Metadata.cs (Method.ctor): Remove rType parameter.
+ (Method.GetRetType): Remove.
+ (Method.AddCallConv): Make it abstract.
+ (Method.GetSigIx): Likewise.
+ (MethodDef): Override and implement abstract methods from Method class.
+ (MethodRef): Likewise.
+ (MethodSpec): Change base class from MetaDataElement to Method. Override
+ abstract methods from Method but throw Exception as they are not meant to be used here.
+ (MethodDef.TypeSig): Write gen_param_count before num of params.
+ (ClassRef.AddMethod): New overload with an extra gen_param_count param.
+ * PEAPI.cs (PEFile.AddMethodToTypeSpec): New overload with an extra gen_param_count
+ param.
+ (PEFile.AddMethodSpec): Change return type from void to Method.
+
+2005-12-05 Ankit Jain <jankit@novell.com>
+
+ * Metadata.cs (GenParamType): New enum.
+ (CallConv): Add [Flags] attribute.
+ (GenParam): New. Replaces ..
+ (MVar): .. this ..
+ (GenericTypeSpec): .. and this.
+ (GenericTypeInst.ctor): Use PrimitiveType.GenericInst.GetTypeIndex () instead
+ of hard-coded 0x15.
+ (GenericTypeInst.TypeSig): First byte should the 0x0A (GENERIC_INST).
+ (Method.gen_param_count): New. Num of generic parameters.
+ (MethodDef.ctor): Use overload.
+ (MethodDef.TypeSig): Write gen_param_count if callConv is Generic.
+ (MethodRef.GenParamCount): New.
+ (MethodRef.TypeSig): Write gen_param_count if callConv is Generic.
+ (PrimitiveType.Var): New.
+ (PrimitiveType.MVar): New.
+ (PrimitiveType.GenericInst): New.
+
+2005-11-21 Ankit Jain <jankit@novell.com>
+
+ * Metadata.cs (MetaData.WriteCodedIndex): Fix indentation.
+
+2005-11-21 Ankit Jain <jankit@novell.com>
+
+ * Metadata.cs (GenericParameter.SortKey2): New. Use index as the secondary key.
+ (GenericParameter.Size): Set size correctly.
+ (GenericParameter.Write): Use StringsIndex to write the index.
+ (MetaData.WriteTildeStream): Emit 2,0 as version for NET_2_0 profile.
+ (MetaData.version): Use 'v2.0.50727' for NET_2_0 profile.
+ (MetaData.BuildMetaData): Build and sort GenericParam, MethodSpec and
+ GenericParamConstraint tables only for NET_2_0 profile.
+
+2005-09-16 Ankit Jain <jankit@novell.com>
+
+ * PEAPI.cs: Clean up indentation. Split into ...
+ Metadata.cs, Code.cs, PEAPI.cs: ... these.
+
+2005-09-08 Ankit Jain <jankit@novell.com>
+
+ * PEAPI.cs (FileImage.stackReserve): New. Set to default value of 0x100000 (1Mb).
+ (FileImage.WritePEHeader): Write stackReserve instead of the default value.
+ (PEFile.SetStackReserve): Set stack reserve for fileImage.
+
+2005-09-06 Ankit Jain <jankit@novell.com>
+
+ * PEAPI.cs (MetaData.WriteTildeStream): Change minor version back to 0.
+
+2005-08-30 Ankit Jain <jankit@novell.com>
+
+ * PEAPI.cs (MetaData.WriteTildeStream): Change minor version to 1.
+
+2005-08-29 Ankit Jain <jankit@novell.com>
+
+ * PEAPI.cs (CustomMarshaller.ctor): New.
+ (CustomMarshaller.ToBlob): Emit marshallerName and cookie strings with
+ their lengths.
+
+2005-08-26 Ankit Jain <jankit@novell.com>
+
+ * PEAPI.cs (PEFile.ctor): Restore old constructor overload to avoid
+ changing public API.
+
+2005-08-26 Ankit Jain <jankit@novell.com>
+
+ * PEAPI.cs (IResolutionScope): New. Empty interface.
+ (ClassRef): Implement IResolutionScope.
+ (ClassRef.parent): Change type from ResolutionScope to IResolutionScope.
+ (ClassRef.AddClass): New. Add nested class.
+ (ClassRef.AddValueClass): New. Add nested value class.
+
+2005-08-23 Ankit Jain <jankit@novell.com>
+
+ * PEAPI.cs (MetaData.version): Change from 1.0.3705 to 1.1.4322.
+
+2005-08-23 Ankit Jain <jankit@novell.com>
+
+ * PEAPI.cs (MSCorLib.systemClasses): Change type from ClassRef[] to
+ Class[].
+ (MSCorLib.ctor): Add assembly ref to mscorlib for non-mscorlib assemblies
+ only.
+ (MSCorLib.AddClass): Use Class instead of ClassRef.
+ (MSCorLib.GetSpecialClass): Change return type to Class from ClassRef.
+ Don't instantiate object of SystemClass if this assembly is mscorlib.
+ (MSCorLib.SetSpecialSystemClass): New. Set a System.* class for primitive
+ types, used for compiling mscorlib.
+ (MSCorLib.GetValueClass): Change to handle new type of systemClasses.
+ (MSCorLib.ValueType),
+ (MSCorLib.EnumType): Don't instantiate ClassRef if this assembly is mscorlib.
+ (ClassDef.ctor): Don't superType to System.Object for System.Object and <Module>.
+ (ClassDef.MakeValueClass): Set typeIndex to ValueType's typeIndex.
+ (ClassDef.IsValueType),
+ (ClassDef.IsEnum): Use "==" instead of .CompareTo for string comparison.
+ (ClassDef.AddNestedClass): Set typeIndexChecked = true for the nested class.
+ (PEFile.isMSCorlib): New. bool field.
+ (PEFile.ctor): Move all ctor logic into one overload and call that from others.
+ (PEFile.ctor): Add outputDir parameter.
+ (PEFile.SetName): Set name of the assembly and set isMSCorlib accordingly.
+ (PEFile.IsMSCorlib): New. bool Property.
+ (PEFile.AddClass): Call overload.
+ (PEFile.AddClass): Set superType and SetSpecialSystemClass if compiling mscorlib.
+ (PEFile.AddValueClass): Call MakeValueClass only if the class is not System.ValueType
+ or System.Enum itself, else set the supertype correctly.
+
+2005-08-16 Ankit Jain <jankit@novell.com>
+
+ * PEAPI.cs (FieldAttr): Move HasFieldMarshal from FieldDef to this.
+ (ParamAttr): Move HasDefault and HasFieldMarshal from Param to this.
+ (ManifestResource.ctor): Use 'mres' param to clone.
+ (MethodDef.ret_param): New.
+ (MethodDef.AddRetTypeMarshallInfo): New.
+ (MethodDef.TypeSig): Set seqNo for ret_param to zero.
+ (MethodDef.BuildTables): Add ret_param to Param table, and BuildTables
+ for it.
+ (FixedSysString): New. Class to represent Fixed SysString native type.
+ (NativeArray): Rename len to numElem. Init numElem, parNum and elemMult
+ to -1.
+ (NativeArray.ctor): Uncomment ctor with one param (elemType).
+ (NativeArray.ctor): Move ctor logic to the one with all params.
+ (NativeArray.ToBlob): Emit values in correct order.
+ (SafeArray.hasElemType): New. bool var to indicate presence of ElemType.
+ (SafeArray.ctor): New. Parameterless constructor.
+ (SafeArray.ToBlob): Emit correctly.
+ (FixedArray.ctor): Remove elemType param.
+ (FixedArray.ToBlob): Don't emit elemType.
+
+2005-08-08 Ankit Jain <jankit@novell.com>
+
+ * PEAPI.cs (CodeBlock): Set maxCodeSize to 255 instead of 256 for checking
+ Fat format.
+ (CILInstructions.CheckCode): Use 255 instead of 256 for checking Fat format.
+
+2005-08-08 Ankit Jain <jankit@novell.com>
+
+ * PEAPI.cs (FileImage.WriteCLIHeader): Move the check for no entrypoint
+ in case of an EXE to ilasm/codegen/CodeGen.cs to avoid creating unnecessary
+ .exe.
+
+2005-08-05 Ankit Jain <jankit@novell.com>
+
+ * PEAPI.cs (FileImage.WriteCLIHeader): Throw Exception if an EXE has been
+ requested but the source file has no entrypoint defined.
+
+2005-08-05 Ankit Jain <jankit@novell.com>
+
+ * PEAPI.cs (TypeAttr): Add HasSecurity.
+ (MethAttr): Likewise.
+ (SecurityAction): New enum.
+ (DeclSecurity.ctor): Add 'byte []' as the third parameter.
+ (DeclSecurity.BuildTables): Write the byte array to the blob.
+ (MetaData.AddDeclSecurity): Add DeclSecurity to declsec_list.
+ (MetaData.BuildMetaData): Call BuildTables for declsec_list members.
+ (PEFile.AddDeclSecurity): New. Add DeclSecurity to metaData.
+
+2005-04-30 Ankit Jain <ankit@corewars.org>
+
+ * PEAPI.cs (InterfaceImpl.SortKey): New.
+ (MetaData.BuildMetaData): Sort InterfaceImpl table.
+ (MethodSemantics.SortKey): Compute key correctly.
+
+2005-04-18 Ankit Jain <ankit@corewars.org>
+
+ * PEAPI.cs (ManifestResource.InitResource): New. Used by constructors
+ to initialize the resource.
+ (ManifestResource.ctor): New. Constructor to accept resource as a
+ byte array.
+ (ManifestResource.ctor): New. Constructor to accept an object of self.
+ (ManifestResource.BuildTables): Update.
+ (MetaData.AddResource): New. Add the resource to the list, adjust
+ resourcesSize.
+ (MetaData.WriteResource): New. Write resources to the FileImage.
+ (PEFile.AddExternalManagedResource): New. Add a new resource.
+ (PEFile.GetResource): New. Get resource by name.
+ (PEFile.GetResources): New. Get array of resources.
+
+2005-04-12 Ankit Jain <ankit@corewars.org>
+
+ * PEAPI.cs (CustomAttribute.ctor): Dont throw
+ NotYetImplementedException.
+ (MethodSemantics.SortKey): Should be sorted by
+ 'Association' column.
+
+2005-04-08 Ankit Jain <radical@corewars.org>
+
+ * PEAPI.cs (MSCorLib.GetSpecialClass): Don't encode
+ System.ValueType and System.Enum as value types.
+ (ValueClass): New enum.
+ (Class.MakeValueClass): Add a 'ValueClass' parameter.
+ (ClassDef.MakeValueClass): Set supertype to ValueType or Enum
+ according to ValueClass parameter.
+ (IsValueType,IsEnum): New. Test if type is System.ValueType or
+ System.Enum.
+ (ClassDef.AddNestedClass): Don't encode System.ValueType and
+ System.Enum as value types.
+
+2005-03-17 Ankit Jain <radical@corewars.org>
+
+ * PEAPI.cs: Metadata tables that must be sorted are sorted now.
+ Fixes the code for ParamAttr.Opt. Fix bug #73517.
+
+2004-12-08 Sebastien Pouliot <sebastien@ximian.com>
+
+ * PEAPI.cs: Added support for allocating and storing strongname
+ signatures when a .publickey directive is present in source. Fix bug
+ #69721.
+
+2004-12-01 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Allow underlying types of ByteArrConsts to be set when
+ they are used as field init data.
+
+2004-07-29 Martin Baulig <martin@ximian.com>
+
+ * PEAPI.cs (Module.Guid): New public property.
+
+2004-07-27 Martin Baulig <martin@ximian.com>
+
+ * PEAPI.cs (CILInstructions.Offset): New public property.
+
+2004-07-23 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Make the type index modifiable so ClassRefInsts will
+ be emitted properly. This is in desperate need of some API love.
+
+2004-07-21 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Do all the index size checks. I always wondered why
+ the code was like that and finally realized today that it was like
+ that because it was wrong. Wait until the opportune momement to
+ calculate the index sizes (after everything has been added to the
+ streams, and before writing anything).
+
+2004-07-21 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Create ClassRefInsts with types not just
+ ClassRefs. This way modified types can be used. I am having alot
+ of trouble remembering why I actually even need this class though.
+
+2004-07-16 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: make sure small index sizes get set properly. Use a
+ continue to reduce nesting a little and make code almost mildly
+ readable. Add MDTable.Field to the list of tables that can
+ increase the CustomAttributeType shift. TODO: What else should be
+ here?
+
+2004-07-13 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Use a byte array hash code provider and comprarer, so
+ checking the byte hashtable for duplicate entries actually
+ works. Old method was valid but created larger then needed binaries.
+
+2004-07-09 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Don't build custom attributes twice.
+
+2004-07-08 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Add custom attributes through the pefile so that we
+ can ensure they are emitted no matter what table they are
+ in. Previously not all custom attributes were getting emitted.
+
+2004-06-26 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Add a method to set the fields list. This is needed so
+ that sequentially laid out fields are laid out in the right
+ order. When building custom attribute tables actually emit the
+ custom attribute data. When writing the .sdata section make sure
+ to pad to its size. The constants itself will not make up the
+ entire section because it is aligned on 512 byte blocks.
+
+2004-06-19 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Make sure the sentinel is placed properly for vararg
+ method pointers.
+
+2004-06-19 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Allow MethPtrTypes to be created from a signature
+ instead of from a method reference because it really doesn't make
+ sense to do it that way ;-).
+
+2004-06-14 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Add IExternRef interface and modify sigs so it can be
+ used. So we can easily add stuff to modules and assemblies. Fix
+ the nometadata flag, it should be set when there is NO metadata
+ not when there is metadata.
+
+2004-06-14 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Add new constructor so we can explicitly set the
+ module name.
+
+2004-06-03 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Do not null terminate byte arrays when writing to the
+ blob stream.
+
+2004-05-25 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: When writing to the blob heap we always set a size.
+
+2004-05-25 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Set the has default flag on fields when a default data
+ constant is assigned to them.
+
+2004-05-25 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Encode string constants as unicode before putting them
+ in the blob.
+
+2004-05-25 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: zero RVAs for abstract, runtime, and internal call
+ methods.
+
+2004-04-30 Duncan Mak <duncan@ximian.com>
+
+ * PEAPI.dll.sources: Added Assembly/AssemblyInfo.cs and
+ Locale.cs to build.
+
+2004-04-02 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Allow hash algorithms to be any integer.
+
+2004-02-18 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Add a class for creating instances of class refs, this
+ is used for setting the class or valuetype of a types instance so the class
+ reference isn't modified. Allows things like 'valuetype [mscorlib]System.Object'.
+
+2003-11-18 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: If the data length for a methods seh section is
+ greater then 255 use fat format headers.
+
+2003-11-17 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Allow strings to be loaded as bytearrays.
+
+2003-10-19 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Use bytes not bits for constant sizes.
+
+2003-10-18 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Add proper support for short instructions, removing
+ PEAPI's auto selection of short/long branch operations feature.
+
+2003-10-10 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: New GenericMethodSig class for creating generic method
+ signatures. Use this class instead of GenericTypeInst for creating
+ generic methods. Fix Generic call conv. according to two of my
+ docs it is 0x10 and only one says 0x50 so I will go with 0x10.
+
+2003-10-09 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Add generic method Mvar type. Add MethodSpec table,
+ and an Api method for adding methods to the methodspec table.
+
+2003-10-08 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Remove some old hacks for adding methods to arrays,
+ typespecs are used for this now. Add Generic call conv.
+
+2003-10-08 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Remove methods for creating generic parameters without
+ a name, names are mandatory. Add method to add type parameters to
+ methods. Allow GenericParameters to have either a type or a
+ method as its owner. Also fix visibility of GenericParameters, a
+ GenericParameter should not be created outside of PEAPI.
+
+2003-10-07 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Add unbox.any instruction.
+
+2003-09-27 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: Fix pinvoke attributes, zero a methods RVA if it has
+ pinvoke info. This isn't entirely correct because native unmanaged
+ methods can have pinvoke info and not have 0 RVAs PEAPI can't
+ handle native unmanged code though. Expose the ModuleClass so
+ 'global' items can be referenced like this '<Module>'::foo.
+
+2003-09-21 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: sigh, sometimes it is best to calculate variables
+ before using them. This fixes PEAPI creating broken images when
+ the sdata section is used.
+
+2003-09-20 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: Rework to allow multiple constraints to be added to a
+ single generic parameter.
+
+2003-08-19 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: Make no super method public so we can have types
+ with no super type.
+
+2003-08-03 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: New Sentinel type.
+
+2003-08-03 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: Only give method definitions 0 RVAs if they are
+ marked abstract.
+
+2003-08-03 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: Offsets are not explicit offsets, they are just
+ byte offsets from the current position.
+
+2003-07-29 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: Allow labels to be created with an explicit offset
+
+Fri Jul 25 19:25:31 CEST 2003 Paolo Molaro <lupus@ximian.com>
+
+ * PEAPI.cs: added coded index for the owner field in the GenericParam
+ table.
+
+2003-07-20 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: Add methods to PEFile to allow fields and methods to
+ be added to type specs. This fixing bah-zillions of little
+ problems in ilasm. We can now add fields and methods to arrays,
+ reference types, and most importantly generics.
+
+ Add the GenericTypeInst class. This is an instance of a generic
+ type. ie Hash<int32, string>. GenericTypeSpecs now write their id
+ number as a compressed number, this matches the way the runtime
+ loads them and will allow generic types to have more then 255 type
+ parameters.
+
+2003-07-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: Add GenericTypeSpec so generic members can be
+ referenced. Add the ldelem and stelem opcodes (these are part of
+ the new spec).
+
+2003-07-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: Allow generic constraints to be added, emit generic
+ constraints.
+
+2003-07-14 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: Cleanup methods for generics, now that constraints and
+ params are seperated.
+
+2003-05-31 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: Initial work on implementing custom
+ attributes. Attributes can now be added to ClassDefs and
+ MethodDefs. Still need to implement for other metadata elements.
+ Added the stele.r4 and stelem.r8 instructions, this should also
+ shift the stelem.ref instruction to the proper value (0xA2)
+
+2003-05-25 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: Create a list of vararg signatures and add them all to
+ tables. this allows more then one vararg signature to be created
+ per method.
+
+2003-05-18 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: Add methods to allow methods to be added to arrays.
+
+2003-05-11 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: The class size in class layout metadata table is a
+ uint not a short.
+
+2003-04-05 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: Add indexes to GenericParameters, make string index
+ always a full 4 bytes.
+
+2003-04-05 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: Add GenericParameter table, and method to add generic
+ parameters.
+
+2003-03-15 Daniel Morgan <danmorg@sc.rr.com>
+
+ * PEAPI.build: added file for windows build
+
+2003-03-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: (ImplAttr) Add Optil implementation flag (not supported
+ in first release of CLR)
+ (Class) And Name property
+
+2003-03-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * makefile.gnu: Add file
+ * list.unix: Add file
+
+2003-03-02 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: Do not add file extensions to output names
+
+2003-03-02 Jackson Harper <jackson@latitudegeo.com>
+
+ * PEAPI.cs: Add file
+ * README.txt: Add file
diff --git a/mcs/class/PEAPI/Code.cs b/mcs/class/PEAPI/Code.cs
new file mode 100644
index 00000000000..af8ae771cfa
--- /dev/null
+++ b/mcs/class/PEAPI/Code.cs
@@ -0,0 +1,1322 @@
+using System.IO;
+using System.Collections;
+
+namespace PEAPI {
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for an IL instruction
+ /// </summary>
+ internal abstract class CILInstruction {
+ protected static readonly sbyte maxByteVal = 127;
+ protected static readonly sbyte minByteVal = -128;
+ protected static readonly byte leadByte = 0xFE;
+ protected static readonly uint USHeapIndex = 0x70000000;
+ protected static readonly int longInstrStart = (int)Op.arglist;
+ public bool twoByteInstr = false;
+ public uint size = 0;
+ public uint offset;
+
+ internal virtual bool Check(MetaData md)
+ {
+ return false;
+ }
+
+ internal virtual void Write(FileImage output) { }
+
+ }
+
+ internal class CILByte : CILInstruction {
+ byte byteVal;
+
+ internal CILByte(byte bVal)
+ {
+ byteVal = bVal;
+ size = 1;
+ }
+
+ internal override void Write(FileImage output)
+ {
+ output.Write(byteVal);
+ }
+
+ }
+
+ internal class Instr : CILInstruction {
+ protected int instr;
+
+ internal Instr(int inst)
+ {
+ if (inst >= longInstrStart) {
+ instr = inst - longInstrStart;
+ twoByteInstr = true;
+ size = 2;
+ } else {
+ instr = inst;
+ size = 1;
+ }
+ }
+
+ internal override void Write(FileImage output)
+ {
+ //Console.WriteLine("Writing instruction " + instr + " with size " + size);
+ if (twoByteInstr) output.Write(leadByte);
+ output.Write((byte)instr);
+ }
+
+ }
+
+ internal class IntInstr : Instr {
+ int val;
+ bool byteNum;
+
+ internal IntInstr(int inst, int num, bool byteSize) : base(inst)
+ {
+ val = num;
+ byteNum = byteSize;
+ if (byteNum) size++;
+ else size += 4;
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ base.Write(output);
+ if (byteNum)
+ output.Write((sbyte)val);
+ else
+ output.Write(val);
+ }
+
+ }
+
+ internal class UIntInstr : Instr {
+ int val;
+ bool byteNum;
+
+ internal UIntInstr(int inst, int num, bool byteSize) : base(inst)
+ {
+ val = num;
+ byteNum = byteSize;
+ if (byteNum) size++;
+ else size += 2;
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ base.Write(output);
+ if (byteNum)
+ output.Write((byte)val);
+ else
+ output.Write((ushort)val);
+ }
+
+ }
+
+ internal class LongInstr : Instr {
+ long val;
+
+ internal LongInstr(int inst, long l) : base(inst)
+ {
+ val = l;
+ size += 8;
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ base.Write(output);
+ output.Write(val);
+ }
+
+ }
+
+ internal class FloatInstr : Instr {
+ float fVal;
+
+ internal FloatInstr(int inst, float f) : base(inst)
+ {
+ fVal = f;
+ size += 4;
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ base.Write(output);
+ output.Write(fVal);
+ }
+
+ }
+
+ internal class DoubleInstr : Instr {
+ double val;
+
+ internal DoubleInstr(int inst, double d) : base(inst)
+ {
+ val = d;
+ size += 8;
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ base.Write(output);
+ output.Write(val);
+ }
+
+ }
+
+ internal class StringInstr : Instr {
+ string val;
+ byte[] bval;
+ uint strIndex;
+
+ internal StringInstr(int inst, string str) : base(inst)
+ {
+ val = str;
+ size += 4;
+ }
+
+ internal StringInstr (int inst, byte[] str) : base (inst)
+ {
+ bval = str;
+ size += 4;
+ }
+
+ internal sealed override bool Check(MetaData md)
+ {
+ if (val != null)
+ strIndex = md.AddToUSHeap(val);
+ else
+ strIndex = md.AddToUSHeap (bval);
+ return false;
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ base.Write(output);
+ output.Write(USHeapIndex | strIndex);
+ }
+
+ }
+
+ internal class LabelInstr : CILInstruction {
+ CILLabel label;
+
+ internal LabelInstr(CILLabel lab)
+ {
+ label = lab;
+ label.AddLabelInstr(this);
+ }
+ }
+
+ internal class FieldInstr : Instr {
+ Field field;
+
+ internal FieldInstr(int inst, Field f) : base(inst)
+ {
+ field = f;
+ size += 4;
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ base.Write(output);
+ output.Write(field.Token());
+ }
+
+ }
+
+ internal class MethInstr : Instr {
+ Method meth;
+
+ internal MethInstr(int inst, Method m) : base(inst)
+ {
+ meth = m;
+ size += 4;
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ base.Write(output);
+ output.Write(meth.Token());
+ }
+
+ }
+
+ internal class SigInstr : Instr {
+ CalliSig signature;
+
+ internal SigInstr(int inst, CalliSig sig) : base(inst)
+ {
+ signature = sig;
+ size += 4;
+ }
+
+ internal sealed override bool Check(MetaData md)
+ {
+ md.AddToTable(MDTable.StandAloneSig,signature);
+ signature.BuildTables(md);
+ return false;
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ base.Write(output);
+ output.Write(signature.Token());
+ }
+ }
+
+ internal class TypeInstr : Instr {
+ MetaDataElement theType;
+
+ internal TypeInstr(int inst, Type aType, MetaData md) : base(inst)
+ {
+ theType = aType.GetTypeSpec(md);
+ size += 4;
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ base.Write(output);
+ output.Write(theType.Token());
+ }
+
+ }
+
+ internal class BranchInstr : Instr {
+ CILLabel dest;
+ private bool shortVer = true;
+ private static readonly byte longInstrOffset = 13;
+ private int target = 0;
+
+ internal BranchInstr(int inst, CILLabel dst) : base(inst)
+ {
+ dest = dst;
+ dest.AddBranch(this);
+ size++;
+
+ if (inst >= (int) BranchOp.br && inst != (int) BranchOp.leave_s) {
+ shortVer = false;
+ size += 3;
+ }
+ }
+
+ internal sealed override bool Check(MetaData md)
+ {
+ target = (int)dest.GetLabelOffset() - (int)(offset + size);
+ return false;
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ base.Write(output);
+ if (shortVer)
+ output.Write((sbyte)target);
+ else
+ output.Write(target);
+ }
+
+ }
+
+ internal class SwitchInstr : Instr {
+ CILLabel[] cases;
+ uint numCases = 0;
+
+ internal SwitchInstr(int inst, CILLabel[] dsts) : base(inst)
+ {
+ cases = dsts;
+ if (cases != null) numCases = (uint)cases.Length;
+ size += 4 + (numCases * 4);
+ for (int i=0; i < numCases; i++) {
+ cases[i].AddBranch(this);
+ }
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ base.Write(output);
+ output.Write(numCases);
+ for (int i=0; i < numCases; i++) {
+ int target = (int)cases[i].GetLabelOffset() - (int)(offset + size);
+ output.Write(target);
+ }
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// The IL instructions for a method
+ /// </summary>
+ public class CILInstructions {
+ private static readonly uint ExHeaderSize = 4;
+ private static readonly uint FatExClauseSize = 24;
+ private static readonly uint SmlExClauseSize = 12;
+ private static readonly sbyte maxByteVal = 127;
+ private static readonly sbyte minByteVal = -128;
+ private static readonly byte maxUByteVal = 255;
+ private static readonly int smallSize = 64;
+ private static readonly ushort TinyFormat = 0x2;
+ private static readonly ushort FatFormat = 0x3003;
+ private static readonly ushort MoreSects = 0x8;
+ private static readonly ushort InitLocals = 0x10;
+ private static readonly uint FatSize = 12;
+ private static readonly uint FatWords = FatSize/4;
+ private static readonly byte FatExceptTable = 0x41;
+ private static readonly byte SmlExceptTable = 0x01;
+
+ private MetaData metaData;
+ private ArrayList exceptions, blockStack;
+ //private bool codeChecked = false;
+ private static readonly int INITSIZE = 5;
+ private CILInstruction[] buffer = new CILInstruction[INITSIZE];
+ private int tide = 0;
+ private uint offset = 0;
+ private ushort headerFlags = 0;
+ private short maxStack;
+ private uint paddingNeeded = 0;
+ private byte exceptHeader = 0;
+ uint localSigIx = 0;
+ uint codeSize = 0, exceptSize = 0;
+ bool tinyFormat, fatExceptionFormat = false;
+
+ public uint Offset {
+ get { return offset; }
+ }
+
+ internal CILInstructions(MetaData md)
+ {
+ metaData = md;
+ }
+
+ private void AddToBuffer(CILInstruction inst)
+ {
+ if (tide >= buffer.Length) {
+ CILInstruction[] tmp = buffer;
+ buffer = new CILInstruction[tmp.Length * 2];
+ for (int i=0; i < tide; i++) {
+ buffer[i] = tmp[i];
+ }
+ }
+ //Console.WriteLine("Adding instruction at offset " + offset + " with size " + inst.size);
+ inst.offset = offset;
+ offset += inst.size;
+ buffer[tide++] = inst;
+ }
+
+ /// <summary>
+ /// Add a simple IL instruction
+ /// </summary>
+ /// <param name="inst">the IL instruction</param>
+ public void Inst(Op inst)
+ {
+ AddToBuffer(new Instr((int)inst));
+ }
+
+ /// <summary>
+ /// Add an IL instruction with an integer parameter
+ /// </summary>
+ /// <param name="inst">the IL instruction</param>
+ /// <param name="val">the integer parameter value</param>
+ public void IntInst(IntOp inst, int val)
+ {
+ int instr = (int)inst;
+ if ((inst == IntOp.ldc_i4_s) || (inst == IntOp.ldc_i4))
+ AddToBuffer(new IntInstr(instr,val,(inst == IntOp.ldc_i4_s)));
+ else
+ AddToBuffer(new UIntInstr(instr,val,((inst < IntOp.ldc_i4_s) ||
+ (inst == IntOp.unaligned))));
+ }
+
+ /// <summary>
+ /// Add the load long instruction
+ /// </summary>
+ /// <param name="cVal">the long value</param>
+ public void ldc_i8(long cVal)
+ {
+ AddToBuffer(new LongInstr(0x21,cVal));
+ }
+
+ /// <summary>
+ /// Add the load float32 instruction
+ /// </summary>
+ /// <param name="cVal">the float value</param>
+ public void ldc_r4(float cVal)
+ {
+ AddToBuffer(new FloatInstr(0x22,cVal));
+ }
+
+ /// <summary>
+ /// Add the load float64 instruction
+ /// </summary>
+ /// <param name="cVal">the float value</param>
+ public void ldc_r8(double cVal)
+ {
+ AddToBuffer(new DoubleInstr(0x23,cVal));
+ }
+
+ /// <summary>
+ /// Add the load string instruction
+ /// </summary>
+ /// <param name="str">the string value</param>
+ public void ldstr(string str)
+ {
+ AddToBuffer(new StringInstr(0x72,str));
+ }
+
+ /// <summary>
+ /// Add the load string instruction
+ /// </summary>
+ public void ldstr (byte[] str)
+ {
+ AddToBuffer (new StringInstr (0x72, str));
+ }
+
+ /// <summary>
+ /// Add the calli instruction
+ /// </summary>
+ /// <param name="sig">the signature for the calli</param>
+ public void calli(CalliSig sig)
+ {
+ AddToBuffer(new SigInstr(0x29,sig));
+ }
+
+ /// <summary>
+ /// Add a label to the CIL instructions
+ /// </summary>
+ /// <param name="lab">the label to be added</param>
+ public void CodeLabel(CILLabel lab)
+ {
+ AddToBuffer(new LabelInstr(lab));
+ }
+
+ /// <summary>
+ /// Add an instruction with a field parameter
+ /// </summary>
+ /// <param name="inst">the CIL instruction</param>
+ /// <param name="f">the field parameter</param>
+ public void FieldInst(FieldOp inst, Field f)
+ {
+ AddToBuffer(new FieldInstr((int)inst,f));
+ }
+
+ /// <summary>
+ /// Add an instruction with a method parameter
+ /// </summary>
+ /// <param name="inst">the CIL instruction</param>
+ /// <param name="m">the method parameter</param>
+ public void MethInst(MethodOp inst, Method m)
+ {
+ AddToBuffer(new MethInstr((int)inst,m));
+ }
+
+ /// <summary>
+ /// Add an instruction with a type parameter
+ /// </summary>
+ /// <param name="inst">the CIL instruction</param>
+ /// <param name="t">the type argument for the CIL instruction</param>
+ public void TypeInst(TypeOp inst, Type aType)
+ {
+ AddToBuffer(new TypeInstr((int)inst,aType,metaData));
+ }
+
+ /// <summary>
+ /// Add a branch instruction
+ /// </summary>
+ /// <param name="inst">the branch instruction</param>
+ /// <param name="lab">the label that is the target of the branch</param>
+ public void Branch(BranchOp inst, CILLabel lab)
+ {
+ AddToBuffer(new BranchInstr((int)inst,lab));
+ }
+
+ /// <summary>
+ /// Add a switch instruction
+ /// </summary>
+ /// <param name="labs">the target labels for the switch</param>
+ public void Switch(CILLabel[] labs)
+ {
+ AddToBuffer(new SwitchInstr(0x45,labs));
+ }
+
+ /// <summary>
+ /// Add a byte to the CIL instructions (.emitbyte)
+ /// </summary>
+ /// <param name="bVal"></param>
+ public void emitbyte(byte bVal)
+ {
+ AddToBuffer(new CILByte(bVal));
+ }
+
+ /// <summary>
+ /// Add an instruction which puts an integer on TOS. This method
+ /// selects the correct instruction based on the value of the integer.
+ /// </summary>
+ /// <param name="i">the integer value</param>
+ public void PushInt(int i)
+ {
+ if (i == -1) {
+ AddToBuffer(new Instr((int)Op.ldc_i4_m1));
+ } else if ((i >= 0) && (i <= 8)) {
+ Op op = (Op)(Op.ldc_i4_0 + i);
+ AddToBuffer(new Instr((int)op));
+ } else if ((i >= minByteVal) && (i <= maxByteVal)) {
+ AddToBuffer(new IntInstr((int)IntOp.ldc_i4_s,i,true));
+ } else {
+ AddToBuffer(new IntInstr((int)IntOp.ldc_i4,i,false));
+ }
+ }
+
+ /// <summary>
+ /// Add the instruction to load a long on TOS
+ /// </summary>
+ /// <param name="l">the long value</param>
+ public void PushLong(long l)
+ {
+ AddToBuffer(new LongInstr(0x21,l));
+ }
+
+ /// <summary>
+ /// Add an instruction to push the boolean value true on TOS
+ /// </summary>
+ public void PushTrue()
+ {
+ AddToBuffer(new Instr((int)Op.ldc_i4_1));
+ }
+
+ /// <summary>
+ /// Add an instruction to push the boolean value false on TOS
+ /// </summary>
+ public void PushFalse()
+ {
+ AddToBuffer(new Instr((int)Op.ldc_i4_0));
+ }
+
+ /// <summary>
+ /// Add the instruction to load an argument on TOS. This method
+ /// selects the correct instruction based on the value of argNo
+ /// </summary>
+ /// <param name="argNo">the number of the argument</param>
+ public void LoadArg(int argNo)
+ {
+ if (argNo < 4) {
+ int op = (int)Op.ldarg_0 + argNo;
+ AddToBuffer(new Instr(op));
+ } else if (argNo <= maxUByteVal) {
+ AddToBuffer(new UIntInstr((int)IntOp.ldarg,argNo,true));
+ } else {
+ AddToBuffer(new UIntInstr(0x09,argNo,false));
+ }
+ }
+
+ /// <summary>
+ /// Add the instruction to load the address of an argument on TOS.
+ /// This method selects the correct instruction based on the value
+ /// of argNo.
+ /// </summary>
+ /// <param name="argNo">the number of the argument</param>
+ public void LoadArgAdr(int argNo)
+ {
+ if (argNo <= maxUByteVal) {
+ AddToBuffer(new UIntInstr((int)IntOp.ldarga,argNo,true));
+ } else {
+ AddToBuffer(new UIntInstr(0x0A,argNo,false));
+ }
+ }
+
+ /// <summary>
+ /// Add the instruction to load a local on TOS. This method selects
+ /// the correct instruction based on the value of locNo.
+ /// </summary>
+ /// <param name="locNo">the number of the local to load</param>
+ public void LoadLocal(int locNo)
+ {
+ if (locNo < 4) {
+ int op = (int)Op.ldloc_0 + locNo;
+ AddToBuffer(new Instr(op));
+ } else if (locNo <= maxUByteVal) {
+ AddToBuffer(new UIntInstr((int)IntOp.ldloc,locNo,true));
+ } else {
+ AddToBuffer(new UIntInstr(0x0C,locNo,false));
+ }
+ }
+
+ /// <summary>
+ /// Add the instruction to load the address of a local on TOS.
+ /// This method selects the correct instruction based on the
+ /// value of locNo.
+ /// </summary>
+ /// <param name="locNo">the number of the local</param>
+ public void LoadLocalAdr(int locNo)
+ {
+ if (locNo <= maxUByteVal) {
+ AddToBuffer(new UIntInstr((int)IntOp.ldloca,locNo,true));
+ } else {
+ AddToBuffer(new UIntInstr(0x0D,locNo,false));
+ }
+ }
+
+ /// <summary>
+ /// Add the instruction to store to an argument. This method
+ /// selects the correct instruction based on the value of argNo.
+ /// </summary>
+ /// <param name="argNo">the argument to be stored to</param>
+ public void StoreArg(int argNo)
+ {
+ if (argNo <= maxUByteVal) {
+ AddToBuffer(new UIntInstr((int)IntOp.starg,argNo,true));
+ } else {
+ AddToBuffer(new UIntInstr(0x0B,argNo,false));
+ }
+ }
+
+ /// <summary>
+ /// Add the instruction to store to a local. This method selects
+ /// the correct instruction based on the value of locNo.
+ /// </summary>
+ /// <param name="locNo">the local to be stored to</param>
+ public void StoreLocal(int locNo)
+ {
+ if (locNo < 4) {
+ int op = (int)Op.stloc_0 + locNo;
+ AddToBuffer(new Instr(op));
+ } else if (locNo <= maxUByteVal) {
+ AddToBuffer(new UIntInstr((int)IntOp.stloc,locNo,true));
+ } else {
+ AddToBuffer(new UIntInstr(0x0E,locNo,false));
+ }
+ }
+
+ /// <summary>
+ /// Create a new CIL label. To place the label in the CIL instruction
+ /// stream use CodeLabel.
+ /// </summary>
+ /// <returns>a new CIL label</returns>
+ public CILLabel NewLabel()
+ {
+ return new CILLabel();
+ }
+
+ public void AddTryBlock(TryBlock tryBlock)
+ {
+ if (exceptions == null)
+ exceptions = new ArrayList();
+ else if (exceptions.Contains(tryBlock)) return;
+ exceptions.Add(tryBlock);
+ }
+
+ /// <summary>
+ /// Create a new label at this position in the code buffer
+ /// </summary>
+ /// <returns>the label at the current position</returns>
+ public CILLabel NewCodedLabel()
+ {
+ CILLabel lab = new CILLabel();
+ AddToBuffer(new LabelInstr(lab));
+ return lab;
+ }
+
+ /// <summary>
+ /// Mark this position as the start of a new block
+ /// (try, catch, filter, finally or fault)
+ /// </summary>
+ public void StartBlock()
+ {
+ if (blockStack == null) blockStack = new ArrayList();
+ blockStack.Insert(0,NewCodedLabel());
+ }
+
+ /// <summary>
+ /// Mark this position as the end of the last started block and
+ /// make it a try block. This try block is added to the current
+ /// instructions (ie do not need to call AddTryBlock)
+ /// </summary>
+ /// <returns>The try block just ended</returns>
+ public TryBlock EndTryBlock()
+ {
+ TryBlock tBlock = new TryBlock((CILLabel)blockStack[0],NewCodedLabel());
+ blockStack.RemoveAt(0);
+ AddTryBlock(tBlock);
+ return tBlock;
+ }
+
+ /// <summary>
+ /// Mark this position as the end of the last started block and
+ /// make it a catch block. This catch block is associated with the
+ /// specified try block.
+ /// </summary>
+ /// <param name="exceptType">the exception type to be caught</param>
+ /// <param name="tryBlock">the try block associated with this catch block</param>
+ public void EndCatchBlock(Class exceptType, TryBlock tryBlock)
+ {
+ Catch catchBlock = new Catch(exceptType,(CILLabel)blockStack[0],
+ NewCodedLabel());
+ tryBlock.AddHandler(catchBlock);
+ }
+
+ /// <summary>
+ /// Mark this position as the end of the last started block and
+ /// make it a filter block. This filter block is associated with the
+ /// specified try block.
+ /// </summary>
+ /// <param name="filterLab">the label where the filter code is</param>
+ /// <param name="tryBlock">the try block associated with this filter block</param>
+ public void EndFilterBlock(CILLabel filterLab, TryBlock tryBlock)
+ {
+ Filter filBlock = new Filter(filterLab,(CILLabel)blockStack[0],NewCodedLabel());
+ tryBlock.AddHandler(filBlock);
+ }
+
+ /// <summary>
+ /// Mark this position as the end of the last started block and
+ /// make it a finally block. This finally block is associated with the
+ /// specified try block.
+ /// </summary>
+ /// <param name="tryBlock">the try block associated with this finally block</param>
+ public void EndFinallyBlock(TryBlock tryBlock)
+ {
+ Finally finBlock= new Finally((CILLabel)blockStack[0],NewCodedLabel());
+ tryBlock.AddHandler(finBlock);
+ }
+
+ /// <summary>
+ /// Mark this position as the end of the last started block and
+ /// make it a fault block. This fault block is associated with the
+ /// specified try block.
+ /// </summary>
+ /// <param name="tryBlock">the try block associated with this fault block</param>
+ public void EndFaultBlock(TryBlock tryBlock)
+ {
+ Fault fBlock= new Fault((CILLabel)blockStack[0],NewCodedLabel());
+ tryBlock.AddHandler(fBlock);
+ }
+
+ internal uint GetCodeSize()
+ {
+ return codeSize + paddingNeeded + exceptSize;
+ }
+
+ internal void CheckCode(uint locSigIx, bool initLocals, int maxStack)
+ {
+ if (tide == 0) return;
+ bool changed = true;
+ while (changed) {
+ changed = false;
+ for (int i=0; i < tide; i++) {
+ changed = buffer[i].Check(metaData) || changed;
+ }
+ if (changed) {
+ for (int i=1; i < tide; i++) {
+ buffer[i].offset = buffer[i-1].offset + buffer[i-1].size;
+ }
+ offset = buffer[tide-1].offset + buffer[tide-1].size;
+ }
+ }
+ codeSize = offset;
+ // Console.WriteLine("codeSize before header added = " + codeSize);
+ if ((offset < smallSize) && (maxStack <= 8) && (locSigIx == 0) && (exceptions == null)) {
+ // can use tiny header
+ //Console.WriteLine("Tiny Header");
+ tinyFormat = true;
+ headerFlags = (ushort)(TinyFormat | ((ushort)codeSize << 2));
+ codeSize++;
+ if ((codeSize % 4) != 0) { paddingNeeded = 4 - (codeSize % 4); }
+ } else {
+ //Console.WriteLine("Fat Header");
+ tinyFormat = false;
+ localSigIx = locSigIx;
+ this.maxStack = (short)maxStack;
+ headerFlags = FatFormat;
+ if (exceptions != null) {
+ // Console.WriteLine("Got exceptions");
+ headerFlags |= MoreSects;
+ uint numExceptClauses = 0;
+ for (int i=0; i < exceptions.Count; i++) {
+ TryBlock tryBlock = (TryBlock)exceptions[i];
+ tryBlock.SetSize();
+ numExceptClauses += (uint)tryBlock.NumHandlers();
+ if (tryBlock.isFat()) fatExceptionFormat = true;
+ }
+
+ uint data_size = ExHeaderSize + numExceptClauses *
+ (fatExceptionFormat ? FatExClauseSize : SmlExClauseSize);
+
+ if (data_size > 255)
+ fatExceptionFormat = true;
+
+ // Console.WriteLine("numexceptclauses = " + numExceptClauses);
+ if (fatExceptionFormat) {
+ // Console.WriteLine("Fat exception format");
+ exceptHeader = FatExceptTable;
+ exceptSize = ExHeaderSize + numExceptClauses * FatExClauseSize;
+ } else {
+ // Console.WriteLine("Tiny exception format");
+ exceptHeader = SmlExceptTable;
+ exceptSize = ExHeaderSize + numExceptClauses * SmlExClauseSize;
+ }
+ // Console.WriteLine("exceptSize = " + exceptSize);
+ }
+ if (initLocals) headerFlags |= InitLocals;
+ if ((offset % 4) != 0) { paddingNeeded = 4 - (offset % 4); }
+ codeSize += FatSize;
+ }
+ // Console.WriteLine("codeSize = " + codeSize + " headerFlags = " +
+ // Hex.Short(headerFlags));
+ }
+
+ internal void Write(FileImage output)
+ {
+ // Console.WriteLine("Writing header flags = " + Hex.Short(headerFlags));
+ if (tinyFormat) {
+ // Console.WriteLine("Writing tiny code");
+ output.Write((byte)headerFlags);
+ } else {
+ // Console.WriteLine("Writing fat code");
+ output.Write(headerFlags);
+ output.Write((ushort)maxStack);
+ output.Write(offset);
+ output.Write(localSigIx);
+ }
+ // Console.WriteLine(Hex.Int(tide) + " CIL instructions");
+ // Console.WriteLine("starting instructions at " + output.Seek(0,SeekOrigin.Current));
+ for (int i=0; i < tide; i++) {
+ buffer[i].Write(output);
+ }
+ // Console.WriteLine("ending instructions at " + output.Seek(0,SeekOrigin.Current));
+ for (int i=0; i < paddingNeeded; i++) { output.Write((byte)0); }
+ if (exceptions != null) {
+ // Console.WriteLine("Writing exceptions");
+ // Console.WriteLine("header = " + Hex.Short(exceptHeader) + " exceptSize = " + Hex.Int(exceptSize));
+ output.Write(exceptHeader);
+ output.Write3Bytes((uint)exceptSize);
+ for (int i=0; i < exceptions.Count; i++) {
+ TryBlock tryBlock = (TryBlock)exceptions[i];
+ tryBlock.Write(output,fatExceptionFormat);
+ }
+ }
+ }
+
+ }
+
+ /**************************************************************************/
+ public abstract class CodeBlock {
+
+ private static readonly int maxCodeSize = 255;
+ protected CILLabel start, end;
+ protected bool small = true;
+
+ public CodeBlock(CILLabel start, CILLabel end)
+ {
+ this.start = start;
+ this.end = end;
+ }
+
+ internal virtual bool isFat()
+ {
+ // Console.WriteLine("block start = " + start.GetLabelOffset() +
+ // " block end = " + end.GetLabelOffset());
+ return (end.GetLabelOffset() - start.GetLabelOffset()) > maxCodeSize;
+ }
+
+ internal virtual void Write(FileImage output, bool fatFormat)
+ {
+ if (fatFormat) output.Write(start.GetLabelOffset());
+ else output.Write((short)start.GetLabelOffset());
+ uint len = end.GetLabelOffset() - start.GetLabelOffset();
+ if (fatFormat) output.Write(len);
+ else output.Write((byte)len);
+ }
+
+ }
+
+ /// <summary>
+ /// The descriptor for a guarded block (.try)
+ /// </summary>
+ public class TryBlock : CodeBlock {
+ protected bool fatFormat = false;
+ protected int flags = 0;
+ ArrayList handlers = new ArrayList();
+
+ /// <summary>
+ /// Create a new try block
+ /// </summary>
+ /// <param name="start">start label for the try block</param>
+ /// <param name="end">end label for the try block</param>
+ public TryBlock(CILLabel start, CILLabel end) : base(start,end) { }
+
+ /// <summary>
+ /// Add a handler to this try block
+ /// </summary>
+ /// <param name="handler">a handler to be added to the try block</param>
+ public void AddHandler(HandlerBlock handler)
+ {
+ flags = handler.GetFlag();
+ handlers.Add(handler);
+ }
+
+ internal void SetSize()
+ {
+ fatFormat = base.isFat();
+ if (fatFormat) return;
+ for (int i=0; i < handlers.Count; i++) {
+ HandlerBlock handler = (HandlerBlock)handlers[i];
+ if (handler.isFat()) {
+ fatFormat = true;
+ return;
+ }
+ }
+ }
+
+ internal int NumHandlers()
+ {
+ return handlers.Count;
+ }
+
+ internal override bool isFat()
+ {
+ return fatFormat;
+ }
+
+ internal override void Write(FileImage output, bool fatFormat)
+ {
+ // Console.WriteLine("writing exception details");
+ for (int i=0; i < handlers.Count; i++) {
+ // Console.WriteLine("Except block " + i);
+ HandlerBlock handler = (HandlerBlock)handlers[i];
+ if (fatFormat) output.Write(flags);
+ else output.Write((short)flags);
+ // Console.WriteLine("flags = " + Hex.Short(flags));
+ base.Write(output,fatFormat);
+ handler.Write(output,fatFormat);
+ }
+ }
+ }
+
+ public abstract class HandlerBlock : CodeBlock {
+
+ protected static readonly short ExceptionFlag = 0;
+ protected static readonly short FilterFlag = 0x01;
+ protected static readonly short FinallyFlag = 0x02;
+ protected static readonly short FaultFlag = 0x04;
+
+ public HandlerBlock(CILLabel start, CILLabel end) : base(start,end) { }
+
+ internal virtual short GetFlag() { return ExceptionFlag; }
+
+ internal override void Write(FileImage output, bool fatFormat)
+ {
+ base.Write(output,fatFormat);
+ }
+
+ }
+
+ /// <summary>
+ /// The descriptor for a catch clause (.catch)
+ /// </summary>
+ public class Catch : HandlerBlock {
+
+ Class exceptType;
+
+ /// <summary>
+ /// Create a new catch clause
+ /// </summary>
+ /// <param name="except">the exception to be caught</param>
+ /// <param name="handlerStart">start of the handler code</param>
+ /// <param name="handlerEnd">end of the handler code</param>
+ public Catch(Class except, CILLabel handlerStart, CILLabel handlerEnd)
+ : base(handlerStart,handlerEnd)
+ {
+ exceptType = except;
+ }
+
+ internal override void Write(FileImage output, bool fatFormat)
+ {
+ base.Write(output,fatFormat);
+ output.Write(exceptType.Token());
+ }
+ }
+
+ /// <summary>
+ /// The descriptor for a filter clause (.filter)
+ /// </summary>
+ public class Filter : HandlerBlock {
+
+ CILLabel filterLabel;
+
+ /// <summary>
+ /// Create a new filter clause
+ /// </summary>
+ /// <param name="filterLabel">the label where the filter code starts</param>
+ /// <param name="handlerStart">the start of the handler code</param>
+ /// <param name="handlerEnd">the end of the handler code</param>
+ public Filter(CILLabel filterLabel, CILLabel handlerStart,
+ CILLabel handlerEnd) : base(handlerStart,handlerEnd)
+ {
+ this.filterLabel = filterLabel;
+ }
+
+ internal override short GetFlag()
+ {
+ return FilterFlag;
+ }
+
+ internal override void Write(FileImage output, bool fatFormat)
+ {
+ base.Write(output,fatFormat);
+ output.Write(filterLabel.GetLabelOffset());
+ }
+
+ }
+
+ /// <summary>
+ /// Descriptor for a finally block (.finally)
+ /// </summary>
+ public class Finally : HandlerBlock {
+
+ /// <summary>
+ /// Create a new finally clause
+ /// </summary>
+ /// <param name="finallyStart">start of finally code</param>
+ /// <param name="finallyEnd">end of finally code</param>
+ public Finally(CILLabel finallyStart, CILLabel finallyEnd)
+ : base(finallyStart,finallyEnd) { }
+
+ internal override short GetFlag()
+ {
+ return FinallyFlag;
+ }
+
+ internal override void Write(FileImage output, bool fatFormat)
+ {
+ base.Write(output,fatFormat);
+ output.Write((int)0);
+ }
+
+ }
+
+ /// <summary>
+ /// Descriptor for a fault block (.fault)
+ /// </summary>
+ public class Fault : HandlerBlock {
+
+ /// <summary>
+ /// Create a new fault clause
+ /// </summary>
+ /// <param name="faultStart">start of the fault code</param>
+ /// <param name="faultEnd">end of the fault code</param>
+ public Fault(CILLabel faultStart, CILLabel faultEnd)
+ : base(faultStart,faultEnd) { }
+
+ internal override short GetFlag()
+ {
+ return FaultFlag;
+ }
+
+ internal override void Write(FileImage output, bool fatFormat)
+ {
+ base.Write(output,fatFormat);
+ output.Write((int)0);
+
+ }
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for the locals for a method
+ /// </summary>
+ public class LocalSig : Signature {
+
+ private static readonly byte LocalSigByte = 0x7;
+ Local[] locals;
+
+ public LocalSig(Local[] locals)
+ {
+ this.locals = locals;
+ tabIx = MDTable.StandAloneSig;
+ }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ if (done) return;
+ MemoryStream sig = new MemoryStream();
+ sig.WriteByte(LocalSigByte);
+ MetaData.CompressNum((uint)locals.Length,sig);
+ for (int i=0; i < locals.Length; i++) {
+ ((Local)locals[i]).TypeSig(sig);
+ }
+ sigIx = md.AddToBlobHeap(sig.ToArray());
+ done = true;
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Signature for calli instruction
+ /// </summary>
+ public class CalliSig : Signature {
+
+ private static readonly byte Sentinel = 0x41;
+ CallConv callConv;
+ Type returnType;
+ Type[] parameters, optParams;
+ uint numPars = 0, numOptPars = 0;
+
+ /// <summary>
+ /// Create a signature for a calli instruction
+ /// </summary>
+ /// <param name="cconv">calling conventions</param>
+ /// <param name="retType">return type</param>
+ /// <param name="pars">parameter types</param>
+ public CalliSig(CallConv cconv, Type retType, Type[] pars)
+ {
+ tabIx = MDTable.StandAloneSig;
+ callConv = cconv;
+ returnType = retType;
+ parameters = pars;
+ if (pars != null) numPars = (uint)pars.Length;
+ }
+
+ /// <summary>
+ /// Add the optional parameters to a vararg method
+ /// This method sets the vararg calling convention
+ /// </summary>
+ /// <param name="optPars">the optional pars for the vararg call</param>
+ public void AddVarArgs(Type[] optPars)
+ {
+ optParams = optPars;
+ if (optPars != null) numOptPars = (uint)optPars.Length;
+ callConv |= CallConv.Vararg;
+ }
+
+ /// <summary>
+ /// Add extra calling conventions to this callsite signature
+ /// </summary>
+ /// <param name="cconv"></param>
+ public void AddCallingConv(CallConv cconv)
+ {
+ callConv |= cconv;
+ }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ if (done) return;
+ MemoryStream sig = new MemoryStream();
+ sig.WriteByte((byte)callConv);
+ MetaData.CompressNum(numPars+numOptPars,sig);
+ returnType.TypeSig(sig);
+ for (int i=0; i < numPars; i++) {
+ parameters[i].TypeSig(sig);
+ }
+ sigIx = md.AddToBlobHeap(sig.ToArray());
+ if (numOptPars > 0) {
+ sig.WriteByte(Sentinel);
+ for (int i=0; i < numOptPars; i++) {
+ optParams[i].TypeSig(sig);
+ }
+ }
+ done = true;
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for a local of a method
+ /// </summary>
+ public class Local {
+
+ private static readonly byte Pinned = 0x45;
+ string name;
+ Type type;
+ bool pinned = false, byref = false;
+
+ /// <summary>
+ /// Create a new local variable
+ /// </summary>
+ /// <param name="lName">name of the local variable</param>
+ /// <param name="lType">type of the local variable</param>
+ public Local(string lName, Type lType)
+ {
+ name = lName;
+ type = lType;
+ }
+
+ /// <summary>
+ /// Create a new local variable that is byref and/or pinned
+ /// </summary>
+ /// <param name="lName">local name</param>
+ /// <param name="lType">local type</param>
+ /// <param name="byRef">is byref</param>
+ /// <param name="isPinned">has pinned attribute</param>
+ public Local(string lName, Type lType, bool byRef, bool isPinned)
+ {
+ name = lName;
+ type = lType;
+ byref = byRef;
+ pinned = isPinned;
+ }
+
+ internal void TypeSig(MemoryStream str)
+ {
+ if (pinned) str.WriteByte(Pinned);
+ type.TypeSig(str);
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// A label in the IL
+ /// </summary>
+ public class CILLabel {
+
+ CILInstruction branch;
+ CILInstruction[] multipleBranches;
+ int tide = 0;
+ CILInstruction labInstr;
+ uint offset = 0;
+
+ public CILLabel (uint offset)
+ {
+ this.offset = offset;
+ }
+
+
+ internal CILLabel()
+ {
+ }
+
+ internal void AddBranch(CILInstruction instr)
+ {
+ if (branch == null) {
+ branch = instr;
+ return;
+ }
+ if (multipleBranches == null) {
+ multipleBranches = new CILInstruction[2];
+ } else if (tide >= multipleBranches.Length) {
+ CILInstruction[] tmp = multipleBranches;
+ multipleBranches = new CILInstruction[tmp.Length*2];
+ for (int i=0; i < tide; i++) {
+ multipleBranches[i] = tmp[i];
+ }
+ }
+ multipleBranches[tide++] = instr;
+ }
+
+ internal void AddLabelInstr(LabelInstr lInstr)
+ {
+ labInstr = lInstr;
+ }
+
+ internal uint GetLabelOffset()
+ {
+ if (labInstr == null) return 0;
+ return labInstr.offset + offset;
+ }
+
+ }
+
+
+}
+
+
diff --git a/mcs/class/PEAPI/Makefile b/mcs/class/PEAPI/Makefile
new file mode 100644
index 00000000000..8b62d923806
--- /dev/null
+++ b/mcs/class/PEAPI/Makefile
@@ -0,0 +1,11 @@
+thisdir = class/PEAPI
+SUBDIRS =
+include ../../build/rules.make
+
+LIBRARY = PEAPI.dll
+LIB_MCS_FLAGS = /r:$(corlib) /r:System.dll
+NO_TEST = yes
+
+EXTRA_DISTFILES = README.txt
+
+include ../../build/library.make
diff --git a/mcs/class/PEAPI/Metadata.cs b/mcs/class/PEAPI/Metadata.cs
new file mode 100644
index 00000000000..c77ae5d9b65
--- /dev/null
+++ b/mcs/class/PEAPI/Metadata.cs
@@ -0,0 +1,5659 @@
+using System;
+using System.IO;
+using System.Collections;
+using System.Text;
+
+namespace PEAPI {
+
+ #region Enums
+
+ /// <summary>
+ /// flags for the assembly (.corflags)
+ /// </summary>
+ public enum CorFlags {CF_IL_ONLY = 1, CF_32_BITREQUIRED = 2,
+ CF_STRONGNAMESIGNED = 8, CF_TRACKDEBUGDATA = 0x10000 }
+
+ /// <summary>
+ /// subsystem for the assembly (.subsystem)
+ /// </summary>
+ public enum SubSystem { Native = 1, Windows_GUI = 2,
+ Windows_CUI = 3, OS2_CUI = 5, POSIX_CUI = 7, Native_Windows = 8,
+ Windows_CE_GUI = 9}
+
+ /// <summary>
+ /// Hash algorithms for the assembly
+ /// </summary>
+ public enum HashAlgorithm { None, SHA1 }
+
+ /// <summary>
+ /// Attributes for this assembly
+ /// </summary>
+ public enum AssemAttr { EnableJITCompileTracking = 0x8000,
+ DisableJITCompileOptimizer = 0x4000}
+
+ /// <summary>
+ /// Method call conventions
+ /// </summary>
+ [Flags]
+ public enum CallConv { Default, Cdecl, Stdcall, Thiscall,
+ Fastcall, Vararg, Instance = 0x20, Generic = 0x10, InstanceExplicit = 0x60 }
+
+ /// <summary>
+ /// Type custom modifier
+ /// </summary>
+ public enum CustomModifier { modreq = 0x1F, modopt };
+
+ /// <summary>
+ /// Attibutes for a class
+ /// </summary>
+ [Flags]
+ public enum TypeAttr {Private, Public, NestedPublic, NestedPrivate,
+ NestedFamily, NestedAssembly, NestedFamAndAssem, NestedFamOrAssem,
+ SequentialLayout, ExplicitLayout = 0x10, Interface = 0x20,
+ Abstract = 0x80, PublicAbstract = 0x81, Sealed = 0x100,
+ PublicSealed = 0x101, SpecialName = 0x400, RTSpecialName = 0x800,
+ Import = 0x1000, Serializable = 0x2000, UnicodeClass = 0x10000,
+ AutoClass = 0x20000, HasSecurity = 0x40000, BeforeFieldInit = 0x100000,
+ VisibilityMask = 0x07 }
+
+ /// <summary>
+ /// Attributes for a field
+ /// </summary>
+ public enum FieldAttr {Default, Private, FamAndAssem, Assembly,
+ Family, FamOrAssem, Public, Static = 0x10, PublicStatic = 0x16,
+ Initonly = 0x20, Literal = 0x40, Notserialized = 0x80,
+ SpecialName = 0x200, RTSpecialName = 0x400, HasFieldMarshal = 0x1000 }
+
+ /// <summary>
+ /// Attributes for a method
+ /// </summary>
+ public enum MethAttr { Default, Private, FamAndAssem, Assembly,
+ Family, FamOrAssem, Public, Static = 0x0010, PublicStatic = 0x16,
+ Final = 0x0020, PublicStaticFinal = 0x36, Virtual = 0x0040,
+ PrivateVirtual, PublicVirtual = 0x0046, HideBySig = 0x0080,
+ NewSlot = 0x0100, Abstract = 0x0400, SpecialName = 0x0800,
+ RTSpecialName = 0x1000, SpecialRTSpecialName = 0x1800,
+ HasSecurity = 0x4000, RequireSecObject = 0x8000}
+
+ /// <summary>
+ /// Attributes for .pinvokeimpl method declarations
+ /// </summary>
+ public enum PInvokeAttr { nomangle = 1, ansi = 2, unicode = 4, autochar = 6,
+ bestfit_on = 0x0010, bestfit_off = 0x0020, bestfit_mask = 0x0030,
+ lasterr = 0x0040, winapi = 0x0100, cdecl = 0x0200,
+ stdcall = 0x0300, thiscall = 0x0400, fastcall = 0x0500,
+ charmaperror_on = 0x1000, charmaperror_off = 0x2000
+ }
+
+ /// <summary>
+ /// Implementation attributes for a method
+ /// </summary>
+ public enum ImplAttr { IL, Native, Runtime = 0x03, Unmanaged = 0x04,
+ ForwardRef = 0x10, PreserveSig = 0x0080, InternalCall = 0x1000,
+ Synchronised = 0x0020, Synchronized = 0x0020, NoInLining = 0x0008, Optil = 0x0002}
+
+ /// <summary>
+ /// Modes for a parameter
+ /// </summary>
+ public enum ParamAttr { Default, In, Out, Opt = 16, HasDefault = 0x1000, HasFieldMarshal = 0x2000 }
+
+ /// <summary>
+ /// CIL instructions
+ /// </summary>
+ public enum Op { nop, breakOp, ldarg_0, ldarg_1, ldarg_2, ldarg_3,
+ ldloc_0, ldloc_1, ldloc_2, ldloc_3, stloc_0, stloc_1, stloc_2, stloc_3,
+ ldnull = 0x14, ldc_i4_m1, ldc_i4_0, ldc_i4_1, ldc_i4_2, ldc_i4_3,
+ ldc_i4_4, ldc_i4_5, ldc_i4_6, ldc_i4_7, ldc_i4_8, dup = 0x25, pop,
+ ret = 0x2A, ldind_i1 = 0x46, ldind_u1, ldind_i2, ldind_u2, ldind_i4,
+ ldind_u4, ldind_i8, ldind_i, ldind_r4, ldind_r8, ldind_ref, stind_ref,
+ stind_i1, stind_i2, stind_i4, stind_i8, stind_r4, stind_r8, add, sub, mul,
+ div, div_un, rem, rem_un, and, or, xor, shl, shr, shr_un, neg, not,
+ conv_i1, conv_i2, conv_i4, conv_i8, conv_r4, conv_r8, conv_u4, conv_u8,
+ conv_r_un = 0x76, throwOp = 0x7A, conv_ovf_i1_un = 0x82, conv_ovf_i2_un,
+ conv_ovf_i4_un, conv_ovf_i8_un, conf_ovf_u1_un, conv_ovf_u2_un,
+ conv_ovf_u4_un, conv_ovf_u8_un, conv_ovf_i_un, conv_ovf_u_un,
+ ldlen = 0x8E, ldelem_i1 = 0x90, ldelem_u1, ldelem_i2, ldelem_u2,
+ ldelem_i4, ldelem_u4, ldelem_i8, ldelem_i, ldelem_r4, ldelem_r8,
+ ldelem_ref, stelem_i, stelem_i1, stelem_i2, stelem_i4, stelem_i8, stelem_r4 = 0xA0, stelem_r8,
+ stelem_ref, conv_ovf_i1 = 0xb3, conv_ovf_u1, conv_ovf_i2, conv_ovf_u2,
+ conv_ovf_i4, conv_ovf_u4, conv_ovf_i8, conv_ovf_u8, ckfinite = 0xC3,
+ conv_u2 = 0xD1, conv_u1, conv_i, conv_ovf_i, conv_ovf_u, add_ovf,
+ add_ovf_un, mul_ovf, mul_ovf_un, sub_ovf, sub_ovf_un, endfinally,
+ stind_i = 0xDF, conv_u, arglist = 0xFE00, ceq, cgt, cgt_un, clt, clt_un,
+ localloc = 0xFE0F, endfilter = 0xFE11, volatile_ = 0xFE13, tail_,
+ cpblk = 0xFE17, initblk, rethrow = 0xFE1A, refanytype = 0xFE1D, readonly_ = 0xFE1E }
+
+ /// <summary>
+ /// CIL instructions requiring an integer parameter
+ /// </summary>
+ public enum IntOp {ldarg_s = 0x0E, ldarga_s, starg_s, ldloc_s, ldloca_s,
+ stloc_s, ldc_i4_s = 0x1F, ldc_i4, ldarg = 0xFE09,
+ ldarga, starg, ldloc, ldloca, stloc, unaligned = 0xFE12 }
+
+ /// <summary>
+ /// CIL instructions requiring a field parameter
+ /// </summary>
+ public enum FieldOp {ldfld = 0x7B, ldflda, stfld, ldsfld, ldsflda,
+ stsfld, ldtoken = 0xD0 }
+
+ /// <summary>
+ /// CIL instructions requiring a method parameter
+ /// </summary>
+ public enum MethodOp {jmp = 0x27, call, callvirt = 0x6F, newobj = 0x73,
+ ldtoken = 0xD0, ldftn = 0xFE06, ldvirtfn }
+
+ /// <summary>
+ /// CIL instructions requiring a type parameter
+ /// </summary>
+ public enum TypeOp {cpobj = 0x70, ldobj, castclass = 0x74, isinst,
+ unbox = 0x79, stobj = 0x81, box = 0x8C, newarr,
+ ldelema = 0x8F, refanyval = 0xC2, mkrefany = 0xC6,
+ ldtoken = 0xD0, initobj = 0xFE15, constrained = 0xFE16,
+ sizeOf = 0xFE1C, ldelem = 0xA3, stelem = 0xA4, unbox_any }
+
+ /// <summary>
+ /// CIL branch instructions
+ /// </summary>
+ public enum BranchOp {
+ // short branches
+ br_s = 0x2B, brfalse_s, brtrue_s, beq_s, bge_s, bgt_s,
+ ble_s, blt_s, bne_un_s, bge_un_s, bgt_un_s, ble_un_s, blt_un_s,
+ // long branches
+ br = 0x38, brfalse, brtrue, beq, bge, bgt, ble, blt,
+ bne_un, bge_un, bgt_un, ble_un, blt_un,
+
+ leave = 0xDD, leave_s }
+
+ /// <summary>
+ /// Index for all the tables in the meta data
+ /// </summary>
+ public enum MDTable { Module, TypeRef, TypeDef, Field = 0x04, Method = 0x06,
+ Param = 0x08, InterfaceImpl, MemberRef, Constant, CustomAttribute,
+ FieldMarshal, DeclSecurity, ClassLayout, FieldLayout, StandAloneSig,
+ EventMap, Event = 0x14, PropertyMap, Property = 0x17, MethodSemantics,
+ MethodImpl, ModuleRef, TypeSpec, ImplMap, FieldRVA, Assembly = 0x20,
+ AssemblyProcessor, AssemblyOS, AssemblyRef, AssemblyRefProcessor,
+ AssemblyRefOS, File, ExportedType, ManifestResource, NestedClass,
+ GenericParam, MethodSpec, GenericParamConstraint }
+
+ public enum SafeArrayType { int16 = 2, int32, float32, float64,
+ currency, date, bstr, dispatch, error, boolean, variant, unknown,
+ Decimal, int8 = 16, uint8, uint16, uint32, Int = 22, UInt }
+
+ internal enum CIx { TypeDefOrRef, HasConst, HasCustomAttr, HasFieldMarshal,
+ HasDeclSecurity, MemberRefParent, HasSemantics, MethodDefOrRef,
+ MemberForwarded, Implementation, CustomAttributeType, ResolutionScope,
+ TypeOrMethodDef, MaxCIx }
+
+ internal enum MapType { eventMap, propertyMap, nestedClass }
+
+ public enum ValueClass { ValueType, Enum }
+
+ public enum GenParamType : byte {
+ Var = 0x13, MVar = 0x1E
+ }
+
+ [Flags]
+ public enum GenericParamAttributes : ushort {
+ VarianceMask = 0x0003,
+ NonVariant = 0x0000,
+ Covariant = 0x0001,
+ Contravariant = 0x0002,
+
+ SpecialConstraintMask = 0x001c,
+ ReferenceTypeConstraint = 0x0004,
+ NotNullableValueTypeConstraint = 0x0008,
+ DefaultConstructorConstrait = 0x0010
+ }
+
+ /* Taken from Mono.Cecil */
+ public enum SecurityAction : short {
+ Request = 1,
+ Demand = 2,
+ Assert = 3,
+ Deny = 4,
+ PermitOnly = 5,
+ LinkDemand = 6,
+ InheritDemand = 7,
+ RequestMinimum = 8,
+ RequestOptional = 9,
+ RequestRefuse = 10,
+ PreJitGrant = 11,
+ PreJitDeny = 12,
+ NonCasDemand = 13,
+ NonCasLinkDemand = 14,
+ NonCasInheritance = 15,
+ LinkDemandChoice = 16,
+ InheritDemandChoice = 17,
+ DemandChoice = 18
+ }
+
+ #endregion
+
+ /**************************************************************************/
+ /// <summary>
+ /// Base class for all Meta Data table elements
+ /// </summary>
+
+ public abstract class MetaDataElement: IComparable {
+ protected ArrayList customAttributes;
+ private uint row = 0;
+ protected bool done = false;
+ protected MDTable tabIx;
+ protected bool sortTable = false;
+
+ internal MetaDataElement() { }
+
+ public uint Row {
+ get {
+ return row;
+ }
+ set {
+ row = value;
+ }
+ }
+
+ internal virtual uint GetCodedIx(CIx code) { return 0; }
+
+ /// <summary>
+ /// Add a custom attribute to this item
+ /// </summary>
+ /// <param name="ctorMeth">the constructor method for this attribute</param>
+ /// <param name="val">the byte value of the parameters</param>
+ public void AddCustomAttribute(Method ctorMeth, byte[] val)
+ {
+ if (customAttributes == null) {
+ customAttributes = new ArrayList();
+ }
+ customAttributes.Add(new CustomAttribute(this,ctorMeth,val));
+ }
+
+ /// <summary>
+ /// Add a custom attribute to this item
+ /// </summary>
+ /// <param name="ctorMeth">the constructor method for this attribute</param>
+ /// <param name="val">the constant values of the parameters</param>
+ public void AddCustomAttribute(Method ctorMeth, Constant[] cVals)
+ {
+ if (customAttributes == null) {
+ customAttributes = new ArrayList();
+ }
+ // customAttributes.Add(new CustomAttribute(this,ctorMeth,cVals));
+ }
+
+ internal uint Token()
+ {
+ return (((uint)tabIx << 24) | row);
+ }
+
+ internal virtual void BuildTables(MetaData md)
+ {
+ done = true;
+ }
+
+ internal virtual uint Size(MetaData md)
+ {
+ return 0;
+ }
+
+ internal virtual void Write(FileImage output) { }
+
+ internal virtual uint SortKey()
+ {
+ throw new PEFileException("Trying to sort table of " + this);
+ //return 0;
+ }
+
+ internal virtual uint SortKey2()
+ {
+ return 0;
+ }
+
+ public int CompareTo(object obj)
+ {
+ uint otherKey = ((MetaDataElement)obj).SortKey();
+ uint thisKey = SortKey();
+
+ if (thisKey == otherKey) {
+
+ otherKey = ((MetaDataElement)obj).SortKey2();
+ thisKey = SortKey2();
+ if (thisKey == otherKey)
+ return 0;
+ if (thisKey < otherKey)
+ return -1;
+ return 1;
+ }
+ if (thisKey < otherKey) return -1;
+
+ return 1;
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Layout information for a class (.class [sequential | explicit])
+ /// </summary>
+ internal class ClassLayout : MetaDataElement {
+
+ ClassDef parent;
+ ushort packSize = 0;
+ uint classSize = 0;
+
+ internal ClassLayout(int pack, int cSize, ClassDef par)
+ {
+ packSize = (ushort)pack;
+ classSize = (uint)cSize;
+ parent = par;
+ tabIx = MDTable.ClassLayout;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return 6 + md.TableIndexSize(MDTable.TypeDef);
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.Write(packSize);
+ output.Write(classSize);
+ output.WriteIndex(MDTable.TypeDef,parent.Row);
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Summary description for ConstantElem.
+ /// </summary>
+ internal class ConstantElem : MetaDataElement {
+
+ MetaDataElement parent;
+ Constant cValue;
+ uint valIx = 0;
+
+ internal ConstantElem(MetaDataElement parent, Constant val)
+ {
+ this.parent = parent;
+ cValue = val;
+ tabIx = MDTable.Constant;
+ sortTable = true;
+ }
+
+ internal override uint SortKey()
+ {
+ return (parent.Row << MetaData.CIxShiftMap[(uint)CIx.HasConst])
+ | parent.GetCodedIx(CIx.HasConst);
+ }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ if (done) return;
+ valIx = cValue.GetBlobIndex(md);
+ done = true;
+ }
+
+ internal void AddToBlob(BinaryWriter bw)
+ {
+ cValue.Write(bw);
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return 2 + md.CodedIndexSize(CIx.HasConst) + md.BlobIndexSize();
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.Write(cValue.GetTypeIndex());
+ output.Write((byte)0);
+ output.WriteCodedIndex(CIx.HasConst,parent);
+ output.BlobIndex(valIx);
+ }
+
+ }
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for a Custom Attribute (.custom)
+ /// </summary>
+
+ public class CustomAttribute : MetaDataElement {
+
+ private static readonly ushort prolog = 0x0001;
+ MetaDataElement parent;
+ Method type;
+ uint valIx;
+ Constant cVal;
+ byte[] byteVal;
+ ushort numNamed = 0;
+ ArrayList names, vals;
+
+ internal CustomAttribute(MetaDataElement paren, Method constrType,
+ Constant val) {
+ parent = paren;
+ type = constrType;
+ cVal = val;
+ tabIx = MDTable.CustomAttribute;
+ }
+
+ internal CustomAttribute(MetaDataElement paren, Method constrType,
+ byte[] val) {
+ parent = paren;
+ type = constrType;
+ tabIx = MDTable.CustomAttribute;
+ byteVal = val;
+ }
+
+ internal override uint SortKey()
+ {
+ return (parent.Row << MetaData.CIxShiftMap[(uint)CIx.HasCustomAttr])
+ | parent.GetCodedIx(CIx.HasCustomAttr);
+ }
+
+ public void AddFieldOrProp(string name, Constant val)
+ {
+ if (numNamed == 0) {
+ names = new ArrayList();
+ vals = new ArrayList();
+ }
+ names.Add(name);
+ vals.Add(val);
+ }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ BinaryWriter bw = new BinaryWriter(new MemoryStream());
+ bw.Write(byteVal);
+ md.AddToTable(MDTable.CustomAttribute, this);
+ MemoryStream str = (MemoryStream)bw.BaseStream;
+ valIx = md.AddToBlobHeap(str.ToArray());
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return md.CodedIndexSize(CIx.HasCustomAttr) + md.CodedIndexSize(CIx.CustomAttributeType) + md.BlobIndexSize();
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.WriteCodedIndex(CIx.HasCustomAttr,parent);
+ output.WriteCodedIndex(CIx.CustomAttributeType,type);
+ output.BlobIndex(valIx);
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for security permissions for a class or a method
+ /// </summary>
+
+ public class DeclSecurity : MetaDataElement {
+
+ ushort action;
+ MetaDataElement parent;
+ uint permissionIx;
+ byte [] byteVal;
+
+ internal DeclSecurity(MetaDataElement paren, ushort act, byte [] val)
+ {
+ parent = paren;
+ action = act;
+ tabIx = MDTable.DeclSecurity;
+ byteVal = val;
+ }
+
+ internal override uint SortKey()
+ {
+ return (parent.Row << MetaData.CIxShiftMap[(uint)CIx.HasDeclSecurity])
+ | parent.GetCodedIx(CIx.HasDeclSecurity);
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return 2 + md.CodedIndexSize(CIx.HasDeclSecurity) + md.BlobIndexSize();
+ }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ if (done) return;
+ BinaryWriter bw = new BinaryWriter (new MemoryStream ());
+ bw.Write (byteVal);
+ md.AddToTable (MDTable.DeclSecurity, this);
+ MemoryStream str = (MemoryStream)bw.BaseStream;
+ permissionIx = md.AddToBlobHeap(str.ToArray());
+
+ done = true;
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.Write(action);
+ output.WriteCodedIndex(CIx.HasDeclSecurity,parent);
+ output.BlobIndex(permissionIx);
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for layout information for a field
+ /// </summary>
+
+ public class FieldLayout : MetaDataElement {
+
+ Field field;
+ uint offset;
+
+ internal FieldLayout(Field field, uint offset)
+ {
+ this.field = field;
+ this.offset = offset;
+ tabIx = MDTable.FieldLayout;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return 4 + md.TableIndexSize(MDTable.Field);
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.Write(offset);
+ output.WriteIndex(MDTable.Field,field.Row);
+ }
+
+ }
+
+ /*****************************************************************************/
+ /// <summary>
+ /// Marshalling information for a field or param
+ /// </summary>
+ public class FieldMarshal : MetaDataElement {
+
+ MetaDataElement field;
+ NativeType nt;
+ uint ntIx;
+
+ internal FieldMarshal(MetaDataElement field, NativeType nType)
+ {
+ this.field = field;
+ this.nt = nType;
+ tabIx = MDTable.FieldMarshal;
+ }
+
+ internal override uint SortKey()
+ {
+ return (field.Row << MetaData.CIxShiftMap[(uint)CIx.HasFieldMarshal])
+ | field.GetCodedIx(CIx.HasFieldMarshal);
+ }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ if (done) return;
+ ntIx = md.AddToBlobHeap(nt.ToBlob());
+ done = true;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return md.CodedIndexSize(CIx.HasFieldMarshal) + md.BlobIndexSize();
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.WriteCodedIndex(CIx.HasFieldMarshal,field);
+ output.BlobIndex(ntIx);
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for the address of a field's value in the PE file
+ /// </summary>
+ public class FieldRVA : MetaDataElement {
+
+ Field field;
+ DataConstant data;
+
+ internal FieldRVA(Field field, DataConstant data)
+ {
+ this.field = field;
+ this.data = data;
+ tabIx = MDTable.FieldRVA;
+ }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ if (done) return;
+ md.AddData(data);
+ done = true;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return 4 + md.TableIndexSize(MDTable.Field);
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.WriteDataRVA(data.DataOffset);
+ output.WriteIndex(MDTable.Field,field.Row);
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for a file referenced in THIS assembly/module (.file)
+ /// </summary>
+ public class FileRef : MetaDataElement {
+
+ private static readonly uint NoMetaData = 0x1;
+ uint nameIx = 0, hashIx = 0;
+ uint flags = 0;
+ protected string name;
+
+ internal FileRef(string name, byte[] hashBytes, bool metaData,
+ bool entryPoint, MetaData md) {
+ if (!metaData) flags = NoMetaData;
+ if (entryPoint) md.SetEntryPoint(this);
+ this.name = name;
+ nameIx = md.AddToStringsHeap(name);
+ hashIx = md.AddToBlobHeap(hashBytes);
+ tabIx = MDTable.File;
+ }
+
+ internal FileRef(uint nameIx, byte[] hashBytes, bool metaData,
+ bool entryPoint, MetaData md) {
+ if (!metaData) flags = NoMetaData;
+ if (entryPoint) md.SetEntryPoint(this);
+ this.nameIx = nameIx;
+ hashIx = md.AddToBlobHeap(hashBytes);
+ tabIx = MDTable.File;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return 4 + md.StringsIndexSize() + md.BlobIndexSize();
+ }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ md.AddToTable(MDTable.File,this);
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.Write(flags);
+ output.StringsIndex(nameIx);
+ output.BlobIndex(hashIx);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code)
+ {
+ switch (code) {
+ case (CIx.HasCustomAttr) : return 16;
+ case (CIx.Implementation) : return 0;
+ }
+ return 0;
+ }
+
+ }
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for pinvoke information for a method NOT YET IMPLEMENTED
+ /// </summary>
+ public class ImplMap : MetaDataElement {
+
+ private static readonly ushort NoMangle = 0x01;
+ ushort flags;
+ Method meth;
+ string importName;
+ uint iNameIx;
+ ModuleRef importScope;
+
+ internal ImplMap(ushort flag, Method implMeth, string iName, ModuleRef mScope)
+ {
+ flags = flag;
+ meth = implMeth;
+ importName = iName;
+ importScope = mScope;
+ tabIx = MDTable.ImplMap;
+ if (iName == null) flags |= NoMangle;
+ //throw(new NotYetImplementedException("PInvoke "));
+ }
+
+ internal override uint SortKey()
+ {
+ return (meth.Row << MetaData.CIxShiftMap[(uint)CIx.MemberForwarded])
+ | meth.GetCodedIx(CIx.MemberForwarded);
+ }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ if (done) return;
+ iNameIx = md.AddToStringsHeap(importName);
+ done = true;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return 2+ md.CodedIndexSize(CIx.MemberForwarded) +
+ md.StringsIndexSize() + md.TableIndexSize(MDTable.ModuleRef);
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.Write(flags);
+ output.WriteCodedIndex(CIx.MemberForwarded,meth);
+ output.StringsIndex(iNameIx);
+ output.WriteIndex(MDTable.ModuleRef,importScope.Row);
+ }
+
+ }
+
+ /**************************************************************************/
+
+ public class GenericParameter : MetaDataElement {
+
+ MetaDataElement owner;
+ MetaData metadata;
+ public string name;
+ uint nameIx;
+ short index;
+ GenericParamAttributes attr;
+
+ internal GenericParameter (ClassDef owner, MetaData metadata,
+ short index, string name, GenericParamAttributes attr) : this (owner, metadata, index, name, attr, true)
+ {
+ }
+
+ internal GenericParameter (MethodDef owner, MetaData metadata,
+ short index, string name, GenericParamAttributes attr) : this (owner, metadata, index, name, attr, true)
+ {
+ }
+
+ private GenericParameter (MetaDataElement owner, MetaData metadata,
+ short index, string name, GenericParamAttributes attr, bool nadda) {
+ this.owner = owner;
+ this.metadata = metadata;
+ this.index = index;
+ tabIx = MDTable.GenericParam;
+ this.name = name;
+ this.attr = attr;
+ }
+
+ internal override uint SortKey()
+ {
+ return (owner.Row << MetaData.CIxShiftMap[(uint)CIx.TypeOrMethodDef])
+ | owner.GetCodedIx(CIx.TypeOrMethodDef);
+ }
+
+ internal override uint SortKey2 ()
+ {
+ return (uint) index;
+ }
+
+ public void AddConstraint (Type constraint)
+ {
+ metadata.AddToTable (MDTable.GenericParamConstraint,
+ new GenericParamConstraint (this, constraint));
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return (uint) (4 +
+ md.CodedIndexSize(CIx.TypeOrMethodDef) +
+ md.StringsIndexSize ());
+ }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ if (done) return;
+ nameIx = md.AddToStringsHeap(name);
+ done = true;
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.Write ((short) index);
+ output.Write ((short) attr);
+ output.WriteCodedIndex(CIx.TypeOrMethodDef, owner);
+ output.StringsIndex (nameIx);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code)
+ {
+ switch (code) {
+ case (CIx.HasCustomAttr) : return 19;
+ }
+ return 0;
+ }
+
+ }
+
+ internal class GenericParamConstraint : MetaDataElement {
+
+ GenericParameter param;
+ Type type;
+
+ public GenericParamConstraint (GenericParameter param, Type type)
+ {
+ this.param = param;
+ this.type = type;
+ tabIx = MDTable.GenericParamConstraint;
+ }
+
+ internal override uint SortKey()
+ {
+ return param.Row;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return (uint) (md.TableIndexSize(MDTable.GenericParam) +
+ md.CodedIndexSize(CIx.TypeDefOrRef));
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.WriteIndex(MDTable.GenericParam, param.Row);
+ output.WriteCodedIndex(CIx.TypeDefOrRef, type);
+ }
+
+ }
+
+ internal class MethodSpec : Method {
+
+ Method meth;
+ GenericMethodSig g_sig;
+ uint sidx;
+
+ internal MethodSpec (Method meth, GenericMethodSig g_sig) : base ("")
+ {
+ this.meth = meth;
+ this.g_sig = g_sig;
+ tabIx = MDTable.MethodSpec;
+ }
+
+ internal override uint GetSigIx (MetaData md)
+ {
+ throw new Exception ("Should not be used.");
+ }
+
+ public override void AddCallConv (CallConv cconv)
+ {
+ throw new Exception ("Should not be used.");
+ }
+
+ internal sealed override void BuildTables (MetaData md)
+ {
+ if (done) return;
+ sidx = g_sig.GetSigIx (md);
+ done = true;
+ }
+
+ internal sealed override uint Size (MetaData md)
+ {
+ return (uint) (md.CodedIndexSize(CIx.MethodDefOrRef) +
+ md.BlobIndexSize ());
+ }
+
+ internal sealed override void Write (FileImage output)
+ {
+ output.WriteCodedIndex (CIx.MethodDefOrRef, meth);
+ output.BlobIndex (sidx);
+ }
+
+ internal sealed override void TypeSig (MemoryStream sig)
+ {
+ throw new Exception ("Should not be used.");
+ }
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for interface implemented by a class
+ /// </summary>
+ public class InterfaceImpl: MetaDataElement {
+
+ ClassDef theClass;
+ Class theInterface;
+
+ internal InterfaceImpl(ClassDef theClass, Class theInterface)
+ {
+ this.theClass = theClass;
+ this.theInterface = theInterface;
+ tabIx = MDTable.InterfaceImpl;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return md.TableIndexSize(MDTable.TypeDef) +
+ md.CodedIndexSize(CIx.TypeDefOrRef);
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.WriteIndex(MDTable.TypeDef,theClass.Row);
+ output.WriteCodedIndex(CIx.TypeDefOrRef,theInterface);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code) { return 5; }
+
+ internal override uint SortKey ()
+ {
+ return (theClass.Row << MetaData.CIxShiftMap[(uint)CIx.TypeDefOrRef])
+ | theClass.GetCodedIx (CIx.TypeDefOrRef);
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for resources used in this PE file
+ /// </summary>
+
+ public class ManifestResource : MetaDataElement {
+
+ public static readonly uint PublicResource = 0x1;
+ public static readonly uint PrivateResource = 0x2;
+
+ string mrName;
+ MetaDataElement rRef;
+ uint fileOffset;
+ uint nameIx = 0;
+ uint flags = 0;
+ byte [] resourceBytes;
+
+ public ManifestResource (string name, byte[] resBytes, uint flags)
+ {
+ InitResource (name, flags);
+ this.resourceBytes = resBytes;
+ }
+
+ public ManifestResource(string name, uint flags, FileRef fileRef)
+ {
+ InitResource (name, flags);
+ rRef = fileRef;
+ }
+
+ public ManifestResource(string name, uint flags, FileRef fileRef,
+ uint fileIx) {
+ InitResource (name, flags);
+ rRef = fileRef;
+ fileOffset = fileIx;
+ }
+
+ public ManifestResource(string name, uint flags, AssemblyRef assemRef)
+ {
+ InitResource (name, flags);
+ rRef = assemRef;
+ }
+
+ internal ManifestResource (ManifestResource mres)
+ {
+ mrName = mres.mrName;
+ flags = mres.flags;
+ rRef = mres.rRef;
+ fileOffset = mres.fileOffset;
+ resourceBytes = mres.resourceBytes;
+ }
+
+ private void InitResource (string name, uint flags)
+ {
+ mrName = name;
+ this.flags = flags;
+ tabIx = MDTable.ManifestResource;
+ }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ if (done) return;
+ md.AddToTable (MDTable.ManifestResource, this);
+ nameIx = md.AddToStringsHeap(mrName);
+ if (resourceBytes != null) {
+ if (rRef != null)
+ throw new PEFileException ("Manifest Resource has byte value and file reference");
+ fileOffset = md.AddResource(resourceBytes);
+ } else {
+ if (rRef == null)
+ throw new PEFileException ("Manifest Resource has no implementation or value");
+ rRef.BuildTables (md);
+ }
+
+ done = true;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return 8 + md.StringsIndexSize() +
+ md.CodedIndexSize(CIx.Implementation);
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.Write(fileOffset);
+ output.Write(flags);
+ output.StringsIndex(nameIx);
+ output.WriteCodedIndex(CIx.Implementation,rRef);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code) { return 18; }
+
+ public string Name {
+ get { return mrName; }
+ set { mrName = value; }
+ }
+
+ }
+ /**************************************************************************/
+ /// <summary>
+ /// Base class for elements in the PropertyMap, EventMap and
+ /// NestedClass MetaData tables
+ /// </summary>
+ public class MapElem : MetaDataElement {
+
+ ClassDef parent;
+ uint elemIx;
+ MDTable elemTable;
+
+ internal MapElem(ClassDef par, uint elIx, MDTable elemTab)
+ {
+ parent = par;
+ elemIx = elIx;
+ elemTable = elemTab;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return md.TableIndexSize(MDTable.TypeDef) + md.TableIndexSize(elemTable);
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.WriteIndex(MDTable.TypeDef,parent.Row);
+ output.WriteIndex(elemTable,elemIx);
+ }
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for an overriding method (.override)
+ /// </summary>
+ public class MethodImpl : MetaDataElement {
+
+ ClassDef parent;
+ Method header, body;
+
+ internal MethodImpl(ClassDef par, Method decl, Method bod)
+ {
+ parent = par;
+ header = decl;
+ body = bod;
+ tabIx = MDTable.MethodImpl;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return md.TableIndexSize(MDTable.TypeDef) + 2 * md.CodedIndexSize(CIx.MethodDefOrRef);
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.WriteIndex(MDTable.TypeDef,parent.Row);
+ output.WriteCodedIndex(CIx.MethodDefOrRef,body);
+ output.WriteCodedIndex(CIx.MethodDefOrRef,header);
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for Property and Event methods
+ /// </summary>
+ public class MethodSemantics : MetaDataElement {
+
+ Feature.MethodType type;
+ MethodDef meth;
+ Feature eventOrProp;
+
+ internal MethodSemantics(Feature.MethodType mType, MethodDef method, Feature feature)
+ {
+ type = mType;
+ meth = method;
+ eventOrProp = feature;
+ tabIx = MDTable.MethodSemantics;
+ }
+
+ internal override uint SortKey()
+ {
+ return (eventOrProp.Row << MetaData.CIxShiftMap [(uint)CIx.HasSemantics])
+ | eventOrProp.GetCodedIx (CIx.HasSemantics);
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return 2 + md.TableIndexSize(MDTable.Method) + md.CodedIndexSize(CIx.HasSemantics);
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.Write((ushort)type);
+ output.WriteIndex(MDTable.Method,meth.Row);
+ output.WriteCodedIndex(CIx.HasSemantics,eventOrProp);
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for a parameter of a method defined in this assembly/module
+ /// </summary>
+ public class Param : MetaDataElement {
+
+
+ Type pType;
+ string pName;
+ internal ushort seqNo = 0;
+ ushort parMode;
+ ConstantElem defaultVal;
+ uint nameIx = 0;
+ FieldMarshal marshalInfo;
+
+ /// <summary>
+ /// Create a new parameter for a method
+ /// </summary>
+ /// <param name="mode">param mode (in, out, opt)</param>
+ /// <param name="parName">parameter name</param>
+ /// <param name="parType">parameter type</param>
+ public Param(ParamAttr mode, string parName, Type parType)
+ {
+ pName = parName;
+ pType = parType;
+ parMode = (ushort)mode;
+ tabIx = MDTable.Param;
+ }
+
+ /// <summary>
+ /// Add a default value to this parameter
+ /// </summary>
+ /// <param name="c">the default value for the parameter</param>
+ public void AddDefaultValue(Constant cVal)
+ {
+ defaultVal = new ConstantElem(this,cVal);
+ parMode |= (ushort) ParamAttr.HasDefault;
+ }
+
+ /// <summary>
+ /// Add marshalling information about this parameter
+ /// </summary>
+ public void AddMarshallInfo(NativeType marshallType)
+ {
+ parMode |= (ushort) ParamAttr.HasFieldMarshal;
+ marshalInfo = new FieldMarshal(this,marshallType);
+ }
+
+ internal Type GetParType() { return pType; }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ if (done) return;
+ nameIx = md.AddToStringsHeap(pName);
+ if (defaultVal != null) {
+ md.AddToTable(MDTable.Constant,defaultVal);
+ defaultVal.BuildTables(md);
+ }
+ if (marshalInfo != null) {
+ md.AddToTable(MDTable.FieldMarshal,marshalInfo);
+ marshalInfo.BuildTables(md);
+ }
+ done = true;
+ }
+
+ internal void TypeSig(MemoryStream str)
+ {
+ pType.TypeSig(str);
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return 4 + md.StringsIndexSize();
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.Write(parMode);
+ output.Write(seqNo);
+ output.StringsIndex(nameIx);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code)
+ {
+ switch (code) {
+ case (CIx.HasCustomAttr) : return 4;
+ case (CIx.HasConst) : return 1;
+ case (CIx.HasFieldMarshal) : return 1;
+ }
+ return 0;
+ }
+
+ }
+
+ /**************************************************************************/
+ public abstract class Signature : MetaDataElement {
+
+ protected uint sigIx;
+
+ internal Signature()
+ {
+ tabIx = MDTable.StandAloneSig;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return md.BlobIndexSize();
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.BlobIndex(sigIx);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code) { return (uint)tabIx; }
+
+ }
+
+ /**************************************************************************/
+ public class TypeSpec : MetaDataElement {
+ uint sigIx = 0;
+
+ internal TypeSpec(Type aType, MetaData md)
+ {
+ MemoryStream sig = new MemoryStream();
+ aType.TypeSig(sig);
+ sigIx = md.AddToBlobHeap(sig.ToArray());
+ tabIx = MDTable.TypeSpec;
+ }
+
+ internal sealed override uint GetCodedIx(CIx code)
+ {
+ switch (code) {
+ case (CIx.TypeDefOrRef) : return 2;
+ case (CIx.HasCustomAttr) : return 13;
+ case (CIx.MemberRefParent) : return 4;
+ }
+ return 0;
+ }
+
+ internal override uint Size(MetaData md)
+ {
+ return md.BlobIndexSize();
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ //Console.WriteLine("Writing the blob index for a TypeSpec");
+ output.BlobIndex(sigIx);
+ }
+ }
+
+
+ /**************************************************************************/
+ /// <summary>
+ /// Base class for all IL types
+ /// </summary>
+ public abstract class Type : MetaDataElement {
+ protected byte typeIndex;
+ protected TypeSpec typeSpec;
+
+ internal Type(byte tyIx) { typeIndex = tyIx; }
+
+ internal byte GetTypeIndex() { return typeIndex; }
+ internal void SetTypeIndex (byte b) { typeIndex = b; }
+
+ internal virtual MetaDataElement GetTypeSpec(MetaData md)
+ {
+ if (typeSpec == null) {
+ typeSpec = new TypeSpec(this,md);
+ md.AddToTable(MDTable.TypeSpec,typeSpec);
+ }
+ return typeSpec;
+ }
+
+ internal virtual void TypeSig(MemoryStream str)
+ {
+ throw(new TypeSignatureException(this.GetType().AssemblyQualifiedName +
+ " doesn't have a type signature!!"));
+ }
+ }
+
+ public class ClassRefInst : Type {
+
+ private Type type;
+ private bool is_value;
+
+ public ClassRefInst (Type type, bool is_value) : base (PrimitiveType.Class.GetTypeIndex ())
+ {
+ this.type = type;
+ this.is_value = is_value;
+ if (is_value)
+ typeIndex = PrimitiveType.ValueType.GetTypeIndex ();
+ tabIx = MDTable.TypeSpec;
+ }
+
+ internal sealed override void TypeSig(MemoryStream str)
+ {
+ type.TypeSig (str);
+ }
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// The base descriptor for a class
+ /// </summary>
+ public abstract class Class : Type {
+
+ protected int row = 0;
+ public string name, nameSpace;
+ protected uint nameIx, nameSpaceIx;
+ protected MetaData _metaData;
+ internal Class(string nameSpaceName, string className, MetaData md)
+ : base(PrimitiveType.Class.GetTypeIndex ())
+ {
+ nameSpace = nameSpaceName;
+ name = className;
+ nameIx = md.AddToStringsHeap(name);
+ nameSpaceIx = md.AddToStringsHeap(nameSpace);
+ _metaData = md;
+ }
+
+ internal Class(uint nsIx, uint nIx) : base(PrimitiveType.Class.GetTypeIndex ())
+ {
+ nameSpaceIx = nsIx;
+ nameIx = nIx;
+ }
+
+ internal Class (byte typeIndex) : base (typeIndex)
+ {
+ nameSpace = "Should not be used";
+ name = "Should not be used";
+ }
+
+ internal virtual uint TypeDefOrRefToken() { return 0; }
+
+ internal virtual void MakeValueClass(ValueClass vClass)
+ {
+ typeIndex = PrimitiveType.ValueType.GetTypeIndex ();
+ }
+
+ internal virtual string TypeName()
+ {
+ return (nameSpace + "." + name);
+ }
+
+ internal override MetaDataElement GetTypeSpec(MetaData md)
+ {
+ return this;
+ }
+ }
+
+ /**************************************************************************/
+ // This Class produces entries in the TypeDef table of the MetaData
+ // in the PE meta data.
+
+ // NOTE: Entry 0 in TypeDef table is always the pseudo class <module>
+ // which is the parent for functions and variables declared a module level
+
+ /// <summary>
+ /// The descriptor for a class defined in the IL (.class) in the current assembly/module
+ /// </summary>
+ ///
+ public class ClassDef : Class {
+
+ private static readonly byte ElementType_Class = 0x12;
+
+ Class superType;
+ ArrayList fields = new ArrayList();
+ ArrayList methods = new ArrayList();
+ ArrayList events;
+ ArrayList properties;
+ bool typeIndexChecked = true;
+ uint fieldIx = 0, methodIx = 0;
+ byte[] securityActions;
+ uint flags;
+ ClassLayout layout;
+ ClassDef parentClass;
+ MetaData metaData;
+
+ internal ClassDef(TypeAttr attrSet, string nsName, string name,
+ MetaData md) : base(nsName, name, md)
+ {
+ metaData = md;
+ if (! ((nsName == "" && name == "<Module>") || (nsName == "System" && name == "Object")) ) {
+ superType = metaData.mscorlib.GetSpecialSystemClass(PrimitiveType.Object);
+ }
+ flags = (uint)attrSet;
+ tabIx = MDTable.TypeDef;
+ }
+
+ internal void SetSuper(Class sClass)
+ {
+ superType = sClass;
+ if (! (sClass is GenericTypeInst))
+ typeIndexChecked = false;
+ }
+
+ internal override void MakeValueClass(ValueClass vClass)
+ {
+ if (vClass == ValueClass.Enum)
+ superType = metaData.mscorlib.EnumType();
+ else
+ superType = metaData.mscorlib.ValueType();
+
+ typeIndex = PrimitiveType.ValueType.GetTypeIndex ();
+ }
+
+ public void SpecialNoSuper()
+ {
+ superType = null;
+ }
+
+ /// <summary>
+ /// Add an attribute to this class
+ /// </summary>
+ /// <param name="ta">the attribute to be added</param>
+ public void AddAttribute(TypeAttr ta)
+ {
+ flags |= (uint)ta;
+ }
+
+ /// <summary>
+ /// Add an interface that is implemented by this class
+ /// </summary>
+ /// <param name="iFace">the interface that is implemented</param>
+ public void AddImplementedInterface(Class iFace)
+ {
+ metaData.AddToTable(MDTable.InterfaceImpl,new InterfaceImpl(this,iFace));
+ }
+
+ /// <summary>
+ /// Add a named generic type parameter
+ /// </summary>
+ public GenericParameter AddGenericParameter (short index, string name)
+ {
+ return AddGenericParameter (index, name, 0);
+ }
+
+ /// <summary>
+ /// Add a named generic type parameter with attributes
+ /// </summary>
+ public GenericParameter AddGenericParameter (short index, string name, GenericParamAttributes attr)
+ {
+ GenericParameter gp = new GenericParameter (this, metaData, index, name, attr);
+ metaData.AddToTable (MDTable.GenericParam, gp);
+ return gp;
+ }
+
+ /// <summary>
+ /// Add a field to this class
+ /// </summary>
+ /// <param name="name">field name</param>
+ /// <param name="fType">field type</param>
+ /// <returns>a descriptor for this new field</returns>
+ public FieldDef AddField(string name, Type fType)
+ {
+ FieldDef field = new FieldDef(name,fType);
+ fields.Add(field);
+ return field;
+ }
+
+ /// <summary>
+ /// Add a field to this class
+ /// </summary>
+ /// <param name="fAtts">attributes for this field</param>
+ /// <param name="name">field name</param>
+ /// <param name="fType">field type</param>
+ /// <returns>a descriptor for this new field</returns>
+ public FieldDef AddField(FieldAttr fAtts, string name, Type fType)
+ {
+ FieldDef field = new FieldDef(fAtts,name,fType);
+ fields.Add(field);
+ return field;
+ }
+
+ public void SetFieldOrder (ArrayList fields)
+ {
+ this.fields = fields;
+ }
+
+ /// <summary>
+ /// Add a method to this class
+ /// </summary>
+ /// <param name="name">method name</param>
+ /// <param name="retType">return type</param>
+ /// <param name="pars">parameters</param>
+ /// <returns>a descriptor for this new method</returns>
+ public MethodDef AddMethod(string name, Type retType, Param[] pars)
+ {
+ // Console.WriteLine("Adding method " + name + " to class " + this.name);
+ MethodDef meth = new MethodDef(metaData,name,retType, pars);
+ methods.Add(meth);
+ return meth;
+ }
+
+ /// <summary>
+ /// Add a method to this class
+ /// </summary>
+ /// <param name="mAtts">attributes for this method</param>
+ /// <param name="iAtts">implementation attributes for this method</param>
+ /// <param name="name">method name</param>
+ /// <param name="retType">return type</param>
+ /// <param name="pars">parameters</param>
+ /// <returns>a descriptor for this new method</returns>
+ public MethodDef AddMethod(MethAttr mAtts, ImplAttr iAtts, string name,
+ Type retType, Param[] pars) {
+ // Console.WriteLine("Adding method " + name + " to class " + this.name);
+ MethodDef meth = new MethodDef(metaData,mAtts,iAtts,name,retType,pars);
+ methods.Add(meth);
+ return meth;
+ }
+
+ /// <summary>
+ /// Add an event to this class
+ /// </summary>
+ /// <param name="name">event name</param>
+ /// <param name="eType">event type</param>
+ /// <returns>a descriptor for this new event</returns>
+ public Event AddEvent(string name, Type eType)
+ {
+ Event e = new Event(name,eType,this);
+ if (events == null) events = new ArrayList();
+ events.Add(e);
+ return e;
+ }
+
+ /// <summary>
+ /// Add a property to this class
+ /// </summary>
+ /// <param name="name">property name</param>
+ /// <param name="propType">property type</param>
+ /// <returns>a descriptor for this new property</returns>
+ public Property AddProperty(string name, Type retType, Type[] pars)
+ {
+ Property p = new Property(name, retType, pars, this);
+ if (properties == null) properties = new ArrayList();
+ properties.Add(p);
+ return p;
+ }
+
+ /// <summary>
+ /// Add a nested class to this class
+ /// </summary>
+ /// <param name="attrSet">attributes for this nested class</param>
+ /// <param name="nsName">nested name space name</param>
+ /// <param name="name">nested class name</param>
+ /// <returns>a descriptor for this new nested class</returns>
+ public ClassDef AddNestedClass(TypeAttr attrSet, string nsName,
+ string name) {
+ ClassDef nClass = new ClassDef(attrSet,"",name,metaData);
+ metaData.AddToTable(MDTable.TypeDef,nClass);
+ metaData.AddToTable(MDTable.NestedClass,new MapElem(nClass,Row,MDTable.TypeDef));
+ nClass.parentClass = this;
+ return (nClass);
+ }
+
+ public static bool IsValueType (Class type)
+ {
+ return IsValueType (type.nameSpace, type.name);
+ }
+
+ public static bool IsEnum (Class type)
+ {
+ return IsEnum (type.nameSpace, type.name);
+ }
+
+ public static bool IsValueType (string nsName, string name)
+ {
+ return (nsName == "System" && name == "ValueType");
+ }
+
+ public static bool IsEnum (string nsName, string name)
+ {
+ return (nsName == "System" && name == "Enum");
+ }
+
+ /// <summary>
+ /// Add a nested class to this class
+ /// </summary>
+ /// <param name="attrSet">attributes for this nested class</param>
+ /// <param name="nsName">nested name space name</param>
+ /// <param name="name">nested class name</param>
+ /// <param name="sType">super type of this nested class</param>
+ /// <returns>a descriptor for this new nested class</returns>
+ public ClassDef AddNestedClass(TypeAttr attrSet, string nsName,
+ string name, Class sType) {
+ ClassDef nClass = AddNestedClass (attrSet, nsName, name);
+ nClass.SetSuper(sType);
+ if (ClassDef.IsValueType (sType))
+ nClass.MakeValueClass (ValueClass.ValueType);
+ else
+ if (ClassDef.IsEnum (sType))
+ nClass.MakeValueClass (ValueClass.Enum);
+
+ if (ClassDef.IsValueType (sType) || ClassDef.IsEnum (sType))
+ nClass.SetTypeIndex (PrimitiveType.ValueType.GetTypeIndex ());
+
+ nClass.typeIndexChecked = true;
+ return (nClass);
+ }
+
+ /// <summary>
+ /// Add layout information for this class. This class must have the
+ /// sequential or explicit attribute.
+ /// </summary>
+ /// <param name="packSize">packing size (.pack)</param>
+ /// <param name="classSize">class size (.size)</param>
+ public void AddLayoutInfo (int packSize, int classSize)
+ {
+ layout = new ClassLayout(packSize,classSize,this);
+ }
+
+ /// <summary>
+ /// Use a method as the implementation for another method (.override)
+ /// </summary>
+ /// <param name="decl">the method to be overridden</param>
+ /// <param name="body">the implementation to be used</param>
+ public void AddMethodOverride(Method decl, Method body)
+ {
+ metaData.AddToTable(MDTable.MethodImpl,new MethodImpl(this,decl,body));
+ }
+
+ /// <summary>
+ /// Add security to this class NOT YET IMPLEMENTED
+ /// </summary>
+ /// <param name="permissionSet"></param>
+ public void AddSecurity(byte[] permissionSet)
+ {
+ throw(new NotYetImplementedException("Class security "));
+ //flags |= HasSecurity;
+ // securityActions = permissionSet;
+ }
+
+ //public void AddLineInfo(int row, int col) { }
+
+ internal void CheckTypeIndex()
+ {
+ if (typeIndexChecked) return;
+ if (superType is ClassDef)
+ ((ClassDef)superType).CheckTypeIndex();
+ typeIndex = superType.GetTypeIndex();
+ typeIndexChecked = true;
+ }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ if (done) return;
+ if ((flags & (uint)TypeAttr.Interface) != 0) { superType = null; }
+ // Console.WriteLine("Building tables for " + name);
+ if (layout != null) md.AddToTable(MDTable.ClassLayout,layout);
+ // Console.WriteLine("adding methods " + methods.Count);
+ methodIx = md.TableIndex(MDTable.Method);
+ for (int i=0; i < methods.Count; i++) {
+ md.AddToTable(MDTable.Method,(MetaDataElement)methods[i]);
+ ((MethodDef)methods[i]).BuildTables(md);
+ }
+ // Console.WriteLine("adding fields");
+ fieldIx = md.TableIndex(MDTable.Field);
+ for (int i=0; i < fields.Count; i++) {
+ md.AddToTable(MDTable.Field,(MetaDataElement)fields[i]);
+ ((FieldDef)fields[i]).BuildTables(md);
+ }
+ // Console.WriteLine("adding events and properties");
+ if (events != null) {
+ for (int i=0; i < events.Count; i++) {
+ md.AddToTable(MDTable.Event,(Event)events[i]);
+ ((Event)events[i]).BuildTables(md);
+ }
+ md.AddToTable(MDTable.EventMap,
+ new MapElem(this,((Event)events[0]).Row,MDTable.Event));
+ }
+ if (properties != null) {
+ for (int i=0; i < properties.Count; i++) {
+ md.AddToTable(MDTable.Property,(Property)properties[i]);
+ ((Property)properties[i]).BuildTables(md);
+ }
+ md.AddToTable(MDTable.PropertyMap,new MapElem(this,
+ ((Property)properties[0]).Row,MDTable.Property));
+ }
+ // Console.WriteLine("End of building tables");
+ done = true;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return 4 + 2 * md.StringsIndexSize() +
+ md.CodedIndexSize(CIx.TypeDefOrRef) +
+ md.TableIndexSize(MDTable.Field) +
+ md.TableIndexSize(MDTable.Method);
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.Write(flags);
+ output.StringsIndex(nameIx);
+ output.StringsIndex(nameSpaceIx);
+ //if (superType != null)
+ // Console.WriteLine("getting coded index for superType of " + name + " = " + superType.GetCodedIx(CIx.TypeDefOrRef));
+ output.WriteCodedIndex(CIx.TypeDefOrRef,superType);
+ output.WriteIndex(MDTable.Field,fieldIx);
+ output.WriteIndex(MDTable.Method,methodIx);
+ }
+
+ internal sealed override uint TypeDefOrRefToken()
+ {
+ uint cIx = Row;
+ cIx = cIx << 2;
+ return cIx;
+ }
+
+ internal sealed override void TypeSig(MemoryStream sig)
+ {
+ if (!typeIndexChecked) CheckTypeIndex();
+ sig.WriteByte(GetTypeIndex());
+ MetaData.CompressNum(TypeDefOrRefToken(),sig);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code)
+ {
+ switch (code) {
+ case (CIx.TypeDefOrRef) : return 0;
+ case (CIx.HasCustomAttr) : return 3;
+ case (CIx.HasDeclSecurity) : return 0;
+ case (CIx.TypeOrMethodDef) : return 0;
+ }
+ return 0;
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for a class/interface declared in another module of THIS
+ /// assembly, or in another assembly.
+ /// </summary>
+ public class ClassRef : Class, IExternRef, IResolutionScope {
+
+ protected IResolutionScope parent;
+ ExternClass externClass;
+ protected MetaData metaData;
+
+ internal ClassRef(string nsName, string name, MetaData md) : base(nsName, name, md)
+ {
+ metaData = md;
+ tabIx = MDTable.TypeRef;
+ }
+
+ /// <summary>
+ /// Add a method to this class
+ /// </summary>
+ /// <param name="name">method name</param>
+ /// <param name="retType">return type</param>
+ /// <param name="pars">parameter types</param>
+ /// <returns>a descriptor for this method</returns>
+ public MethodRef AddMethod(string name, Type retType, Type[] pars)
+ {
+ return AddMethod (name, retType, pars, 0);
+ }
+
+ /// <summary>
+ /// Add a method to this class
+ /// </summary>
+ /// <param name="name">method name</param>
+ /// <param name="retType">return type</param>
+ /// <param name="pars">parameter types</param>
+ /// <param name="gen_param_count">num of generic parameters</param>
+ /// <returns>a descriptor for this method</returns>
+ public MethodRef AddMethod (string name, Type retType, Type[] pars, int gen_param_count)
+ {
+ MethodRef meth = new MethodRef (this, name, retType, pars, false, null, gen_param_count);
+ metaData.AddToTable(MDTable.MemberRef,meth);
+ return meth;
+ }
+
+ /// <summary>
+ /// Add a method to this class
+ /// </summary>
+ /// <param name="name">method name</param>
+ /// <param name="retType">return type</param>
+ /// <param name="pars">parameter types</param>
+ /// <returns>a descriptor for this method</returns>
+ public MethodRef AddVarArgMethod(string name, Type retType,
+ Type[] pars, Type[] optPars)
+ {
+ MethodRef meth = new MethodRef(this,name,retType,pars,true,optPars, 0);
+ metaData.AddToTable(MDTable.MemberRef,meth);
+ return meth;
+ }
+
+ /// <summary>
+ /// Add a field to this class
+ /// </summary>
+ /// <param name="name">field name</param>
+ /// <param name="fType">field type</param>
+ /// <returns>a descriptor for this field</returns>
+ public FieldRef AddField(string name, Type fType)
+ {
+ FieldRef field = new FieldRef(this,name,fType);
+ metaData.AddToTable(MDTable.MemberRef,field);
+ return field;
+ }
+
+ public ClassRef AddClass (string nsName, string name)
+ {
+ ClassRef aClass = new ClassRef(nsName,name,metaData);
+ metaData.AddToTable(MDTable.TypeRef,aClass);
+ aClass.SetParent(this);
+ return aClass;
+ }
+
+ public ClassRef AddValueClass (string nsName, string name)
+ {
+ ClassRef aClass = AddClass (nsName, name);
+ aClass.MakeValueClass (ValueClass.ValueType);
+ return aClass;
+ }
+
+ internal void SetParent(IResolutionScope par)
+ {
+ parent = par;
+ }
+
+ internal override string TypeName()
+ {
+ if ((parent != null) && (parent is AssemblyRef))
+ return (nameSpace + "." + name + ", " + ((AssemblyRef)parent).TypeName());
+ else
+ return (nameSpace + name);
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return md.CodedIndexSize(CIx.ResolutionScope) + 2 *
+ md.StringsIndexSize();
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.WriteCodedIndex(CIx.ResolutionScope,(MetaDataElement) parent);
+ output.StringsIndex(nameIx);
+ output.StringsIndex(nameSpaceIx);
+ }
+
+ internal override sealed uint TypeDefOrRefToken()
+ {
+ uint cIx = Row;
+ cIx = (cIx << 2) | 0x1;
+ return cIx;
+ }
+
+ internal override void TypeSig(MemoryStream sig)
+ {
+ sig.WriteByte(GetTypeIndex());
+ MetaData.CompressNum(TypeDefOrRefToken(),sig);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code)
+ {
+ switch (code) {
+ case (CIx.TypeDefOrRef) : return 1;
+ case (CIx.HasCustomAttr) : return 2;
+ case (CIx.MemberRefParent) : return 1;
+ case (CIx.ResolutionScope) : return 3;
+ }
+ return 0;
+ }
+
+ }
+
+ /**************************************************************************/
+ public class ExternClassRef : ClassRef {
+
+ ExternClass externClass;
+
+ internal ExternClassRef(TypeAttr attrs, string nsName, string name,
+ FileRef declFile, MetaData md) : base(nsName,name,md)
+ {
+ externClass = new ExternClass(attrs,nameSpaceIx,nameIx,declFile);
+ metaData.AddToTable(MDTable.ExportedType,externClass);
+ }
+
+ internal ExternClassRef(string name, MetaData md) : base(null,name,md)
+ {
+ }
+
+ public ClassRef AddNestedClass(TypeAttr attrs, string name)
+ {
+ ExternClassRef nestedClass = new ExternClassRef(name,metaData);
+ externClass = new ExternClass(attrs,0,nameIx,this.externClass);
+ metaData.AddToTable(MDTable.ExportedType,externClass);
+ return nestedClass;
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for a class defined in another module of THIS assembly
+ /// and exported (.class extern)
+ /// </summary>
+
+ internal class ExternClass : Class {
+
+ MetaDataElement parent;
+ uint flags;
+
+ internal ExternClass(TypeAttr attr, uint nsIx, uint nIx,
+ MetaDataElement paren) : base(nsIx,nIx)
+ {
+ flags = (uint)attr;
+ parent = paren;
+ tabIx = MDTable.ExportedType;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return 8 + 2* md.StringsIndexSize() + md.CodedIndexSize(CIx.Implementation);
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.Write(flags);
+ output.Write(0);
+ output.StringsIndex(nameIx);
+ output.StringsIndex(nameSpaceIx);
+ output.WriteCodedIndex(CIx.Implementation,parent);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code)
+ {
+ switch (code) {
+ case (CIx.HasCustomAttr) : return 17;
+ case (CIx.Implementation) : return 2;
+ }
+ return 0;
+ }
+
+ }
+
+ public class GenParam : Class {
+
+ private int index;
+ private string param_name;
+ private uint sigIx = 0;
+
+ public GenParam (int index, string name, GenParamType ptype) : base ((byte) ptype)
+ {
+ this.index = index;
+ this.param_name = name;
+ tabIx = MDTable.TypeSpec;
+ }
+
+ public int Index {
+ get { return index; }
+ set { index = value; }
+ }
+
+ public string Name {
+ get { return param_name; }
+ set { param_name = value; }
+ }
+
+ public GenParamType Type {
+ get { return (GenParamType) GetTypeIndex (); }
+ }
+
+ internal sealed override void BuildTables (MetaData md)
+ {
+ if (done)
+ return;
+ MemoryStream str = new MemoryStream ();
+ TypeSig (str);
+ sigIx = md.AddToBlobHeap (str.ToArray ());
+
+ done = true;
+ }
+
+ internal sealed override void TypeSig(MemoryStream str)
+ {
+ if (index < 0)
+ throw new PEFileException (String.Format ("Unresolved {0} - {1}", (GenParamType) GetTypeIndex (), param_name));
+ str.WriteByte(typeIndex);
+ MetaData.CompressNum ((uint) index, str);
+ }
+
+ internal override uint Size(MetaData md)
+ {
+ return md.BlobIndexSize();
+ }
+
+ internal sealed override void Write (FileImage output)
+ {
+ output.BlobIndex (sigIx);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code)
+ {
+ switch (code) {
+ case (CIx.TypeDefOrRef) : return 2;
+ case (CIx.HasCustomAttr) : return 13;
+ case (CIx.MemberRefParent) : return 4;
+ }
+ return 0;
+ }
+ }
+
+ public class GenericTypeInst : Class {
+
+ private Type gen_type;
+ private Type[] gen_param;
+ bool inTable = false;
+ uint sigIx = 0;
+
+ public GenericTypeInst (Type gen_type, Type[] gen_param)
+ : base ((byte) PrimitiveType.GenericInst.GetTypeIndex ())
+ {
+ this.gen_type = gen_type;
+ this.gen_param = gen_param;
+ tabIx = MDTable.TypeSpec;
+ }
+
+ internal override MetaDataElement GetTypeSpec (MetaData md)
+ {
+ if (!inTable) {
+ md.AddToTable (MDTable.TypeSpec, this);
+ inTable = true;
+ }
+
+ return this;
+ }
+
+ internal sealed override void TypeSig(MemoryStream str)
+ {
+ str.WriteByte(typeIndex);
+ gen_type.TypeSig (str);
+ MetaData.CompressNum ((uint) gen_param.Length, str);
+ foreach (Type param in gen_param)
+ param.TypeSig (str);
+ }
+
+ internal sealed override void BuildTables (MetaData md)
+ {
+ if (done)
+ return;
+ MemoryStream str = new MemoryStream ();
+ TypeSig (str);
+ sigIx = md.AddToBlobHeap (str.ToArray ());
+
+ done = true;
+ }
+
+ internal sealed override uint Size (MetaData md)
+ {
+ return md.BlobIndexSize ();
+ }
+
+ internal sealed override void Write (FileImage output)
+ {
+ output.BlobIndex (sigIx);
+ }
+
+ internal sealed override uint GetCodedIx (CIx code)
+ {
+ switch (code) {
+ case (CIx.TypeDefOrRef): return 2;
+ case (CIx.MemberRefParent): return 4;
+ case (CIx.HasCustomAttr): return 13;
+ }
+ return 0;
+ }
+ }
+
+ public class GenericMethodSig {
+
+ private Type[] gen_param;
+ private bool done;
+ private uint sigIx = 0;
+
+ public GenericMethodSig (Type[] gen_param)
+ {
+ this.gen_param = gen_param;
+ done = false;
+ }
+
+ internal void TypeSig (MemoryStream str)
+ {
+ str.WriteByte (0x0A); /* GENERIC_INST */
+ MetaData.CompressNum ((uint) gen_param.Length, str);
+ foreach (Type param in gen_param)
+ param.TypeSig (str);
+ }
+
+ internal uint GetSigIx (MetaData md)
+ {
+ if (done)
+ return sigIx;
+
+ MemoryStream sig = new MemoryStream();
+ TypeSig (sig);
+ sigIx = md.AddToBlobHeap (sig.ToArray());
+ done = true;
+ return sigIx;
+ }
+ }
+
+ public class Sentinel : Type {
+
+ public Sentinel () : base (0x41) { }
+
+ internal sealed override void TypeSig(MemoryStream str)
+ {
+ str.WriteByte(typeIndex);
+ }
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for a FunctionPointer type
+ /// </summary>
+ ///
+ public class MethPtrType : Type {
+
+ bool varArgMeth;
+ Type retType;
+ Type [] parList;
+ Type [] optParList;
+ CallConv callConv;
+ uint numPars;
+ uint numOptPars;
+ uint sigIx = 0;
+
+ /// <summary>
+ /// Create a new function pointer type
+ /// </summary>
+ /// <param name="meth">the function to be referenced</param>
+ public MethPtrType (CallConv callconv, Type retType, Type[] pars,
+ bool varArgMeth, Type[] optPars) : base(0x1B)
+ {
+ this.retType = retType;
+ callConv = callconv;
+ parList = pars;
+ this.varArgMeth = varArgMeth;
+ if (parList != null) numPars = (uint)parList.Length;
+ if (varArgMeth) {
+ optParList = optPars;
+ if (optParList != null) numOptPars = (uint)optParList.Length;
+ callConv |= CallConv.Vararg;
+ }
+ tabIx = MDTable.TypeSpec;
+ }
+
+ internal sealed override void TypeSig(MemoryStream sig)
+ {
+ sig.WriteByte(typeIndex);
+ // Bootlegged from method ref
+ sig.WriteByte((byte)callConv);
+ MetaData.CompressNum (numPars + numOptPars, sig);
+ retType.TypeSig (sig);
+ for (int i=0; i < numPars; i++) {
+ parList[i].TypeSig (sig);
+ }
+ if (varArgMeth) {
+ sig.WriteByte (0x41); // Write the sentinel
+ for (int i=0; i < numOptPars; i++) {
+ optParList[i].TypeSig (sig);
+ }
+ }
+ }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ if (done) return;
+ MemoryStream sig = new MemoryStream();
+ TypeSig(sig);
+ sigIx = md.AddToBlobHeap(sig.ToArray());
+ done = true;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return md.BlobIndexSize();
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.BlobIndex(sigIx);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code) { return 0x1B; }
+
+ }
+
+ #region Array Types
+ /* Classes for Arrays */
+
+ /// <summary>
+ /// The IL Array type
+ /// </summary>
+ public abstract class Array : Type {
+
+ protected Type elemType;
+ protected MetaData metaData;
+ protected string cnameSpace, cname;
+
+ internal Array(Type eType, byte TypeId) : base(TypeId)
+ {
+ elemType = eType;
+ tabIx = MDTable.TypeSpec;
+ }
+ }
+
+ /// <summary>
+ /// Single dimensional array with zero lower bound
+ /// </summary>
+ public class ZeroBasedArray : Array {
+
+ /// <summary>
+ /// Create a new array - elementType[]
+ /// </summary>
+ /// <param name="elementType">the type of the array elements</param>
+ public ZeroBasedArray(Type elementType) : base (elementType, PrimitiveType.SZArray.GetTypeIndex ()) { }
+
+ internal sealed override void TypeSig(MemoryStream str)
+ {
+ str.WriteByte(typeIndex);
+ elemType.TypeSig(str);
+ }
+
+ }
+
+ /// <summary>
+ /// Multi dimensional array with explicit bounds
+ /// </summary>
+ public class BoundArray : Array {
+ int[] lowerBounds;
+ int[] sizes;
+ uint numDims;
+
+ /// <summary>
+ /// Create a new multi dimensional array type
+ /// eg. elemType[1..5,3..10,5,,] would be
+ /// new BoundArray(elemType,5,[1,3,0],[5,10,4])
+ /// </summary>
+ /// <param name="elementType">the type of the elements</param>
+ /// <param name="dimensions">the number of dimensions</param>
+ /// <param name="loBounds">lower bounds of dimensions</param>
+ /// <param name="sizes">sizes for the dimensions</param>
+ public BoundArray(Type elementType, uint dimensions, int[] loBounds,
+ int[] sizes) : base (elementType,0x14)
+ {
+ numDims = dimensions;
+ lowerBounds = loBounds;
+ this.sizes = sizes;
+ }
+
+ /// <summary>
+ /// Create a new multi dimensional array type
+ /// eg. elemType[5,10,20] would be new BoundArray(elemType,3,[5,10,20])
+ /// </summary>
+ /// <param name="elementType">the type of the elements</param>
+ /// <param name="dimensions">the number of dimensions</param>
+ /// <param name="size">the sizes of the dimensions</param>
+ public BoundArray(Type elementType, uint dimensions, int[] size)
+ : base (elementType,0x14)
+ {
+ numDims = dimensions;
+ sizes = size;
+ }
+
+ /// <summary>
+ /// Create a new multi dimensional array type
+ /// eg. elemType[,,] would be new BoundArray(elemType,3)
+ /// </summary>
+ /// <param name="elementType">the type of the elements</param>
+ /// <param name="dimensions">the number of dimensions</param>
+ public BoundArray(Type elementType, uint dimensions)
+ : base (elementType,0x14)
+ {
+ numDims = dimensions;
+ }
+
+ internal sealed override void TypeSig(MemoryStream str)
+ {
+ str.WriteByte(typeIndex);
+ elemType.TypeSig(str);
+ MetaData.CompressNum(numDims,str);
+ if ((sizes != null) && (sizes.Length > 0)) {
+
+ MetaData.CompressNum((uint)sizes.Length,str);
+ for (int i=0; i < sizes.Length; i++) {
+ MetaData.CompressNum((uint)sizes[i],str);
+ }
+ } else str.WriteByte(0);
+ if ((lowerBounds != null) && (lowerBounds.Length > 0)) {
+ MetaData.CompressNum((uint)lowerBounds.Length,str);
+ for (int i=0; i < lowerBounds.Length; i++) {
+ CompressSignedNum (lowerBounds[i],str);
+ }
+ } else str.WriteByte(0);
+ }
+ private void CompressSignedNum (int val, MemoryStream str)
+ {
+ uint uval = (uint) val;
+ byte sign = 0;
+ if (val < 0) {
+ val = -val;
+ sign = 1;
+ }
+
+ /* Map the signed number to an unsigned number in two ways.
+
+ fval: left-rotated 2's complement representation
+ sval: map the signed number to unsigned as follows: 0 -> 0, -1 -> 1, 1 -> 2, -2 -> 3, 2 -> 4, ....
+ the mapping is: x -> 2*|x| - signbit(x)
+ */
+ uint fval = (uval << 1) | sign;
+ int sval = (val << 1) - sign;
+
+ /* An overly clever transformation:
+
+ a. sval is used to determine the number of bytes in the compressed representation.
+ b. fval is truncated to the appropriate number of bits and output using the
+ normal unsigned-int compressor.
+
+ However, or certain values, the truncated fval doesn't carry enough information to round trip.
+
+ (fval & 0x3FFF) <= 0x7F => compressor emits 1 byte, not 2 => there is aliasing of values
+
+ So, we use full 4 bytes to encode such values.
+
+ LAMESPEC: The Microsoft implementation doesn't appear to handle this subtle case.
+ e.g., it ends up encoding -8192 as the byte 0x01, which decodes to -64
+ */
+ if (sval <= 0x7F)
+ MetaData.CompressNum (fval & 0x7F, str);
+ else if (sval <= 0x3FFF && (fval & 0x3FFF) > 0x7F)
+ MetaData.CompressNum (fval & 0x3FFF, str);
+ else if (sval <= 0x1FFFFFFF && (fval & 0x1FFFFFFF) > 0x3FFF)
+ MetaData.CompressNum (fval & 0x1FFFFFFF, str);
+ else
+ /* FIXME: number cannot be represented. Report a warning. */
+ // throw new Exception ("cannot represent signed value" + -val);
+ MetaData.CompressNum (fval, str);
+ }
+ }
+
+ #endregion
+
+
+ /* Empty interface for grouping TypeRef's possible ResolutionScope
+ namely : Module, ModuleRef, AssemblyRef and TypeRef */
+ public interface IResolutionScope {
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Base class for scopes (extended by Module, ModuleRef, Assembly, AssemblyRef)
+ /// </summary>
+ public abstract class ResolutionScope : MetaDataElement, IResolutionScope {
+
+ protected uint nameIx = 0;
+ protected MetaData metaData;
+ protected string name;
+
+ internal ResolutionScope(string name, MetaData md)
+ {
+ metaData = md;
+ this.name = name;
+ nameIx = md.AddToStringsHeap(name);
+ }
+
+ internal string GetName() { return name; }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for THIS assembly (.assembly)
+ /// </summary>
+ public class Assembly : ResolutionScope {
+
+ ushort majorVer, minorVer, buildNo, revisionNo;
+ uint flags;
+ uint hashAlgId;
+ uint keyIx = 0, cultIx = 0;
+ bool hasPublicKey = false;
+
+ internal Assembly(string name, MetaData md) : base(name,md)
+ {
+ tabIx = MDTable.Assembly;
+ }
+
+ /// <summary>
+ /// Add details about THIS assembly
+ /// </summary>
+ /// <param name="majVer">Major Version</param>
+ /// <param name="minVer">Minor Version</param>
+ /// <param name="bldNo">Build Number</param>
+ /// <param name="revNo">Revision Number</param>
+ /// <param name="key">Hash Key</param>
+ /// <param name="hash">Hash Algorithm</param>
+ /// <param name="cult">Culture</param>
+ public void AddAssemblyInfo(int majVer, int minVer, int bldNo, int revNo,
+ byte[] key, uint hash, string cult)
+ {
+ majorVer = (ushort)majVer;
+ minorVer = (ushort)minVer;
+ buildNo = (ushort)bldNo;
+ revisionNo = (ushort)revNo;
+ hashAlgId = hash;
+ hasPublicKey = (key != null);
+ keyIx = metaData.AddToBlobHeap(key);
+ cultIx = metaData.AddToStringsHeap(cult);
+ }
+
+ /// <summary>
+ /// Add an attribute to THIS assembly
+ /// </summary>
+ /// <param name="aa">assembly attribute</param>
+ public void AddAssemblyAttr(AssemAttr aa)
+ {
+ flags |= (uint)aa;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return 16 + md.BlobIndexSize() + 2 * md.StringsIndexSize();
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ // Console.WriteLine("Writing assembly element with nameIx of " + nameIx + " at file offset " + output.Seek(0,SeekOrigin.Current));
+ output.Write((uint)hashAlgId);
+ output.Write(majorVer);
+ output.Write(minorVer);
+ output.Write(buildNo);
+ output.Write(revisionNo);
+ output.Write(flags);
+ output.BlobIndex(keyIx);
+ output.StringsIndex(nameIx);
+ output.StringsIndex(cultIx);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code)
+ {
+ switch (code) {
+ case (CIx.HasCustomAttr) : return 14;
+ case (CIx.HasDeclSecurity) : return 2;
+ }
+ return 0;
+ }
+
+ internal bool HasPublicKey {
+ get { return hasPublicKey; }
+ }
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for THIS module
+ /// </summary>
+ public class Module : ResolutionScope, IExternRef {
+
+ Guid mvid;
+ uint mvidIx = 0;
+
+ internal Module(string name, MetaData md) : base(name,md)
+ {
+ mvid = Guid.NewGuid();
+ mvidIx = md.AddToGUIDHeap(mvid);
+ tabIx = MDTable.Module;
+ }
+
+ public Guid Guid {
+ get { return mvid; }
+ }
+
+ public ClassRef AddClass(string nsName, string name)
+ {
+ ClassRef aClass = new ClassRef (nsName, name, metaData);
+ metaData.AddToTable (MDTable.TypeRef, aClass);
+ aClass.SetParent (this);
+ return aClass;
+ }
+
+ public ClassRef AddValueClass(string nsName, string name)
+ {
+ ClassRef aClass = AddClass (nsName, name);
+ aClass.MakeValueClass (ValueClass.ValueType);
+ return aClass;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return 2 + md.StringsIndexSize() + 3 * md.GUIDIndexSize();
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.Write((short)0);
+ output.StringsIndex(nameIx);
+ output.GUIDIndex(mvidIx);
+ output.GUIDIndex(0);
+ output.GUIDIndex(0);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code)
+ {
+ switch (code) {
+ case (CIx.HasCustomAttr) : return 7;
+ case (CIx.ResolutionScope) : return 0;
+ }
+ return 0;
+ }
+ }
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for another module in THIS assembly
+ /// </summary>
+ public class ModuleRef : ResolutionScope, IExternRef {
+
+ internal ModuleRef(MetaData md, string name) : base(name,md)
+ {
+ tabIx = MDTable.ModuleRef;
+ }
+
+ /// <summary>
+ /// Add a class to this external module. This is a class declared in
+ /// another module of THIS assembly.
+ /// </summary>
+ /// <param name="nsName">name space name</param>
+ /// <param name="name">class name</param>
+ /// <returns>a descriptor for this class in another module</returns>
+ public ClassRef AddClass(string nsName, string name)
+ {
+ ClassRef aClass = new ClassRef(nsName,name,metaData);
+ metaData.AddToTable(MDTable.TypeRef,aClass);
+ aClass.SetParent(this);
+ return aClass;
+ }
+
+ /// <summary>
+ /// Make a file descriptor to correspond to this module. The file
+ /// descriptor will have the same name as the module descriptor
+ /// </summary>
+ /// <param name="hashBytes">the hash of the file</param>
+ /// <param name="hasMetaData">the file contains metadata</param>
+ /// <param name="entryPoint">the program entry point is in this file</param>
+ /// <returns>a descriptor for the file which contains this module</returns>
+ public FileRef MakeFile(byte[] hashBytes, bool hasMetaData, bool entryPoint)
+ {
+ FileRef file = new FileRef(nameIx,hashBytes,hasMetaData,entryPoint,metaData);
+ metaData.AddToTable(MDTable.File,file);
+ return file;
+ }
+
+ /// <summary>
+ /// Add a value class to this module. This is a class declared in
+ /// another module of THIS assembly.
+ /// </summary>
+ /// <param name="nsName">name space name</param>
+ /// <param name="name">class name</param>
+ /// <returns></returns>
+ public ClassRef AddValueClass(string nsName, string name)
+ {
+ ClassRef aClass = new ClassRef(nsName,name,metaData);
+ metaData.AddToTable(MDTable.TypeRef,aClass);
+ aClass.SetParent(this);
+ aClass.MakeValueClass(ValueClass.ValueType);
+ return aClass;
+ }
+
+ /// <summary>
+ /// Add a class which is declared public in this external module of
+ /// THIS assembly. This class will be exported from this assembly.
+ /// The ilasm syntax for this is .extern class
+ /// </summary>
+ /// <param name="attrSet">attributes of the class to be exported</param>
+ /// <param name="nsName">name space name</param>
+ /// <param name="name">external class name</param>
+ /// <param name="declFile">the file where the class is declared</param>
+ /// <param name="isValueClass">is this class a value type?</param>
+ /// <returns>a descriptor for this external class</returns>
+ public ExternClassRef AddExternClass(TypeAttr attrSet, string nsName,
+ string name, FileRef declFile,
+ bool isValueClass) {
+ ExternClassRef cRef = new ExternClassRef(attrSet,nsName,name,declFile,metaData);
+ metaData.AddToTable(MDTable.TypeRef,cRef);
+ cRef.SetParent(this);
+ if (isValueClass) cRef.MakeValueClass(ValueClass.ValueType);
+ return cRef;
+ }
+
+ /// <summary>
+ /// Add a "global" method in another module
+ /// </summary>
+ /// <param name="name">method name</param>
+ /// <param name="retType">return type</param>
+ /// <param name="pars">method parameter types</param>
+ /// <returns>a descriptor for this method in anther module</returns>
+ public MethodRef AddMethod(string name, Type retType, Type[] pars)
+ {
+ MethodRef meth = new MethodRef(this,name,retType,pars,false,null, 0);
+ metaData.AddToTable(MDTable.MemberRef,meth);
+ return meth;
+ }
+
+ /// <summary>
+ /// Add a vararg method to this class
+ /// </summary>
+ /// <param name="name">method name</param>
+ /// <param name="retType">return type</param>
+ /// <param name="pars">parameter types</param>
+ /// <param name="optPars">optional param types for this vararg method</param>
+ /// <returns>a descriptor for this method</returns>
+ public MethodRef AddVarArgMethod(string name, Type retType,
+ Type[] pars, Type[] optPars) {
+ MethodRef meth = new MethodRef(this,name,retType,pars,true,optPars, 0);
+ metaData.AddToTable(MDTable.MemberRef,meth);
+ return meth;
+ }
+
+ /// <summary>
+ /// Add a field in another module
+ /// </summary>
+ /// <param name="name">field name</param>
+ /// <param name="fType">field type</param>
+ /// <returns>a descriptor for this field in another module</returns>
+ public FieldRef AddField(string name, Type fType)
+ {
+ FieldRef field = new FieldRef(this,name,fType);
+ metaData.AddToTable(MDTable.MemberRef,field);
+ return field;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return md.StringsIndexSize();
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.StringsIndex(nameIx);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code)
+ {
+ switch (code) {
+ case (CIx.HasCustomAttr) : return 12;
+ case (CIx.MemberRefParent) : return 2;
+ case (CIx.ResolutionScope) : return 1;
+ }
+ return 0;
+ }
+
+ }
+
+ #region Classes for Constants
+ /// <summary>
+ /// Descriptor for a constant value
+ /// </summary>
+ public abstract class Constant {
+ protected uint size = 0;
+ protected Type type;
+ protected uint blobIndex;
+ protected bool addedToBlobHeap = false;
+
+ internal Constant() { }
+
+ internal virtual uint GetBlobIndex(MetaData md) { return 0; }
+
+ internal uint GetSize() { return size; }
+
+ internal byte GetTypeIndex() { return type.GetTypeIndex(); }
+
+ internal virtual void Write(BinaryWriter bw) { }
+
+ }
+ /// <summary>
+ /// Descriptor for a constant value
+ /// </summary>
+ public abstract class DataConstant : Constant {
+ private uint dataOffset = 0;
+
+ internal DataConstant() { }
+
+ public uint DataOffset {
+ get { return dataOffset; }
+ set { dataOffset = value; }
+ }
+
+ }
+
+ /// <summary>
+ /// Boolean constant
+ /// </summary>
+ public class BoolConst : Constant {
+ bool val;
+
+ /// <summary>
+ /// Create a new boolean constant with the value "val"
+ /// </summary>
+ /// <param name="val">value of this boolean constant</param>
+ public BoolConst(bool val)
+ {
+ this.val = val;
+ size = 1;
+ type = PrimitiveType.Boolean;
+ }
+
+ internal sealed override uint GetBlobIndex(MetaData md)
+ {
+ if (!addedToBlobHeap) {
+ if (val) blobIndex = md.AddToBlobHeap((sbyte)1);
+ else blobIndex = md.AddToBlobHeap((sbyte)0);
+ addedToBlobHeap = true;
+ }
+ return blobIndex;
+ }
+
+ internal sealed override void Write(BinaryWriter bw)
+ {
+ if (val) bw.Write((sbyte)1);
+ else bw.Write((sbyte)0);
+ }
+
+ }
+
+ public class ByteArrConst : DataConstant {
+ byte[] val;
+
+ public ByteArrConst(byte[] val)
+ {
+ type = PrimitiveType.String;
+ this.val = val;
+ size = (uint)val.Length;
+ }
+
+ public Type Type {
+ get { return type; }
+ set { type = value; }
+ }
+
+ internal sealed override uint GetBlobIndex(MetaData md)
+ {
+ if (!addedToBlobHeap) {
+ blobIndex = md.AddToBlobHeap(val);
+ addedToBlobHeap = true;
+ }
+ return blobIndex;
+ }
+
+ internal sealed override void Write(BinaryWriter bw)
+ {
+ bw.Write(val);
+ }
+
+ }
+
+ public class CharConst : Constant {
+ char val;
+
+ public CharConst(char val)
+ {
+ this.val = val;
+ size = 2;
+ type = PrimitiveType.Char;
+ }
+
+ internal sealed override uint GetBlobIndex(MetaData md)
+ {
+ if (!addedToBlobHeap) {
+ blobIndex = md.AddToBlobHeap(val);
+ addedToBlobHeap = true;
+ }
+ return blobIndex;
+ }
+
+ internal sealed override void Write(BinaryWriter bw)
+ {
+ bw.Write(val);
+ }
+
+ }
+
+ public class FloatConst : DataConstant {
+ float val;
+
+ public FloatConst(float val)
+ {
+ this.val = val;
+ size = 4;
+ type = PrimitiveType.Float32;
+ }
+
+ internal sealed override uint GetBlobIndex(MetaData md)
+ {
+ if (!addedToBlobHeap) {
+ blobIndex = md.AddToBlobHeap(val);
+ addedToBlobHeap = true;
+ }
+ return blobIndex;
+ }
+
+ internal sealed override void Write(BinaryWriter bw)
+ {
+ bw.Write(val);
+ }
+
+ }
+
+ public class DoubleConst : DataConstant {
+ double val;
+
+ public DoubleConst(double val)
+ {
+ this.val = val;
+ size = 8;
+ type = PrimitiveType.Float64;
+ }
+
+ internal sealed override uint GetBlobIndex(MetaData md)
+ {
+ if (!addedToBlobHeap) {
+ blobIndex = md.AddToBlobHeap(val);
+ addedToBlobHeap = true;
+ }
+ return blobIndex;
+ }
+
+ internal sealed override void Write(BinaryWriter bw)
+ {
+ bw.Write(val);
+ }
+
+ }
+
+ public class IntConst : DataConstant {
+ long val;
+
+ public IntConst(sbyte val)
+ {
+ this.val = val;
+ size = 1;
+ type = PrimitiveType.Int8;
+ }
+
+ public IntConst(short val)
+ {
+ this.val = val;
+ size = 2;
+ type = PrimitiveType.Int16;
+ }
+
+ public IntConst(int val)
+ {
+ this.val = val;
+ size = 4;
+ type = PrimitiveType.Int32;
+ }
+
+ public IntConst(long val)
+ {
+ this.val = val;
+ size = 8;
+ type = PrimitiveType.Int64;
+ }
+
+ internal sealed override uint GetBlobIndex(MetaData md)
+ {
+ if (!addedToBlobHeap) {
+ switch (size) {
+ case (1) : blobIndex = md.AddToBlobHeap((sbyte)val); break;
+ case (2) : blobIndex = md.AddToBlobHeap((short)val); break;
+ case (4) : blobIndex = md.AddToBlobHeap((int)val); break;
+ default : blobIndex = md.AddToBlobHeap(val); break;
+ }
+ addedToBlobHeap = true;
+ }
+ return blobIndex;
+ }
+
+ internal sealed override void Write(BinaryWriter bw)
+ {
+ switch (size) {
+ case (1) : bw.Write((sbyte)val); break;
+ case (2) : bw.Write((short)val); break;
+ case (4) : bw.Write((int)val); break;
+ default : bw.Write(val); break;
+ }
+ }
+
+ }
+
+ public class UIntConst : Constant {
+ ulong val;
+
+ public UIntConst(byte val)
+ {
+ this.val = val;
+ size = 1;
+ type = PrimitiveType.UInt8;
+ }
+ public UIntConst(ushort val)
+ {
+ this.val = val;
+ size = 2;
+ type = PrimitiveType.UInt16;
+ }
+ public UIntConst(uint val)
+ {
+ this.val = val;
+ size = 4;
+ type = PrimitiveType.UInt32;
+ }
+ public UIntConst(ulong val)
+ {
+ this.val = val;
+ size = 8;
+ type = PrimitiveType.UInt64;
+ }
+
+ internal sealed override uint GetBlobIndex(MetaData md)
+ {
+ if (!addedToBlobHeap) {
+ switch (size) {
+ case (1) : blobIndex = md.AddToBlobHeap((byte)val); break;
+ case (2) : blobIndex = md.AddToBlobHeap((ushort)val); break;
+ case (4) : blobIndex = md.AddToBlobHeap((uint)val); break;
+ default : blobIndex = md.AddToBlobHeap(val); break;
+ }
+ addedToBlobHeap = true;
+ }
+ return blobIndex;
+ }
+
+ internal sealed override void Write(BinaryWriter bw)
+ {
+ switch (size) {
+ case (1) : bw.Write((byte)val); break;
+ case (2) : bw.Write((ushort)val); break;
+ case (4) : bw.Write((uint)val); break;
+ default : bw.Write(val); break;
+ }
+ }
+
+ }
+
+ public class StringConst : DataConstant {
+ string val;
+
+ public StringConst(string val)
+ {
+ this.val = val;
+ size = (uint)val.Length; // need to add null ??
+ type = PrimitiveType.String;
+ }
+
+ internal sealed override uint GetBlobIndex(MetaData md)
+ {
+ if (!addedToBlobHeap) {
+ byte [] b = Encoding.Unicode.GetBytes (val);
+ blobIndex = md.AddToBlobHeap(b);
+ addedToBlobHeap = true;
+ }
+ return blobIndex;
+ }
+
+ internal sealed override void Write(BinaryWriter bw)
+ {
+ bw.Write(val);
+ }
+
+ }
+
+ public class NullConst : Constant {
+
+ public NullConst()
+ {
+ size = 4;
+ type = PrimitiveType.Class;
+ }
+
+ internal sealed override uint GetBlobIndex(MetaData md)
+ {
+ if (!addedToBlobHeap) {
+ blobIndex = md.AddToBlobHeap((int)0);
+ addedToBlobHeap = true;
+ }
+ return blobIndex;
+ }
+
+ internal sealed override void Write(BinaryWriter bw)
+ {
+ bw.Write((int)0);
+ }
+
+ }
+
+ public class AddressConstant : DataConstant {
+ DataConstant data;
+
+ public AddressConstant(DataConstant dConst)
+ {
+ data = dConst;
+ size = 4;
+ type = PrimitiveType.TypedRef;
+ }
+
+ internal sealed override void Write(BinaryWriter bw)
+ {
+ ((FileImage)bw).WriteDataRVA(data.DataOffset);
+ }
+
+ }
+
+ public class RepeatedConstant : DataConstant {
+ DataConstant data;
+ uint repCount;
+
+ public RepeatedConstant(DataConstant dConst, int repeatCount)
+ {
+ data = dConst;
+ repCount = (uint)repeatCount;
+ int[] sizes = new int[1];
+ sizes[0] = repeatCount;
+ type = new BoundArray(type,1,sizes);
+ size = data.GetSize() * repCount;
+ }
+
+ internal sealed override void Write(BinaryWriter bw)
+ {
+ for (int i=0; i < repCount; i++) {
+ data.Write(bw);
+ }
+ }
+
+ }
+
+ public class ArrayConstant : DataConstant {
+ DataConstant[] dataVals;
+
+ public ArrayConstant(DataConstant[] dVals)
+ {
+ dataVals = dVals;
+ for (int i=0; i < dataVals.Length; i++) {
+ size += dataVals[i].GetSize();
+ }
+ }
+
+ internal sealed override void Write(BinaryWriter bw)
+ {
+ for (int i=0; i < dataVals.Length; i++) {
+ dataVals[i].Write(bw);
+ }
+ }
+
+ }
+
+ public class ClassType : Constant {
+ string name;
+ Class desc;
+
+ public ClassType(string className)
+ {
+ name = className;
+ type = PrimitiveType.ClassType;
+ }
+
+ public ClassType(Class classDesc)
+ {
+ desc = classDesc;
+ type = PrimitiveType.ClassType;
+ }
+
+ internal override void Write(BinaryWriter bw)
+ {
+ if (name == null) name = desc.TypeName();
+ bw.Write(name);
+ }
+
+ }
+
+ #endregion
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for a custom modifier of a type (modopt or modreq)
+ /// </summary>
+
+ public class CustomModifiedType : Type {
+
+ Type type;
+ Class cmodType;
+
+ /// <summary>
+ /// Create a new custom modifier for a type
+ /// </summary>
+ /// <param name="type">the type to be modified</param>
+ /// <param name="cmod">the modifier</param>
+ /// <param name="cmodType">the type reference to be associated with the type</param>
+ public CustomModifiedType(Type type, CustomModifier cmod, Class cmodType)
+ : base((byte)cmod)
+ {
+ this.type = type;
+ this.cmodType = cmodType;
+ }
+
+ internal sealed override void TypeSig(MemoryStream str)
+ {
+ str.WriteByte(typeIndex);
+ MetaData.CompressNum(cmodType.TypeDefOrRefToken(),str);
+ type.TypeSig(str);
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Base class for Event and Property descriptors
+ /// </summary>
+
+ public class Feature : MetaDataElement {
+
+ internal enum MethodType : ushort { Setter = 0x01, Getter, Other = 0x04, AddOn = 0x08,
+ RemoveOn = 0x10, Fire = 0x20 }
+
+ private static readonly int INITSIZE = 5;
+ private static readonly ushort specialName = 0x200;
+ private static readonly ushort rtSpecialName = 0x400;
+
+ protected ClassDef parent;
+ protected ushort flags = 0;
+ protected string name;
+ protected int tide = 0;
+ protected uint nameIx;
+ protected MethodSemantics[] methods = new MethodSemantics[INITSIZE];
+
+ internal Feature(string name, ClassDef par)
+ {
+ parent = par;
+ this.name = name;
+ }
+
+ internal void AddMethod(MethodDef meth, MethodType mType)
+ {
+ if (tide >= methods.Length) {
+ int len = methods.Length;
+ MethodSemantics[] mTmp = methods;
+ methods = new MethodSemantics[len * 2];
+ for (int i=0; i < len; i++) {
+ methods[i] = mTmp[i];
+ }
+ }
+ methods[tide++] = new MethodSemantics(mType,meth,this);
+ }
+
+ /// <summary>
+ /// Set the specialName attribute for this Event or Property
+ /// </summary>
+ public void SetSpecialName()
+ {
+ flags |= specialName;
+ }
+
+ /// <summary>
+ /// Set the RTSpecialName attribute for this Event or Property
+ /// </summary>
+ public void SetRTSpecialName()
+ {
+ flags |= rtSpecialName;
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for an event
+ /// </summary>
+ public class Event : Feature {
+
+ Type eventType;
+
+ internal Event(string name, Type eType, ClassDef parent)
+ : base(name, parent)
+ {
+ eventType = eType;
+ tabIx = MDTable.Event;
+ }
+
+ /// <summary>
+ /// Add the addon method to this event
+ /// </summary>
+ /// <param name="addon">the addon method</param>
+ public void AddAddon(MethodDef addon)
+ {
+ AddMethod(addon,MethodType.AddOn);
+ }
+
+ /// <summary>
+ /// Add the removeon method to this event
+ /// </summary>
+ /// <param name="removeOn">the removeon method</param>
+ public void AddRemoveOn(MethodDef removeOn)
+ {
+ AddMethod(removeOn,MethodType.RemoveOn);
+ }
+
+ /// <summary>
+ /// Add the fire method to this event
+ /// </summary>
+ /// <param name="fire">the fire method</param>
+ public void AddFire(MethodDef fire)
+ {
+ AddMethod(fire,MethodType.Fire);
+ }
+
+ /// <summary>
+ /// Add another method to this event
+ /// </summary>
+ /// <param name="other">the method to be added</param>
+ public void AddOther(MethodDef other)
+ {
+ AddMethod(other,MethodType.Other);
+ }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ if (done) return;
+ nameIx = md.AddToStringsHeap(name);
+ for (int i=0; i < tide; i++) {
+ md.AddToTable(MDTable.MethodSemantics,methods[i]);
+ }
+ done = true;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return 2 + md.StringsIndexSize() + md.CodedIndexSize(CIx.TypeDefOrRef);
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.Write(flags);
+ output.StringsIndex(nameIx);
+ output.WriteCodedIndex(CIx.TypeDefOrRef,eventType);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code)
+ {
+ switch (code) {
+ case (CIx.HasCustomAttr) : return 10;
+ case (CIx.HasSemantics) : return 0;
+ }
+ return 0;
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for the Property of a class
+ /// </summary>
+ public class Property : Feature {
+
+ private static readonly byte PropertyTag = 0x8;
+ private bool instance;
+ MethodDef getterMeth;
+ ConstantElem constVal;
+ uint typeBlobIx = 0;
+ Type[] parList;
+ Type returnType;
+ uint numPars = 0;
+
+ internal Property(string name, Type retType, Type[] pars, ClassDef parent) : base(name, parent)
+ {
+ returnType = retType;
+ parList = pars;
+ if (pars != null) numPars = (uint)pars.Length;
+ tabIx = MDTable.Property;
+ }
+
+ /// <summary>
+ /// Add a set method to this property
+ /// </summary>
+ /// <param name="setter">the set method</param>
+ public void AddSetter(MethodDef setter)
+ {
+ AddMethod(setter,MethodType.Setter);
+ }
+
+ /// <summary>
+ /// Add a get method to this property
+ /// </summary>
+ /// <param name="getter">the get method</param>
+ public void AddGetter(MethodDef getter)
+ {
+ AddMethod(getter,MethodType.Getter);
+ getterMeth = getter;
+ }
+
+ /// <summary>
+ /// Add another method to this property
+ /// </summary>
+ /// <param name="other">the method</param>
+ public void AddOther(MethodDef other)
+ {
+ AddMethod(other,MethodType.Other);
+ }
+
+ /// <summary>
+ /// Add an initial value for this property
+ /// </summary>
+ /// <param name="constVal">the initial value for this property</param>
+ public void AddInitValue(Constant constVal)
+ {
+ this.constVal = new ConstantElem(this,constVal);
+ }
+
+ public void SetInstance (bool isInstance)
+ {
+ this.instance = isInstance;
+ }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ if (done) return;
+ nameIx = md.AddToStringsHeap(name);
+ MemoryStream sig = new MemoryStream();
+ byte tag = PropertyTag;
+ if (instance)
+ tag |= 0x20;
+ sig.WriteByte(tag);
+ MetaData.CompressNum(numPars,sig);
+ returnType.TypeSig(sig);
+ for (int i=0; i < numPars; i++) {
+ parList[i].TypeSig(sig);
+ }
+ typeBlobIx = md.AddToBlobHeap(sig.ToArray());
+ for (int i=0; i < tide; i++) {
+ md.AddToTable(MDTable.MethodSemantics,methods[i]);
+ }
+ if (constVal != null) {
+ md.AddToTable(MDTable.Constant,constVal);
+ constVal.BuildTables(md);
+ }
+ done = true;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return 2 + md.StringsIndexSize() + md.BlobIndexSize();
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.Write(flags);
+ output.StringsIndex(nameIx);
+ output.BlobIndex(typeBlobIx);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code)
+ {
+ switch (code) {
+ case (CIx.HasCustomAttr) : return 9;
+ case (CIx.HasConst) : return 2;
+ case (CIx.HasSemantics) : return 1;
+ }
+ return 0;
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Base class for field/methods (member of a class)
+ /// </summary>
+ public abstract class Member : MetaDataElement {
+
+ protected string name;
+ protected uint nameIx = 0, sigIx = 0;
+
+ internal Member(string memName)
+ {
+ name = memName;
+ tabIx = MDTable.MemberRef;
+ }
+
+ }
+
+ /*****************************************************************************/
+ /// <summary>
+ /// Descriptor for a field of a class
+ /// </summary>
+
+ public abstract class Field : Member {
+
+ protected static readonly byte FieldSig = 0x6;
+
+ protected Type type;
+
+ internal Field(string pfName, Type pfType) : base(pfName)
+ {
+ type = pfType;
+ }
+
+ }
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for a field defined in a class of THIS assembly/module
+ /// </summary>
+ public class FieldDef : Field {
+
+ //private static readonly uint PInvokeImpl = 0x2000;
+ private static readonly ushort HasFieldRVA = 0x100;
+ private static readonly ushort HasDefault = 0x8000;
+
+ FieldRVA rva;
+ ConstantElem constVal;
+ FieldLayout layout;
+ FieldMarshal marshalInfo;
+ ushort flags;
+
+ internal FieldDef(string name, Type fType) : base(name,fType)
+ {
+ tabIx = MDTable.Field;
+ }
+
+ internal FieldDef(FieldAttr attrSet, string name, Type fType) : base(name, fType)
+ {
+ flags = (ushort)attrSet;
+ tabIx = MDTable.Field;
+ }
+
+ /// <summary>
+ /// Add an attribute(s) to this field
+ /// </summary>
+ /// <param name="fa">the attribute(s) to be added</param>
+ public void AddFieldAttr(FieldAttr fa)
+ {
+ flags |= (ushort)fa;
+ }
+
+ /// <summary>
+ /// Add a value for this field
+ /// </summary>
+ /// <param name="val">the value for the field</param>
+ public void AddValue(Constant val)
+ {
+ constVal = new ConstantElem(this,val);
+ flags |= HasDefault;
+ }
+
+ /// <summary>
+ /// Add an initial value for this field (at dataLabel) (.data)
+ /// </summary>
+ /// <param name="val">the value for the field</param>
+ /// <param name="repeatVal">the number of repetitions of this value</param>
+ public void AddDataValue(DataConstant val)
+ {
+ flags |= HasFieldRVA;
+ rva = new FieldRVA(this,val);
+ }
+
+ /// <summary>
+ /// Set the offset of the field. Used for sequential or explicit classes.
+ /// (.field [offs])
+ /// </summary>
+ /// <param name="offs">field offset</param>
+ public void SetOffset(uint offs)
+ {
+ layout = new FieldLayout(this,offs);
+ }
+
+ /// <summary>
+ /// Set the marshalling info for a field
+ /// </summary>
+ /// <param name="mInf"></param>
+ public void SetMarshalInfo(NativeType marshallType)
+ {
+ flags |= (ushort) FieldAttr.HasFieldMarshal;
+ marshalInfo = new FieldMarshal(this,marshallType);
+ }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ if (done) return;
+ nameIx = md.AddToStringsHeap(name);
+ MemoryStream sig = new MemoryStream();
+ sig.WriteByte(FieldSig);
+ type.TypeSig(sig);
+ sigIx = md.AddToBlobHeap(sig.ToArray());
+ if (rva != null) {
+ md.AddToTable(MDTable.FieldRVA,rva);
+ rva.BuildTables(md);
+ } else if (constVal != null) {
+ md.AddToTable(MDTable.Constant,constVal);
+ constVal.BuildTables(md);
+ }
+ if (layout != null) md.AddToTable(MDTable.FieldLayout,layout);
+ if (marshalInfo != null) {
+ md.AddToTable(MDTable.FieldMarshal,marshalInfo);
+ marshalInfo.BuildTables(md);
+ }
+ done = true;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return 2 + md.StringsIndexSize() + md.BlobIndexSize();
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.Write(flags);
+ output.StringsIndex(nameIx);
+ output.BlobIndex(sigIx);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code)
+ {
+ switch (code) {
+ case (CIx.HasConst) : return 0;
+ case (CIx.HasCustomAttr) : return 1;
+ case (CIx.HasFieldMarshal) : return 0;
+ case (CIx.MemberForwarded) : return 0;
+ }
+ return 0;
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for a field of a class defined in another assembly/module
+ /// </summary>
+ public class FieldRef : Field {
+
+ MetaDataElement parent;
+
+ internal FieldRef(MetaDataElement paren, string name, Type fType) : base(name, fType)
+ {
+ parent = paren;
+ }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ if (done) return;
+ nameIx = md.AddToStringsHeap(name);
+ MemoryStream sig = new MemoryStream();
+ sig.WriteByte(FieldSig);
+ type.TypeSig(sig);
+ sigIx = md.AddToBlobHeap(sig.ToArray());
+ done = true;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return md.CodedIndexSize(CIx.MemberRefParent) + md.StringsIndexSize() + md.BlobIndexSize();
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.WriteCodedIndex(CIx.MemberRefParent,parent);
+ output.StringsIndex(nameIx);
+ output.BlobIndex(sigIx);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code) { return 6; }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Base class for Method Descriptors
+ /// </summary>
+
+ public abstract class Method : Member {
+
+ internal Method (string methName) : base (methName)
+ {}
+
+ public abstract void AddCallConv(CallConv cconv);
+ internal abstract void TypeSig(MemoryStream sig);
+ internal abstract uint GetSigIx(MetaData md);
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for a method defined in THIS assembly/module
+ /// IL .method
+ /// </summary>
+
+ public class MethodDef : Method {
+
+ private static readonly ushort PInvokeImpl = 0x2000;
+ //private static readonly uint UnmanagedExport = 0x0008;
+ // private static readonly byte LocalSigByte = 0x7;
+ uint parIx = 0, textOffset = 0;
+ private CallConv callConv = CallConv.Default;
+ private Type retType;
+ private int gen_param_count;
+
+ MetaData metaData;
+ CILInstructions code;
+ ArrayList securityActions = new ArrayList();
+ Param[] parList;
+ Local[] locals;
+ bool initLocals;
+ ushort methFlags = 0, implFlags = 0;
+ int maxStack = 0, numPars = 0;
+ bool entryPoint = false;
+ LocalSig localSig;
+ ArrayList varArgSigList;
+ ImplMap pinvokeImpl;
+ Param ret_param;
+
+
+ internal MethodDef(MetaData md, string name, Type retType, Param[] pars) : base (name)
+ {
+ this.retType = retType;
+ metaData = md;
+ parList = pars;
+ if (parList != null) numPars = parList.Length;
+ tabIx = MDTable.Method;
+ }
+
+ internal MethodDef (MetaData md, MethAttr mAttrSet, ImplAttr iAttrSet, string name,
+ Type retType, Param [] pars) : this (md, name, retType, pars)
+ {
+ methFlags = (ushort)mAttrSet;
+ implFlags = (ushort)iAttrSet;
+ }
+
+ internal Param[] GetPars()
+ {
+ return parList;
+ }
+
+ internal override uint GetSigIx(MetaData md)
+ {
+ MemoryStream sig = new MemoryStream();
+ TypeSig(sig);
+ return md.AddToBlobHeap(sig.ToArray());
+ }
+
+ public override void AddCallConv(CallConv cconv)
+ {
+ callConv |= cconv;
+ }
+
+ /// <summary>
+ /// Add some attributes to this method descriptor
+ /// </summary>
+ /// <param name="ma">the attributes to be added</param>
+ public void AddMethAttribute(MethAttr ma)
+ {
+ methFlags |= (ushort)ma;
+ }
+
+ /// <summary>
+ /// Add some implementation attributes to this method descriptor
+ /// </summary>
+ /// <param name="ia">the attributes to be added</param>
+ public void AddImplAttribute(ImplAttr ia)
+ {
+ implFlags |= (ushort)ia;
+ }
+
+ public void AddPInvokeInfo(ModuleRef scope, string methName,
+ PInvokeAttr callAttr) {
+ pinvokeImpl = new ImplMap((ushort)callAttr,this,methName,scope);
+ methFlags |= PInvokeImpl;
+ }
+
+ /// <summary>
+ /// Add a named generic type parameter
+ /// </summary>
+ public GenericParameter AddGenericParameter (short index, string name)
+ {
+ return AddGenericParameter (index, name, 0);
+ }
+
+ /// <summary>
+ /// Add a named generic type parameter with attributes
+ /// </summary>
+ public GenericParameter AddGenericParameter (short index, string name, GenericParamAttributes attr)
+ {
+ GenericParameter gp = new GenericParameter (this, metaData, index, name, attr);
+ metaData.AddToTable (MDTable.GenericParam, gp);
+ gen_param_count ++;
+ return gp;
+ }
+
+ /// <summary>
+ /// Set the maximum stack height for this method
+ /// </summary>
+ /// <param name="maxStack">the maximum height of the stack</param>
+ public void SetMaxStack(int maxStack)
+ {
+ this.maxStack = maxStack;
+ }
+
+ /// <summary>
+ /// Add local variables to this method
+ /// </summary>
+ /// <param name="locals">the locals to be added</param>
+ /// <param name="initLocals">are locals initialised to default values</param>
+ public void AddLocals(Local[] locals, bool initLocals)
+ {
+ this.locals = locals;
+ this.initLocals = initLocals;
+ }
+
+ /* Add Marshal info for return type */
+ public void AddRetTypeMarshallInfo (NativeType marshallType)
+ {
+ ret_param = new Param (ParamAttr.HasFieldMarshal, "", retType);
+ ret_param.AddMarshallInfo (marshallType);
+ }
+
+ /// <summary>
+ /// Mark this method as having an entry point
+ /// </summary>
+ public void DeclareEntryPoint()
+ {
+ entryPoint = true;
+ }
+
+ /// <summary>
+ /// Create a code buffer for this method to add the IL instructions to
+ /// </summary>
+ /// <returns>a buffer for this method's IL instructions</returns>
+ public CILInstructions CreateCodeBuffer()
+ {
+ code = new CILInstructions(metaData);
+ return code;
+ }
+
+ /// <summary>
+ /// Make a method reference descriptor for this method to be used
+ /// as a callsite signature for this vararg method
+ /// </summary>
+ /// <param name="optPars">the optional pars for the vararg method call</param>
+ /// <returns></returns>
+ public MethodRef MakeVarArgSignature(Type[] optPars)
+ {
+ Type[] pars = new Type[numPars];
+ MethodRef varArgSig;
+ for (int i=0; i < numPars; i++) {
+ pars[i] = parList[i].GetParType();
+ }
+ varArgSig = new MethodRef(this,name,retType,pars,true,optPars, 0);
+
+ if (varArgSigList == null)
+ varArgSigList = new ArrayList ();
+ varArgSigList.Add (varArgSig);
+ return varArgSig;
+ }
+
+ internal sealed override void TypeSig(MemoryStream sig)
+ {
+ sig.WriteByte((byte)callConv);
+ if ((callConv & CallConv.Generic) == CallConv.Generic)
+ MetaData.CompressNum ((uint) gen_param_count, sig);
+ MetaData.CompressNum((uint)numPars,sig);
+ if (ret_param != null)
+ ret_param.seqNo = 0;
+ retType.TypeSig(sig);
+ for (ushort i=0; i < numPars; i++) {
+ parList[i].seqNo = (ushort)(i+1);
+ parList[i].TypeSig(sig);
+ }
+ }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ if (done) return;
+ if (pinvokeImpl != null) {
+ md.AddToTable(MDTable.ImplMap,pinvokeImpl);
+ pinvokeImpl.BuildTables(md);
+ }
+ if (entryPoint) md.SetEntryPoint(this);
+ uint locToken = 0;
+ if (locals != null) {
+ localSig = new LocalSig(locals);
+ md.AddToTable(MDTable.StandAloneSig,localSig);
+ localSig.BuildTables(md);
+ locToken = localSig.Token();
+ }
+ if (code != null) {
+ code.CheckCode(locToken,initLocals,maxStack);
+ textOffset = md.AddCode(code);
+ }
+ nameIx = md.AddToStringsHeap(name);
+ sigIx = GetSigIx(md);
+ parIx = md.TableIndex(MDTable.Param);
+ if (ret_param != null) {
+ md.AddToTable(MDTable.Param, ret_param);
+ ret_param.BuildTables(md);
+ }
+ for (int i=0; i < numPars; i++) {
+ md.AddToTable(MDTable.Param,parList[i]);
+ parList[i].BuildTables(md);
+ }
+ if (varArgSigList != null) {
+ foreach (MethodRef varArgSig in varArgSigList) {
+ md.AddToTable(MDTable.MemberRef,varArgSig);
+ varArgSig.BuildTables(md);
+ }
+ }
+ // Console.WriteLine("method has " + numPars + " parameters");
+ done = true;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return 8 + md.StringsIndexSize() + md.BlobIndexSize() + md.TableIndexSize(MDTable.Param);
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ if (ZeroRva ()) output.Write(0);
+ else output.WriteCodeRVA(textOffset);
+ output.Write(implFlags);
+ output.Write(methFlags);
+ output.StringsIndex(nameIx);
+ output.BlobIndex(sigIx);
+ output.WriteIndex(MDTable.Param,parIx);
+ }
+
+ internal bool ZeroRva ()
+ {
+ return (((methFlags & (ushort)MethAttr.Abstract) != 0) ||
+ ((implFlags & (ushort)ImplAttr.Runtime) != 0) ||
+ ((implFlags & (ushort)ImplAttr.InternalCall) != 0) ||
+ (pinvokeImpl != null)); // TODO: Not entirely true but works for now
+ }
+
+ internal sealed override uint GetCodedIx(CIx code)
+ {
+ switch (code) {
+ case (CIx.HasCustomAttr) : return 0;
+ case (CIx.HasDeclSecurity) : return 1;
+ case (CIx.MemberRefParent) : return 3;
+ case (CIx.MethodDefOrRef) : return 0;
+ case (CIx.MemberForwarded) : return 1;
+ case (CIx.CustomAttributeType) : return 2;
+ case (CIx.TypeOrMethodDef) : return 1;
+ }
+ return 0;
+ }
+
+ }
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for a method defined in another assembly/module
+ /// </summary>
+ public class MethodRef : Method {
+
+ private static readonly byte Sentinel = 0x41;
+ Type[] parList, optParList;
+ MetaDataElement parent;
+ uint numPars = 0, numOptPars = 0;
+ CallConv callConv = CallConv.Default;
+ Type retType;
+ int gen_param_count;
+
+ internal MethodRef(MetaDataElement paren, string name, Type retType,
+ Type[] pars, bool varArgMeth, Type[] optPars, int gen_param_count) : base(name)
+ {
+ parent = paren;
+ parList = pars;
+ this.retType = retType;
+ if (parList != null) numPars = (uint)parList.Length;
+ if (varArgMeth) {
+ optParList = optPars;
+ if (optParList != null) numOptPars = (uint)optParList.Length;
+ callConv = CallConv.Vararg;
+ }
+ this.gen_param_count = gen_param_count;
+ }
+
+ internal override uint GetSigIx(MetaData md)
+ {
+ MemoryStream sig = new MemoryStream();
+ TypeSig(sig);
+ return md.AddToBlobHeap(sig.ToArray());
+ }
+
+ public override void AddCallConv(CallConv cconv)
+ {
+ callConv |= cconv;
+ }
+
+ internal sealed override void TypeSig(MemoryStream sig)
+ {
+ sig.WriteByte((byte)callConv);
+ if ((callConv & CallConv.Generic) == CallConv.Generic)
+ MetaData.CompressNum ((uint) gen_param_count, sig);
+ MetaData.CompressNum(numPars+numOptPars,sig);
+ retType.TypeSig(sig);
+ for (int i=0; i < numPars; i++) {
+ parList[i].TypeSig(sig);
+ }
+ if (numOptPars > 0) {
+ sig.WriteByte(Sentinel);
+ for (int i=0; i < numOptPars; i++) {
+ optParList[i].TypeSig(sig);
+ }
+ }
+ }
+
+ internal sealed override void BuildTables(MetaData md)
+ {
+ if (done) return;
+ nameIx = md.AddToStringsHeap(name);
+ sigIx = GetSigIx(md);
+ done = true;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return md.CodedIndexSize(CIx.MemberRefParent) + md.StringsIndexSize() + md.BlobIndexSize();
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.WriteCodedIndex(CIx.MemberRefParent,parent);
+ output.StringsIndex(nameIx);
+ output.BlobIndex(sigIx);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code)
+ {
+ switch (code) {
+ case (CIx.HasCustomAttr) : return 6;
+ case (CIx.MethodDefOrRef) : return 1;
+ case (CIx.CustomAttributeType) : return 3;
+ }
+ return 0;
+ }
+
+ }
+
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptors for native types used for marshalling
+ /// </summary>
+ public class NativeType {
+ public static readonly NativeType Void = new NativeType(0x01);
+ public static readonly NativeType Boolean = new NativeType(0x02);
+ public static readonly NativeType Int8 = new NativeType(0x03);
+ public static readonly NativeType UInt8 = new NativeType(0x04);
+ public static readonly NativeType Int16 = new NativeType(0x05);
+ public static readonly NativeType UInt16 = new NativeType(0x06);
+ public static readonly NativeType Int32 = new NativeType(0x07);
+ public static readonly NativeType UInt32 = new NativeType(0x08);
+ public static readonly NativeType Int64 = new NativeType(0x09);
+ public static readonly NativeType UInt64 = new NativeType(0x0A);
+ public static readonly NativeType Float32 = new NativeType(0x0B);
+ public static readonly NativeType Float64 = new NativeType(0x0C);
+ public static readonly NativeType Currency = new NativeType(0x0F);
+ public static readonly NativeType BStr = new NativeType(0x13);
+ public static readonly NativeType LPStr = new NativeType(0x14);
+ public static readonly NativeType LPWStr = new NativeType(0x15);
+ public static readonly NativeType LPTStr = new NativeType(0x16);
+ public static readonly NativeType FixedSysString = new NativeType(0x17);
+ public static readonly NativeType IUnknown = new NativeType(0x19);
+ public static readonly NativeType IDispatch = new NativeType(0x1A);
+ public static readonly NativeType Struct = new NativeType(0x1B);
+ public static readonly NativeType Interface = new NativeType(0x1C);
+ public static readonly NativeType Int = new NativeType(0x1F);
+ public static readonly NativeType UInt = new NativeType(0x20);
+ public static readonly NativeType ByValStr = new NativeType(0x22);
+ public static readonly NativeType AnsiBStr = new NativeType(0x23);
+ public static readonly NativeType TBstr = new NativeType(0x24);
+ public static readonly NativeType VariantBool = new NativeType(0x25);
+ public static readonly NativeType FuncPtr = new NativeType(0x26);
+ public static readonly NativeType AsAny = new NativeType(0x28);
+
+ protected byte typeIndex;
+
+ internal NativeType(byte tyIx) { typeIndex = tyIx; }
+ internal byte GetTypeIndex() { return typeIndex; }
+
+ internal virtual byte[] ToBlob()
+ {
+ byte[] bytes = new byte[1];
+ bytes[0] = GetTypeIndex();
+ return bytes;
+ }
+
+ }
+
+ public class FixedSysString : NativeType {
+
+ uint size;
+
+ public FixedSysString (uint size) : base (NativeType.FixedSysString.GetTypeIndex ())
+ {
+ this.size = size;
+ }
+
+ internal override byte [] ToBlob ()
+ {
+ MemoryStream str = new MemoryStream ();
+ str.WriteByte (GetTypeIndex ());
+ MetaData.CompressNum (size, str);
+ return str.ToArray ();
+ }
+
+ }
+
+ public class NativeArray : NativeType {
+
+ NativeType elemType;
+ int numElem = -1, parNum = -1, elemMult = -1;
+
+ public NativeArray(NativeType elemType) : this (elemType, -1, -1, -1)
+ {
+ this.elemType = elemType;
+ }
+
+ /* public NativeArray(NativeType elemType, int len) : base(0x2A) {
+ this.elemType = elemType;
+ this.len = len;
+ }
+ */
+
+ public NativeArray(NativeType elemType, int numElem, int parNumForLen, int elemMult) : base(0x2A)
+ {
+ this.elemType = elemType;
+ this.numElem = numElem;
+ parNum = parNumForLen;
+ this.elemMult = elemMult;
+ }
+
+ public NativeArray(NativeType elemType, int numElem, int parNumForLen)
+ : this (elemType, numElem, parNumForLen, -1)
+ {
+ }
+
+ internal override byte[] ToBlob()
+ {
+ MemoryStream str = new MemoryStream();
+ str.WriteByte(GetTypeIndex());
+ if (elemType == null) str.WriteByte(0x50); // no info (MAX)
+ else str.WriteByte(elemType.GetTypeIndex());
+
+ /* see : mono/metadata/metadata.c:mono_metadata_parse_marshal_spec
+ * LAMESPEC: Older spec versions say elemMult comes before
+ * len. Newer spec versions don't talk about elemMult at
+ * all, but csc still emits it, and it is used to distinguish
+ * between parNum being 0, and parNum being omitted.
+ */
+
+ if (parNum == -1)
+ // <native_type> []
+ return str.ToArray ();
+
+ MetaData.CompressNum((uint) parNum,str);
+ if (numElem != -1) {
+ MetaData.CompressNum ((uint) numElem, str);
+ if (elemMult != -1)
+ // <native_type> [ int32 ]
+ MetaData.CompressNum((uint) elemMult,str);
+ //else <native_type> [ int32 + int32 ]
+ } else if (elemMult != -1) {
+ // When can this occur ?
+ MetaData.CompressNum (0, str);
+ MetaData.CompressNum((uint) elemMult,str);
+ }
+ //else <native_type> [ + int32 ]
+
+ return str.ToArray();
+ }
+
+ }
+
+ public class SafeArray : NativeType {
+
+ SafeArrayType elemType;
+ bool hasElemType;
+
+ public SafeArray() : base(0x1D)
+ {
+ }
+
+ public SafeArray(SafeArrayType elemType) : base(0x1D)
+ {
+ this.elemType = elemType;
+ hasElemType = true;
+ }
+
+ internal override byte[] ToBlob()
+ {
+ byte[] bytes = new byte[hasElemType ? 2 : 1];
+ bytes[0] = GetTypeIndex();
+ if (hasElemType)
+ bytes[1] = (byte)elemType;
+ return bytes;
+ }
+
+ }
+
+ public class FixedArray : NativeType {
+
+ NativeType elemType;
+ uint numElem;
+
+ //public FixedArray(NativeType elemType, int numElems) : base(0x1E) {
+ public FixedArray(int numElems) : base(0x1E)
+ {
+ //this.elemType = elemType;
+ numElem = (uint)numElems;
+ }
+
+ internal override byte[] ToBlob()
+ {
+ MemoryStream str = new MemoryStream();
+ str.WriteByte(GetTypeIndex());
+ MetaData.CompressNum(numElem,str);
+ /* FIXME:
+ fixed array [5] lpstr [2]
+ This format is not supported by ilasm 1.1.4322.2032,
+ but is supported by 2.0.5125..
+ ilasm 1.1 only supports "fixed array [5]"
+ if (elemType == null) str.WriteByte(0x50); // no info (MAX)
+ else str.WriteByte(elemType.GetTypeIndex());*/
+
+ return str.ToArray();
+ }
+
+ }
+
+ public class CustomMarshaller : NativeType {
+
+ string typeName;
+ string marshallerName;
+ string cookie;
+
+ public CustomMarshaller(string typeNameOrGUID, string marshallerName,
+ string optCookie) : base(0x2C)
+ {
+ typeName = typeNameOrGUID;
+ this.marshallerName = marshallerName;
+ cookie = optCookie;
+ }
+
+ public CustomMarshaller(string marshallerName, string optCookie)
+ :this (null, marshallerName, optCookie)
+ {
+ }
+
+ internal override byte[] ToBlob()
+ {
+ MemoryStream str = new MemoryStream();
+ BinaryWriter bw = new BinaryWriter(str,new UTF8Encoding());
+ bw.Write(GetTypeIndex());
+ //Native type name & unmanaged type - unused
+ //See mono/metadata/metadata.c : mono_metadata_parse_marshal_spec
+ bw.Write ((byte) 0); // Native Type name, unused
+ bw.Write ((byte) 0); // Unmanaged type, unused
+ if (marshallerName != null) {
+ MetaData.CompressNum ((uint)marshallerName.Length, str);
+ bw.Write(marshallerName.ToCharArray());
+ } else {
+ bw.Write ((byte) 0);
+ }
+ if (cookie != null) {
+ MetaData.CompressNum ((uint)cookie.Length, str);
+ bw.Write(cookie.ToCharArray());
+ } else {
+ bw.Write ((byte) 0);
+ }
+ bw.Flush();
+ return str.ToArray();
+ }
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for the Primitive types defined in IL
+ /// </summary>
+ public class PrimitiveType : Type {
+
+ private string name;
+ private int systemTypeIndex;
+ public static int NumSystemTypes = 18;
+
+ public static readonly PrimitiveType Void = new PrimitiveType(0x01,"Void",0);
+ public static readonly PrimitiveType Boolean = new PrimitiveType(0x02,"Boolean",1);
+ public static readonly PrimitiveType Char = new PrimitiveType(0x03,"Char",2);
+ public static readonly PrimitiveType Int8 = new PrimitiveType(0x04,"SByte",3);
+ public static readonly PrimitiveType UInt8 = new PrimitiveType(0x05,"Byte",4);
+ public static readonly PrimitiveType Int16 = new PrimitiveType(0x06,"Int16",5);
+ public static readonly PrimitiveType UInt16 = new PrimitiveType(0x07,"UInt16",6);
+ public static readonly PrimitiveType Int32 = new PrimitiveType(0x08,"Int32",7);
+ public static readonly PrimitiveType UInt32 = new PrimitiveType(0x09,"UInt32",8);
+ public static readonly PrimitiveType Int64 = new PrimitiveType(0x0A,"Int64",9);
+ public static readonly PrimitiveType UInt64 = new PrimitiveType(0x0B,"UInt64",10);
+ public static readonly PrimitiveType Float32 = new PrimitiveType(0x0C,"Single",11);
+ public static readonly PrimitiveType Float64 = new PrimitiveType(0x0D,"Double",12);
+ public static readonly PrimitiveType String = new PrimitiveType(0x0E,"String",13);
+ internal static readonly PrimitiveType Class = new PrimitiveType(0x12);
+ internal static readonly PrimitiveType Var = new PrimitiveType(0x13);
+ internal static readonly PrimitiveType GenericInst = new PrimitiveType(0x15);
+ public static readonly PrimitiveType TypedRef = new PrimitiveType(0x16,"TypedReference",14);
+ public static readonly PrimitiveType IntPtr = new PrimitiveType(0x18,"IntPtr",15);
+ public static readonly PrimitiveType UIntPtr = new PrimitiveType(0x19,"UIntPtr",16);
+ public static readonly PrimitiveType Object = new PrimitiveType(0x1C,"Object",17);
+ internal static readonly PrimitiveType ClassType = new PrimitiveType(0x50);
+ internal static readonly PrimitiveType SZArray = new PrimitiveType(0x1D);
+ internal static readonly PrimitiveType MVar = new PrimitiveType(0x1E);
+ internal static readonly PrimitiveType ValueType = new PrimitiveType(0x11, "ValueType", 18);
+ public static readonly PrimitiveType NativeInt = IntPtr;
+ public static readonly PrimitiveType NativeUInt = UIntPtr;
+
+ internal PrimitiveType(byte typeIx) : base(typeIx) { }
+
+ internal PrimitiveType(byte typeIx, string name, int STIx) : base(typeIx)
+ {
+ this.name = name;
+ this.systemTypeIndex = STIx;
+ }
+
+ internal string GetName() { return name; }
+
+ internal int GetSystemTypeIx() { return systemTypeIndex; }
+
+ internal sealed override void TypeSig(MemoryStream str)
+ {
+ str.WriteByte(typeIndex);
+ }
+
+ internal override MetaDataElement GetTypeSpec(MetaData md)
+ {
+ TypeSpec tS = md.GetPrimitiveTypeSpec(systemTypeIndex);
+ if (tS == null) {
+ tS = new TypeSpec(this,md);
+ md.SetPrimitiveTypeSpec(systemTypeIndex,tS);
+ md.AddToTable(MDTable.TypeSpec,tS);
+ }
+ return tS;
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for an pointer (type * or type &)
+ /// </summary>
+ public abstract class PtrType : Type {
+
+ Type baseType;
+
+ internal PtrType(Type bType, byte typeIx) : base(typeIx)
+ {
+ baseType = bType;
+ tabIx = MDTable.TypeSpec;
+ }
+
+ internal sealed override void TypeSig(MemoryStream str)
+ {
+ str.WriteByte(typeIndex);
+ baseType.TypeSig(str);
+ }
+
+ }
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for a managed pointer (type & or byref)
+ /// </summary>
+
+ public class ManagedPointer : PtrType {
+
+ /// <summary>
+ /// Create new managed pointer to baseType
+ /// </summary>
+ /// <param name="bType">the base type of the pointer</param>
+ public ManagedPointer(Type baseType) : base(baseType,0x10) { }
+
+ }
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for an unmanaged pointer (type *)
+ /// </summary>
+ public class UnmanagedPointer : PtrType {
+
+ /// <summary>
+ /// Create a new unmanaged pointer to baseType
+ /// </summary>
+ /// <param name="baseType">the base type of the pointer</param>
+ public UnmanagedPointer(Type baseType) : base(baseType, 0x0F) { }
+
+ }
+
+ /**************************************************************************/
+
+ public interface IExternRef {
+ ClassRef AddClass(string nsName, string name);
+ ClassRef AddValueClass(string nsName, string name);
+ }
+
+ /// <summary>
+ /// A reference to an external assembly (.assembly extern)
+ /// </summary>
+ public class AssemblyRef : ResolutionScope, IExternRef {
+
+ private ushort major, minor, build, revision;
+ uint flags, keyIx, hashIx, cultIx;
+ bool hasVersion = false, isKeyToken = false;
+ byte[] keyBytes;
+ string culture;
+
+ internal AssemblyRef(MetaData md, string name) : base(name,md)
+ {
+ tabIx = MDTable.AssemblyRef;
+ }
+
+ /// <summary>
+ /// Add version information about this external assembly
+ /// </summary>
+ /// <param name="majVer">Major Version</param>
+ /// <param name="minVer">Minor Version</param>
+ /// <param name="bldNo">Build Number</param>
+ /// <param name="revNo">Revision Number</param>
+ public void AddVersionInfo(int majVer, int minVer, int bldNo, int revNo)
+ {
+ major = (ushort)majVer;
+ minor = (ushort)minVer;
+ build = (ushort)bldNo;
+ revision = (ushort)revNo;
+ hasVersion = true;
+ }
+
+ /// <summary>
+ /// Add the hash value for this external assembly
+ /// </summary>
+ /// <param name="hash">bytes of the hash value</param>
+ public void AddHash(byte[] hash)
+ {
+ hashIx = metaData.AddToBlobHeap(hash);
+ }
+
+ /// <summary>
+ /// Set the culture for this external assembly
+ /// </summary>
+ /// <param name="cult">the culture string</param>
+ public void AddCulture(string cult)
+ {
+ cultIx = metaData.AddToStringsHeap(cult);
+ culture = cult;
+ }
+
+ /// <summary>
+ /// Add the full public key for this external assembly
+ /// </summary>
+ /// <param name="key">bytes of the public key</param>
+ public void AddKey(byte[] key)
+ {
+ flags |= 0x0001; // full public key
+ keyBytes = key;
+ keyIx = metaData.AddToBlobHeap(key);
+ }
+
+ /// <summary>
+ /// Add the public key token (low 8 bytes of the public key)
+ /// </summary>
+ /// <param name="key">low 8 bytes of public key</param>
+ public void AddKeyToken(byte[] key)
+ {
+ keyIx = metaData.AddToBlobHeap(key);
+ keyBytes = key;
+ isKeyToken = true;
+ }
+
+ /// <summary>
+ /// Add a class to this external assembly
+ /// </summary>
+ /// <param name="nsName">name space name</param>
+ /// <param name="name">class name</param>
+ /// <returns></returns>
+ public virtual ClassRef AddClass(string nsName, string name)
+ {
+ ClassRef aClass = new ClassRef(nsName,name,metaData);
+ metaData.AddToTable(MDTable.TypeRef,aClass);
+ aClass.SetParent(this);
+ return aClass;
+ }
+
+ /// <summary>
+ /// Add a value class to this external assembly
+ /// </summary>
+ /// <param name="nsName">name space name</param>
+ /// <param name="name">class name</param>
+ /// <returns></returns>
+ public virtual ClassRef AddValueClass(string nsName, string name)
+ {
+ ClassRef aClass = new ClassRef(nsName,name,metaData);
+ metaData.AddToTable(MDTable.TypeRef,aClass);
+ aClass.SetParent(this);
+ aClass.MakeValueClass(ValueClass.ValueType);
+ return aClass;
+ }
+
+ internal string TypeName()
+ {
+ string result = name;
+ if (hasVersion)
+ result = result + ", Version=" + major + "." + minor + "." +
+ build + "." + revision;
+ if (keyBytes != null) {
+ string tokenStr = "=";
+ if (isKeyToken) tokenStr = "Token=";
+ result = result + ", PublicKey" + tokenStr;
+ for (int i=0; i < keyBytes.Length; i++) {
+ result = result + Hex.Byte(keyBytes[i]);
+ }
+ }
+ if (culture != null)
+ result = result + ", Culture=" + culture;
+ return result;
+ }
+
+ internal sealed override uint Size(MetaData md)
+ {
+ return 12 + 2 * md.StringsIndexSize() + 2 * md.BlobIndexSize();
+ }
+
+ internal sealed override void Write(FileImage output)
+ {
+ output.Write(major);
+ output.Write(minor);
+ output.Write(build);
+ output.Write(revision);
+ output.Write(flags);
+ output.BlobIndex(keyIx);
+ output.StringsIndex(nameIx);
+ output.StringsIndex(cultIx);
+ output.BlobIndex(hashIx);
+ }
+
+ internal sealed override uint GetCodedIx(CIx code)
+ {
+ switch (code) {
+ case (CIx.ResolutionScope) : return 2;
+ case (CIx.HasCustomAttr) : return 15;
+ case (CIx.Implementation) : return 1;
+ }
+ return 0;
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for a class defined in System (mscorlib)
+ /// </summary>
+ internal class SystemClass : ClassRef {
+
+ PrimitiveType elemType;
+
+ internal SystemClass(PrimitiveType eType, AssemblyRef paren, MetaData md)
+ : base("System",eType.GetName(),md) {
+ elemType = eType;
+ parent = paren;
+ }
+
+ internal override sealed MetaDataElement GetTypeSpec(MetaData md)
+ {
+ if (typeSpec == null) typeSpec = (TypeSpec)elemType.GetTypeSpec(md);
+ return typeSpec;
+ }
+
+
+ internal sealed override void TypeSig(MemoryStream str)
+ {
+ str.WriteByte(elemType.GetTypeIndex());
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// The assembly for mscorlib.
+ /// </summary>
+ public sealed class MSCorLib : AssemblyRef {
+
+ private static readonly int valueTypeIx = 18;
+ private readonly string systemName = "System";
+ private Class[] systemClasses = new Class[valueTypeIx+2];
+ private PrimitiveType[] systemTypes = new PrimitiveType[valueTypeIx];
+ private TypeSpec[] specialTypeSpecs = new TypeSpec[valueTypeIx];
+ private static int[] specialNames = {
+ PrimitiveType.Void.GetName().GetHashCode(),
+ PrimitiveType.Boolean.GetName().GetHashCode(),
+ PrimitiveType.Char.GetName().GetHashCode(),
+ PrimitiveType.Int8.GetName().GetHashCode(),
+ PrimitiveType.UInt8.GetName().GetHashCode(),
+ PrimitiveType.Int16.GetName().GetHashCode(),
+ PrimitiveType.UInt16.GetName().GetHashCode(),
+ PrimitiveType.Int32.GetName().GetHashCode(),
+ PrimitiveType.UInt32.GetName().GetHashCode(),
+ PrimitiveType.Int64.GetName().GetHashCode(),
+ PrimitiveType.UInt64.GetName().GetHashCode(),
+ PrimitiveType.Float32.GetName().GetHashCode(),
+ PrimitiveType.Float64.GetName().GetHashCode(),
+ PrimitiveType.String.GetName().GetHashCode(),
+ PrimitiveType.TypedRef.GetName().GetHashCode(),
+ PrimitiveType.IntPtr.GetName().GetHashCode(),
+ PrimitiveType.UIntPtr.GetName().GetHashCode(),
+ PrimitiveType.Object.GetName().GetHashCode(),
+ PrimitiveType.ValueType.GetName ().GetHashCode(),
+ "Enum".GetHashCode()
+ };
+
+ internal MSCorLib(MetaData md) : base(md,"mscorlib")
+ {
+ if (!PEFile.IsMSCorlib)
+ md.AddToTable(MDTable.AssemblyRef,this);
+ systemTypes[PrimitiveType.Void.GetSystemTypeIx()] = PrimitiveType.Void;
+ systemTypes[PrimitiveType.Boolean.GetSystemTypeIx()] = PrimitiveType.Boolean;
+ systemTypes[PrimitiveType.Char.GetSystemTypeIx()] = PrimitiveType.Char;
+ systemTypes[PrimitiveType.Int8.GetSystemTypeIx()] = PrimitiveType.Int8;
+ systemTypes[PrimitiveType.UInt8.GetSystemTypeIx()] = PrimitiveType.UInt8;
+ systemTypes[PrimitiveType.Int16.GetSystemTypeIx()] = PrimitiveType.Int16;
+ systemTypes[PrimitiveType.UInt16.GetSystemTypeIx()] = PrimitiveType.UInt16;
+ systemTypes[PrimitiveType.Int32.GetSystemTypeIx()] = PrimitiveType.Int32;
+ systemTypes[PrimitiveType.UInt32.GetSystemTypeIx()] = PrimitiveType.UInt32;
+ systemTypes[PrimitiveType.Int64.GetSystemTypeIx()] = PrimitiveType.Int64;
+ systemTypes[PrimitiveType.UInt64.GetSystemTypeIx()] = PrimitiveType.UInt64;
+ systemTypes[PrimitiveType.Float32.GetSystemTypeIx()] = PrimitiveType.Float32;
+ systemTypes[PrimitiveType.Float64.GetSystemTypeIx()] = PrimitiveType.Float64;
+ systemTypes[PrimitiveType.IntPtr.GetSystemTypeIx()] = PrimitiveType.IntPtr;
+ systemTypes[PrimitiveType.UIntPtr.GetSystemTypeIx()] = PrimitiveType.UIntPtr;
+ systemTypes[PrimitiveType.String.GetSystemTypeIx()] = PrimitiveType.String;
+ systemTypes[PrimitiveType.Object.GetSystemTypeIx()] = PrimitiveType.Object;
+ systemTypes[PrimitiveType.TypedRef.GetSystemTypeIx()] = PrimitiveType.TypedRef;
+ }
+
+ /// <summary>
+ /// Add a class to the mscorlib assembly
+ /// </summary>
+ /// <param name="nsName">name space name</param>
+ /// <param name="name">class name</param>
+ /// <returns></returns>
+ public override ClassRef AddClass(string nsName, string name)
+ {
+ /* This gets called by !mscorlib, for adding references INTO mscorlib, so
+ it should be returning ClassRef ..*/
+ Class aClass = GetSpecialClass(nsName,name);
+ if (aClass == null) {
+ aClass = new ClassRef(nsName,name,metaData);
+ metaData.AddToTable(MDTable.TypeRef,aClass);
+ if (aClass is ClassRef)
+ ((ClassRef) aClass).SetParent(this);
+ }
+ //FIXME: Check for !ClassRef here?
+ return (ClassRef) aClass;
+ }
+
+ private Class GetSpecialClass(string nsName,string name)
+ {
+ if (nsName.CompareTo(systemName) != 0) return null;
+ int hash = name.GetHashCode();
+ for (int i=0; i < specialNames.Length; i++) {
+ if (hash != specialNames[i])
+ continue;
+ if (systemClasses[i] == null) {
+ if (i < valueTypeIx) {
+ systemClasses[i] = new SystemClass(systemTypes[i],this,metaData);
+ if ((systemTypes[i] != PrimitiveType.Object) &&
+ (systemTypes[i] != PrimitiveType.String)) {
+ systemClasses[i].MakeValueClass(ValueClass.ValueType);
+ }
+ } else {
+ systemClasses[i] = new ClassRef(nsName,name,metaData);
+ ((ClassRef) systemClasses[i]).SetParent(this);
+ if (!ClassDef.IsValueType (nsName, name) && !ClassDef.IsEnum (nsName, name))
+ systemClasses[i].MakeValueClass(ValueClass.ValueType);
+ }
+ metaData.AddToTable(MDTable.TypeRef,systemClasses[i]);
+ }
+ return systemClasses[i];
+ }
+ return null;
+ }
+
+ internal void SetSpecialSystemClass (string nsName, string name, Class aClass)
+ {
+ if (nsName != systemName) return;
+ int hash = name.GetHashCode ();
+ for (int i = 0; i < specialNames.Length; i++) {
+ if (hash != specialNames [i])
+ continue;
+ if (systemClasses [i] == null) {
+ systemClasses [i] = aClass;
+ }
+ }
+ }
+
+ internal Class GetSpecialSystemClass(PrimitiveType pType)
+ {
+ int ix = pType.GetSystemTypeIx();
+ if (systemClasses[ix] == null && !PEFile.IsMSCorlib) {
+ systemClasses[ix] = new SystemClass(pType,this,metaData);
+ metaData.AddToTable(MDTable.TypeRef,systemClasses[ix]);
+ }
+ return systemClasses[ix];
+ }
+
+ private ClassRef GetValueClass(string name, int hash)
+ {
+ /* Called by MSCorLib.AddValueClass, which is called by
+ !mscorlib, for adding ref to value class INTO mscorlib,
+ so this should be classref */
+ int ix = valueTypeIx;
+ if (hash != specialNames[valueTypeIx]) ix++;
+ if (systemClasses[ix] == null) {
+ systemClasses[ix] = new ClassRef(systemName,name,metaData);
+ ((ClassRef) systemClasses[ix]).SetParent(this);
+ ((ClassRef) systemClasses[ix]).MakeValueClass(ValueClass.ValueType);
+ metaData.AddToTable(MDTable.TypeRef,systemClasses[ix]);
+ }
+ return (ClassRef) systemClasses[ix];
+ }
+
+ internal Class ValueType()
+ {
+ if (systemClasses[valueTypeIx] == null && !PEFile.IsMSCorlib) {
+ ClassRef valType = new ClassRef("System","ValueType",metaData);
+ valType.SetParent(this);
+ valType.MakeValueClass(ValueClass.ValueType);
+ metaData.AddToTable(MDTable.TypeRef,valType);
+ systemClasses[valueTypeIx] = valType;
+ }
+ return systemClasses[valueTypeIx];
+ }
+
+ internal Class EnumType()
+ {
+ /* Called by both mscorlib & !mscorlib, so can be
+ either ClassRef or ClassDef */
+ //systemClasses [ valueTypeIx + 1] -> System.Enum
+ if (systemClasses[valueTypeIx + 1] == null && !PEFile.IsMSCorlib) {
+ ClassRef valType = new ClassRef("System","Enum",metaData);
+ valType.SetParent(this);
+ valType.MakeValueClass(ValueClass.Enum);
+ metaData.AddToTable(MDTable.TypeRef,valType);
+ systemClasses[valueTypeIx + 1] = valType;
+ }
+ return systemClasses[valueTypeIx + 1];
+ }
+
+ /// <summary>
+ /// Add a value class to this external assembly
+ /// </summary>
+ /// <param name="nsName">name space name</param>
+ /// <param name="name">class name</param>
+ /// <returns></returns>
+ public override ClassRef AddValueClass(string nsName, string name)
+ {
+ if (nsName.CompareTo(systemName) == 0) {
+ int hash = name.GetHashCode();
+ if ((hash == specialNames[valueTypeIx]) ||
+ (hash == specialNames[valueTypeIx+1])) {
+ return GetValueClass(name,hash);
+ }
+ }
+ ClassRef aClass = new ClassRef(nsName,name,metaData);
+ metaData.AddToTable(MDTable.TypeRef,aClass);
+ aClass.SetParent(this);
+ aClass.MakeValueClass(ValueClass.ValueType);
+ return aClass;
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// MetaData
+ /// Root (20 bytes + UTF-8 Version String + quad align padding)
+ /// StreamHeaders (8 bytes + null terminated name string + quad align padding)
+ /// Streams
+ /// #~ (always present - holds metadata tables)
+ /// #Strings (always present - holds identifier strings)
+ /// #US (Userstring heap)
+ /// #Blob (signature blobs)
+ /// #GUID (guids for assemblies or Modules)
+ /// </summary>
+ public class MetaData {
+
+ internal static readonly int[] CIxShiftMap = {2,2,5,1,2,3,1,1,1,2,3,2,1};
+ private static readonly byte StringsHeapMask = 0x1;
+ private static readonly byte GUIDHeapMask = 0x2;
+ private static readonly byte BlobHeapMask = 0x4;
+ private static readonly uint MetaDataSignature = 0x424A5342;
+ private static readonly uint maxSmlIxSize = 0xFFFF;
+ private static readonly uint max1BitSmlIx = 0x7FFF;
+ private static readonly uint max2BitSmlIx = 0x3FFF;
+ private static readonly uint max3BitSmlIx = 0x1FFF;
+ private static readonly uint max5BitSmlIx = 0x7FF;
+ // NOTE: version and stream name strings MUST always be quad padded
+#if NET_2_0 || BOOTSTRAP_NET_2_0
+ private static readonly string version = "v2.0.50727\0\0";
+#else
+ private static readonly string version = "v1.1.4322\0\0\0";
+#endif
+ private static readonly char[] tildeName = {'#','~','\0','\0'};
+ private static readonly char[] stringsName = {'#','S','t','r','i','n','g','s','\0','\0','\0','\0'};
+ private static readonly char[] usName = {'#','U','S','\0'};
+ private static readonly char[] guidName = {'#','G','U','I','D','\0','\0','\0'};
+ private static readonly char[] blobName = {'#','B','l','o','b','\0','\0','\0'};
+ private static readonly uint MetaDataHeaderSize = 20 + (uint)version.Length;
+ private static readonly uint TildeHeaderSize = 24;
+ private static readonly uint StreamHeaderSize = 8;
+ private static readonly uint numMetaDataTables = (int)MDTable.GenericParamConstraint + 1;
+ private static readonly uint tildeHeaderSize = 8 + (uint)tildeName.Length;
+
+ MetaDataStream strings, us, guid, blob;
+
+ MetaDataStream[] streams = new MetaDataStream[5];
+ uint numStreams = 5;
+ uint tildeTide = 0, tildePadding = 0, tildeStart = 0;
+ uint numTables = 0, resourcesSize = 0;
+ ArrayList[] metaDataTables = new ArrayList[numMetaDataTables];
+ ArrayList byteCodes = new ArrayList();
+ uint codeSize = 0, codeStart, byteCodePadding = 0, metaDataSize = 0;
+ ulong valid = 0, /*sorted = 0x000002003301FA00;*/ sorted = 0;
+ bool[] largeIx = new bool[numMetaDataTables];
+ bool[] lgeCIx = new bool[(int)CIx.MaxCIx];
+ bool largeStrings = false, largeUS = false, largeGUID = false, largeBlob = false;
+ private FileImage file;
+ private byte heapSizes = 0;
+ MetaDataElement entryPoint;
+ BinaryWriter output;
+ public MSCorLib mscorlib;
+ private TypeSpec[] systemTypeSpecs = new TypeSpec[PrimitiveType.NumSystemTypes];
+ long mdStart;
+ private ArrayList cattr_list;
+ private ArrayList declsec_list;
+ ArrayList resources;
+
+ internal MetaData(FileImage file)
+ {
+ // tilde = new MetaDataStream(tildeName,false,0);
+ this.file = file;
+ strings = new MetaDataStream(stringsName,new UTF8Encoding(),true);
+ us = new MetaDataStream(usName,new UnicodeEncoding(),true);
+ guid = new MetaDataStream(guidName,false);
+ blob = new MetaDataStream(blobName,true);
+ streams[1] = strings;
+ streams[2] = us;
+ streams[3] = guid;
+ streams[4] = blob;
+ for (int i=0; i < numMetaDataTables; i++) {
+ largeIx[i] = false;
+ }
+ for (int i=0; i < lgeCIx.Length; i++) {
+ lgeCIx[i] = false;
+ }
+ mscorlib = new MSCorLib(this);
+ }
+
+ internal TypeSpec GetPrimitiveTypeSpec(int ix)
+ {
+ return systemTypeSpecs[ix];
+ }
+
+ internal void SetPrimitiveTypeSpec(int ix, TypeSpec typeSpec)
+ {
+ systemTypeSpecs[ix] = typeSpec;
+ }
+
+ internal uint Size()
+ {
+ return metaDataSize;
+ }
+
+ private void CalcHeapSizes ()
+ {
+ if (strings.LargeIx()) {
+ largeStrings = true;
+ heapSizes |= StringsHeapMask;
+ }
+ if (guid.LargeIx()) {
+ largeGUID = true;
+ heapSizes |= GUIDHeapMask;
+ }
+ if (blob.LargeIx()) {
+ largeBlob = true;
+ heapSizes |= BlobHeapMask;
+ }
+
+ largeUS = us.LargeIx();
+ }
+
+ internal void StreamSize(byte mask)
+ {
+ heapSizes |= mask;
+ }
+
+ internal uint AddToUSHeap(string str)
+ {
+ if (str == null) return 0;
+ return us.Add(str,true);
+ }
+
+ internal uint AddToUSHeap(byte[] str)
+ {
+ if (str == null) return 0;
+ return us.Add (str, true);
+ }
+
+ internal uint AddToStringsHeap(string str)
+ {
+ if ((str == null) || (str.CompareTo("") == 0)) return 0;
+ return strings.Add(str,false);
+ }
+
+ internal uint AddToGUIDHeap(Guid guidNum)
+ {
+ return guid.Add(guidNum, false);
+ }
+
+ internal uint AddToBlobHeap(byte[] blobBytes)
+ {
+ if (blobBytes == null) return 0;
+ return blob.Add(blobBytes, true);
+ }
+
+ internal uint AddToBlobHeap(byte val)
+ {
+ return blob.Add(val, true);
+ }
+
+ internal uint AddToBlobHeap(sbyte val)
+ {
+ return blob.Add(val, true);
+ }
+
+ internal uint AddToBlobHeap(ushort val)
+ {
+ return blob.Add(val, true);
+ }
+
+ internal uint AddToBlobHeap(short val)
+ {
+ return blob.Add(val, true);
+ }
+
+ internal uint AddToBlobHeap(uint val)
+ {
+ return blob.Add(val, true);
+ }
+
+ internal uint AddToBlobHeap(int val)
+ {
+ return blob.Add(val, true);
+ }
+
+ internal uint AddToBlobHeap(ulong val)
+ {
+ return blob.Add(val, true);
+ }
+
+ internal uint AddToBlobHeap(long val)
+ {
+ return blob.Add(val, true);
+ }
+
+ internal uint AddToBlobHeap(float val)
+ {
+ return blob.Add(val, true);
+ }
+
+ internal uint AddToBlobHeap(double val)
+ {
+ return blob.Add(val, true);
+ }
+
+ internal uint AddToBlobHeap(string val)
+ {
+ return blob.Add(val,true);
+ }
+
+ internal void AddCustomAttribute (CustomAttribute cattr)
+ {
+ if (cattr_list == null)
+ cattr_list = new ArrayList ();
+ cattr_list.Add (cattr);
+ }
+
+ internal void AddDeclSecurity (DeclSecurity decl_sec)
+ {
+ if (declsec_list == null)
+ declsec_list = new ArrayList ();
+ declsec_list.Add (decl_sec);
+ }
+
+ private ArrayList GetTable(MDTable tableIx)
+ {
+ int tabIx = (int)tableIx;
+ if (metaDataTables[tabIx] == null) {
+ metaDataTables[tabIx] = new ArrayList();
+ valid |= ((ulong)0x1 << tabIx);
+ // Console.WriteLine("after creating table " + tableIx + "(" + tabIx + ") valid = " + valid);
+ numTables++;
+ }
+ return metaDataTables[tabIx];
+ }
+
+ internal void AddToTable(MDTable tableIx, MetaDataElement elem)
+ {
+ if (elem.Row > 0) {
+ // Console.Out.WriteLine("ERROR - element already in table " + tableIx);
+ return;
+ }
+ // updates Row field of the element
+ // Console.WriteLine("Adding element to table " + (uint)tableIx);
+ ArrayList table = GetTable(tableIx);
+ elem.Row = (uint)table.Count + 1;
+ table.Add(elem);
+ }
+
+ internal uint TableIndex(MDTable tableIx)
+ {
+ if (metaDataTables[(int)tableIx] == null) return 1;
+ return (uint)metaDataTables[(int)tableIx].Count+1;
+ }
+
+ internal uint AddCode(CILInstructions byteCode)
+ {
+ byteCodes.Add(byteCode);
+ uint offset = codeSize + codeStart;
+ codeSize += byteCode.GetCodeSize();
+ return offset;
+ }
+
+ internal void SetEntryPoint(MetaDataElement ep)
+ {
+ entryPoint = ep;
+ }
+
+ internal uint AddResource(byte[] resBytes)
+ {
+ if (resources == null) resources = new ArrayList ();
+ resources.Add (resBytes);
+ uint offset = resourcesSize;
+ resourcesSize += (uint)resBytes.Length + 4;
+ return offset;
+ }
+
+ internal void AddData(DataConstant cVal)
+ {
+ file.AddInitData(cVal);
+ }
+
+ internal static void CompressNum(uint val, MemoryStream sig)
+ {
+ if (val <= 0x7F) {
+ sig.WriteByte((byte)val);
+ } else if (val <= 0x3FFF) {
+ byte b1 = (byte)((val >> 8) | 0x80);
+ byte b2 = (byte)(val & FileImage.iByteMask[0]);
+ sig.WriteByte(b1);
+ sig.WriteByte(b2);
+ } else {
+ byte b1 = (byte)((val >> 24) | 0xC0);
+ byte b2 = (byte)((val & FileImage.iByteMask[2]) >> 16);
+ byte b3 = (byte)((val & FileImage.iByteMask[1]) >> 8);;
+ byte b4 = (byte)(val & FileImage.iByteMask[0]);
+ sig.WriteByte(b1);
+ sig.WriteByte(b2);
+ sig.WriteByte(b3);
+ sig.WriteByte(b4);
+ }
+ }
+
+ internal uint CodeSize()
+ {
+ return codeSize + byteCodePadding;
+ }
+
+ internal uint GetResourcesSize()
+ {
+ return resourcesSize;
+ }
+
+ internal uint StringsIndexSize()
+ {
+ if (largeStrings) return 4;
+ return 2;
+ }
+
+ internal uint GUIDIndexSize()
+ {
+ if (largeGUID) return 4;
+ return 2;
+ }
+
+ internal uint USIndexSize()
+ {
+ if (largeUS) return 4;
+ return 2;
+ }
+
+ internal uint BlobIndexSize()
+ {
+ if (largeBlob) return 4;
+ return 2;
+ }
+
+ internal uint CodedIndexSize(CIx code)
+ {
+ if (lgeCIx[(uint)code]) return 4;
+ return 2;
+ }
+
+ internal uint TableIndexSize(MDTable tabIx)
+ {
+ if (largeIx[(uint)tabIx]) return 4;
+ return 2;
+ }
+
+ private void SetIndexSizes()
+ {
+ for (int i=0; i < numMetaDataTables; i++) {
+ if (metaDataTables[i] == null)
+ continue;
+
+ uint count = (uint)metaDataTables[i].Count;
+ if (count > maxSmlIxSize)
+ largeIx[i] = true;
+
+ MDTable tabIx = (MDTable)i;
+ if (count > max5BitSmlIx) {
+ lgeCIx[(int)CIx.HasCustomAttr] = true;
+ }
+ if (count > max3BitSmlIx) {
+ if ((tabIx == MDTable.TypeRef) || (tabIx == MDTable.ModuleRef) || (tabIx == MDTable.Method) || (tabIx == MDTable.TypeSpec) || (tabIx == MDTable.Field))
+ lgeCIx[(int)CIx.CustomAttributeType] = true;
+ if ((tabIx == MDTable.Method) || (tabIx == MDTable.MemberRef))
+ lgeCIx[(int)CIx.MemberRefParent] = true;
+ }
+ if (count > max2BitSmlIx) {
+ if ((tabIx == MDTable.Field) || (tabIx == MDTable.Param) || (tabIx == MDTable.Property))
+ lgeCIx[(int)CIx.HasConst] = true;
+ if ((tabIx == MDTable.TypeDef) || (tabIx == MDTable.TypeRef) || (tabIx == MDTable.TypeSpec))
+ lgeCIx[(int)CIx.TypeDefOrRef] = true;
+ if ((tabIx == MDTable.TypeDef) || (tabIx == MDTable.Method) || (tabIx == MDTable.Assembly))
+ lgeCIx[(int)CIx.HasDeclSecurity] = true;
+ if ((tabIx == MDTable.File) || (tabIx == MDTable.AssemblyRef) || (tabIx == MDTable.ExportedType))
+ lgeCIx[(int)CIx.Implementation] = true;
+ if ((tabIx == MDTable.Module) || (tabIx == MDTable.ModuleRef) || (tabIx == MDTable.AssemblyRef) || (tabIx == MDTable.TypeRef))
+ lgeCIx[(int)CIx.ResolutionScope] = true;
+ }
+ if (count > max1BitSmlIx) {
+ if ((tabIx == MDTable.Field) || (tabIx == MDTable.Param))
+ lgeCIx[(int)CIx.HasFieldMarshal] = true;
+ if ((tabIx == MDTable.Event) || (tabIx == MDTable.Property))
+ lgeCIx[(int)CIx.HasSemantics] = true;
+ if ((tabIx == MDTable.Method) || (tabIx == MDTable.MemberRef))
+ lgeCIx[(int)CIx.MethodDefOrRef] = true;
+ if ((tabIx == MDTable.Field) || (tabIx == MDTable.Method))
+ lgeCIx[(int)CIx.MemberForwarded] = true;
+ if ((tabIx == MDTable.TypeDef) || (tabIx == MDTable.Method))
+ lgeCIx[(int)CIx.TypeOrMethodDef] = true;
+ }
+ }
+ }
+
+ private void SetStreamOffsets()
+ {
+ uint sizeOfHeaders = StreamHeaderSize + (uint)tildeName.Length;
+ for (int i=1; i < numStreams; i++) {
+ sizeOfHeaders += streams[i].headerSize();
+ }
+ metaDataSize = MetaDataHeaderSize + sizeOfHeaders;
+ tildeStart = metaDataSize;
+ metaDataSize += tildeTide + tildePadding;
+ for (int i=1; i < numStreams; i++) {
+ streams[i].Start = metaDataSize;
+ metaDataSize += streams[i].Size();
+ streams[i].WriteDetails();
+ }
+ }
+
+ internal void CalcTildeStreamSize()
+ {
+ CalcHeapSizes ();
+ //tilde.SetIndexSizes(strings.LargeIx(),us.LargeIx(),guid.LargeIx(),blob.LargeIx());
+ tildeTide = TildeHeaderSize;
+ tildeTide += 4 * numTables;
+ //Console.WriteLine("Tilde header + sizes = " + tildeTide);
+ for (int i=0; i < numMetaDataTables; i++) {
+ if (metaDataTables[i] != null) {
+ ArrayList table = metaDataTables[i];
+ // Console.WriteLine("Meta data table " + i + " at offset " + tildeTide);
+ tildeTide += (uint)table.Count * ((MetaDataElement)table[0]).Size(this);
+ // Console.WriteLine("Metadata table " + i + " has size " + table.Count);
+ // Console.WriteLine("tildeTide = " + tildeTide);
+ }
+ }
+ if ((tildeTide % 4) != 0) tildePadding = 4 - (tildeTide % 4);
+ //Console.WriteLine("tildePadding = " + tildePadding);
+ }
+
+ internal void WriteTildeStream(FileImage output)
+ {
+ long startTilde = output.Seek(0,SeekOrigin.Current);
+ output.Write((uint)0); // Reserved
+#if NET_2_0 || BOOTSTRAP_NET_2_0
+ output.Write((byte)2); // MajorVersion
+ output.Write((byte)0); // MinorVersion
+#else
+ output.Write((byte)1); // MajorVersion
+ output.Write((byte)0); // MinorVersion
+#endif
+ output.Write(heapSizes);
+ output.Write((byte)1); // Reserved
+ output.Write(valid);
+ output.Write(sorted);
+ for (int i=0; i < numMetaDataTables; i++) {
+ if (metaDataTables[i] != null) {
+ uint count = (uint)metaDataTables[i].Count;
+ output.Write(count);
+ }
+ }
+ long tabStart = output.Seek(0,SeekOrigin.Current);
+ // Console.WriteLine("Starting metaData tables at " + tabStart);
+ for (int i=0; i < numMetaDataTables; i++) {
+ if (metaDataTables[i] != null) {
+ // Console.WriteLine("Starting metaData table " + i + " at " + (output.Seek(0,SeekOrigin.Current) - startTilde));
+ ArrayList table = metaDataTables[i];
+ for (int j=0; j < table.Count; j++) {
+ ((MetaDataElement)table[j]).Write(output);
+ }
+ }
+ }
+ // Console.WriteLine("Writing padding at " + output.Seek(0,SeekOrigin.Current));
+ for (int i=0; i < tildePadding; i++) output.Write((byte)0);
+ }
+
+ private void BuildTable(ArrayList table)
+ {
+ if (table == null) return;
+ for (int j=0; j < table.Count; j++) {
+ ((MetaDataElement)table[j]).BuildTables(this);
+ }
+ }
+
+ private void SortTable (ArrayList mTable)
+ {
+ if (mTable == null) return;
+ mTable.Sort();
+ for (int i=0; i < mTable.Count; i++) {
+ ((MetaDataElement)mTable[i]).Row = (uint)i+1;
+ }
+ }
+
+ internal void BuildMetaData(uint codeStartOffset)
+ {
+ codeStart = codeStartOffset;
+ BuildTable(metaDataTables[(int)MDTable.TypeDef]);
+ BuildTable(metaDataTables[(int)MDTable.TypeSpec]);
+ BuildTable(metaDataTables[(int)MDTable.MemberRef]);
+#if NET_2_0 || BOOTSTRAP_NET_2_0
+ BuildTable(metaDataTables[(int)MDTable.GenericParam]);
+ BuildTable(metaDataTables[(int)MDTable.MethodSpec]);
+ BuildTable(metaDataTables[(int)MDTable.GenericParamConstraint]);
+#endif
+ BuildTable(metaDataTables[(int)MDTable.ManifestResource]);
+
+ if (cattr_list != null) {
+ foreach (CustomAttribute cattr in cattr_list)
+ cattr.BuildTables (this);
+ }
+
+ if (declsec_list != null) {
+ foreach (DeclSecurity decl_sec in declsec_list)
+ decl_sec.BuildTables (this);
+ }
+
+ /* for (int i=0; i < metaDataTables.Length; i++) {
+ ArrayList table = metaDataTables[i];
+ if (table != null) {
+ for (int j=0; j < table.Count; j++) {
+ ((MetaDataElement)table[j]).BuildTables(this);
+ }
+ }
+ }
+ */
+
+ SetIndexSizes();
+ for (int i=1; i < numStreams; i++) {
+ streams[i].EndStream();
+ }
+ CalcTildeStreamSize();
+ SetStreamOffsets();
+ byteCodePadding = NumToAlign(codeSize,4);
+ if (entryPoint != null) file.SetEntryPoint(entryPoint.Token());
+
+ // Check ordering of specific tables
+ // Constant, CustomAttribute, FieldMarshal, DeclSecurity, MethodSemantics
+ // ImplMap, GenericParam
+ // Need to load GenericParamConstraint AFTER GenericParam table in correct order
+ // The tables:
+ // InterfaceImpl, ClassLayout, FieldLayout, MethodImpl, FieldRVA, NestedClass
+ // will _ALWAYS_ be in the correct order as embedded in BuildMDTables
+
+ SortTable(metaDataTables[(int)MDTable.Constant]);
+ SortTable(metaDataTables[(int)MDTable.FieldMarshal]);
+ SortTable(metaDataTables[(int)MDTable.DeclSecurity]);
+ SortTable(metaDataTables[(int)MDTable.MethodSemantics]);
+ SortTable(metaDataTables[(int)MDTable.ImplMap]);
+#if NET_2_0 || BOOTSTRAP_NET_2_0
+ if (metaDataTables[(int)MDTable.GenericParam] != null) {
+ SortTable(metaDataTables[(int)MDTable.GenericParam]);
+ // Now add GenericParamConstraints
+ /*for (int i=0; i < metaDataTables[(int)MDTable.GenericParam].Count; i++) {
+ ((GenericParameter)metaDataTables[(int)MDTable.GenericParam][i]).AddConstraints(this);
+ }*/
+ }
+ SortTable(metaDataTables[(int)MDTable.GenericParamConstraint]);
+#endif
+ SortTable(metaDataTables[(int)MDTable.InterfaceImpl]);
+ SortTable(metaDataTables[(int)MDTable.CustomAttribute]);
+
+ }
+
+ internal void WriteByteCodes(FileImage output)
+ {
+ for (int i=0; i < byteCodes.Count; i++) {
+ ((CILInstructions)byteCodes[i]).Write(output);
+ }
+ for (int i=0; i < byteCodePadding; i++) {
+ output.Write((byte)0);
+ }
+ }
+
+ internal void WriteResources (FileImage output)
+ {
+ if (resources == null) return;
+ for (int i = 0; i < resources.Count; i ++) {
+ byte [] resBytes = (byte []) resources [i];
+ output.Write ((uint) resBytes.Length);
+ output.Write (resBytes);
+ }
+ }
+
+ internal void WriteMetaData(FileImage output)
+ {
+ this.output = output;
+ mdStart = output.Seek(0,SeekOrigin.Current);
+ // Console.WriteLine("Writing metaData at " + Hex.Long(mdStart));
+ output.Write(MetaDataSignature);
+ output.Write((short)1); // Major Version
+ output.Write((short)1); // Minor Version ECMA = 0, PEFiles = 1
+ output.Write(0); // Reserved
+ output.Write(version.Length);
+ output.Write(version.ToCharArray()); // version string is already zero padded
+ output.Write((short)0);
+ output.Write((ushort)numStreams);
+ // write tilde header
+ output.Write(tildeStart);
+ output.Write(tildeTide + tildePadding);
+ output.Write(tildeName);
+ for (int i=1; i < numStreams; i++) streams[i].WriteHeader(output);
+ // Console.WriteLine("Writing tilde stream at " + output.Seek(0,SeekOrigin.Current) + " = " + tildeStart);
+ WriteTildeStream(output);
+ for (int i=1; i < numStreams; i++) streams[i].Write(output);
+ // Console.WriteLine("Finished Writing metaData at " + output.Seek(0,SeekOrigin.Current));
+ }
+
+ internal bool LargeStringsIndex() { return strings.LargeIx(); }
+ internal bool LargeGUIDIndex() { return guid.LargeIx(); }
+ internal bool LargeUSIndex() { return us.LargeIx(); }
+ internal bool LargeBlobIndex() { return blob.LargeIx(); }
+
+ internal bool LargeIx(MDTable tabIx) { return largeIx[(uint)tabIx]; }
+
+
+ private uint NumToAlign(uint val, uint alignVal)
+ {
+ if ((val % alignVal) == 0) return 0;
+ return alignVal - (val % alignVal);
+ }
+
+ internal void WriteCodedIndex(CIx code, MetaDataElement elem, FileImage output)
+ {
+ uint ix = 0;
+ if (elem != null) {
+ ix = (elem.Row << CIxShiftMap[(uint)code]) | elem.GetCodedIx(code);
+ // Console.WriteLine("coded index = " + ix + " row = " + elem.Row);
+ //} else {
+ // Console.WriteLine("elem for coded index is null");
+ }
+ if (lgeCIx[(uint)code])
+ output.Write(ix);
+ else
+ output.Write((ushort)ix);
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Stream in the Meta Data (#Strings, #US, #Blob and #GUID)
+ /// </summary>
+
+ internal class MetaDataStream : BinaryWriter {
+
+ private static readonly uint StreamHeaderSize = 8;
+ private static uint maxSmlIxSize = 0xFFFF;
+
+ private uint start = 0;
+ uint size = 0, tide = 1;
+ bool largeIx = false;
+ uint sizeOfHeader;
+ char[] name;
+ Hashtable htable = new Hashtable();
+ Hashtable btable = new Hashtable (new ByteArrayHashCodeProvider (), new ByteArrayComparer ());
+
+ internal MetaDataStream(char[] name, bool addInitByte) : base(new MemoryStream())
+ {
+ if (addInitByte) { Write((byte)0); size = 1; }
+ this.name = name;
+ sizeOfHeader = StreamHeaderSize + (uint)name.Length;
+ }
+
+ internal MetaDataStream(char[] name, System.Text.Encoding enc, bool addInitByte) : base(new MemoryStream(),enc)
+ {
+ if (addInitByte) { Write((byte)0); size = 1; }
+ this.name = name;
+ sizeOfHeader = StreamHeaderSize + (uint)name.Length;
+ }
+
+ public uint Start {
+ get { return start; }
+ set { start = value; }
+ }
+
+ internal uint headerSize()
+ {
+ // Console.WriteLine(name + " stream has headersize of " + sizeOfHeader);
+ return sizeOfHeader;
+ }
+
+ internal void SetSize(uint siz)
+ {
+ size = siz;
+ }
+
+ internal uint Size()
+ {
+ return size;
+ }
+
+ internal bool LargeIx()
+ {
+ return largeIx;
+ }
+
+ internal void WriteDetails()
+ {
+ // Console.WriteLine(name + " - size = " + size);
+ }
+
+ internal uint Add(string str, bool prependSize)
+ {
+ Object val = htable[str];
+ uint index = 0;
+ if (val == null) {
+ index = size;
+ htable[str] = index;
+ char[] arr = str.ToCharArray();
+ if (prependSize) CompressNum((uint)arr.Length*2+1);
+ Write(arr);
+ Write((byte)0);
+ size = (uint)Seek(0,SeekOrigin.Current);
+ } else {
+ index = (uint)val;
+ }
+ return index;
+ }
+ internal uint Add (byte[] str, bool prependSize)
+ {
+ Object val = btable [str];
+ uint index = 0;
+ if (val == null) {
+ index = size;
+ btable [str] = index;
+ if (prependSize) CompressNum ((uint) str.Length);
+ Write (str);
+ size = (uint) Seek (0, SeekOrigin.Current);
+ } else {
+ index = (uint) val;
+ }
+ return index;
+ }
+
+
+ internal uint Add(Guid guid, bool prependSize)
+ {
+ byte [] b = guid.ToByteArray ();
+ if (prependSize) CompressNum ((uint) b.Length);
+ Write(guid.ToByteArray());
+ size =(uint)Seek(0,SeekOrigin.Current);
+ return tide++;
+ }
+
+ internal uint Add(byte[] blob)
+ {
+ uint ix = size;
+ CompressNum((uint)blob.Length);
+ Write(blob);
+ size = (uint)Seek(0,SeekOrigin.Current);
+ return ix;
+ }
+
+ internal uint Add(byte val, bool prependSize)
+ {
+ uint ix = size;
+ if (prependSize) CompressNum (1);
+ Write(val);
+ size = (uint)Seek(0,SeekOrigin.Current);
+ return ix;
+ }
+
+ internal uint Add(sbyte val, bool prependSize)
+ {
+ uint ix = size;
+ if (prependSize) CompressNum (1);
+ Write(val);
+ size = (uint)Seek(0,SeekOrigin.Current);
+ return ix;
+ }
+
+ internal uint Add(ushort val, bool prependSize)
+ {
+ uint ix = size;
+ if (prependSize) CompressNum (2);
+ Write(val);
+ size = (uint)Seek(0,SeekOrigin.Current);
+ return ix;
+ }
+
+ internal uint Add(short val, bool prependSize)
+ {
+ uint ix = size;
+ if (prependSize) CompressNum (2);
+ Write(val);
+ size = (uint)Seek(0,SeekOrigin.Current);
+ return ix;
+ }
+
+ internal uint Add(uint val, bool prependSize)
+ {
+ uint ix = size;
+ if (prependSize) CompressNum (4);
+ Write(val);
+ size = (uint)Seek(0,SeekOrigin.Current);
+ return ix;
+ }
+
+ internal uint Add(int val, bool prependSize)
+ {
+ uint ix = size;
+ if (prependSize) CompressNum (4);
+ Write (val);
+ size = (uint)Seek(0,SeekOrigin.Current);
+ return ix;
+ }
+
+ internal uint Add(ulong val, bool prependSize)
+ {
+ uint ix = size;
+ if (prependSize) CompressNum (8);
+ Write(val);
+ size = (uint)Seek(0,SeekOrigin.Current);
+ return ix;
+ }
+
+ internal uint Add(long val, bool prependSize)
+ {
+ uint ix = size;
+ if (prependSize) CompressNum (8);
+ Write(val);
+ size = (uint)Seek(0,SeekOrigin.Current);
+ return ix;
+ }
+
+ internal uint Add(float val, bool prependSize)
+ {
+ uint ix = size;
+ if (prependSize) CompressNum (4);
+ Write(val);
+ size = (uint)Seek(0,SeekOrigin.Current);
+ return ix;
+ }
+
+ internal uint Add(double val, bool prependSize)
+ {
+ uint ix = size;
+ if (prependSize) CompressNum (8);
+ Write(val);
+ size = (uint)Seek(0,SeekOrigin.Current);
+ return ix;
+ }
+
+ private void CompressNum(uint val)
+ {
+ if (val < 0x7F) {
+ Write((byte)val);
+ } else if (val < 0x3FFF) {
+ byte b1 = (byte)((val >> 8) | 0x80);
+ byte b2 = (byte)(val & FileImage.iByteMask[0]);
+ Write(b1);
+ Write(b2);
+ } else {
+ byte b1 = (byte)((val >> 24) | 0xC0);
+ byte b2 = (byte)((val & FileImage.iByteMask[2]) >> 16);
+ byte b3 = (byte)((val & FileImage.iByteMask[1]) >> 8);;
+ byte b4 = (byte)(val & FileImage.iByteMask[0]);
+ Write(b1);
+ Write(b2);
+ Write(b3);
+ Write(b4);
+ }
+ }
+
+ private void QuadAlign()
+ {
+ if ((size % 4) != 0) {
+ uint pad = 4 - (size % 4);
+ size += pad;
+ for (int i=0; i < pad; i++) {
+ Write((byte)0);
+ }
+ }
+ }
+
+ internal void EndStream()
+ {
+ QuadAlign();
+ if (size > maxSmlIxSize) {
+ largeIx = true;
+ }
+ }
+
+ internal void WriteHeader(BinaryWriter output)
+ {
+ output.Write(start);
+ output.Write(size);
+ output.Write(name);
+ }
+
+ internal virtual void Write(BinaryWriter output)
+ {
+ // Console.WriteLine("Writing " + name + " stream at " + output.Seek(0,SeekOrigin.Current) + " = " + start);
+ MemoryStream str = (MemoryStream)BaseStream;
+ output.Write(str.ToArray());
+ }
+
+ }
+
+ /**************************************************************************/
+ class ByteArrayComparer : IComparer {
+
+ public int Compare (object x, object y)
+ {
+ byte [] a = (byte []) x;
+ byte [] b = (byte []) y;
+ int len = a.Length;
+
+ if (b.Length != len)
+ return 1;
+
+ for (int i = 0; i < len; ++i)
+ if (a [i] != b [i])
+ return 1;
+ return 0;
+ }
+ }
+
+ class ByteArrayHashCodeProvider : IHashCodeProvider {
+
+ public int GetHashCode (Object key)
+ {
+ byte [] arr = (byte []) key;
+ int len = arr.Length;
+ int h = 0;
+
+ for (int i = 0; i < len; ++i)
+ h = (h << 5) - h + arr [i];
+
+ return h;
+ }
+
+ }
+
+
+}
diff --git a/mcs/class/PEAPI/PEAPI.cs b/mcs/class/PEAPI/PEAPI.cs
new file mode 100644
index 00000000000..be8605c109b
--- /dev/null
+++ b/mcs/class/PEAPI/PEAPI.cs
@@ -0,0 +1,1211 @@
+using System;
+using System.IO;
+using System.Collections;
+using System.Text;
+
+namespace PEAPI {
+
+ /**************************************************************************/
+ /// <summary>
+ /// Image for a PEFile
+ /// File Structure
+ /// DOS Header (128 bytes)
+ /// PE Signature ("PE\0\0")
+ /// PEFileHeader (20 bytes)
+ /// PEOptionalHeader (224 bytes)
+ /// SectionHeaders (40 bytes * NumSections)
+ ///
+ /// Sections .text (always present - contains metadata)
+ /// .sdata (contains any initialised data in the file - may not be present)
+ /// (for ilams /debug this contains the Debug table)
+ /// .reloc (always present - in pure CIL only has one fixup)
+ /// others??? c# produces .rsrc section containing a Resource Table
+ ///
+ /// .text layout
+ /// IAT (single entry 8 bytes for pure CIL)
+ /// CLIHeader (72 bytes)
+ /// CIL instructions for all methods (variable size)
+ /// MetaData
+ /// Root (20 bytes + UTF-8 Version String + quad align padding)
+ /// StreamHeaders (8 bytes + null terminated name string + quad align padding)
+ /// Streams
+ /// #~ (always present - holds metadata tables)
+ /// #Strings (always present - holds identifier strings)
+ /// #US (Userstring heap)
+ /// #Blob (signature blobs)
+ /// #GUID (guids for assemblies or Modules)
+ /// ImportTable (40 bytes)
+ /// ImportLookupTable(8 bytes) (same as IAT for standard CIL files)
+ /// Hint/Name Tables with entry "_CorExeMain" for .exe file and "_CorDllMain" for .dll (14 bytes)
+ /// ASCII string "mscoree.dll" referenced in ImportTable (+ padding = 16 bytes)
+ /// Entry Point (0xFF25 followed by 4 bytes 0x400000 + RVA of .text)
+ ///
+ /// #~ stream structure
+ /// Header (24 bytes)
+ /// Rows (4 bytes * numTables)
+ /// Tables
+ /// </summary>
+ internal class FileImage : BinaryWriter {
+
+ internal readonly static uint[] iByteMask = {0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000};
+ internal readonly static ulong[] lByteMask = {0x00000000000000FF, 0x000000000000FF00,
+ 0x0000000000FF0000, 0x00000000FF000000,
+ 0x000000FF00000000, 0x0000FF0000000000,
+ 0x00FF000000000000, 0xFF00000000000000 };
+ internal readonly static uint nibble0Mask = 0x0000000F;
+ internal readonly static uint nibble1Mask = 0x000000F0;
+
+ private static readonly byte[] DOSHeader = { 0x4d,0x5a,0x90,0x00,0x03,0x00,0x00,0x00,
+ 0x04,0x00,0x00,0x00,0xff,0xff,0x00,0x00,
+ 0xb8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,
+ 0x0e,0x1f,0xba,0x0e,0x00,0xb4,0x09,0xcd,
+ 0x21,0xb8,0x01,0x4c,0xcd,0x21,0x54,0x68,
+ 0x69,0x73,0x20,0x70,0x72,0x6f,0x67,0x72,
+ 0x61,0x6d,0x20,0x63,0x61,0x6e,0x6e,0x6f,
+ 0x74,0x20,0x62,0x65,0x20,0x72,0x75,0x6e,
+ 0x20,0x69,0x6e,0x20,0x44,0x4f,0x53,0x20,
+ 0x6d,0x6f,0x64,0x65,0x2e,0x0d,0x0d,0x0a,
+ 0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x50,0x45,0x00,0x00};
+ private static byte[] PEHeader = { 0x4c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xE0, 0x00, 0x0E, 0x01, // PE Header Standard Fields
+ 0x0B, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ };
+
+ private static readonly uint minFileAlign = 0x200;
+ private static readonly uint maxFileAlign = 0x1000;
+ private static readonly uint fileHeaderSize = 0x178;
+ private static readonly uint sectionHeaderSize = 40;
+ private static readonly uint SectionAlignment = 0x2000;
+ private static readonly uint ImageBase = 0x400000;
+ private static readonly uint ImportTableSize = 40;
+ private static readonly uint IATSize = 8;
+ private static readonly uint CLIHeaderSize = 72;
+ private uint runtimeFlags = 0x01; // COMIMAGE_FLAGS_ILONLY
+ // 32BITREQUIRED 0x02, STRONGNAMESIGNED 0x08, TRACKDEBUGDATA 0x10000
+ private static readonly uint StrongNameSignatureSize = 128;
+ private bool reserveStrongNameSignatureSpace = false;
+
+ private static readonly uint relocFlags = 0x42000040;
+ private static readonly ushort exeCharacteristics = 0x010E;
+ private static readonly ushort dllCharacteristics = 0x210E;
+ // section names are all 8 bytes
+ private static readonly string textName = ".text\0\0\0";
+ private static readonly string sdataName = ".sdata\0\0";
+ private static readonly string relocName = ".reloc\0\0";
+ private static readonly string rsrcName = ".rsrc\0\0\0";
+ private static readonly string exeHintNameTable = "\0\0_CorExeMain\0";
+ private static readonly string dllHintNameTable = "\0\0_CorDllMain\0";
+ private static readonly string runtimeEngineName = "mscoree.dll\0\0";
+
+ private Section text, sdata, rsrc;
+ ArrayList data;
+ BinaryWriter reloc = new BinaryWriter(new MemoryStream());
+ uint dateStamp = 0;
+ DateTime origin = new DateTime(1970,1,1);
+ uint numSections = 2; // always have .text and .reloc sections
+ internal SubSystem subSys = SubSystem.Windows_CUI; // default is Windows Console mode
+ internal long stackReserve = 0x100000; // default is 1Mb
+ internal uint fileAlign = minFileAlign;
+ uint entryPointOffset, entryPointPadding, imageSize, headerSize, headerPadding, entryPointToken = 0;
+ uint relocOffset, relocRVA, relocSize, relocPadding, relocTide, hintNameTableOffset;
+ uint metaDataOffset, runtimeEngineOffset, initDataSize = 0, importTablePadding;
+ uint resourcesSize, resourcesOffset;
+ uint strongNameSigOffset;
+ uint importTableOffset, importLookupTableOffset, totalImportTableSize;
+ MetaData metaData;
+ char[] runtimeEngine = runtimeEngineName.ToCharArray(), hintNameTable;
+ bool doDLL, largeStrings, largeGUID, largeUS, largeBlob;
+ ushort characteristics;
+
+ internal FileImage(bool makeDLL, string fileName) : base(new FileStream(fileName,FileMode.Create))
+ {
+ InitFileImage(makeDLL);
+ TimeSpan tmp = System.IO.File.GetCreationTime(fileName).Subtract(origin);
+ dateStamp = Convert.ToUInt32(tmp.TotalSeconds);
+ }
+
+ internal FileImage(bool makeDLL, Stream str) : base(str)
+ {
+ InitFileImage(makeDLL);
+ TimeSpan tmp = DateTime.Now.Subtract(origin);
+ dateStamp = Convert.ToUInt32(tmp.TotalSeconds);
+ }
+
+ private void InitFileImage(bool makeDLL)
+ {
+ doDLL = makeDLL;
+ if (doDLL) {
+ hintNameTable = dllHintNameTable.ToCharArray();
+ characteristics = dllCharacteristics;
+ } else {
+ hintNameTable = exeHintNameTable.ToCharArray();
+ characteristics = exeCharacteristics;
+ }
+ text = new Section(textName,0x60000020); // IMAGE_SCN_CNT CODE, EXECUTE, READ
+ // rsrc = new Section(rsrcName,0x40000040); // IMAGE_SCN_CNT INITIALIZED_DATA, READ
+ metaData = new MetaData(this);
+ }
+
+ internal MetaData GetMetaData()
+ {
+ return metaData;
+ }
+
+ private uint GetNextSectStart(uint rva, uint tide)
+ {
+ if (tide < SectionAlignment) return rva + SectionAlignment;
+ return rva + ((tide / SectionAlignment) + 1) * SectionAlignment;
+ }
+
+ private void BuildTextSection()
+ {
+ // .text layout
+ // IAT (single entry 8 bytes for pure CIL)
+ // CLIHeader (72 bytes)
+ // CIL instructions for all methods (variable size)
+ // MetaData
+ // ImportTable (40 bytes)
+ // ImportLookupTable(8 bytes) (same as IAT for standard CIL files)
+ // Hint/Name Tables with entry "_CorExeMain" for .exe file and "_CorDllMain" for .dll (14 bytes)
+ // ASCII string "mscoree.dll" referenced in ImportTable (+ padding = 16 bytes)
+ // Entry Point (0xFF25 followed by 4 bytes 0x400000 + RVA of .text)
+ metaData.BuildMetaData(IATSize + CLIHeaderSize);
+ metaDataOffset = IATSize + CLIHeaderSize;
+ // Console.WriteLine("Code starts at " + metaDataOffset);
+ metaDataOffset += metaData.CodeSize();
+ // resourcesStart =
+ resourcesOffset = metaDataOffset + metaData.Size ();
+ resourcesSize = metaData.GetResourcesSize ();
+ if (reserveStrongNameSignatureSpace) {
+ strongNameSigOffset = resourcesOffset + resourcesSize;
+ // fixUps = RVA for vtable
+ importTableOffset = strongNameSigOffset + StrongNameSignatureSize;
+ } else {
+ strongNameSigOffset = 0;
+ // fixUps = RVA for vtable
+ importTableOffset = resourcesOffset + resourcesSize;
+ }
+ importTablePadding = NumToAlign(importTableOffset,16);
+ importTableOffset += importTablePadding;
+ importLookupTableOffset = importTableOffset + ImportTableSize;
+ hintNameTableOffset = importLookupTableOffset + IATSize;
+ runtimeEngineOffset = hintNameTableOffset + (uint)hintNameTable.Length;
+ entryPointOffset = runtimeEngineOffset + (uint)runtimeEngine.Length;
+ totalImportTableSize = entryPointOffset - importTableOffset;
+ // Console.WriteLine("total import table size = " + totalImportTableSize);
+ // Console.WriteLine("entrypoint offset = " + entryPointOffset);
+ entryPointPadding = NumToAlign(entryPointOffset,4) + 2;
+ entryPointOffset += entryPointPadding;
+ text.AddReloc(entryPointOffset+2);
+ text.IncTide(entryPointOffset + 6);
+ //if (text.Tide() < fileAlign) fileAlign = minFileAlign;
+ text.SetSize(NumToAlign(text.Tide(),fileAlign));
+ // Console.WriteLine("text size = " + text.Size() + " text tide = " + text.Tide() + " text padding = " + text.Padding());
+ // Console.WriteLine("metaDataOffset = " + Hex.Int(metaDataOffset));
+ // Console.WriteLine("importTableOffset = " + Hex.Int(importTableOffset));
+ // Console.WriteLine("importLookupTableOffset = " + Hex.Int(importLookupTableOffset));
+ // Console.WriteLine("hintNameTableOffset = " + Hex.Int(hintNameTableOffset));
+ // Console.WriteLine("runtimeEngineOffset = " + Hex.Int(runtimeEngineOffset));
+ // Console.WriteLine("entryPointOffset = " + Hex.Int(entryPointOffset));
+ // Console.WriteLine("entryPointPadding = " + Hex.Int(entryPointPadding));
+
+ }
+
+ internal void BuildRelocSection()
+ {
+ text.DoRelocs(reloc);
+ if (sdata != null) sdata.DoRelocs(reloc);
+ if (rsrc != null) rsrc.DoRelocs(reloc);
+ relocTide = (uint)reloc.Seek(0,SeekOrigin.Current);
+ relocPadding = NumToAlign(relocTide,fileAlign);
+ relocSize = relocTide + relocPadding;
+ imageSize = relocRVA + SectionAlignment;
+ initDataSize += relocSize;
+ }
+
+ private void CalcOffsets()
+ {
+ if (sdata != null)
+ numSections++;
+ if (rsrc != null)
+ numSections++;
+ headerSize = fileHeaderSize + (numSections * sectionHeaderSize);
+ headerPadding = NumToAlign(headerSize,fileAlign);
+ headerSize += headerPadding;
+ uint offset = headerSize;
+ uint rva = SectionAlignment;
+ text.SetOffset(offset);
+ text.SetRVA(rva);
+ offset += text.Size();
+ rva = GetNextSectStart(rva,text.Tide());
+ // Console.WriteLine("headerSize = " + headerSize);
+ // Console.WriteLine("headerPadding = " + headerPadding);
+ // Console.WriteLine("textOffset = " + Hex.Int(text.Offset()));
+ if (sdata != null) {
+ sdata.SetSize(NumToAlign(sdata.Tide(),fileAlign));
+ sdata.SetOffset(offset);
+ sdata.SetRVA(rva);
+ offset += sdata.Size();
+ rva = GetNextSectStart(rva,sdata.Tide());
+ initDataSize += sdata.Size();
+ }
+ if (rsrc != null) {
+ rsrc.SetSize(NumToAlign(rsrc.Tide(),fileAlign));
+ rsrc.SetOffset(offset);
+ rsrc.SetRVA(rva);
+ offset += rsrc.Size();
+ rva = GetNextSectStart(rva,rsrc.Tide());
+ initDataSize += rsrc.Size();
+ }
+ relocOffset = offset;
+ relocRVA = rva;
+ }
+
+ internal void MakeFile()
+ {
+ if (doDLL) hintNameTable = dllHintNameTable.ToCharArray();
+ else hintNameTable = exeHintNameTable.ToCharArray();
+ BuildTextSection();
+ CalcOffsets();
+ BuildRelocSection();
+ // now write it out
+ WriteHeader();
+ WriteSections();
+ Flush();
+ Close();
+ }
+
+ private void WriteHeader()
+ {
+ Write(DOSHeader);
+ // Console.WriteLine("Writing PEHeader at offset " + Seek(0,SeekOrigin.Current));
+ WritePEHeader();
+ // Console.WriteLine("Writing text section header at offset " + Hex.Long(Seek(0,SeekOrigin.Current)));
+ text.WriteHeader(this,relocRVA);
+ if (sdata != null) sdata.WriteHeader(this,relocRVA);
+ if (rsrc != null) rsrc.WriteHeader(this,relocRVA);
+ // Console.WriteLine("Writing reloc section header at offset " + Seek(0,SeekOrigin.Current));
+ WriteRelocSectionHeader();
+ // Console.WriteLine("Writing padding at offset " + Seek(0,SeekOrigin.Current));
+ WriteZeros(headerPadding);
+ }
+
+ private void WriteSections()
+ {
+ // Console.WriteLine("Writing text section at offset " + Seek(0,SeekOrigin.Current));
+ WriteTextSection();
+ if (sdata != null) WriteSDataSection();
+ if (rsrc != null) WriteRsrcSection();
+ WriteRelocSection();
+ }
+
+ private void WriteIAT()
+ {
+ Write(text.RVA() + hintNameTableOffset);
+ Write(0);
+ }
+
+ private void WriteImportTables()
+ {
+ // Import Table
+ WriteZeros(importTablePadding);
+ // Console.WriteLine("Writing import tables at offset " + Hex.Long(Seek(0,SeekOrigin.Current)));
+ Write(importLookupTableOffset + text.RVA());
+ WriteZeros(8);
+ Write(runtimeEngineOffset + text.RVA());
+ Write(text.RVA()); // IAT is at the beginning of the text section
+ WriteZeros(20);
+ // Import Lookup Table
+ WriteIAT(); // lookup table and IAT are the same
+ // Hint/Name Table
+ // Console.WriteLine("Writing hintname table at " + Hex.Long(Seek(0,SeekOrigin.Current)));
+ Write(hintNameTable);
+ Write(runtimeEngineName.ToCharArray());
+ }
+
+ private void WriteTextSection()
+ {
+ WriteIAT();
+ WriteCLIHeader();
+ // Console.WriteLine("Writing code at " + Hex.Long(Seek(0,SeekOrigin.Current)));
+ metaData.WriteByteCodes(this);
+ // Console.WriteLine("Finished writing code at " + Hex.Long(Seek(0,SeekOrigin.Current)));
+ largeStrings = metaData.LargeStringsIndex();
+ largeGUID = metaData.LargeGUIDIndex();
+ largeUS = metaData.LargeUSIndex();
+ largeBlob = metaData.LargeBlobIndex();
+ metaData.WriteMetaData(this);
+ metaData.WriteResources (this);
+ if (reserveStrongNameSignatureSpace) {
+ WriteZeros(StrongNameSignatureSize);
+ }
+ WriteImportTables();
+ WriteZeros(entryPointPadding);
+ Write((ushort)0x25FF);
+ Write(ImageBase + text.RVA());
+ WriteZeros(text.Padding());
+ }
+
+ private void WriteCLIHeader()
+ {
+ Write(CLIHeaderSize); // Cb
+ Write((short)2); // Major runtime version
+ Write((short)0); // Minor runtime version
+ Write(text.RVA() + metaDataOffset);
+ Write(metaData.Size());
+ Write(runtimeFlags);
+ Write(entryPointToken);
+ if (resourcesSize > 0) {
+ Write (text.RVA () + resourcesOffset);
+ Write (resourcesSize);
+ } else {
+ WriteZeros (8);
+ }
+ // Strong Name Signature (RVA, size)
+ if (reserveStrongNameSignatureSpace) {
+ Write(text.RVA() + strongNameSigOffset);
+ Write(StrongNameSignatureSize);
+ } else {
+ WriteZeros(8);
+ }
+ WriteZeros(8); // CodeManagerTable
+ WriteZeros(8); // VTableFixups NYI
+ WriteZeros(16); // ExportAddressTableJumps, ManagedNativeHeader
+ }
+
+ private void WriteSDataSection()
+ {
+ long size = sdata.Size ();
+ long start = BaseStream.Position;
+ for (int i=0; i < data.Count; i++) {
+ ((DataConstant)data[i]).Write(this);
+ }
+ while (BaseStream.Position < (start + size))
+ Write ((byte) 0);
+ }
+
+ private void WriteRsrcSection()
+ {
+ }
+
+ private void WriteRelocSection()
+ {
+ // Console.WriteLine("Writing reloc section at " + Seek(0,SeekOrigin.Current) + " = " + relocOffset);
+ MemoryStream str = (MemoryStream)reloc.BaseStream;
+ Write(str.ToArray());
+ WriteZeros(NumToAlign((uint)str.Position,fileAlign));
+ }
+
+ internal void SetEntryPoint(uint entryPoint)
+ {
+ entryPointToken = entryPoint;
+ }
+
+ internal void AddInitData(DataConstant cVal)
+ {
+ if (sdata == null) {
+ sdata = new Section(sdataName,0xC0000040); // IMAGE_SCN_CNT INITIALIZED_DATA, READ, WRITE
+ data = new ArrayList();
+ }
+ data.Add(cVal);
+ cVal.DataOffset = sdata.Tide();
+ sdata.IncTide(cVal.GetSize());
+ }
+
+ internal void WriteZeros(uint numZeros)
+ {
+ for (int i=0; i < numZeros; i++) {
+ Write((byte)0);
+ }
+ }
+
+ internal void WritePEHeader()
+ {
+ Write((ushort)0x014C); // Machine - always 0x14C for Managed PE Files (allow others??)
+ Write((ushort)numSections);
+ Write(dateStamp);
+ WriteZeros(8); // Pointer to Symbol Table and Number of Symbols (always zero for ECMA CLI files)
+ Write((ushort)0x00E0); // Size of Optional Header
+ Write(characteristics);
+ // PE Optional Header
+ Write((ushort)0x010B); // Magic
+ Write((byte)0x6); // LMajor pure-IL = 6 C++ = 7
+ Write((byte)0x0); // LMinor
+ Write(text.Size());
+ Write(initDataSize);
+ Write(0); // Check other sections here!!
+ Write(text.RVA() + entryPointOffset);
+ Write(text.RVA());
+ uint dataBase = 0;
+ if (sdata != null) dataBase = sdata.RVA();
+ else if (rsrc != null) dataBase = rsrc.RVA();
+ else dataBase = relocRVA;
+ Write(dataBase);
+ Write(ImageBase);
+ Write(SectionAlignment);
+ Write(fileAlign);
+ Write((ushort)0x04); // OS Major
+ WriteZeros(6); // OS Minor, User Major, User Minor
+ Write((ushort)0x04); // SubSys Major
+ WriteZeros(6); // SybSys Minor, Reserved
+ Write(imageSize);
+ Write(headerSize);
+ Write((int)0); // File Checksum
+ Write((ushort)subSys);
+ Write((short)0); // DLL Flags
+ Write((uint)stackReserve); // Stack Reserve Size
+ Write((uint)0x1000); // Stack Commit Size
+ Write((uint)0x100000); // Heap Reserve Size
+ Write((uint)0x1000); // Heap Commit Size
+ Write(0); // Loader Flags
+ Write(0x10); // Number of Data Directories
+ WriteZeros(8); // Export Table
+ Write(importTableOffset + text.RVA());
+ Write(totalImportTableSize);
+ WriteZeros(24); // Resource, Exception and Certificate Tables
+ Write(relocRVA);
+ Write(relocTide);
+ WriteZeros(48); // Debug, Copyright, Global Ptr, TLS, Load Config and Bound Import Tables
+ Write(text.RVA()); // IATRVA - IAT is at start of .text Section
+ Write(IATSize);
+ WriteZeros(8); // Delay Import Descriptor
+ Write(text.RVA()+IATSize); // CLIHeader immediately follows IAT
+ Write(CLIHeaderSize);
+ WriteZeros(8); // Reserved
+ }
+
+ internal void WriteRelocSectionHeader()
+ {
+ Write(relocName.ToCharArray());
+ Write(relocTide);
+ Write(relocRVA);
+ Write(relocSize);
+ Write(relocOffset);
+ WriteZeros(12);
+ Write(relocFlags);
+ }
+
+ private void Align (MemoryStream str, int val)
+ {
+ if ((str.Position % val) != 0) {
+ for (int i=val - (int)(str.Position % val); i > 0; i--) {
+ str.WriteByte(0);
+ }
+ }
+ }
+
+ private uint Align(uint val, uint alignVal)
+ {
+ if ((val % alignVal) != 0) {
+ val += alignVal - (val % alignVal);
+ }
+ return val;
+ }
+
+ private uint NumToAlign(uint val, uint alignVal)
+ {
+ if ((val % alignVal) == 0) return 0;
+ return alignVal - (val % alignVal);
+ }
+
+ internal void StringsIndex(uint ix)
+ {
+ if (largeStrings) Write(ix);
+ else Write((ushort)ix);
+ }
+
+ internal void GUIDIndex(uint ix)
+ {
+ if (largeGUID) Write(ix);
+ else Write((ushort)ix);
+ }
+
+ internal void USIndex(uint ix)
+ {
+ if (largeUS) Write(ix);
+ else Write((ushort)ix);
+ }
+
+ internal void BlobIndex(uint ix)
+ {
+ if (largeBlob) Write(ix);
+ else Write((ushort)ix);
+ }
+
+ internal void WriteIndex(MDTable tabIx,uint ix)
+ {
+ if (metaData.LargeIx(tabIx)) Write(ix);
+ else Write((ushort)ix);
+ }
+
+ internal void WriteCodedIndex(CIx code, MetaDataElement elem)
+ {
+ metaData.WriteCodedIndex(code,elem,this);
+ }
+
+ internal void WriteCodeRVA(uint offs)
+ {
+ Write(text.RVA() + offs);
+ }
+
+ internal void WriteDataRVA(uint offs)
+ {
+ Write(sdata.RVA() + offs);
+ }
+
+ internal void Write3Bytes(uint val)
+ {
+ byte b3 = (byte)((val & FileImage.iByteMask[2]) >> 16);
+ byte b2 = (byte)((val & FileImage.iByteMask[1]) >> 8);;
+ byte b1 = (byte)(val & FileImage.iByteMask[0]);
+ Write(b1);
+ Write(b2);
+ Write(b3);
+ }
+
+ internal bool ReserveStrongNameSignatureSpace {
+ get { return reserveStrongNameSignatureSpace; }
+ set { reserveStrongNameSignatureSpace = value; }
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Base class for the PEFile (starting point)
+ /// </summary>
+ public class PEFile {
+
+ private static readonly string mscorlibName = "mscorlib";
+ private Module thisMod;
+ private ClassDef moduleClass;
+ private ArrayList classRefList = new ArrayList();
+ private ArrayList classDefList = new ArrayList();
+ private ArrayList resources = new ArrayList ();
+ private Assembly thisAssembly;
+ private static bool isMSCorlib;
+ private int corFlags = 1;
+ FileImage fileImage;
+ MetaData metaData;
+
+ /// <summary>
+ /// Create a new PEFile. Each PEFile is a module.
+ /// </summary>
+ /// <param name="name">module name, also used for the file name</param>
+ /// <param name="isDLL">create a .dll or .exe file</param>
+ /// <param name="hasAssembly">this file is an assembly and
+ /// will contain the assembly manifest. The assembly name is the
+ /// same as the module name</param>
+ public PEFile(string name, bool isDLL, bool hasAssembly)
+ : this (name, null, isDLL, hasAssembly, null, null)
+ {
+ // Console.WriteLine(Hex.Byte(0x12));
+ // Console.WriteLine(Hex.Short(0x1234));
+ // Console.WriteLine(Hex.Int(0x12345678));
+ }
+
+ /// <summary>
+ /// Create a new PEFile. Each PEFile is a module.
+ /// </summary>
+ /// <param name="name">module name, also used for the file name</param>
+ /// <param name="isDLL">create a .dll or .exe file</param>
+ /// <param name="hasAssembly">this file is an assembly and
+ /// will contain the assembly manifest. The assembly name is the
+ /// same as the module name</param>
+ /// <param name="outputDir">write the PEFile to this directory. If this
+ /// string is null then the output will be to the current directory</param>
+ public PEFile(string name, bool isDLL, bool hasAssembly, string outputDir)
+ : this (name, null, isDLL, hasAssembly, outputDir, null)
+ {
+ // Console.WriteLine(Hex.Byte(0x12));
+ // Console.WriteLine(Hex.Short(0x1234));
+ // Console.WriteLine(Hex.Int(0x12345678));
+ }
+
+ /// <summary>
+ /// Create a new PEFile
+ /// </summary>
+ /// <param name="name">module name</param>
+ /// <param name="isDLL">create a .dll or .exe</param>
+ /// <param name="hasAssembly">this PEfile is an assembly and
+ /// will contain the assemly manifest. The assembly name is the
+ /// same as the module name</param>
+ /// <param name="outStream">write the PEFile to this stream instead
+ /// of to a new file</param>
+ public PEFile(string name, bool isDLL, bool hasAssembly, Stream outStream)
+ : this (name, null, isDLL, hasAssembly, null, outStream)
+ {
+ }
+
+ public PEFile(string name, string module_name, bool isDLL, bool hasAssembly, Stream outStream)
+ : this (name, module_name, isDLL, hasAssembly, null, outStream)
+ {
+ }
+
+ public PEFile(string name, string module_name, bool isDLL, bool hasAssembly, string outputDir, Stream outStream)
+ {
+ SetName (name);
+ string fname = module_name == null ? MakeFileName (outputDir, name, isDLL) : module_name;
+ if (outStream == null)
+ fileImage = new FileImage (isDLL, fname);
+ else
+ fileImage = new FileImage (isDLL, outStream);
+
+ InitPEFile (name, fname, hasAssembly);
+ }
+
+ private void SetName (string name)
+ {
+ if (name == "mscorlib")
+ isMSCorlib = true;
+ }
+
+ private void InitPEFile(string name, string fName, bool hasAssembly)
+ {
+ metaData = fileImage.GetMetaData();
+ thisMod = new Module(fName,metaData);
+ if (hasAssembly) {
+ thisAssembly = new Assembly(name,metaData);
+ metaData.AddToTable(MDTable.Assembly,thisAssembly);
+ }
+ moduleClass = AddClass(TypeAttr.Private,"","<Module>");
+ moduleClass.SpecialNoSuper();
+ metaData.AddToTable(MDTable.Module,thisMod);
+ }
+
+ internal static bool IsMSCorlib {
+ get { return isMSCorlib; }
+ }
+
+ public ClassDef ModuleClass {
+ get { return moduleClass; }
+ }
+
+ /// <summary>
+ /// Set the subsystem (.subsystem) (Default is Windows Console mode)
+ /// </summary>
+ /// <param name="subS">subsystem value</param>
+ public void SetSubSystem(SubSystem subS)
+ {
+ fileImage.subSys = subS;
+ }
+
+ /// <summary>
+ /// Set the flags (.corflags)
+ /// </summary>
+ /// <param name="flags">the flags value</param>
+ public void SetCorFlags(int flags)
+ {
+ corFlags = flags;
+ }
+
+ public void SetStackReserve (long stackReserve)
+ {
+ fileImage.stackReserve = stackReserve;
+ }
+
+ private string MakeFileName(string dirName, string name, bool isDLL)
+ {
+ string result = "";
+ if ((dirName != null) && (dirName.CompareTo("") != 0)) {
+ result = dirName;
+ if (!dirName.EndsWith("\\")) result += "\\";
+ }
+ result += name;
+
+ // if (isDLL) result += ".dll"; else result += ".exe";
+
+ return result;
+ }
+
+ /// <summary>
+ /// Add an external assembly to this PEFile (.assembly extern)
+ /// </summary>
+ /// <param name="assemName">the external assembly name</param>
+ /// <returns>a descriptor for this external assembly</returns>
+ public AssemblyRef AddExternAssembly(string assemName)
+ {
+ if (assemName.CompareTo(mscorlibName) == 0) return metaData.mscorlib;
+ AssemblyRef anAssem = new AssemblyRef(metaData,assemName);
+ metaData.AddToTable(MDTable.AssemblyRef,anAssem);
+ // Console.WriteLine("Adding assembly " + assemName);
+ return anAssem;
+ }
+
+ /// <summary>
+ /// Add an external module to this PEFile (.module extern)
+ /// </summary>
+ /// <param name="name">the external module name</param>
+ /// <returns>a descriptor for this external module</returns>
+ public ModuleRef AddExternModule(string name)
+ {
+ ModuleRef modRef = new ModuleRef(metaData,name);
+ metaData.AddToTable(MDTable.ModuleRef,modRef);
+ return modRef;
+ }
+
+ /// <summary>
+ /// Add a "global" method to this module
+ /// </summary>
+ /// <param name="name">method name</param>
+ /// <param name="retType">return type</param>
+ /// <param name="pars">method parameters</param>
+ /// <returns>a descriptor for this new "global" method</returns>
+ public MethodDef AddMethod(string name, Type retType, Param[] pars)
+ {
+ return moduleClass.AddMethod(name,retType,pars);
+ }
+
+ /// <summary>
+ /// Add a "global" method to this module
+ /// </summary>
+ /// <param name="mAtts">method attributes</param>
+ /// <param name="iAtts">method implementation attributes</param>
+ /// <param name="name">method name</param>
+ /// <param name="retType">return type</param>
+ /// <param name="pars">method parameters</param>
+ /// <returns>a descriptor for this new "global" method</returns>
+ public MethodDef AddMethod(MethAttr mAtts, ImplAttr iAtts, string name, Type retType, Param[] pars)
+ {
+ return moduleClass.AddMethod(mAtts,iAtts,name,retType,pars);
+ }
+
+ public MethodRef AddMethodToTypeSpec (Type item, string name, Type retType, Type[] pars)
+ {
+ return AddMethodToTypeSpec (item, name, retType, pars, 0);
+ }
+
+ public MethodRef AddMethodToTypeSpec (Type item, string name, Type retType, Type[] pars, int gen_param_count)
+ {
+ MethodRef meth = new MethodRef (item.GetTypeSpec (metaData), name, retType, pars, false, null, gen_param_count);
+ metaData.AddToTable (MDTable.MemberRef,meth);
+ return meth;
+ }
+
+ public MethodRef AddVarArgMethodToTypeSpec (Type item, string name, Type retType,
+ Type[] pars, Type[] optPars) {
+ MethodRef meth = new MethodRef(item.GetTypeSpec (metaData), name,retType,pars,true,optPars, 0);
+ metaData.AddToTable(MDTable.MemberRef,meth);
+ return meth;
+ }
+
+ public FieldRef AddFieldToTypeSpec (Type item, string name, Type fType)
+ {
+ FieldRef field = new FieldRef (item.GetTypeSpec (metaData), name,fType);
+ metaData.AddToTable (MDTable.MemberRef,field);
+ return field;
+ }
+
+ public Method AddMethodSpec (Method m, GenericMethodSig g_sig)
+ {
+ MethodSpec ms = new MethodSpec (m, g_sig);
+ metaData.AddToTable (MDTable.MethodSpec, ms);
+ return ms;
+ }
+
+ /// <summary>
+ /// Add a "global" field to this module
+ /// </summary>
+ /// <param name="name">field name</param>
+ /// <param name="fType">field type</param>
+ /// <returns>a descriptor for this new "global" field</returns>
+ public FieldDef AddField(string name, Type fType)
+ {
+ return moduleClass.AddField(name,fType);
+ }
+
+ /// <summary>
+ /// Add a "global" field to this module
+ /// </summary>
+ /// <param name="attrSet">attributes of this field</param>
+ /// <param name="name">field name</param>
+ /// <param name="fType">field type</param>
+ /// <returns>a descriptor for this new "global" field</returns>
+ public FieldDef AddField(FieldAttr attrSet, string name, Type fType)
+ {
+ return moduleClass.AddField(attrSet,name,fType);
+ }
+
+ /// <summary>
+ /// Add a class to this module
+ /// </summary>
+ /// <param name="attrSet">attributes of this class</param>
+ /// <param name="nsName">name space name</param>
+ /// <param name="name">class name</param>
+ /// <returns>a descriptor for this new class</returns>
+ public ClassDef AddClass(TypeAttr attrSet, string nsName, string name)
+ {
+ return AddClass (attrSet, nsName, name, null);
+ }
+
+ /// <summary>
+ /// Add a class which extends System.ValueType to this module
+ /// </summary>
+ /// <param name="attrSet">attributes of this class</param>
+ /// <param name="nsName">name space name</param>
+ /// <param name="name">class name</param>
+ /// <returns>a descriptor for this new class</returns>
+ public ClassDef AddValueClass(TypeAttr attrSet, string nsName, string name, ValueClass vClass)
+ {
+ ClassDef aClass = new ClassDef(attrSet,nsName,name,metaData);
+ if (!ClassDef.IsValueType (nsName, name) && !ClassDef.IsEnum (nsName, name)) {
+ aClass.MakeValueClass(vClass);
+ } else {
+ if (ClassDef.IsEnum (nsName, name))
+ aClass.SetSuper (metaData.mscorlib.ValueType ());
+ else
+ aClass.SetSuper (metaData.mscorlib.GetSpecialSystemClass (PrimitiveType.Object));
+
+ metaData.mscorlib.SetSpecialSystemClass (nsName, name, aClass);
+ }
+ aClass.SetTypeIndex (PrimitiveType.ValueType.GetTypeIndex ());
+ metaData.AddToTable(MDTable.TypeDef,aClass);
+ return aClass;
+ }
+
+ /// <summary>
+ /// Add a class to this module
+ /// </summary>
+ /// <param name="attrSet">attributes of this class</param>
+ /// <param name="nsName">name space name</param>
+ /// <param name="name">class name</param>
+ /// <param name="superType">super type of this class (extends)</param>
+ /// <returns>a descriptor for this new class</returns>
+ public ClassDef AddClass(TypeAttr attrSet, string nsName, string name, Class superType)
+ {
+ ClassDef aClass = new ClassDef(attrSet,nsName,name,metaData);
+ if (superType != null)
+ aClass.SetSuper(superType);
+ if (PEFile.IsMSCorlib)
+ metaData.mscorlib.SetSpecialSystemClass (nsName, name, aClass);
+ metaData.AddToTable(MDTable.TypeDef,aClass);
+ return aClass;
+ }
+
+ public void AddGenericClass (GenericTypeInst gti)
+ {
+ metaData.AddToTable (MDTable.TypeSpec, gti);
+ }
+
+ public void AddGenericParam (GenParam param)
+ {
+ metaData.AddToTable (MDTable.TypeSpec, param);
+ }
+
+ public FileRef AddFile(string fName, byte[] hashBytes, bool hasMetaData, bool entryPoint)
+ {
+ FileRef file = new FileRef(fName,hashBytes,hasMetaData,entryPoint,metaData);
+ metaData.AddToTable(MDTable.File,file);
+ return file;
+ }
+
+ /// <summary>
+ /// Add a manifest resource to this PEFile NOT YET IMPLEMENTED
+ /// </summary>
+ /// <param name="mr"></param>
+ public void AddManifestResource(ManifestResource mr)
+ {
+ metaData.AddToTable(MDTable.ManifestResource,mr);
+ resources.Add (mr);
+ //mr.FixName(metaData);
+ }
+
+ public void AddCustomAttribute (Method meth, byte [] data, MetaDataElement element)
+ {
+ metaData.AddCustomAttribute (new CustomAttribute (element, meth, data));
+ }
+
+ public void AddDeclSecurity (SecurityAction sec_action, byte [] data, MetaDataElement element)
+ {
+ metaData.AddDeclSecurity (new DeclSecurity (element, (ushort) sec_action, data));
+ }
+
+ /// <summary>
+ /// Add a managed resource from another assembly.
+ /// </summary>
+ /// <param name="resName">The name of the resource</param>
+ /// <param name="assem">The assembly where the resource is</param>
+ /// <param name="isPublic">Access for the resource</param>
+ public void AddExternalManagedResource (string resName, AssemblyRef assem, uint flags)
+ {
+ resources.Add (new ManifestResource (resName, flags, assem));
+ }
+
+ /// <summary>
+ /// Add a managed resource from another assembly.
+ /// </summary>
+ /// <param name="mr"></param>
+ /// <param name="isPublic"></param>
+ public void AddExternalManagedResource (ManifestResource mr)
+ {
+ resources.Add (new ManifestResource (mr));
+ }
+ /// <summary>
+ /// Find a resource
+ /// </summary>
+ /// <param name="name">The name of the resource</param>
+ /// <returns>The resource with the name "name" or null </returns>
+ public ManifestResource GetResource (string name)
+ {
+ for (int i = 0; i < resources.Count; i ++) {
+ if (((ManifestResource) resources [i]).Name == name)
+ return (ManifestResource) resources [i];
+ }
+ return null;
+ }
+
+ public ManifestResource [] GetResources()
+ {
+ return (ManifestResource []) resources.ToArray (typeof (ManifestResource));
+ }
+
+ /// <summary>
+ /// Write out the PEFile (the "bake" function)
+ /// </summary>
+ public void WritePEFile() { /* the "bake" function */
+ fileImage.ReserveStrongNameSignatureSpace = thisAssembly.HasPublicKey;
+ fileImage.MakeFile();
+ }
+
+ /// <summary>
+ /// Get the descriptor of this module
+ /// </summary>
+ /// <returns>the descriptor for this module</returns>
+ public Module GetThisModule()
+ {
+ return thisMod;
+ }
+
+ /// <summary>
+ /// Get the descriptor for this assembly. The PEFile must have been
+ /// created with hasAssembly = true
+ /// </summary>
+ /// <returns>the descriptor for this assembly</returns>
+ public Assembly GetThisAssembly()
+ {
+ return thisAssembly;
+ }
+
+ }
+
+ /**************************************************************************/
+ /// <summary>
+ /// Descriptor for a Section in a PEFile eg .text, .sdata
+ /// </summary>
+ internal class Section {
+ private static readonly uint relocPageSize = 4096; // 4K pages for fixups
+
+ char[] name;
+ uint offset = 0, tide = 0, size = 0, rva = 0, relocTide = 0;
+ //uint relocOff = 0;
+ uint flags = 0, padding = 0;
+ uint[] relocs;
+
+ internal Section(string sName, uint sFlags)
+ {
+ name = sName.ToCharArray();
+ flags = sFlags;
+ }
+
+ internal uint Tide() { return tide; }
+
+ internal void IncTide(uint incVal) { tide += incVal; }
+
+ internal uint Padding() { return padding; }
+
+ internal uint Size() { return size; }
+
+ internal void SetSize(uint pad)
+ {
+ padding = pad;
+ size = tide + padding;
+ }
+
+ internal uint RVA() { return rva; }
+
+ internal void SetRVA(uint rva) { this.rva = rva; }
+
+ internal uint Offset() { return offset; }
+
+ internal void SetOffset(uint offs) { offset = offs; }
+
+ internal void DoBlock(BinaryWriter reloc, uint page, int start, int end)
+ {
+ //Console.WriteLine("rva = " + rva + " page = " + page);
+ reloc.Write(rva + page);
+ reloc.Write((uint)(((end-start+1)*2) + 8));
+ for (int j=start; j < end; j++) {
+ //Console.WriteLine("reloc offset = " + relocs[j]);
+ reloc.Write((ushort)((0x3 << 12) | (relocs[j] - page)));
+ }
+ reloc.Write((ushort)0);
+ }
+
+ internal void DoRelocs(BinaryWriter reloc)
+ {
+ if (relocTide > 0) {
+ //relocOff = (uint)reloc.Seek(0,SeekOrigin.Current);
+ uint block = (relocs[0]/relocPageSize + 1) * relocPageSize;
+ int start = 0;
+ for (int i=1; i < relocTide; i++) {
+ if (relocs[i] >= block) {
+ DoBlock(reloc,block-relocPageSize,start,i);
+ start = i;
+ block = (relocs[i]/relocPageSize + 1) * relocPageSize;
+ }
+ }
+ DoBlock(reloc,block-relocPageSize,start,(int)relocTide);
+ }
+ }
+
+ internal void AddReloc(uint offs)
+ {
+ int pos = 0;
+ if (relocs == null) {
+ relocs = new uint[5];
+ } else {
+ if (relocTide >= relocs.Length) {
+ uint[] tmp = relocs;
+ relocs = new uint[tmp.Length + 5];
+ for (int i=0; i < relocTide; i++) {
+ relocs[i] = tmp[i];
+ }
+ }
+ while ((pos < relocTide) && (relocs[pos] < offs)) pos++;
+ for (int i=pos; i < relocTide; i++) {
+ relocs[i+1] = relocs[i];
+ }
+ }
+ relocs[pos] = offs;
+ relocTide++;
+ }
+
+ internal void WriteHeader(BinaryWriter output, uint relocRVA)
+ {
+ output.Write(name);
+ output.Write(tide);
+ output.Write(rva);
+ output.Write(size);
+ output.Write(offset);
+ output.Write(0);
+ //output.Write(relocRVA + relocOff);
+ output.Write(0);
+ output.Write(0);
+ //output.Write((ushort)relocTide);
+ //output.Write((ushort)0);
+ output.Write(flags);
+ }
+
+ }
+
+ public class Hex {
+ readonly static char[] hexDigit = {'0','1','2','3','4','5','6','7',
+ '8','9','A','B','C','D','E','F'};
+ readonly static uint[] iByteMask = {0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000};
+ readonly static ulong[] lByteMask = {0x00000000000000FF, 0x000000000000FF00,
+ 0x0000000000FF0000, 0x00000000FF000000,
+ 0x000000FF00000000, 0x0000FF0000000000,
+ 0x00FF000000000000, 0xFF00000000000000 };
+ readonly static uint nibble0Mask = 0x0000000F;
+ readonly static uint nibble1Mask = 0x000000F0;
+
+ public static String Byte(int b)
+ {
+ char[] str = new char[2];
+ uint num = (uint)b;
+ uint b1 = num & nibble0Mask;
+ uint b2 = (num & nibble1Mask) >> 4;
+ str[0] = hexDigit[b2];
+ str[1] = hexDigit[b1];
+ return new String(str);
+ }
+
+ public static String Short(int b)
+ {
+ char[] str = new char[4];
+ uint num1 = (uint)b & iByteMask[0];
+ uint num2 = ((uint)b & iByteMask[1]) >> 8;
+ uint b1 = num1 & nibble0Mask;
+ uint b2 = (num1 & nibble1Mask) >> 4;
+ uint b3 = num2 & nibble0Mask;
+ uint b4 = (num2 & nibble1Mask) >> 4;
+ str[0] = hexDigit[b4];
+ str[1] = hexDigit[b3];
+ str[2] = hexDigit[b2];
+ str[3] = hexDigit[b1];
+ return new String(str);
+ }
+
+ public static String Int(int val)
+ {
+ char[] str = new char[8];
+ uint num = (uint)val;
+ int strIx = 7;
+ for (int i=0; i < iByteMask.Length; i++) {
+ uint b = num & iByteMask[i];
+ b >>= (i*8);
+ uint b1 = b & nibble0Mask;
+ uint b2 = (b & nibble1Mask) >> 4;
+ str[strIx--] = hexDigit[b1];
+ str[strIx--] = hexDigit[b2];
+ }
+ return new String(str);
+ }
+
+ public static String Int(uint num)
+ {
+ char[] str = new char[8];
+ int strIx = 7;
+ for (int i=0; i < iByteMask.Length; i++) {
+ uint b = num & iByteMask[i];
+ b >>= (i*8);
+ uint b1 = b & nibble0Mask;
+ uint b2 = (b & nibble1Mask) >> 4;
+ str[strIx--] = hexDigit[b1];
+ str[strIx--] = hexDigit[b2];
+ }
+ return new String(str);
+ }
+
+ public static String Long(long lnum)
+ {
+ ulong num = (ulong)lnum;
+ char[] str = new char[16];
+ int strIx = 15;
+ for (int i=0; i < lByteMask.Length; i++) {
+ ulong b = num & lByteMask[i];
+ b >>= (i*8);
+ ulong b1 = b & nibble0Mask;
+ ulong b2 = (b & nibble1Mask) >> 4;
+ str[strIx--] = hexDigit[b1];
+ str[strIx--] = hexDigit[b2];
+ }
+ return new String(str);
+ }
+ }
+
+ /// <summary>
+ /// Error for invalid PE file
+ /// </summary>
+ public class PEFileException : System.Exception {
+ public PEFileException(string msg) : base(msg) { }
+ }
+
+ public class NotYetImplementedException : System.Exception {
+ public NotYetImplementedException(string msg) : base(msg + " Not Yet Implemented") { }
+ }
+
+ public class TypeSignatureException : System.Exception {
+ public TypeSignatureException(string msg) : base(msg) { }
+ }
+
+}
diff --git a/mcs/class/PEAPI/PEAPI.dll.sources b/mcs/class/PEAPI/PEAPI.dll.sources
new file mode 100644
index 00000000000..fe5b1f598c3
--- /dev/null
+++ b/mcs/class/PEAPI/PEAPI.dll.sources
@@ -0,0 +1,6 @@
+./Assembly/AssemblyInfo.cs
+../../build/common/Consts.cs
+../../build/common/Locale.cs
+Metadata.cs
+Code.cs
+PEAPI.cs
diff --git a/mcs/class/PEAPI/README.txt b/mcs/class/PEAPI/README.txt
new file mode 100644
index 00000000000..87ee90a369b
--- /dev/null
+++ b/mcs/class/PEAPI/README.txt
@@ -0,0 +1,34 @@
+PEAPI
+-----
+
+This is a preliminary version of our PE writer component. It is a managed
+component which presents on the client side an API and constructs program
+executable files.
+
+We have tested this component as an alternative backend for Gardens Point
+Component Pascal .NET. Our previous versions of gpcp produced textual CIL and
+invoked ilasm. The new backend can create a program executable file in almost
+exactly the same length of time as it takes to write the equivalent CIL text
+file.
+
+PEAPI is written in C# and is released as open source under a FreeBSD-like
+licence. Included in this release is pdf documentation and both html and
+chm documentation. The main documentation is written as if it was a new
+Appendix to John Gough's book Compiling for the .NET Common Language Runtime,
+Prentice-Hall 2002.
+
+The current release implements most of the facilities of the API however,
+some final features not required for component pascal have yet to be added.
+We expect to update the component incrementally as additional features are
+added. Currently the component does not produce debugger information (pdb
+files). We are considering possible ways of doing this or alternatively
+producing rotor-format debugging information.
+
+The team has a committment to maintain and update the component into the
+foreseeable future, as several other projects here depend on it. Users are
+encouraged to send feedback on missing features, bug reports etc. to assist
+in this quest.
+
+Update (18th Apr 2005)
+
+Some portions of the code have been taken from PERWAPI (http://www.plas.fit.qut.edu.au/perwapi/Default.aspx), which extends PEAPI. It is developed by Diane Corney.
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..521aa46d55d
--- /dev/null
+++ b/mcs/class/System.Drawing/ChangeLog
@@ -0,0 +1,326 @@
+2006-01-30 Boris Kirzner <borisk@mainsoft.com>
+ * run-tests.test.bat: changed location of xmltool.
+
+2006-01-29 Boris Kirzner <borisk@mainsoft.com>
+ * run-tests.bat, run-tests.test.bat, runtestfixture.bat,
+ runmonotestfixture.bat : added batch files for automatic
+ testing for TARGET_JVM.
+
+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..25d6f39a204
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing.Printing/ChangeLog
@@ -0,0 +1,17 @@
+2006-01-27 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * Adds PrintFontSample.cs
+
+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/PrintFontSample.cs b/mcs/class/System.Drawing/Samples/System.Drawing.Printing/PrintFontSample.cs
new file mode 100644
index 00000000000..d378a604317
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing.Printing/PrintFontSample.cs
@@ -0,0 +1,58 @@
+//
+// Sample to Print diferent font types and sizes
+//
+
+using System;
+using System.Drawing;
+using System.IO;
+using System.Drawing.Printing;
+
+public class PrintingTextFile
+{
+
+ static private void PrintPageEvent (object sender, PrintPageEventArgs e)
+ {
+ float left = e.MarginBounds.Left;
+ float top = e.MarginBounds.Top;
+
+ Font font = new Font ("Arial", 10);
+ e.Graphics.DrawString("This a sample with font " + font.Name + " size:" + font.Size,
+ font, new SolidBrush (Color.Red), left, top);
+
+ font = new Font ("Verdana", 16);
+ e.Graphics.DrawString ("This a sample with font " + font.Name + " size:" + font.Size,
+ font, new SolidBrush (Color.Blue), left, top + 50);
+
+ font = new Font ("Verdana", 22);
+ e.Graphics.DrawString ("This a sample with font " + font.Name + " size:" + font.Size,
+ font, new SolidBrush (Color.Black), left, top + 150);
+
+ font = new Font (FontFamily.GenericMonospace, 14);
+ e.Graphics.DrawString ("This a sample with font " + font.Name + " size:" + font.Size,
+ font, new SolidBrush (Color.Black), left, top + 250);
+
+ font = new Font ("Arial", 48);
+ e.Graphics.DrawString ("Font " + font.Name + " size:" + font.Size,
+ font, new SolidBrush (Color.Red), left, top + 300);
+
+ font = new Font ("Times New Roman", 32);
+ e.Graphics.DrawString ("Another sample font " + font.Name + " size:" + font.Size,
+ font, new SolidBrush (Color.Black), left, top + 500);
+
+ font = new Font (FontFamily.GenericSansSerif, 8);
+ e.Graphics.DrawString ("Another sample font " + font.Name + " size:" + font.Size,
+ font, new SolidBrush (Color.Blue), left, top + 900);
+
+ e.HasMorePages = false;
+ }
+
+
+ public static void Main (string[] args)
+ {
+ PrintDocument p = new PrintDocument ();
+ p.PrintPage += new PrintPageEventHandler (PrintPageEvent);
+ p.Print ();
+ }
+}
+
+
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..ebff33c1e0a
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/ChangeLog
@@ -0,0 +1,73 @@
+2006-02-02 Sebastien Pouliot <sebastien@ximian.com>
+
+ * RegionsRectangle.cs: Add test case for bug #77408.
+
+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..1ffa07ce93f
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/RegionsRectangle.cs
@@ -0,0 +1,445 @@
+//
+// 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;
+
+ dc.DrawString ("Special cases (old bugs)", fnttitle, whiteBrush, 5, 610);
+
+ x = 0;
+
+ if (xor) {
+ rect1 = new Rectangle (20+x, 330+300, 40, 50);
+ rect2 = new Rectangle (40+x, 360+300, 20, 20);
+ dc.DrawRectangle (Pens.Red, rect1);
+ dc.DrawRectangle (Pens.Green, rect2);
+ rgn1 = new Region (rect1);
+ rgn1.Xor (rect2);
+ dc.FillRegion (Brushes.Blue, rgn1);
+ dc.DrawString ("Xor (" + rgn1.GetRegionScans (matrix).Length +") #77408", fnt, whiteBrush, 10, 430+300);
+ dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
+ DumpRegion (rgn1);
+ }
+
+ 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..299f5dc49ed
--- /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.bmp", 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..caee595a731
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/imagecompose.cs
@@ -0,0 +1,71 @@
+//
+// 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;
+ if (info == null) {
+ Console.WriteLine ("Couldn't get codec for image/tiff");
+ return;
+ }
+ //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..3b33bc8de77
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog
@@ -0,0 +1,576 @@
+2006-03-22 Sebastien Pouliot <sebastien@ximian.com>
+
+ * GraphicsPath.cs: Call [libgdiplus|GDI+] for AddString (even if it
+ is not yet implemented in libgdiplus).
+ * LinearGradientBrush.cs: Update the rectangle when using the internal
+ ctor. Fix a few missing validations.
+
+2006-03-17 Sebastien Pouliot <sebastien@ximian.com>
+
+ * Matrix.cs: Add missing checks to methods (and fix unit tests).
+
+2006-02-05 Konstantin Triger <kostat@mainsoft.com>
+
+ * ExtendedGeneralPath.jvm.cs: use correct properties.
+
+2006-01-27 Sebastien Pouliot <sebastien@ximian.com>
+
+ * GraphicsPath.cs: Removed TODO on Flatten methods (now supported in
+ libgdiplus). Added a private constant for FlatnessDefault (0.25).
+ Added MonoTODO on IsVisible* methods (not supported in libgdiplus).
+ * Matrix.cs: Ensure we call Marshal.FreeHGlobal even if CheckStatus
+ throws an exception.
+
+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..3d72b7c5798
--- /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.Types [tpos - 1] = (byte) (pathData.Types [tpos - 1] | (byte) PathPointType.CloseSubpath | marker);
+ break;
+ case SEG_MOVETO:
+ pathData.Types [tpos++] = (byte)((byte) PathPointType.Start | marker);
+ pathData.Points [ppos++] = new PointF (Coords [cpos++], Coords [cpos++]);
+ break;
+ case SEG_LINETO:
+ pathData.Types [tpos++] = (byte) ((byte) PathPointType.Line | marker);
+ pathData.Points [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.Types [tpos++] = (byte)(byte) PathPointType.Bezier;
+ pathData.Points [ppos++] = new PointF (x1, y1);
+ pathData.Types [tpos++] = (byte)(byte) PathPointType.Bezier;
+ pathData.Points [ppos++] = new PointF (x2, y2);
+ pathData.Types [tpos++] = (byte) ((byte)PathPointType.Bezier | marker);
+ pathData.Points [ppos++] = new PointF (x3, y3);
+ break;
+ case SEG_CUBICTO:
+ pathData.Types [tpos++] = (byte)(byte) PathPointType.Bezier3;
+ pathData.Points [ppos++] = new PointF (Coords [cpos++], Coords [cpos++]);
+ pathData.Types [tpos++] = (byte) PathPointType.Bezier3;
+ pathData.Points [ppos++] = new PointF (Coords [cpos++], Coords [cpos++]);
+ pathData.Types [tpos++] = (byte) ((byte)PathPointType.Bezier3 | marker);
+ pathData.Points [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..d8832e2e0aa
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPath.cs
@@ -0,0 +1,913 @@
+//
+// 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.Runtime.InteropServices;
+
+namespace System.Drawing.Drawing2D
+{
+ public sealed class GraphicsPath : MarshalByRefObject, ICloneable, IDisposable
+ {
+ // 1/4 is the FlatnessDefault as defined in GdiPlusEnums.h
+ private const float FlatnessDefault = 1.0f / 4.0f;
+
+ 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 ("GdipAddStringI isn't implemented in libgdiplus")]
+ public void AddString (string s, FontFamily family, int style, float emSize, Point origin, StringFormat format)
+ {
+ Rectangle layout;
+ layout.X = origin.X;
+ layout.Y = origin.Y;
+ AddString (s, family, style, emSize, layout, format);
+ }
+
+ [MonoTODO ("GdipAddString isn't implemented in libgdiplus")]
+ public void AddString (string s, FontFamily family, int style, float emSize, PointF origin, StringFormat format)
+ {
+ RectangleF layout;
+ layout.X = origin.X;
+ layout.Y = origin.Y;
+ AddString (s, family, style, emSize, layout, format);
+ }
+
+ [MonoTODO ("GdipAddStringI isn't implemented in libgdiplus")]
+ public void AddString (string s, FontFamily family, int style, float emSize, Rectangle layoutRect, StringFormat format)
+ {
+ if (s == null)
+ throw new ArgumentNullException ("s");
+
+ IntPtr ffamily = (family == null) ? IntPtr.Zero : family.NativeObject;
+ IntPtr sformat = (format == null) ? IntPtr.Zero : format.NativeObject;
+
+ Status status = GDIPlus.GdipAddStringI (nativePath, s, s.Length, ffamily, style, emSize, ref layoutRect, sformat);
+ GDIPlus.CheckStatus (status);
+ }
+
+ [MonoTODO ("GdipAddString isn't implemented in libgdiplus")]
+ public void AddString (string s, FontFamily family, int style, float emSize, RectangleF layoutRect, StringFormat format)
+ {
+ if (s == null)
+ throw new ArgumentNullException ("s");
+
+ IntPtr ffamily = (family == null) ? IntPtr.Zero : family.NativeObject;
+ IntPtr sformat = (format == null) ? IntPtr.Zero : format.NativeObject;
+
+ Status status = GDIPlus.GdipAddString (nativePath, s, s.Length, ffamily, style, emSize, ref layoutRect, sformat);
+ GDIPlus.CheckStatus (status);
+ }
+
+ 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);
+ }
+
+ public void Flatten ()
+ {
+ Flatten (null, FlatnessDefault);
+ }
+
+ public void Flatten (Matrix matrix)
+ {
+ Flatten (matrix, FlatnessDefault);
+ }
+
+ 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;
+ }
+
+ [MonoTODO ("GdipIsOutlineVisiblePathPoint[I] isn't implemented in libgdiplus")]
+ public bool IsOutlineVisible (Point point, Pen pen)
+ {
+ return IsOutlineVisible (point.X, point.Y, pen, null);
+ }
+
+ [MonoTODO ("GdipIsOutlineVisiblePathPoint[I] isn't implemented in libgdiplus")]
+ public bool IsOutlineVisible (PointF point, Pen pen)
+ {
+ return IsOutlineVisible (point.X, point.Y, pen, null);
+ }
+
+ [MonoTODO ("GdipIsOutlineVisiblePathPoint[I] isn't implemented in libgdiplus")]
+ public bool IsOutlineVisible (int x, int y, Pen pen)
+ {
+ return IsOutlineVisible (x, y, pen, null);
+ }
+
+ [MonoTODO ("GdipIsOutlineVisiblePathPoint[I] isn't implemented in libgdiplus")]
+ public bool IsOutlineVisible (float x, float y, Pen pen)
+ {
+ return IsOutlineVisible (x, y, pen, null);
+ }
+
+ [MonoTODO ("GdipIsOutlineVisiblePathPoint[I] isn't implemented in libgdiplus")]
+ public bool IsOutlineVisible (Point pt, Pen pen, Graphics graphics)
+ {
+ return IsOutlineVisible (pt.X, pt.Y, pen, graphics);
+ }
+
+ [MonoTODO ("GdipIsOutlineVisiblePathPoint[I] isn't implemented in libgdiplus")]
+ public bool IsOutlineVisible (PointF pt, Pen pen, Graphics graphics)
+ {
+ return IsOutlineVisible (pt.X, pt.Y, pen, graphics);
+ }
+
+ [MonoTODO ("GdipIsOutlineVisiblePathPoint[I] isn't implemented in libgdiplus")]
+ 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 ("GdipIsOutlineVisiblePathPoint[I] isn't implemented in libgdiplus")]
+ 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;
+ }
+
+ [MonoTODO ("GdipIsVisiblePathPoint[I] isn't implemented in libgdiplus")]
+ public bool IsVisible (Point point)
+ {
+ return IsVisible (point.X, point.Y, null);
+ }
+
+ [MonoTODO ("GdipIsVisiblePathPoint[I] isn't implemented in libgdiplus")]
+ public bool IsVisible (PointF point)
+ {
+ return IsVisible (point.X, point.Y, null);
+ }
+
+ [MonoTODO ("GdipIsVisiblePathPoint[I] isn't implemented in libgdiplus")]
+ public bool IsVisible (int x, int y)
+ {
+ return IsVisible (x, y, null);
+ }
+
+ [MonoTODO ("GdipIsVisiblePathPoint[I] isn't implemented in libgdiplus")]
+ public bool IsVisible (float x, float y)
+ {
+ return IsVisible (x, y, null);
+ }
+
+ [MonoTODO ("GdipIsVisiblePathPoint[I] isn't implemented in libgdiplus")]
+ public bool IsVisible (Point pt, Graphics graphics)
+ {
+ return IsVisible (pt.X, pt.Y, graphics);
+ }
+
+ [MonoTODO ("GdipIsVisiblePathPoint[I] isn't implemented in libgdiplus")]
+ public bool IsVisible (PointF pt, Graphics graphics)
+ {
+ return IsVisible (pt.X, pt.Y, graphics);
+ }
+
+ [MonoTODO ("GdipIsVisiblePathPoint[I] isn't implemented in libgdiplus")]
+ 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 ("GdipIsVisiblePathPoint[I] isn't implemented in libgdiplus")]
+ 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, FlatnessDefault);
+ }
+
+ [MonoTODO ("GdipWarpPath isn't implemented in libgdiplus")]
+ public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix)
+ {
+ Warp (destPoints, srcRect, matrix, WarpMode.Perspective, FlatnessDefault);
+ }
+
+ [MonoTODO ("GdipWarpPath isn't implemented in libgdiplus")]
+ public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode)
+ {
+ Warp (destPoints, srcRect, matrix, warpMode, FlatnessDefault);
+ }
+
+ [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, FlatnessDefault);
+ }
+
+ [MonoTODO ("GdipWidenPath isn't implemented in libgdiplus")]
+ public void Widen (Pen pen, Matrix matrix)
+ {
+ Widen (pen, matrix, FlatnessDefault);
+ }
+
+ [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..abdc54637b5
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.cs
@@ -0,0 +1,355 @@
+//
+// 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,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;
+
+namespace System.Drawing.Drawing2D {
+
+ public sealed class LinearGradientBrush : Brush
+ {
+ RectangleF rectangle;
+
+ internal LinearGradientBrush (IntPtr native) : base (native)
+ {
+ Status status = GDIPlus.GdipGetLineRect (native, out rectangle);
+ GDIPlus.CheckStatus (status);
+ }
+
+ 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 {
+ if (value == null)
+ throw new ArgumentNullException ("Transform");
+
+ 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 {
+ // note: Clamp isn't valid (context wise) but it is checked in libgdiplus
+ if ((value < WrapMode.Tile) || (value > WrapMode.Clamp))
+ throw new InvalidEnumArgumentException ("WrapMode");
+
+ 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)
+ {
+ if (matrix == null)
+ throw new ArgumentNullException ("matrix");
+
+ 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);
+
+ return new LinearGradientBrush (clonePtr);
+ }
+ }
+}
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..47e87dd337e
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/Matrix.cs
@@ -0,0 +1,327 @@
+//
+// 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
+// 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.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)
+ {
+ if (plgpts == null)
+ throw new ArgumentNullException ("plgpts");
+
+ Status status = GDIPlus.GdipCreateMatrix3I (rect, plgpts, out nativeMatrix);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public Matrix (RectangleF rect , PointF[] pa)
+ {
+ if (pa == null)
+ throw new ArgumentNullException ("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 {
+ float [] retval = new float [6];
+ IntPtr tmp = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (float)) * 6);
+ try {
+ Status status = GDIPlus.GdipGetMatrixElements (nativeMatrix, tmp);
+ GDIPlus.CheckStatus (status);
+ Marshal.Copy (tmp, retval, 0, 6);
+ }
+ finally {
+ 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)
+ {
+ if (matrix == null)
+ throw new ArgumentNullException ("matrix");
+
+ 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)
+ {
+ if ((order < MatrixOrder.Prepend) || (order > MatrixOrder.Append))
+ throw new ArgumentException ("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)
+ {
+ if (pts == null)
+ throw new ArgumentNullException ("pts");
+
+ Status status = GDIPlus.GdipTransformMatrixPointsI (nativeMatrix, pts, pts.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void TransformPoints (PointF[] pts)
+ {
+ if (pts == null)
+ throw new ArgumentNullException ("pts");
+
+ Status status = GDIPlus.GdipTransformMatrixPoints (nativeMatrix, pts, pts.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void TransformVectors (Point[] pts)
+ {
+ if (pts == null)
+ throw new ArgumentNullException ("pts");
+
+ Status status = GDIPlus.GdipVectorTransformMatrixPointsI (nativeMatrix, pts, pts.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void TransformVectors (PointF[] pts)
+ {
+ if (pts == null)
+ throw new ArgumentNullException ("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..42f297169a0
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ChangeLog
@@ -0,0 +1,424 @@
+2006-02-09 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ColorPalette.cs, EncoderParameters.cs, EncoderParameter.cs,
+ ImageAttributes.cs: 64bit cleanup and some simplifications
+
+2006-01-27 Sebastien Pouliot <sebastien@ximian.com>
+
+ * ImageAttributes.cs: Ensure Marshal.FreeHGlobal is called for all
+ unmanaged memory allocated with AllocHGlobal.
+ * ImageCodecInfo.cs: Ensure Marshal.FreeHGlobal is called for all
+ unmanaged memory allocated with AllocHGlobal.
+
+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..a7c989f5c26
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorPalette.cs
@@ -0,0 +1,118 @@
+//
+// 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.ToInt64() + Marshal.SizeOf (palette)), values.Length);
+
+ return lfBuffer;
+ }
+
+ internal void setFromGDIPalette (IntPtr palette)
+ {
+ IntPtr ptr = palette;
+ int cnt, color;
+ int offset;
+
+ flags = Marshal.ReadInt32 (ptr); ptr = (IntPtr) (ptr.ToInt64() + 4);
+ cnt = Marshal.ReadInt32 (ptr); ptr = (IntPtr) (ptr.ToInt64() + 4);
+
+ entries = new Color [cnt];
+
+ offset = 0;
+ for (int i = 0; i < cnt; i++) {
+ color = Marshal.ReadInt32 (ptr, offset);
+ entries[i] = Color.FromArgb (color);
+ offset += 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..f21831faa49
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameter.cs
@@ -0,0 +1,349 @@
+//
+// 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);
+ for (int i = 0; i < valuesCount; i++) {
+ Marshal.WriteInt32 (valuePtr, i * 4, (int) numerator[i]);
+ Marshal.WriteInt32 (valuePtr, (i + 1) * 4, (int) denominator[i]);
+ }
+ }
+
+ 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, i * 4, (int) rangebegin[i]);
+ Marshal.WriteInt32 (dest, (i + 1) * 4, (int) rangeend[i]);
+ }
+ }
+
+ 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, i * 4, numerator1[i]);
+ Marshal.WriteInt32 (dest, (i + 1) * 4, denominator1[i]);
+ Marshal.WriteInt32 (dest, (i + 2) * 4, numerator2[i]);
+ Marshal.WriteInt32 (dest, (i + 3) * 4, denominator2[i]);
+ }
+ }
+
+ 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..27fd027039c
--- /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) (ptr.ToInt64() + 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) (ptr.ToInt64() + 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..28879656c93
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageAttributes.cs
@@ -0,0 +1,432 @@
+//
+// 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);
+ try {
+ 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.ToInt64() + mapsize);
+ }
+
+ Status status = GDIPlus.GdipSetImageAttributesRemapTable (nativeImageAttr,
+ ColorAdjustType.Brush, true, (uint) map.Length, clrmap);
+ GDIPlus.CheckStatus (status);
+ }
+ finally {
+ Marshal.FreeHGlobal (clrmap);
+ }
+ }
+
+
+ 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);
+ try {
+ 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.ToInt64() + mapsize);
+ }
+
+ Status status = GDIPlus.GdipSetImageAttributesRemapTable (nativeImageAttr,
+ type, true, (uint) map.Length, clrmap);
+ GDIPlus.CheckStatus (status);
+ }
+ finally {
+ Marshal.FreeHGlobal (clrmap);
+ }
+ }
+
+ 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..afe0e4be2a8
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecInfo.cs
@@ -0,0 +1,220 @@
+//
+// 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);
+ try {
+ 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]);
+ }
+ }
+ finally {
+ 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);
+ try {
+ 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]);
+ }
+ }
+ finally {
+ 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..a7913108044
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/ChangeLog
@@ -0,0 +1,74 @@
+2006-03-21 Sebastien Pouliot <sebastien@ximian.com>
+
+ * PrintingServicesUnix.cs: cupsGetPrinters(char***) requires to free
+ each individual string and (finally) the list. Note that this call is
+ deprecated.
+
+2006-03-13 Peter Dennis Bartok <pbartok@novell.com>
+
+ * PrintingServicesUnix.cs: Handle not having a printer
+
+2006-02-09 Peter Dennis Bartok <pbartok@novell.com>
+
+ * PrintingServicesWin32.cs: Simplyfied the code, removing the need
+ for pointer calculations (part of 64bit cleanup)
+
+2006-01-27 Sebastien Pouliot <sebastien@ximian.com>
+
+ * PrintingServicesWin32.cs: Ensure Marshal.FreeHGlobal is called for
+ all unmanaged memory allocated with AllocHGlobal.
+
+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..b404ec48e9e
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrintingServicesUnix.cs
@@ -0,0 +1,360 @@
+//
+// 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;
+
+ if ((printer == null) || (printer == String.Empty)) {
+ return;
+ }
+
+ 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[] {});
+
+ /* FIXME: call is deprecated */
+ 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);
+ Marshal.FreeHGlobal (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..c9e2728b127
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrintingServicesWin32.cs
@@ -0,0 +1,348 @@
+//
+// 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;
+
+ try {
+ 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) {
+ // the finally clause will free the unmanaged memory before returning
+ 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, i * 4);
+ y = Marshal.ReadInt32 (ptr_sizes, (i + 1) * 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);
+ }
+ }
+ finally {
+ if (buff_names != IntPtr.Zero)
+ Marshal.FreeHGlobal (buff_names);
+ if (buff_sizes != IntPtr.Zero)
+ Marshal.FreeHGlobal (buff_sizes);
+ if (buff_sizes_enum != IntPtr.Zero)
+ 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);
+ try {
+ // 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));
+ }
+ }
+ finally {
+ 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/ChangeLog b/mcs/class/System.Drawing/System.Drawing.Text/ChangeLog
new file mode 100644
index 00000000000..3bf96ff7cac
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Text/ChangeLog
@@ -0,0 +1,112 @@
+2006-03-23 Peter Dennis Bartok <pbartok@novell.com>
+
+ * FontCollection.cs (Dispose): When on Linux/Unix, call
+ GdipDeletePrivateFontCollection to free up the font collection (even
+ though it's not private, we'd be leaking otherwise. Don't try this
+ with Microsoft's GDI+ on Win32, though.)
+
+2006-03-23 Peter Dennis Bartok <pbartok@novell.com>
+
+ * FontCollection.cs (get_Families): Now letting the runtime do the
+ marshalling work for us. Easier to maintain and cleaner code.
+ * PrivateFontCollection.cs:
+ - AddFontFile: Fixed weird english in error message
+ - Dispose: Need to pass ref to the native object, we were crashing
+ badly
+
+2006-02-09 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ChangeLog: Created, contents from deleted 'changelog' file
+ * FontCollection.cs: Cleaned up marshalling and made 64bit safe
+
+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.Text/FontCollection.cs b/mcs/class/System.Drawing/System.Drawing.Text/FontCollection.cs
new file mode 100644
index 00000000000..47a140f7652
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Text/FontCollection.cs
@@ -0,0 +1,101 @@
+//
+// 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)
+// Peter Dennis Bartok (pbartok@novell.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;
+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)
+ {
+ OperatingSystem osInfo = Environment.OSVersion;
+
+ if (nativeFontCollection != IntPtr.Zero) {
+ if ((int) osInfo.Platform == 128 || (int) osInfo.Platform == 4) {
+ GDIPlus.GdipDeletePrivateFontCollection (ref nativeFontCollection);
+ nativeFontCollection = IntPtr.Zero;
+ }
+ }
+ }
+
+ // properties
+ public FontFamily[] Families
+ {
+ get {
+ int found;
+ int returned;
+ Status status;
+ FontFamily[] families;
+ IntPtr[] result;
+
+ status = GDIPlus.GdipGetFontCollectionFamilyCount (nativeFontCollection, out found);
+ GDIPlus.CheckStatus (status);
+
+ result = new IntPtr[found];
+ status = GDIPlus.GdipGetFontCollectionFamilyList(nativeFontCollection, found, result, out returned);
+
+ families = new FontFamily [returned];
+ for ( int i = 0; i < returned ; i++) {
+ families[i] = new FontFamily(result[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..4488706f06c
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Text/PrivateFontCollection.cs
@@ -0,0 +1,90 @@
+//
+// 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)
+// Peter Dennis Bartok (pbartok@novell.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.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 specified file does not exist");
+
+ 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 (ref nativeFontCollection);
+
+ // This must be zeroed out, otherwise our base will also call
+ // the GDI+ delete method on unix platforms. We're keeping the
+ // base.Dispose() call in case other cleanup ever gets added there
+ 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.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..ab1eaf0b73f
--- /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 = 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 = 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 = bmp;
+ }
+
+ internal Bitmap (float width, float height, PixelFormat pixel, IntPtr bmp)
+ {
+ nativeObject = 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 = 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, 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, 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.Zero)
+ 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..6b3c48ff570
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Brush.cs
@@ -0,0 +1,90 @@
+//
+// System.Drawing.Brush.cs
+//
+// Authors:
+// Miguel de Icaza (miguel@ximian.com)
+// Ravindra (rkumar@novell.com)
+//
+// (C) 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.
+//
+
+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
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ System.GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ // NOTE: this has been known to fail in the past (cairo)
+ // but it's the only way to reclaim brush related memory
+ if (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..6ebfd20de5f
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/ChangeLog
@@ -0,0 +1,2572 @@
+2006-03-23 Peter Dennis Bartok <pbartok@novell.com>
+
+ * gdipFunctions.cs:
+ - GdipGetFontCollectionFamilyList: No need for complicated
+ GlobalAlloc stuff, .Net marshals the IntPtr[] array just fine
+ - GdipDeletePrivateFontCollection: We need to pass a ref to the
+ structure. This was causing nasty crashes.
+ - GdipGetFamilyName: Switched to use StringBuilder instead of
+ manual marshalling
+ * FontFamily.cs: Simplified the refreshName method, less error-prone now
+
+2006-03-21 Sebastien Pouliot <sebastien@ximian.com>
+
+ * Brush.cs: Remove unused code.
+ * FontFamily.cs: Remove warnings from build.
+ * gdipFunctions.cs: Add missing p/invoke calls for GdipAddString[I].
+
+2006-03-21 Sebastien Pouliot <sebastien@ximian.com>
+
+ * gdipFunctions.cs: Import XFree (from libX11) so we can free the
+ memory we allocate.
+ * Graphics.cs: Free the memory we get from XGetVisualInfo.
+
+2006-03-20 Sebastien Pouliot <sebastien@ximian.com>
+
+ * Brush.cs: Allow Dispose to free the unmanaged memory for the brush
+ in every case. This has been known (in the past) to cause crashes
+ in Cairo. If still true then we need to find out why!
+
+2006-03-09 Peter Dennis Bartok <pbartok@novell.com>
+
+ * gdipFunctions.cs: Removed XCloseDisplay call from Gdi+ shutdown,
+ it was causing crashes in the finalizers (bug #77464)
+
+2006-03-06 Jonathan Gilbert <logic@deltaq.org>
+
+ * gdipFunctions.cs: Rewrote the StreamSeekImpl function to invalidate
+ the start_buf cached bytes whenever Seek() is actually called. If
+ Seek is not called (an invalid 'whence' value), then the buffer is
+ not invalidated. This fixes a bug with TIFF loading.
+
+2006-03-02 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Image.cs (ISerializable.GetObjectData): Save the image in it's
+ original format. (Fixes #77673)
+
+2006-02-28 Jonathan Chambers <jonathan.chambers@ansys.com>,
+ Peter Dennis Bartok <pbartok@novell.com>
+
+ * Font.cs:
+ - ToLogFont: Reworked to allow running under MS runtime and to
+ support it being called with both boxed structs and formatted
+ classes (MS runtime PtrToStructure cannot marshal boxed value
+ types, but Marshal.AsAny can)
+ - Switched all usage of LOGFONTA to more generic CharSet-driven
+ LOGFONT structure
+ - FromLogFont: Switched to use charset-agnostic GdipCreateFontFromLogfont
+ * gdipStructs.cs: Dropped LOGFONTA and LOGFONTW and switched to
+ CharSet-driven LOGFONT structure (needed because of ToLogFont fix)
+ * gdipFunctions.cs: Switched GdipGetLogFont, GdipCreateFontFromLogfont and
+ CreateFontIndirect to use LOGFONT structure, set to be CharSet=Auto
+ (needed because of ToLogFont fix)
+
+2006-02-18 Duncan Mak <duncan@novell.com>
+
+ * Graphics.cs (DrawBeziers): Patch from Alexander Olk to fix
+ possible IndexOutOfRangeException.
+
+2006-02-09 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Image.cs, Bitmap.cs: Removed unneeded casts
+ * Icon.cs: Fixed code to be 64bit safe
+
+2006-01-31 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * Font.cs: Fixes 77407
+
+2006-01-27 Sebastien Pouliot <sebastien@ximian.com>
+
+ * Font.cs: Ensure unmanaged memory is free correctly in ToLogFont
+ even if GDIPlus.CheckStatus throws an exception;
+ * Image.cs: Ensure unmanaged memory is free correctly even if
+ GDIPlus.CheckStatus throws an exception. Note: the SetPropertyItem use
+ case is unclear to me (and unimplemented in libgdiplus);
+ * Region.cs: Ensure unmanaged memory is free correctly in
+ GetRegionScans even if GDIPlus.CheckStatus throws an exception;
+
+2006-01-27 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * gdipFunctions.cs: New gdiplus imports
+ * Font.cs: Use gdiplus calls to get font height and size
+
+2006-01-26 Sebastien Pouliot <sebastien@ximian.com>
+
+ * FontFamily.cs: Free the memory allocated with Marshal.AllocHGlobal.
+ * Region.cs: Updated TODO to reflect current status.
+
+2006-01-24 Konstantin Triger <kostat@mainsoft.com>
+
+ * Font.jvm.cs, FontFamily.jvm.cs: use static container.
+
+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..4f45c85b6ef
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Font.cs
@@ -0,0 +1,659 @@
+//
+// 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, 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.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 float _size;
+
+ 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;
+ LOGFONT lf = new LOGFONT ();
+
+ // Sanity. Should we throw an exception?
+ if (Hfont == IntPtr.Zero) {
+ Font result = new Font ("Arial", (float)10.0, FontStyle.Regular);
+ return(result);
+ }
+
+ if ((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 {
+ LOGFONT lf = new LOGFONT ();
+ ToLogFont(lf);
+ Hfont = GDIPlus.CreateFontIndirect (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;
+ }
+ }
+
+ 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;
+ LOGFONT o = (LOGFONT)lf;
+ GDIPlus.GdipCreateFontFromLogfont (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)
+ {
+ if (graphics == null) {
+ throw new ArgumentNullException ("graphics");
+ }
+
+ if (Marshal.SizeOf(logFont) >= Marshal.SizeOf(typeof(LOGFONT))) {
+ GDIPlus.CheckStatus (GDIPlus.GdipGetLogFont(NativeObject, graphics.NativeObject, logFont));
+ }
+ }
+
+ public float GetHeight (Graphics graphics)
+ {
+ float size;
+
+ GDIPlus.GdipGetFontHeight (fontObject, graphics.NativeObject, out size);
+ return size;
+ }
+
+ public float GetHeight (float dpi)
+ {
+ float size;
+ GDIPlus.GdipGetFontHeightGivenDPI (fontObject, dpi, out size);
+ return size;
+ }
+
+ 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..63d08b6fcd9
--- /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;
+ _charset = original._charset;
+ }
+
+ 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 {
+ return FontFamily.Container.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..fc9704ad80a
--- /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)
+// Peter Dennis Bartok (pbartok@novell.com)
+//
+// Copyright (C) 2002/2004 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.Text;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing {
+
+ public sealed class FontFamily : MarshalByRefObject, IDisposable
+ {
+
+ static private FontFamily genericMonospace;
+ static private FontFamily genericSansSerif;
+ static private FontFamily genericSerif;
+ private string name;
+ internal IntPtr nativeFontFamily = IntPtr.Zero;
+
+ internal FontFamily(IntPtr fntfamily)
+ {
+ nativeFontFamily = fntfamily;
+ refreshName();
+ }
+
+ internal void refreshName()
+ {
+ StringBuilder sb;
+
+ if (nativeFontFamily == IntPtr.Zero)
+ return;
+
+ sb = new StringBuilder(GDIPlus.FACESIZE);
+ Status status = GDIPlus.GdipGetFamilyName (nativeFontFamily, sb, 0);
+ GDIPlus.CheckStatus (status);
+ name = sb.ToString();
+ }
+
+ //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..90042743762
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/FontFamily.jvm.cs
@@ -0,0 +1,233 @@
+//
+// 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;
+ internal static readonly awt.Container Container;
+
+ static FontFamily() {
+ Container = new awt.Container();
+ _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..f78266b4c54
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Graphics.cs
@@ -0,0 +1,2449 @@
+//
+// 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);
+ GDIPlus.XFree (vPtr);
+ 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 < 4)
+ return;
+
+ for (int i = 0; i < length - 1; 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 < 4)
+ return;
+
+ for (int i = 0; i < length - 1; 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..8ee79947772
--- /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)(bits.Scan0.ToInt64() + 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..4bb5c4395f0
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Image.cs
@@ -0,0 +1,798 @@
+//
+// 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, RawFormat);
+ 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);
+ }
+ finally {
+ 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);
+ try {
+ status = GDIPlus.GdipGetPropertyItem (nativeObject, propid, propSize, property);
+ GDIPlus.CheckStatus (status);
+ gdipProperty = (GdipPropertyItem) Marshal.PtrToStructure (property,
+ typeof (GdipPropertyItem));
+ GdipPropertyItem.MarshalTo (gdipProperty, item);
+ }
+ finally {
+ 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);
+ // FIXME: GdipSetPropertyItem isn't implemented in libgdiplus (but returns Ok)
+ // so who's freeing "property" ? GDI+ ?
+ }
+
+ // 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);
+ try {
+ 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]);
+ }
+ }
+ finally {
+ 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..9dbcb81a7c8
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Region.cs
@@ -0,0 +1,644 @@
+//
+// 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
+ [MonoTODO ("Region are limited to rectangles when using libgdiplus")]
+ 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;
+ }
+
+ 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);
+ }
+
+ 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
+ //
+
+ [MonoTODO ("GdipCombineRegionPath isn't implemented in libgdiplus")]
+ 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);
+ try {
+ status = GDIPlus.GdipGetRegionScans (nativeRegion, dest, out cnt, matrix.NativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+ finally {
+ // note: Marshal.FreeHGlobal is called from GDIPlus.FromUnManagedMemoryToRectangles
+ GDIPlus.FromUnManagedMemoryToRectangles (dest, rects);
+ }
+ return rects;
+ }
+
+ [MonoTODO ("GdipTransformRegion isn't implemented in libgdiplus")]
+ 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..0236a5223b1
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs
@@ -0,0 +1,1829 @@
+//
+// 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)
+// Peter Dennis Bartok (pbartok@novell.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.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);
+
+ // This causes crashes in Mono libgdiplus because this call
+ // occurs before all managed GDI objects are finalized
+ // When they are finalized they use the closed display and
+ // crash
+ //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);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipAddString (IntPtr graphics, string s, int len, IntPtr font, int style, float size, ref RectangleF layout, IntPtr format);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipAddStringI (IntPtr graphics, string s, int len, IntPtr font, int style, float size, ref Rectangle layout, IntPtr format);
+
+
+ // 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.Auto)]
+ internal static extern Status GdipGetLogFont(IntPtr font, IntPtr graphics, [MarshalAs(UnmanagedType.AsAny), Out] object logfontA);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreateFontFromDC(IntPtr hdc, out IntPtr font);
+ [DllImport("gdiplus.dll", SetLastError=true, CharSet=CharSet.Auto)]
+ internal static extern Status GdipCreateFontFromLogfont(IntPtr hdc, ref LOGFONT 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", CharSet=CharSet.Ansi)]
+ internal static extern Status GdipCreateFontFromHfont(IntPtr hdc, out IntPtr font, ref LOGFONT lf);
+
+ // This is win32/gdi, not gdiplus, but it's easier to keep in here, also see above comment
+ [DllImport("gdi32.dll", CallingConvention=CallingConvention.StdCall, CharSet = CharSet.Auto)]
+ internal static extern IntPtr CreateFontIndirect (ref LOGFONT logfont);
+ [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);
+
+ [DllImport ("libX11", EntryPoint="XFree")]
+ internal extern static void XFree (IntPtr data);
+
+ // 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 (ref 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", CharSet=CharSet.Unicode)]
+ internal static extern Status GdipGetFamilyName(IntPtr family, StringBuilder name, 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);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetFontSize (IntPtr font, out float size);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetFontHeight (IntPtr font, IntPtr graphics, out float height);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetFontHeightGivenDPI (IntPtr font, float dpi, out float height);
+
+
+ // 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)
+ {
+ // Make sure we have a valid 'whence'.
+ if ((whence < 0) || (whence > 2))
+ return -1;
+
+ // Invalidate the start_buf if we're actually going to call a Seek method.
+ start_buf_pos += start_buf_len;
+ start_buf_len = 0;
+
+ SeekOrigin origin;
+
+ // Translate 'whence' into a SeekOrigin enum member.
+ switch (whence)
+ {
+ case 0: origin = SeekOrigin.Begin; break;
+ case 1: origin = SeekOrigin.Current; break;
+ case 2: origin = SeekOrigin.End; break;
+
+ // The following line is redundant but necessary to avoid a
+ // "Use of unassigned local variable" error without actually
+ // initializing 'origin' to a dummy value.
+ default: return -1;
+ }
+
+ // Do the actual seek operation and return its result.
+ return stream.Seek ((long) offset, origin);
+ }
+
+ 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..6d9b49294bd
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/gdipStructs.cs
@@ -0,0 +1,206 @@
+//
+// 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.Auto)]
+ internal struct LOGFONT
+ {
+ 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..12d76b8d478
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing_test.dll.sources
@@ -0,0 +1,57 @@
+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/LinearGradientBrushTest.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..83d66580ac2
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/ChangeLog
@@ -0,0 +1,34 @@
+2006-01-25 Boris Kirzner <borisk@mainsoft.com>
+ * Test.vmwcsproj,Test.dotnet.csproj: added reference to NUnit projects.
+
+2006-01-23 Boris Kirzner <borisk@mainsoft.com>
+ * Test.vmwcsproj: perform java output validation.
+
+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..11fd8a4f1a6
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/ChangeLog
@@ -0,0 +1,24 @@
+2006-01-25 Boris Kirzner <borisk@mainsoft.com>
+ * System.Drawing.Test.dotnet.sln, System.Drawing.Test.sln:
+ added NUnit projects.
+
+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..6520cf2fe71
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/ChangeLog
@@ -0,0 +1,40 @@
+2006-01-25 Boris Kirzner <borisk@mainsoft.com>
+ * DrawingTestHelper_java.vmwcsproj, DrawingTestHelper.csproj:
+ projects updates for TARGET_JVM.
+
+2006-01-23 Boris Kirzner <borisk@mainsoft.com>
+ * DrawingTestHelper_java.vmwcsproj: include PDComparer.cs.
+
+2006-01-22 Boris Kirzner <borisk@mainsoft.com>
+ * DrawingTestHelper.csproj: include PDComparer.cs.
+ * DrawingTest.cs: implement IDisposable.
+
+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..8f0ba78e195
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/DrawingTest.cs
@@ -0,0 +1,665 @@
+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 : IDisposable {
+
+ 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;
+ }
+ #region IDisposable Members
+
+ public void Dispose()
+ {
+ // TODO: Add DrawingTest.Dispose implementation
+ if (_graphics != null) {
+ _graphics.Dispose();
+ _graphics = null;
+ }
+ }
+
+ #endregion
+ }
+
+#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 = @"";
+ 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 );
+ GC.Collect();
+ 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..784b95bf402
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/DrawingTestHelper.csproj
@@ -0,0 +1,121 @@
+<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\"
+ 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.dll.J2EE"
+ Project = "{39CC8FF7-EF1A-41A1-B727-42684211ECD1}"
+ Package = "{83B010C7-76FC-4FAD-A26C-00D7EFE60256}"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "AssemblyInfo.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "DrawingTest.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "PDComparer.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..619e0f6c8b8
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/DrawingTestHelper_java.vmwcsproj
@@ -0,0 +1,30 @@
+<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="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="rt" AssemblyName="rt" HintPath="..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\jre5\rt.dll" Private="False"/>
+ <Reference Name="nunit.framework.dll.J2EE" Project="{39CC8FF7-EF1A-41A1-B727-42684211ECD1}" Package="{83B010C7-76FC-4FAD-A26C-00D7EFE60256}"/>
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File RelPath="AssemblyInfo.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="DrawingTest.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="PDComparer.cs" SubType="Code" BuildAction="Compile"/>
+ </Include>
+ </Files>
+ <UserProperties REFS.JarPath.j2se.helpers="..\..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\J2SE.Helpers.jar" REFS.JarPath.vmwutils="..\..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\vmwutils.jar" REFS.JarPath.system="..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\System.jar" REFS.JarPath.rt="..\..\Program Files\Mainsoft\Visual MainWin for J2EE\j2sdk1.4\lib\rt.jar" project.JDKType="1.5.0_05" REFS.JarPath.system.drawing="C:\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\System.Drawing.jar" REFS.JarPath.system.xml="..\..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\System.Xml.jar"/>
+ </CSHARP>
+ <VisualMainWin><Project Prop2023="1.5.0_05" Prop2024="" Prop2026="" Prop2015="" Version="1.7.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="-1" Name="Debug_Java"/><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="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"/></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..165feff5022
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/System.Drawing.Test.dotnet.sln
@@ -0,0 +1,99 @@
+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
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit.core.dll.J2EE", "..\..\..\..\nunit20\core\nunit.core.dll.J2EE.vmwcsproj", "{7C52A6A5-71ED-4468-9564-2FF5CD6E6E6C}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit.framework.dll.J2EE", "..\..\..\..\nunit20\framework\nunit.framework.dll.J2EE.vmwcsproj", "{39CC8FF7-EF1A-41A1-B727-42684211ECD1}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit.util.dll.J2EE", "..\..\..\..\nunit20\util\nunit.util.dll.J2EE.vmwcsproj", "{36BE0465-4DE4-44CE-AF8D-6E50D0C40BC6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit-console.J2EE", "..\..\..\..\nunit20\nunit-console\nunit-console.J2EE.vmwcsproj", "{EE901CF2-A263-471C-AEE2-2400A7105ABE}"
+ 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
+ {7C52A6A5-71ED-4468-9564-2FF5CD6E6E6C}.Debug.ActiveCfg = Debug_Java|.NET
+ {7C52A6A5-71ED-4468-9564-2FF5CD6E6E6C}.Debug.Build.0 = Debug_Java|.NET
+ {7C52A6A5-71ED-4468-9564-2FF5CD6E6E6C}.Debug_Java.ActiveCfg = Debug_Java|.NET
+ {7C52A6A5-71ED-4468-9564-2FF5CD6E6E6C}.Debug_Java.Build.0 = Debug_Java|.NET
+ {7C52A6A5-71ED-4468-9564-2FF5CD6E6E6C}.Release.ActiveCfg = Release_Java|.NET
+ {7C52A6A5-71ED-4468-9564-2FF5CD6E6E6C}.Release.Build.0 = Release_Java|.NET
+ {7C52A6A5-71ED-4468-9564-2FF5CD6E6E6C}.Release_Java.ActiveCfg = Release_Java|.NET
+ {7C52A6A5-71ED-4468-9564-2FF5CD6E6E6C}.Release_Java.Build.0 = Release_Java|.NET
+ {39CC8FF7-EF1A-41A1-B727-42684211ECD1}.Debug.ActiveCfg = Debug_Java|.NET
+ {39CC8FF7-EF1A-41A1-B727-42684211ECD1}.Debug.Build.0 = Debug_Java|.NET
+ {39CC8FF7-EF1A-41A1-B727-42684211ECD1}.Debug_Java.ActiveCfg = Debug_Java|.NET
+ {39CC8FF7-EF1A-41A1-B727-42684211ECD1}.Debug_Java.Build.0 = Debug_Java|.NET
+ {39CC8FF7-EF1A-41A1-B727-42684211ECD1}.Release.ActiveCfg = Release_Java|.NET
+ {39CC8FF7-EF1A-41A1-B727-42684211ECD1}.Release.Build.0 = Release_Java|.NET
+ {39CC8FF7-EF1A-41A1-B727-42684211ECD1}.Release_Java.ActiveCfg = Release_Java|.NET
+ {39CC8FF7-EF1A-41A1-B727-42684211ECD1}.Release_Java.Build.0 = Release_Java|.NET
+ {36BE0465-4DE4-44CE-AF8D-6E50D0C40BC6}.Debug.ActiveCfg = Debug_Java|.NET
+ {36BE0465-4DE4-44CE-AF8D-6E50D0C40BC6}.Debug.Build.0 = Debug_Java|.NET
+ {36BE0465-4DE4-44CE-AF8D-6E50D0C40BC6}.Debug_Java.ActiveCfg = Debug_Java|.NET
+ {36BE0465-4DE4-44CE-AF8D-6E50D0C40BC6}.Debug_Java.Build.0 = Debug_Java|.NET
+ {36BE0465-4DE4-44CE-AF8D-6E50D0C40BC6}.Release.ActiveCfg = Release_Java|.NET
+ {36BE0465-4DE4-44CE-AF8D-6E50D0C40BC6}.Release.Build.0 = Release_Java|.NET
+ {36BE0465-4DE4-44CE-AF8D-6E50D0C40BC6}.Release_Java.ActiveCfg = Release_Java|.NET
+ {36BE0465-4DE4-44CE-AF8D-6E50D0C40BC6}.Release_Java.Build.0 = Release_Java|.NET
+ {EE901CF2-A263-471C-AEE2-2400A7105ABE}.Debug.ActiveCfg = Debug_Java|.NET
+ {EE901CF2-A263-471C-AEE2-2400A7105ABE}.Debug.Build.0 = Debug_Java|.NET
+ {EE901CF2-A263-471C-AEE2-2400A7105ABE}.Debug_Java.ActiveCfg = Debug_Java|.NET
+ {EE901CF2-A263-471C-AEE2-2400A7105ABE}.Debug_Java.Build.0 = Debug_Java|.NET
+ {EE901CF2-A263-471C-AEE2-2400A7105ABE}.Release.ActiveCfg = Release_Java|.NET
+ {EE901CF2-A263-471C-AEE2-2400A7105ABE}.Release.Build.0 = Release_Java|.NET
+ {EE901CF2-A263-471C-AEE2-2400A7105ABE}.Release_Java.ActiveCfg = Release_Java|.NET
+ {EE901CF2-A263-471C-AEE2-2400A7105ABE}.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/System.Drawing.Test.sln b/mcs/class/System.Drawing/Test/DrawingTest/System.Drawing.Test.sln
new file mode 100644
index 00000000000..5f472abb958
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/System.Drawing.Test.sln
@@ -0,0 +1,84 @@
+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
+Project("{83B010C7-76FC-4FAD-A26C-00D7EFE60256}") = "nunit.core.dll.J2EE", "..\..\..\..\nunit20\core\nunit.core.dll.J2EE.vmwcsproj", "{7C52A6A5-71ED-4468-9564-2FF5CD6E6E6C}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{83B010C7-76FC-4FAD-A26C-00D7EFE60256}") = "nunit.framework.dll.J2EE", "..\..\..\..\nunit20\framework\nunit.framework.dll.J2EE.vmwcsproj", "{39CC8FF7-EF1A-41A1-B727-42684211ECD1}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{83B010C7-76FC-4FAD-A26C-00D7EFE60256}") = "nunit-console.J2EE", "..\..\..\..\nunit20\nunit-console\nunit-console.J2EE.vmwcsproj", "{EE901CF2-A263-471C-AEE2-2400A7105ABE}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{83B010C7-76FC-4FAD-A26C-00D7EFE60256}") = "nunit.util.dll.J2EE", "..\..\..\..\nunit20\util\nunit.util.dll.J2EE.vmwcsproj", "{36BE0465-4DE4-44CE-AF8D-6E50D0C40BC6}"
+ 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
+ {7C52A6A5-71ED-4468-9564-2FF5CD6E6E6C}.Debug.ActiveCfg = Debug|.NET
+ {7C52A6A5-71ED-4468-9564-2FF5CD6E6E6C}.Debug.Build.0 = Debug|.NET
+ {7C52A6A5-71ED-4468-9564-2FF5CD6E6E6C}.Debug_Java.ActiveCfg = Debug_Java|.NET
+ {7C52A6A5-71ED-4468-9564-2FF5CD6E6E6C}.Debug_Java.Build.0 = Debug_Java|.NET
+ {7C52A6A5-71ED-4468-9564-2FF5CD6E6E6C}.Release_Java.ActiveCfg = Release_Java|.NET
+ {7C52A6A5-71ED-4468-9564-2FF5CD6E6E6C}.Release_Java.Build.0 = Release_Java|.NET
+ {39CC8FF7-EF1A-41A1-B727-42684211ECD1}.Debug.ActiveCfg = Debug|.NET
+ {39CC8FF7-EF1A-41A1-B727-42684211ECD1}.Debug.Build.0 = Debug|.NET
+ {39CC8FF7-EF1A-41A1-B727-42684211ECD1}.Debug_Java.ActiveCfg = Debug_Java|.NET
+ {39CC8FF7-EF1A-41A1-B727-42684211ECD1}.Debug_Java.Build.0 = Debug_Java|.NET
+ {39CC8FF7-EF1A-41A1-B727-42684211ECD1}.Release_Java.ActiveCfg = Release_Java|.NET
+ {39CC8FF7-EF1A-41A1-B727-42684211ECD1}.Release_Java.Build.0 = Release_Java|.NET
+ {EE901CF2-A263-471C-AEE2-2400A7105ABE}.Debug.ActiveCfg = Debug|.NET
+ {EE901CF2-A263-471C-AEE2-2400A7105ABE}.Debug.Build.0 = Debug|.NET
+ {EE901CF2-A263-471C-AEE2-2400A7105ABE}.Debug_Java.ActiveCfg = Debug_Java|.NET
+ {EE901CF2-A263-471C-AEE2-2400A7105ABE}.Debug_Java.Build.0 = Debug_Java|.NET
+ {EE901CF2-A263-471C-AEE2-2400A7105ABE}.Release_Java.ActiveCfg = Release_Java|.NET
+ {EE901CF2-A263-471C-AEE2-2400A7105ABE}.Release_Java.Build.0 = Release_Java|.NET
+ {36BE0465-4DE4-44CE-AF8D-6E50D0C40BC6}.Debug.ActiveCfg = Debug|.NET
+ {36BE0465-4DE4-44CE-AF8D-6E50D0C40BC6}.Debug.Build.0 = Debug|.NET
+ {36BE0465-4DE4-44CE-AF8D-6E50D0C40BC6}.Debug_Java.ActiveCfg = Debug_Java|.NET
+ {36BE0465-4DE4-44CE-AF8D-6E50D0C40BC6}.Debug_Java.Build.0 = Debug_Java|.NET
+ {36BE0465-4DE4-44CE-AF8D-6E50D0C40BC6}.Release_Java.ActiveCfg = Release_Java|.NET
+ {36BE0465-4DE4-44CE-AF8D-6E50D0C40BC6}.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..c7072156ba8
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/Bitmap.cs
@@ -0,0 +1,60 @@
+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 ("Bitmap1.png");
+ t.Graphics.DrawImageUnscaled (b, 0, 0);
+ DrawingTest.ShowForms = false;
+ }
+
+ [TearDown]
+ public void TearDown ()
+ {
+ if (t != null)
+ t.Dispose ();
+ }
+
+ [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]
+ 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..1de07e7e440
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/Brush.cs
@@ -0,0 +1,146 @@
+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() {
+ if (t != null)
+ t.Dispose ();
+ }
+
+ [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]
+ [Category("NotWorking")]
+ 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]
+ [Category("NotWorking")]
+ 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]
+ [Category("NotWorking")]
+ 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]
+ [Category("NotWorking")]
+ 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]
+ [Category("NotWorking")]
+ 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..be36e2a7ce4
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/ChangeLog
@@ -0,0 +1,83 @@
+2006-01-25 Boris Kirzner <borisk@maonsoft.com>
+ * Graphics.cs: added #ifdef for TARGET_JVM.
+
+2006-01-22 Boris Kirzner <borisk@mainsoft.com>
+ * Bitmap.cs, Brush.cs, Graphics.cs, GraphicsPath.cs, Image.cs, Pen.cs,
+ Region.cs: tests refactoring.
+
+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..370f79ca856
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/Graphics.cs
@@ -0,0 +1,4079 @@
+//
+// 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);
+ }
+
+ [TearDown]
+ public void TearDown ()
+ {
+ if (t != null)
+ t.Dispose ();
+ }
+
+ [Test]
+ 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]
+ 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]
+ [Category("NotWorking")]
+ 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]
+ 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() {
+ if (t != null)
+ t.Dispose ();
+ }
+
+ [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() {
+ if (t != null)
+ t.Dispose ();
+ }
+
+ [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 ()
+ {
+ if (t != null)
+ t.Dispose ();
+ }
+
+ [Test]
+ public virtual 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]
+ public virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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]
+ [Category("NotWorking")]
+ public virtual 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]
+ [Category("NotWorking")]
+ public virtual 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]
+ [Category("NotWorking")]
+ public virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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
+ [Category("NotWorking")]
+ public virtual 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 virtual 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 virtual void EnumerateMetafile() {
+ }
+
+ [Test]
+ public virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual void FlushTest() {
+ t.Graphics.Flush();
+ t.Graphics.Flush(FlushIntention.Flush);
+ }
+
+ [Test]
+ public virtual 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 virtual 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]
+ [Category("NotWorking")]
+ public virtual 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
+ [Category("NotWorking")]
+ public virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ #endregion
+
+ #region GraphicsFixturePropCompositingMode
+
+ [TestFixture]
+ public class GraphicsFixturePropCompositingMode1 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropCompositingMode1");
+ t.Graphics.CompositingMode = CompositingMode.SourceCopy;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropCompositingMode2 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropCompositingMode2");
+ t.Graphics.CompositingMode = CompositingMode.SourceOver;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ #endregion
+
+ #region GraphicsFixturePropInterpolationMode
+
+ [TestFixture]
+ public class GraphicsFixturePropInterpolationMode1 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropInterpolationMode1");
+ t.Graphics.InterpolationMode = InterpolationMode.Bilinear;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropInterpolationMode2 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropInterpolationMode2");
+ t.Graphics.InterpolationMode = InterpolationMode.Bicubic;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ #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;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ #endregion
+
+ #region GraphicsFixturePropPageUnit
+
+ [TestFixture]
+ public class GraphicsFixturePropPageUnit1 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropPageUnit1");
+ t.Graphics.PageUnit = GraphicsUnit.Display;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ [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;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void BeginContainerTest() {
+ base.BeginContainerTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void EndContainerState() {
+ base.EndContainerState ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropPageUnit3 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropPageUnit3");
+ t.Graphics.PageUnit = GraphicsUnit.Inch;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void IsVisible4Float() {
+ base.IsVisible4Float ();
+ }
+
+ [Test]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ [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;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawClosedCurveTest() {
+ base.DrawClosedCurveTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropPageUnit5 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropPageUnit5");
+
+ t.Graphics.PageUnit = GraphicsUnit.Pixel;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ [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;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawClosedCurveTest() {
+ base.DrawClosedCurveTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawCurveTest() {
+ base.DrawCurveTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawCurveTestF() {
+ base.DrawCurveTestF ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawEllipseTest() {
+ base.DrawEllipseTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawEllipseTestF() {
+ base.DrawEllipseTestF ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawPathTest() {
+ base.DrawPathTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void EndContainerState() {
+ base.EndContainerState ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MultiplyTransform() {
+ base.MultiplyTransform ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MultiplyTransformMatrixOrder1() {
+ base.MultiplyTransformMatrixOrder1 ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void RotateTransformAngleMatrixOrder1() {
+ base.RotateTransformAngleMatrixOrder1 ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void TranslateTransformAngleMatrixOrder() {
+ base.TranslateTransformAngleMatrixOrder ();
+ }
+ }
+
+ // [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;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropPixelOffsetMode1 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropPixelOffsetMode1");
+ t.Graphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropPixelOffsetMode2 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropPixelOffsetMode2");
+ t.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
+
+ st["TransformPointsPointF:2"] = TOLERANCE * 3.0f;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ #endregion
+
+ #region GraphicsFixturePropRenderingOrigin
+
+ [TestFixture]
+ [Category("NotWorking")]
+ public class GraphicsFixturePropRenderingOrigin : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropRenderingOrigin");
+ t.Graphics.RenderingOrigin = new Point(12, 23);
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void BeginContainerTest() {
+ base.BeginContainerTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void BeginContainerTest_2() {
+ base.BeginContainerTest_2 ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void ClearTest() {
+ base.ClearTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawArcTest() {
+ base.DrawArcTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawBezierTest() {
+ base.DrawBezierTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawBeziersTest() {
+ base.DrawBeziersTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawClosedCurveTest() {
+ base.DrawClosedCurveTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawCurveTest() {
+ base.DrawCurveTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawCurveTestF() {
+ base.DrawCurveTestF ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawEllipseTest() {
+ base.DrawEllipseTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawEllipseTestF() {
+ base.DrawEllipseTestF ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawLineTest() {
+ base.DrawLineTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawLineTestF() {
+ base.DrawLineTestF ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawLinesTest() {
+ base.DrawLinesTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawLinesTestF() {
+ base.DrawLinesTestF ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawPathTest() {
+ base.DrawPathTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawPieTestF() {
+ base.DrawPieTestF ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawPieTest() {
+ base.DrawPieTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawPolygonPoint() {
+ base.DrawPolygonPoint ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawPolygonPointF() {
+ base.DrawPolygonPointF ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawRectangleFloat() {
+ base.DrawRectangleFloat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawRectanglesRectangleF() {
+ base.DrawRectanglesRectangleF ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawRectanglesRectangle() {
+ base.DrawRectanglesRectangle ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void EndContainerState() {
+ base.EndContainerState ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void EnumerateMetafile() {
+ base.EnumerateMetafile ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void ExcludeClipRegion() {
+ base.ExcludeClipRegion ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void FillClosedCurvePointFillModeTension() {
+ base.FillClosedCurvePointFillModeTension ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void FillClosedCurvePointFFillModeTension() {
+ base.FillClosedCurvePointFFillModeTension ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void FillEllipse() {
+ base.FillEllipse ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void FillEllipseFloat() {
+ base.FillEllipseFloat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void FillPathEllipse() {
+ base.FillPathEllipse ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void FillPieFloat() {
+ base.FillPieFloat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void FillPolygonPointFillMode() {
+ base.FillPolygonPointFillMode ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void FillPolygonPointFFillMode() {
+ base.FillPolygonPointFFillMode ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void FillRectangle() {
+ base.FillRectangle ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void FillRectangleFloat() {
+ base.FillRectangleFloat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void FillRectanglesRectangle() {
+ base.FillRectanglesRectangle ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void FillRectanglesRectangleF() {
+ base.FillRectanglesRectangleF ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void FillRegionRectangle() {
+ base.FillRegionRectangle ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void FlushTest() {
+ base.FlushTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void IsVisible4Float() {
+ base.IsVisible4Float ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MultiplyTransform() {
+ base.MultiplyTransform ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MultiplyTransformMatrixOrder() {
+ base.MultiplyTransformMatrixOrder ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MultiplyTransformMatrixOrder1() {
+ base.MultiplyTransformMatrixOrder1 ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void ResetClipIntersectClipRectangleF() {
+ base.ResetClipIntersectClipRectangleF ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void SaveRestoreTranslate() {
+ base.SaveRestoreTranslate ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void RotateTransformAngleMatrixOrder() {
+ base.RotateTransformAngleMatrixOrder ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void RotateTransformAngleMatrixOrder1() {
+ base.RotateTransformAngleMatrixOrder1 ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void ScaleTransformFloatMatrixOrder() {
+ base.ScaleTransformFloatMatrixOrder ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void ScaleTransformFloatMatrixOrder1() {
+ base.ScaleTransformFloatMatrixOrder1 ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void SetClipRegionCombine() {
+ base.SetClipRegionCombine ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void TransformPointsPointF() {
+ base.TransformPointsPointF ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void TranslateClipFloat() {
+ base.TranslateClipFloat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void TranslateTransformAngleMatrixOrder() {
+ base.TranslateTransformAngleMatrixOrder ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void TranslateTransformAngleMatrixOrder1() {
+ base.TranslateTransformAngleMatrixOrder1 ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void TransfromPageScaleUnits() {
+ base.TransfromPageScaleUnits ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void TransfromPageScaleUnits_2() {
+ base.TransfromPageScaleUnits_2 ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void TransfromPageScaleUnits_3() {
+ base.TransfromPageScaleUnits_3 ();
+ }
+ }
+
+ #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;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropSmoothingMode1 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropSmoothingMode1");
+ t.Graphics.SmoothingMode = SmoothingMode.HighSpeed;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ #endregion
+
+ #region GraphicsFixturePropTextContrast
+
+ [TestFixture]
+ public class GraphicsFixturePropTextContrast : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropTextContrast");
+ t.Graphics.TextContrast = 9;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ #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 ()
+ {
+ if (t != null)
+ t.Dispose ();
+ }
+
+ [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]
+ public class GraphicsFixturePropTextRenderingHint : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropTextRenderingHint");
+ t.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropTextRenderingHint1 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropTextRenderingHint1");
+ t.Graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropTextRenderingHint2 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropTextRenderingHint2");
+ t.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropTextRenderingHint3 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropTextRenderingHint3");
+ t.Graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropTextRenderingHint4 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropTextRenderingHint4");
+ t.Graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropTextRenderingHint5 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropTextRenderingHint5");
+ t.Graphics.TextRenderingHint = TextRenderingHint.SystemDefault;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ #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;
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconTest() {
+ base.DrawIconTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawIconUnstretchedTest() {
+ base.DrawIconUnstretchedTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawImageUnscaledTest() {
+ base.DrawImageUnscaledTest ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void DrawStringFloatFormat() {
+ base.DrawStringFloatFormat ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureCharacterRangesRegions() {
+ base.MeasureCharacterRangesRegions ();
+ }
+
+ [Test]
+ [Category("NotWorking")]
+ public override void MeasureStringSizeFFormatInts() {
+ base.MeasureStringSizeFFormatInts ();
+ }
+ }
+
+ #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..55909dff820
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/GraphicsPath.cs
@@ -0,0 +1,5694 @@
+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;
+ }
+
+ [TearDown]
+ public void TearDown ()
+ {
+ if (t != null)
+ t.Dispose ();
+ }
+
+ [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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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..5b7165966e7
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/Image.cs
@@ -0,0 +1,271 @@
+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);
+ }
+
+ [TearDown]
+ public void TearDown ()
+ {
+ if (t != null)
+ t.Dispose ();
+ }
+
+ [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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ public void GetPropertyItem () {
+ Assert.Fail ("Test not implemented - undocumented parameter");
+ }
+ [Test]
+ [Category ("NotWorking")]
+ public void RemovePropertyItem () {
+ Assert.Fail ("Test not implemented - undocumented parameter");
+ }
+ static bool ThumbnailCallback() {
+ return false;
+ }
+ [Test]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ public void Save_Stream_ImageCodecInfo_EncoderParameters () {
+ using (FileStream w = new FileStream ("test.png", FileMode.OpenOrCreate)) {
+ foreach (ImageCodecInfo i in ImageCodecInfo.GetImageEncoders()) {
+ if (i.FilenameExtension.ToLower().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]
+ public void Save_string_ImageCodecInfo_EncoderParameters () {
+ foreach (ImageCodecInfo i in ImageCodecInfo.GetImageEncoders()) {
+ if (i.FilenameExtension.ToLower().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]
+ [Category ("NotWorking")]
+ public void SaveAdd () {
+ Assert.Fail ("Test not implemented");
+ }
+ [Test]
+ [Category ("NotWorking")]
+ 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]
+ public void HorizontalResolution () {
+ Assert.AreEqual (96, t.Bitmap.HorizontalResolution);
+ }
+ [Test]
+ public void VerticalResolution () {
+ Assert.AreEqual (96, t.Bitmap.VerticalResolution);
+ }
+ [Test]
+ public void PixelFormatTest () {
+ Assert.AreEqual (PixelFormat.Format32bppArgb, t.Bitmap.PixelFormat);
+ }
+ [Test]
+ [Category ("NotWorking")]
+ public void PropertyIdList () {
+ Assert.AreEqual (new int [0], t.Bitmap.PropertyIdList);
+ }
+ [Test]
+ [Category ("NotWorking")]
+ 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..be83d18e833
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/Pen.cs
@@ -0,0 +1,823 @@
+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;
+ }
+
+ [TearDown]
+ public void TearDown ()
+ {
+ if (t != null)
+ t.Dispose ();
+ }
+
+ #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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ 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]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ 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]
+ 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]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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..40e3dae8fac
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/Region.cs
@@ -0,0 +1,231 @@
+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);
+ }
+
+ [TearDown]
+ public void TearDown ()
+ {
+ if (t != null)
+ t.Dispose ();
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ public void ctor_RectangleF () {
+ Region r1 = new Region (rect);
+ Assert.AreEqual (r.GetRegionData ().Data,
+ r1.GetRegionData ().Data);
+ }
+ [Test]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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]
+ [Category ("NotWorking")]
+ 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..16c895e47c2
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/ChangeLog
@@ -0,0 +1,73 @@
+2006-03-22 Sebastien Pouliot <sebastien@ximian.com>
+
+ * LinearGradientBrushTest.cs: New. Some unit tests (moslty failing).
+
+2006-03-14 Sebastien Pouliot <sebastien@ximian.com>
+
+ * TestMatrix.cs: Added new test cases to test libgdiplus validations.
+
+2006-03-13 Sebastien Pouliot <sebastien@ximian.com>
+
+ * GraphicsPathTest.cs: Added new test cases for SetMarkers,
+ ClearMarkers, CloseFigure and CloseAllFigures on an empty path.
+
+2006-01-27 Sebastien Pouliot <sebastien@ximian.com>
+
+ * GraphicsPathTest.cs: Removed "NotWorking" from existing Flatten
+ tests and added more test cases (for each type of shape).
+
+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..8df24d6de24
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/GraphicsPathTest.cs
@@ -0,0 +1,1292 @@
+//
+// 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);
+ }
+
+ private void ComparePaths (GraphicsPath expected, GraphicsPath actual)
+ {
+ Assert.AreEqual (expected.PointCount, actual.PointCount, "PointCount");
+ for (int i = 0; i < expected.PointCount; i++) {
+ Assert.AreEqual (expected.PathPoints[i], actual.PathPoints[i], "PathPoints-" + i.ToString ());
+ Assert.AreEqual (expected.PathTypes[i], actual.PathTypes[i], "PathTypes-" + i.ToString ());
+ }
+ }
+
+ private void CompareFlats (GraphicsPath flat, GraphicsPath original)
+ {
+ Assert.IsTrue (flat.PointCount >= original.PointCount, "PointCount");
+ for (int i = 0; i < flat.PointCount; i++) {
+ Assert.IsTrue (flat.PathTypes[i] != 3, "PathTypes-" + i.ToString ());
+ }
+ }
+
+ [Test]
+ public void Flatten_Empty ()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ GraphicsPath clone = (GraphicsPath) path.Clone ();
+ // this is a no-op as there's nothing in the path
+ path.Flatten ();
+ ComparePaths (path, clone);
+ }
+
+ [Test]
+ public void Flatten_Null ()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ GraphicsPath clone = (GraphicsPath) path.Clone ();
+ // this is a no-op as there's nothing in the path
+ // an no matrix to apply
+ path.Flatten (null);
+ ComparePaths (path, clone);
+ }
+
+ [Test]
+ public void Flatten_NullFloat ()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ GraphicsPath clone = (GraphicsPath) path.Clone ();
+ // this is a no-op as there's nothing in the path
+ // an no matrix to apply
+ path.Flatten (null, 1f);
+ ComparePaths (path, clone);
+ }
+
+ [Test]
+ public void Flatten_Arc ()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ path.AddArc (0f, 0f, 100f, 100f, 30, 30);
+ GraphicsPath clone = (GraphicsPath) path.Clone ();
+ path.Flatten ();
+ CompareFlats (path, clone);
+ }
+
+ [Test]
+ public void Flatten_Bezier ()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ path.AddBezier (0, 0, 100, 100, 30, 30, 60, 60);
+ GraphicsPath clone = (GraphicsPath) path.Clone ();
+ path.Flatten ();
+ CompareFlats (path, clone);
+ }
+
+ [Test]
+ public void Flatten_ClosedCurve ()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ path.AddClosedCurve (new Point[4] {
+ new Point (0, 0), new Point (40, 20),
+ new Point (20, 40), new Point (40, 40)
+ });
+ GraphicsPath clone = (GraphicsPath) path.Clone ();
+ path.Flatten ();
+ CompareFlats (path, clone);
+ }
+
+ [Test]
+ public void Flatten_Curve ()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ path.AddCurve (new Point[4] {
+ new Point (0, 0), new Point (40, 20),
+ new Point (20, 40), new Point (40, 40)
+ });
+ GraphicsPath clone = (GraphicsPath) path.Clone ();
+ path.Flatten ();
+ CompareFlats (path, clone);
+ }
+
+ [Test]
+ public void Flatten_Ellipse ()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ path.AddEllipse (10f, 10f, 100f, 100f);
+ GraphicsPath clone = (GraphicsPath) path.Clone ();
+ path.Flatten ();
+ CompareFlats (path, clone);
+ }
+
+ [Test]
+ public void Flatten_Line ()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ path.AddLine (10f, 10f, 100f, 100f);
+ GraphicsPath clone = (GraphicsPath) path.Clone ();
+ path.Flatten ();
+ ComparePaths (path, clone);
+ }
+
+ [Test]
+ public void Flatten_Pie ()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ path.AddPie (0, 0, 100, 100, 30, 30);
+ GraphicsPath clone = (GraphicsPath) path.Clone ();
+ path.Flatten ();
+ CompareFlats (path, clone);
+ }
+
+ [Test]
+ public void Flatten_Polygon ()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ path.AddPolygon (new Point[4] {
+ new Point (0, 0), new Point (10, 10),
+ new Point (20, 20), new Point (40, 40)
+ });
+ GraphicsPath clone = (GraphicsPath) path.Clone ();
+ path.Flatten ();
+ ComparePaths (path, clone);
+ }
+
+ [Test]
+ public void Flatten_Rectangle ()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ path.AddRectangle (new Rectangle (0, 0, 100, 100));
+ GraphicsPath clone = (GraphicsPath) path.Clone ();
+ path.Flatten ();
+ ComparePaths (path, clone);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Warp_Null ()
+ {
+ new GraphicsPath ().Warp (null, new RectangleF ());
+ }
+
+ [Test]
+ public void SetMarkers_EmptyPath ()
+ {
+ new GraphicsPath ().SetMarkers ();
+ }
+
+ [Test]
+ public void ClearMarkers_EmptyPath ()
+ {
+ new GraphicsPath ().ClearMarkers ();
+ }
+
+ [Test]
+ public void CloseFigure_EmptyPath ()
+ {
+ new GraphicsPath ().CloseFigure ();
+ }
+
+ [Test]
+ public void CloseAllFigures_EmptyPath ()
+ {
+ new GraphicsPath ().CloseAllFigures ();
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/LinearGradientBrushTest.cs b/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/LinearGradientBrushTest.cs
new file mode 100644
index 00000000000..1bdf83350dc
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/LinearGradientBrushTest.cs
@@ -0,0 +1,494 @@
+//
+// System.Drawing.Drawing2D.LinearGradientBrush 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.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 LinearGradientBrushTest {
+
+ private Point pt1;
+ private Point pt2;
+ private Color c1;
+ private Color c2;
+ private LinearGradientBrush default_brush;
+ private Matrix empty_matrix;
+
+ [TestFixtureSetUp]
+ public void FixtureSetUp ()
+ {
+ pt1 = new Point (0, 0);
+ pt2 = new Point (32, 32);
+ c1 = Color.Blue;
+ c2 = Color.Red;
+ default_brush = new LinearGradientBrush (pt1, pt2, c1, c2);
+ empty_matrix = new Matrix ();
+ }
+
+ private void CheckDefaultRectangle (string msg, RectangleF rect)
+ {
+ Assert.AreEqual (pt1.X, rect.X, msg + ".Rectangle.X");
+ Assert.AreEqual (pt1.Y, rect.Y, msg + ".Rectangle.Y");
+ Assert.AreEqual (pt2.X, rect.Width, msg + ".Rectangle.Width");
+ Assert.AreEqual (pt2.Y, rect.Height, msg + ".Rectangle.Height");
+ }
+
+ private void CheckEmptyMatrix (Matrix matrix)
+ {
+ float[] elements = matrix.Elements;
+ Assert.AreEqual (1, elements[0], "matrix.0");
+ Assert.AreEqual (0, elements[1], "matrix.1");
+ Assert.AreEqual (0, elements[2], "matrix.2");
+ Assert.AreEqual (1, elements[3], 0.1, "matrix.3");
+ Assert.AreEqual (0, elements[4], "matrix.4");
+ Assert.AreEqual (0, elements[5], "matrix.5");
+ }
+
+ private void CheckDefaultMatrix (Matrix matrix)
+ {
+ float[] elements = matrix.Elements;
+ Assert.AreEqual (1, elements[0], 0.1, "matrix.0");
+ Assert.AreEqual (1, elements[1], 0.1, "matrix.1");
+ Assert.AreEqual (-1, elements[2], 0.1, "matrix.2");
+ Assert.AreEqual (1, elements[3], 0.1, "matrix.3");
+ Assert.AreEqual (16, elements[4], "matrix.4");
+ Assert.AreEqual (-16, elements[5], "matrix.5");
+ }
+
+ [Test]
+ [NUnit.Framework.Category ("NotWorking")]
+ public void Constructor4 ()
+ {
+ LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
+ CheckDefaultRectangle ("4", lgb.Rectangle);
+ Assert.AreEqual (1, lgb.Blend.Factors.Length, "Blend.Factors");
+ Assert.AreEqual (1, lgb.Blend.Factors [0], "Blend.Factors [0]");
+ Assert.AreEqual (1, lgb.Blend.Positions.Length, "Blend.Positions");
+ Assert.IsFalse (lgb.GammaCorrection, "GammaCorrection");
+ Assert.AreEqual (2, lgb.LinearColors.Length, "LinearColors");
+ Assert.IsNotNull (lgb.Transform, "Transform");
+ CheckDefaultMatrix (lgb.Transform);
+
+ Assert.AreEqual (WrapMode.Tile, lgb.WrapMode, "WrapMode.Tile");
+ lgb.WrapMode = WrapMode.TileFlipX;
+ Assert.AreEqual (WrapMode.TileFlipX, lgb.WrapMode, "WrapMode.TileFlipX");
+ lgb.WrapMode = WrapMode.TileFlipY;
+ Assert.AreEqual (WrapMode.TileFlipY, lgb.WrapMode, "WrapMode.TileFlipY");
+ lgb.WrapMode = WrapMode.TileFlipXY;
+ Assert.AreEqual (WrapMode.TileFlipXY, lgb.WrapMode, "WrapMode.TileFlipXY");
+ // can't set WrapMode.Clamp
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void InterpolationColors_Colors_InvalidBlend ()
+ {
+ // default Blend doesn't allow getting this property
+ Assert.IsNotNull (default_brush.InterpolationColors.Colors);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void InterpolationColors_Positions_InvalidBlend ()
+ {
+ // default Blend doesn't allow getting this property
+ Assert.IsNotNull (default_brush.InterpolationColors.Positions);
+ }
+
+ [Test]
+ [ExpectedException (typeof (IndexOutOfRangeException))]
+ public void LinearColors_Empty ()
+ {
+ default_brush.LinearColors = new Color[0];
+ }
+
+ [Test]
+ [ExpectedException (typeof (IndexOutOfRangeException))]
+ public void LinearColors_One ()
+ {
+ default_brush.LinearColors = new Color[1];
+ }
+
+ [Test]
+ public void LinearColors_Two ()
+ {
+ Assert.AreEqual (Color.FromArgb (255, 0, 0, 255), default_brush.LinearColors[0], "0");
+ Assert.AreEqual (Color.FromArgb (255, 255, 0, 0), default_brush.LinearColors[1], "1");
+
+ LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
+ lgb.LinearColors = new Color[2] { Color.Black, Color.White };
+ // not the same, the alpha is changed to 255 so they can't compare
+ Assert.AreEqual (Color.FromArgb (255, 0, 0, 0), lgb.LinearColors[0], "0");
+ Assert.AreEqual (Color.FromArgb (255, 255, 255, 255), lgb.LinearColors[1], "1");
+ }
+
+ [Test]
+ public void LinearColors_Three ()
+ {
+ LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
+ lgb.LinearColors = new Color[3] { Color.Red, Color.Green, Color.Blue };
+ // not the same, the alpha is changed to 255 so they can't compare
+ Assert.AreEqual (Color.FromArgb (255, 255, 0, 0), lgb.LinearColors[0], "0");
+ Assert.AreEqual (Color.FromArgb (255, 0, 128, 0), lgb.LinearColors[1], "1");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Transform_Null ()
+ {
+ default_brush.Transform = null;
+ }
+
+ [Test]
+ public void Transform_Empty ()
+ {
+ LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
+ lgb.Transform = new Matrix ();
+ CheckEmptyMatrix (lgb.Transform);
+ }
+
+ [Test]
+ public void WrapMode_AllValid ()
+ {
+ LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
+ lgb.WrapMode = WrapMode.Tile;
+ Assert.AreEqual (WrapMode.Tile, lgb.WrapMode, "WrapMode.Tile");
+ lgb.WrapMode = WrapMode.TileFlipX;
+ Assert.AreEqual (WrapMode.TileFlipX, lgb.WrapMode, "WrapMode.TileFlipX");
+ lgb.WrapMode = WrapMode.TileFlipY;
+ Assert.AreEqual (WrapMode.TileFlipY, lgb.WrapMode, "WrapMode.TileFlipY");
+ lgb.WrapMode = WrapMode.TileFlipXY;
+ Assert.AreEqual (WrapMode.TileFlipXY, lgb.WrapMode, "WrapMode.TileFlipXY");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void WrapMode_Clamp ()
+ {
+ default_brush.WrapMode = WrapMode.Clamp;
+ }
+
+ [Test]
+ [ExpectedException (typeof (InvalidEnumArgumentException))]
+ public void WrapMode_Invalid ()
+ {
+ default_brush.WrapMode = (WrapMode) Int32.MinValue;
+ }
+
+
+ [Test]
+ public void Clone ()
+ {
+ CheckDefaultRectangle ("default", default_brush.Rectangle);
+ LinearGradientBrush clone = (LinearGradientBrush) default_brush.Clone ();
+ CheckDefaultRectangle ("clone", clone.Rectangle);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void MultiplyTransform1_Null ()
+ {
+ default_brush.MultiplyTransform (null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void MultiplyTransform2_Null ()
+ {
+ default_brush.MultiplyTransform (null, MatrixOrder.Append);
+ }
+
+ [Test]
+ public void MultiplyTransform2_Invalid ()
+ {
+ default_brush.MultiplyTransform (empty_matrix, (MatrixOrder) Int32.MinValue);
+ }
+
+ [Test]
+ public void ResetTransform ()
+ {
+ LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
+ lgb.ResetTransform ();
+ CheckEmptyMatrix (lgb.Transform);
+ }
+
+ [Test]
+ [NUnit.Framework.Category ("NotWorking")]
+ public void RotateTransform ()
+ {
+ LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
+ lgb.RotateTransform (90);
+ float[] elements = lgb.Transform.Elements;
+ Assert.AreEqual (-1, elements[0], 0.1, "matrix.0");
+ Assert.AreEqual (1, elements[1], 0.1, "matrix.1");
+ Assert.AreEqual (-1, elements[2], 0.1, "matrix.2");
+ Assert.AreEqual (-1, elements[3], 0.1, "matrix.3");
+ Assert.AreEqual (16, elements[4], 0.1, "matrix.4");
+ Assert.AreEqual (-16, elements[5], 0.1, "matrix.5");
+
+ lgb.RotateTransform (270);
+ CheckDefaultMatrix (lgb.Transform);
+ }
+
+ [Test]
+ [NUnit.Framework.Category ("NotWorking")]
+ public void RotateTransform_Max ()
+ {
+ LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
+ lgb.RotateTransform (Single.MaxValue);
+ float[] elements = lgb.Transform.Elements;
+ Assert.AreEqual (-1.69580966E+30, elements[0], 1e25, "matrix.0");
+ Assert.AreEqual (1.18780928E+37, elements[1], 1e32, "matrix.1");
+ Assert.AreEqual (-1.18780953E+37, elements[2], 1e32, "matrix.2");
+ Assert.AreEqual (-2.79830475E+29, elements[3], 1e24, "matrix.3");
+ Assert.AreEqual (16, elements[4], 0.1, "matrix.4");
+ Assert.AreEqual (-16, elements[5], 0.1, "matrix.5");
+ }
+
+ [Test]
+ [NUnit.Framework.Category ("NotWorking")]
+ public void RotateTransform_Min ()
+ {
+ LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
+ lgb.RotateTransform (Single.MinValue);
+ float[] elements = lgb.Transform.Elements;
+ Assert.AreEqual (1.06198436E+30, elements[0], 1e25, "matrix.0");
+ Assert.AreEqual (-1.18780953E+37, elements[1], 1e32, "matrix.1");
+ Assert.AreEqual (1.1878094E+37, elements[2], 1e32, "matrix.2");
+ Assert.AreEqual (-3.53994825E+29, elements[3], 1e24, "matrix.3");
+ Assert.AreEqual (16, elements[4], 0.1, "matrix.4");
+ Assert.AreEqual (-16, elements[5], 0.1, "matrix.5");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void RotateTransform_InvalidOrder ()
+ {
+ LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
+ lgb.RotateTransform (720, (MatrixOrder) Int32.MinValue);
+ }
+
+ [Test]
+ [NUnit.Framework.Category ("NotWorking")]
+ public void ScaleTransform ()
+ {
+ LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
+ lgb.ScaleTransform (2, 4);
+ float[] elements = lgb.Transform.Elements;
+ Assert.AreEqual (2, elements[0], 0.1, "matrix.0");
+ Assert.AreEqual (2, elements[1], 0.1, "matrix.1");
+ Assert.AreEqual (-4, elements[2], 0.1, "matrix.2");
+ Assert.AreEqual (4, elements[3], 0.1, "matrix.3");
+ Assert.AreEqual (16, elements[4], 0.1, "matrix.4");
+ Assert.AreEqual (-16, elements[5], 0.1, "matrix.5");
+
+ lgb.ScaleTransform (0.5f, 0.25f);
+ CheckDefaultMatrix (lgb.Transform);
+ }
+
+ [Test]
+ [NUnit.Framework.Category ("NotWorking")]
+ public void ScaleTransform_MaxMin ()
+ {
+ LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
+ lgb.ScaleTransform (Single.MaxValue, Single.MinValue);
+ float[] elements = lgb.Transform.Elements;
+ Assert.AreEqual (Single.MaxValue, elements[0], 1e33, "matrix.0");
+ Assert.AreEqual (Single.MaxValue, elements[1], 1e33, "matrix.1");
+ Assert.AreEqual (Single.MaxValue, elements[2], 1e33, "matrix.2");
+ Assert.AreEqual (Single.MinValue, elements[3], 1e33, "matrix.3");
+ Assert.AreEqual (16, elements[4], 0.1, "matrix.4");
+ Assert.AreEqual (-16, elements[5], 0.1, "matrix.5");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ScaleTransform_InvalidOrder ()
+ {
+ LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
+ lgb.ScaleTransform (1, 1, (MatrixOrder) Int32.MinValue);
+ }
+
+ [Test]
+ [NUnit.Framework.Category ("NotWorking")]
+ public void SetBlendTriangularShape_Focus ()
+ {
+ LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
+ // max valid
+ lgb.SetBlendTriangularShape (1);
+ CheckDefaultMatrix (lgb.Transform);
+ // min valid
+ lgb.SetBlendTriangularShape (0);
+ CheckDefaultMatrix (lgb.Transform);
+ // middle
+ lgb.SetBlendTriangularShape (0.5f);
+ CheckDefaultMatrix (lgb.Transform);
+ // no impact on matrix
+ }
+
+ [Test]
+ [NUnit.Framework.Category ("NotWorking")]
+ public void SetBlendTriangularShape_Scale ()
+ {
+ LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
+ // max valid
+ lgb.SetBlendTriangularShape (0, 1);
+ CheckDefaultMatrix (lgb.Transform);
+ // min valid
+ lgb.SetBlendTriangularShape (1, 0);
+ CheckDefaultMatrix (lgb.Transform);
+ // middle
+ lgb.SetBlendTriangularShape (0.5f, 0.5f);
+ CheckDefaultMatrix (lgb.Transform);
+ // no impact on matrix
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void SetBlendTriangularShape_FocusTooSmall ()
+ {
+ default_brush.SetBlendTriangularShape (-1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void SetBlendTriangularShape_FocusTooBig ()
+ {
+ default_brush.SetBlendTriangularShape (1.01f);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void SetBlendTriangularShape_ScaleTooSmall ()
+ {
+ default_brush.SetBlendTriangularShape (1, -1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void SetBlendTriangularShape_ScaleTooBig ()
+ {
+ default_brush.SetBlendTriangularShape (1, 1.01f);
+ }
+
+ [Test]
+ [NUnit.Framework.Category ("NotWorking")]
+ public void SetSigmaBellShape_Focus ()
+ {
+ LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
+ // max valid
+ lgb.SetSigmaBellShape (1);
+ CheckDefaultMatrix (lgb.Transform);
+ // min valid
+ lgb.SetSigmaBellShape (0);
+ CheckDefaultMatrix (lgb.Transform);
+ // middle
+ lgb.SetSigmaBellShape (0.5f);
+ CheckDefaultMatrix (lgb.Transform);
+ // no impact on matrix
+ }
+
+ [Test]
+ [NUnit.Framework.Category ("NotWorking")]
+ public void SetSigmaBellShape_Scale ()
+ {
+ LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
+ // max valid
+ lgb.SetSigmaBellShape (0, 1);
+ CheckDefaultMatrix (lgb.Transform);
+ // min valid
+ lgb.SetSigmaBellShape (1, 0);
+ CheckDefaultMatrix (lgb.Transform);
+ // middle
+ lgb.SetSigmaBellShape (0.5f, 0.5f);
+ CheckDefaultMatrix (lgb.Transform);
+ // no impact on matrix
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void SetSigmaBellShape_FocusTooSmall ()
+ {
+ default_brush.SetSigmaBellShape (-1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void SetSigmaBellShape_FocusTooBig ()
+ {
+ default_brush.SetSigmaBellShape (1.01f);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void SetSigmaBellShape_ScaleTooSmall ()
+ {
+ default_brush.SetSigmaBellShape (1, -1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void SetSigmaBellShape_ScaleTooBig ()
+ {
+ default_brush.SetSigmaBellShape (1, 1.01f);
+ }
+
+ [Test]
+ [NUnit.Framework.Category ("NotWorking")]
+ public void TranslateTransform ()
+ {
+ LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
+ lgb.TranslateTransform (1, 1);
+ float[] elements = lgb.Transform.Elements;
+ Assert.AreEqual (1, elements[0], 0.1, "matrix.0");
+ Assert.AreEqual (1, elements[1], 0.1, "matrix.1");
+ Assert.AreEqual (-1, elements[2], 0.1, "matrix.2");
+ Assert.AreEqual (1, elements[3], 0.1, "matrix.3");
+ Assert.AreEqual (16, elements[4], 0.1, "matrix.4");
+ Assert.AreEqual (-14, elements[5], 0.1, "matrix.5");
+
+ lgb.TranslateTransform (-1, -1);
+ CheckDefaultMatrix (lgb.Transform);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void TranslateTransform_InvalidOrder ()
+ {
+ LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
+ lgb.TranslateTransform (1, 1, (MatrixOrder) Int32.MinValue);
+ }
+ }
+}
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..22b071c9641
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/TestMatrix.cs
@@ -0,0 +1,532 @@
+//
+// Tests for System.Drawing.Drawing2D.Matrix.cs
+//
+// Authors:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2005-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 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 {
+
+ private Matrix default_matrix;
+ private Rectangle rect;
+ private RectangleF rectf;
+
+ [TestFixtureSetUp]
+ public void FixtureSetUp ()
+ {
+ default_matrix = new Matrix ();
+ }
+
+ [Test]
+ public void Constructor_Default ()
+ {
+ Matrix matrix = new Matrix ();
+ AssertEquals ("C#1", 6, matrix.Elements.Length);
+ }
+
+ [Test]
+ public void Constructor_SixFloats ()
+ {
+ 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]);
+ }
+
+ [Test]
+ public void Constructor_Float ()
+ {
+ 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]);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Constructor_Int_Null ()
+ {
+ new Matrix (rect, null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void Constructor_Int_Empty ()
+ {
+ new Matrix (rect, new Point[0]);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Constructor_Float_Null ()
+ {
+ new Matrix (rectf, null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void Constructor_Float_Empty ()
+ {
+ new Matrix (rectf, new PointF[0]);
+ }
+
+ // 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 HashCode ()
+ {
+ Matrix matrix = new Matrix (10, 20, 30, 40, 50, 60);
+ Matrix clone = matrix.Clone ();
+ Assert ("HashCode/Clone", matrix.GetHashCode () != clone.GetHashCode ());
+
+ Matrix matrix2 = new Matrix (10, 20, 30, 40, 50, 60);
+ Assert ("HashCode/Identical", matrix.GetHashCode () != matrix2.GetHashCode ());
+ }
+
+ [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]
+ [ExpectedException (typeof (ArgumentException))]
+ public void Rotate_InvalidOrder ()
+ {
+ new Matrix ().Rotate (180, (MatrixOrder) Int32.MinValue);
+ }
+
+ [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]
+ [ExpectedException (typeof (ArgumentException))]
+ public void RotateAt_InvalidOrder ()
+ {
+ new Matrix ().RotateAt (180, new PointF (10, 10), (MatrixOrder) Int32.MinValue);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Multiply_Null ()
+ {
+ new Matrix (10, 20, 30, 40, 50, 60).Multiply (null);
+ }
+
+ [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]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Multiply_Null_Order ()
+ {
+ new Matrix (10, 20, 30, 40, 50, 60).Multiply (null, MatrixOrder.Append);
+ }
+
+ [Test]
+ public void Multiply_Append ()
+ {
+ Matrix matrix = new Matrix (10, 20, 30, 40, 50, 60);
+ matrix.Multiply (new Matrix (10, 20, 30, 40, 50, 60), MatrixOrder.Append);
+
+ 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 Multiply_Prepend ()
+ {
+ Matrix matrix = new Matrix (10, 20, 30, 40, 50, 60);
+ matrix.Multiply (new Matrix (10, 20, 30, 40, 50, 60), MatrixOrder.Prepend);
+
+ 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]
+ [ExpectedException (typeof (ArgumentException))]
+ public void Multiply_InvalidOrder ()
+ {
+ Matrix matrix = new Matrix (10, 20, 30, 40, 50, 60);
+ matrix.Multiply (new Matrix (10, 20, 30, 40, 50, 60), (MatrixOrder)Int32.MinValue);
+ }
+
+ [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 Scale_Negative ()
+ {
+ 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]
+ [ExpectedException (typeof (ArgumentException))]
+ public void Scale_InvalidOrder ()
+ {
+ new Matrix ().Scale (2, 1, (MatrixOrder) Int32.MinValue);
+ }
+
+ [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]
+ [ExpectedException (typeof (ArgumentException))]
+ public void Shear_InvalidOrder ()
+ {
+ new Matrix ().Shear (-1, 1, (MatrixOrder) Int32.MinValue);
+ }
+
+ [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]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void TransformPoints_Point_Null ()
+ {
+ new Matrix ().TransformPoints ((Point[]) null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void TransformPoints_PointF_Null ()
+ {
+ new Matrix ().TransformPoints ((PointF[]) null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void TransformPoints_Point_Empty ()
+ {
+ new Matrix ().TransformPoints (new Point[0]);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void TransformPoints_PointF_Empty ()
+ {
+ new Matrix ().TransformPoints (new PointF[0]);
+ }
+
+ [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]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void TransformVectors_Point_Null ()
+ {
+ new Matrix ().TransformVectors ((Point[]) null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void TransformVectors_PointF_Null ()
+ {
+ new Matrix ().TransformVectors ((PointF[]) null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void TransformVectors_Point_Empty ()
+ {
+ new Matrix ().TransformVectors (new Point[0]);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void TransformVectors_PointF_Empty ()
+ {
+ new Matrix ().TransformVectors (new PointF[0]);
+ }
+
+ [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]);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void Translate_InvalidOrder ()
+ {
+ new Matrix ().Translate (-1, 1, (MatrixOrder) Int32.MinValue);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void VectorTransformPoints_Null ()
+ {
+ new Matrix ().VectorTransformPoints ((Point[]) null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void VectorTransformPoints_Empty ()
+ {
+ new Matrix ().VectorTransformPoints (new Point[0]);
+ }
+ }
+}
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..6b27469b6fe
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/ChangeLog
@@ -0,0 +1,52 @@
+2006-01-25 Boris Kirzner <borisk@mainsoft.com>
+ *TestBmpCodec.cs, TestImageAttributes.cs, TestImageCodecInfo.cs:
+ added #ifdef for TARGET_JVM.
+
+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..3effdcfc8bc
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestBmpCodec.cs
@@ -0,0 +1,162 @@
+//
+// 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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..7db25131cc9
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageAttributes.cs
@@ -0,0 +1,106 @@
+//
+// 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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..a6f477d521a
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageCodecInfo.cs
@@ -0,0 +1,195 @@
+//
+// 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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..3a7e6db9ba7
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
@@ -0,0 +1,387 @@
+2006-03-25 Sebastien Pouliot <sebastien@ximian.com>
+
+ * RegionDataTest.cs: Add test cases for GetRegionData when a region is
+ path-based (using bitmaps in libgdiplus) and for regions that had a
+ binary operations applied (i.e. using a path tree in libgdiplus).
+ * RegionNonRectTest.cs: Add test cases for GetRegionScans and all
+ binary operators (Union, Intersection, Complement, Exclude and Xor)
+ on path based regions (using bitmaps in libgdiplus).
+
+2006-02-29 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TestFont.cs: LOGFONT must be CharSet=Auto to make sure we have
+ the appropriate size on each system
+
+2006-01-27 Sebastien Pouliot <sebastien@ximian.com>
+
+ * RegionNonRectTest.cs: Updated comments on a test that fails on both
+ 1.x and 2.0 MS runtime.
+ * TestFont.cs: Converted tests to NUnit 2.2 and added descriptions to
+ each asserts.
+
+2006-01-26 Boris Kirzner <borisk@mainsoft.com>
+ * ColorConverter.cs, TestBitmap.cs, TestIcon.cs, TestIconConverter.cs,
+ TestImageConverter.cs, TestPointConverter.cs, TestRectangleConverter.cs,
+ TestRegion.cs, TestSizeConverter.cs, TestStringFormat.cs:
+ added #ifdef for TARGET_JVM.
+
+2006-01-23 Boris Kirzner <borisk@mainsoft.com>
+ * TestBitmap.cs, TestFont.cs: #ifdef fot TARGET_JVM.
+
+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..0d42f95a74a
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/ColorConverter.cs
@@ -0,0 +1,416 @@
+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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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))]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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..0b491065b68
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/RegionDataTest.cs
@@ -0,0 +1,138 @@
+//
+// 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;
+ private GraphicsPath sp1;
+ private GraphicsPath sp2;
+
+ [TestFixtureSetUp]
+ public void FixtureSetUp ()
+ {
+ bitmap = new Bitmap (10, 10);
+ graphic = Graphics.FromImage (bitmap);
+
+ sp1 = new GraphicsPath ();
+ sp1.AddPolygon (new Point[4] { new Point (0, 0), new Point (3, 0), new Point (3, 3), new Point (0, 3) });
+
+ sp2 = new GraphicsPath ();
+ sp2.AddPolygon (new Point[4] { new Point (2, 2), new Point (5, 2), new Point (5, 5), new Point (2, 5) });
+ }
+
+ [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");
+ }
+
+ [Test]
+ public void CombinedPathRegion ()
+ {
+ // note: seems identical to PathRegion but it test another code path inside libgdiplus
+ Region r = new Region (sp1);
+ r.Xor (sp2);
+ RegionData data = r.GetRegionData ();
+ Assert.IsNotNull (data.Data, "Data");
+ Region region = new Region (data);
+ Assert.IsTrue (r.GetBounds (graphic).Equals (region.GetBounds (graphic)), "Bounds");
+ }
+
+ [Test]
+ public void MultiCombinedPathRegion ()
+ {
+ // note: seems identical to PathRegion but it test another code path inside libgdiplus
+ Region r1 = new Region (sp1);
+ r1.Xor (sp2);
+ Region r2 = new Region (sp2);
+ r2.Complement (sp1);
+
+ Region r = r1.Clone ();
+ r.Union (r2);
+ 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..1cc034394a6
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/RegionNonRectTest.cs
@@ -0,0 +1,720 @@
+//
+// 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;
+ private Matrix matrix;
+ private GraphicsPath sp1, sp2, sp3, sp4;
+
+ [TestFixtureSetUp]
+ public void FixtureSetUp ()
+ {
+ bitmap = new Bitmap (10, 10);
+ graphic = Graphics.FromImage (bitmap);
+ matrix = new Matrix ();
+
+ sp1 = new GraphicsPath ();
+ sp1.AddPolygon (new Point[4] { new Point (0, 0), new Point (3, 0), new Point (3, 3), new Point (0, 3) });
+
+ sp2 = new GraphicsPath ();
+ sp2.AddPolygon (new Point[4] { new Point (2, 2), new Point (5, 2), new Point (5, 5), new Point (2, 5) });
+
+ sp3 = new GraphicsPath ();
+ sp3.AddPolygon (new Point[4] { new Point (6, 0), new Point (9, 0), new Point (9, 3), new Point (6, 3) });
+
+ sp4 = new GraphicsPath ();
+ sp4.AddPolygon (new Point[4] { new Point (8, 0), new Point (11, 0), new Point (11, 3), new Point (8, 3) });
+ }
+
+ // 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 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");
+ }
+
+ [Test]
+ public void Curve_GetRegionScans ()
+ {
+ Point[] points = new Point[2] { new Point (-4194304, -4194304), new Point (4194304, 4194304) };
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddCurve (points);
+ Region region = new Region (gp);
+ // too big, returns 0
+ Assert.AreEqual (0, region.GetRegionScans (matrix).Length, "GetRegionScans");
+ }
+
+ private void DisplaySmallRegion (Region region, int ox, int oy, int width, int height)
+ {
+ for (int y = oy ; y < height - 1; y++) {
+ for (int x = ox; x < width - 1; x++) {
+ if (region.IsVisible (x, y))
+ Console.Write ("X");
+ else
+ Console.Write (".");
+ }
+ Console.WriteLine ();
+ }
+ }
+
+ private void DisplaySmallRegion (Region region, int width, int height)
+ {
+ DisplaySmallRegion (region, -1, -1, width, height);
+ }
+
+
+ private void CompareSmallRegion (Region region, bool[] expected, int ox, int oy, int width, int height)
+ {
+ int p = 0;
+ for (int y = oy; y < height + oy; y++) {
+ for (int x = ox; x < width + ox; x++) {
+ Assert.AreEqual (expected[p], region.IsVisible (x, y), String.Format ("{0},{1}", x, y));
+ p++;
+ }
+ }
+ }
+
+ private void CompareSmallRegion (Region region, bool[] expected, int width, int height)
+ {
+ CompareSmallRegion (region, expected, -1, -1, width, height);
+ }
+
+ private void CheckRectF (string msg, int x, int y, int w, int h, RectangleF rect)
+ {
+ Assert.AreEqual (x, rect.X, msg + ".X");
+ Assert.AreEqual (y, rect.Y, msg + ".Y");
+ Assert.AreEqual (w, rect.Width, msg + ".Width");
+ Assert.AreEqual (h, rect.Height, msg + ".Height");
+ }
+
+ static bool[] sunion = new bool[49] {
+ false, false, false, false, false, false, false, // .......
+ false, true, true, true, false, false, false, // .XXX...
+ false, true, true, true, false, false, false, // .XXX...
+ false, true, true, true, true, true, false, // .XXXXX.
+ false, false, false, true, true, true, false, // ...XXX.
+ false, false, false, true, true, true, false, // ...XXX.
+ false, false, false, false, false, false, false, // .......
+ };
+
+ [Test]
+ public void SmallUnion1 ()
+ {
+ Region region = new Region (sp1);
+ region.Union (sp2);
+ CompareSmallRegion (region, sunion, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (3, scans.Length, "GetRegionScans");
+ CheckRectF ("[0]", 0, 0, 3, 2, scans[0]);
+ CheckRectF ("[1]", 0, 2, 5, 1, scans[1]);
+ CheckRectF ("[2]", 2, 3, 3, 2, scans[2]);
+ }
+
+ [Test]
+ public void SmallUnion2 ()
+ {
+ Region region = new Region (sp2);
+ region.Union (sp1);
+ CompareSmallRegion (region, sunion, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (3, scans.Length, "GetRegionScans");
+ CheckRectF ("[0]", 0, 0, 3, 2, scans[0]);
+ CheckRectF ("[1]", 0, 2, 5, 1, scans[1]);
+ CheckRectF ("[2]", 2, 3, 3, 2, scans[2]);
+ }
+
+ static bool[] self1 = new bool[49] {
+ false, false, false, false, false, false, false, // .......
+ false, true, true, true, false, false, false, // .XXX...
+ false, true, true, true, false, false, false, // .XXX...
+ false, true, true, true, false, false, false, // .XXX...
+ false, false, false, false, false, false, false, // .......
+ false, false, false, false, false, false, false, // .......
+ false, false, false, false, false, false, false, // .......
+ };
+
+ [Test]
+ public void SmallUnion_Self1 ()
+ {
+ Region region = new Region (sp1);
+ region.Union (sp1);
+ CompareSmallRegion (region, self1, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (1, scans.Length, "GetRegionScans");
+ CheckRectF ("[0]", 0, 0, 3, 3, scans[0]);
+ }
+
+ static bool[] self2 = new bool[49] {
+ false, false, false, false, false, false, false, // .......
+ false, false, false, false, false, false, false, // .......
+ false, false, false, false, false, false, false, // .......
+ false, false, false, true, true, true, false, // ...XXX.
+ false, false, false, true, true, true, false, // ...XXX.
+ false, false, false, true, true, true, false, // ...XXX.
+ false, false, false, false, false, false, false, // .......
+ };
+
+ [Test]
+ public void SmallUnion_Self2 ()
+ {
+ Region region = new Region (sp2);
+ region.Union (sp2);
+ CompareSmallRegion (region, self2, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (1, scans.Length, "GetRegionScans");
+ CheckRectF ("[0]", 2, 2, 3, 3, scans[0]);
+ }
+
+ static bool[] sintersection = new bool[49] {
+ false, false, false, false, false, false, false, // .......
+ false, false, false, false, false, false, false, // .......
+ false, false, false, false, false, false, false, // .......
+ false, false, false, true, false, false, false, // ...X...
+ false, false, false, false, false, false, false, // .......
+ false, false, false, false, false, false, false, // .......
+ false, false, false, false, false, false, false, // .......
+ };
+
+ [Test]
+ public void SmallIntersection1 ()
+ {
+ Region region = new Region (sp1);
+ region.Intersect (sp2);
+ CompareSmallRegion (region, sintersection, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (1, scans.Length, "GetRegionScans");
+ CheckRectF ("[0]", 2, 2, 1, 1, scans[0]);
+ }
+
+ [Test]
+ public void SmallIntersection2 ()
+ {
+ Region region = new Region (sp2);
+ region.Intersect (sp1);
+ CompareSmallRegion (region, sintersection, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (1, scans.Length, "GetRegionScans");
+ CheckRectF ("[0]", 2, 2, 1, 1, scans[0]);
+ }
+
+ [Test]
+ public void SmallIntersection_Self1 ()
+ {
+ Region region = new Region (sp1);
+ region.Intersect (sp1);
+ CompareSmallRegion (region, self1, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (1, scans.Length, "GetRegionScans");
+ CheckRectF ("[0]", 0, 0, 3, 3, scans[0]);
+ }
+
+ [Test]
+ public void SmallIntersection_Self2 ()
+ {
+ Region region = new Region (sp2);
+ region.Intersect (sp2);
+ CompareSmallRegion (region, self2, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (1, scans.Length, "GetRegionScans");
+ CheckRectF ("[0]", 2, 2, 3, 3, scans[0]);
+ }
+
+ static bool[] sexclude1 = new bool[49] {
+ false, false, false, false, false, false, false, // .......
+ false, true, true, true, false, false, false, // .XXX...
+ false, true, true, true, false, false, false, // .XXX...
+ false, true, true, false, false, false, false, // .XX....
+ false, false, false, false, false, false, false, // .......
+ false, false, false, false, false, false, false, // .......
+ false, false, false, false, false, false, false, // .......
+ };
+
+ [Test]
+ public void SmallExclude1 ()
+ {
+ Region region = new Region (sp1);
+ region.Exclude (sp2);
+ CompareSmallRegion (region, sexclude1, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (2, scans.Length, "GetRegionScans");
+ CheckRectF ("[0]", 0, 0, 3, 2, scans[0]);
+ CheckRectF ("[1]", 0, 2, 2, 1, scans[1]);
+ }
+
+ static bool[] sexclude2 = new bool[49] {
+ false, false, false, false, false, false, false, // .......
+ false, false, false, false, false, false, false, // .......
+ false, false, false, false, false, false, false, // .......
+ false, false, false, false, true, true, false, // ....XX.
+ false, false, false, true, true, true, false, // ...XXX.
+ false, false, false, true, true, true, false, // ...XXX.
+ false, false, false, false, false, false, false, // .......
+ };
+
+ [Test]
+ public void SmallExclude2 ()
+ {
+ Region region = new Region (sp2);
+ region.Exclude (sp1);
+ CompareSmallRegion (region, sexclude2, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (2, scans.Length, "GetRegionScans");
+ CheckRectF ("[0]", 3, 2, 2, 1, scans[0]);
+ CheckRectF ("[1]", 2, 3, 3, 2, scans[1]);
+ }
+
+ static bool[] sempty = new bool[49] {
+ false, false, false, false, false, false, false, // .......
+ false, false, false, false, false, false, false, // .......
+ false, false, false, false, false, false, false, // .......
+ false, false, false, false, false, false, false, // .......
+ false, false, false, false, false, false, false, // .......
+ false, false, false, false, false, false, false, // .......
+ false, false, false, false, false, false, false, // .......
+ };
+
+ [Test]
+ public void SmallExclude_Self1 ()
+ {
+ Region region = new Region (sp1);
+ region.Exclude (sp1);
+ CompareSmallRegion (region, sempty, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (0, scans.Length, "GetRegionScans");
+ }
+
+ [Test]
+ public void SmallExclude_Self2 ()
+ {
+ Region region = new Region (sp2);
+ region.Exclude (sp2);
+ CompareSmallRegion (region, sempty, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (0, scans.Length, "GetRegionScans");
+ }
+
+ [Test]
+ public void SmallComplement1 ()
+ {
+ Region region = new Region (sp1);
+ region.Complement (sp2);
+ CompareSmallRegion (region, sexclude2, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (2, scans.Length, "GetRegionScans");
+ CheckRectF ("[0]", 3, 2, 2, 1, scans[0]);
+ CheckRectF ("[1]", 2, 3, 3, 2, scans[1]);
+ }
+
+ [Test]
+ public void SmallComplement2 ()
+ {
+ Region region = new Region (sp2);
+ region.Complement (sp1);
+ CompareSmallRegion (region, sexclude1, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (2, scans.Length, "GetRegionScans");
+ CheckRectF ("[0]", 0, 0, 3, 2, scans[0]);
+ CheckRectF ("[1]", 0, 2, 2, 1, scans[1]);
+ }
+
+ [Test]
+ public void SmallComplement_Self1 ()
+ {
+ Region region = new Region (sp1);
+ region.Complement (sp1);
+ CompareSmallRegion (region, sempty, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (0, scans.Length, "GetRegionScans");
+ }
+
+ [Test]
+ public void SmallComplement_Self2 ()
+ {
+ Region region = new Region (sp2);
+ region.Complement (sp2);
+ CompareSmallRegion (region, sempty, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (0, scans.Length, "GetRegionScans");
+ }
+
+ static bool[] sxor = new bool[49] {
+ false, false, false, false, false, false, false, // .......
+ false, true, true, true, false, false, false, // .XXX...
+ false, true, true, true, false, false, false, // .XXX...
+ false, true, true, false, true, true, false, // .XX.XX.
+ false, false, false, true, true, true, false, // ...XXX.
+ false, false, false, true, true, true, false, // ...XXX.
+ false, false, false, false, false, false, false, // .......
+ };
+
+ [Test]
+ public void SmallXor1 ()
+ {
+ Region region = new Region (sp1);
+ region.Xor (sp2);
+ CompareSmallRegion (region, sxor, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (4, scans.Length, "GetRegionScans");
+ CheckRectF ("[0]", 0, 0, 3, 2, scans[0]);
+ CheckRectF ("[1]", 0, 2, 2, 1, scans[1]);
+ CheckRectF ("[2]", 3, 2, 2, 1, scans[2]);
+ CheckRectF ("[3]", 2, 3, 3, 2, scans[3]);
+ }
+
+ [Test]
+ public void SmallXor2 ()
+ {
+ Region region = new Region (sp2);
+ region.Xor (sp1);
+ CompareSmallRegion (region, sxor, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (4, scans.Length, "GetRegionScans");
+ CheckRectF ("[0]", 0, 0, 3, 2, scans[0]);
+ CheckRectF ("[1]", 0, 2, 2, 1, scans[1]);
+ CheckRectF ("[2]", 3, 2, 2, 1, scans[2]);
+ CheckRectF ("[3]", 2, 3, 3, 2, scans[3]);
+ }
+
+ [Test]
+ public void SmallXor_Self1 ()
+ {
+ Region region = new Region (sp1);
+ region.Xor (sp1);
+ CompareSmallRegion (region, sempty, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (0, scans.Length, "GetRegionScans");
+ }
+
+ [Test]
+ public void SmallXor_Self2 ()
+ {
+ Region region = new Region (sp2);
+ region.Xor (sp2);
+ CompareSmallRegion (region, sempty, 7, 7);
+
+ RectangleF[] scans = region.GetRegionScans (matrix);
+ Assert.AreEqual (0, scans.Length, "GetRegionScans");
+ }
+
+ [Test]
+ public void NegativeXor ()
+ {
+ GraphicsPath neg = new GraphicsPath ();
+ // identical result (matrix) of XOR but we're using negative coordinates
+ neg.AddPolygon (new Point[4] { new Point (-2, -2), new Point (1, -2), new Point (1, 1), new Point (-2, 1) });
+
+ Region region = new Region (sp1);
+ region.Xor (neg);
+ CompareSmallRegion (region, sxor, -3, -3, 7, 7);
+ }
+
+ static bool[] ni_union = new bool[55] {
+ false, false, false, false, false, false, false, false, false, false, false, // ...........
+ false, true, true, true, false, false, false, true, true, true, false, // .XXX...XXX.
+ false, true, true, true, false, false, false, true, true, true, false, // .XXX...XXX.
+ false, true, true, true, false, false, false, true, true, true, false, // .XXX...XXX.
+ false, false, false, false, false, false, false, false, false, false, false, // ...........
+ };
+
+ [Test]
+ public void UnionWithoutIntersection ()
+ {
+ Region region = new Region (sp1);
+ region.Union (sp3);
+ CompareSmallRegion (region, ni_union, 11,5 );
+ }
+
+ [Test]
+ // libgdiplus: both region are considered inside as intersecting rectangle because
+ // part of them co-exists in the same 8x8 bitmap. Full algorithm apply but results
+ // in an empty bitmap
+ public void IntersectionWithoutIntersection ()
+ {
+ Region region = new Region (sp1);
+ region.Intersect (sp3);
+ CompareSmallRegion (region, sempty, 7, 7);
+ }
+
+ [Test]
+ // libgdiplus: no intersection results in an empty bitmap (optimization)
+ public void IntersectionWithoutIntersection_Large ()
+ {
+ Region region = new Region (sp1);
+ region.Intersect (sp4);
+ CompareSmallRegion (region, sempty, 7, 7);
+ }
+
+ [Test]
+ // libgdiplus: both region are considered inside as intersecting rectangle because
+ // part of them co-exists in the same 8x8 bitmap. Full algorithm apply but results
+ // as a copy of sp1
+ public void ExcludeWithoutIntersection ()
+ {
+ Region region = new Region (sp1);
+ region.Exclude (sp3);
+ CompareSmallRegion (region, self1, 7, 7);
+ }
+
+ [Test]
+ // libgdiplus: no intersection results in a clone of sp1 (optimization)
+ public void ExcludeWithoutIntersection_Large ()
+ {
+ Region region = new Region (sp1);
+ region.Exclude (sp4);
+ CompareSmallRegion (region, self1, 7, 7);
+ }
+
+ [Test]
+ // libgdiplus: both region are considered inside as intersecting rectangle because
+ // part of them co-exists in the same 8x8 bitmap. Full algorithm apply but results
+ // as a copy of sp1
+ public void ComplementWithoutIntersection ()
+ {
+ Region region = new Region (sp3);
+ region.Complement (sp1);
+ CompareSmallRegion (region, self1, 7, 7);
+ }
+
+ [Test]
+ // libgdiplus: no intersection results in a clone of sp1 (optimization)
+ public void ComplementWithoutIntersection_Large ()
+ {
+ Region region = new Region (sp4);
+ region.Complement (sp1);
+ CompareSmallRegion (region, self1, 7, 7);
+ }
+
+ [Test]
+ // libgdiplus: both region are considered inside as intersecting rectangle because
+ // part of them co-exists in the same 8x8 bitmap.
+ public void XorWithoutIntersection ()
+ {
+ Region region = new Region (sp1);
+ region.Xor (sp3);
+ CompareSmallRegion (region, ni_union, 11, 5);
+ }
+
+ static bool[] ni_xor = new bool[65] {
+ false, false, false, false, false, false, false, false, false, false, false, false, false, // .............
+ false, true, true, true, false, false, false, false, false, true, true, true, false, // .XXX.....XXX.
+ false, true, true, true, false, false, false, false, false, true, true, true, false, // .XXX.....XXX.
+ false, true, true, true, false, false, false, false, false, true, true, true, false, // .XXX.....XXX.
+ false, false, false, false, false, false, false, false, false, false, false, false, false, // .............
+ };
+
+ [Test]
+ // libgdiplus: both region aren't considered as an intersection because they do
+ // not co-exists in the same 8x8 bitmap. In this case the xor function calls the
+ // union code (optimization).
+ public void XorWithoutIntersection_Large ()
+ {
+ Region region = new Region (sp1);
+ region.Xor (sp4);
+ CompareSmallRegion (region, ni_xor, 13, 5);
+ }
+
+ [Test]
+ public void IsEqual ()
+ {
+ Region r1 = new Region (sp1);
+ Region r2 = new Region (sp2);
+ Region r3 = new Region (sp3);
+ Region r4 = new Region (sp4);
+ // with self
+ Assert.IsTrue (r1.Equals (r1, graphic), "r1-r1");
+ Assert.IsTrue (r2.Equals (r2, graphic), "r2-r2");
+ Assert.IsTrue (r3.Equals (r3, graphic), "r3-r3");
+ Assert.IsTrue (r4.Equals (r4, graphic), "r4-r4");
+ // with a different
+ Assert.IsFalse (r1.Equals (r4, graphic), "r1-r4");
+ Assert.IsFalse (r2.Equals (r3, graphic), "r2-r3");
+ Assert.IsFalse (r3.Equals (r2, graphic), "r3-r2");
+ Assert.IsFalse (r4.Equals (r1, graphic), "r4-r1");
+ // with same (not self)
+ Region r5 = r1.Clone ();
+ r1.Exclude (r4);
+ Assert.IsTrue (r1.Equals (r5, graphic), "r1-r5");
+ Assert.IsTrue (r5.Equals (r1, graphic), "r5-r1");
+ Assert.IsFalse (r5.Equals (r4, graphic), "r5-r4");
+ Assert.IsFalse (r4.Equals (r5, graphic), "r4-r5");
+ }
+
+ [Test]
+ public void Translate_Int ()
+ {
+ Region r1 = new Region (sp1);
+ Region r2 = new Region (sp2);
+ r2.Translate (-2, -2);
+ r1.Intersect (r2);
+ CompareSmallRegion (r1, self1, 7, 7);
+ }
+
+ [Test]
+ public void Translate_Float ()
+ {
+ Region r1 = new Region (sp1);
+ Region r2 = new Region (sp2);
+ r2.Translate (-2.0f, -2.0f);
+ r1.Intersect (r2);
+ CompareSmallRegion (r1, self1, 7, 7);
+ }
+ }
+}
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..92d0434f155
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestBitmap.cs
@@ -0,0 +1,557 @@
+//
+// 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))]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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);
+ }
+#if !TARGET_JVM
+ 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);
+ }
+#endif
+
+
+ /*
+ 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));
+
+ }
+
+#if !TARGET_JVM
+ /*
+ 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));
+ }
+ }
+#endif
+ }
+}
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..bce591e4692
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestFont.cs
@@ -0,0 +1,102 @@
+//
+// 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
+// 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 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 {
+
+
+ // Test basic Font clone, properties and contructor
+ [Test]
+ public void TestClone()
+ {
+ Font f = new Font("Arial",12);
+ Font f2 = (Font) f.Clone();
+
+ Assert.AreEqual (f.Bold, f2.Bold, "Bold");
+ Assert.AreEqual (f.FontFamily, f2.FontFamily, "FontFamily");
+ Assert.AreEqual (f.GdiCharSet, f2.GdiCharSet, "GdiCharSet");
+ Assert.AreEqual (f.GdiVerticalFont, f2.GdiVerticalFont, "GdiVerticalFont");
+ Assert.AreEqual (f.Height, f2.Height, "Height");
+ Assert.AreEqual (f.Italic, f2.Italic, "Italic");
+ Assert.AreEqual (f.Name, f2.Name, "Name");
+ Assert.AreEqual (f.Size, f2.Size, "Size");
+ Assert.AreEqual (f.SizeInPoints, f2.SizeInPoints, "SizeInPoints");
+ Assert.AreEqual (f.Strikeout, f2.Strikeout, "Strikeout");
+ Assert.AreEqual (f.Style, f2.Style, "Style");
+ Assert.AreEqual (f.Underline, f2.Underline, "Underline");
+ Assert.AreEqual (f.Unit, f2.Unit, "Unit");
+ }
+
+ [ StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto) ]
+ 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;
+ }
+#if !TARGET_JVM
+ [Test]
+ public void TestToLogFont() {
+ Font f;
+ LOGFONT lf;
+
+ lf = new LOGFONT();
+ f = new Font("Arial", 10);
+
+ f.ToLogFont(lf);
+ Assert.AreEqual (-13, lf.lfHeight, "lfHeight");
+ Assert.AreEqual (400, lf.lfWeight, "lfWeight");
+ Assert.AreEqual (1, lf.lfCharSet, "lfCharSet");
+ Assert.AreEqual (f.Name, lf.lfFaceName, "lfFaceName");
+ }
+#endif
+ }
+}
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..40b893f3627
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestIcon.cs
@@ -0,0 +1,121 @@
+//
+// 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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..92c98188136
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestIconConverter.cs
@@ -0,0 +1,436 @@
+//
+// 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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..46df68ba469
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestImageConverter.cs
@@ -0,0 +1,477 @@
+//
+// 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ public void TestGetPropertiesSupported ()
+ {
+ Assert.IsTrue (imgConv.GetPropertiesSupported (), "GPS#1");
+ Assert.IsTrue (imgConv.GetPropertiesSupported (null), "GPS#2");
+ }
+
+ [Test]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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..788ed2c5fcf
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestPointConverter.cs
@@ -0,0 +1,473 @@
+//
+// 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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..459418b395c
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestRectangleConverter.cs
@@ -0,0 +1,551 @@
+//
+// 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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..cd953b462b0
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestRegion.cs
@@ -0,0 +1,1366 @@
+//
+// 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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))]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void Constructor_GraphicsPath_Null ()
+ {
+ GraphicsPath gp = null;
+ Region r = new Region (gp);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void IsVisible_IntIntNull ()
+ {
+ Assert.IsTrue (new Region ().IsVisible (0, 0, null));
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void IsVisible_IntIntIntIntNull ()
+ {
+ Assert.IsFalse (new Region ().IsVisible (0, 0, 0, 0, null));
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void IsVisible_PointNull ()
+ {
+ Point p = new Point ();
+ Assert.IsTrue (new Region ().IsVisible (p, null));
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void IsVisible_PointFNull ()
+ {
+ PointF p = new PointF ();
+ Assert.IsTrue (new Region ().IsVisible (p, null));
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void IsVisible_RectangleNull ()
+ {
+ Rectangle r = new Rectangle ();
+ Assert.IsFalse (new Region ().IsVisible (r, null));
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void IsVisible_RectangleFNull ()
+ {
+ RectangleF r = new RectangleF ();
+ Assert.IsFalse (new Region ().IsVisible (r, null));
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void IsVisible_SingleSingleNull ()
+ {
+ Assert.IsTrue (new Region ().IsVisible (0f, 0f, null));
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ [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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ [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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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..c1cee53cc36
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestSizeConverter.cs
@@ -0,0 +1,480 @@
+//
+// 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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]
+#if TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif
+ 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..09c3052fd63
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestStringFormat.cs
@@ -0,0 +1,119 @@
+//
+// 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]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ 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..2647d19b8d7
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/Test.dotnet.csproj
@@ -0,0 +1,541 @@
+<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 = "DrawingTest\Test\"
+ 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 = "DrawingTestHelper"
+ Project = "{8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}"
+ Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
+ />
+ <Reference
+ Name = "nunit.core.dll.J2EE"
+ Project = "{7C52A6A5-71ED-4468-9564-2FF5CD6E6E6C}"
+ Package = "{83B010C7-76FC-4FAD-A26C-00D7EFE60256}"
+ />
+ <Reference
+ Name = "nunit.framework.dll.J2EE"
+ Project = "{39CC8FF7-EF1A-41A1-B727-42684211ECD1}"
+ Package = "{83B010C7-76FC-4FAD-A26C-00D7EFE60256}"
+ />
+ <Reference
+ Name = "nunit.util.dll.J2EE"
+ Project = "{36BE0465-4DE4-44CE-AF8D-6E50D0C40BC6}"
+ Package = "{83B010C7-76FC-4FAD-A26C-00D7EFE60256}"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "DrawingTest\Test\AssemblyInfo.cs"
+ SubType = "Code"
+ 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..a6acc143026
--- /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="DrawingTest\Test\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="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="rt" AssemblyName="rt" HintPath="..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\jre5\rt.dll" Private="False"/>
+ <Reference Name="nunit.core.dll.J2EE" Project="{7C52A6A5-71ED-4468-9564-2FF5CD6E6E6C}" Package="{83B010C7-76FC-4FAD-A26C-00D7EFE60256}"/>
+ <Reference Name="nunit.framework.dll.J2EE" Project="{39CC8FF7-EF1A-41A1-B727-42684211ECD1}" Package="{83B010C7-76FC-4FAD-A26C-00D7EFE60256}"/>
+ <Reference Name="nunit.util.dll.J2EE" Project="{36BE0465-4DE4-44CE-AF8D-6E50D0C40BC6}" Package="{83B010C7-76FC-4FAD-A26C-00D7EFE60256}"/>
+ </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 project.JDKType="1.5.0_05" REFS.JarPath.rt="..\..\..\..\..\..\..\..\..\j2sdk1.4\lib\rt.jar" REFS.JarPath.system.xml="..\..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\System.Xml.jar" REFS.JarPath.system.data="..\..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\System.Data.jar" REFS.JarPath.system="..\..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\System.jar" REFS.JarPath.system.drawing="..\..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\System.Drawing.jar"/>
+ </CSHARP>
+ <VisualMainWin><Project Prop2023="1.5.0_05" Prop2024="" Prop2026="" Prop2015="" Version="1.7.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="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"/><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"/></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
diff --git a/mcs/class/System.Drawing/run-tests.bat b/mcs/class/System.Drawing/run-tests.bat
new file mode 100644
index 00000000000..9ea5669afc5
--- /dev/null
+++ b/mcs/class/System.Drawing/run-tests.bat
@@ -0,0 +1,52 @@
+@echo off
+REM ********************************************************
+REM This batch call all the test batches with default parameters
+REM ********************************************************
+REM ********************************************************
+REM This batch file receives the follwing parameters:
+REM build/rebuild (optional): should the solution file be rebuilded
+REM or just builded before test run (default is rebuild)
+REM ********************************************************
+
+IF "%1"=="" (
+ set BUILD_OPTION=rebuild
+) ELSE (
+ set BUILD_OPTION=%1
+)
+
+IF "%2"=="" (
+ set OUTPUT_FILE_PREFIX=System.Drawing.MonoTests.NUnitTestResult
+) ELSE (
+ set OUTPUT_FILE_PREFIX=%2
+)
+
+
+IF "%3"=="" (
+ set RUNNING_FIXTURE=MonoTests
+) ELSE (
+ set RUNNING_FIXTURE=%3
+)
+
+call run-tests.test.bat %BUILD_OPTION% %OUTPUT_FILE_PREFIX% %RUNNING_FIXTURE% "" ""
+
+IF "%1"=="" (
+ set BUILD_OPTION=rebuild
+) ELSE (
+ set BUILD_OPTION=%1
+)
+
+IF "%2"=="" (
+ set OUTPUT_FILE_PREFIX=System.Drawing.Test.NUnitTestResult
+) ELSE (
+ set OUTPUT_FILE_PREFIX=%2
+)
+
+
+IF "%3"=="" (
+ set RUNNING_FIXTURE=Test
+) ELSE (
+ set RUNNING_FIXTURE=%3
+)
+
+@echo on
+call run-tests.test.bat %BUILD_OPTION% %OUTPUT_FILE_PREFIX% %RUNNING_FIXTURE% "Test\DrawingTest\Test" "..\..\..\" \ No newline at end of file
diff --git a/mcs/class/System.Drawing/run-tests.test.bat b/mcs/class/System.Drawing/run-tests.test.bat
new file mode 100644
index 00000000000..b2b37af58d9
--- /dev/null
+++ b/mcs/class/System.Drawing/run-tests.test.bat
@@ -0,0 +1,163 @@
+@echo off
+REM ********************************************************
+REM This batch file receives the follwing parameters:
+REM build/rebuild (optional): should the solution file be rebuilded
+REM or just builded before test run (default is rebuild)
+REM output files name prefix (mandratory) : prefix for naming output xml files
+REM test fixture name (optional) : if you want to run some particular test fixture
+REM directory to run tests (optional)
+REM path back to root directory (opposite to previous param)
+REM example run-tests build GhTests Test.Sys.Drawing Test\DrawingTest\Test ..\..\..\
+REM will cause to build (and not rebuild) test solutions,
+REM running Test.Sys.Drawing fixture in directory Test\DrawingTest\Test
+REM with output files named GhTests.Net.xml and GhTests.GH.xml
+REM ********************************************************
+
+IF "%1"=="" GOTO USAGE
+
+IF "%JAVA_HOME%"=="" GOTO ENVIRONMENT_EXCEPTION
+
+IF "%GH_HOME%"=="" GOTO ENVIRONMENT_EXCEPTION
+
+REM ********************************************************
+REM Set parameters
+REM ********************************************************
+
+set BUILD_OPTION=%1
+set OUTPUT_FILE_PREFIX=%2
+set RUNNING_FIXTURE=%3
+set RUNNING_DIR=%~4
+set BACK_TO_ROOT_DIR=%~5
+
+
+REM ********************************************************
+REM @echo Set environment
+REM ********************************************************
+
+set JGAC_PATH=%GH_HOME%\jgac\vmw4j2ee_110\
+
+set RUNTIME_CLASSPATH=%JGAC_PATH%mscorlib.jar;%JGAC_PATH%System.jar;%JGAC_PATH%System.Xml.jar;%JGAC_PATH%System.Drawing.jar;%JGAC_PATH%J2SE.Helpers.jar;%JGAC_PATH%jai_imageio.jar
+set NUNIT_OPTIONS=/exclude=NotWorking
+
+set NET_OUTPUT_XML=%OUTPUT_FILE_PREFIX%.Net.xml
+set GH_OUTPUT_XML=%OUTPUT_FILE_PREFIX%.GH.xml
+
+set NUNIT_PATH=%BACK_TO_ROOT_DIR%..\..\nunit20\
+set NUNIT_CLASSPATH=%NUNIT_PATH%nunit-console\bin\Debug_Java\nunit.framework.jar;%NUNIT_PATH%nunit-console\bin\Debug_Java\nunit.util.jar;%NUNIT_PATH%nunit-console\bin\Debug_Java\nunit.core.jar;%NUNIT_PATH%nunit-console\bin\Debug_Java\nunit-console.jar
+set CLASSPATH="%RUNTIME_CLASSPATH%;%NUNIT_CLASSPATH%"
+
+
+REM ********************************************************
+@echo Building .Net solution...
+REM ********************************************************
+
+devenv Test\DrawingTest\System.Drawing.Test.dotnet.sln /%BUILD_OPTION% Debug >%RUNNING_FIXTURE%_build.log.txt 2<&1
+
+IF %ERRORLEVEL% NEQ 0 GOTO BUILD_EXCEPTION
+
+REM ********************************************************
+@echo Building GH solution...
+REM ********************************************************
+
+devenv Test\DrawingTest\System.Drawing.Test.sln /%BUILD_OPTION% Debug_Java >>%RUNNING_FIXTURE%_build.log.txt 2<&1
+
+IF %ERRORLEVEL% NEQ 0 GOTO BUILD_EXCEPTION
+
+REM ********************************************************
+@echo Building NUnit solution...
+REM ********************************************************
+
+devenv ..\..\nunit20\nunit.java.sln /%BUILD_OPTION% Debug_Java >>%RUNNING_FIXTURE%_build.log.txt 2<&1
+
+IF %ERRORLEVEL% NEQ 0 GOTO BUILD_EXCEPTION
+
+REM ********************************************************
+@echo Running Net reference tests...
+REM ********************************************************
+
+REM ********************************************************
+@echo Running fixture "%RUNNING_FIXTURE%"
+REM ********************************************************
+
+if "%RUNNING_DIR%" NEQ "" (
+ cd %RUNNING_DIR% )
+
+if not exist Exocortex.DSP.v1.dll (
+ copy %BACK_TO_ROOT_DIR%Test\DrawingTest\Test\Exocortex.DSP.v1.dll .)
+
+if not exist DrawingTest.dll (
+ copy %BACK_TO_ROOT_DIR%Test\DrawingTest\Test\DrawingTest.dll . )
+
+if not exist Test.dotnet.dll (
+ copy %BACK_TO_ROOT_DIR%Test\DrawingTest\Test\Test.dotnet.dll . )
+
+copy "%NUNIT_PATH%nunit-console\bin\Debug_Java\nunit-console.exe" .
+copy "%NUNIT_PATH%nunit-console\bin\Debug_Java\nunit.util.dll" .
+copy "%NUNIT_PATH%nunit-console\bin\Debug_Java\nunit.core.dll" .
+copy "%NUNIT_PATH%nunit-console\bin\Debug_Java\nunit.framework.dll" .
+nunit-console.exe /fixture:%RUNNING_FIXTURE% Test.dotnet.dll %NUNIT_OPTIONS% /xml=%NET_OUTPUT_XML% >%RUNNING_FIXTURE%_run.log.txt 2<&1
+
+
+REM ********************************************************
+@echo Running GH tests...
+REM ********************************************************
+
+REM ********************************************************
+@echo Running fixture "%RUNNING_FIXTURE%"
+REM ********************************************************
+
+copy %BACK_TO_ROOT_DIR%Test\DrawingTest\Test\bin\Debug_Java\Exocortex.DSP.v1.jar .
+copy %BACK_TO_ROOT_DIR%Test\DrawingTest\Test\bin\Debug_Java\DrawingTest.jar .
+copy %BACK_TO_ROOT_DIR%Test\DrawingTest\Test\bin\Debug_Java\Test.jar .
+
+
+REM @echo on
+"%JAVA_HOME%\bin\java" -Xmx1024M -cp %CLASSPATH% NUnit.Console.ConsoleUi Test.jar /fixture=%RUNNING_FIXTURE% %NUNIT_OPTIONS% /xml=%GH_OUTPUT_XML% >>%RUNNING_FIXTURE%_run.log.txt 2<&1
+REM @echo off
+
+if "%RUNNING_DIR%" NEQ "" (
+ copy %NET_OUTPUT_XML% %BACK_TO_ROOT_DIR%
+ copy %GH_OUTPUT_XML% %BACK_TO_ROOT_DIR%
+ cd %BACK_TO_ROOT_DIR% )
+
+REM ********************************************************
+@echo Build XmlTool
+REM ********************************************************
+set XML_TOOL_PATH=..\..\tools\mono-xmltool
+devenv %XML_TOOL_PATH%\XmlTool.sln /%BUILD_OPTION% Debug_Java >>%RUNNING_FIXTURE%_build.log.txt 2<&1
+
+IF %ERRORLEVEL% NEQ 0 GOTO BUILD_EXCEPTION
+
+copy %XML_TOOL_PATH%\bin\Debug_Java\xmltool.exe .
+copy %XML_TOOL_PATH%\nunit_transform.xslt .
+
+REM ********************************************************
+@echo Analyze and print results
+REM ********************************************************
+@echo on
+xmltool.exe --transform nunit_transform.xslt %GH_OUTPUT_XML%
+@echo off
+
+:FINALLY
+GOTO END
+
+:ENVIRONMENT_EXCEPTION
+@echo This test requires environment variables JAVA_HOME and GH_HOME to be defined
+GOTO END
+
+:BUILD_EXCEPTION
+@echo Error in building solutions. See %RUNNING_FIXTURE%_build.log.txt for details...
+REM EXIT 1
+GOTO END
+
+:RUN_EXCEPTION
+@echo Error in running fixture %RUNNING_FIXTURE%. See %RUNNING_FIXTURE%_run.log.txt for details...
+REM EXIT 1
+GOTO END
+
+:USAGE
+@echo Parameters: "[build|rebuild] <output_file_name_prefix> <test_fixture> <relative_Working_directory> <back_path (..\..\.....) >"
+GOTO END
+
+:END
+REM EXIT 0
diff --git a/mcs/class/System.Drawing/runmonotestfixture.bat b/mcs/class/System.Drawing/runmonotestfixture.bat
new file mode 100644
index 00000000000..0f201c89d4b
--- /dev/null
+++ b/mcs/class/System.Drawing/runmonotestfixture.bat
@@ -0,0 +1 @@
+run-tests.test.bat build %1 %1 "" "" \ No newline at end of file
diff --git a/mcs/class/System.Drawing/runtestfixture.bat b/mcs/class/System.Drawing/runtestfixture.bat
new file mode 100644
index 00000000000..306dab973ee
--- /dev/null
+++ b/mcs/class/System.Drawing/runtestfixture.bat
@@ -0,0 +1 @@
+run-tests.test.bat build %1 %1 Test\DrawingTest\Test ..\..\..\ \ No newline at end of file
diff --git a/mcs/ilasm/.cvsignore b/mcs/ilasm/.cvsignore
new file mode 100644
index 00000000000..6feccf7e4d3
--- /dev/null
+++ b/mcs/ilasm/.cvsignore
@@ -0,0 +1,4 @@
+list
+ILParser.cs
+ilasm.pdb
+ilasm.exe.mdb
diff --git a/mcs/ilasm/AssemblyInfo.cs b/mcs/ilasm/AssemblyInfo.cs
new file mode 100644
index 00000000000..56edc2e79dd
--- /dev/null
+++ b/mcs/ilasm/AssemblyInfo.cs
@@ -0,0 +1,8 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly: AssemblyVersion (Consts.MonoVersion)]
+[assembly: AssemblyTitle ("Mono ILasm Compiler")]
+[assembly: AssemblyDescription ("Mono ILasm Compiler")]
+[assembly: AssemblyCopyright ("Sergey Chaban and Jackson Harper")]
+
diff --git a/mcs/ilasm/ChangeLog b/mcs/ilasm/ChangeLog
new file mode 100644
index 00000000000..b075bfdb3c4
--- /dev/null
+++ b/mcs/ilasm/ChangeLog
@@ -0,0 +1,344 @@
+2006-02-20 Ankit Jain <jankit@novell.com>
+
+ * Report.cs (Report): Make all methods,fields static.
+ (Report.Error): Update to throw ILAsmException.
+ (ILAsmException): New.
+ (InternalErrorException): New. Derive from ILAsmException.
+ * Driver.cs (Driver.Run): Catch ILAsmException and PEFileException and
+ print error messages instead of dumping the stack trace, and delete the
+ output file if CodeGen.Write() fails.
+ Move the check for entrypoint from CodeGen.Write to here.
+
+2006-01-19 Ankit Jain <jankit@novell.com>
+
+ * ilasm.exe.sources: Add Module.cs to the build.
+
+2006-01-13 Ankit Jain <jankit@novell.com>
+
+ * ilasm.exe.sources: Replace IMethodRef.cs with BaseMethodRef.cs
+
+2006-01-09 Ankit Jain <jankit@novell.com>
+
+ * ilasm.exe.sources: Replace GenericTypeRef.cs with GenericParamRef.cs
+
+2006-01-07 Ankit Jain <jankit@novell.com>
+
+ * ilasm.exe.sources: Add GenericParameters.cs to the build.
+
+2006-01-06 Ankit Jain <jankit@novell.com>
+
+ * ilasm.exe.sources: Remove ExternTypeRefInst from build.
+
+2005-12-21 Ankit Jain <jankit@novell.com>
+
+ * ilasm.exe.sources: Add GenericArguments.cs to the build.
+
+2005-08-26 Kornél Pál <kornelpal@hotmail.com>
+
+ * AssemblyInfo.cs: Using Consts.MonoVersion instead of MonoVersion.cs.
+ * ilasm.exe.sources: Using Consts.MonoVersion instead of MonoVersion.cs.
+
+2005-08-05 Ankit Jain <jankit@novell.com>
+
+ * ilasm.exe.sources: Add DeclSecurity.cs to the build.
+
+2005-05-12 Ankit Jain <ankit@corewars.org>
+
+ * Makefile (LOCAL_MCS_FLAGS): Use the in-tree PEAPI.dll as its public
+ interface has changed a bit, so avoid clash with older installed
+ dll.
+
+2005-04-21 Raja R Harinath <rharinath@novell.com>
+
+ * Makefile (PROGRAM): Make profile-specific.
+
+2004-12-08 Sebastien Pouliot <sebastien@ximian.com>
+
+ * Driver.cs: Added support for /key option to strongname assemblies
+ produced by ilasm. Fix bug #69721.
+ * Makefile: Added dependency on Mono.Security.dll assembly to provide
+ strongnaming support.
+
+2004-12-02 Miguel de Icaza <miguel@ximian.com>
+
+ * CodeGen.cs: Correctly compute the name of a nested class,
+ currently it was ignoring anything above level 1.
+
+2004-07-27 Jackson Harper <jackson@ximian.com>
+
+ * Driver.cs: Make debug switch compatible with MS's add debug to
+ the usage.
+
+2004-07-27 Martin Baulig <martin@ximian.com>
+
+ Added debugging support to ilasm :-)
+
+ * Makefile: Depend on Mono.CSharp.Debugger.dll (this is only
+ exposed in DebuggingInfo.cs, so we can easily change that).
+
+ * Driver.cs: Added --debug command line argument to create
+ debugging info; this'll create a .mdb symbol file.
+
+2004-06-26 Jackson Harper <jackson@ximian.com>
+
+ * Report.cs: Fix quiet.
+
+2004-06-24 Jackson Harper <jackson@ximian.com>
+
+ * Report.cs: Add new mehtod for displaying messages.
+
+2004-06-23 Jackson Harper <jackson@ximian.com>
+
+ * Driver.cs: Use the same success message as MS.
+
+2004-06-19 Jackson Harper <jackson@ximian.com>
+
+ * ilasm.exe.sources: Add MethodPointerTypeRef.cs to the build.
+
+2004-06-14 Jackson Harper <jackson@ximian.com>
+
+ * ilasm.exe.sources: Add FileRef.cs
+
+2004-06-10 Jackson Harper <jackson@ximian.com>
+
+ * Driver.cs: Handle tokenization errors with the correct error
+ message.
+ * Report.cs: Print error messages properly. Add an extra \n after
+ the assemble file message.
+ * ilasm.exe.sources: Add new exception, remove old one.
+
+2004-06-04 Jackson Harper <jackson@ximian.com>
+
+ * Driver.cs: Do everything using the invariant culture.
+
+2004-04-26 Jackson Harper <jackson@ximian.com>
+
+ * Makefile: Get libs from the default profile directory
+
+2004-04-05 Jackson Harper <jackson@ximian.com>
+
+ * Driver.cs: Accept output option. Usage shows /output instead of
+ /out like MS.
+
+2004-04-01 Jackson Harper <jackson@ximian.com>
+
+ * Driver.cs: The parser now needs to take a scanner object in its
+ constructor so it can set a flag when parsing byte arrays.
+
+2004-02-18 Jackson Harper <jackson@ximian.com>
+
+ * ilasm.exe.sources: Add ExternTypeRefInst to the build.
+
+2003-11-16 Jackson Harper <jackson@ximian.com>
+
+ * Driver.cs: Give the parser an instance of the stream reader so
+ it can get the streams encoding.
+
+2003-11-16 Jackson Harper <jackson@ximian.com>
+
+ * Driver.cs: If an arg isn't a switch and starts with a / add it
+ as a file to be compiled. This fixes bug #51041.
+
+2003-10-28 Jackson Harper <jackson@ximian.com>
+
+ * Driver.cs: Stub some command line args to maintain compatibility
+ with MS.
+
+2003-10-01 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: Remove delete on error, add quiet option.
+ * Report.cs: Can be quiet
+
+2003-09-21 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: Give codegen a report object
+ * Report.cs: Remove silly methods that wouldnt have worked. Errors
+ are just string messages.
+
+2003-08-14 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: Report entry for each il file processed
+ * Report.cs: New file - All error/warning/progress reporting will
+ go through here.
+ * ilasm.exe.sources: Add report to build
+
+2003-08-12 Jackson Harper <jackson@latitudegeo.com>
+
+ * AssemblyInfo.cs: Bump up the vizzity-version number.
+
+2003-07-30 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: Throw compile errors for now
+
+2003-07-30 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: Add some basic line number feedback when an error
+ occurs
+
+2003-07-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * ilasm.exe.sources: Add corlib/GenericTypeRef.cs to build
+
+2003-07-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: Use WriteLine for 'compilation succeeded' message.
+
+2003-07-16 Peter Williams <peter@newton.cx>
+
+ * Makefile (ILParser.cs): Move this from parser/ so we avoid
+ slash direction issues on the Windows build.
+
+ * .cvsignore: Add ILParser.cs here.
+
+2003-07-14 Jackson Harper <jackson@latitudegeo.com>
+
+ * Makefile: Add the class/lib directory to the lib path so the
+ newest PEAPI is allways loaded.
+
+2003-06-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * AssemblyInfo.cs: Bump version number up (way up) lots of
+ features have been implemented since last version.
+
+2003-05-19 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: Exit with 1 return code when no arguments are supplied.
+
+2003-05-19 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: Add command switch to delete output files created if
+ there is an error.
+
+2003-05-19 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: Print error exception when compilation fails.
+
+2003-05-18 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: Return an error code if any errors occur during
+ compiling. Also print a success or error message.
+
+2003-05-02 Jackson Harper <jackson@latitudegeo.com>
+
+ * AssemblyInfo.cs: Bump up version number
+
+2003-04-30 Jackson Harper <jackson@latitudegeo.com>
+
+ * makefile: Add instructions to build
+ * makefile.gnu: Add instructions to build
+
+2003-04-20 Jackson Harper <jackson@latitudegeo.com>
+
+ * makefile: Add DataDef to build
+ * makefile.gnu: Add DataDef to build
+
+2003-04-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * makefile: Add new types to build
+ * makefile.gnu: Add new types to build
+
+2003-04-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * AssemblyInfo.cs: Increase version number.
+
+2003-04-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: Call new codegen methods.
+ * makefile: Add new types to build
+ * makefile.gnu: Add new types to build
+
+2003-03-31 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: de-tabbify
+
+2003-03-29 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: Add switch to display parser debugging information.
+
+2003-03-16 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: Add switch to display method definitions and references.
+
+2003-03-16 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: Add switch to display tokens as they are generated.
+
+2003-03-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * makefile, makefile.gnu: Add FieldTable to build
+
+Fri Mar 14 10:06:49 CET 2003 Paolo Molaro <lupus@ximian.com>
+
+ * codegen/InstrTable.cs: fix break instruction name.
+ * codegen/Method.cs: use ArgumentNullException.
+ * parser/ILParser.jay: handle stdcall convention.
+
+2003-03-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * makefile, makefile.gnu: Add InstrTable to build
+
+2003-03-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * makefile, makefile.gnu: Add MethodTable and TypeRef to build.
+
+2003-03-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * makefile, makefile.gnu: Add ExternTable to build
+
+2003-03-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: If a file does not exist print an error and exit.
+
+2003-03-07 Alp Toker <alp@atoker.com>
+
+ * makefile, makefile.gnu: reference PEAPI.dll instead of including
+ PEAPI.cs
+
+2003-03-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * AssemblyInfo.cs: Bump up version number, this new version is a major
+ structural change, PEAPI is now being used for code emission.
+ * makefile, makefile.gnu: Add AssemblyInfo.cs to build
+
+2003-03-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: Check that all types are defined before writing pe file
+
+2003-03-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * makefile, makefile.gnu: Include PEAPI.cs instead of linking to it, this fixes build but is not ideal.
+
+2003-03-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: Change a few calls to match new CodeGen
+ * makefile: Build with PEAPI
+ * makefile.gnu: Build with PEAPI
+
+2003-02-22 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: Add version option, fix bug that allowed -- switches to be invoked with /-
+
+2003-02-21 Jackson Harper <jackson@latitudegeo.com>
+
+ * AssemblyInfo.cs: Add file
+ * makefile: Add AssemblyInfo to build
+ * makefile.gnu: Add AssemblyInfo to build
+
+2003-02-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * makefile: Add TypeManager.cs to build
+ * makefile.gnu: Add TypeManager.cs to build
+
+2003-02-03 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: Remove some debugging info.
+
+2003-02-02 Jackson Harper <jackson@latitudegeo.com>
+
+ * makefile.gnu: Use new Driver.cs instead of Main.cs
+
+2003-02-02 Jackson Harper <jackson@latitudegeo.com>
+
+ * Driver.cs: Add new Driver
+ * tests: Add new tests directory
+ * makefile: Use new Driver.cs instead of Main.cs
diff --git a/mcs/ilasm/Driver.cs b/mcs/ilasm/Driver.cs
new file mode 100644
index 00000000000..d4315f4c640
--- /dev/null
+++ b/mcs/ilasm/Driver.cs
@@ -0,0 +1,357 @@
+//
+// Mono.ILASM.Driver
+// Main Command line interface for Mono ILasm Compiler
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using System.IO;
+using System.Reflection;
+using System.Collections;
+using System.Security.Cryptography;
+using Mono.Security;
+
+namespace Mono.ILASM {
+
+ public class Driver {
+
+ enum Target {
+ Dll,
+ Exe
+ }
+
+ public static int Main (string[] args)
+ {
+ // Do everything in Invariant
+ System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
+
+ DriverMain driver = new DriverMain (args);
+ if (!driver.Run ())
+ return 1;
+ Console.WriteLine ("Operation completed successfully");
+ return 0;
+ }
+
+ private class DriverMain {
+
+ private ArrayList il_file_list;
+ private string output_file;
+ private Target target = Target.Exe;
+ private string target_string = "exe";
+ private bool show_tokens = false;
+ private bool show_method_def = false;
+ private bool show_method_ref = false;
+ private bool show_parser = false;
+ private bool scan_only = false;
+ private bool debugging_info = false;
+ private CodeGen codegen;
+ private bool keycontainer = false;
+ private string keyname;
+
+ public DriverMain (string[] args)
+ {
+ il_file_list = new ArrayList ();
+ ParseArgs (args);
+ }
+
+ public bool Run ()
+ {
+ if (il_file_list.Count == 0)
+ Usage ();
+ if (output_file == null)
+ output_file = CreateOutputFilename ();
+ try {
+ codegen = new CodeGen (output_file, target == Target.Dll, true, debugging_info);
+ foreach (string file_path in il_file_list)
+ ProcessFile (file_path);
+ if (scan_only)
+ return true;
+
+ if (Report.ErrorCount > 0)
+ return false;
+
+ if (target != Target.Dll && !codegen.HasEntryPoint)
+ Report.Error ("No entry point found.");
+
+ try {
+ codegen.Write ();
+ } catch {
+ File.Delete (output_file);
+ throw;
+ }
+ } catch (ILAsmException e) {
+ Error (e.Message);
+ return false;
+ } catch (PEAPI.PEFileException pe) {
+ Error (pe.Message);
+ return false;
+ }
+
+ try {
+ if (keyname != null) {
+ Console.WriteLine ("Signing assembly with the specified strongname keypair");
+ return Sign (output_file);
+ }
+ } catch {
+ return false;
+ }
+
+ return true;
+ }
+
+ private void Error (string message)
+ {
+ Console.WriteLine ("Error : " + message + "\n");
+ Console.WriteLine ("***** FAILURE *****\n");
+ }
+
+ private bool Sign (string filename)
+ {
+ // note: if the file cannot be signed (no public key in it) then
+ // we do not show an error, or a warning, if the key file doesn't
+ // exists
+ StrongName sn = null;
+ if (keycontainer) {
+ CspParameters csp = new CspParameters ();
+ csp.KeyContainerName = keyname;
+ RSACryptoServiceProvider rsa = new RSACryptoServiceProvider (csp);
+ sn = new StrongName (rsa);
+ } else {
+ byte[] data = null;
+ using (FileStream fs = File.OpenRead (keyname)) {
+ data = new byte [fs.Length];
+ fs.Read (data, 0, data.Length);
+ fs.Close ();
+ }
+ sn = new StrongName (data);
+ }
+ return sn.Sign (filename);
+ }
+
+ private void ProcessFile (string file_path)
+ {
+ if (!File.Exists (file_path)) {
+ Console.WriteLine ("File does not exist: {0}",
+ file_path);
+ Environment.Exit (2);
+ }
+ Report.AssembleFile (file_path, null,
+ target_string, output_file);
+ StreamReader reader = File.OpenText (file_path);
+ ILTokenizer scanner = new ILTokenizer (reader);
+
+ if (show_tokens)
+ scanner.NewTokenEvent += new NewTokenEvent (ShowToken);
+ //if (show_method_def)
+ // MethodTable.MethodDefinedEvent += new MethodDefinedEvent (ShowMethodDef);
+ //if (show_method_ref)
+ // MethodTable.MethodReferencedEvent += new MethodReferencedEvent (ShowMethodRef);
+
+ if (scan_only) {
+ ILToken tok;
+ while ((tok = scanner.NextToken) != ILToken.EOF) {
+ Console.WriteLine (tok);
+ }
+ return;
+ }
+
+ ILParser parser = new ILParser (codegen, scanner);
+ codegen.BeginSourceFile (file_path);
+ try {
+ if (show_parser)
+ parser.yyparse (new ScannerAdapter (scanner),
+ new yydebug.yyDebugSimple ());
+ else
+ parser.yyparse (new ScannerAdapter (scanner), null);
+ } catch (ILTokenizingException ilte) {
+ Report.Error (file_path + "(" + ilte.Location.line + ") : error : " +
+ "syntax error at token '" + ilte.Token + "'.");
+ } catch (Mono.ILASM.yyParser.yyException) {
+ Report.Error ("Error at: " + scanner.Reader.Location);
+ } catch {
+ Console.WriteLine ("Error at: " + scanner.Reader.Location);
+ throw;
+ } finally {
+ codegen.EndSourceFile ();
+ }
+ }
+
+ public void ShowToken (object sender, NewTokenEventArgs args)
+ {
+ Console.WriteLine ("token: '{0}'", args.Token);
+ }
+ /*
+ public void ShowMethodDef (object sender, MethodDefinedEventArgs args)
+ {
+ Console.WriteLine ("***** Method defined *****");
+ Console.WriteLine ("-- signature: {0}", args.Signature);
+ Console.WriteLine ("-- name: {0}", args.Name);
+ Console.WriteLine ("-- return type: {0}", args.ReturnType);
+ Console.WriteLine ("-- is in table: {0}", args.IsInTable);
+ Console.WriteLine ("-- method atts: {0}", args.MethodAttributes);
+ Console.WriteLine ("-- impl atts: {0}", args.ImplAttributes);
+ Console.WriteLine ("-- call conv: {0}", args.CallConv);
+ }
+
+ public void ShowMethodRef (object sender, MethodReferencedEventArgs args)
+ {
+ Console.WriteLine ("***** Method referenced *****");
+ Console.WriteLine ("-- signature: {0}", args.Signature);
+ Console.WriteLine ("-- name: {0}", args.Name);
+ Console.WriteLine ("-- return type: {0}", args.ReturnType);
+ Console.WriteLine ("-- is in table: {0}", args.IsInTable);
+ }
+ */
+ private void ParseArgs (string[] args)
+ {
+ string command_arg;
+ foreach (string str in args) {
+ if ((str[0] != '-') && (str[0] != '/')) {
+ il_file_list.Add (str);
+ continue;
+ }
+ switch (GetCommand (str, out command_arg)) {
+ case "out":
+ case "output":
+ output_file = command_arg;
+ break;
+ case "exe":
+ target = Target.Exe;
+ target_string = "exe";
+ break;
+ case "dll":
+ target = Target.Dll;
+ target_string = "dll";
+ break;
+ case "quiet":
+ Report.Quiet = true;
+ break;
+ case "debug":
+ case "deb":
+ if (str[0] != '-')
+ break;
+ debugging_info = true;
+ break;
+ // Stubs to stay commandline compatible with MS
+ case "listing":
+ case "nologo":
+ case "clock":
+ case "error":
+ case "subsystem":
+ case "flags":
+ case "alignment":
+ case "base":
+ case "resource":
+ break;
+ case "key":
+ if (command_arg.Length > 0)
+ keycontainer = (command_arg [0] == '@');
+ if (keycontainer)
+ keyname = command_arg.Substring (1);
+ else
+ keyname = command_arg;
+ break;
+ case "scan_only":
+ scan_only = true;
+ break;
+ case "show_tokens":
+ show_tokens = true;
+ break;
+ case "show_method_def":
+ show_method_def = true;
+ break;
+ case "show_method_ref":
+ show_method_ref = true;
+ break;
+ case "show_parser":
+ show_parser = true;
+ break;
+ case "-about":
+ if (str[0] != '-')
+ break;
+ About ();
+ break;
+ case "-version":
+ if (str[0] != '-')
+ break;
+ Version ();
+ break;
+ default:
+ if (str [0] == '-')
+ break;
+ il_file_list.Add (str);
+ break;
+ }
+ }
+ }
+
+ private string GetCommand (string str, out string command_arg)
+ {
+ int end_index = str.IndexOfAny (new char[] {':', '='}, 1);
+ string command = str.Substring (1,
+ end_index == -1 ? str.Length - 1 : end_index - 1);
+
+ if (end_index != -1) {
+ command_arg = str.Substring (end_index+1);
+ } else {
+ command_arg = null;
+ }
+
+ return command.ToLower ();
+ }
+
+ /// <summary>
+ /// Get the first file name and makes it into an output file name
+ /// </summary>
+ private string CreateOutputFilename ()
+ {
+ string file_name = (string)il_file_list[0];
+ int ext_index = file_name.LastIndexOf ('.');
+
+ if (ext_index == -1)
+ ext_index = file_name.Length;
+
+ return String.Format ("{0}.{1}", file_name.Substring (0, ext_index),
+ target_string);
+ }
+
+ private void Usage ()
+ {
+ Console.WriteLine ("Mono ILasm compiler\n" +
+ "ilasm [options] source-files\n" +
+ " --about About the Mono ILasm compiler\n" +
+ " --version Print the version number of the Mono ILasm compiler\n" +
+ " /output:file_name Specifies output file.\n" +
+ " /exe Compile to executable.\n" +
+ " /dll Compile to library.\n" +
+ " /debug Include debug information.\n" +
+ " /key:keyfile Strongname using the specified key file\n" +
+ " /key:@container Strongname using the specified key container\n" +
+ "Options can be of the form -option or /option\n");
+ Environment.Exit (1);
+ }
+
+ private void About ()
+ {
+ Console.WriteLine (
+ "For more information on Mono, visit the project Web site\n" +
+ " http://www.go-mono.com\n\n");
+ Environment.Exit (0);
+ }
+
+ private void Version ()
+ {
+ string version = Assembly.GetExecutingAssembly ().GetName ().Version.ToString ();
+ Console.WriteLine ("Mono ILasm compiler version {0}", version);
+ Environment.Exit (0);
+ }
+
+ }
+ }
+}
+
diff --git a/mcs/ilasm/Main.cs b/mcs/ilasm/Main.cs
new file mode 100644
index 00000000000..a7fe5edb133
--- /dev/null
+++ b/mcs/ilasm/Main.cs
@@ -0,0 +1,39 @@
+using System;
+using System.IO;
+
+using Mono.ILASM;
+
+
+public class ILAsmTest {
+ private ILAsmTest() {}
+
+
+ public static int Main (string [] args) {
+
+ if (args.Length != 1) {
+ Console.WriteLine ("Usage : ilasm [filename]");
+ return 1;
+ }
+
+ StreamReader reader = File.OpenText (args [0]);
+ ILTokenizer scanner = new ILTokenizer (reader);
+
+ bool testScanner = true;
+
+ if (testScanner) {
+ ILToken tok;
+ while ((tok = scanner.NextToken) != ILToken.EOF) {
+ Console.WriteLine (tok);
+ }
+ } else {
+ ILParser parser = new ILParser (new CodeGen ());
+ parser.yyparse (new ScannerAdapter (scanner), new yydebug.yyDebugSimple ());
+
+ CodeGen cg = parser.CodeGen;
+ int n = cg.ClassCount;
+ cg.Emit ();
+ }
+
+ return 0;
+ }
+}
diff --git a/mcs/ilasm/Makefile b/mcs/ilasm/Makefile
new file mode 100644
index 00000000000..7df9413c4e2
--- /dev/null
+++ b/mcs/ilasm/Makefile
@@ -0,0 +1,29 @@
+thisdir = ilasm
+SUBDIRS =
+include ../build/rules.make
+
+PROGRAM = $(topdir)/class/lib/$(PROFILE)/ilasm.exe
+BUILT_SOURCES = ILParser.cs
+LOCAL_MCS_FLAGS = /lib:../class/lib/$(PROFILE) /r:../class/lib/$(PROFILE)/PEAPI.dll /r:Mono.CompilerServices.SymbolWriter.dll /r:Mono.Security.dll
+
+CLEAN_FILES = parser/y.output
+
+EXTRA_DISTFILES = \
+ parser/ILParser.jay \
+ parser/ChangeLog \
+ scanner/ChangeLog \
+ tests/ChangeLog \
+ $(wildcard tests/*.il)
+
+ILParser.cs: parser/ILParser.jay $(topdir)/jay/skeleton.cs
+ $(topdir)/jay/jay -ct < $(topdir)/jay/skeleton.cs $< >$@
+
+include ../build/executable.make
+
+ifeq (default, $(PROFILE))
+# Utility rule to make debugging somewhat easier.
+all-local: ilasm.exe
+ilasm.exe: $(PROGRAM)
+ cp -p $< $@
+ test ! -f $<.mdb || cp -p $<.mdb $@.mdb
+endif
diff --git a/mcs/ilasm/Report.cs b/mcs/ilasm/Report.cs
new file mode 100644
index 00000000000..02d65362532
--- /dev/null
+++ b/mcs/ilasm/Report.cs
@@ -0,0 +1,102 @@
+//
+// Mono.ILASM.Report
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+using System.IO;
+
+namespace Mono.ILASM {
+
+ public abstract class Report {
+
+ private static int error_count;
+ private static int mark_count;
+ private static bool quiet;
+
+ static Report ()
+ {
+ error_count = 0;
+ quiet = false;
+ }
+
+ public static int ErrorCount {
+ get { return error_count; }
+ }
+
+ public static bool Quiet {
+ get { return quiet; }
+ set { quiet = value; }
+ }
+
+ public static void AssembleFile (string file, string listing,
+ string target, string output)
+ {
+ Console.WriteLine ("Assembling '{0}' , {1}, to {2} --> '{3}'", file,
+ GetListing (listing), target, output);
+ Console.WriteLine ();
+ }
+
+ public static void Error (string message)
+ {
+ error_count++;
+ throw new ILAsmException (message);
+ }
+
+ public static void Message (string message)
+ {
+ if (quiet)
+ return;
+ Console.WriteLine (message);
+ }
+
+ private static string GetListing (string listing)
+ {
+ if (listing == null)
+ return "no listing file";
+ return listing;
+ }
+
+ }
+
+ public class ILAsmException : Exception {
+
+ string message;
+ Location location;
+
+ public ILAsmException (Location location, string message)
+ {
+ this.location = location;
+ this.message = message;
+ }
+
+ public ILAsmException (string message)
+ {
+ this.message = message;
+ }
+
+ public override string Message {
+ get { return message; }
+ }
+
+ }
+
+ public class InternalErrorException : Exception {
+ public InternalErrorException ()
+ : base ("Internal error")
+ {
+ }
+
+ public InternalErrorException (string message)
+ : base (message)
+ {
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/.cvsignore b/mcs/ilasm/codegen/.cvsignore
new file mode 100644
index 00000000000..6cf78161dc9
--- /dev/null
+++ b/mcs/ilasm/codegen/.cvsignore
@@ -0,0 +1 @@
+semantic.cache
diff --git a/mcs/ilasm/codegen/AssemblyNameStore.cs b/mcs/ilasm/codegen/AssemblyNameStore.cs
new file mode 100644
index 00000000000..e138a639ca6
--- /dev/null
+++ b/mcs/ilasm/codegen/AssemblyNameStore.cs
@@ -0,0 +1,47 @@
+//
+// Mono.ILASM.AssemblyNameStore
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+using System.Reflection;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class AssemblyNameStore {
+
+ private Hashtable name_store;
+
+ public AssemblyNameStore ()
+ {
+
+ }
+
+ public void Add (AssemblyName assembly_name)
+ {
+ if (name_store == null)
+ name_store = new Hashtable ();
+ name_store.Add (assembly_name.Name, assembly_name);
+ }
+
+ public Assembly Get (string name)
+ {
+ AssemblyName assembly_name;
+
+ assembly_name = (AssemblyName)name_store[name];
+
+ if (assembly_name == null)
+ return null;
+
+ return Assembly.Load (assembly_name);
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/BaseClassRef.cs b/mcs/ilasm/codegen/BaseClassRef.cs
new file mode 100644
index 00000000000..0be33e7be17
--- /dev/null
+++ b/mcs/ilasm/codegen/BaseClassRef.cs
@@ -0,0 +1,71 @@
+//
+// Mono.ILASM.BaseClassRef
+//
+// Author(s):
+// Ankit Jain <jankit@novell.com>
+//
+// Copyright 2006 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public abstract class BaseClassRef : BaseTypeRef {
+
+ protected Hashtable p_genericinst_table;
+ protected bool is_valuetype;
+
+ protected BaseClassRef (string full_name, bool is_valuetype)
+ : this (full_name, is_valuetype, null, null)
+ {
+ }
+
+ protected BaseClassRef (string full_name, bool is_valuetype, ArrayList conv_list, string sig_mod)
+ : base (full_name, conv_list, sig_mod)
+ {
+ this.is_valuetype = is_valuetype;
+ p_genericinst_table = null;
+ }
+
+ public PEAPI.Class PeapiClass {
+ get { return type as PEAPI.Class; }
+ }
+
+ public abstract BaseClassRef Clone ();
+
+ public virtual void MakeValueClass ()
+ {
+ is_valuetype = true;
+ }
+
+ public virtual GenericTypeInst GetGenericTypeInst (GenericArguments gen_args)
+ {
+ return new GenericTypeInst (this, gen_args, is_valuetype);
+ }
+
+ public virtual PEAPI.Type ResolveInstance (CodeGen code_gen, GenericArguments gen_args)
+ {
+ PEAPI.GenericTypeInst gtri = null;
+ string sig = gen_args.ToString ();
+
+ if (p_genericinst_table == null)
+ p_genericinst_table = new Hashtable ();
+ else
+ gtri = p_genericinst_table [sig] as PEAPI.GenericTypeInst;
+
+ if (gtri == null) {
+ if (!IsResolved)
+ Resolve (code_gen);
+
+ gtri = new PEAPI.GenericTypeInst (PeapiType, gen_args.Resolve (code_gen));
+ p_genericinst_table [sig] = gtri;
+ }
+
+ return gtri;
+ }
+ }
+
+
+}
diff --git a/mcs/ilasm/codegen/BaseGenericTypeRef.cs b/mcs/ilasm/codegen/BaseGenericTypeRef.cs
new file mode 100644
index 00000000000..3e0be9a7703
--- /dev/null
+++ b/mcs/ilasm/codegen/BaseGenericTypeRef.cs
@@ -0,0 +1,42 @@
+//
+// Mono.ILASM.BaseGenericTypeRef
+//
+// Author(s):
+// Ankit Jain <jankit@novell.com>
+//
+// Copyright 2006 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public abstract class BaseGenericTypeRef : BaseClassRef {
+ public BaseGenericTypeRef (string full_name, bool is_valuetype, ArrayList conv_list, string sig_mod)
+ : base (full_name, is_valuetype, conv_list, sig_mod)
+ {
+ }
+
+ /* Used to resolve any gen params in arguments, constraints etc */
+ public abstract void Resolve (GenericParameters type_gen_params, GenericParameters method_gen_params);
+
+ /* Only resolves, does not add it to the TypeSpec
+ table */
+ public abstract void ResolveNoTypeSpec (CodeGen code_gen);
+
+ public override GenericTypeInst GetGenericTypeInst (GenericArguments gen_args)
+ {
+ Report.Error ("Invalid attempt to create '" + FullName + "''" + gen_args.ToString () + "'");
+ return null;
+ }
+
+ public override PEAPI.Type ResolveInstance (CodeGen code_gen, GenericArguments gen_args)
+ {
+ Report.Error ("Invalid attempt to create '" + FullName + "''" + gen_args.ToString () + "'");
+ return null;
+ }
+ }
+
+
+}
diff --git a/mcs/ilasm/codegen/BaseMethodRef.cs b/mcs/ilasm/codegen/BaseMethodRef.cs
new file mode 100644
index 00000000000..73c7b1e2740
--- /dev/null
+++ b/mcs/ilasm/codegen/BaseMethodRef.cs
@@ -0,0 +1,79 @@
+//
+// Mono.ILASM.BaseMethodRef
+//
+// Author(s):
+// Ankit Jain <JAnkit@novell.com>
+//
+// Copyright 2006 Novell, Inc (http://www.novell.com)
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+ public abstract class BaseMethodRef {
+
+ protected BaseTypeRef owner;
+ protected PEAPI.CallConv call_conv;
+ protected BaseTypeRef ret_type;
+ protected string name;
+ protected BaseTypeRef[] param;
+
+ protected PEAPI.Method peapi_method;
+ protected bool is_resolved;
+ protected int gen_param_count;
+
+ protected Hashtable gen_method_table;
+
+ public BaseMethodRef (BaseTypeRef owner, PEAPI.CallConv call_conv,
+ BaseTypeRef ret_type, string name, BaseTypeRef[] param, int gen_param_count)
+ {
+ this.owner = owner;
+ this.call_conv = call_conv;
+ this.ret_type = ret_type;
+ this.name = name;
+ this.param = param;
+ this.gen_param_count = gen_param_count;
+ if (gen_param_count > 0)
+ CallConv |= PEAPI.CallConv.Generic;
+ is_resolved = false;
+ }
+
+ public virtual PEAPI.Method PeapiMethod {
+ get { return peapi_method; }
+ }
+
+ public virtual PEAPI.CallConv CallConv {
+ get { return call_conv; }
+ set { call_conv = value; }
+ }
+
+ public virtual BaseTypeRef Owner {
+ get { return owner; }
+ }
+
+ public abstract void Resolve (CodeGen code_gen);
+
+ public GenericMethodRef GetGenericMethodRef (GenericArguments gen_args)
+ {
+ GenericMethodRef methref = null;
+
+ if (gen_method_table == null)
+ gen_method_table = new Hashtable ();
+ else
+ methref = (GenericMethodRef) gen_method_table [gen_args.ToString ()];
+
+ if (methref == null) {
+ methref = new GenericMethodRef (this, GenericMethodSig.GetInstance (gen_args));
+ gen_method_table [gen_args.ToString ()] = methref;
+ }
+
+ return methref;
+ }
+
+ }
+}
+
+
+
diff --git a/mcs/ilasm/codegen/BaseTypeRef.cs b/mcs/ilasm/codegen/BaseTypeRef.cs
new file mode 100644
index 00000000000..117a629c7c8
--- /dev/null
+++ b/mcs/ilasm/codegen/BaseTypeRef.cs
@@ -0,0 +1,101 @@
+//
+// Mono.ILASM.BaseTypeRef
+//
+// Author(s):
+// Ankit Jain <jankit@novell.com>
+//
+// Copyright 2006 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public abstract class BaseTypeRef : ModifiableType {
+ protected string full_name;
+ protected string sig_mod;
+ protected PEAPI.Type type;
+ protected bool is_resolved;
+ protected Hashtable method_table;
+ protected Hashtable field_table;
+
+ protected BaseTypeRef (string full_name)
+ : this (full_name, null, null)
+ {
+ }
+
+ protected BaseTypeRef (string full_name, ArrayList conv_list, string sig_mod)
+ {
+ this.full_name = full_name;
+ this.sig_mod = sig_mod;
+ is_resolved = false;
+ if (conv_list != null)
+ ConversionList = conv_list;
+ }
+
+ public virtual string FullName {
+ get { return full_name + sig_mod; }
+ }
+
+ public override string SigMod {
+ get { return sig_mod; }
+ set { sig_mod = value; }
+ }
+
+ public PEAPI.Type PeapiType {
+ get { return type; }
+ }
+
+ public bool IsResolved {
+ get { return is_resolved; }
+ }
+
+ public abstract void Resolve (CodeGen code_gen);
+
+ protected abstract BaseMethodRef CreateMethodRef (BaseTypeRef ret_type,
+ PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count);
+
+ public virtual BaseMethodRef GetMethodRef (BaseTypeRef ret_type,
+ PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count)
+ {
+ BaseMethodRef mr = null;
+
+ /* Note: FullName not reqd as this is cached per object */
+ string key = MethodDef.CreateSignature (ret_type, name, param, gen_param_count);
+ if (method_table == null)
+ method_table = new Hashtable ();
+ else
+ mr = (BaseMethodRef) method_table [key];
+
+ if (mr == null) {
+ mr = CreateMethodRef (ret_type, call_conv, name, param, gen_param_count);
+ method_table [key] = mr;
+ }
+
+ return mr;
+ }
+
+ protected abstract IFieldRef CreateFieldRef (BaseTypeRef ret_type, string name);
+
+ public virtual IFieldRef GetFieldRef (BaseTypeRef ret_type, string name)
+ {
+ IFieldRef fr = null;
+ string key = ret_type.FullName + name;
+
+ if (field_table == null)
+ field_table = new Hashtable ();
+ else
+ fr = (IFieldRef) field_table [key];
+
+ if (fr == null) {
+ fr = CreateFieldRef (ret_type, name);
+ field_table [key] = fr;
+ }
+
+ return fr;
+ }
+
+ }
+
+}
diff --git a/mcs/ilasm/codegen/BranchInstr.cs b/mcs/ilasm/codegen/BranchInstr.cs
new file mode 100644
index 00000000000..168112bd507
--- /dev/null
+++ b/mcs/ilasm/codegen/BranchInstr.cs
@@ -0,0 +1,36 @@
+//
+// Mono.ILASM.BranchInstr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+
+namespace Mono.ILASM {
+
+ public class BranchInstr : IInstr {
+
+ private PEAPI.BranchOp op;
+ private LabelInfo label;
+
+ public BranchInstr (PEAPI.BranchOp op, LabelInfo label, Location loc)
+ : base (loc)
+ {
+ this.op = op;
+ this.label = label;
+ }
+
+ public override void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
+ {
+ cil.Branch (op, label.Label);
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/CalliInstr.cs b/mcs/ilasm/codegen/CalliInstr.cs
new file mode 100644
index 00000000000..676e7462f63
--- /dev/null
+++ b/mcs/ilasm/codegen/CalliInstr.cs
@@ -0,0 +1,56 @@
+//
+// Mono.ILASM.CalliInstr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+
+namespace Mono.ILASM {
+
+ public class CalliInstr : IInstr {
+
+ private PEAPI.CallConv call_conv;
+ private BaseTypeRef ret_type;
+ private BaseTypeRef[] param;
+
+ public CalliInstr (PEAPI.CallConv call_conv, BaseTypeRef ret_type,
+ BaseTypeRef[] param, Location loc)
+ : base (loc)
+ {
+ this.call_conv = call_conv;
+ this.ret_type = ret_type;
+ this.param = param;
+ }
+
+ public override void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
+ {
+ PEAPI.Type[] param_array;
+ PEAPI.CalliSig callisig;
+
+ if (param != null) {
+ param_array = new PEAPI.Type[param.Length];
+ int count = 0;
+ foreach (BaseTypeRef typeref in param) {
+ typeref.Resolve (code_gen);
+ param_array[count++] = typeref.PeapiType;
+ }
+ } else {
+ param_array = new PEAPI.Type[0];
+ }
+
+ ret_type.Resolve (code_gen);
+ callisig = new PEAPI.CalliSig (call_conv,
+ ret_type.PeapiType, param_array);
+
+ cil.calli (callisig);
+ }
+ }
+
+}
diff --git a/mcs/ilasm/codegen/CatchBlock.cs b/mcs/ilasm/codegen/CatchBlock.cs
new file mode 100644
index 00000000000..6fc78c4fa37
--- /dev/null
+++ b/mcs/ilasm/codegen/CatchBlock.cs
@@ -0,0 +1,45 @@
+//
+// Mono.ILASM.CatchBlock
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+
+namespace Mono.ILASM {
+
+ public class CatchBlock : ISehClause {
+
+ private BaseClassRef class_ref;
+ private HandlerBlock handler_block;
+
+ public CatchBlock (BaseClassRef class_ref)
+ {
+ this.class_ref = class_ref;
+ }
+
+ public void SetHandlerBlock (HandlerBlock hb)
+ {
+ handler_block = hb;
+ }
+
+ public PEAPI.HandlerBlock Resolve (CodeGen code_gen, MethodDef method)
+ {
+ PEAPI.CILLabel from = handler_block.GetFromLabel (code_gen, method);
+ PEAPI.CILLabel to = handler_block.GetToLabel (code_gen, method);
+ PEAPI.Catch katch;
+
+ class_ref.Resolve (code_gen);
+
+ katch = new PEAPI.Catch (class_ref.PeapiClass, from, to);
+
+ return katch;
+ }
+ }
+
+}
diff --git a/mcs/ilasm/codegen/ChangeLog b/mcs/ilasm/codegen/ChangeLog
new file mode 100644
index 00000000000..c93e93ee92a
--- /dev/null
+++ b/mcs/ilasm/codegen/ChangeLog
@@ -0,0 +1,1687 @@
+2006-02-22 Ankit Jain <jankit@novell.com>
+
+ * ExternTable.cs (ExternTable.GetTypeRef): Emit a warning if mscorlib is
+ referenced without a corresponding '.assembly extern' directive.
+ * TypeDef.cs (TypeDef.Define): Valuetype class should be sealed. Emit
+ warning if its not, and make it so.
+
+2006-02-20 Ankit Jain <jankit@novell.com>
+
+ * *.cs: Update all .cs files to use Report.Error instead of directly
+ throwing an exception.
+ * CodeGen.cs (CodeGen.ctor): Remove 'report' param, and the related
+ field & property.
+
+2006-02-19 Ankit Jain <jankit@novell.com>
+
+ * ExternTable.cs (ExternTable.GetModuleTypeRef): 'module_table' can be
+ null.
+
+2006-02-19 Ankit Jain <jankit@novell.com>
+
+ * CodeGen.cs (CodeGen.Write): Use only filename as the name of the
+ module.
+ * TypeDef.cs (TypeDef.ResolveAsMethodRef): New.
+ (TypeDef.ResolveMethod): Change signature to take ret_type, params
+ etc instead of a signature string. Also, if the method does not exist,
+ then use ResolveAsMethodRef to return a MethodRef for it.
+ (TypeDef.ResolveVarargMethod): Likewise.
+ (TypeDef.ResolveField): Likewise.
+ * MethodRef.cs (MethodRef.Resolve): Update use of TypeDef.Resolve*
+ methods.
+ * FieldRef.cs (FieldRef.Resolve): Update use of TypeDef.ResolveField.
+ * PropertyDef.cs (PropertyDef.AsMethodDef): Throws an exception is the
+ method is not a MethodDef.
+ (PropertyDef.Define): Use AsMethodDef to ensure that get/set/other are
+ MethodDefs.
+ * EventDef.cs (EventDef.AsMethodDef): Same as PropertyDef.
+ (EventDef.Define): Likewise.
+
+2006-02-19 Ankit Jain <jankit@novell.com>
+
+ * CodeGen.cs (CodeGen.ThisModule): New.
+ (CodeGen.Write): Set module name if not set by '.module' directive.
+ * Module.cs: Inherit from ExternRef.
+
+2006-02-10 Ankit Jain <jankit@novell.com>
+
+ * CodeGen.cs (CodeGen.ResolveMethod): Throw exception if global method
+ not found.
+ (CodeGen.ResolveField): Likewise for global field.
+
+2006-02-08 Ankit Jain <jankit@novell.com>
+
+ * PeapiTypeRef.cs (PeapiTypeRef.MakeBoundArray): Simplify and fix
+ behavior.
+
+2006-01-31 Ankit Jain <jankit@novell.com>
+
+ * TypeDef.cs (TypeDef.AddMethodDef): Throw exception with proper message
+ if adding a duplicate method.
+
+2006-01-31 Ankit Jain <jankit@novell.com>
+
+ * InstrTable.cs (inst_table): Add 'readonly.' .
+
+2006-01-31 Ankit Jain <jankit@novell.com>
+
+ * ExternTable.cs (ExternTable.GetTypeRef): If type is from an
+ undeclared assembly, then add reference to the assembly.
+
+2006-01-28 Ankit Jain <jankit@novell.com>
+
+ * MethodDef.cs:
+ * TypeManager.cs:
+ * MethodPointerTypeRef.cs:
+ * ExternMethodRef.cs: Remove unused variables to fix warnings.
+
+2006-01-28 Ankit Jain <jankit@novell.com>
+
+ * TypeDef.cs (GenericInfo):
+ * MethodDef.cs (GenericInfo): Remove (unused).
+
+2006-01-23 Ankit Jain <jankit@novell.com>
+
+ * TypeDef.cs (TypeDef.AddFieldDef): Throw exception if duplicate field being
+ added.
+
+2006-01-19 Ankit Jain <jankit@novell.com>
+
+ * Module.cs (Module): New. Class for representing this module.
+ * CodeGen.cs (CodeGen): Update to use the new Module class.
+ (CodeGen.Write): Resolve this_module.
+
+2006-01-19 Ankit Jain <jankit@novell.com>
+
+ * GenericParameters.cs (GenericParameter): Implement ICustomAttrTarget.
+ (GenericParameter.Resolve): New overload, reduce code duplication.
+ (GenericParameters.GetGenericParam): New. Returns a GenericParameter.
+ (GenericParameters.GetGenericParamNum): Update to use new GetGenericParam.
+
+ * TypeDef.cs (TypeDef.GetGenericParam): New. Two overloads for id and index.
+ * MethodDef.cs (MethodDef.GetGenericParam): Likewise.
+
+2006-01-19 Ankit Jain <jankit@novell.com>
+
+ * MethodRef.cs (MethodRef.Resolve): Resolve owner.
+
+2006-01-16 Ankit Jain <jankit@novell.com>
+
+ * TypeDef.cs (TypeDef.IComparable): Implement IComparable interface.
+ * TypeManager.cs (TypeManager.DefineAll): Sort type_table before Define()'ing.
+
+2006-01-16 Ankit Jain <jankit@novell.com>
+
+ * TypeRef.cs (TypeRef.CreateMethodRef): Return a TypeSpecMethodRef if
+ this is a modified (eg. []) type.
+
+2006-01-16 Ankit Jain <jankit@novell.com>
+
+ * BaseTypeRef.cs (BaseTypeRef.Resolve): Make this abstract.
+ (BaseTypeRef.CreateMethodRef):
+ (BaseTypeRef.CreateFieldRef): Make protected and abstract.
+ * BaseClassRef.cs (BaseClassRef.Clone): Make this abstract.
+ Update all derived classes.
+ * PrimitiveTypeRef.cs (PrimitiveTypeRef.CreateMethodRef):
+ * GenericTypeInst.cs (GenericTypeInst.CreateMethodRef): Implement, but throw
+ exception as this method is not used.
+
+2006-01-14 Ankit Jain <jankit@novell.com>
+
+ * GenericParamRef.cs (GenericParamRef.Resolve): Apply modifications to the
+ cached type.
+
+2006-01-14 Ankit Jain <jankit@novell.com>
+
+ * GenericParamRef.cs (GenericParamRef.Resolve): Set PeapiType of the instance
+ to the cached one.
+
+2006-01-13 Ankit Jain <jankit@novell.com>
+
+ * GenericParamRef.cs (GenericParamRef.Resolve): Ensure no duplicate
+ GenParams get added to the TypeSpec table.
+ * GenericMethodSig.cs (GenericMethodSig.GetInstance): Cache sigs in a
+ static hashtable.
+ * BaseMethodRef.cs (BaseMethodRef.GetGenericMethodRef): Cache GenericMethodRefs.
+
+2006-01-13 Ankit Jain <jankit@novell.com>
+
+ Create BaseMethodRef from IMethodRef. Replace usage of IMethodRef
+ with BaseMethodRef in *all* files.
+ Remove implementations of IMethodRef's methods from derived classes.
+ * BaseMethodRef.cs: New.
+
+2006-01-13 Ankit Jain <jankit@novell.com>
+
+ Move caching of method-refs and field-refs to BaseTypeRef, and use
+ CreateMethodRef & CreateFieldRef for creating the actual object.
+ Override these in derived classes to return the right objects.
+
+ * BaseTypeRef.cs (BaseTypeRef.CreateMethodRef): New.
+ (BaseTypeRef.CreateFieldRef): New.
+ (BaseTypeRef.GetMethodRef): Implement caching.
+ (BaseTypeRef.GetFieldRef): Likewise.
+
+ GenericTypeInst and PrimitiveTypeRef are not cached, so static hashtables
+ are used here for caching their MethodRefs n FieldRefs.
+
+ * GenericTypeInst.cs (GenericTypeInst.GetMethodRef): Override and use
+ static hashtable to do caching.
+ (GenericTypeInst.GetFieldRef): Likewise.
+ * PrimitiveTypeRef.cs (PrimitiveTypeRef.GetMethodRef): Likewise.
+ (PrimitiveTypeRef.GetFieldRef): Likewise.
+
+ * CodeGen.cs (CodeGen.GetGlobalMethodRef): New. Cache global method refs.
+ (CodeGen.GetGlobalFieldRef): New. Cache global field refs.
+
+2006-01-13 Ankit Jain <jankit@novell.com>
+
+ Create BaseClassRef, BaseGenericTypeRef from IClassRef & IGenTypeRef.
+ Replace usage of interfaces ITypeRef, IClassRef & IGenTypeRef with their
+ corresponding Base* types.
+ * BaseTypeRef.cs: New. Combine ITypeRef and ModifiableType into this.
+ * BaseClassRef.cs: New.
+ * BaseGenericTypeRef.cs: New.
+ * TypeSpecMethodRef.cs (TypeSpecMethodRef.ctor): Slight change in order
+ of params.
+
+2006-01-12 Ankit Jain <jankit@novell.com>
+
+ * MethodDef.cs (MethodDef.CreateSignature): Use "`n" only for generic
+ methods.
+
+2006-01-11 Ankit Jain <jankit@novell.com>
+
+ * InstrTable.cs (inst_table): Uncomment stelem and ldelem .
+
+2006-01-11 Ankit Jain <jankit@novell.com>
+
+ Support new syntax of specifying namespace, ie., as
+ part of the type name. (gen-nested2.il)
+ * TypeDef.cs (TypeDef.ctor): Add outer as a param.
+ Don't split name on '.' for inner classes.
+ * CodeGen.cs (CodeGen.BeginTypeDef): Update to use only 'name'
+ for inner classes and FullName for outermost class.
+
+2006-01-10 Ankit Jain <jankit@novell.com>
+
+ * TypeDef.cs (TypeDef.GetGenericParamNum): Return -1 if type has no
+ generic parameters.
+ * MethodDef.cs (MethodDef.GetGenericParamNum): Likewise.
+
+2006-01-10 Ankit Jain <jankit@novell.com>
+
+ * MethodDef.cs (MethodDef.WriteCode): Resolve generic params for abstract
+ methods also.
+
+2006-01-10 Ankit Jain <jankit@novell.com>
+
+ * TypeDef.cs (TypeDef.TypeParameters): New.
+ (TypeDef.ResolveGenParams): New. Resolve any gen param refs in
+ constraints, base class ref or implemented interfaces.
+ * MethodDef.cs (MethodDef.ResolveGenParams): Update to use new Resolve
+ overloads and ResolveConstraints for GenericParameters.
+
+ * GenericTypeInst.cs (GenericTypeInst.Resolve): Resolve generic args.
+ * GenericParamRef.cs (GenericParamRef.Resolve): Implement.
+ * GenericParameters.cs (GenericParameter.ResolveConstraints): New.
+ (GenericParameters.ResolveConstraints): New.
+ * GenericArguments.cs (GenericArguments.Resolve): New.
+
+ * TypeRef.cs (TypeRef.GetGenericTypeInst): Don't cache.
+ * ExternTypeRef.cs (ExternTypeRef.GetGenericTypeInst): Likewise.
+
+2006-01-09 Ankit Jain <jankit@novell.com>
+
+ * GenericArguments.cs (GenericArguments.is_resolved): New.
+ (GenericArguments.p_type_list): New. Resolve only once and return this.
+
+2006-01-09 Ankit Jain <jankit@novell.com>
+
+ * TypeDef.cs (TypeDef.Define): Set is_defined to true as soon as the
+ Peapi type gets created.
+
+2006-01-09 Ankit Jain <jankit@novell.com>
+
+ * GenericTypeRef.cs: Rename to ..
+ * GenericParamRef.cs: .. this.
+ (IGenericTypeRef): New.
+ (GenericParamRef): Implement IGenericTypeRef.
+ * GenericTypeInst.cs (GenericTypeInst): Implement IGenericTypeRef instead
+ of IClassRef.
+ (GenericTypeInst.ResolveOnly): Rename to ResolveNoTypeSpec to implement
+ IGenericTypeRef.ResolveNoTypeSpec .
+ * MethodDef.cs (MethodDef.ResolveGenParams): Update to use GenericParamRef.
+ * Local.cs (Local.GetPeapiLocal): Use IGenericTypeRef.
+
+2006-01-08 Ankit Jain <jankit@novell.com>
+
+ * InstrTable.cs (inst_table): Add stelem.any, ldelem.any and
+ constrained. instructions.
+
+2006-01-07 Ankit Jain <jankit@novell.com>
+
+ * GenericParameters.cs (GenericParameter): New.
+ (GenericParameters): Collection of Generic parameters.
+ * TypeDef.cs:
+ * CodeGen.cs:
+ * MethodDef.cs: Update to use the new GenericParameters class.
+
+2006-01-06 Ankit Jain <jankit@novell.com>
+
+ GenericTypeInst.Resolve should do the expected thing ie., resolve and add
+ the Generic Inst to the typespec table. Use ResolveOnly to Resolve w/o
+ adding to the table.
+ * GenericTypeInst.cs (GenericTypeInst.Resolve): Rename to ..
+ (GenericTypeInst.ResolveOnly): .. this.
+ (GenericTypeInst.ResolveAsClass): Rename to Resolve.
+
+ * TypeDef.cs (TypeDef.Define): Revert the ResolveAsClass calls added here.
+ * Local.cs (Local.GetPeapiLocal): Use new GenericTypeInst.ResolveOnly if type is
+ GenericTypeInst.
+
+2006-01-06 Ankit Jain <jankit@novell.com>
+
+ * IClassRef.cs (IClassRef.Clone): New.
+ (IClassRef.GetGenericTypeInst): Get the Generic Instance of the IClassRef.
+ (IClassRef.ResolveInstance): Resolves the generic instance and returns the
+ resolved PEAPI type.
+
+ * TypeRef.cs:
+ * ExternTypeRef.cs: Implement new methods of IClassRef.
+ Classes implementing IClassRef cache their generic instances (GenericTypeInst)
+ and their corresponding resolved PEAPI types.
+
+ * CodeGen.cs (CodeGen.GetTypeRef): Gets a TypeRef given a type name and caches them.
+
+ GenericTypeInst is now used for any Generic Type Instance, including any
+ extern types. ExternTypeRefInst is not used now.
+ * GenericTypeInst.cs (GenericTypeInst): Implement IClassRef instead of ITypeRef.
+ (GenericTypeInst.ResolveAsClass): Adds the instance to the TypeSpec table after Resolve()'ing it.
+ Clone () returns a cloned instance which shares its class_ref and generic arguments.
+
+ * TypeDef.cs (TypeDef.Define): Use ResolveAsClass for base class and interfaces
+ being implemented if they are GenericTypeInsts.
+
+2005-12-24 Jb Evain <jbevain@gmail.com>
+
+ * FeatureAttr.cs: tag as Flags, add an Instance value.
+ * PropertyDef.cs (PropertyDef.Resolve): Tag the property as instance or class.
+
+2005-12-22 Ankit Jain <jankit@novell.com>
+
+ * MethodDef.cs (MethodDef.ctor): Add type_def param. Use this for all uses of
+ the owner type_def. ResolveGenParams () before creating signature.
+ (MethodDef.ResolveGenParams):
+ (MethodDef.ResolveGenParam): Remove type_def param, instead use type_def field.
+ (MethodDef.Define): Remove overload with typedef param.
+ (MethodDef.CreateSignature): Put "`0" right after the name instead of at the end.
+ * TypeDef.cs (TypeDef.DefineContents): Update usage of MethodDef.Define .
+
+2005-12-21 Ankit Jain <jankit@novell.com>
+
+ * GenericArguments.cs (GenericArguments): New.
+ * ExternTypeRefInst.cs (ExternTypeRefInst):
+ * GenericTypeInst.cs (GenericTypeInst):
+ * GenericMethodSig.cs (GenericMethodSig): Update to use new GenericArguments class.
+
+2005-12-16 Ankit Jain <jankit@novell.com>
+
+ Use tuple of (field name, type_name) for fielddef hashtable in TypeDef.cs and
+ CodeGen.cs
+ * FieldDef.cs (FieldDef.Type): New.
+ * TypeDef.cs (TypeDef.ResolveField): Add 'type_name' param.
+ * CodeGen.cs (CodeGen.ResolveField): Add 'type_name' param.
+ * FieldRef.cs (FieldRef.Resolve): Update usage of .ResolveField .
+ * GlobalFieldRef (GlobalFieldRef.Resolve): Likewise.
+ * ExternTable.cs (IScope.FullName): New. Returns full name including and enclosing class
+ or assembly/module name.
+ (ExternRef.FullName):
+ (ExternModule.FullName):
+ (ExternAssembly.FullName): Implement new IScope.FullName .
+ * ExternTypeRef.cs (ExternTypeRef.Clone): Clone SigMod also.
+ (ExternTypeRef.FullName): Update to return full name including enclosing type or assembly
+ or module name.
+ (ExternTypeRef.Name): Update to return only full_name with modifiers (array/pointers etc).
+ (ExternTypeRef.GetReflectedType): Use Name instead of FullName as only type name is required here.
+ * GenericTypeRef.cs (GenericTypeRef.FullName): Return proper fullname of the form (!0 or !!0).
+ * GenericTypeInst.cs (GenericTypeInst.ctor): Change param 'full_name' to 'name'. 'full_name' is
+ constructed here using the type parameter list.
+ Update code to use name instead of full_name.
+
+2005-12-15 Ankit Jain <jankit@novell.com>
+
+ * CodeGen.cs (CodeGen.SetAssemblyName): Multiple .assembly declarations with different
+ names are not allowed.
+
+2005-12-14 Ankit Jain <jankit@novell.com>
+
+ * PeapiTypeRef.cs (PeapiTypeRef.MakeBoundArray): Handle the case when only
+ lower bound (no size info) is available.
+
+2005-12-14 Ankit Jain <jankit@novell.com>
+
+ * TypeDef.cs (TypeDef.ctor): name_space can be null.
+
+2005-12-13 Ankit Jain <jankit@novell.com>
+
+ * TypeDef.cs (TypeDef.ctor): Ensure that 'name' contains only the last part
+ of the full (namespace + name) dotted name.
+
+2005-12-12 Ankit Jain <jankit@novell.com>
+
+ * TypeDef.cs (TypeDef.Define): Ensure nested visibility for a nested class.
+ (TypeDef.NestedFullName): New.
+
+2005-12-09 Ankit Jain <jankit@novell.com>
+
+ * MethodDef.cs (MethodDef.GenParamCount): typar_list can be null.
+
+2005-12-09 Ankit Jain <jankit@novell.com>
+
+ * ITypeRef.cs (ITypeRef.GetMethodRef): Add 'gen_param_count' param.
+ * Sentinel.cs (Sentinel.GetMethodRef): Update.
+ * GlobalMethodRef.cs (GlobalMethodRef.ctor): Add 'gen_param_count' param.
+ (GlobalMethodRef.Resolve): Update usage of MethodDef.CreateSignature .
+ * TypeDef.cs (TypeDef.GetGenericParamNum): New.
+ (TypeDef.DefineContents): Update usage of ITypeRef.GetMethodRef .
+ * ExternTypeRefInst.cs (ExternTypeRefInst.ctor): Add parameter for list of type
+ parameters (type_list).
+ (ExternTypeRefInst.Clone): Clone type_list also.
+ (ExternTypeRefInst.Resolve): Resolve the list of type parameters, and create
+ instance of PEAPI.GenericTypeInst instead of PEAPI.ClassRefInst .
+ (ExternTypeRefInst.GetMethodRef): Update.
+ * GenericTypeInst.cs (GenericTypeInst.GetMethodRef): Update signature. Update
+ usage of TypeSpecMethodRef.ctor .
+ * MethodRef.cs (MethodRef.ctor): Add 'gen_param_count' param.
+ (MethodRef.Resolve): Throw exception for non-existant owner. Update usage of
+ MethodDef.CreateSignature .
+ * ExternMethodRef.cs (ExternMethodRef.ctor): Add 'gen_param_count' param.
+ (ExternMethodRef.Resolve): Update usage of PEFile.AddMethodToTypeSpec and .AddMethod
+ * GenericMethodRef.cs (GenericMethodRef.PeapiMethod): Return PEAPI.Method obtained in
+ .Resolve .
+ * GenericTypeRef.cs (GenericTypeRef.GetMethodRef): Update.
+ * MethodPointerTypeRef.cs (MethodPointerTypeRef.GetMethodRef): Likewise.
+ * TypeSpecMethodRef.cs (TypeSpecMethodRef.ctor): Add 'gen_param_count' param.
+ (TypeSpecMethodRef.Resolve): Update usage of PEFile.AddMethodToTypeSpec .
+ * MethodDef.cs (MethodDef.ctor): Add 'typars_list' param.
+ (MethodDef.AddGenericParam): Replace ..
+ (MethodDef.AddGenericParams): .. with this.
+ (MethodDef.GenParamCount): New.
+ (MethodDef.GetGenericParamNum): New. Returns index for a given method type parameter name.
+ (MethodDef.ResolveGenParams): Resolves type parameter names in the parameter
+ list to their corresponding indices.
+ (MethodDef.ResolveGenParam): Resolves a give type parameter to its corresponding
+ index.
+ (MethodDef.CreateSignature): Add 'gen_param_count' param.
+ * TypeRef.cs (TypeRef.GetMethodRef): Update.
+ * ExternTypeRef.cs (ExternTypeRef.GetMethodRef): Likewise.
+ * PrimitiveTypeRef.cs (PrimitiveTypeRef.GetMethodRef): Likewise.
+
+2005-12-05 Ankit Jain <jankit@novell.com>
+
+ * TypeDef.cs (TypeDef.GenericInfo.num): New.
+ (TypeDef.AddGenericParam): Set num for GenericInfo.
+ * MethodDef.cs (MethodDef.GenericInfo.num): New.
+ (MethodDef.AddGenericParam): Set num for GenericInfo.
+ * GenericTypeRef.cs (GenericTypeRef.ctor): Update to use PEAPI.GenParam
+ instead of PEAPI.MVar and PEAPI.GenericTypeSpec.
+
+2005-11-28 Ankit Jain <jankit@novell.com>
+
+ * ExternTypeRef.cs (extern_table): Remove unused field.
+ (.ctor): Remove parameter for extern_table. Update usage accordingly.
+ * ExternTable.cs (IScope): Remove unused 'table' parameter.
+ (ExternRef): Change IScope interface implementation accordingly. Update
+ call to ExternTypeRef.ctor for the previous change.
+
+2005-09-15 Ankit Jain <jankit@novell.com>
+
+ * DeclSecurity.cs (IDeclSecurityTarget.AddDeclSecurity): Remove.
+ (IDeclSecurityTarget.AddPermission),
+ (IDeclSecurityTarget.AddPermissionSet): New.
+ (DeclSecurity.IDeclSecurityTarget): Implement new interface methods.
+ (DeclSecurity.sec_action),
+ (DeclSecurity.data): Remove.
+ (DeclSecurity.permissionset_table): New.
+ (DeclSecurity.ctor): Replace parameterized constructor with a default one.
+ (DeclSecurity.AddTo): AddDeclSecurity for all Security Actions in the permissionset_table.
+ * TypeDef.cs (TypeDef.declsecurity_list): Remove.
+ (TypeDef.decl_sec): New.
+ (TypeDef.IDeclSecurityTarget): Implement new interface methods.
+ (TypeDef.DefineContents): Use new decl_sec instead of declsecurity_list.
+ * CodeGen.cs (CodeGen.assembly_declsec): Change type from ArrayList to DeclSecurity.
+ (CodeGen.EndAssemblyRef): Set current_customattrtarget and current_declsectarget to null.
+ (CodeGen.IDeclSecurityTarget): Implement new interface methods.
+ (CodeGen.Write): Add assembly_declsec to the assembly (using DeclSecurity.AddTo).
+ * ExternTable.cs (ExternAssembly.declsec_list): Remove.
+ (ExternAssembly.decl_sec): New.
+ (ExternAssembly.Resolve): Use new decl_sec instead of declsec_list.
+ (ExternAssembly.IDeclSecurityTarget): Implement new interface methods.
+ * MethodDef.cs (MethodDef.declsecurity_list): Remove.
+ (MethodDef.decl_sec): New.
+ (MethodDef.IDeclSecurityTarget): Implement new interface methods.
+ (MethodDef.WriteCode): Use new decl_sec instead of declsecurity_list.
+ * ExternTypeRef.cs (ExternTypeRef.GetReflectedType): New.
+
+2005-09-08 Ankit Jain <jankit@novell.com>
+
+ * CodeGen.cs (CodeGen.stack_reserve): New.
+ (CodeGen.SetStackReserve): New.
+ (CodeGen.Write): SetStackReserve on the pefile.
+
+2005-09-06 Ankit Jain <jankit@novell.com>
+
+ * ExternTable.cs (ExternRef.is_resolved): New.
+ (ExternModule.Resolve, ExternAssembly.Resolve,
+ ExternTable.Resolve): Return if is_resolved. Set to true at the end.
+
+2005-08-29 Ankit Jain <jankit@novell.com>
+
+ * InstrTable.cs (inst_table): Comment out stelem and ldelem opcodes.
+
+2005-08-26 Ankit Jain <jankit@novell.com>
+
+ * ExternTable.cs (IScope): New. Interface for ResolutionScope.
+ (ExternRef): Implement IScope.
+ (ExternRef.GetTypeRef): Handle references to nested classes.
+ (ExternRef.GetValueType): Remove. Logic combined with GetType.
+ (ExternRef.GetType): Add param 'is_valuetype' and handle accordingly.
+ * ExternTypeRef.cs (ExternTypeRef): Implement IScope.
+ (ExternTypeRef.extern_ref),
+ (ExternTypeRef.ctor),
+ (ExternTypeRef.ExternRef): Change extern_ref type from ExternRef to IScope.
+ (ExternTypeRef.nestedtypes_table),
+ (ExternTypeRef.nestedclass_table): New. Hashtables for nested classes.
+ (ExternTypeRef.Resolve): Resolve parent if it is ExternTypeRef type.
+ (ExternTypeRef.GetTypeRef): New.
+ (ExternTypeRef.GetExternTypeRef): New. Returns the resolve PEAPI type.
+ (ExternTypeRef.GetType): New.
+
+2005-08-23 Ankit Jain <jankit@novell.com>
+
+ * ExternTable.cs (ExternTable.ctor): Remove. Move the initialization code
+ to the new method AddCorlib.
+ (ExternTable.AddCorlib): New.
+ (ExternTable.Resolve): Assembly_table can be null so check before using it.
+ (ExternTable.GetTypeRef): AddCorlib if mscorlib is being referenced but
+ assembly_table is still null.
+ * CodeGen.cs (CodeGen.SetAssemblyName): Call AddCorlib if name is not mscorlib.
+ (CodeGen.Write): Pass null for new outputDir param for PEFile ctor.
+ * (PrimitiveTypeRef.Name): New. Returns the full_name.
+
+2005-08-18 Ankit Jain <jankit@novell.com>
+
+ * IMethodRef.cs (IMethodRef.Owner): New. Returns owner of the method.
+ * GlobalMethodRef.cs (GlobalMethodRef),
+ MethodRef.cs (MethodRef),
+ ExternMethodRef.cs (ExternMethodRef),
+ GenericMethodRef.cs (GenericMethodRef),
+ TypeSpecMethodRef.cs (TypeSpecMethodRef): Implement IMethodRef.Owner.
+ * CustomAttr.cs (CustomAttr.IsSuppressUnmanaged): New. Checks if the
+ it is a "System.Security.SuppressUnmanagedCodeSecurityAttribute" and
+ is from "mscorlib" or the current assembly is mscorlib itself.
+ * TypeDef.cs (TypeDef.DefineContents),
+ MethodDef.cs (MethodDef.WriteCode): Set HasSecurity attribute if
+ SuppressUnmanagedCodeSecurity custom attribute is present.
+ * ExternTable.cs (ExternRef.Name): New.
+ * ExternTypeRef.cs (ExternTypeRef.ExternRef): New. Returns the corresponding
+ extern ref.
+
+2005-08-18 Ankit Jain <jankit@novell.com>
+
+ * MethodDef.cs (MethodDef.WriteCode): Process custom attributes and decl security
+ lists even for abstract methods.
+
+2005-08-16 Ankit Jain <jankit@novell.com>
+
+ * CodeGen.cs (CodeGen.current_field_native_type): New.
+ (CodeGen.AddFieldMarshalInfo): New. Add marshal info for the current field.
+ (CodeGen.AddFieldDef): Add marshal info for the field.
+ * FieldDef.cs (FieldDef.native_type): New. Native type for marshalling.
+ (FieldDef.AddMarshalInfo): New. Set native_type.
+ (FieldDef.Resolve): Set MarshalInfo for field_def.
+ * MethodDef.cs (MethodDef.ret_native_type): New. Native type for return type.
+ (MethodDef.AddRetTypeMarshalInfo): New.
+ (MethodDef.EntryPoint): Throw exception is the method is not static.
+ (MethodDef.Resolve): Call overload with class_def=null.
+ (MethodDef.Resolve): Add global methods to code_gen.PEFile.
+ Add marshal info for return type.
+ * ParamDef.cs (ParamDef.native_type): New. Native type for marshalling.
+ (ParamDef.AddMarshalInfo): New.
+ (ParamDef.Define): Add marshal info to peapi_param.
+
+2005-08-08 Ankit Jain <jankit@novell.com>
+
+ * ExternTypeRef.cs (ExternTypeRef.Clone): Use full_name instead of FullName
+ to avoid cloning modifiers (like []).
+
+2005-08-08 Ankit Jain <jankit@novell.com>
+
+ * CodeGen.cs (CodeGen.entry_point): New bool field.
+ (CodeGen.HasEntryPoint): New. Property to mark that the assembly
+ has an entrypoint.
+ (CodeGen.Write): Throw Exception if an EXE has been requested but the
+ source file has no entrypoint defined.
+
+2005-08-05 Ankit Jain <jankit@novell.com>
+
+ * DeclSecurity.cs: New File.
+ (DeclSecurity): New class.
+ (IDeclSecurityTarget): New interface.
+ * TypeDef.cs (TypeDef): Implement IDeclSecurityTarget.
+ (TypeDef.DefineContents): Add DeclSecurity info.
+ * CodeGen.cs (CurrentDeclSecurityTarget): New. Property for current
+ DeclSecurity target.
+ (BeginTypeDef, BeginMethodDef, BeginAssemblyRef): Set current DeclSecurity
+ target accordingly.
+ (AddAssemblyDeclSecurity): New. Add DeclSecurity info to assembly.
+ * ExternTable.cs (ExternAssembly): Implement IDeclSecurityTarget.
+ (Resolve): Add DeclSecurity info to AssemblyRef.
+ * MethodDef.cs (MethodDef): Implement IDeclSecurityTarget.
+ (WriteCode): Add DeclSecurity info to MethodDef.
+
+2005-08-03 Ankit Jain <jankit@novell.com>
+
+ * GlobalMethodRef.cs (GlobalMethodRef.Resolve): Use CreateVarargSignature
+ to create method's signature for a vararg method.
+
+2005-08-02 Ankit Jain <ankit@corewars.org>
+
+ Fix #61512.
+ * TypeDef.cs (TypeDef.Define): Use default values for pack and size if only
+ one of them is unspecified.
+
+2005-05-10 Ankit Jain <ankit@corewars.org>
+
+ Fix #74768.
+ * ExternTable.cs (ExternRef.GetTypeRef): Make ValueClass if requested.
+ Hack alongwith Hari.
+
+2005-05-06 Ankit Jain <ankit@corewars.org>
+
+ * MethodDef.cs (MethodDef.GetNamedParamPos): Param num starts from 1 for instance
+ methods.
+ * CodeGen.cs (CodeGen.BeginTypeDef): Set current_customattrtarget when reopening a
+ class.
+
+2005-04-27 Ankit Jain <ankit@corewars.org>
+
+ * ExternTypeRefInst.cs (ExternTypeRefInst.GetMethodRef): Use method_table to avoid
+ creating duplicates.
+ * PrimitiveTypeRef.cs (PrimitiveTypeRef.GetMethodRef): Use method_table to avoid
+ creating duplicates
+ * PeapiTypeRef.cs (Pair): New class. Tuple of PEAPI.Type and string.
+ (PeapiTypeRef.type_table): New.
+ (PeapiTypeRef.MakeArray, MakeBoundArray, MakeManagedPointer, MakeUnmanagedPointer,
+ MakeCustomModified): Use type_table to avoid creating duplicates.
+
+2005-04-22 Atsushi Enomoto <atsushi@ximian.com>
+
+ * InstrTable.cs :
+ ble.un.s and blt.un.s were incorrectly added to the table.
+
+2005-04-22 Ankit Jain <ankit@corewars.org>
+
+ * TypeSpecMethodRef.cs (TypeSpecMethodRef.Resolve): Set is_resolved
+ to true.
+
+2005-04-18 Ankit Jain <ankit@corewars.org>
+
+ * CodeGen.cs (CodeGen.AddManifestResource): Add a
+ ManifestResource to manifestResources ArrayList.
+ (CodeGen.Write): Add all resources to the pefile.
+
+2005-04-12 Ankit Jain <ankit@corewars.org>
+
+ * CustomAttr.cs (ICustomAttrTarget): New interface.
+ * TypeDef.cs: Implement ICustomAttrTarget.
+ * FieldDef.cs, PropertyDef.cs, ParamDef.cs, EventDef.cs
+ (AddCustomAttribute): Implement ICustomAttrTarget
+ (.Resolve): Add custom attributes.
+ * CodeGen.cs (CurrentCustomAttrTarget): New. Property for
+ current CustomAttr target.
+ (BeginTypeDef, BeginMethodDef, BeginAssemblyRef): Set
+ current_customattrtarget accordingly.
+ * ExternTable.cs (ExternRef): Implement ICustomAttrTarget.
+ (ExternModule.Resolve): Add custom attributes to ModuleRef.
+ (ExternAssembly.Resolve): Add custom attributes to AssemblyRef.
+ * MethodDef.cs: Implement ICustomAttrTarget and add custom
+ attributes.
+ (GetParam): New. Get ParamDef by index.
+
+2005-04-08 Ankit Jain <radical@corewars.org>
+
+ * MethodDef.cs (named_param_table, CreateNamedParamTable): Remove.
+ (GetNamedParamPos): Implement using a linear scan.
+
+ * TypeDef.cs (TypeDef): Initialize 'is_enum_class'.
+ (Define): Set 'is_value_class' or 'is_enum_class' depending on
+ whether the parent is System.ValueType or System.Enum. Update to
+ changes in PEAPI.cs.
+
+2005-03-17 Ankit Jain <radical@corewars.org>
+
+ * MethodDef.cs: Added method AddParamDefaultValue for adding DefaultValue
+ to a method parameter.
+ * ParamDef.cs: Added method AddDefaultValue and handling of default value.
+
+2005-02-07 Jackson Harper <jackson@ximian.com>
+
+ * MethodDef.cs: Don't die on duplicate local symbols. Fixes bug
+ 72149. Patch by Sohail Somani.
+
+2004-12-14 Raja R Harinath <rharinath@novell.com>
+
+ * MethodDef.cs (CreateSignature): Add a space in generated signature.
+
+2004-12-02 Jackson Harper <jackson@ximian.com>
+
+ * ExternTypeRefInst.cs: When converting to arrays we loose our valuetypedness.
+
+2004-12-02 Jackson Harper <jackson@ximian.com>
+
+ * MethodDef.cs: Abstract methods don't get bodies. Even if there
+ are bodies there.
+
+2004-12-02 Jackson Harper <jackson@ximian.com>
+
+ * MethodDef.cs: If the type is an interface auto set fields to
+ static (and give a warning if they are not static), and set
+ methods to abstract virtual (and give warning if they were not already).
+ * FieldDef.cs:
+ * TypeDef.cs: Accessors and convience properties for getting and
+ setting the method/field attributes.
+
+
+2004-12-02 Jackson Harper <jackson@ximian.com>
+
+ * FieldDef.cs: Set the underlying type for bytearray data constants. This
+ fixes bug #70153 and #70154 which my previous fix caused.
+
+2004-08-01 Atsushi Enomoto <atsushi@ximian.com>
+
+ * DebuggingInfo.cs : csc build fix (see bug #62230).
+
+2004-07-27 Martin Baulig <martin@ximian.com>
+
+ * IInstr.cs (IInstr): Made this an abstract class and not an
+ interface, added a .ctor which takes a Location.
+ (IInstr.Location): New public readonly field.
+
+ * CodeGen.cs (CodeGen.SymbolWriter): New public property.
+ (CodeGen.BeginSourceFile, EndSourceFile): New public methods.
+ (CodeGen.EndMethodDef): Take a `Location' argument.
+ (CodeGen.Write): Create debugging info if the user requested it.
+
+ * MethodDef.cs (MethodDef.ctor): Added `CodeGen codegen' and
+ `Location start' arguments. If the user requested debugging
+ information, register ourselves with the symbol writer.
+ (MethodDef.WriteCode): Emit debugging information.
+
+ * DebuggingInfo.cs: New file.
+
+2004-07-23 Jackson Harper <jackson@ximian.com>
+
+ * MethodDef.cs: Params are 1 based if the method is instance
+ because of the 'this' arg.
+
+2004-07-21 Jackson Harper <jackson@ximian.com>
+
+ * ExternTypeRefInst.cs: Use the PeapiType so that modified types
+ will actually work. Add a Clone method so that type ref insts
+ aren't duplicated making them modified multiple times.
+
+2004-07-12 Jackson Harper <jackson@ximian.com>
+
+ * MethodDef.cs: Local lists are not lazyily allocated so they were
+ getting added to every method. This is legal but wastes space.
+
+2004-07-08 Jackson Harper <jackson@ximian.com>
+
+ * CodeGen.cs: Add assembly custom attributes to the pe file.
+ * CustomAttr.cs: Custom attributes are now added through the
+ pefile, this ensures that they get emitted properly.
+ * ExternTable.cs: Allow adding custom attributes to assembly
+ refs.
+
+2004-06-26 Jackson Harper <jackson@ximian.com>
+
+ * TypeDef.cs: Preserve the order of fields in a class. Then after
+ all the fields have been defined reset the order in PEAPI to the
+ correct order. This is done so sequential layouts actually
+ work. The order needs to be reset because it can be lost during
+ the recursive definition phase.
+ * MethodDef.cs: Use and ExternModule for pinvoke data's module
+ refs. This way we don't get duplicate module refs.
+
+2004-06-24 Jackson Harper <jackson@ximian.com>
+
+ * MethodDef.cs: Report when defining methods just like MS.
+ * TypeDef.cs: Error message when we can't find a locla method.
+
+2004-06-23 Jackson Harper <jackson@ximian.com>
+
+ * MethodDef.cs: sigh, another varargs fix that probably breaks
+ other varargs tets. Someday I will get this right, I don't think
+ today is that day though. This fix basically just makes sure to
+ trim the sentinel off of signatures. Also eliminated some code
+ duplication.
+ * ParamDef.cs: Make IsSentinel work for both cases of generating a
+ sentinel param def.
+
+2004-06-20 Jackson Harper <jackson@ximian.com>
+
+ * SwitchInstr.cs: Allow switches with no labels.
+
+2004-06-20 Jackson Harper <jackson@ximian.com>
+
+ * InstrTable.cs: Add .u8 opcodes for ldind and ldelem these are
+ just aliases to their .i8 equivelents.
+
+2004-06-19 Jackson Harper <jackson@ximian.com>
+
+ * MethodPointerTypeRef.cs: New File - represents a method pointer
+ that is being treated as a typeref. For example method void*() in
+ the statement castclass method void*().
+
+2004-06-19 Jackson Harper <jackson@ximian.com>
+
+ * InstrTable.cs: Add undocumented brnull opcode. This is really
+ just an alias for brfalse.
+
+2004-06-19 Jackson Harper <jackson@ximian.com>
+
+ * MethodDef.cs: Add a method to create vararg signatures from a
+ list of typerefs that matches the algorithm for creating vararg
+ signatures from paramdefs. This is used when creating methodref
+ signatures.
+ * MethodRef.cs: Use the new CreateVarargSignature method to create
+ the methods signature if it is a vararg method.
+
+2004-06-14 Jackson Harper <jackson@ximian.com>
+
+ * CodeGen.cs: Allow file refs to be added.
+ * FileRef.cs: New file - represents a file ref.
+
+2004-06-14 Jackson Harper <jackson@ximian.com>
+
+ * CodeGen.cs: Allow adding module refs.
+ * ExternTable.cs: Add ExternModule refs.
+ * ExternTypeRef.cs: Take an ExternRef which can be either an
+ assmebly ref or a module ref.
+
+2004-06-14 Jackson Harper <jackson@ximian.com>
+
+ * CodeGen.cs: Implement setting module names.
+
+2004-05-23 Jackson Harper <jackson@ximian.com>
+
+ * MethodDef.cs: Cache vararg signatures so a new memberref is not
+ created for each vararg pattern.
+
+2004-05-22 Jackson Harper <jackson@ximian.com>
+
+ * InstrTable.cs: ldc.i4.M1 is aliased to ldc.i4.m1. Fixes bug #58524.
+
+2004-05-22 Jackson Harper <jackson@ximian.com>
+
+ * GlobalMethodRef.cs: Check for sentinel properly.
+
+2004-04-03 Jackson Harper <jackson@ximian.com>
+
+ * CodeGen.cs: cast
+
+2004-04-02 Jackson Harper <jackson@ximian.com>
+
+ * CodeGen.cs: Allow setting assembly info.
+
+2004-04-01 Jackson Harper <jackson@ximian.com>
+
+ * CodeGen.cs: Add a current assembly ref and methods to create/end
+ it so we can set assembly ref attributes.
+ * ExternTable.cs: Make the ExternAssembly public so that its
+ attributes can be set.
+
+2004-03-28 Jackson Harper <jackson@ximian.com>
+
+ * PeapiTypeRef.cs: Check for null bounds in bound arrays. Patch by
+ Vladimir Vukicevic.
+ * ModifiablyType.cs: Set names properly for bound arrays.
+
+2004-02-18 Jackson Harper <jackson@ximian.com>
+
+ * ExternTypeRefInst.cs: New file - represents an instance of an
+ extern type ref, used for making value type tokens.
+ * TypeDef.cs: Add implementing classes.
+
+2003-12-10 Jackson Harper <jackson@ximian.com>
+
+ * ModifiableType.cs: Allow the conversion list to be got/set.
+ * ExternTypeRef.cs: Add a Clone method. Remove table modification.
+
+2003-12-10 Jackson Harper <jackson@ximian.com>
+
+ * ExternTable.cs: Add methods to update a types name.
+ * ExternTypeRef.cs: When a types name is modified update it in the
+ table.
+
+2003-12-08 Jackson Harper <jackson@ximian.com>
+
+ * ModifiableType.cs: Put modifier and class in the list in the
+ correct order.
+
+2003-11-18 Jackson Harper <jackson@ximian.com>
+
+ * MethodDef.cs: Add support for .zeroinit. This is just another
+ way of initializing locals.
+
+2003-11-17 Jackson Harper <jackson@ximian.com>
+
+ * LdstrInstr.cs: Allow strings to be created as bytearrays.
+
+2003-10-28 Jackson Harper <jackson@ximian.com>
+
+ * ExternTable.cs: Revert back to resolving value and class types
+ into the same table. This avoids types being resolved multiple
+ times when classrefs are used with valuetypes.
+
+2003-10-28 Jackson Harper <jackson@ximian.com>
+
+ * ExternTable.cs: This is now used to store ExternTypeRefs so we
+ only create 1 for each external type.
+ * ExternTypeRef.cs: Only create one method and field per a
+ signature/name.
+
+2003-10-18 Jackson Harper <jackson@ximian.com>
+
+ * ExternTable.cs: Separate class and value types into diff tables.
+
+2003-10-18 Jackson Harper <jackson@ximian.com>
+
+ * InstrTable.cs: Use short branch instructions instead of aliasing them
+ to the long branch instructions.
+
+2003-10-13 Jackson Harper <jackson@ximian.com>
+
+ * MethodDef.cs: Check for null param lists in vararg
+ methods. Fixes bug #49614.
+
+2003-10-11 Jackson Harper <jackson@ximian.com>
+
+ * GenericTypeRef.cs: Allow Mvars to be a base type.
+ * GenericMethodRef.cs: Basically just a wrapper around an existing
+ method making it into a generic method.
+ * GenericMethodSig.cs: Signature for a generic method.
+
+2003-10-08 Jackson Harper <jackson@ximian.com>
+
+ * PeapiTypeRef.cs: Remove old hackery for adding methods to
+ arrays, use typespecs now.
+
+2003-10-08 Jackson Harper <jackson@ximian.com>
+
+ * InstrTable.cs: Add unbox.any instruction.
+ * MethodDef.cs: Allow generic parameters to be added to methods.
+
+2003-10-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * MethodInfo.cs: Use report to display no label error message.
+
+2003-10-01 Jackson Harper <jackson@latitudegeo.com>
+
+ * LabelInfo.cs: Fix tabbing, add ToString so labels are printed
+ properly in error messages.
+
+2003-09-27 Jackson Harper <jackson@latitudegeo.com>
+
+ * MethodDef.cs: Allow PInvoke info to be added.
+
+2003-09-21 Jackson Harper <jackson@latitudegeo.com>
+
+ * CodeGen.cs: Add methods for adding data. CodeGen now takes a
+ report object for giving users errors/warnings/info.
+ * FieldDef.cs: When a data constant is assigned to a field the
+ constant might not exist yet. So just take the constants name and
+ look it up when writting code.
+ * Local.cs: Starting to add some error handling. Still playing
+ with diff ways to do this.
+ * MethodDef.cs: Add some error handling for local var lookups
+ * TypeDef.cs: Data is allways global so it should never be added
+ to a class
+ * TypeRef.cs: Error message for lookups.
+
+2003-09-20 Jackson Harper <jackson@latitudegeo.com>
+
+ * TypeDef.cs: Rework so multiple constraints can be added to a
+ generic parameter.
+
+2003-09-16 Jackson Harper <jackson@latitudegeo.com>
+
+ * InstrTable.cs: endfault instruction (which is just endfinally
+ with a costume on).
+
+2003-09-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * FinallyBlock.cs: The sad thing is how long it took me to realize
+ what was going on here...
+
+2003-09-13 Jackson Harper <jackson@latitudegeo.com>
+
+ * MethodInstr.cs: callvirt operation is implicitly instance.
+
+2003-09-12 Jackson Harper <jackson@latitudegeo.com>
+
+ * TypeRef.cs: Remove unused enum, this has been moved to the
+ ModifiableType base class.
+
+2003-09-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * TypeDef.cs: By default types will have System.Object as their
+ parent type if no parent type is specified (this is what PEAPI
+ does) however if we are assembling corlib the System.Object type
+ will not have System.Object as its parent type.
+
+2003-08-19 Jackson Harper <jackson@latitudegeo.com>
+
+ * DataDef.cs: Make name public so data names can be looked up
+ * FieldDef.cs: Stub method for adding data values
+ * TypeDef.cs: Implement long form overrides, fix some backwords
+ variable naming, add a method to lookup data definitions.
+
+2003-08-19 Jackson Harper <jackson@latitudegeo.com>
+
+ * IClassRef.cs: Removed methods that have been moved into ITypeRef
+ * MethodDef.cs: Make some properties public, Add method to get a
+ list of parameter types. This is used to build signatures. Alow
+ sentinels in signatures and in param lists. Fix some tabbing.
+ * ParamDef.cs: Expose the parameters type so they can be used when
+ building signatures.
+ * TypeDef.cs: Add and emit overrides.
+
+2003-08-10 Jackson Harper <jackson@latitudegeo.com>
+
+ * CodeGen.cs: Fix tabbing
+ * ModifiableType.cs: Modify a types signature when the type is
+ modified instead of waiting untill the end. Signatures need to be
+ modified immediatly because they are used in method signatures and
+ would fail for overloaded operations if sigs weren't modified
+ right away.
+ * ExternTypeRef.cs: Add signature modifications, fix some tabbing
+ * GenericTypeInst.cs: Use ModifiableType as a base
+ * GenericTypeRef.cs: Use ModifiableType as a base
+ * PeapiTypeRef.cs: No longer take or modify type names.
+ * PrimitiveTypeRef.cs: Add signature modifications, fix some tabbing.
+ * Sentinel.cs: Add signature modifications, fix some tabbing.
+ * TypeRef.cs: Add signature modifications, fix some tabbing.
+
+2003-08-05 Nick Drochak <ndrochak@gol.com>
+
+ * IClassRef.cs: Fix build on .NET
+
+2003-08-03 Jackson Harper <jackson@latitudegeo.com>
+
+ * IClassRef.cs: Add method for making types into value types
+ * ExternTypeRef.cs: Add functionality for valuetypes
+ * MethodDef.cs: Handle Vararg signatures individually. Fixes for
+ new Sentinel type in vararg signatures
+ * MethodRef.cs: Use new SentinelTypeRef instead of Sentinel type
+ ref constant.
+ * ParamDef.cs: New method to check if this parameter is the sentinel
+ * TypeRef.cs: Add some functionality for creating valuetypes
+ * Sentinel.cs: New type represents the sentinel
+
+2003-08-03 Jackson Harper <jackson@latitudegeo.com>
+
+ * TypeDef.cs: Make types into value types if specified. Also
+ add the functionality to make types into Enums.
+ TODO: Value types of nested classes.
+
+2003-08-03 Jackson Harper <jackson@latitudegeo.com>
+
+ * LabelInfo.cs: Move this type outside of MethodDef, because other
+ types use LabelInfos for label references now.
+ * BranchInstr.cs: Take a LabelInfo instead of information on a label.
+ * HandlerBlock.cs: Take a LabelInfo instead of information on a label.
+ * MethodDef.cs: Return LabelInfo from AddLabel methods. New method for
+ adding a reference to a label.
+
+2003-08-02 Jackson Harper <jackson@latitudegeo.com>
+
+ * ExternMethodRef.cs: Remove top secret debugging code.
+ * MethodDef.cs: Less elegant but more bugfree method of doing explicit
+ offsets for labels. Just put the offset labels in another list and
+ define them in another loop.
+
+2003-08-02 Jackson Harper <jackson@latitudegeo.com>
+
+ * IMethodRef.cs: Method refs should expose their call conv. This is
+ needed so the call conv can be modified for the newobj operation which
+ is implicitly instance.
+ * ExternMethodRef.cs: Expose call conv. Don't resolve vararg methods
+ more then once.
+ * GlobalMethodRef.cs: Expose call conv
+ * TypeSpecMethodRef.cs: Expose call conv
+ * MethodInstr.cs: For newobj operations set the call conv to instance
+
+2003-07-31 Jackson Harper <jackson@latitudegeo.com>
+
+ * MethodDef.cs: Allow 0 offsets for labels, and make sure to only
+ use offsets when we are supposed to.
+
+2003-07-30 Jackson Harper <jackson@latitudegeo.com>
+
+ * BranchInstr.cs: Allow explicit offsets for labels
+
+2003-07-29 Jackson Harper <jackson@latitudegeo.com>
+
+ * FilterBlock.cs: Use a handler block for the this block. This
+ makes it easier to create filters using braces, labels, or offsets
+ * HandlerBlock.cs: Allow handler blocks to be created using positions,
+ offsets, and labels.
+ * MethodDef.cs: Add methods to create labels all 3 ways, and emit
+ labels created by each of the methods.
+ * TryBlock.cs: Use a handler block instead of label strings. This
+ allows all three methods of label creation to be used.
+
+2003-07-29 Jackson Harper <jackson@latitudegeo.com>
+
+ * IInstr.cs: Instructions now get their parent method when being
+ emitted.
+ * *Instr.cs: Adjust emit method to accept a methoddef
+
+2003-07-27 Jackson Harper <jackson@latitudegeo.com>
+
+ * CodeGen.cs: Set the assembly name when creating the PEFile.
+
+2003-07-27 Jackson Harper <jackson@latitudegeo.com>
+
+ * CodeGen.cs: Do not create the PEFile untill the resolve phase. This
+ fixes the problem with ilasm creating blank files if their is a
+ failure in the parsing phase and not being able to set the assembly
+ name.
+ * ExternTable.cs: Do not reference the assemblies untill after the
+ PEFile untill the Resolve phase.
+
+2003-07-27 Jackson Harper <jackson@latitudegeo.com>
+
+ * ExternFieldRef.cs: Resolve as a typespec field if neccasary, make
+ sure to not resolve more then once.
+ * ExternMethodRef.cs: Resolve as a typespec method if neccasary
+ * ExternTypeRef.cs: Use modifiable type as base class
+ * FieldRef.cs: Make sure to not resolve more then once.
+ * GlobalFieldRef.cs: Make sure to not resolve more then once.
+ * GlobalMethodRef.cs: Make sure to not resolve more then once.
+ * ITypeRef.cs: Types no longer need the AsClassRef method
+ * MethodDef.cs: Only decriment param count for vararg methods if there
+ is an ellipsis on the end of the param list.
+ Fix little bug so return types allways get resolved.
+ * PeapiTypeRef.cs: Use TypeRef.Ellipsis for a place holder in bound
+ arrays instead of null
+ * PrimitiveTypeRef.cs: Use modifiable type as a base
+ * TypeRef.cs: Use modifable type as base, and let it do all the
+ modifications
+ * TypeSpecFieldRef.cs: Make sure to not resolve more then once.
+ * ModifiableType.cs: New base class for all types. This class will
+ handle all of the typemodification and determine whether methods
+ should be added to the type or the types typespec.
+
+2003-07-25 Jackson Harper <jackson@latitudegeo.com>
+
+ * MethodDef.cs: If methods do not have the static attribute give
+ them the instance calling convention.
+
+2003-07-21 Jackson Harper <jackson@latitudegeo.com>
+
+ * MethodDef.cs: Do not decremint param count for vararg methods,
+ the ellipsis is needed later
+
+2003-07-20 Jackson Harper <jackson@latitudegeo.com>
+
+ * GenericTypeInst.cs: New File - A type reference to an instance
+ of a generic type. ie Set<int32>
+ * TypeSpecFieldRef.cs: New File - A field ref that is attached to
+ a typespec. This can be used with modified types, and generic types.
+ * TypeSpecMethodRef.cs: New File - A method ref that is attached
+ to a typespec. This can be used with modified types, and generic types.
+ * GenericTypeRef.cs: Create method refs and field refs using the
+ new typespec classes.
+ * ITypeRef.cs: Types should now be able to have methods and fields
+ attached to them
+ * PeapiTypeRef.cs: Set UseTypeSpec to true if the type is modified
+ * PrimitiveTypeRef.cs: Add methods to attach fields and
+ methods. This just uses the TypeSpec* classes so I don't need to
+ create classrefs.
+ * TypeRef.cs: Set UseTypeSpec to true if a type is modified.
+
+2003-07-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * GenericTypeRef.cs: New File - A reference to a generic type
+ spec. ie !0 or !1
+ * InstrTable.cs: Add the stelem and ldelem opcodes.
+
+2003-07-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * TypeDef.cs: Allow adding and emitting generic type constraints.
+
+2003-07-14 Jackson Harper <jackson@latitudegeo.com>
+
+ * TypeDef.cs: Emit generic parameters.
+
+2003-06-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * CodeGen.cs: Fix buglet in cache name creating (I will claim this
+ was a typo).
+
+2003-06-14 Jackson Harper <jackson@latitudegeo.com>
+
+ * CodeGen.cs: When creating nested types cache their names using
+ the parent/type method but emit their short name.
+
+2003-06-14 Jackson Harper <jackson@latitudegeo.com>
+
+ * CodeGen.cs: Add methods for setting corflags, subsystem, and corflags.
+
+2003-06-14 Jackson Harper <jackson@latitudegeo.com>
+
+ * ITypeRef.cs, PeapiTypeRef.cs, TypeRef.cs: Quick hack for custom
+ modified types.
+
+2003-06-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * EventDef.cs: Only add one method for addon, fire, other, and
+ removeon
+
+2003-06-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * TypeDef.cs: Add properties to types.
+ * PropertyDef.cs: New file - Implementation of a type property feature
+
+2003-06-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * TypeDef.cs: Fix silly null reference bug.
+
+2003-06-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * EventDef.cs: New file - An event definition.
+ * FeatureAttr.cs: New file - Attributes for features (events and
+ properties)
+ * MethodRef.cs: Only resolve methods once.
+ * TypeDef.cs: Allow Events to be added to types. Also add
+ functionality to add generic type parameters to types. The
+ actually emission of these type parameters is commented out untill
+ I commit my patches to PEAPI and work out the syntax of constraints.
+
+2003-05-31 Jackson Harper <jackson@latitudegeo.com>
+
+ * CodeGen.cs: Allow this assembly name to be set.
+ * HandlerBlock.cs: Make label fields public so they can be
+ accessed in a TryBlocks constructor.
+ * MethodDef.cs: Allow random labels to be inserted at the current
+ position. These are use for scope blocks.
+ * TryBlock.cs: New constructor takes from and to labels as a HandlerBlock
+
+2003-05-31 Jackson Harper <jackson@latitudegeo.com>
+
+ * CustomAttr.cs: New file - Custom attributes
+ * InstrTable.cs: Add stelem.r4 and stelem.r8 instructions. Add
+ . tail to unaligned modifier.
+ * LdtokenInstr.cs: Add type tokens.
+ * MethodDef.cs: Fix IsVararg, add method to add custom attributes,
+ emitting custom attributes when writing code, allow for Ellipsises
+ in param lists, add coma between args in signatures.
+ * ParamDef.cs: Add the Ellipsis pseudo param
+ * PrimitiveTypeRef.cs: System.String and System.Object can be
+ referenced without an [mscorlib] assembly prefix.
+ * TypeDef.cs: Add Custom attributes.
+
+2003-05-25 Jackson Harper <jackson@latitudegeo.com>
+
+ * CodeGen.cs: Add method to resolve global vararg methods.
+ * ExternMethodRef.cs: Resolve vararg methods
+ * GlobalMethodRef.cs: Set calling conventions, add vararg methods
+ * MethodDef.cs: Set calling conventions, add vararg methods
+ * MethodRef.cs: Set calling conventions, add vararg methods
+ * TypeDef.cs: Resolve vararg methods
+ * TypeRef.cs: Add Ellipsis pseudo type, this should never really
+ be used as a type, but is stored in arrays with other types. Pass
+ call convs to methodref constructor.
+
+2003-05-24 Jackson Harper <jackson@latitudegeo.com>
+
+ * CatchBlock.cs: Remove typo causing to labels to be the same as
+ from labels.
+ * FaultBlock.cs: Remove typo causing to labels to be the same as
+ from labels.
+ * FilterBlock.cs: Remove typo causing to labels to be the same as
+ from labels.
+ * MethodDef.cs: Allow for multiple labels to point to the same
+ line. ie:
+ END_BLOCK:
+ PASS:
+ do stuff
+
+2003-05-23 Jackson Harper <jackson@latitudegeo.com>
+
+ * CatchBlock.cs: New file - Initial implementation of a catch
+ block
+ * FaultBlock.cs: New file - Initial implementation of a fault
+ block
+ * FilterBlock.cs: New file - Initial implementation of a filter
+ block
+ * FinallyBlock.cs: New file - Initial implementation of a finally
+ block
+ * HandlerBlock.cs: New file - A handler block is the block
+ assosciated with a SEH clause
+ * ISehClause: New file - Interface that structured exception
+ handling clauses must implement.
+ * TryBlock.cs: New file - Initial implementation only supports
+ label form SEH. This TryBlock is added to a method as an
+ instruction out of convenience, tryblock is not an instruction.
+
+2003-05-22 Jackson Harper <jackson@latitudegeo.com>
+
+ * InstrTable.cs: Add unsigned conversion instructions.
+
+2003-05-21 Jackson Harper <jackson@latitudegeo.com>
+
+ * CalliInstr.cs: New file - The calli instruction
+ * Ldtoken.cs: New file - The ldtoken instruction
+ * InstrTable.cs: ldc.i8 is a TOKEN_I8 and should be given the
+ MiscToken.ldc_i8 value.
+
+2003-05-18 Jackson Harper <jackson@latitudegeo.com>
+
+ * ExternMethodRef.cs: Accept and add calling conventions. Add
+ methods using array methods if owners are arrays, resolve methods
+ named <init> as .ctor.
+ * ExternTable.cs: Add method to get value classes.
+ * ExternTypeRef.cs: Add AsClassRef method, GetMethodRef now takes
+ calling conventions.
+ * IClassRef.cs: GetMethodRef now takes calling conventions
+ * ITypeRef.cs: Add IsArray IsRef and AsClassRef methods
+ * MethodRef.cs: Change <init> to .ctor
+ * PeapiTypeRef.cs: This class is no longer an ITypeRef because it
+ cannot be converted to a IClassRef. Add IsArray and IsRef, use new
+ Class::GetArray* methods to convert to arrays.
+ * PrimitiveTypeRef.cs: Add method to convert to an IClassRef
+ * TypeRef.cs: Add IsArray and IsRef, add method to convert to
+ IClassRef. GetMethodRef now takes calling conventions
+
+2003-05-11 Jackson Harper <jackson@latitudegeo.com>
+
+ * MethodDef.cs: Add named param table and methods to get named param
+ positions. Add method to get named local variables slot
+ number. Make sure param_lists aren't null when defining them. Add
+ specialname and rtspecialname attributes if the method being
+ defined is named '.ctor' or '.cctor'. Add new method for creating
+ signatures using a list of typerefs.
+ * GlobalMethodRef.cs: Use new CreateSignature method that takes an
+ array of typerefs.
+ * MethodRef.cs: Use new CreateSignature method
+ * InstrTable.cs: Use INSTR_LOCAL and INSTR_PARAM tokens for
+ instructions that take local and param operands.
+
+2003-05-11 Jackson Harper <jackson@latitudegeo.com>
+
+ * TypeDef.cs: Add size and packing information
+
+2003-05-10 Jackson Harper <jackson@latitudegeo.com>
+
+ * IFieldRef.cs: New file - interface field references must implement
+ * ExternFieldRef.cs: New file - Reference to a field in another
+ assembly
+ * FieldRef.cs: New file - Reference to a field in this assembly
+ * GlobalFieldRef.cs: New file - Reference to a global field
+ * FieldInstr.cs: New file - Instruction that takes a field
+ instruction
+ * CodeGen.cs: Add method to resolve global methods
+ * ExternTypeRef.cs: Add method to get method references
+ * FieldDef.cs: Allow methods to be resolved before being defined
+ * IClassRef.cs: Add method to get field references.
+ * TypeDef.cs: Add method to resolve member fields.
+ * TypeRef.cs: Add method to get field references
+
+2003-05-10 Jackson Harper <jackson@latitudegeo.com>
+
+ * GlobalMethodRef.cs: New file - A reference to a global method
+ * CodeGen.cs: Store global methods and fields in hashtables to
+ make lookup easier. Add method to resolve global methods.
+
+2003-05-10 Jackson Harper <jackson@latitudegeo.com>
+
+ * MethodDef.cs: Allways set max stack
+
+2003-05-10 Jackson Harper <jackson@latitudegeo.com>
+
+ * ExternTable.cs: Alias corlib to mscorlib since these seem to get
+ used interchangably
+
+2003-05-10 Jackson Harper <jackson@latitudegeo.com>
+
+ * IMethodRef.cs: New file - Interface that method references must
+ implement
+ * ExternMethodRef.cs: New file - Reference to a method in another
+ assembly
+ * Local.cs: New file - A Local variable
+ * MethodInstr.cs: New file - an instruction that takes a method
+ reference operand
+ * IClassRef.cs: Add method to get a method reference from a class
+ reference
+ * MethodDef.cs: Add ability to resolve methods before defining
+ them, add max stack, locals, and entry point. Make CreateSignature
+ method public and static so other classes can use it.
+ * TypeDef.cs: Store methods and fields in hashtables so they can
+ be easily retrieved, add method to resolve member methods.
+ * TypeRef.cs: Add method for resolving member methods.
+ * ExternTypeRef.cs: Add methods to get classref and methodrefs
+ * MethodRef.cs: New file - Reference to a method in this assembly.
+
+
+2003-05-07 Jackson Harper <jackson@latitudegeo.com>
+
+ * TypeInstr.cs: New file - implementation of instructions that
+ take a single type instruction.
+
+2003-05-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * SwitchInstr.cs: New file - implementation of switch instructions
+
+2003-05-05 Jackson Harper <jackson@lattidegeo.com>
+
+ * MethodDef.cs: Add ability to add and emit labels
+ * BranchInstr.cs: New file - Branch instructions
+
+2003-05-04 Jackson Harper <jackson@latitudegeo.com>
+
+ * LdcInstr.cs: New file - lcd* instructions
+ * MiscInstr.cs: New file - Just an enum that gives me constant
+ values for instructions PEAPI does not define in an enum
+ * InstrTable.cs: Use new MiscInstr constants instead of string values.
+
+2003-05-01 Jackson Harper <jackson@latitudegeo.com>
+
+ * CodeGen.cs: Define the contents of types after all types have
+ been resolved, this avoids the infinite loop that would occur if a
+ type was a member of its base type.
+ * TypeDef.cs: Method to define contents after being defined.
+
+2003-05-01 Jackson Harper <jackson@latitudegeo.com>
+
+ * TypeManager.cs: Check if type is defined before defining it.
+
+2003-05-01 Jackson Harper <jackson@latitudegeo.com>
+
+ * CodeGen.cs: Add outer classes to typedefs if necesary
+ * InstrTable.cs: ldtoken instruction is a INSTR_TOK token
+ * TypeDef.cs: Add outer class property
+
+2003-04-30 Jackson Harper <jackson@latitudegeo.com>
+
+ * MethodDef.cs: Accept and emit instructions.
+ * CodeGen.cs: Fix typo
+ * IInstr.cs: New file - Interface for instructions that are added to methods
+ * IntInstr.cs: New file - Instruction that takes a single int
+ param
+ * LdstrInstr.cs: New file - ldstr instruction (the only
+ instruction that takes a string parameter)
+
+2003-04-28 Jackson Harper <jackson@latitudegeo.com>
+
+ * InstrTable.cs: Much simpler system. All tokens go into one
+ hashtable now. There is no reason to have them seperated out.
+
+2003-04-20 Jackson Harper <jackson@latitudegeo.com>
+
+ * CodeGen.cs: Add method to add data
+ * FieldDef.cs: Add method to set a fields value
+ * TypeDef.cs: Add method to add data
+ * DataDef.cs: New file - Definition of a data constant
+
+2003-04-18 Jackson Harper <jackson@latitudegeo.com>
+
+ * FieldDef.cs: Change peapi fielddef name.
+ * MethodDef.cs: Change peapi methoddef name.
+
+2003-04-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * MethodDef.cs: New file - definition of a method.
+ * ParamDef.cs: New file - definition of a parameter to a method
+ * TypeDef.cs: Add method definitions, set intransit flag to false
+ before defining members, so a false circular reference is not
+ created.
+ * CodeGen.cs: Add methods to add method definitions
+
+2003-04-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * ExternTypeRef.cs: external types are classrefs
+
+2003-04-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * PeapiTypeRef.cs: New file - base wrapper for type refs that are
+ just peapi types.
+ * PrimitiveTypeRef.cs: New file - A primitive type (char, int, string)
+
+2003-04-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * TypeRef.cs: Rewrite - Typerefs are now resolved after parsing.
+ * TypeManager.cs: Rewrite - Just a simple table for looking up
+ typedefs
+ * ExternTable.cs: Create ClassRef's instead of Classes
+ * Location.cs: Make compile
+ * CodeGen.cs: Use new tree system
+
+2003-04-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * ExternTypeRef.cs: New file - Represents a reference to a type in
+ an external assembly
+ * FieldDef.cs: New file - Represents a field definition
+ * IClassRef.cs: New file - Interface that classrefs must
+ implement. This needs some more thought though because once a
+ classref has been modified it is no longer a classref.
+ * ITypeRef.cs: New file - Interface that references to types must
+ implement
+ * TypeDef.cs: New file - Represents the a class definition, and
+ will hold all of the classes members.
+
+2003-04-07 Jackson Harper <jackson@latitudegeo.com>
+
+ * TypeRef.cs: Return FieldDef when adding a field def to a class
+
+2003-04-01 Jackson Harper <jackson@latitudegeo.com>
+
+ * TypeRef.cs: Add flag for making types pinned
+
+2003-04-01 Jackson Harper <jackson@latitudegeo.com>
+
+ * ClassTable.cs: Do not append a . to names that are not in a
+ namespace
+ * CodeGen.cs: Handle nested classes
+
+2003-03-30 Jackson Harper <jackson@latitudegeo.com>
+
+ * ExternTable.cs: Remove some unsed fields.
+
+2003-03-30 Jackson Harper <jackson@latitudegeo.com>
+
+ * ExternTable.cs: Add method to lookup classes with a full name,
+ instead of having to have namespace and name seperate.
+ * ClassTable.cs: Make method that seprates full names into
+ name/namespaces public.
+
+2003-03-30 Jackson Harper <jackson@latitudegeo.com>
+
+ * InstrTable.cs: Add Calli, detabify
+
+2003-03-29 Jackson Harper <jackson@latitudegeo.com>
+
+ * InstrTable.cs: Add branch ops switch, and lc.r*, also fix some
+ typos for other ops.
+
+2003-03-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * ClassTable.cs: Set defined flag and type attributes for referenced
+ classes when they are defined.
+
+2003-03-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * MethodTable.cs: Add method to Check if all methods have been defined, set referenced methods properties
+ when defining them
+ * FieldTable.cs: Add method to check if all fields have been defined, set referenced fields properties
+ when defining them
+ * ClassTable.cs: Make sure all methods and fields are defined.
+
+2003-03-16 Jackson Harper <jackson@latitudegeo.com>
+
+ * MethodTable.cs: Fire events when methods are defined and referenced
+
+2003-03-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * ClassTable.cs: Classes now store field tables
+ * CodeGen.cs: Add methods to add fields and get field references
+
+2003-03-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * FieldTable.cs: New file, holds a classes fields
+
+2003-03-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * InstrTable.cs: Add FieldOp instructions
+
+2003-03-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * InstrTable.cs: Add ldstr instruction
+
+2003-03-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * CodeGen.cs: Add method to get method references.
+ * MethodTable.cs: Complete GetReference method
+ * InstrTable.cs: Add MethodOps (instructions that take a method ref param)
+
+2003-03-14 Jackson Harper <jackson@latitudegeo.com>
+
+ * InstrTable.cs: Add TypeOps (instructions that take a type param)
+
+2003-03-14 Jackson Harper <jackson@latitudegeo.com>
+
+ * InstrTable.cs: Add IntOps (instructions that take an integer param)
+
+2003-03-13 Jackson Harper <jackson@latitudegeo.com>
+
+ * InstrTable.cs: Fix instructions that have dots in their name
+
+2003-03-13 Jackson Harper <jackson@latitudegeo.com>
+
+ * CodeGen.cs: Add code buffer for il instructions when a new method is added.
+ * InstrTable.cs: New file, this is a table of all the instructions (just simple
+ instructions right now)
+
+2003-03-13 Jackson Harper <jackson@latitudegeo.com>
+
+ * CodeGen.cs: Set current method when a new method is added.
+
+2003-03-12 Jackson Harper <jackson@latitudegeo.com>
+
+ * ClassTable.cs: Add Method tables to Class tables, add method to get a
+ class's method table.
+ * CodeGen.cs: Add Method to add methods :p
+ * MethodTable.cs: Add file, this class is used to add methods to a class.
+
+2003-03-11 Jackson Harper <jackson@latitudegeo.com>
+
+ * TypeRef.cs: New file, used for pairing types and their names.
+
+2003-03-09 Jackson Harper <jackson@latitudegeo.com>
+
+ * ExternTable.cs: Do not verify the existence of external types
+
+2003-03-08: Jackson Harper <jackson@latitudegeo.com>
+
+ * CodeGen.cs: Add ExternTable property
+ * ExternTable.cs: New file, this will is used for pulling
+ types and methods from external assemblies.
+
+2003-03-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * ClassTable.cs, CodeGen.cs: Add methods to allow types to inherit from another type.
+
+2003-03-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * ClassTable.cs: Add method to check for undefined types
+
+2003-03-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * CodeGen.cs: Use class table for adding type definitions
+ * ClassTable.cs: Return ClassDef when defining types
+
+2003-03-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * ClassTable.cs: Add method for adding class definitions to the
+ the table.
+
+2003-03-6 Jackson Harper <jackson@latitudegeo.com>
+
+ * CodeGen.cs: Reconfigure to work with new PEAPI emission system
+
+2003-03-6 Jackson Harper <jackson@latitudegeo.com>
+
+ * ClassTable.cs: Add file, this is a 'table' for storing classes
+ * Location.cs: Add file, this will eventually be used for marking
+ locations in IL files
+
+2003-02-10 Jackson Harper <jackson@latitudegeo.com>
+
+ * Method.cs: Add method to set parameters,
+ set parameters when defining type
+ * Class.cs: Fix very silly bug in GetMethod method
+
+
+2003-02-09 Jackson Harper <jackson@latitudegeo.com>
+
+ * Class.cs: Resolve Methods before emiting
+ * InstrBase.cs: Take a Class instead of CodeGen when emiting
+ * Method.cs: Replace MethodInfo property with MethodBuilder property,
+ Add resolve method
+ * Instructions.cs: Take Class instead of CodeGen when emitting,
+ get member methods from Class.
+ * TypeManager.cs: Add set indexer
+
+2003-02-09 Jackson Harper <jackson@latitudegeo.com>
+
+ * Instructions.cs: Use TypeManager to lookup types
+
+2003-02-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * TypeManager.cs: Fix error parsing type names
+ * Method.cs: Display the name of types that can't be found
+
+2003-02-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * TypeManager.cs: Add file
+ * CodeGen.cs: Add TypeManager attribute
+ * InstrBase.cs: Take a CodeGen in Emit method
+ * Instructions.cs: Take a CodeGen in Emit method, handle arg lists better
+ * Method.cs: Handle local variables better
+
+
+2003-02-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * Method.cs: Add functionality to define local variables
+ * Instructions.cs: Add newobj instruction, cleanup call instruction
+
+2003-02-03 Jackson Harper <jackson@latitudegeo.com>
+
+ * AssemblyNameStore.cs: Added file
+
+2003-02-02 Jackson Harper <jackson@latitudegeo.com>
+
+ * Instructions.cs: Resolve parameters types in a more proper manner.
+
+2003-02-02 Jackson Harper <jackson@latitudegeo.com>
+
+ * Class.cs: Don't try to emit methods if we don't have any
+ * Class.cs: Test for entry point of methods, and set Assembly entrypoint
+ * CodeGen.cs: Add method to set an Assemblys entry point
+ * Method.cs: Add IsEntryPoint property
+ * Method.cs Add MethodInfo property, and set this while Emiting
+ * Instructions.cs: Add new InstrCall instruction
diff --git a/mcs/ilasm/codegen/Class.cs b/mcs/ilasm/codegen/Class.cs
new file mode 100644
index 00000000000..58a946cd1fe
--- /dev/null
+++ b/mcs/ilasm/codegen/Class.cs
@@ -0,0 +1,169 @@
+// Class.cs
+// (C) Sergey Chaban (serge@wildwestsoftware.com)
+
+using System;
+using System.Collections;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.ILASM {
+
+ /// <summary>
+ /// </summary>
+ public class ClassName {
+
+ private string name;
+ private string assembly;
+ private string module;
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="name"></param>
+ public ClassName (string name) {
+ this.name = name;
+ this.assembly = String.Empty;
+ this.module = String.Empty;
+ }
+
+
+ public string Name {
+ get {
+ return name;
+ }
+ }
+
+
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public class Class {
+
+ private string name;
+
+ // extends clause
+ private ClassName baseClass;
+
+ // implements clause
+ private ArrayList interfaces;
+
+ private ArrayList methods;
+
+ private TypeBuilder tb;
+
+ private CodeGen codgen;
+
+ private TypeAttributes attrs;
+
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="name"></param>
+ public Class (string name)
+ {
+ this.name = name;
+ }
+
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="m"></param>
+ public void AddMethod (Method m)
+ {
+ if (methods == null) methods = new ArrayList ();
+ methods.Add (m);
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public CodeGen CodeGen {
+ get {
+ return codgen;
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public TypeAttributes Attrs {
+ get {
+ return attrs;
+ }
+ set {
+ attrs = value;
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public TypeBuilder TypeBuilder {
+ get {
+ if (tb == null && codgen != null) {
+ tb = codgen.ModBuilder.DefineType (name, Attrs);
+ }
+ return tb;
+ }
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <param name="cg"></param>
+ public void Emit (CodeGen cg)
+ {
+ codgen = cg;
+
+ TypeBuilder.CreateType();
+ cg.TypeManager[name] = TypeBuilder;
+
+ if (methods != null) {
+ foreach (Method m in methods)
+ m.Resolve (this);
+ }
+
+ if (methods != null) {
+ foreach (Method m in methods) {
+ m.Emit (this);
+ if (m.IsEntryPoint)
+ cg.SetEntryPoint (m.Builder);
+ }
+ }
+ }
+
+ // This can be removed when System.Reflection.Emit.TypeBuilder.GetMethod is implemented
+ // TODO: This function needs allot of work
+ public MethodInfo GetMethod (string method_name, BindingFlags binding_flags,
+ Type[] param_type_list)
+ {
+ foreach (Method method in methods) {
+ if (method.Name != method_name)
+ continue;
+ ParameterInfo[] param_info = method.Builder.GetParameters ();
+ if (param_info == null) {
+ if (param_type_list.Length == 0)
+ return method.Builder;
+ else
+ continue;
+ }
+ int size = param_info.Length;
+ if (param_type_list.Length != size)
+ continue;
+ for (int i=0; i<size; i++) {
+ if (param_type_list[i] != param_info[i].ParameterType)
+ goto end;
+ }
+
+ return method.Builder;
+ end: continue;
+ }
+
+ return null;
+ }
+ }
+}
+
diff --git a/mcs/ilasm/codegen/ClassTable.cs b/mcs/ilasm/codegen/ClassTable.cs
new file mode 100644
index 00000000000..0c2b5adcaca
--- /dev/null
+++ b/mcs/ilasm/codegen/ClassTable.cs
@@ -0,0 +1,250 @@
+//
+// Mono.ILASM.ClassTable.cs
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+using PEAPI;
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class ClassTable {
+
+ private class ClassTableItem {
+
+ private static readonly int DefinedFlag = 2;
+
+ private int flags;
+
+ public ArrayList LocationList;
+ public ClassDef Class;
+ public MethodTable method_table;
+ public FieldTable field_table;
+
+ public ClassTableItem (ClassDef klass, Location location)
+ {
+ flags = 0;
+ Class = klass;
+ LocationList = new ArrayList ();
+ LocationList.Add (location);
+ method_table = new MethodTable (klass);
+ field_table = new FieldTable (klass);
+ }
+
+ public bool Defined {
+ get { return ((flags & DefinedFlag) != 0); }
+ set {
+ if (value)
+ flags |= DefinedFlag;
+ else
+ flags ^= DefinedFlag;
+ }
+ }
+
+ public bool CheckDefined ()
+ {
+ if (!Defined)
+ return false;
+
+ if (!FieldTable.CheckDefined ())
+ return false;
+
+ if (!MethodTable.CheckDefined ())
+ return false;
+
+ return true;
+ }
+
+ public MethodTable MethodTable {
+ get { return method_table; }
+ }
+
+ public FieldTable FieldTable {
+ get { return field_table; }
+ }
+
+ }
+
+ protected readonly TypeAttr DefaultAttr;
+ protected Hashtable table;
+ protected PEFile pefile;
+
+ public ClassTable (PEFile pefile)
+ {
+ DefaultAttr = TypeAttr.Public;
+ this.pefile = pefile;
+ table = new Hashtable ();
+ }
+
+ public Class Get (string full_name)
+ {
+ ClassTableItem item = table[full_name] as ClassTableItem;
+
+ if (item == null)
+ return null;
+
+ return item.Class;
+ }
+
+ public Class GetReference (string full_name, Location location)
+ {
+ ClassTableItem item = table[full_name] as ClassTableItem;
+
+ if (item != null) {
+ item.LocationList.Add (location);
+ return item.Class;
+ }
+
+ string name_space, name;
+ GetNameAndNamespace (full_name, out name_space, out name);
+ ClassDef klass = pefile.AddClass (DefaultAttr, name_space, name);
+ AddReference (full_name, klass, location);
+
+ return klass;
+ }
+
+ public MethodTable GetMethodTable (string full_name, Location location)
+ {
+ ClassTableItem item = table[full_name] as ClassTableItem;
+
+ if (item == null) {
+ GetReference (full_name, location);
+ return GetMethodTable (full_name, location);
+ }
+
+ return item.MethodTable;
+ }
+
+ public FieldTable GetFieldTable (string full_name, Location location)
+ {
+ ClassTableItem item = table[full_name] as ClassTableItem;
+
+ if (item == null) {
+ GetReference (full_name, location);
+ return GetFieldTable (full_name, location);
+ }
+
+ return item.FieldTable;
+ }
+
+ public ClassDef AddDefinition (string name_space, string name,
+ TypeAttr attr, Location location)
+ {
+ string full_name;
+
+ if (name_space != null)
+ full_name = String.Format ("{0}.{1}", name_space, name);
+ else
+ full_name = name;
+
+ ClassTableItem item = (ClassTableItem) table[full_name];
+
+ if (item == null) {
+ ClassDef klass = pefile.AddClass (attr, name_space, name);
+ AddDefined (full_name, klass, location);
+ return klass;
+ }
+
+ item.Class.AddAttribute (attr);
+ item.Defined = true;
+
+ return item.Class;
+ }
+
+ public ClassDef AddDefinition (string name_space, string name,
+ TypeAttr attr, Class parent, Location location)
+ {
+ string full_name;
+
+ if (name_space != null)
+ full_name = String.Format ("{0}.{1}", name_space, name);
+ else
+ full_name = name;
+
+ ClassTableItem item = (ClassTableItem) table[full_name];
+
+ if (item == null) {
+ ClassDef klass = pefile.AddClass (attr, name_space, name, parent);
+ AddDefined (full_name, klass, location);
+ return klass;
+ }
+
+ /// TODO: Need to set parent, will need to modify PEAPI for this.
+ item.Class.AddAttribute (attr);
+ item.Defined = true;
+
+ return item.Class;
+ }
+
+ /// <summary>
+ /// When there is no code left to compile, check to make sure referenced types where defined
+ /// TODO: Proper error reporting
+ /// </summary>
+ public void CheckForUndefined ()
+ {
+ foreach (DictionaryEntry dic_entry in table) {
+ ClassTableItem table_item = (ClassTableItem) dic_entry.Value;
+ if (table_item.CheckDefined ())
+ continue;
+ Report.Error (String.Format ("Type: {0} is not defined.", dic_entry.Key));
+ }
+ }
+
+ /// <summary>
+ /// If a type is allready defined throw an Error
+ /// </summary>
+ protected void CheckExists (string full_name)
+ {
+ ClassTableItem item = table[full_name] as ClassTableItem;
+
+ if ((item != null) && (item.Defined)) {
+ Report.Error (String.Format ("Class: {0} defined in multiple locations.",
+ full_name));
+ }
+ }
+
+ protected void AddDefined (string full_name, ClassDef klass, Location location)
+ {
+ if (table.Contains (full_name))
+ return;
+
+ ClassTableItem item = new ClassTableItem (klass, location);
+ item.Defined = true;
+
+ table[full_name] = item;
+ }
+
+ protected void AddReference (string full_name, ClassDef klass, Location location)
+ {
+ if (table.Contains (full_name))
+ return;
+
+ ClassTableItem item = new ClassTableItem (klass, location);
+
+ table[full_name] = item;
+ }
+
+ public static void GetNameAndNamespace (string full_name,
+ out string name_space, out string name) {
+
+ int last_dot = full_name.LastIndexOf ('.');
+
+ if (last_dot < 0) {
+ name_space = String.Empty;
+ name = full_name;
+ return;
+ }
+
+ name_space = full_name.Substring (0, last_dot);
+ name = full_name.Substring (last_dot + 1);
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/CodeGen.cs b/mcs/ilasm/codegen/CodeGen.cs
new file mode 100644
index 00000000000..cabfe9b7f5d
--- /dev/null
+++ b/mcs/ilasm/codegen/CodeGen.cs
@@ -0,0 +1,595 @@
+//
+// Mono.ILASM.CodeGen.cs
+//
+// Author(s):
+// Sergey Chaban (serge@wildwestsoftware.com)
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) Sergey Chaban
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+using PEAPI;
+using System;
+using System.IO;
+using System.Collections;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Text;
+using System.Security;
+
+
+namespace Mono.ILASM {
+
+ public class CodeGen {
+
+ private PEFile pefile;
+ private string assembly_name;
+ private ExternAssembly current_assemblyref;
+ private ExternModule current_moduleref;
+ private string current_namespace;
+ private TypeDef current_typedef;
+ private MethodDef current_methoddef;
+ private ArrayList typedef_stack;
+ private int typedef_stack_top;
+ private SymbolWriter symwriter;
+ private ICustomAttrTarget current_customattrtarget;
+ private IDeclSecurityTarget current_declsectarget;
+ private PEAPI.NativeType current_field_native_type;
+
+ private byte [] assembly_public_key;
+ private int assembly_major_version;
+ private int assembly_minor_version;
+ private int assembly_build_version;
+ private int assembly_revision_version;
+ private string assembly_locale;
+ private int assembly_hash_algorithm;
+ private ArrayList assembly_custom_attributes;
+ private DeclSecurity assembly_declsec;
+
+ private TypeManager type_manager;
+ private ExternTable extern_table;
+ private Hashtable global_field_table;
+ private Hashtable global_method_table;
+ private Hashtable global_methodref_table;
+ private Hashtable global_fieldref_table;
+ private ArrayList data_list;
+ private FileRef file_ref;
+ private ArrayList manifestResources;
+ private Hashtable typeref_table;
+
+ private ArrayList defcont_list;
+
+ private int sub_system;
+ private int cor_flags;
+ private long image_base;
+ private long stack_reserve;
+
+ private string output_file;
+ private string debug_file;
+ private bool is_dll;
+ private bool is_assembly;
+ private bool entry_point;
+
+ private Module this_module;
+
+ public CodeGen (string output_file, bool is_dll, bool is_assembly,
+ bool debugging_info)
+ {
+ this.output_file = output_file;
+ this.is_dll = is_dll;
+ this.is_assembly = is_assembly;
+
+ if (debugging_info)
+ symwriter = new SymbolWriter (CreateDebugFile (output_file));
+
+ type_manager = new TypeManager (this);
+ extern_table = new ExternTable ();
+ typedef_stack = new ArrayList ();
+ typedef_stack_top = 0;
+ global_field_table = new Hashtable ();
+ global_method_table = new Hashtable ();
+
+ data_list = new ArrayList ();
+
+ defcont_list = new ArrayList ();
+
+ sub_system = -1;
+ cor_flags = -1;
+ image_base = -1;
+ stack_reserve = -1;
+ entry_point = false;
+ this_module = null;
+ }
+
+ private string CreateDebugFile (string output_file)
+ {
+ int ext_index = output_file.LastIndexOf ('.');
+
+ if (ext_index == -1)
+ ext_index = output_file.Length;
+
+ return String.Format ("{0}.{1}", output_file.Substring (0, ext_index),
+ "mdb");
+ }
+
+ public PEFile PEFile {
+ get { return pefile; }
+ }
+
+ public SymbolWriter SymbolWriter {
+ get { return symwriter; }
+ }
+
+ public string CurrentNameSpace {
+ get { return current_namespace; }
+ set { current_namespace = value; }
+ }
+
+ public TypeDef CurrentTypeDef {
+ get { return current_typedef; }
+ }
+
+ public MethodDef CurrentMethodDef {
+ get { return current_methoddef; }
+ }
+
+ public ExternAssembly CurrentAssemblyRef {
+ get { return current_assemblyref; }
+ }
+
+ public ExternModule CurrentModuleRef {
+ get { return current_moduleref; }
+ }
+
+ public ICustomAttrTarget CurrentCustomAttrTarget {
+ get { return current_customattrtarget; }
+ set { current_customattrtarget = value; }
+ }
+
+ public IDeclSecurityTarget CurrentDeclSecurityTarget {
+ get { return current_declsectarget; }
+ set { current_declsectarget = value; }
+ }
+
+ public ExternTable ExternTable {
+ get { return extern_table; }
+ }
+
+ public TypeManager TypeManager {
+ get { return type_manager; }
+ }
+
+ public bool HasEntryPoint {
+ get { return entry_point; }
+ set {
+ /* if (!value) error: unsetting entrypoint ? */
+ if (entry_point)
+ Report.Error ("Multiple .entrypoint declarations.");
+ entry_point = value;
+ }
+ }
+
+ public TypeRef GetTypeRef (string name)
+ {
+ TypeRef tr = null;
+
+ if (typeref_table == null)
+ typeref_table = new Hashtable ();
+ else
+ tr = typeref_table [name] as TypeRef;
+
+ if (tr == null) {
+ tr = new TypeRef (name, false, null);
+ typeref_table [name] = tr;
+ }
+
+ return tr;
+ }
+
+ public GlobalMethodRef GetGlobalMethodRef (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
+ string name, BaseTypeRef[] param, int gen_param_count)
+ {
+ string key = MethodDef.CreateSignature (ret_type, name, param, gen_param_count);
+
+ GlobalMethodRef methref = null;
+
+ if (global_methodref_table == null)
+ global_methodref_table = new Hashtable ();
+ else
+ methref = (GlobalMethodRef) global_methodref_table [key];
+
+ if (methref == null) {
+ methref = new GlobalMethodRef (ret_type, call_conv, name, param, gen_param_count);
+ global_methodref_table [key] = methref;
+ }
+
+ return methref;
+ }
+
+ public GlobalFieldRef GetGlobalFieldRef (BaseTypeRef ret_type, string name)
+ {
+ string key = ret_type.FullName + name;
+
+ GlobalFieldRef fieldref = null;
+
+ if (global_fieldref_table == null)
+ global_fieldref_table = new Hashtable ();
+ else
+ fieldref = (GlobalFieldRef) global_fieldref_table [key];
+
+ if (fieldref == null) {
+ fieldref = new GlobalFieldRef (ret_type, name);
+ global_fieldref_table [key] = fieldref;
+ }
+
+ return fieldref;
+ }
+
+ public void SetSubSystem (int sub_system)
+ {
+ this.sub_system = sub_system;
+ }
+
+ public void SetCorFlags (int cor_flags)
+ {
+ this.cor_flags = cor_flags;
+ }
+
+ public void SetImageBase (long image_base)
+ {
+ this.image_base = image_base;
+ }
+
+ public void SetStackReserve (long stack_reserve)
+ {
+ this.stack_reserve = stack_reserve;
+ }
+
+ public void SetAssemblyName (string name)
+ {
+ if (assembly_name != null && assembly_name != name)
+ Report.Error ("Multiple assembly declarations");
+ assembly_name = name;
+ if (assembly_name != "mscorlib")
+ ExternTable.AddCorlib ();
+ }
+
+ public void SetModuleName (string module_name)
+ {
+ this_module = new Module (module_name);
+ CurrentCustomAttrTarget = this_module;
+ }
+
+ public void SetFileRef (FileRef file_ref)
+ {
+ this.file_ref = file_ref;
+ }
+
+ public bool IsThisAssembly (string name)
+ {
+ return (name == assembly_name);
+ }
+
+ public Module ThisModule {
+ get { return this_module; }
+ }
+
+ public bool IsThisModule (string name)
+ {
+ return (this_module != null && name == this_module.Name);
+ }
+
+ public void BeginSourceFile (string name)
+ {
+ if (symwriter != null)
+ symwriter.BeginSourceFile (name);
+ }
+
+ public void EndSourceFile ()
+ {
+ if (symwriter != null)
+ symwriter.EndSourceFile ();
+ }
+
+ public void BeginTypeDef (TypeAttr attr, string name, BaseClassRef parent,
+ ArrayList impl_list, Location location, GenericParameters gen_params)
+ {
+ TypeDef outer = null;
+ string cache_name = CacheName (name);
+ if (typedef_stack_top > 0) {
+ StringBuilder sb = new StringBuilder ();
+
+ for (int i = 0; i < typedef_stack_top; i++){
+ outer = (TypeDef) typedef_stack [i];
+ if (i == 0)
+ /* Use FullName for outermost class to get the
+ namespace also */
+ sb.Append (outer.FullName);
+ else
+ sb.Append (outer.Name);
+ sb.Append ("/");
+ }
+ sb.Append (name);
+ cache_name = sb.ToString ();
+ }
+
+ TypeDef typedef = type_manager[cache_name];
+
+ if (typedef != null) {
+ // Class head is allready defined, we are just reopening the class
+ current_customattrtarget = current_typedef = typedef;
+ current_declsectarget = typedef;
+ typedef_stack.Add (current_typedef);
+ typedef_stack_top++;
+ return;
+ }
+
+ typedef = new TypeDef (attr, current_namespace,
+ name, parent, impl_list, location, gen_params, outer);
+
+ type_manager[cache_name] = typedef;
+ current_customattrtarget = current_typedef = typedef;
+ current_declsectarget = typedef;
+ typedef_stack.Add (typedef);
+ typedef_stack_top++;
+ }
+
+ public void AddFieldMarshalInfo (PEAPI.NativeType native_type)
+ {
+ current_field_native_type = native_type;
+ }
+
+ public void AddFieldDef (FieldDef fielddef)
+ {
+ if (current_field_native_type != null) {
+ fielddef.AddMarshalInfo (current_field_native_type);
+ current_field_native_type = null;
+ }
+
+ if (current_typedef != null) {
+ current_typedef.AddFieldDef (fielddef);
+ } else {
+ global_field_table.Add (
+ new DictionaryEntry (fielddef.Name, fielddef.Type.FullName),
+ fielddef);
+ }
+ }
+
+ public void AddDataDef (DataDef datadef)
+ {
+ data_list.Add (datadef);
+ }
+
+ public void AddManifestResource (ManifestResource mr)
+ {
+ if (manifestResources == null)
+ manifestResources = new ArrayList ();
+ manifestResources.Add (mr);
+ }
+
+ public PEAPI.DataConstant GetDataConst (string name)
+ {
+ foreach (DataDef def in data_list) {
+ if (def.Name == name)
+ return (DataConstant) def.PeapiConstant;
+ }
+ return null;
+
+ }
+
+ public void BeginMethodDef (MethodDef methoddef)
+ {
+ if (current_typedef != null) {
+ current_typedef.AddMethodDef (methoddef);
+ } else {
+ global_method_table.Add (methoddef.Signature,
+ methoddef);
+ }
+
+ current_customattrtarget = current_methoddef = methoddef;
+ current_declsectarget = methoddef;
+ }
+
+ public void EndMethodDef (Location location)
+ {
+ if (symwriter != null)
+ symwriter.EndMethod (location);
+
+ current_methoddef = null;
+ }
+
+ public void EndTypeDef ()
+ {
+ typedef_stack_top--;
+ typedef_stack.RemoveAt (typedef_stack_top);
+
+ if (typedef_stack_top > 0)
+ current_typedef = (TypeDef) typedef_stack [typedef_stack_top-1];
+ else
+ current_typedef = null;
+
+ }
+
+ public void BeginAssemblyRef (string name, AssemblyName asmb_name)
+ {
+ current_customattrtarget = current_assemblyref = ExternTable.AddAssembly (name, asmb_name);
+ current_declsectarget = current_assemblyref;
+ }
+
+ public void EndAssemblyRef ()
+ {
+ current_assemblyref = null;
+ current_customattrtarget = null;
+ current_declsectarget = null;
+ }
+
+ public void AddToDefineContentsList (TypeDef typedef)
+ {
+ defcont_list.Add (typedef);
+ }
+
+ public void SetAssemblyPublicKey (byte [] public_key)
+ {
+ assembly_public_key = public_key;
+ }
+
+ public void SetAssemblyVersion (int major, int minor, int build, int revision)
+ {
+ assembly_major_version = major;
+ assembly_minor_version = minor;
+ assembly_build_version = build;
+ assembly_revision_version = revision;
+ }
+
+ public void SetAssemblyLocale (string locale)
+ {
+ assembly_locale = locale;
+ }
+
+ public void SetAssemblyHashAlgorithm (int algorithm)
+ {
+ assembly_hash_algorithm = algorithm;
+ }
+
+ public void AddAssemblyCustomAttribute (CustomAttr attribute)
+ {
+ if (assembly_custom_attributes == null)
+ assembly_custom_attributes = new ArrayList ();
+ assembly_custom_attributes.Add (attribute);
+ }
+
+ public void AddAssemblyPermission (PEAPI.SecurityAction sec_action, object perm)
+ {
+ if (assembly_declsec == null)
+ assembly_declsec = new DeclSecurity ();
+
+ PermissionSet ps = perm as PermissionSet;
+ if (ps == null)
+ assembly_declsec.AddPermission (sec_action, (IPermission) perm);
+ else
+ assembly_declsec.AddPermissionSet (sec_action, ps);
+ }
+
+ public void AddPermission (PEAPI.SecurityAction sec_action, object perm)
+ {
+ if (CurrentDeclSecurityTarget == null)
+ return;
+
+ PermissionSet ps = perm as PermissionSet;
+ if (ps == null)
+ CurrentDeclSecurityTarget.AddPermission (sec_action, (IPermission) perm);
+ else
+ CurrentDeclSecurityTarget.AddPermissionSet (sec_action, ps);
+ }
+
+ public void Write ()
+ {
+ FileStream out_stream = null;
+
+ try {
+ if (ThisModule == null)
+ this_module = new Module (Path.GetFileName (output_file));
+
+ out_stream = new FileStream (output_file, FileMode.Create, FileAccess.Write);
+ pefile = new PEFile (assembly_name, ThisModule.Name, is_dll, is_assembly, null, out_stream);
+ PEAPI.Assembly asmb = pefile.GetThisAssembly ();
+
+ ThisModule.PeapiModule = pefile.GetThisModule ();
+
+ if (file_ref != null)
+ file_ref.Resolve (this);
+
+ extern_table.Resolve (this);
+ type_manager.DefineAll ();
+
+ if (manifestResources != null) {
+ foreach (ManifestResource mr in manifestResources)
+ pefile.AddManifestResource (mr);
+ }
+
+ foreach (FieldDef fielddef in global_field_table.Values) {
+ fielddef.Define (this);
+ }
+
+ foreach (MethodDef methoddef in global_method_table.Values) {
+ methoddef.Define (this);
+ }
+
+ foreach (TypeDef typedef in defcont_list) {
+ typedef.DefineContents (this);
+ }
+
+ if (assembly_custom_attributes != null) {
+ foreach (CustomAttr cattr in assembly_custom_attributes)
+ cattr.AddTo (this, asmb);
+ }
+
+ ThisModule.Resolve (this, pefile.GetThisModule ());
+
+ if (assembly_declsec != null)
+ assembly_declsec.AddTo (this, asmb);
+
+ if (sub_system != -1)
+ pefile.SetSubSystem ((PEAPI.SubSystem) sub_system);
+ if (cor_flags != -1)
+ pefile.SetCorFlags (cor_flags);
+ if (stack_reserve != -1)
+ pefile.SetStackReserve (stack_reserve);
+
+ asmb.AddAssemblyInfo(assembly_major_version,
+ assembly_minor_version, assembly_build_version,
+ assembly_revision_version, assembly_public_key,
+ (uint) assembly_hash_algorithm, assembly_locale);
+
+ pefile.WritePEFile ();
+
+ if (symwriter != null) {
+ Guid guid = pefile.GetThisModule ().Guid;
+ symwriter.Write (guid);
+ }
+ } finally {
+ if (out_stream != null)
+ out_stream.Close ();
+ }
+ }
+
+ public PEAPI.Method ResolveMethod (string signature)
+ {
+ MethodDef methoddef = (MethodDef) global_method_table[signature];
+ if (methoddef == null)
+ Report.Error ("Unable to resolve global method : " + signature);
+
+ return methoddef.Resolve (this);
+ }
+
+ public PEAPI.Method ResolveVarargMethod (string signature,
+ CodeGen code_gen, PEAPI.Type[] opt)
+ {
+ MethodDef methoddef = (MethodDef) global_method_table[signature];
+ methoddef.Resolve (code_gen);
+
+ return methoddef.GetVarargSig (opt);
+ }
+
+ public PEAPI.Field ResolveField (string name, string type_name)
+ {
+ FieldDef fielddef = (FieldDef) global_field_table[new DictionaryEntry (name, type_name)];
+ if (fielddef == null)
+ Report.Error (String.Format ("Unable to resolve global field : {0} {1}", type_name, name));
+
+ return fielddef.Resolve (this);
+ }
+
+ private string CacheName (string name)
+ {
+ if (current_namespace == null ||
+ current_namespace == String.Empty)
+ return name;
+
+ return current_namespace + "." + name;
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/CustomAttr.cs b/mcs/ilasm/codegen/CustomAttr.cs
new file mode 100644
index 00000000000..964a2ff6b63
--- /dev/null
+++ b/mcs/ilasm/codegen/CustomAttr.cs
@@ -0,0 +1,58 @@
+//
+// Mono.ILASM.CustomAttr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public interface ICustomAttrTarget {
+ void AddCustomAttribute (CustomAttr customattr);
+ }
+
+ public class CustomAttr {
+
+ private BaseMethodRef method_ref;
+ private byte[] data;
+
+ public CustomAttr (BaseMethodRef method_ref, byte[] data)
+ {
+ this.method_ref = method_ref;
+ this.data = data;
+ }
+
+ public void AddTo (CodeGen code_gen, PEAPI.MetaDataElement elem)
+ {
+ method_ref.Resolve (code_gen);
+ code_gen.PEFile.AddCustomAttribute (method_ref.PeapiMethod, data, elem);
+ }
+
+ public bool IsSuppressUnmanaged (CodeGen codegen)
+ {
+ string asmname = "";
+
+ BaseTypeRef owner = method_ref.Owner;
+ if (owner == null)
+ return false;
+
+ ExternTypeRef etr = owner as ExternTypeRef;
+ if (etr != null) {
+ ExternAssembly ea = etr.ExternRef as ExternAssembly;
+ if (ea != null)
+ asmname = ea.Name;
+ }
+
+ return (owner.FullName == "System.Security.SuppressUnmanagedCodeSecurityAttribute"
+ && (asmname == "mscorlib" || codegen.IsThisAssembly ("mscorlib")) );
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/DataDef.cs b/mcs/ilasm/codegen/DataDef.cs
new file mode 100644
index 00000000000..ad83cb476b5
--- /dev/null
+++ b/mcs/ilasm/codegen/DataDef.cs
@@ -0,0 +1,40 @@
+//
+// Mono.ILASM.DataDef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class DataDef {
+
+ private string name;
+ private bool is_tls;
+
+ private PEAPI.Constant constant;
+
+ public DataDef (string name, bool is_tls)
+ {
+ this.name = name;
+ this.is_tls = is_tls;
+ }
+
+ public PEAPI.Constant PeapiConstant {
+ get { return constant; }
+ set { constant = value; }
+ }
+
+ public string Name {
+ get { return name; }
+ set { name = value; }
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/DebuggingInfo.cs b/mcs/ilasm/codegen/DebuggingInfo.cs
new file mode 100644
index 00000000000..23fcac2b771
--- /dev/null
+++ b/mcs/ilasm/codegen/DebuggingInfo.cs
@@ -0,0 +1,117 @@
+//
+// Mono.ILASM.DebuggingInfo.cs
+//
+// Author(s):
+// Martin Baulig (martin@ximian.com)
+//
+// Copyright (C) 2004 Novell, Inc.
+//
+
+using PEAPI;
+using System;
+using System.IO;
+using System.Collections;
+using Mono.CompilerServices.SymbolWriter;
+
+namespace Mono.ILASM {
+
+ public class SymbolWriter : MonoSymbolWriter
+ {
+ ArrayList sources;
+ Mono.ILASM.SourceMethod current_method;
+ SourceFile current_source;
+
+ public SymbolWriter (string filename)
+ : base (filename)
+ {
+ sources = new ArrayList ();
+ }
+
+ public Mono.ILASM.SourceMethod BeginMethod (MethodDef method, Location location)
+ {
+ current_method = new Mono.ILASM.SourceMethod (method, location);
+ current_source.AddMethod (current_method);
+ return current_method;
+ }
+
+ public void EndMethod (Location location)
+ {
+ current_method.EndLine = location.line;
+ current_method = null;
+ }
+
+ public void BeginSourceFile (string filename)
+ {
+ current_source = new SourceFile (file, filename);
+ sources.Add (current_source);
+ }
+
+ public void EndSourceFile ()
+ {
+ current_source = null;
+ }
+
+ public void Write (Guid guid)
+ {
+ foreach (SourceFile source in sources)
+ source.Write ();
+
+ WriteSymbolFile (guid);
+ }
+ }
+
+ public class SourceFile : SourceFileEntry
+ {
+ private ArrayList methods = new ArrayList ();
+
+ public SourceFile (MonoSymbolFile file, string filename)
+ : base (file, filename)
+ { }
+
+ public void AddMethod (SourceMethod method)
+ {
+ methods.Add (method);
+ }
+
+ public void Write ()
+ {
+ foreach (SourceMethod method in methods)
+ method.Write (this);
+ }
+ }
+
+ public class SourceMethod
+ {
+ MethodDef method;
+ ArrayList lines;
+ public int StartLine, EndLine;
+
+ public SourceMethod (MethodDef method, Location start)
+ {
+ this.method = method;
+ this.StartLine = start.line;
+
+ lines = new ArrayList ();
+ MarkLocation (start.line, 0);
+ }
+
+ public void MarkLocation (int line, uint offset)
+ {
+ lines.Add (new LineNumberEntry (line, (int) offset));
+ }
+
+ public void Write (SourceFile file)
+ {
+ PEAPI.MethodDef pemethod = method.PeapiMethodDef;
+
+ LineNumberEntry[] lne = new LineNumberEntry [lines.Count];
+ lines.CopyTo (lne);
+
+ uint token = ((uint) PEAPI.MDTable.Method << 24) | pemethod.Row;
+
+ file.DefineMethod (
+ method.Name, (int) token, null, lne, null,
+ StartLine, EndLine, 0);
+ }
+ }
+}
diff --git a/mcs/ilasm/codegen/DeclSecurity.cs b/mcs/ilasm/codegen/DeclSecurity.cs
new file mode 100644
index 00000000000..274d05e1d15
--- /dev/null
+++ b/mcs/ilasm/codegen/DeclSecurity.cs
@@ -0,0 +1,66 @@
+//
+// Mono.ILASM.DeclSecurity
+//
+// Author(s):
+// Ankit Jain <JAnkit@novell.com>
+//
+// (C) 2005 Ankit Jain, All rights reserved
+//
+
+
+using System;
+using System.Collections;
+using System.Security;
+using System.Security.Permissions;
+
+namespace Mono.ILASM {
+
+ public interface IDeclSecurityTarget {
+ void AddPermission (PEAPI.SecurityAction sec_action, IPermission iper);
+ void AddPermissionSet (PEAPI.SecurityAction sec_action, PermissionSet perm_set);
+ }
+
+ public class DeclSecurity {
+
+ private Hashtable permissionset_table;
+
+ public DeclSecurity ()
+ {
+ permissionset_table = new Hashtable ();
+ }
+
+ public void AddPermission (PEAPI.SecurityAction sec_action, IPermission perm)
+ {
+ PermissionSet ps = (PermissionSet) permissionset_table [sec_action];
+ if (ps == null) {
+ ps = new PermissionSet (PermissionState.None);
+ permissionset_table [sec_action] = ps;
+ }
+
+ ps.AddPermission (perm);
+ }
+
+ public void AddPermissionSet (PEAPI.SecurityAction sec_action, PermissionSet perm_set)
+ {
+ PermissionSet ps = (PermissionSet) permissionset_table [sec_action];
+ if (ps == null) {
+ permissionset_table [sec_action] = perm_set;
+ return;
+ }
+
+ foreach (IPermission iper in perm_set)
+ ps.AddPermission (iper);
+ }
+
+ public void AddTo (CodeGen code_gen, PEAPI.MetaDataElement elem)
+ {
+ System.Text.UnicodeEncoding ue = new System.Text.UnicodeEncoding ();
+ foreach (PEAPI.SecurityAction sec_action in permissionset_table.Keys)
+ code_gen.PEFile.AddDeclSecurity (sec_action,
+ ue.GetBytes (((PermissionSet) permissionset_table [sec_action]).ToXml ().ToString ()),
+ elem);
+ }
+
+ }
+
+}
diff --git a/mcs/ilasm/codegen/EventDef.cs b/mcs/ilasm/codegen/EventDef.cs
new file mode 100644
index 00000000000..28f8dc4c4a2
--- /dev/null
+++ b/mcs/ilasm/codegen/EventDef.cs
@@ -0,0 +1,126 @@
+//
+// Mono.ILASM.EventDef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All right reserved
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class EventDef : ICustomAttrTarget {
+
+ private FeatureAttr attr;
+ private string name;
+ private BaseTypeRef type;
+ private PEAPI.Event event_def;
+ private bool is_resolved;
+ private ArrayList customattr_list;
+
+ private MethodRef addon;
+ private MethodRef fire;
+ private MethodRef other;
+ private MethodRef removeon;
+
+ public EventDef (FeatureAttr attr, BaseTypeRef type, string name)
+ {
+ this.attr = attr;
+ this.name = name;
+ this.type = type;
+ is_resolved = false;
+ }
+
+ public void AddCustomAttribute (CustomAttr customattr)
+ {
+ if (customattr_list == null)
+ customattr_list = new ArrayList ();
+
+ customattr_list.Add (customattr);
+ }
+
+ public PEAPI.Event Resolve (CodeGen code_gen, PEAPI.ClassDef classdef)
+ {
+ if (is_resolved)
+ return event_def;
+
+ type.Resolve (code_gen);
+ event_def = classdef.AddEvent (name, type.PeapiType);
+
+ if ((attr & FeatureAttr.Rtspecialname) != 0)
+ event_def.SetRTSpecialName ();
+
+ if ((attr & FeatureAttr.Specialname) != 0)
+ event_def.SetSpecialName ();
+
+ if (customattr_list != null)
+ foreach (CustomAttr customattr in customattr_list)
+ customattr.AddTo (code_gen, event_def);
+
+ is_resolved = true;
+
+ return event_def;
+ }
+
+ private PEAPI.MethodDef AsMethodDef (PEAPI.Method method, string type)
+ {
+ PEAPI.MethodDef methoddef = method as PEAPI.MethodDef;
+ if (methoddef == null)
+ Report.Error (type + " method of event " + name + " not found");
+ return methoddef;
+ }
+
+ public void Define (CodeGen code_gen, PEAPI.ClassDef classdef)
+ {
+ if (!is_resolved)
+ Resolve (code_gen, classdef);
+
+ if (addon != null) {
+ addon.Resolve (code_gen);
+ event_def.AddAddon (AsMethodDef (addon.PeapiMethod, "addon"));
+ }
+
+ if (fire != null) {
+ fire.Resolve (code_gen);
+ event_def.AddFire (AsMethodDef (fire.PeapiMethod, "fire"));
+ }
+
+ if (other != null) {
+ other.Resolve (code_gen);
+ event_def.AddOther (AsMethodDef (other.PeapiMethod, "other"));
+ }
+
+ if (removeon != null) {
+ removeon.Resolve (code_gen);
+ event_def.AddRemoveOn (AsMethodDef (removeon.PeapiMethod, "removeon"));
+ }
+ }
+
+ public void AddAddon (MethodRef method_ref)
+ {
+ addon = method_ref;
+ }
+
+ public void AddFire (MethodRef method_ref)
+ {
+ fire = method_ref;
+ }
+
+ public void AddOther (MethodRef method_ref)
+ {
+ other = method_ref;
+ }
+
+ public void AddRemoveon (MethodRef method_ref)
+ {
+ removeon = method_ref;
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/ExternFieldRef.cs b/mcs/ilasm/codegen/ExternFieldRef.cs
new file mode 100644
index 00000000000..3a20ad5872f
--- /dev/null
+++ b/mcs/ilasm/codegen/ExternFieldRef.cs
@@ -0,0 +1,60 @@
+//
+// Mono.ILASM.ExternFieldRef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class ExternFieldRef : IFieldRef {
+
+ private ExternTypeRef owner;
+ private BaseTypeRef type;
+ private string name;
+
+ private bool is_resolved;
+ private PEAPI.FieldRef peapi_field;
+
+ public ExternFieldRef (ExternTypeRef owner, BaseTypeRef type, string name)
+ {
+ this.owner = owner;
+ this.type = type;
+ this.name = name;
+
+ is_resolved = false;
+ }
+
+ public PEAPI.Field PeapiField {
+ get { return peapi_field; }
+ }
+
+ public void Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ owner.Resolve (code_gen);
+
+ if (owner.UseTypeSpec) {
+ PEAPI.Type owner_ref = owner.PeapiType;
+ code_gen.PEFile.AddFieldToTypeSpec (owner_ref, name,
+ type.PeapiType);
+ } else {
+ PEAPI.ClassRef owner_ref;
+ owner_ref = (PEAPI.ClassRef) owner.PeapiType;
+ type.Resolve (code_gen);
+ peapi_field = owner_ref.AddField (name, type.PeapiType);
+ }
+
+ is_resolved = true;
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/ExternMethodRef.cs b/mcs/ilasm/codegen/ExternMethodRef.cs
new file mode 100644
index 00000000000..93298776908
--- /dev/null
+++ b/mcs/ilasm/codegen/ExternMethodRef.cs
@@ -0,0 +1,125 @@
+//
+// Mono.ILASM.ExternMethodRef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class ExternMethodRef : BaseMethodRef {
+
+ public ExternMethodRef (ExternTypeRef owner, BaseTypeRef ret_type,
+ PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count)
+ : base (owner, call_conv, ret_type, name, param, gen_param_count)
+ {
+ }
+
+ public override void Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ if ((call_conv & PEAPI.CallConv.Vararg) != 0) {
+ ResolveVararg (code_gen);
+ return;
+ }
+
+ PEAPI.Type[] param_list = new PEAPI.Type[param.Length];
+ string write_name;
+
+ ret_type.Resolve (code_gen);
+
+ int count = 0;
+ foreach (BaseTypeRef typeref in param) {
+ typeref.Resolve (code_gen);
+ param_list[count++] = typeref.PeapiType;
+ }
+
+ if (name == "<init>")
+ write_name = ".ctor";
+ else
+ write_name = name;
+
+ owner.Resolve (code_gen);
+
+ if (owner.UseTypeSpec) {
+ PEAPI.Type owner_ref = owner.PeapiType;
+ peapi_method = code_gen.PEFile.AddMethodToTypeSpec (owner_ref, write_name,
+ ret_type.PeapiType, param_list, gen_param_count);
+ } else {
+ PEAPI.ClassRef owner_ref;
+ owner_ref = (PEAPI.ClassRef) owner.PeapiType;
+ peapi_method = owner_ref.AddMethod (write_name,
+ ret_type.PeapiType, param_list, gen_param_count);
+ }
+
+ peapi_method.AddCallConv (call_conv);
+
+ is_resolved = true;
+ }
+
+ protected void ResolveVararg (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ ArrayList param_list = new ArrayList ();
+ ArrayList opt_list = new ArrayList ();
+ bool in_opt = false;
+ string write_name;
+
+ ret_type.Resolve (code_gen);
+
+ foreach (BaseTypeRef typeref in param) {
+ if (in_opt) {
+ typeref.Resolve (code_gen);
+ opt_list.Add (typeref.PeapiType);
+ } else if (TypeRef.Ellipsis == typeref) {
+ in_opt = true;
+ } else {
+ typeref.Resolve (code_gen);
+ param_list.Add (typeref.PeapiType);
+ }
+ }
+
+ if (name == "<init>")
+ write_name = ".ctor";
+ else
+ write_name = name;
+
+ if (owner.IsArray)
+ Report.Error ("Vararg methods on arrays are not supported yet.");
+
+ owner.Resolve (code_gen);
+
+ if (owner.UseTypeSpec) {
+ PEAPI.Type owner_ref = owner.PeapiType;
+ peapi_method = code_gen.PEFile.AddVarArgMethodToTypeSpec (owner_ref,
+ write_name, ret_type.PeapiType,
+ (PEAPI.Type[]) param_list.ToArray (typeof (PEAPI.Type)),
+ (PEAPI.Type[]) opt_list.ToArray (typeof (PEAPI.Type)));
+ } else {
+ PEAPI.ClassRef owner_ref;
+ owner_ref = (PEAPI.ClassRef) owner.PeapiType;
+ peapi_method = owner_ref.AddVarArgMethod (write_name,
+ ret_type.PeapiType,
+ (PEAPI.Type[]) param_list.ToArray (typeof (PEAPI.Type)),
+ (PEAPI.Type[]) opt_list.ToArray (typeof (PEAPI.Type)));
+ }
+
+
+ peapi_method.AddCallConv (call_conv);
+
+ is_resolved = true;
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/ExternTable.cs b/mcs/ilasm/codegen/ExternTable.cs
new file mode 100644
index 00000000000..659f0b462a5
--- /dev/null
+++ b/mcs/ilasm/codegen/ExternTable.cs
@@ -0,0 +1,368 @@
+//
+// Mono.ILASM.ExternTable.cs
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+using System;
+using System.Collections;
+using System.Reflection;
+using System.Security;
+
+namespace Mono.ILASM {
+
+ public interface IScope {
+ ExternTypeRef GetTypeRef (string full_name, bool is_valuetype);
+ PEAPI.ClassRef GetType (string full_name, bool is_valuetype);
+ string FullName { get; }
+ }
+
+ public abstract class ExternRef : ICustomAttrTarget, IScope {
+
+ protected string name;
+ protected Hashtable class_table;
+ protected Hashtable typeref_table;
+ protected ArrayList customattr_list;
+ protected bool is_resolved;
+
+ public abstract void Resolve (CodeGen codegen);
+ public abstract PEAPI.IExternRef GetExternRef ();
+
+ public ExternRef (string name)
+ {
+ this.name = name;
+ typeref_table = new Hashtable ();
+ class_table = new Hashtable ();
+ }
+
+ public string Name {
+ get { return name; }
+ }
+
+ public virtual string FullName {
+ get { return name; }
+ }
+
+ public void AddCustomAttribute (CustomAttr customattr)
+ {
+ if (customattr_list == null)
+ customattr_list = new ArrayList ();
+
+ customattr_list.Add (customattr);
+ }
+
+ public ExternTypeRef GetTypeRef (string full_name, bool is_valuetype)
+ {
+ string first= full_name;
+ string rest = "";
+ int slash = full_name.IndexOf ('/');
+ if (slash > 0) {
+ first = full_name.Substring (0, slash);
+ rest = full_name.Substring (slash + 1);
+ }
+
+ ExternTypeRef type_ref = typeref_table [first] as ExternTypeRef;
+
+ if (type_ref != null) {
+ if (is_valuetype && rest == "")
+ type_ref.MakeValueClass ();
+ } else {
+ type_ref = new ExternTypeRef (this, first, is_valuetype);
+ typeref_table [first] = type_ref;
+ }
+
+ return (rest == "" ? type_ref : type_ref.GetTypeRef (rest, is_valuetype));
+ }
+
+ public PEAPI.ClassRef GetType (string full_name, bool is_valuetype)
+ {
+ PEAPI.ClassRef klass = class_table[full_name] as PEAPI.ClassRef;
+
+ if (klass != null)
+ return klass;
+
+ string name_space, name;
+ ExternTable.GetNameAndNamespace (full_name, out name_space, out name);
+
+ if (is_valuetype)
+ klass = (PEAPI.ClassRef) GetExternRef ().AddValueClass (name_space, name);
+ else
+ klass = (PEAPI.ClassRef) GetExternRef ().AddClass (name_space, name);
+
+ class_table [full_name] = klass;
+ return klass;
+ }
+
+ }
+
+ public class ExternModule : ExternRef {
+
+ public PEAPI.ModuleRef ModuleRef;
+
+ public ExternModule (string name) : base (name)
+ {
+ }
+
+ public override string FullName {
+ get {
+ //'name' field should not contain the [.module ]
+ //as its used for resolving
+ return String.Format ("[.module {0}]", name);
+ }
+ }
+
+ public override void Resolve (CodeGen codegen)
+ {
+ if (is_resolved)
+ return;
+
+ ModuleRef = codegen.PEFile.AddExternModule (name);
+ if (customattr_list != null)
+ foreach (CustomAttr customattr in customattr_list)
+ customattr.AddTo (codegen, ModuleRef);
+
+ is_resolved = true;
+ }
+
+
+ public override PEAPI.IExternRef GetExternRef ()
+ {
+ return ModuleRef;
+ }
+ }
+
+ public class ExternAssembly : ExternRef, IDeclSecurityTarget {
+
+ public PEAPI.AssemblyRef AssemblyRef;
+
+ private int major, minor, build, revision;
+ private byte [] public_key;
+ private byte [] public_key_token;
+ private string locale;
+ private byte [] hash;
+ private DeclSecurity decl_sec;
+
+ public ExternAssembly (string name, AssemblyName asmb_name) : base (name)
+ {
+ this.name = name;
+ major = minor = build = revision = -1;
+ }
+
+ public override string FullName {
+ get {
+ //'name' field should not contain the []
+ //as its used for resolving
+ return String.Format ("[{0}]", name);
+ }
+ }
+
+ public override void Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ AssemblyRef = code_gen.PEFile.AddExternAssembly (name);
+ if (major != -1)
+ AssemblyRef.AddVersionInfo (major, minor, build, revision);
+ if (public_key != null)
+ AssemblyRef.AddKey (public_key);
+ if (public_key_token != null)
+ AssemblyRef.AddKeyToken (public_key_token);
+ if (locale != null)
+ AssemblyRef.AddCulture (locale);
+ if (hash != null)
+ AssemblyRef.AddHash (hash);
+
+ if (customattr_list != null)
+ foreach (CustomAttr customattr in customattr_list)
+ customattr.AddTo (code_gen, AssemblyRef);
+
+ if (decl_sec != null)
+ decl_sec.AddTo (code_gen, AssemblyRef);
+
+ class_table = new Hashtable ();
+
+ is_resolved = true;
+ }
+
+ public override PEAPI.IExternRef GetExternRef ()
+ {
+ return AssemblyRef;
+ }
+
+ public void AddPermissionSet (PEAPI.SecurityAction sec_action, PermissionSet ps)
+ {
+ if (decl_sec == null)
+ decl_sec = new DeclSecurity ();
+
+ decl_sec.AddPermissionSet (sec_action, ps);
+ }
+
+ public void AddPermission (PEAPI.SecurityAction sec_action, IPermission iper)
+ {
+ if (decl_sec == null)
+ decl_sec = new DeclSecurity ();
+
+ decl_sec.AddPermission (sec_action, iper);
+ }
+
+ public void SetVersion (int major, int minor, int build, int revision)
+ {
+ this.major = major;
+ this.minor = minor;
+ this.build = build;
+ this.revision = revision;
+ }
+
+ public void SetPublicKey (byte [] public_key)
+ {
+ this.public_key = public_key;
+ }
+
+ public void SetPublicKeyToken (byte [] public_key_token)
+ {
+ this.public_key_token = public_key_token;
+ }
+
+ public void SetLocale (string locale)
+ {
+ this.locale = locale;
+ }
+
+ public void SetHash (byte [] hash)
+ {
+ this.hash = hash;
+ }
+
+ }
+
+
+ public class ExternTable {
+
+ Hashtable assembly_table;
+ Hashtable module_table;
+ bool is_resolved;
+
+ public void AddCorlib ()
+ {
+ // Add mscorlib
+ string mscorlib_name = "mscorlib";
+ AssemblyName mscorlib = new AssemblyName ();
+ mscorlib.Name = mscorlib_name;
+ AddAssembly (mscorlib_name, mscorlib);
+
+ // Also need to alias corlib, normally corlib and
+ // mscorlib are used interchangably
+ assembly_table["corlib"] = assembly_table["mscorlib"];
+ }
+
+ public ExternAssembly AddAssembly (string name, AssemblyName asmb_name)
+ {
+ ExternAssembly ea = null;
+
+ if (assembly_table == null) {
+ assembly_table = new Hashtable ();
+ } else {
+ ea = assembly_table [name] as ExternAssembly;
+ if (ea != null)
+ return ea;
+ }
+
+ ea = new ExternAssembly (name, asmb_name);
+
+ assembly_table [name] = ea;
+
+ return ea;
+ }
+
+ public ExternModule AddModule (string name)
+ {
+ ExternModule em = null;
+
+ if (module_table == null) {
+ module_table = new Hashtable ();
+ } else {
+ em = module_table [name] as ExternModule;
+ if (em != null)
+ return em;
+ }
+
+ em = new ExternModule (name);
+
+ module_table [name] = em;
+
+ return em;
+ }
+
+ public void Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ if (assembly_table != null)
+ foreach (ExternAssembly ext in assembly_table.Values)
+ ext.Resolve (code_gen);
+ if (module_table == null)
+ return;
+ foreach (ExternModule ext in module_table.Values)
+ ext.Resolve (code_gen);
+
+ is_resolved = true;
+ }
+
+ public ExternTypeRef GetTypeRef (string asmb_name, string full_name, bool is_valuetype)
+ {
+ ExternAssembly ext_asmb = null;
+ if (assembly_table == null && (asmb_name == "mscorlib" || asmb_name == "corlib")) {
+ /* AddCorlib if mscorlib is being referenced but
+ we haven't encountered a ".assembly 'name'" as yet. */
+ Console.Error.WriteLine ("Warning -- Reference to undeclared extern assembly '{0}', adding.", asmb_name);
+ AddCorlib ();
+ }
+ if (assembly_table != null)
+ ext_asmb = assembly_table[asmb_name] as ExternAssembly;
+
+ if (ext_asmb == null) {
+ System.Reflection.AssemblyName asmname = new System.Reflection.AssemblyName ();
+ asmname.Name = asmb_name;
+
+ Console.Error.WriteLine ("Warning -- Reference to undeclared extern assembly '{0}', adding.", asmb_name);
+ ext_asmb = AddAssembly (asmb_name, asmname);
+ }
+
+ return ext_asmb.GetTypeRef (full_name, is_valuetype);
+ }
+
+ public ExternTypeRef GetModuleTypeRef (string mod_name, string full_name, bool is_valuetype)
+ {
+ ExternModule mod = null;
+ if (module_table != null)
+ mod = module_table [mod_name] as ExternModule;
+
+ if (mod == null)
+ Report.Error ("Module " + mod_name + " not defined.");
+
+ return mod.GetTypeRef (full_name, is_valuetype);
+ }
+
+ public static void GetNameAndNamespace (string full_name,
+ out string name_space, out string name) {
+
+ int last_dot = full_name.LastIndexOf ('.');
+
+ if (last_dot < 0) {
+ name_space = String.Empty;
+ name = full_name;
+ return;
+ }
+
+ name_space = full_name.Substring (0, last_dot);
+ name = full_name.Substring (last_dot + 1);
+ }
+
+ }
+}
+
diff --git a/mcs/ilasm/codegen/ExternTypeRef.cs b/mcs/ilasm/codegen/ExternTypeRef.cs
new file mode 100644
index 00000000000..1480a024115
--- /dev/null
+++ b/mcs/ilasm/codegen/ExternTypeRef.cs
@@ -0,0 +1,160 @@
+//
+// Mono.ILASM.ExternTypeRef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ /// <summary>
+ /// A reference to a type in another assembly
+ /// </summary>
+ public class ExternTypeRef : BaseClassRef , IScope {
+
+ private IScope extern_ref;
+ private Hashtable nestedtypes_table;
+ private Hashtable nestedclass_table;
+
+ public ExternTypeRef (IScope extern_ref, string full_name, bool is_valuetype)
+ : this (extern_ref, full_name, is_valuetype, null, null)
+ {
+ }
+
+ private ExternTypeRef (IScope extern_ref, string full_name,
+ bool is_valuetype, ArrayList conv_list, string sig_mod)
+ : base (full_name, is_valuetype, conv_list, sig_mod)
+ {
+ this.extern_ref = extern_ref;
+
+ nestedclass_table = new Hashtable ();
+ nestedtypes_table = new Hashtable ();
+ }
+
+ public override BaseClassRef Clone ()
+ {
+ return new ExternTypeRef (extern_ref, full_name, is_valuetype,
+ (ArrayList) ConversionList.Clone (), sig_mod);
+ }
+
+ public override string FullName {
+ get {
+ if (extern_ref == null)
+ return full_name + sig_mod;
+ else
+ return extern_ref.FullName + (extern_ref is ExternTypeRef ? "/" : "") + full_name + sig_mod;
+ }
+ }
+
+ public string Name {
+ get { return full_name + sig_mod; }
+ }
+
+ public IScope ExternRef {
+ get { return extern_ref; }
+ }
+
+ public override void Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ ExternTypeRef etr = extern_ref as ExternTypeRef;
+ if (etr != null)
+ //This is a nested class, so resolve parent
+ etr.Resolve (code_gen);
+
+ type = extern_ref.GetType (full_name, is_valuetype);
+ type = Modify (code_gen, type);
+
+ is_resolved = true;
+ }
+
+ protected override BaseMethodRef CreateMethodRef (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
+ string name, BaseTypeRef[] param, int gen_param_count)
+ {
+ return new ExternMethodRef (this, ret_type, call_conv, name, param, gen_param_count);
+ }
+
+ protected override IFieldRef CreateFieldRef (BaseTypeRef ret_type, string name)
+ {
+ return new ExternFieldRef (this, ret_type, name);
+ }
+
+ public ExternTypeRef GetTypeRef (string _name, bool is_valuetype)
+ {
+ string first= _name;
+ string rest = "";
+ int slash = _name.IndexOf ('/');
+
+ if (slash > 0) {
+ first = _name.Substring (0, slash);
+ rest = _name.Substring (slash + 1);
+ }
+
+ ExternTypeRef ext_typeref = nestedtypes_table [first] as ExternTypeRef;
+
+ if (ext_typeref != null) {
+ if (is_valuetype && rest == "")
+ ext_typeref.MakeValueClass ();
+ } else {
+ ext_typeref = new ExternTypeRef (this, first, is_valuetype);
+ nestedtypes_table [first] = ext_typeref;
+ }
+
+ return (rest == "" ? ext_typeref : ext_typeref.GetTypeRef (rest, is_valuetype));
+ }
+
+ public PEAPI.IExternRef GetExternTypeRef ()
+ {
+ //called by GetType for a nested type
+ //should this cant be 'modified' type, so it should
+ //be ClassRef
+ return (PEAPI.ClassRef) type;
+ }
+
+ public PEAPI.ClassRef GetType (string _name, bool is_valuetype)
+ {
+ PEAPI.ClassRef klass = nestedclass_table [_name] as PEAPI.ClassRef;
+
+ if (klass != null)
+ return klass;
+
+ string name_space, name;
+ ExternTable.GetNameAndNamespace (_name, out name_space, out name);
+
+ if (is_valuetype)
+ klass = (PEAPI.ClassRef) GetExternTypeRef ().AddValueClass (name_space, name);
+ else
+ klass = (PEAPI.ClassRef) GetExternTypeRef ().AddClass (name_space, name);
+
+ nestedclass_table [_name] = klass;
+
+ return klass;
+ }
+
+ public System.Type GetReflectedType ()
+ {
+ ExternRef er = extern_ref as ExternRef;
+ if (er != null) {
+ ExternAssembly ea = er as ExternAssembly;
+ if (ea != null) {
+ System.Reflection.Assembly asm = System.Reflection.Assembly.Load (ea.Name);
+
+ //Type name required here, so don't use FullName
+ return asm.GetType (Name);
+ }/* else ExternModule */
+
+ } /*else - nested type? */
+ return null;
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/ExternTypeRefInst.cs b/mcs/ilasm/codegen/ExternTypeRefInst.cs
new file mode 100644
index 00000000000..6d0111775b1
--- /dev/null
+++ b/mcs/ilasm/codegen/ExternTypeRefInst.cs
@@ -0,0 +1,139 @@
+//
+// Mono.ILASM.ExternTypeRefInst
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2004 Novell, Inc (http://www.novell.com)
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class ExternTypeRefInst : BaseTypeRef {
+
+ private ExternTypeRef type_ref;
+ private PEAPI.Type type;
+ private bool is_valuetypeinst;
+ private bool is_resolved;
+ private GenericArguments gen_args;
+ private static Hashtable method_table = new Hashtable ();
+
+ public ExternTypeRefInst (ExternTypeRef type_ref, GenericArguments gen_args, bool is_valuetypeinst)
+ {
+ this.type_ref = type_ref;
+ this.gen_args = gen_args;
+ this.is_valuetypeinst = is_valuetypeinst;
+
+ is_resolved = false;
+ }
+
+ public PEAPI.Type PeapiType {
+ get { return type; }
+ }
+
+ public string FullName {
+ get { return type_ref.FullName; }
+ }
+
+
+ public string SigMod {
+ get { return type_ref.SigMod; }
+ set { type_ref.SigMod = value; }
+ }
+
+
+ public bool IsPinned {
+ get { return type_ref.IsPinned; }
+ }
+
+ public bool IsRef {
+ get { return type_ref.IsRef; }
+ }
+
+ public bool IsArray {
+ get { return type_ref.IsArray; }
+ }
+
+ public bool UseTypeSpec {
+ get { return type_ref.UseTypeSpec; }
+ }
+
+ public ExternTypeRefInst Clone ()
+ {
+ return new ExternTypeRefInst (type_ref.Clone (), gen_args, is_valuetypeinst);
+ }
+
+ public void MakeArray ()
+ {
+ is_valuetypeinst = false;
+ type_ref.MakeArray ();
+ }
+
+ public void MakeBoundArray (ArrayList bounds)
+ {
+ is_valuetypeinst = false;
+ type_ref.MakeBoundArray (bounds);
+ }
+
+ public void MakeManagedPointer ()
+ {
+ type_ref.MakeManagedPointer ();
+ }
+
+ public void MakeUnmanagedPointer ()
+ {
+ type_ref.MakeUnmanagedPointer ();
+ }
+
+ public void MakeCustomModified (CodeGen code_gen,
+ PEAPI.CustomModifier modifier, BaseClassRef klass)
+ {
+ type_ref.MakeCustomModified (code_gen, modifier, klass);
+ }
+
+ public void MakePinned ()
+ {
+ type_ref.MakePinned ();
+ }
+
+ public void MakeValueClass ()
+ {
+ type_ref.MakeValueClass ();
+ }
+
+ public void Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ type_ref.Resolve (code_gen);
+
+ type = new PEAPI.GenericTypeInst (type_ref.PeapiType, gen_args.Resolve (code_gen));
+
+ is_resolved = true;
+ }
+
+ public BaseMethodRef GetMethodRef (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
+ string name, BaseTypeRef[] param, int gen_param_count)
+ {
+ string key = type_ref.FullName + MethodDef.CreateSignature (ret_type, name, param, gen_param_count) + type_ref.SigMod;
+ TypeSpecMethodRef mr = method_table [key] as TypeSpecMethodRef;
+ if (mr == null) {
+ mr = new TypeSpecMethodRef (this, ret_type, call_conv, name, param, gen_param_count);
+ method_table [key] = mr;
+ }
+
+ return mr;
+ }
+
+ public IFieldRef GetFieldRef (BaseTypeRef ret_type, string name)
+ {
+ return new TypeSpecFieldRef (this, ret_type, name);
+ }
+ }
+}
+
diff --git a/mcs/ilasm/codegen/FaultBlock.cs b/mcs/ilasm/codegen/FaultBlock.cs
new file mode 100644
index 00000000000..34609712dcb
--- /dev/null
+++ b/mcs/ilasm/codegen/FaultBlock.cs
@@ -0,0 +1,41 @@
+//
+// Mono.ILASM.FaultBlock
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class FaultBlock : ISehClause {
+
+ private HandlerBlock handler_block;
+
+ public FaultBlock ()
+ {
+
+ }
+
+ public void SetHandlerBlock (HandlerBlock hb)
+ {
+ handler_block = hb;
+ }
+
+ public PEAPI.HandlerBlock Resolve (CodeGen code_gen, MethodDef method)
+ {
+ PEAPI.CILLabel from = handler_block.GetFromLabel (code_gen, method);
+ PEAPI.CILLabel to = handler_block.GetToLabel (code_gen, method);
+ PEAPI.Fault fault = new PEAPI.Fault (from, to);
+
+ return fault;
+ }
+ }
+
+}
+
+
diff --git a/mcs/ilasm/codegen/FeatureAttr.cs b/mcs/ilasm/codegen/FeatureAttr.cs
new file mode 100644
index 00000000000..f3eecb0d067
--- /dev/null
+++ b/mcs/ilasm/codegen/FeatureAttr.cs
@@ -0,0 +1,24 @@
+//
+// Mono.ILASM.FeatureAttr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ [Flags]
+ public enum FeatureAttr {
+ None = 0x0,
+ Instance = 0x1,
+ Rtspecialname = 0x2,
+ Specialname = 0x4
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/FieldDef.cs b/mcs/ilasm/codegen/FieldDef.cs
new file mode 100644
index 00000000000..19c23b9bfef
--- /dev/null
+++ b/mcs/ilasm/codegen/FieldDef.cs
@@ -0,0 +1,173 @@
+//
+// Mono.ILASM.FieldDef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class FieldDef : ICustomAttrTarget {
+
+ private string name;
+ private BaseTypeRef type;
+ private PEAPI.FieldAttr attr;
+ private PEAPI.FieldDef field_def;
+ private ArrayList customattr_list;
+ private PEAPI.NativeType native_type;
+
+ private bool offset_set;
+ private bool datavalue_set;
+ private bool value_set;
+
+ private bool is_resolved;
+
+ private uint offset;
+ private PEAPI.Constant constant;
+ private string at_data_id;
+
+ public FieldDef (PEAPI.FieldAttr attr, string name,
+ BaseTypeRef type)
+ {
+ this.attr = attr;
+ this.name = name;
+ this.type = type;
+
+ offset_set = false;
+ datavalue_set = false;
+ value_set = false;
+
+ at_data_id = null;
+
+ is_resolved = false;
+ }
+
+ public string Name {
+ get { return name; }
+ }
+
+ public PEAPI.FieldDef PeapiFieldDef {
+ get { return field_def; }
+ }
+
+ public bool IsStatic {
+ get { return (attr & PEAPI.FieldAttr.Static) != 0; }
+ }
+
+ public PEAPI.FieldAttr Attributes {
+ get { return attr; }
+ set { attr = value; }
+ }
+
+ public BaseTypeRef Type {
+ get { return type; }
+ }
+
+ public void SetOffset (uint val)
+ {
+ offset_set = true;
+ offset = val;
+ }
+
+ public void SetValue (PEAPI.Constant constant)
+ {
+ value_set = true;
+ this.constant = constant;
+ }
+
+ public void AddDataValue (string at_data_id)
+ {
+ this.at_data_id = at_data_id;
+ }
+
+ public void AddCustomAttribute (CustomAttr customattr)
+ {
+ if (customattr_list == null)
+ customattr_list = new ArrayList ();
+
+ customattr_list.Add (customattr);
+ }
+
+ public void AddMarshalInfo (PEAPI.NativeType native_type)
+ {
+ this.native_type = native_type;
+ }
+
+ public PEAPI.FieldDef Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return field_def;
+
+ type.Resolve (code_gen);
+ field_def = code_gen.PEFile.AddField (attr, name, type.PeapiType);
+
+ is_resolved = true;
+
+ return field_def;
+ }
+
+ public PEAPI.FieldDef Resolve (CodeGen code_gen, PEAPI.ClassDef classdef)
+ {
+ if (is_resolved)
+ return field_def;
+
+ type.Resolve (code_gen);
+ field_def = classdef.AddField (attr, name, type.PeapiType);
+
+ if (customattr_list != null)
+ foreach (CustomAttr customattr in customattr_list)
+ customattr.AddTo (code_gen, field_def);
+
+ if (native_type != null)
+ field_def.SetMarshalInfo (native_type);
+
+ is_resolved = true;
+
+ return field_def;
+ }
+
+ /// <summary>
+ /// Define a global field
+ /// </summary>
+ public void Define (CodeGen code_gen)
+ {
+ Resolve (code_gen);
+ WriteCode (code_gen, field_def);
+ }
+
+ /// <summary>
+ /// Define a field member of the specified class
+ /// </summary>
+ public void Define (CodeGen code_gen, PEAPI.ClassDef class_def)
+ {
+ Resolve (code_gen, class_def);
+ WriteCode (code_gen, field_def);
+ }
+
+ protected void WriteCode (CodeGen code_gen, PEAPI.FieldDef field_def)
+ {
+ if (offset_set)
+ field_def.SetOffset (offset);
+
+ if (value_set) {
+ PEAPI.ByteArrConst dc = constant as PEAPI.ByteArrConst;
+ if (dc != null)
+ dc.Type = type.PeapiType;
+ field_def.AddValue (constant);
+ }
+
+ if (at_data_id != null) {
+ PEAPI.DataConstant dc = code_gen.GetDataConst (at_data_id);
+ field_def.AddDataValue (dc);
+ }
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/FieldInstr.cs b/mcs/ilasm/codegen/FieldInstr.cs
new file mode 100644
index 00000000000..02bb5b69872
--- /dev/null
+++ b/mcs/ilasm/codegen/FieldInstr.cs
@@ -0,0 +1,40 @@
+//
+// Mono.ILASM.FieldInstr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+
+namespace Mono.ILASM {
+
+ public class FieldInstr : IInstr {
+
+ private PEAPI.FieldOp op;
+ private IFieldRef operand;
+
+ public FieldInstr (PEAPI.FieldOp op, IFieldRef operand, Location loc)
+ : base (loc)
+ {
+ this.op = op;
+ this.operand = operand;
+ }
+
+ public override void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
+ {
+ operand.Resolve (code_gen);
+ cil.FieldInst (op, operand.PeapiField);
+ }
+
+ }
+
+}
+
+
+
diff --git a/mcs/ilasm/codegen/FieldRef.cs b/mcs/ilasm/codegen/FieldRef.cs
new file mode 100644
index 00000000000..4b3acb557f5
--- /dev/null
+++ b/mcs/ilasm/codegen/FieldRef.cs
@@ -0,0 +1,50 @@
+//
+// Mono.ILASM.FieldRef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+
+ public class FieldRef : IFieldRef {
+
+ private TypeRef owner;
+ private BaseTypeRef ret_type;
+ private string name;
+
+ private bool is_resolved;
+ private PEAPI.Field peapi_field;
+
+ public FieldRef (TypeRef owner, BaseTypeRef ret_type, string name)
+ {
+ this.owner = owner;
+ this.ret_type = ret_type;
+ this.name = name;
+
+ is_resolved = false;
+ }
+
+ public PEAPI.Field PeapiField {
+ get { return peapi_field; }
+ }
+
+ public void Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ TypeDef owner_def = code_gen.TypeManager[owner.FullName];
+ peapi_field = owner_def.ResolveField (name, ret_type, code_gen);
+
+ is_resolved = true;
+ }
+ }
+}
+
diff --git a/mcs/ilasm/codegen/FieldTable.cs b/mcs/ilasm/codegen/FieldTable.cs
new file mode 100644
index 00000000000..0a5aa46d52e
--- /dev/null
+++ b/mcs/ilasm/codegen/FieldTable.cs
@@ -0,0 +1,130 @@
+//
+// Mono.ILASM.FieldTable.cs
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+using PEAPI;
+using System;
+using System.Text;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class FieldTable {
+
+ private class FieldTableItem {
+
+ private static readonly int DefinedFlag = 2;
+
+ private int flags;
+
+ public ArrayList LocationList;
+ public FieldDef Field;
+
+ public FieldTableItem (FieldDef field, Location location)
+ {
+ flags = 0;
+ Field = field;
+ LocationList = new ArrayList ();
+ LocationList.Add (location);
+ }
+
+ public bool Defined {
+ get { return ((flags & DefinedFlag) != 0); }
+ set {
+ if (value)
+ flags |= DefinedFlag;
+ else
+ flags ^= DefinedFlag;
+ }
+ }
+ }
+
+ protected Hashtable table;
+ protected ClassDef parent_class;
+
+ public FieldTable (ClassDef parent_class)
+ {
+ this.parent_class = parent_class;
+ table = new Hashtable ();
+ }
+
+ public Field GetReference (TypeRef type, string name, Location location)
+ {
+ FieldTableItem item = table[name] as FieldTableItem;
+
+ if (item != null) {
+ item.LocationList.Add (location);
+ return item.Field;
+ }
+
+ FieldDef field = parent_class.AddField (name, type.Type);
+ AddReferenced (name, field, location);
+
+ return field;
+ }
+
+ public FieldDef AddDefinition (FieldAttr field_attr, string name,
+ TypeRef type, Location location)
+ {
+ FieldTableItem item = (FieldTableItem) table[name];
+
+ if (item == null) {
+ FieldDef field = parent_class.AddField (field_attr, name, type.Type);
+ AddDefined (name, field, location);
+ return field;
+ }
+
+ item.Field.AddFieldAttr (field_attr);
+ item.Defined = true;
+
+ return item.Field;
+ }
+
+ public bool CheckDefined ()
+ {
+ foreach (DictionaryEntry dic_entry in table) {
+ FieldTableItem table_item = (FieldTableItem) dic_entry.Value;
+ if (table_item.Defined)
+ continue;
+ Report.Error (String.Format ("Field: {0} is not defined.", dic_entry.Key));
+ }
+ return true;
+ }
+
+ protected void AddDefined (string signature, FieldDef field, Location location)
+ {
+ if (table.Contains (signature))
+ return;
+
+ FieldTableItem item = new FieldTableItem (field, location);
+ item.Defined = true;
+
+ table[signature] = item;
+ }
+
+ protected void AddReferenced (string signature, FieldDef field, Location location)
+ {
+ FieldTableItem item = new FieldTableItem (field, location);
+
+ table[signature] = item;
+ }
+
+ /// <summary>
+ /// If a field is allready defined throw an Error
+ /// </summary>
+ protected void CheckExists (string signature)
+ {
+ FieldTableItem item = table[signature] as FieldTableItem;
+
+ if ((item != null) && (item.Defined))
+ Report.Error ("Field: " + signature + " defined in multiple locations.");
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/FileRef.cs b/mcs/ilasm/codegen/FileRef.cs
new file mode 100644
index 00000000000..5acc659a656
--- /dev/null
+++ b/mcs/ilasm/codegen/FileRef.cs
@@ -0,0 +1,36 @@
+//
+// Mono.ILASM.FileRef
+//
+// Author(s):
+// Jackson Harper (jackson@ximian.com)
+//
+// Copyright 2004 Novell, Inc (http://www.novell.com)
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class FileRef {
+
+ private string name;
+ private byte [] hash;
+ private bool has_metadata;
+ private bool entrypoint;
+
+ public FileRef (string name, byte[] hash, bool has_metadata, bool entrypoint)
+ {
+ this.name = name;
+ this.hash = hash;
+ this.has_metadata = has_metadata;
+ this.entrypoint = entrypoint;
+ }
+
+ public void Resolve (CodeGen codegen)
+ {
+ codegen.PEFile.AddFile (name, hash, has_metadata, entrypoint);
+ }
+ }
+}
+
diff --git a/mcs/ilasm/codegen/FilterBlock.cs b/mcs/ilasm/codegen/FilterBlock.cs
new file mode 100644
index 00000000000..67ef2d111df
--- /dev/null
+++ b/mcs/ilasm/codegen/FilterBlock.cs
@@ -0,0 +1,43 @@
+//
+// Mono.ILASM.FilterBlock
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+
+namespace Mono.ILASM {
+
+ public class FilterBlock : ISehClause {
+
+ private HandlerBlock this_block;
+ private HandlerBlock handler_block;
+
+ public FilterBlock (HandlerBlock this_block)
+ {
+ this.this_block = this_block;
+ }
+
+ public void SetHandlerBlock (HandlerBlock hb)
+ {
+ handler_block = hb;
+ }
+
+ public PEAPI.HandlerBlock Resolve (CodeGen code_gen, MethodDef method)
+ {
+ PEAPI.CILLabel label = this_block.GetFromLabel (code_gen, method);
+ PEAPI.CILLabel from = handler_block.GetFromLabel (code_gen, method);
+ PEAPI.CILLabel to = handler_block.GetToLabel (code_gen, method);
+ PEAPI.Filter filter = new PEAPI.Filter (label, from, to);
+
+ return filter;
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/FinallyBlock.cs b/mcs/ilasm/codegen/FinallyBlock.cs
new file mode 100644
index 00000000000..9e6740e9dc4
--- /dev/null
+++ b/mcs/ilasm/codegen/FinallyBlock.cs
@@ -0,0 +1,41 @@
+//
+// Mono.ILASM.FinallyBlock
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class FinallyBlock : ISehClause {
+
+ private HandlerBlock handler_block;
+
+ public FinallyBlock ()
+ {
+
+ }
+
+ public void SetHandlerBlock (HandlerBlock hb)
+ {
+ handler_block = hb;
+ }
+
+ public PEAPI.HandlerBlock Resolve (CodeGen code_gen, MethodDef method)
+ {
+ PEAPI.CILLabel from = handler_block.GetFromLabel (code_gen, method);
+ PEAPI.CILLabel to = handler_block.GetToLabel (code_gen, method);
+ PEAPI.Finally phinally = new PEAPI.Finally (from, to);
+
+ return phinally;
+ }
+ }
+
+}
+
+
diff --git a/mcs/ilasm/codegen/GenericArguments.cs b/mcs/ilasm/codegen/GenericArguments.cs
new file mode 100644
index 00000000000..afefa395848
--- /dev/null
+++ b/mcs/ilasm/codegen/GenericArguments.cs
@@ -0,0 +1,107 @@
+//
+// Mono.ILASM.GenericArguments
+//
+// Author(s):
+// Ankit Jain <jankit@novell.com>
+//
+// Copyright 2005 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using System.Collections;
+using System.Text;
+
+namespace Mono.ILASM {
+
+ public class GenericArguments {
+ ArrayList type_list;
+ string type_str;
+ BaseTypeRef [] type_arr;
+ bool is_resolved;
+ PEAPI.Type [] p_type_list;
+
+ public GenericArguments ()
+ {
+ type_list = null;
+ type_arr = null;
+ type_str = null;
+ is_resolved = false;
+ p_type_list = null;
+ }
+
+ public int Count {
+ get { return type_list.Count; }
+ }
+
+ public void Add (BaseTypeRef type)
+ {
+ if (type == null)
+ throw new InternalErrorException ();
+
+ if (type_list == null)
+ type_list = new ArrayList ();
+ type_list.Add (type);
+ type_str = null;
+ type_arr = null;
+ }
+
+ public BaseTypeRef [] ToArray ()
+ {
+ if (type_list == null)
+ return null;
+ if (type_arr == null)
+ type_arr = (BaseTypeRef []) type_list.ToArray (typeof (BaseTypeRef));
+
+ return type_arr;
+ }
+
+ public PEAPI.Type [] Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return p_type_list;
+
+ int i = 0;
+ p_type_list = new PEAPI.Type [type_list.Count];
+ foreach (BaseTypeRef type in type_list) {
+ type.Resolve (code_gen);
+ p_type_list [i ++] = type.PeapiType;
+ }
+ is_resolved = true;
+ type_str = null;
+ return p_type_list;
+ }
+
+ public void Resolve (GenericParameters type_gen_params, GenericParameters method_gen_params)
+ {
+ foreach (BaseTypeRef type in type_list) {
+ BaseGenericTypeRef gtr = type as BaseGenericTypeRef;
+ if (gtr != null)
+ gtr.Resolve (type_gen_params, method_gen_params);
+ }
+ /* Reset, might have changed (think GenericParamRef) */
+ type_str = null;
+ }
+
+ private void MakeString ()
+ {
+ //Build full_name (foo < , >)
+ StringBuilder sb = new StringBuilder ();
+ sb.Append ("<");
+ foreach (BaseTypeRef tr in type_list)
+ sb.AppendFormat ("{0}, ", tr.FullName);
+ //Remove the extra ', ' at the end
+ sb.Length -= 2;
+ sb.Append (">");
+ type_str = sb.ToString ();
+ }
+
+ public override string ToString ()
+ {
+ if (type_str == null)
+ MakeString ();
+ return type_str;
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/GenericMethodRef.cs b/mcs/ilasm/codegen/GenericMethodRef.cs
new file mode 100644
index 00000000000..81255f1433b
--- /dev/null
+++ b/mcs/ilasm/codegen/GenericMethodRef.cs
@@ -0,0 +1,46 @@
+//
+// Mono.ILASM.GenericMethodRef
+//
+// Author(s):
+// Jackson Harper (jackson@ximian.com)
+//
+// (C) 2003 Ximian, Inc (http://www.ximian.com)
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class GenericMethodRef : BaseMethodRef {
+
+ private BaseMethodRef meth;
+ private GenericMethodSig sig;
+
+ public GenericMethodRef (BaseMethodRef meth, GenericMethodSig sig)
+ : base (null, meth.CallConv, null, "", null, 0)
+ {
+ this.meth = meth;
+ this.sig = sig;
+ is_resolved = false;
+ }
+
+ public override PEAPI.CallConv CallConv {
+ get { return meth.CallConv; }
+ set { meth.CallConv = value; }
+ }
+
+ public override void Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ meth.Resolve (code_gen);
+ peapi_method = code_gen.PEFile.AddMethodSpec (meth.PeapiMethod, sig.Resolve (code_gen));
+
+ is_resolved = true;
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/GenericMethodSig.cs b/mcs/ilasm/codegen/GenericMethodSig.cs
new file mode 100644
index 00000000000..e8c74bec130
--- /dev/null
+++ b/mcs/ilasm/codegen/GenericMethodSig.cs
@@ -0,0 +1,64 @@
+//
+// Mono.ILASM.GenericMethodSig
+//
+// Author(s):
+// Jackson Harper (jackson@ximian.com)
+//
+// (C) 2003 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class GenericMethodSig {
+
+ private GenericArguments gen_args;
+ private bool is_resolved;
+ private PEAPI.GenericMethodSig sig;
+
+ private static Hashtable sig_table;
+
+ public GenericMethodSig (GenericArguments gen_args)
+ {
+ this.gen_args = gen_args;
+ is_resolved = false;
+ }
+
+ public PEAPI.GenericMethodSig Sig {
+ get { return sig; }
+ }
+
+ public PEAPI.GenericMethodSig Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return sig;
+
+ sig = new PEAPI.GenericMethodSig (gen_args.Resolve (code_gen));
+ is_resolved = true;
+
+ return sig;
+ }
+
+ public static GenericMethodSig GetInstance (GenericArguments gen_args)
+ {
+ GenericMethodSig sig = null;
+
+ if (sig_table == null)
+ sig_table = new Hashtable ();
+ else
+ sig = (GenericMethodSig) sig_table [gen_args.ToString ()];
+
+ if (sig == null) {
+ sig = new GenericMethodSig (gen_args);
+ sig_table [gen_args.ToString ()] = sig;
+ }
+
+ return sig;
+ }
+ }
+
+}
+
+
diff --git a/mcs/ilasm/codegen/GenericParamRef.cs b/mcs/ilasm/codegen/GenericParamRef.cs
new file mode 100644
index 00000000000..cbebce70a04
--- /dev/null
+++ b/mcs/ilasm/codegen/GenericParamRef.cs
@@ -0,0 +1,116 @@
+//
+// Mono.ILASM.GenericParamRef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+// Ankit Jain (JAnkit@novell.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+// (C) 2006 Novell, Inc (http://www.novell.com)
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class GenericParamRef : BaseGenericTypeRef {
+
+ /* PEAPI.Type type: Might get modified */
+ /* Unmodified GenParam */
+ private PEAPI.GenParam param;
+ private bool is_added; /* Added to TypeSpec table ? */
+ private static Hashtable param_table = new Hashtable ();
+
+ public GenericParamRef (PEAPI.GenParam gen_param, string full_name)
+ : this (gen_param, full_name, null)
+ {
+ }
+
+ public GenericParamRef (PEAPI.GenParam gen_param, string full_name, ArrayList conv_list)
+ : base (full_name, false, conv_list, "")
+ {
+ this.type = gen_param;
+ this.param = gen_param;
+ is_added = false;
+ }
+
+ public override string FullName {
+ get {
+ return (param.Type == PEAPI.GenParamType.Var ? "!" : "!!")
+ + param.Index + sig_mod;
+ }
+ }
+
+ public override void MakeValueClass ()
+ {
+ throw new InternalErrorException ("Not supported");
+ }
+
+ public override BaseClassRef Clone ()
+ {
+ return new GenericParamRef (param, full_name, (ArrayList) ConversionList.Clone ());
+ }
+
+ public override void ResolveNoTypeSpec (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ type = Modify (code_gen, type);
+ is_resolved = true;
+ }
+
+ public override void Resolve (CodeGen code_gen)
+ {
+ ResolveNoTypeSpec (code_gen);
+ if (is_added)
+ return;
+
+ string key = param.Type.ToString () + param.Index.ToString ();
+ PEAPI.GenParam val = (PEAPI.GenParam) param_table [key];
+ if (val == null) {
+ code_gen.PEFile.AddGenericParam (param);
+ param_table [key] = param;
+ } else {
+ /* Set this instance's "type" to the cached
+ PEAPI.GenParam, after applying modifications */
+ type = Modify (code_gen, val);
+ }
+
+ is_added = true;
+ }
+
+ public override void Resolve (GenericParameters type_gen_params, GenericParameters method_gen_params)
+ {
+ if (param.Name == "") {
+ /* Name wasn't specified */
+ return;
+ }
+
+ if (param.Type == PEAPI.GenParamType.MVar && method_gen_params != null)
+ param.Index = method_gen_params.GetGenericParamNum (param.Name);
+ else if (type_gen_params != null)
+ param.Index = type_gen_params.GetGenericParamNum (param.Name);
+
+ if (param.Index < 0)
+ Report.Error (String.Format ("Invalid {0}type parameter '{1}'",
+ (param.Type == PEAPI.GenParamType.MVar ? "method " : ""),
+ param.Name));
+ }
+
+ protected override BaseMethodRef CreateMethodRef (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
+ string name, BaseTypeRef[] param, int gen_param_count)
+ {
+ return new TypeSpecMethodRef (this, call_conv, ret_type, name, param, gen_param_count);
+ }
+
+ protected override IFieldRef CreateFieldRef (BaseTypeRef ret_type, string name)
+ {
+ return new TypeSpecFieldRef (this, ret_type, name);
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/GenericParameters.cs b/mcs/ilasm/codegen/GenericParameters.cs
new file mode 100644
index 00000000000..9dcb449a448
--- /dev/null
+++ b/mcs/ilasm/codegen/GenericParameters.cs
@@ -0,0 +1,212 @@
+//
+// Mono.ILASM.GenericParameters
+//
+// Author(s):
+// Ankit Jain <jankit@novell.com>
+//
+// Copyright 2006 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using System.Collections;
+using System.Text;
+
+namespace Mono.ILASM {
+
+ public class GenericParameter : ICustomAttrTarget {
+ string id;
+ int num;
+ PEAPI.GenericParamAttributes attr;
+ ArrayList constraintsList;
+ ArrayList customattrList;
+
+ public GenericParameter (string id)
+ : this (id, 0, null)
+ {
+ }
+
+ public GenericParameter (string id, PEAPI.GenericParamAttributes attr, ArrayList constraints)
+ {
+ this.id = id;
+ this.attr = attr;
+ num = -1;
+ constraintsList = null;
+ customattrList = null;
+
+ if (constraints != null)
+ foreach (BaseTypeRef typeref in constraints)
+ AddConstraint (typeref);
+ }
+
+ public string Id {
+ get { return id; }
+ }
+
+ public int Num {
+ get { return num; }
+ set { num = value; }
+ }
+
+ public void AddConstraint (BaseTypeRef constraint)
+ {
+ if (constraint == null)
+ throw new InternalErrorException ();
+
+ if (constraintsList == null)
+ constraintsList = new ArrayList ();
+
+ constraintsList.Add (constraint);
+ }
+
+ public override string ToString ()
+ {
+ return Id;
+ }
+
+ public void AddCustomAttribute (CustomAttr customattr)
+ {
+ if (customattrList == null)
+ customattrList = new ArrayList ();
+
+ customattrList.Add (customattr);
+ }
+
+ public void Resolve (CodeGen code_gen, PEAPI.MethodDef methoddef)
+ {
+ PEAPI.GenericParameter gp = methoddef.AddGenericParameter ((short) num, id, attr);
+ Resolve (code_gen, gp);
+ }
+
+ public void Resolve (CodeGen code_gen, PEAPI.ClassDef classdef)
+ {
+ PEAPI.GenericParameter gp = classdef.AddGenericParameter ((short) num, id, attr);
+ Resolve (code_gen, gp);
+ }
+
+ private void Resolve (CodeGen code_gen, PEAPI.GenericParameter gp)
+ {
+ ResolveConstraints (code_gen, gp);
+ if (customattrList == null)
+ return;
+
+ foreach (CustomAttr customattr in customattrList)
+ customattr.AddTo (code_gen, gp);
+ }
+
+ public void ResolveConstraints (GenericParameters type_gen_params, GenericParameters method_gen_params)
+ {
+ if (constraintsList == null)
+ return;
+
+ foreach (BaseTypeRef constraint in constraintsList) {
+ BaseGenericTypeRef gtr = constraint as BaseGenericTypeRef;
+ if (gtr != null)
+ gtr.Resolve (type_gen_params, method_gen_params);
+ }
+ }
+
+ private void ResolveConstraints (CodeGen code_gen, PEAPI.GenericParameter gp)
+ {
+ if (constraintsList == null)
+ return;
+
+ foreach (BaseTypeRef constraint in constraintsList) {
+ constraint.Resolve (code_gen);
+ gp.AddConstraint (constraint.PeapiType);
+ }
+ }
+
+ }
+
+ public class GenericParameters {
+ ArrayList param_list;
+ string param_str;
+
+ public GenericParameters ()
+ {
+ param_list = null;
+ param_str = null;
+ }
+
+ public int Count {
+ get { return (param_list == null ? 0 : param_list.Count); }
+ }
+
+ public GenericParameter this [int index] {
+ get { return (param_list != null ? (GenericParameter) param_list [index] : null); }
+ set { Add (value); }
+ }
+
+ public void Add (GenericParameter gen_param)
+ {
+ if (gen_param == null)
+ throw new InternalErrorException ();
+
+ if (param_list == null)
+ param_list = new ArrayList ();
+ gen_param.Num = param_list.Count;
+ param_list.Add (gen_param);
+ param_str = null;
+ }
+
+ public GenericParameter GetGenericParam (string id)
+ {
+ if (param_list == null)
+ Report.Error ("Invalid type parameter '" + id + "'");
+
+ foreach (GenericParameter param in param_list)
+ if (param.Id == id)
+ return param;
+ return null;
+ }
+
+ public int GetGenericParamNum (string id)
+ {
+ GenericParameter param = GetGenericParam (id);
+ if (param != null)
+ return param.Num;
+
+ return -1;
+ }
+
+ public void Resolve (CodeGen code_gen, PEAPI.ClassDef classdef)
+ {
+ foreach (GenericParameter param in param_list)
+ param.Resolve (code_gen, classdef);
+ }
+
+ public void Resolve (CodeGen code_gen, PEAPI.MethodDef methoddef)
+ {
+ foreach (GenericParameter param in param_list)
+ param.Resolve (code_gen, methoddef);
+ }
+
+ public void ResolveConstraints (GenericParameters type_gen_params, GenericParameters method_gen_params)
+ {
+ foreach (GenericParameter param in param_list)
+ param.ResolveConstraints (type_gen_params, method_gen_params);
+ param_str = null;
+ }
+
+ private void MakeString ()
+ {
+ //Build full_name (foo < , >)
+ StringBuilder sb = new StringBuilder ();
+ sb.Append ("<");
+ foreach (GenericParameter param in param_list)
+ sb.AppendFormat ("{0}, ", param);
+ //Remove the extra ', ' at the end
+ sb.Length -= 2;
+ sb.Append (">");
+ param_str = sb.ToString ();
+ }
+
+ public override string ToString ()
+ {
+ if (param_str == null)
+ MakeString ();
+ return param_str;
+ }
+ }
+
+}
diff --git a/mcs/ilasm/codegen/GenericTypeInst.cs b/mcs/ilasm/codegen/GenericTypeInst.cs
new file mode 100644
index 00000000000..1982cd5ba27
--- /dev/null
+++ b/mcs/ilasm/codegen/GenericTypeInst.cs
@@ -0,0 +1,128 @@
+//
+// Mono.ILASM.GenericTypeInst
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+// Ankit Jain (JAnkit@novell.com)
+//
+// (C) 2003 Latitude Geographics Group, All rights reserved
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class GenericTypeInst : BaseGenericTypeRef {
+
+ private BaseClassRef class_ref;
+ private PEAPI.GenericTypeInst p_gen_inst;
+ private bool is_valuetypeinst;
+ private GenericArguments gen_args;
+ private bool is_added; /* Added to PEFile (to TypeSpec table) ? */
+ /* Note: Using static hashtable here as GenericTypeInsts is not cached */
+ private static Hashtable s_method_table = new Hashtable ();
+ private static Hashtable s_field_table = new Hashtable ();
+
+ public GenericTypeInst (BaseClassRef class_ref, GenericArguments gen_args, bool is_valuetypeinst)
+ : this (class_ref, gen_args, is_valuetypeinst, null, null)
+ {
+ }
+
+ public GenericTypeInst (BaseClassRef class_ref, GenericArguments gen_args, bool is_valuetypeinst,
+ string sig_mod, ArrayList conv_list)
+ : base ("", is_valuetypeinst, conv_list, sig_mod)
+ {
+ if (class_ref is GenericTypeInst)
+ throw new InternalErrorException ("Cannot create nested GenericInst, '" +
+ class_ref.FullName + "' '" + gen_args.ToString () + "'");
+
+ this.class_ref = class_ref;
+ this.gen_args = gen_args;
+ is_added = false;
+ }
+
+ public override string FullName {
+ get { return class_ref.FullName + gen_args.ToString () + SigMod; }
+ }
+
+ public override BaseClassRef Clone ()
+ {
+ //Clone'd instance shares the class_ref and gen_args,
+ //as its basically used to create modified types (arrays etc)
+ return new GenericTypeInst (class_ref, gen_args, is_valuetypeinst, sig_mod,
+ (ArrayList) ConversionList.Clone () );
+ }
+
+ public override void MakeValueClass ()
+ {
+ class_ref.MakeValueClass ();
+ }
+
+ public override void ResolveNoTypeSpec (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ class_ref.Resolve (code_gen);
+ p_gen_inst = (PEAPI.GenericTypeInst) class_ref.ResolveInstance (code_gen, gen_args);
+
+ type = Modify (code_gen, p_gen_inst);
+
+ is_resolved = true;
+ }
+
+ public override void Resolve (CodeGen code_gen)
+ {
+ ResolveNoTypeSpec (code_gen);
+ if (is_added)
+ return;
+
+ code_gen.PEFile.AddGenericClass ((PEAPI.GenericTypeInst) p_gen_inst);
+ is_added = true;
+ }
+
+ public override void Resolve (GenericParameters type_gen_params, GenericParameters method_gen_params)
+ {
+ gen_args.Resolve (type_gen_params, method_gen_params);
+ }
+
+ protected override BaseMethodRef CreateMethodRef (BaseTypeRef ret_type,
+ PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count)
+ {
+ throw new InternalErrorException ("Should not be called");
+ }
+
+ public override BaseMethodRef GetMethodRef (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
+ string meth_name, BaseTypeRef[] param, int gen_param_count)
+ {
+ /* Note: Using FullName here as we are caching in a static hashtable */
+ string key = FullName + MethodDef.CreateSignature (ret_type, meth_name, param, gen_param_count);
+ TypeSpecMethodRef mr = s_method_table [key] as TypeSpecMethodRef;
+ if (mr == null) {
+ mr = new TypeSpecMethodRef (this, call_conv, ret_type, meth_name, param, gen_param_count);
+ s_method_table [key] = mr;
+ }
+
+ return mr;
+ }
+
+ protected override IFieldRef CreateFieldRef (BaseTypeRef ret_type, string field_name)
+ {
+ /* Note: Using FullName here as we are caching in a static hashtable */
+ string key = FullName + ret_type.FullName + field_name;
+
+ IFieldRef fr = (IFieldRef) s_field_table [key];
+
+ if (fr == null) {
+ fr = new TypeSpecFieldRef (this, ret_type, field_name);
+ s_field_table [key] = fr;
+ }
+
+ return fr;
+ }
+ }
+}
+
diff --git a/mcs/ilasm/codegen/GlobalFieldRef.cs b/mcs/ilasm/codegen/GlobalFieldRef.cs
new file mode 100644
index 00000000000..2ab31a5834d
--- /dev/null
+++ b/mcs/ilasm/codegen/GlobalFieldRef.cs
@@ -0,0 +1,47 @@
+//
+// Mono.ILASM.GlobalFieldRef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+
+ public class GlobalFieldRef : IFieldRef {
+
+ private BaseTypeRef ret_type;
+ private string name;
+
+ private PEAPI.Field peapi_field;
+ private bool is_resolved;
+
+ public GlobalFieldRef (BaseTypeRef ret_type, string name)
+ {
+ this.ret_type = ret_type;
+ this.name = name;
+
+ is_resolved = false;
+ }
+
+ public PEAPI.Field PeapiField {
+ get { return peapi_field; }
+ }
+
+ public void Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ peapi_field = code_gen.ResolveField (name, ret_type.FullName);
+
+ is_resolved = true;
+ }
+ }
+}
+
diff --git a/mcs/ilasm/codegen/GlobalMethodRef.cs b/mcs/ilasm/codegen/GlobalMethodRef.cs
new file mode 100644
index 00000000000..fb85d1af4b6
--- /dev/null
+++ b/mcs/ilasm/codegen/GlobalMethodRef.cs
@@ -0,0 +1,58 @@
+//
+// Mono.ILASM.GlobalMethodRef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class GlobalMethodRef : BaseMethodRef {
+
+ public GlobalMethodRef (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
+ string name, BaseTypeRef[] param, int gen_param_count)
+ : base (null, call_conv, ret_type, name, param, gen_param_count)
+ {
+ }
+
+ public override void Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ string sig;
+
+ if ((call_conv & PEAPI.CallConv.Vararg) == 0) {
+ sig = MethodDef.CreateSignature (ret_type, name, param, gen_param_count);
+ peapi_method = code_gen.ResolveMethod (sig);
+ } else {
+ ArrayList opt_list = new ArrayList ();
+ bool in_opt = false;
+ foreach (BaseTypeRef type in param) {
+ if (type is SentinelTypeRef) {
+ in_opt = true;
+ } else if (in_opt) {
+ type.Resolve (code_gen);
+ opt_list.Add (type.PeapiType);
+ }
+ }
+ sig = MethodDef.CreateVarargSignature (ret_type, name, param);
+ peapi_method = code_gen.ResolveVarargMethod (sig, code_gen,
+ (PEAPI.Type[]) opt_list.ToArray (typeof (PEAPI.Type)));
+ }
+
+ peapi_method.AddCallConv (call_conv);
+
+ is_resolved = true;
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/HandlerBlock.cs b/mcs/ilasm/codegen/HandlerBlock.cs
new file mode 100644
index 00000000000..900fc6bb5e5
--- /dev/null
+++ b/mcs/ilasm/codegen/HandlerBlock.cs
@@ -0,0 +1,39 @@
+//
+// Mono.ILASM.HandlerBlock
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper (Jackson@LatitudeGeo.com)
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class HandlerBlock {
+
+ private LabelInfo from_label;
+ private LabelInfo to_label;
+
+ public HandlerBlock (LabelInfo from_label, LabelInfo to_label)
+ {
+ this.from_label = from_label;
+ this.to_label = to_label;
+ }
+
+ public PEAPI.CILLabel GetFromLabel (CodeGen code_gen, MethodDef method)
+ {
+ return from_label.Label;
+ }
+
+ public PEAPI.CILLabel GetToLabel (CodeGen code_gen, MethodDef method)
+ {
+ return to_label.Label;
+ }
+ }
+
+}
+
+
diff --git a/mcs/ilasm/codegen/IClassRef.cs b/mcs/ilasm/codegen/IClassRef.cs
new file mode 100644
index 00000000000..699edad7292
--- /dev/null
+++ b/mcs/ilasm/codegen/IClassRef.cs
@@ -0,0 +1,33 @@
+//
+// Mono.ILASM.IClassRef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+// Ankit Jain (JAnkit@novell.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Mono.ILASM {
+
+ public interface BaseClassRef : BaseTypeRef {
+
+ PEAPI.Class PeapiClass { get; }
+
+ void MakeValueClass ();
+
+ IClassRef Clone ();
+
+ /* Returns the Generic Instance for the BaseClassRef */
+ GenericTypeInst GetGenericTypeInst (GenericArguments gen_args);
+
+ /* Resolves the Generic instance and returns the
+ resolved type (typically, PEAPI.GenericTypeInst) */
+ PEAPI.Type ResolveInstance (CodeGen code_gen, GenericArguments gen_args);
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/IFieldRef.cs b/mcs/ilasm/codegen/IFieldRef.cs
new file mode 100644
index 00000000000..15184e41845
--- /dev/null
+++ b/mcs/ilasm/codegen/IFieldRef.cs
@@ -0,0 +1,25 @@
+//
+// Mono.ILASM.IFieldRef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public interface IFieldRef {
+
+ PEAPI.Field PeapiField {
+ get;
+ }
+
+ void Resolve (CodeGen code_gen);
+ }
+}
+
+
diff --git a/mcs/ilasm/codegen/IInstr.cs b/mcs/ilasm/codegen/IInstr.cs
new file mode 100644
index 00000000000..a40da7598a0
--- /dev/null
+++ b/mcs/ilasm/codegen/IInstr.cs
@@ -0,0 +1,34 @@
+//
+// Mono.ILASM.IInstr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public abstract class IInstr {
+
+ public readonly Location Location;
+
+ /// <summary>
+ /// </summary>
+ /// <param name="opcode"></param>
+ public IInstr (Location loc)
+ {
+ this.Location = (Location) loc.Clone ();
+ }
+
+ /// <summary>
+ /// Add this instruction to the supplied codebuffer
+ /// </summary>
+ public abstract void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil);
+ }
+
+}
diff --git a/mcs/ilasm/codegen/IMethodRef.cs b/mcs/ilasm/codegen/IMethodRef.cs
new file mode 100644
index 00000000000..412398f6447
--- /dev/null
+++ b/mcs/ilasm/codegen/IMethodRef.cs
@@ -0,0 +1,37 @@
+//
+// Mono.ILASM.IMethodRef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+
+namespace Mono.ILASM {
+
+ public interface IMethodRef {
+
+ PEAPI.Method PeapiMethod {
+ get;
+ }
+
+ PEAPI.CallConv CallConv {
+ get;
+ set;
+ }
+
+ void Resolve (CodeGen code_gen);
+
+ BaseTypeRef Owner {
+ get;
+ }
+ }
+
+}
+
+
+
diff --git a/mcs/ilasm/codegen/ISehClause.cs b/mcs/ilasm/codegen/ISehClause.cs
new file mode 100644
index 00000000000..de36ef0417e
--- /dev/null
+++ b/mcs/ilasm/codegen/ISehClause.cs
@@ -0,0 +1,21 @@
+//
+// Mono.ILASM.ISehClause
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+namespace Mono.ILASM {
+
+ public interface ISehClause {
+
+ PEAPI.HandlerBlock Resolve (CodeGen code_gen, MethodDef method);
+
+ void SetHandlerBlock (HandlerBlock hb);
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/ITypeRef.cs b/mcs/ilasm/codegen/ITypeRef.cs
new file mode 100644
index 00000000000..80333eee0de
--- /dev/null
+++ b/mcs/ilasm/codegen/ITypeRef.cs
@@ -0,0 +1,85 @@
+//
+// Mono.ILASM.BaseTypeRef
+//
+// Interface that all Type references must implement
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public interface ITypeRef {
+
+ /// <summary>
+ /// The full name of the type, <namespace>.<name>
+ /// ie System.Collections.ArrayList
+ /// </summary>
+ string FullName { get; }
+
+ bool IsPinned { get; }
+ bool IsRef { get; }
+ bool IsArray { get; }
+ bool UseTypeSpec { get; }
+
+ /// <summary>
+ /// The PEAPI.Type of this typeref, this is not guaranteed
+ /// to be correct untill after this is resolved.
+ /// </summary>
+ PEAPI.Type PeapiType { get; }
+
+ /// <summary>
+ /// Convert this typeref into a zero based array
+ /// </summary>
+ void MakeArray ();
+
+ /// <summary>
+ /// Convert this typeref into a bound array. The ArrayList
+ /// should be in the format Entry (lower_bound, upper_bound) with
+ /// null being used for unset bounds.
+ /// </summary>
+ void MakeBoundArray (ArrayList bounds);
+
+ /// <summary>
+ /// Convert this typeref into a reference
+ /// </summary>
+ void MakeManagedPointer ();
+
+ /// <summary>
+ /// Convert this typeref into an unmanaged pointer
+ /// </summary>
+ void MakeUnmanagedPointer ();
+
+ /// <summary>
+ /// Convert this typeref into a CustomModifiedType
+ /// </summary>
+ void MakeCustomModified (CodeGen code_gen,
+ PEAPI.CustomModifier modifier, IClassRef klass);
+
+ /// <summary>
+ /// Make this typeref pinned.
+ /// </summary>
+ void MakePinned ();
+
+ void Resolve (CodeGen code_gen);
+
+ BaseMethodRef GetMethodRef (ITypeRef ret_type, PEAPI.CallConv call_conv,
+ string name, ITypeRef[] param, int gen_param_count);
+
+ IFieldRef GetFieldRef (ITypeRef ret_type, string name);
+
+ /// <summary>
+ /// Convert this typeref to a classref if not possible
+ /// throw an exception
+ /// </summary>
+ // IClassRef AsClassRef (CodeGen code_gen);
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/InstrBase.cs b/mcs/ilasm/codegen/InstrBase.cs
new file mode 100644
index 00000000000..3fba1787275
--- /dev/null
+++ b/mcs/ilasm/codegen/InstrBase.cs
@@ -0,0 +1,51 @@
+// InstrBase.cs
+// (C) Sergey Chaban (serge@wildwestsoftware.com)
+
+using System;
+using System.Reflection.Emit;
+
+namespace Mono.ILASM {
+
+ public abstract class InstrBase {
+
+ private OpCode opcode;
+
+ /// <summary>
+ /// </summary>
+ /// <param name="opcode"></param>
+ public InstrBase (OpCode opcode)
+ {
+ this.opcode = opcode;
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <param name="tok"></param>
+ public InstrBase (InstrToken tok) : this ((OpCode)tok.Value)
+ {
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="tok"></param>
+ public InstrBase (ILToken tok) : this (tok as InstrToken)
+ {
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public OpCode Opcode {
+ get {
+ return opcode;
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="gen"></param>
+ public abstract void Emit (ILGenerator ilgen, Class host);
+ }
+}
diff --git a/mcs/ilasm/codegen/InstrTable.cs b/mcs/ilasm/codegen/InstrTable.cs
new file mode 100644
index 00000000000..2615d0f5837
--- /dev/null
+++ b/mcs/ilasm/codegen/InstrTable.cs
@@ -0,0 +1,313 @@
+//
+// Mono.ILASM.InstrTable
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+using PEAPI;
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class InstrTable {
+
+ private static Hashtable inst_table;
+
+ static InstrTable ()
+ {
+ CreateInstTable ();
+ }
+
+ public static ILToken GetToken (string str)
+ {
+ return inst_table[str] as ILToken;
+ }
+
+ public static bool IsInstr (string str)
+ {
+ return inst_table.Contains (str);
+ }
+
+ private static void CreateInstTable ()
+ {
+ inst_table = new Hashtable ();
+
+ inst_table["nop"] = new ILToken (Token.INSTR_NONE, Op.nop);
+ inst_table["break"] = new ILToken (Token.INSTR_NONE, Op.breakOp);
+ inst_table["ldarg.0"] = new ILToken (Token.INSTR_NONE, Op.ldarg_0);
+ inst_table["ldarg.1"] = new ILToken (Token.INSTR_NONE, Op.ldarg_1);
+ inst_table["ldarg.2"] = new ILToken (Token.INSTR_NONE, Op.ldarg_2);
+ inst_table["ldarg.3"] = new ILToken (Token.INSTR_NONE, Op.ldarg_3);
+ inst_table["ldloc.0"] = new ILToken (Token.INSTR_NONE, Op.ldloc_0);
+ inst_table["ldloc.1"] = new ILToken (Token.INSTR_NONE, Op.ldloc_1);
+ inst_table["ldloc.2"] = new ILToken (Token.INSTR_NONE, Op.ldloc_2);
+ inst_table["ldloc.3"] = new ILToken (Token.INSTR_NONE, Op.ldloc_3);
+ inst_table["stloc.0"] = new ILToken (Token.INSTR_NONE, Op.stloc_0);
+ inst_table["stloc.1"] = new ILToken (Token.INSTR_NONE, Op.stloc_1);
+ inst_table["stloc.2"] = new ILToken (Token.INSTR_NONE, Op.stloc_2);
+ inst_table["stloc.3"] = new ILToken (Token.INSTR_NONE, Op.stloc_3);
+ inst_table["ldnull"] = new ILToken (Token.INSTR_NONE, Op.ldnull);
+ inst_table["ldc.i4.m1"] = new ILToken (Token.INSTR_NONE, Op.ldc_i4_m1);
+ inst_table["ldc.i4.M1"] = new ILToken (Token.INSTR_NONE, Op.ldc_i4_m1);
+ inst_table["ldc.i4.0"] = new ILToken (Token.INSTR_NONE, Op.ldc_i4_0);
+ inst_table["ldc.i4.1"] = new ILToken (Token.INSTR_NONE, Op.ldc_i4_1);
+ inst_table["ldc.i4.2"] = new ILToken (Token.INSTR_NONE, Op.ldc_i4_2);
+ inst_table["ldc.i4.3"] = new ILToken (Token.INSTR_NONE, Op.ldc_i4_3);
+ inst_table["ldc.i4.4"] = new ILToken (Token.INSTR_NONE, Op.ldc_i4_4);
+ inst_table["ldc.i4.5"] = new ILToken (Token.INSTR_NONE, Op.ldc_i4_5);
+ inst_table["ldc.i4.6"] = new ILToken (Token.INSTR_NONE, Op.ldc_i4_6);
+ inst_table["ldc.i4.7"] = new ILToken (Token.INSTR_NONE, Op.ldc_i4_7);
+ inst_table["ldc.i4.8"] = new ILToken (Token.INSTR_NONE, Op.ldc_i4_8);
+ inst_table["dup"] = new ILToken (Token.INSTR_NONE, Op.dup);
+ inst_table["pop"] = new ILToken (Token.INSTR_NONE, Op.pop);
+ inst_table["ret"] = new ILToken (Token.INSTR_NONE, Op.ret);
+ inst_table["ldind.i1"] = new ILToken (Token.INSTR_NONE, Op.ldind_i1);
+ inst_table["ldind.u1"] = new ILToken (Token.INSTR_NONE, Op.ldind_u1);
+ inst_table["ldind.i2"] = new ILToken (Token.INSTR_NONE, Op.ldind_i2);
+ inst_table["ldind.u2"] = new ILToken (Token.INSTR_NONE, Op.ldind_u2);
+ inst_table["ldind.i4"] = new ILToken (Token.INSTR_NONE, Op.ldind_i4);
+ inst_table["ldind.u4"] = new ILToken (Token.INSTR_NONE, Op.ldind_u4);
+ inst_table["ldind.i8"] = new ILToken (Token.INSTR_NONE, Op.ldind_i8);
+ inst_table["ldind.u8"] = new ILToken (Token.INSTR_NONE, Op.ldind_i8);
+ inst_table["ldind.i"] = new ILToken (Token.INSTR_NONE, Op.ldind_i);
+ inst_table["ldind.r4"] = new ILToken (Token.INSTR_NONE, Op.ldind_r4);
+ inst_table["ldind.r8"] = new ILToken (Token.INSTR_NONE, Op.ldind_r8);
+ inst_table["ldind.ref"] = new ILToken (Token.INSTR_NONE, Op.ldind_ref);
+ inst_table["stind.ref"] = new ILToken (Token.INSTR_NONE, Op.stind_ref);
+ inst_table["stind.i1"] = new ILToken (Token.INSTR_NONE, Op.stind_i1);
+ inst_table["stind.i2"] = new ILToken (Token.INSTR_NONE, Op.stind_i2);
+ inst_table["stind.i4"] = new ILToken (Token.INSTR_NONE, Op.stind_i4);
+ inst_table["stind.i8"] = new ILToken (Token.INSTR_NONE, Op.stind_i8);
+ inst_table["stind.r4"] = new ILToken (Token.INSTR_NONE, Op.stind_r4);
+ inst_table["stind.r8"] = new ILToken (Token.INSTR_NONE, Op.stind_r8);
+ inst_table["add"] = new ILToken (Token.INSTR_NONE, Op.add);
+ inst_table["sub"] = new ILToken (Token.INSTR_NONE, Op.sub);
+ inst_table["mul"] = new ILToken (Token.INSTR_NONE, Op.mul);
+ inst_table["div"] = new ILToken (Token.INSTR_NONE, Op.div);
+ inst_table["div.un"] = new ILToken (Token.INSTR_NONE, Op.div_un);
+ inst_table["rem"] = new ILToken (Token.INSTR_NONE, Op.rem);
+ inst_table["rem.un"] = new ILToken (Token.INSTR_NONE, Op.rem_un);
+ inst_table["and"] = new ILToken (Token.INSTR_NONE, Op.and);
+ inst_table["or"] = new ILToken (Token.INSTR_NONE, Op.or);
+ inst_table["xor"] = new ILToken (Token.INSTR_NONE, Op.xor);
+ inst_table["shl"] = new ILToken (Token.INSTR_NONE, Op.shl);
+ inst_table["shr"] = new ILToken (Token.INSTR_NONE, Op.shr);
+ inst_table["shr.un"] = new ILToken (Token.INSTR_NONE, Op.shr_un);
+ inst_table["neg"] = new ILToken (Token.INSTR_NONE, Op.neg);
+ inst_table["not"] = new ILToken (Token.INSTR_NONE, Op.not);
+ inst_table["conv.i1"] = new ILToken (Token.INSTR_NONE, Op.conv_i1);
+ inst_table["conv.i2"] = new ILToken (Token.INSTR_NONE, Op.conv_i2);
+ inst_table["conv.i4"] = new ILToken (Token.INSTR_NONE, Op.conv_i4);
+ inst_table["conv.i8"] = new ILToken (Token.INSTR_NONE, Op.conv_i8);
+ inst_table["conv.r4"] = new ILToken (Token.INSTR_NONE, Op.conv_r4);
+ inst_table["conv.r8"] = new ILToken (Token.INSTR_NONE, Op.conv_r8);
+ inst_table["conv.u4"] = new ILToken (Token.INSTR_NONE, Op.conv_u4);
+ inst_table["conv.u8"] = new ILToken (Token.INSTR_NONE, Op.conv_u8);
+ inst_table["conv.r.un"] = new ILToken (Token.INSTR_NONE, Op.conv_r_un);
+ inst_table["throw"] = new ILToken (Token.INSTR_NONE, Op.throwOp);
+ inst_table["conv.ovf.i1.un"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_i1_un);
+ inst_table["conv.ovf.i2.un"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_i2_un);
+ inst_table["conv.ovf.i4.un"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_i4_un);
+ inst_table["conv.ovf.i8.un"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_i8_un);
+ inst_table["conf.ovf.u1.un"] = new ILToken (Token.INSTR_NONE, Op.conf_ovf_u1_un);
+ inst_table["conv.ovf.u2.un"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_u2_un);
+ inst_table["conv.ovf.u4.un"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_u4_un);
+ inst_table["conv.ovf.u8.un"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_u8_un);
+ inst_table["conv.ovf.i.un"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_i_un);
+ inst_table["conv.ovf.u.un"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_u_un);
+ inst_table["ldlen"] = new ILToken (Token.INSTR_NONE, Op.ldlen);
+ inst_table["ldelem.i1"] = new ILToken (Token.INSTR_NONE, Op.ldelem_i1);
+ inst_table["ldelem.u1"] = new ILToken (Token.INSTR_NONE, Op.ldelem_u1);
+ inst_table["ldelem.i2"] = new ILToken (Token.INSTR_NONE, Op.ldelem_i2);
+ inst_table["ldelem.u2"] = new ILToken (Token.INSTR_NONE, Op.ldelem_u2);
+ inst_table["ldelem.i4"] = new ILToken (Token.INSTR_NONE, Op.ldelem_i4);
+ inst_table["ldelem.u4"] = new ILToken (Token.INSTR_NONE, Op.ldelem_u4);
+ inst_table["ldelem.i8"] = new ILToken (Token.INSTR_NONE, Op.ldelem_i8);
+ inst_table["ldelem.u8"] = new ILToken (Token.INSTR_NONE, Op.ldelem_i8);
+ inst_table["ldelem.i"] = new ILToken (Token.INSTR_NONE, Op.ldelem_i);
+ inst_table["ldelem.r4"] = new ILToken (Token.INSTR_NONE, Op.ldelem_r4);
+ inst_table["ldelem.r8"] = new ILToken (Token.INSTR_NONE, Op.ldelem_r8);
+ inst_table["ldelem.ref"] = new ILToken (Token.INSTR_NONE, Op.ldelem_ref);
+ inst_table["stelem.i"] = new ILToken (Token.INSTR_NONE, Op.stelem_i);
+ inst_table["stelem.i1"] = new ILToken (Token.INSTR_NONE, Op.stelem_i1);
+ inst_table["stelem.i2"] = new ILToken (Token.INSTR_NONE, Op.stelem_i2);
+ inst_table["stelem.i4"] = new ILToken (Token.INSTR_NONE, Op.stelem_i4);
+ inst_table["stelem.i8"] = new ILToken (Token.INSTR_NONE, Op.stelem_i8);
+ inst_table["stelem.r4"] = new ILToken (Token.INSTR_NONE, Op.stelem_r4);
+ inst_table["stelem.r8"] = new ILToken (Token.INSTR_NONE, Op.stelem_r8);
+ inst_table["stelem.ref"] = new ILToken (Token.INSTR_NONE, Op.stelem_ref);
+ inst_table["conv.ovf.i1"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_i1);
+ inst_table["conv.ovf.u1"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_u1);
+ inst_table["conv.ovf.i2"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_i2);
+ inst_table["conv.ovf.u2"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_u2);
+ inst_table["conv.ovf.i4"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_i4);
+ inst_table["conv.ovf.u4"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_u4);
+ inst_table["conv.ovf.i8"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_i8);
+ inst_table["conv.ovf.u8"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_u8);
+ inst_table["conv.ovf.u1.un"] = new ILToken (Token.INSTR_NONE, Op.conf_ovf_u1_un);
+ inst_table["conv.ovf.u2.un"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_u2_un);
+ inst_table["conv.ovf.u4.un"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_u4_un);
+ inst_table["conv.ovf.u8.un"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_u8_un);
+ inst_table["conv.ovf.i1.un"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_i1_un);
+ inst_table["conv.ovf.i2.un"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_i2_un);
+ inst_table["conv.ovf.i4.un"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_i4_un);
+ inst_table["conv.ovf.i8.un"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_i8_un);
+ inst_table["ckfinite"] = new ILToken (Token.INSTR_NONE, Op.ckfinite);
+ inst_table["conv.u2"] = new ILToken (Token.INSTR_NONE, Op.conv_u2);
+ inst_table["conv.u1"] = new ILToken (Token.INSTR_NONE, Op.conv_u1);
+ inst_table["conv.i"] = new ILToken (Token.INSTR_NONE, Op.conv_i);
+ inst_table["conv.ovf.i"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_i);
+ inst_table["conv.ovf.u"] = new ILToken (Token.INSTR_NONE, Op.conv_ovf_u);
+ inst_table["add.ovf"] = new ILToken (Token.INSTR_NONE, Op.add_ovf);
+ inst_table["add.ovf.un"] = new ILToken (Token.INSTR_NONE, Op.add_ovf_un);
+ inst_table["mul.ovf"] = new ILToken (Token.INSTR_NONE, Op.mul_ovf);
+ inst_table["mul.ovf.un"] = new ILToken (Token.INSTR_NONE, Op.mul_ovf_un);
+ inst_table["sub.ovf"] = new ILToken (Token.INSTR_NONE, Op.sub_ovf);
+ inst_table["sub.ovf.un"] = new ILToken (Token.INSTR_NONE, Op.sub_ovf_un);
+ inst_table["endfinally"] = new ILToken (Token.INSTR_NONE, Op.endfinally);
+ // endfault is really just an alias for endfinally
+ inst_table["endfault"] = new ILToken (Token.INSTR_NONE, Op.endfinally);
+ inst_table["stind.i"] = new ILToken (Token.INSTR_NONE, Op.stind_i);
+ inst_table["conv.u"] = new ILToken (Token.INSTR_NONE, Op.conv_u);
+ inst_table["arglist"] = new ILToken (Token.INSTR_NONE, Op.arglist);
+ inst_table["ceq"] = new ILToken (Token.INSTR_NONE, Op.ceq);
+ inst_table["cgt"] = new ILToken (Token.INSTR_NONE, Op.cgt);
+ inst_table["cgt.un"] = new ILToken (Token.INSTR_NONE, Op.cgt_un);
+ inst_table["clt"] = new ILToken (Token.INSTR_NONE, Op.clt);
+ inst_table["clt.un"] = new ILToken (Token.INSTR_NONE, Op.clt_un);
+ inst_table["localloc"] = new ILToken (Token.INSTR_NONE, Op.localloc);
+ inst_table["endfilter"] = new ILToken (Token.INSTR_NONE, Op.endfilter);
+ inst_table["volatile."] = new ILToken (Token.INSTR_NONE, Op.volatile_);
+ inst_table["tail."] = new ILToken (Token.INSTR_NONE, Op.tail_);
+ inst_table["cpblk"] = new ILToken (Token.INSTR_NONE, Op.cpblk);
+ inst_table["initblk"] = new ILToken (Token.INSTR_NONE, Op.initblk);
+ inst_table["rethrow"] = new ILToken (Token.INSTR_NONE, Op.rethrow);
+ inst_table["refanytype"] = new ILToken (Token.INSTR_NONE, Op.refanytype);
+ inst_table["readonly."] = new ILToken (Token.INSTR_NONE, Op.readonly_);
+
+ //
+ // Int operations
+ //
+
+ // param
+ inst_table["ldarg"] = new ILToken (Token.INSTR_PARAM, IntOp.ldarg);
+ inst_table["ldarga"] = new ILToken (Token.INSTR_PARAM, IntOp.ldarga);
+ inst_table["starg"] = new ILToken (Token.INSTR_PARAM, IntOp.starg);
+ inst_table["ldarg.s"] = new ILToken (Token.INSTR_PARAM, IntOp.ldarg_s);
+ inst_table["ldarga.s"] = new ILToken (Token.INSTR_PARAM, IntOp.ldarga_s);
+ inst_table["starg.s"] = new ILToken (Token.INSTR_PARAM, IntOp.starg_s);
+
+ // local
+ inst_table["ldloc"] = new ILToken (Token.INSTR_LOCAL, IntOp.ldloc);
+ inst_table["ldloca"] = new ILToken (Token.INSTR_LOCAL, IntOp.ldloca);
+ inst_table["stloc"] = new ILToken (Token.INSTR_LOCAL, IntOp.stloc);
+ inst_table["ldloc.s"] = new ILToken (Token.INSTR_LOCAL, IntOp.ldloc_s);
+ inst_table["ldloca.s"] = new ILToken (Token.INSTR_LOCAL, IntOp.ldloca_s);
+ inst_table["stloc.s"] = new ILToken (Token.INSTR_LOCAL, IntOp.stloc_s);
+
+ inst_table["ldc.i4.s"] = new ILToken (Token.INSTR_I, IntOp.ldc_i4_s);
+ inst_table["ldc.i4"] = new ILToken (Token.INSTR_I, IntOp.ldc_i4);
+ inst_table["unaligned."] = new ILToken (Token.INSTR_I, IntOp.unaligned);
+
+ //
+ // Type operations
+ //
+
+ inst_table["cpobj"] = new ILToken (Token.INSTR_TYPE, TypeOp.cpobj);
+ inst_table["ldobj"] = new ILToken (Token.INSTR_TYPE, TypeOp.ldobj);
+ inst_table["castclass"] = new ILToken (Token.INSTR_TYPE, TypeOp.castclass);
+ inst_table["isinst"] = new ILToken (Token.INSTR_TYPE, TypeOp.isinst);
+ inst_table["unbox"] = new ILToken (Token.INSTR_TYPE, TypeOp.unbox);
+ inst_table["unbox.any"] = new ILToken (Token.INSTR_TYPE, TypeOp.unbox_any);
+ inst_table["stobj"] = new ILToken (Token.INSTR_TYPE, TypeOp.stobj);
+ inst_table["box"] = new ILToken (Token.INSTR_TYPE, TypeOp.box);
+ inst_table["newarr"] = new ILToken (Token.INSTR_TYPE, TypeOp.newarr);
+ inst_table["ldelema"] = new ILToken (Token.INSTR_TYPE, TypeOp.ldelema);
+ inst_table["refanyval"] = new ILToken (Token.INSTR_TYPE, TypeOp.refanyval);
+ inst_table["mkrefany"] = new ILToken (Token.INSTR_TYPE, TypeOp.mkrefany);
+ inst_table["initobj"] = new ILToken (Token.INSTR_TYPE, TypeOp.initobj);
+ inst_table["sizeof"] = new ILToken (Token.INSTR_TYPE, TypeOp.sizeOf);
+ inst_table["stelem"] = new ILToken (Token.INSTR_TYPE, TypeOp.stelem);
+ inst_table["ldelem"] = new ILToken (Token.INSTR_TYPE, TypeOp.ldelem);
+ inst_table["stelem.any"] = new ILToken (Token.INSTR_TYPE, TypeOp.stelem);
+ inst_table["ldelem.any"] = new ILToken (Token.INSTR_TYPE, TypeOp.ldelem);
+ inst_table["constrained."] = new ILToken (Token.INSTR_TYPE, TypeOp.constrained);
+
+ //
+ // MethodRef operations
+ //
+
+ inst_table["jmp"] = new ILToken (Token.INSTR_METHOD, MethodOp.jmp);
+ inst_table["call"] = new ILToken (Token.INSTR_METHOD, MethodOp.call);
+ inst_table["callvirt"] = new ILToken (Token.INSTR_METHOD, MethodOp.callvirt);
+ inst_table["newobj"] = new ILToken (Token.INSTR_METHOD, MethodOp.newobj);
+ inst_table["ldftn"] = new ILToken (Token.INSTR_METHOD, MethodOp.ldftn);
+ inst_table["ldvirtftn"] = new ILToken (Token.INSTR_METHOD, MethodOp.ldvirtfn);
+
+ //
+ // FieldRef instructions
+ //
+
+ inst_table["ldfld"] = new ILToken (Token.INSTR_FIELD, FieldOp.ldfld);
+ inst_table["ldflda"] = new ILToken (Token.INSTR_FIELD, FieldOp.ldflda);
+ inst_table["stfld"] = new ILToken (Token.INSTR_FIELD, FieldOp.stfld);
+ inst_table["ldsfld"] = new ILToken (Token.INSTR_FIELD, FieldOp.ldsfld);
+ inst_table["ldsflda"] = new ILToken (Token.INSTR_FIELD, FieldOp.ldsflda);
+ inst_table["stsfld"] = new ILToken (Token.INSTR_FIELD, FieldOp.stsfld);
+
+ //
+ // Branch Instructions
+ //
+
+ inst_table["br"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.br);
+ inst_table["brfalse"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.brfalse);
+ inst_table["brnull"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.brfalse);
+ inst_table["brtrue"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.brtrue);
+ inst_table["beq"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.beq);
+ inst_table["bge"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.bge);
+ inst_table["bgt"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.bgt);
+ inst_table["ble"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.ble);
+ inst_table["blt"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.blt);
+ inst_table["bne.un"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.bne_un);
+ inst_table["bge.un"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.bge_un);
+ inst_table["bgt.un"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.bgt_un);
+ inst_table["ble.un"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.ble_un);
+ inst_table["blt.un"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.blt_un);
+ inst_table["leave"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.leave);
+
+ inst_table["br.s"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.br_s);
+ inst_table["brfalse.s"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.brfalse_s);
+ inst_table["brtrue.s"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.brtrue_s);
+ inst_table["beq.s"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.beq_s);
+ inst_table["bge.s"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.bge_s);
+ inst_table["bgt.s"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.bgt_s);
+ inst_table["ble.s"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.ble_s);
+ inst_table["blt.s"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.blt_s);
+ inst_table["bne.un.s"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.bne_un_s);
+ inst_table["bge.un.s"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.bge_un_s);
+ inst_table["bgt.un.s"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.bgt_un_s);
+ inst_table["ble.un.s"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.ble_un_s);
+ inst_table["blt.un.s"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.blt_un_s);
+ inst_table["leave.s"] = new ILToken (Token.INSTR_BRTARGET, BranchOp.leave_s);
+
+ //
+ // Misc other instructions
+ //
+
+ inst_table["ldstr"] = new ILToken (Token.INSTR_STRING, MiscInstr.ldstr);
+ inst_table["ldc.r4"] = new ILToken (Token.INSTR_R, MiscInstr.ldc_r4);
+ inst_table["ldc.r8"] = new ILToken (Token.INSTR_R, MiscInstr.ldc_r8);
+ inst_table["ldc.i8"] = new ILToken (Token.INSTR_I8, MiscInstr.ldc_i8);
+ inst_table["switch"] = new ILToken (Token.INSTR_SWITCH, MiscInstr._switch);
+ inst_table["calli"] = new ILToken (Token.INSTR_SIG, MiscInstr.calli);
+ inst_table["ldtoken"] = new ILToken (Token.INSTR_TOK, MiscInstr.ldtoken);
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/Instructions.cs b/mcs/ilasm/codegen/Instructions.cs
new file mode 100644
index 00000000000..281b9fd87bf
--- /dev/null
+++ b/mcs/ilasm/codegen/Instructions.cs
@@ -0,0 +1,291 @@
+// Instructions.cs
+// (C) Sergey Chaban (serge@wildwestsoftware.com)
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+
+ /// <summary>
+ /// </summary>
+ public class InstrNone : InstrBase {
+
+ /// <summary>
+ /// </summary>
+ /// <param name="tok"></param>
+ public InstrNone (OpCode op) : base (op)
+ {
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <param name="ilgen"></param>
+ public override void Emit (ILGenerator ilgen, Class host)
+ {
+ ilgen.Emit (this.Opcode);
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public class InstrVar : InstrBase {
+
+ private object operand;
+
+ /// <summary>
+ /// </summary>
+ /// <param name="tok"></param>
+ public InstrVar (OpCode op, object operand) : base (op)
+ {
+ this.operand = operand;
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="ilgen"></param>
+ public override void Emit (ILGenerator ilgen, Class host)
+ {
+ if (operand is string) {
+ ilgen.Emit (Opcode, operand as string);
+ } else if (operand is Int32) {
+ ilgen.Emit (Opcode, (Int32)operand);
+ }
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public class InstrI : InstrBase {
+
+ private int operand;
+
+ /// <summary>
+ /// </summary>
+ /// <param name="tok"></param>
+ public InstrI (OpCode op, int operand) : base (op) {
+ this.operand = operand;
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="ilgen"></param>
+ public override void Emit (ILGenerator ilgen, Class host) {
+ ilgen.Emit (Opcode, operand);
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public class InstrI8 : InstrBase {
+
+ private long operand;
+
+ /// <summary>
+ /// </summary>
+ /// <param name="tok"></param>
+ public InstrI8 (OpCode op, long operand) : base (op) {
+ this.operand = operand;
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="ilgen"></param>
+ public override void Emit (ILGenerator ilgen, Class host) {
+ ilgen.Emit (Opcode, operand);
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public class InstrR : InstrBase {
+
+ private double operand;
+
+ /// <summary>
+ /// </summary>
+ /// <param name="tok"></param>
+ public InstrR (OpCode op, double operand) : base (op) {
+ this.operand = operand;
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="ilgen"></param>
+ public override void Emit (ILGenerator ilgen, Class host) {
+ if (Opcode.Name.IndexOf (".r4") != -1) {
+ ilgen.Emit (Opcode, (float) operand);
+ } else {
+ ilgen.Emit (Opcode, operand);
+ }
+ }
+ }
+
+
+
+ /// <summary>
+ /// </summary>
+ public class InstrString : InstrBase {
+
+ private string operand;
+
+ /// <summary>
+ /// </summary>
+ /// <param name="tok"></param>
+ public InstrString (OpCode op, string operand) : base (op) {
+ this.operand = operand;
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="ilgen"></param>
+ public override void Emit (ILGenerator ilgen, Class host) {
+ ilgen.Emit (Opcode, operand);
+ }
+ }
+
+
+ /// <summary>
+ /// Base class for instructions that call methods
+ /// </summary>
+ public abstract class InstrCallBase : InstrBase {
+
+ private string return_type;
+ private string binding_flags;
+ private string calling_type;
+ private string method_name;
+ private ArrayList arg_list;
+
+ /// <summary>
+ /// </summary>
+ /// <param name="tok"></param>
+ public InstrCallBase (OpCode op, string binding_flags, string return_type,
+ string calling_type, string method_name, ArrayList arg_list) : base (op) {
+
+ this.binding_flags = binding_flags;
+ this.return_type = return_type;
+ this.calling_type = calling_type;
+ this.method_name = method_name;
+ this.arg_list = arg_list;
+
+ }
+
+ protected Type[] CreateArgsTypeArray (CodeGen code_gen)
+ {
+ if (arg_list == null)
+ return new Type[0];
+
+ int size = arg_list.Count;
+ Type[] type_array = new Type[size];
+
+ for (int i=0; i<size; i++) {
+ type_array[i] = code_gen.TypeManager[(string)arg_list[i]];
+ }
+
+ return type_array;
+ }
+
+ protected BindingFlags CreateBindingFlags ()
+ {
+ if ((binding_flags == null) || (binding_flags == String.Empty))
+ return (BindingFlags.Static | BindingFlags.Public);
+
+ BindingFlags return_flags = BindingFlags.Public;
+
+ switch (binding_flags) {
+ case "instance":
+ return_flags |= BindingFlags.Instance;
+ break;
+ }
+
+ return return_flags;
+ }
+
+
+ }
+
+ /// <summary>
+ /// call void System.Console::WriteLine(string)
+ /// </summary>
+ public class InstrCall : InstrCallBase {
+
+ /// <summary>
+ /// </summary>
+ /// <param name="tok"></param>
+ public InstrCall (OpCode op, string binding_flags, string return_type, string calling_type,
+ string method_name, ArrayList arg_list) : base (op, binding_flags,
+ return_type, calling_type, method_name, arg_list) {
+
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="ilgen"></param>
+ public override void Emit (ILGenerator ilgen, Class host) {
+ Type type_to_call = host.CodeGen.TypeManager[calling_type];
+ MethodInfo calling_method;
+
+ if (type_to_call == host.TypeBuilder) {
+ calling_method = host.GetMethod (method_name, CreateBindingFlags (),
+ CreateArgsTypeArray (host.CodeGen));
+ } else {
+ calling_method = type_to_call.GetMethod (method_name, CreateBindingFlags (),
+ null, CreateArgsTypeArray (host.CodeGen), null);
+ }
+
+ if (calling_method == null) {
+ Console.WriteLine ("Method does not exist: {0}.{1}", type_to_call, method_name);
+ return;
+ }
+
+ ilgen.Emit (Opcode, calling_method);
+
+ }
+
+ }
+
+ /// <summary>
+ /// </summary>
+ public class InstrNewobj : InstrCallBase {
+
+ /// <summary>
+ /// </summary>
+ /// <param name="tok"></param>
+ public InstrNewobj (OpCode op, string binding_flags, string return_type, string calling_type,
+ string method_name, ArrayList arg_list) : base (op, binding_flags,
+ return_type, calling_type, method_name, arg_list) {
+
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="ilgen"></param>
+ public override void Emit (ILGenerator ilgen, Class host) {
+ Type type_to_call = host.CodeGen.TypeManager[calling_type];
+ ConstructorInfo calling_constructor = null;
+
+ calling_constructor = type_to_call.GetConstructor (CreateArgsTypeArray (host.CodeGen));
+
+ if (calling_constructor == null) {
+ Console.WriteLine ("Constructor does not exist for: {0}", type_to_call);
+ return;
+ }
+
+ ilgen.Emit (Opcode, calling_constructor);
+ }
+ }
+}
+
diff --git a/mcs/ilasm/codegen/IntInstr.cs b/mcs/ilasm/codegen/IntInstr.cs
new file mode 100644
index 00000000000..587c678bac7
--- /dev/null
+++ b/mcs/ilasm/codegen/IntInstr.cs
@@ -0,0 +1,36 @@
+//
+// Mono.ILASM.IntInstr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class IntInstr : IInstr {
+
+ private PEAPI.IntOp op;
+ private int operand;
+
+ public IntInstr (PEAPI.IntOp op, int operand, Location loc)
+ : base (loc)
+ {
+ this.op = op;
+ this.operand = operand;
+ }
+
+ public override void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
+ {
+ cil.IntInst (op, operand);
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/LabelInfo.cs b/mcs/ilasm/codegen/LabelInfo.cs
new file mode 100644
index 00000000000..328787729ad
--- /dev/null
+++ b/mcs/ilasm/codegen/LabelInfo.cs
@@ -0,0 +1,63 @@
+//
+// Mono.ILASM.LabelInfo
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class LabelInfo : IComparable {
+
+ public readonly string Name;
+ public readonly int Pos;
+ public readonly uint Offset;
+ public PEAPI.CILLabel Label;
+ public bool UseOffset;
+
+ public LabelInfo (string name, int pos, uint offset)
+ {
+ Name = name;
+ Pos = pos;
+ Offset = offset;
+ Label = null;
+ UseOffset = true;
+ }
+
+ public LabelInfo (string name, int pos)
+ {
+ Name = name;
+ Pos = pos;
+ Label = null;
+ UseOffset = false;
+ }
+
+ public void Define (PEAPI.CILLabel label)
+ {
+ Label = label;
+ }
+
+ public int CompareTo (object obj)
+ {
+ LabelInfo other = obj as LabelInfo;
+
+ if(other != null)
+ return Pos.CompareTo(other.Pos);
+
+ throw new InternalErrorException ("object is not a LabelInfo");
+ }
+
+ public override string ToString ()
+ {
+ if (Name != null)
+ return Name;
+ return "IL_" + Pos;
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/LdcInstr.cs b/mcs/ilasm/codegen/LdcInstr.cs
new file mode 100644
index 00000000000..186da7a285e
--- /dev/null
+++ b/mcs/ilasm/codegen/LdcInstr.cs
@@ -0,0 +1,54 @@
+//
+// Mono.ILASM.LdcInstr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class LdcInstr : IInstr {
+
+ private MiscInstr op;
+ private double d_operand;
+ private long l_operand;
+
+ public LdcInstr (MiscInstr op, double operand, Location loc)
+ : base (loc)
+ {
+ this.op = op;
+ d_operand = operand;
+ }
+
+ public LdcInstr (MiscInstr op, long operand, Location loc)
+ : base (loc)
+ {
+ this.op = op;
+ l_operand = operand;
+ }
+
+ public override void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
+ {
+ switch (op) {
+ case MiscInstr.ldc_r8:
+ cil.ldc_r8 (d_operand);
+ break;
+ case MiscInstr.ldc_r4:
+ cil.ldc_r4 ((float) d_operand);
+ break;
+ case MiscInstr.ldc_i8:
+ cil.ldc_i8 (l_operand);
+ break;
+ }
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/LdstrInstr.cs b/mcs/ilasm/codegen/LdstrInstr.cs
new file mode 100644
index 00000000000..aa4d8390d80
--- /dev/null
+++ b/mcs/ilasm/codegen/LdstrInstr.cs
@@ -0,0 +1,44 @@
+//
+// Mono.ILASM.LdstrInstr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class LdstrInstr : IInstr {
+
+ private string operand;
+ private byte[] b_operand;
+
+ public LdstrInstr (string operand, Location loc)
+ : base (loc)
+ {
+ this.operand = operand;
+ }
+
+ public LdstrInstr (byte[] b_operand, Location loc)
+ : base (loc)
+ {
+ this.b_operand = b_operand;
+ }
+
+ public override void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
+ {
+ if (operand != null)
+ cil.ldstr (operand);
+ else
+ cil.ldstr (b_operand);
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/LdtokenInstr.cs b/mcs/ilasm/codegen/LdtokenInstr.cs
new file mode 100644
index 00000000000..0accc421b63
--- /dev/null
+++ b/mcs/ilasm/codegen/LdtokenInstr.cs
@@ -0,0 +1,60 @@
+//
+// Mono.ILASM.LdtokenInstr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class LdtokenInstr : IInstr {
+
+ private IFieldRef field_ref;
+ private BaseMethodRef method_ref;
+ private BaseTypeRef type_ref;
+
+ public LdtokenInstr (IFieldRef field_ref, Location loc)
+ : base (loc)
+ {
+ this.field_ref = field_ref;
+ }
+
+ public LdtokenInstr (BaseMethodRef method_ref, Location loc)
+ : base (loc)
+ {
+ this.method_ref = method_ref;
+ }
+
+ public LdtokenInstr (BaseTypeRef type_ref, Location loc)
+ : base (loc)
+ {
+ this.type_ref = type_ref;
+ }
+
+ public override void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
+ {
+ if (field_ref != null) {
+ field_ref.Resolve (code_gen);
+ cil.FieldInst (PEAPI.FieldOp.ldtoken,
+ field_ref.PeapiField);
+ } else if (method_ref != null) {
+ method_ref.Resolve (code_gen);
+ cil.MethInst (PEAPI.MethodOp.ldtoken,
+ method_ref.PeapiMethod);
+ } else if (type_ref != null) {
+ type_ref.Resolve (code_gen);
+ cil.TypeInst (PEAPI.TypeOp.ldtoken,
+ type_ref.PeapiType);
+ }
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/Local.cs b/mcs/ilasm/codegen/Local.cs
new file mode 100644
index 00000000000..2951fa0bfa9
--- /dev/null
+++ b/mcs/ilasm/codegen/Local.cs
@@ -0,0 +1,62 @@
+//
+// Mono.ILASM.Local
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+
+namespace Mono.ILASM {
+
+ public class Local {
+
+ private int slot;
+ private string name;
+ private BaseTypeRef type;
+
+ public Local (int slot, BaseTypeRef type) : this (slot, null, type) {
+
+ }
+
+ public Local (int slot, string name, BaseTypeRef type) {
+ this.slot = slot;
+ this.name = name;
+ this.type = type;
+ }
+
+ public int Slot {
+ get { return slot; }
+ set { slot = value; }
+ }
+
+ public string Name {
+ get { return name; }
+ }
+
+ public BaseTypeRef Type {
+ get { return type; }
+ }
+
+ public PEAPI.Local GetPeapiLocal (CodeGen code_gen)
+ {
+ int ec = Report.ErrorCount;
+ BaseGenericTypeRef gtr = type as BaseGenericTypeRef;
+ if (gtr == null)
+ type.Resolve (code_gen);
+ else
+ gtr.ResolveNoTypeSpec (code_gen);
+
+ if (Report.ErrorCount > ec)
+ return null;
+
+ return new PEAPI.Local (name, type.PeapiType);
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/Location.cs b/mcs/ilasm/codegen/Location.cs
new file mode 100644
index 00000000000..2fc4637e158
--- /dev/null
+++ b/mcs/ilasm/codegen/Location.cs
@@ -0,0 +1,22 @@
+//
+// Mono.ILASM.Location.cs
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+using System;
+
+namespace Mono.ILASM {
+
+ /// TODO: This class will eventually store il file location info,
+ /// like line and col
+ public class Location
+ {
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/Method.cs b/mcs/ilasm/codegen/Method.cs
new file mode 100644
index 00000000000..a52ce897319
--- /dev/null
+++ b/mcs/ilasm/codegen/Method.cs
@@ -0,0 +1,280 @@
+// Method.cs
+// (C) Sergey Chaban (serge@wildwestsoftware.com)
+
+using System;
+using System.Collections;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.ILASM {
+
+
+ public class MethodName {
+ private static int methodCount = 0;
+
+ private bool isCtor;
+ private string name;
+
+ /// <summary>
+ /// </summary>
+ public MethodName () : this ("M_" + (methodCount++))
+ {
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <param name="name"></param>
+ public MethodName (string name) : this (name, false)
+ {
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <param name="name"></param>
+ /// <param name="ctor"></param>
+ public MethodName (string name, bool ctor)
+ {
+ this.name = name;
+ this.isCtor = ctor;
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public string Name {
+ get {
+ return name;
+ }
+ set {
+ name = value;
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public bool IsCtor {
+ get {
+ return isCtor;
+ }
+ set {
+ isCtor = value;
+ }
+ }
+
+ }
+
+
+
+ /// <summary>
+ /// </summary>
+ public class Method {
+
+ private MethodName name;
+ private MethodAttributes attrs;
+ private CallingConventions callConv;
+ private string retType;
+ private MethodBuilder method_builder;
+ private bool entry_point = false;
+
+ private ArrayList param_list;
+ private ArrayList instructions;
+ private ArrayList local_list;
+
+ /// <summary>
+ /// </summary>
+ public Method ()
+ {
+ name = new MethodName ();
+ attrs = 0;
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public string Name {
+ get {
+ return name.Name;
+ }
+ set {
+ name.Name = value;
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="name"></param>
+ public void SetMethodName (MethodName name)
+ {
+ this.name = name;
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public bool IsCtor {
+ get {
+ return name.IsCtor;
+ }
+ set {
+ name.IsCtor = value;
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public string RetType {
+ get {
+ return retType;
+ }
+ set {
+ retType = value;
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public MethodAttributes Attrs {
+ get {
+ return attrs;
+ }
+ set {
+ attrs = value;
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public CallingConventions CallConv {
+ get {
+ return callConv;
+ }
+ set {
+ callConv = value;
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public bool IsEntryPoint {
+ get {
+ return entry_point;
+ }
+ set {
+ entry_point = value;
+ }
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <param name="instr"></param>
+ public void AddInstruction (InstrBase instr)
+ {
+ if (instr == null) {
+ throw new InternalErrorException ("<null> instruction");
+ }
+
+ if (instructions == null) {
+ this.instructions = new ArrayList ();
+ }
+
+ instructions.Add (instr);
+ }
+
+ public void AddLocal (DictionaryEntry local)
+ {
+ if (local_list == null)
+ local_list = new ArrayList ();
+
+ local_list.Add (local);
+
+ }
+
+ public void SetParamList (ArrayList param_list)
+ {
+ this.param_list = param_list;
+ }
+
+ /// <summary>
+ /// </summary>
+ public int InstrCount {
+ get {
+ return (instructions != null) ? instructions.Count : 0;
+ }
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <returns></returns>
+ public override string ToString ()
+ {
+ return String.Format ("IL.Method [Name: {0}, Attrs: {1}, CallConv: {2}, RetType: {3}, Instr: {4}]",
+ Name, Attrs, CallConv, RetType, InstrCount);
+ }
+
+ public MethodBuilder Builder {
+ get {
+ return method_builder;
+ }
+ }
+
+ public void Resolve (Class host)
+ {
+ Type return_type = host.CodeGen.TypeManager[RetType];
+ method_builder = host.TypeBuilder.DefineMethod (Name, Attrs,
+ CallConv, return_type, CreateTypeList (host.CodeGen.TypeManager));
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <param name="tb"></param>
+ public void Emit (Class host)
+ {
+ TypeBuilder tb = host.TypeBuilder;
+
+ if (IsCtor) {
+ } else {
+ ILGenerator ilgen = method_builder.GetILGenerator ();
+
+ if (local_list != null) {
+ foreach (DictionaryEntry local in local_list) {
+ Type local_type = host.CodeGen.TypeManager[(string)local.Key];
+ if (local_type == null) {
+ Console.WriteLine ("Could not find type: {0}", local.Key);
+ return;
+ }
+ ilgen.DeclareLocal (local_type);
+ }
+ }
+
+ if (instructions != null) {
+ foreach (InstrBase instr in instructions)
+ instr.Emit (ilgen, host);
+ }
+ }
+ }
+
+ private Type[] CreateTypeList (TypeManager type_manager)
+ {
+ if (param_list == null)
+ return new Type[0];
+
+ int count = param_list.Count;
+ Type[] type_list = new Type[count];
+
+ for (int i=0; i<count; i++) {
+ type_list[i] = type_manager[(string) param_list[i]];
+ }
+
+ return type_list;
+ }
+
+ }
+
+
+}
diff --git a/mcs/ilasm/codegen/MethodDef.cs b/mcs/ilasm/codegen/MethodDef.cs
new file mode 100644
index 00000000000..8ed1268534e
--- /dev/null
+++ b/mcs/ilasm/codegen/MethodDef.cs
@@ -0,0 +1,751 @@
+//
+// Mono.ILASM.MethodDef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+using System.Text;
+using System.Collections;
+using System.Security;
+
+namespace Mono.ILASM {
+
+ public class MethodDef : ICustomAttrTarget, IDeclSecurityTarget {
+
+ private PEAPI.MethAttr meth_attr;
+ private PEAPI.CallConv call_conv;
+ private PEAPI.ImplAttr impl_attr;
+ private string name;
+ private string signature;
+ private Hashtable vararg_sig_table;
+ private BaseTypeRef ret_type;
+ private ArrayList param_list;
+ private ArrayList inst_list;
+ private ArrayList customattr_list;
+ private DeclSecurity decl_sec;
+ private Hashtable label_table;
+ private Hashtable labelref_table;
+ private ArrayList label_list;
+ private PEAPI.MethodDef methoddef;
+ private bool entry_point;
+ private bool zero_init;
+ private bool is_resolved;
+ private bool is_defined;
+ private ArrayList local_list;
+ private Hashtable named_local_table;
+ private bool init_locals;
+ private int max_stack;
+ private bool pinvoke_info;
+ private ExternModule pinvoke_mod;
+ private string pinvoke_name;
+ private PEAPI.PInvokeAttr pinvoke_attr;
+ private SourceMethod source;
+ private PEAPI.NativeType ret_native_type;
+ private TypeDef type_def;
+ private GenericParameters gen_params;
+
+ public MethodDef (CodeGen codegen, PEAPI.MethAttr meth_attr,
+ PEAPI.CallConv call_conv, PEAPI.ImplAttr impl_attr,
+ string name, BaseTypeRef ret_type, ArrayList param_list,
+ Location start, GenericParameters gen_params, TypeDef type_def)
+ {
+ this.meth_attr = meth_attr;
+ this.call_conv = call_conv;
+ this.impl_attr = impl_attr;
+ this.name = name;
+ this.ret_type = ret_type;
+ this.param_list = param_list;
+ this.type_def = type_def;
+ this.gen_params = gen_params;
+
+ inst_list = new ArrayList ();
+ label_table = new Hashtable ();
+ labelref_table = new Hashtable ();
+ label_list = new ArrayList ();
+ local_list = new ArrayList ();
+ named_local_table = new Hashtable ();
+
+ entry_point = false;
+ zero_init = false;
+ init_locals = false;
+ max_stack = -1;
+ pinvoke_info = false;
+
+ is_defined = false;
+ is_resolved = false;
+ ResolveGenParams ();
+ CreateSignature ();
+
+ codegen.BeginMethodDef (this);
+
+ if (codegen.SymbolWriter != null)
+ source = codegen.SymbolWriter.BeginMethod (this, start);
+ }
+
+ public string Name {
+ get { return name; }
+ }
+
+ public string Signature {
+ get { return signature; }
+ }
+
+ public BaseTypeRef RetType {
+ get { return ret_type; }
+ }
+
+ public PEAPI.CallConv CallConv {
+ get { return call_conv; }
+ }
+
+ public PEAPI.MethodDef PeapiMethodDef {
+ get { return methoddef; }
+ }
+
+ public PEAPI.MethAttr Attributes {
+ get { return meth_attr; }
+ set { meth_attr = value; }
+ }
+
+ public bool IsVararg {
+ get { return (call_conv & PEAPI.CallConv.Vararg) != 0; }
+ }
+
+ public bool IsStatic {
+ get { return (meth_attr & PEAPI.MethAttr.Static) != 0; }
+ }
+
+ public bool IsVirtual {
+ get { return (meth_attr & PEAPI.MethAttr.Virtual) != 0; }
+ }
+
+ public bool IsAbstract {
+ get { return (meth_attr & PEAPI.MethAttr.Abstract) != 0; }
+ }
+
+ public BaseTypeRef[] ParamTypeList () {
+
+ if (param_list == null)
+ return new BaseTypeRef[0];
+ int count = 0;
+ BaseTypeRef[] type_list = new BaseTypeRef[param_list.Count];
+ foreach (ParamDef param in param_list) {
+ type_list[count++] = param.Type;
+ }
+ return type_list;
+ }
+
+ public void AddPInvokeInfo (PEAPI.PInvokeAttr pinvoke_attr, ExternModule pinvoke_mod,
+ string pinvoke_name)
+ {
+ this.pinvoke_attr = pinvoke_attr;
+ this.pinvoke_mod = pinvoke_mod;
+ this.pinvoke_name = pinvoke_name;
+ pinvoke_info = true;
+ }
+
+ public int GenParamCount {
+ get { return (gen_params != null ? gen_params.Count : 0); }
+ }
+
+ public GenericParameter GetGenericParam (string id)
+ {
+ if (gen_params == null)
+ return null;
+
+ return gen_params.GetGenericParam (id);
+ }
+
+ public GenericParameter GetGenericParam (int index)
+ {
+ if (gen_params == null || index < 0 || index >= gen_params.Count)
+ return null;
+
+ return gen_params [index];
+ }
+
+ public int GetGenericParamNum (string id)
+ {
+ if (gen_params == null)
+ return -1;
+
+ return gen_params.GetGenericParamNum (id);
+ }
+
+ public void AddParamDefaultValue (int index, PEAPI.Constant defval)
+ {
+ if (param_list [index] != null) {
+ ((ParamDef)param_list [index]).AddDefaultValue (defval);
+ }
+ }
+
+ public void AddCustomAttribute (CustomAttr customattr)
+ {
+ if (customattr_list == null)
+ customattr_list = new ArrayList ();
+
+ customattr_list.Add (customattr);
+ }
+
+ public void AddPermissionSet (PEAPI.SecurityAction sec_action, PermissionSet ps)
+ {
+ if (decl_sec == null)
+ decl_sec = new DeclSecurity ();
+
+ decl_sec.AddPermissionSet (sec_action, ps);
+ }
+
+ public void AddPermission (PEAPI.SecurityAction sec_action, IPermission iper)
+ {
+ if (decl_sec == null)
+ decl_sec = new DeclSecurity ();
+
+ decl_sec.AddPermission (sec_action, iper);
+ }
+
+ public void AddRetTypeMarshalInfo (PEAPI.NativeType native_type)
+ {
+ this.ret_native_type = native_type;
+ }
+
+ public void AddLocals (ArrayList local_list)
+ {
+ int slot_pos = this.local_list.Count;
+
+ foreach (Local local in local_list) {
+ if (local.Slot == -1) {
+ local.Slot = slot_pos;
+ }
+ slot_pos++;
+ if (local.Name == null)
+ continue;
+ if(!named_local_table.Contains(local.Name))
+ named_local_table.Add (local.Name, local);
+ }
+
+ this.local_list.AddRange (local_list);
+ }
+
+ public Local GetNamedLocal (string name)
+ {
+ return (Local) named_local_table[name];
+ }
+
+ public int GetNamedLocalSlot (string name)
+ {
+ Local local = (Local) named_local_table[name];
+
+ return local.Slot;
+ }
+
+ public int GetNamedParamPos (string name)
+ {
+ int pos = -1;
+ if (!IsStatic)
+ pos ++;
+ foreach (ParamDef param in param_list) {
+ pos ++;
+ if (param.Name.CompareTo (name) == 0)
+ return pos;
+ }
+
+ return pos;
+ }
+
+ public ParamDef GetParam (int index)
+ {
+ if (param_list [index] != null)
+ return (ParamDef)param_list [index];
+ else
+ return null;
+ }
+
+ public void InitLocals ()
+ {
+ init_locals = true;
+ }
+
+ public void EntryPoint ()
+ {
+ if (!IsStatic)
+ Report.Error ("Non-static method as entrypoint.");
+ entry_point = true;
+ }
+
+ public void ZeroInit ()
+ {
+ zero_init = true;
+ }
+
+ public void SetMaxStack (int max_stack)
+ {
+ this.max_stack = max_stack;
+ }
+
+ public void ResolveGenParam (PEAPI.GenParam gpar)
+ {
+ if (gpar.Index != -1)
+ return;
+
+ if (gpar.Type == PEAPI.GenParamType.MVar)
+ gpar.Index = GetGenericParamNum (gpar.Name);
+ else
+ gpar.Index = type_def.GetGenericParamNum (gpar.Name);
+
+ if (gpar.Index < 0)
+ Report.Error (String.Format ("Invalid {0}type parameter '{1}'",
+ (gpar.Type == PEAPI.GenParamType.MVar ? "method " : ""),
+ gpar.Name));
+ }
+
+ public void ResolveGenParams ()
+ {
+ GenericParameters type_params = (type_def != null) ? type_def.TypeParameters : null;
+
+ if (gen_params == null && type_params == null)
+ return;
+
+ if (gen_params != null)
+ gen_params.ResolveConstraints (type_params, gen_params);
+
+ BaseGenericTypeRef gtr = ret_type as BaseGenericTypeRef;
+ if (gtr != null)
+ gtr.Resolve (type_params, gen_params);
+
+ if (param_list == null)
+ return;
+
+ foreach (ParamDef param in param_list) {
+ gtr = param.Type as BaseGenericTypeRef;
+ if (gtr != null)
+ gtr.Resolve (type_params, gen_params);
+ }
+ }
+
+ public PEAPI.MethodDef Resolve (CodeGen code_gen)
+ {
+ return Resolve (code_gen, null);
+ }
+
+ public PEAPI.MethodDef Resolve (CodeGen code_gen, PEAPI.ClassDef classdef)
+ {
+ if (is_resolved)
+ return methoddef;
+
+ PEAPI.Param [] param_array = GenerateParams (code_gen);
+ FixAttributes ();
+ ret_type.Resolve (code_gen);
+
+ if (classdef == null)
+ methoddef = code_gen.PEFile.AddMethod (meth_attr, impl_attr,
+ name, ret_type.PeapiType, param_array);
+ else
+ methoddef = classdef.AddMethod (meth_attr, impl_attr,
+ name, ret_type.PeapiType, param_array);
+
+ methoddef.AddCallConv (call_conv);
+
+ if (ret_native_type != null)
+ methoddef.AddRetTypeMarshallInfo (ret_native_type);
+
+ is_resolved = true;
+
+ return methoddef;
+ }
+
+ private PEAPI.Param [] GenerateParams (CodeGen code_gen)
+ {
+ PEAPI.Param[] param_array;
+
+ if (param_list != null && param_list.Count > 0) {
+ int param_count = param_list.Count;
+
+ // Remove the last param if its the sentinel, not sure what
+ // should happen with more then one sentinel
+ ParamDef last = (ParamDef) param_list [param_count-1];
+ if (last.IsSentinel ())
+ param_count--;
+
+ param_array = new PEAPI.Param [param_count];
+ for (int i = 0; i < param_count; i++) {
+ ParamDef paramdef = (ParamDef) param_list [i];
+ paramdef.Define (code_gen);
+ param_array [i] = paramdef.PeapiParam;
+ }
+
+ } else {
+ param_array = new PEAPI.Param [0];
+ }
+
+ return param_array;
+ }
+
+ public PEAPI.MethodRef GetVarargSig (PEAPI.Type[] opt)
+ {
+ if (!is_resolved)
+ throw new InternalErrorException ("Methods must be resolved before a vararg sig can be created.");
+
+ PEAPI.MethodRef methref = null;
+ StringBuilder sigbuilder = new StringBuilder ();
+ string sig;
+ foreach (PEAPI.Type t in opt)
+ sigbuilder.Append (opt + ", ");
+ sig = sigbuilder.ToString ();
+
+ if (vararg_sig_table == null) {
+ vararg_sig_table = new Hashtable ();
+ } else {
+ methref = vararg_sig_table [sig] as PEAPI.MethodRef;
+ }
+
+ if (methref == null) {
+ methref = methoddef.MakeVarArgSignature (opt);
+ vararg_sig_table [sig] = methref;
+ }
+
+ return methref;
+ }
+
+ /// <summary>
+ /// Define a member method
+ /// </summary>
+ public void Define (CodeGen code_gen)
+ {
+ if (is_defined)
+ return;
+
+ if (type_def == null)
+ /* Global method */
+ Resolve (code_gen, null);
+ else
+ Resolve (code_gen, (PEAPI.ClassDef) type_def.ClassDef);
+
+ WriteCode (code_gen, methoddef);
+
+ //code_gen.Report.Message (String.Format ("Assembled method {0}::{1}", typedef.FullName, name));
+ is_defined = true;
+ }
+
+ public void AddInstr (IInstr instr)
+ {
+ inst_list.Add (instr);
+ }
+
+ protected void WriteCode (CodeGen code_gen, PEAPI.MethodDef methoddef)
+ {
+ /// Add the custrom attributes to this method
+ if (customattr_list != null)
+ foreach (CustomAttr customattr in customattr_list) {
+ customattr.AddTo (code_gen, methoddef);
+ if (customattr.IsSuppressUnmanaged (code_gen))
+ methoddef.AddMethAttribute (PEAPI.MethAttr.HasSecurity);
+ }
+
+ /// Add declarative security to this method
+ if (decl_sec != null) {
+ decl_sec.AddTo (code_gen, methoddef);
+ methoddef.AddMethAttribute (PEAPI.MethAttr.HasSecurity);
+ }
+
+ // Generic type parameters
+ if (gen_params != null)
+ gen_params.Resolve (code_gen, methoddef);
+
+ if (IsAbstract)
+ return;
+
+ if (entry_point)
+ methoddef.DeclareEntryPoint ();
+
+ if (local_list.Count > 0) {
+ int ec = Report.ErrorCount;
+ PEAPI.Local[] local_array = new PEAPI.Local[local_list.Count];
+
+ foreach (Local local in local_list)
+ local_array[local.Slot] = local.GetPeapiLocal (code_gen);
+
+ if (Report.ErrorCount > ec)
+ return;
+
+ if (zero_init)
+ init_locals = true;
+
+ methoddef.AddLocals (local_array, init_locals);
+ }
+
+ /// Nothing seems to work if maxstack is not set,
+ /// i need to find out if this NEEDs to be set
+ /// and what its default value should be
+ if (max_stack < 0)
+ max_stack = 8;
+ methoddef.SetMaxStack (max_stack);
+
+ if (pinvoke_info) {
+ methoddef.AddPInvokeInfo (pinvoke_mod.ModuleRef,
+ (pinvoke_name != null ? pinvoke_name : name), pinvoke_attr);
+ }
+
+ if (inst_list.Count < 1)
+ return;
+
+ PEAPI.CILInstructions cil = methoddef.CreateCodeBuffer ();
+ /// Create all the labels
+ /// TODO: Most labels don't actually need to be created so we could
+ /// probably only create the ones that need to be
+ LabelInfo[] label_info = new LabelInfo[label_table.Count + label_list.Count];
+ label_table.Values.CopyTo (label_info, 0);
+ label_list.CopyTo (label_info, label_table.Count);
+ int previous_pos = -1;
+ LabelInfo previous_label = null;
+ Array.Sort (label_info);
+
+ foreach (LabelInfo label in label_info) {
+ if (label.UseOffset) {
+ label.Define (new PEAPI.CILLabel (label.Offset));
+ continue;
+ }
+ if (label.Pos == previous_pos)
+ label.Label = previous_label.Label;
+ else
+ label.Define (cil.NewLabel ());
+
+ previous_label = label;
+ previous_pos = label.Pos;
+ }
+
+ // Set all the label refs
+ foreach (LabelInfo label in labelref_table.Values) {
+ LabelInfo def = (LabelInfo) label_table[label.Name];
+ if (def == null) {
+ Report.Error ("Undefined Label: " + label);
+ return;
+ }
+ label.Label = def.Label;
+ }
+
+ int label_pos = 0;
+ int next_label_pos = (label_info.Length > 0 ? label_info[0].Pos : -1);
+
+ for (int i=0; i<inst_list.Count; i++) {
+ IInstr instr = (IInstr) inst_list[i];
+ if (next_label_pos == i) {
+ cil.CodeLabel (label_info[label_pos].Label);
+ if (label_pos < label_info.Length) {
+ while (next_label_pos == i && ++label_pos < label_info.Length) {
+ if (label_info[label_pos].UseOffset)
+ cil.CodeLabel (label_info[label_pos].Label);
+ next_label_pos = label_info[label_pos].Pos;
+ }
+ }
+ if (label_pos >= label_info.Length)
+ next_label_pos = -1;
+ }
+ if (source != null)
+ source.MarkLocation (instr.Location.line, cil.Offset);
+ instr.Emit (code_gen, this, cil);
+ }
+
+ if (source != null)
+ source.MarkLocation (source.EndLine, cil.Offset);
+ }
+
+ public LabelInfo AddLabel (string name)
+ {
+ LabelInfo label_info = (LabelInfo) label_table[name];
+ if (label_info != null)
+ return label_info;
+ label_info = new LabelInfo (name, inst_list.Count);
+ label_table.Add (name, label_info);
+ return label_info;
+ }
+
+ public LabelInfo AddLabelRef (string name)
+ {
+ LabelInfo label_info = (LabelInfo) label_table[name];
+ if (label_info != null)
+ return label_info;
+ label_info = (LabelInfo) labelref_table[name];
+ if (label_info != null)
+ return label_info;
+ label_info = new LabelInfo (name, -1);
+ labelref_table.Add (name, label_info);
+ return label_info;
+ }
+
+ public LabelInfo AddLabel (int offset)
+ {
+ // We go pos + 1 so this line is not counted
+ LabelInfo label_info = new LabelInfo (null, inst_list.Count+1, (uint) offset);
+ label_list.Add (label_info);
+ return label_info;
+ }
+
+ public LabelInfo AddLabel ()
+ {
+ LabelInfo label_info = new LabelInfo (null, inst_list.Count);
+ label_list.Add (label_info);
+ return label_info;
+ }
+
+ public PEAPI.CILLabel GetLabelDef (string name)
+ {
+ LabelInfo label_info = (LabelInfo) label_table[name];
+
+ return label_info.Label;
+ }
+
+ public PEAPI.CILLabel GetLabelDef (int pos)
+ {
+ foreach (LabelInfo li in label_list) {
+ if (li.Pos == pos)
+ return li.Label;
+ }
+ return null;
+ }
+
+ private void CreateSignature ()
+ {
+ if (IsVararg)
+ signature = CreateVarargSignature (RetType, name, param_list);
+ else
+ signature = CreateSignature (RetType, name, param_list, GenParamCount);
+ }
+
+ public static string CreateSignature (BaseTypeRef RetType, string name, IList param_list, int gen_param_count)
+ {
+ StringBuilder builder = new StringBuilder ();
+
+ builder.Append (RetType.FullName);
+ builder.Append (" ");
+ builder.Append (name);
+ if (gen_param_count > 0)
+ builder.AppendFormat ("`{0}", gen_param_count);
+ builder.Append ('(');
+
+ if (param_list != null) {
+ bool first = true;
+ foreach (ParamDef paramdef in param_list) {
+ if (!first)
+ builder.Append (',');
+ builder.Append (paramdef.TypeName);
+ first = false;
+ }
+ }
+ builder.Append (')');
+
+ return builder.ToString ();
+ }
+
+ public static string CreateVarargSignature (BaseTypeRef RetType, string name, IList param_list)
+ {
+ StringBuilder builder = new StringBuilder ();
+ ParamDef last = null;
+
+ builder.Append (RetType.FullName);
+ builder.Append (" ");
+ builder.Append (name);
+ builder.Append ('(');
+
+ bool first = true;
+ if (param_list != null) {
+ foreach (ParamDef paramdef in param_list) {
+ if (!first)
+ builder.Append (',');
+ builder.Append (paramdef.TypeName);
+ first = false;
+ }
+ last = (ParamDef) param_list[param_list.Count - 1];
+ }
+
+
+ if (last == null || !last.IsSentinel ()) {
+ if (!first)
+ builder.Append (',');
+ builder.Append ("...");
+ }
+
+ builder.Append (')');
+
+ return builder.ToString ();
+ }
+
+ public static string CreateVarargSignature (BaseTypeRef RetType, string name, BaseTypeRef [] param_list)
+ {
+ StringBuilder builder = new StringBuilder ();
+ BaseTypeRef last = null;
+
+ builder.Append (RetType.FullName);
+ builder.Append (" ");
+ builder.Append (name);
+ builder.Append ('(');
+
+ bool first = true;
+ if (param_list != null && param_list.Length > 0) {
+ foreach (BaseTypeRef param in param_list) {
+ if (!first)
+ builder.Append (',');
+ builder.Append (param.FullName);
+ first = false;
+ last = param;
+ if (param is SentinelTypeRef)
+ break;
+ }
+
+ }
+
+ if (last == null || !(last is SentinelTypeRef)) {
+ if (!first)
+ builder.Append (',');
+ builder.Append ("...");
+ }
+
+ builder.Append (')');
+
+ return builder.ToString ();
+ }
+
+ public static string CreateSignature (BaseTypeRef RetType, string name, BaseTypeRef[] param_list, int gen_param_count)
+ {
+ StringBuilder builder = new StringBuilder ();
+
+ builder.Append (RetType.FullName);
+ builder.Append (" ");
+ builder.Append (name);
+ if (gen_param_count > 0)
+ builder.AppendFormat ("`{0}", gen_param_count);
+ builder.Append ('(');
+
+ if (param_list != null) {
+ bool first = true;
+ foreach (BaseTypeRef param in param_list) {
+ if (!first)
+ builder.Append (',');
+ builder.Append (param.FullName);
+ first = false;
+ if (param is SentinelTypeRef)
+ break;
+ }
+ }
+ builder.Append (')');
+
+ return builder.ToString ();
+ }
+
+ private void FixAttributes ()
+ {
+ if (name == ".ctor" || name == ".cctor")
+ meth_attr |= PEAPI.MethAttr.SpecialName | PEAPI.MethAttr.RTSpecialName;
+ // If methods aren't flagged as static they are instance
+ if ((PEAPI.MethAttr.Static & meth_attr) == 0)
+ call_conv |= PEAPI.CallConv.Instance;
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/MethodInstr.cs b/mcs/ilasm/codegen/MethodInstr.cs
new file mode 100644
index 00000000000..62c291c8900
--- /dev/null
+++ b/mcs/ilasm/codegen/MethodInstr.cs
@@ -0,0 +1,41 @@
+//
+// Mono.ILASM.MethodInstr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+
+namespace Mono.ILASM {
+
+ public class MethodInstr : IInstr {
+
+ private PEAPI.MethodOp op;
+ private BaseMethodRef operand;
+
+ public MethodInstr (PEAPI.MethodOp op, BaseMethodRef operand, Location loc)
+ : base (loc)
+ {
+ this.op = op;
+ this.operand = operand;
+
+ if (op == PEAPI.MethodOp.newobj || op == PEAPI.MethodOp.callvirt)
+ operand.CallConv |= PEAPI.CallConv.Instance;
+ }
+
+ public override void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
+ {
+ operand.Resolve (code_gen);
+ cil.MethInst (op, operand.PeapiMethod);
+ }
+ }
+
+}
+
+
diff --git a/mcs/ilasm/codegen/MethodPointerTypeRef.cs b/mcs/ilasm/codegen/MethodPointerTypeRef.cs
new file mode 100644
index 00000000000..83364ffa4bc
--- /dev/null
+++ b/mcs/ilasm/codegen/MethodPointerTypeRef.cs
@@ -0,0 +1,94 @@
+//
+// Mono.ILASM.MethodPointerTypeRef
+//
+// Author(s):
+// Jackson Harper (jackson@ximian.com)
+//
+// Copyright 2004 Novell, Inc (http://www.novell.com)
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class MethodPointerTypeRef : BaseTypeRef {
+
+ private PEAPI.CallConv callconv;
+ private BaseTypeRef ret;
+ private ArrayList param_list;
+
+ public MethodPointerTypeRef (PEAPI.CallConv callconv, BaseTypeRef ret, ArrayList param_list)
+ : base (String.Empty)
+ {
+ this.callconv = callconv;
+ this.ret = ret;
+ this.param_list = param_list;
+
+ // We just need these to not break the interface
+ //full_name = String.Empty;
+ sig_mod = String.Empty;
+ }
+
+ public override void Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ PEAPI.Type [] arg_array;
+ PEAPI.Type [] opt_array;
+ bool is_vararg = false;
+
+ if (param_list != null) {
+ ArrayList opt_list = new ArrayList ();
+ ArrayList arg_list = new ArrayList ();
+ bool in_opt = false;
+ int max = param_list.Count;
+
+ for (int i = 0; i < max; i++) {
+ ParamDef param = (ParamDef) param_list [i];
+
+ if (param.IsSentinel ()) {
+ is_vararg = true;
+ in_opt = true;
+ param.Type.Resolve (code_gen);
+ } else if (in_opt) {
+ param.Type.Resolve (code_gen);
+ opt_list.Add (param.Type.PeapiType);
+ } else {
+ param.Type.Resolve (code_gen);
+ arg_list.Add (param.Type.PeapiType);
+ }
+ }
+
+ arg_array = (PEAPI.Type []) arg_list.ToArray (typeof (PEAPI.Type));
+ opt_array = (PEAPI.Type []) opt_list.ToArray (typeof (PEAPI.Type));
+ } else {
+ arg_array = new PEAPI.Type [0];
+ opt_array = new PEAPI.Type [0];
+ }
+
+ ret.Resolve (code_gen);
+
+ type = new PEAPI.MethPtrType (callconv, ret.PeapiType, arg_array, is_vararg, opt_array);
+ type = Modify (code_gen, type);
+
+ is_resolved = true;
+ }
+
+ protected override BaseMethodRef CreateMethodRef (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
+ string name, BaseTypeRef[] param, int gen_param_count)
+ {
+ return new TypeSpecMethodRef (this, call_conv, ret_type, name, param, gen_param_count);
+ }
+
+ protected override IFieldRef CreateFieldRef (BaseTypeRef ret_type, string name)
+ {
+ return new TypeSpecFieldRef (this, ret_type, name);
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/MethodRef.cs b/mcs/ilasm/codegen/MethodRef.cs
new file mode 100644
index 00000000000..5c0553febf0
--- /dev/null
+++ b/mcs/ilasm/codegen/MethodRef.cs
@@ -0,0 +1,69 @@
+//
+// Mono.ILASM.MethodRef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class MethodRef : BaseMethodRef {
+
+ public MethodRef (TypeRef owner, PEAPI.CallConv call_conv,
+ BaseTypeRef ret_type, string name, BaseTypeRef[] param, int gen_param_count)
+ : base (owner, call_conv, ret_type, name, param, gen_param_count)
+ {
+ }
+
+ public override void Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ owner.Resolve (code_gen);
+
+ TypeDef owner_def = code_gen.TypeManager[owner.FullName];
+ if (owner_def == null)
+ Report.Error ("Reference to undefined class '" + owner.FullName + "'");
+
+ string write_name;
+
+ if (name == "<init>")
+ write_name = ".ctor";
+ else
+ write_name = name;
+
+ if ((call_conv & PEAPI.CallConv.Vararg) == 0) {
+ peapi_method = owner_def.ResolveMethod (ret_type, call_conv, name,
+ param, gen_param_count, code_gen);
+ } else {
+ ArrayList opt_list = new ArrayList ();
+ bool in_opt = false;
+ foreach (BaseTypeRef type in param) {
+ if (type is SentinelTypeRef) {
+ in_opt = true;
+ } else if (in_opt) {
+ type.Resolve (code_gen);
+ opt_list.Add (type.PeapiType);
+ }
+ }
+ peapi_method = owner_def.ResolveVarargMethod (
+ ret_type, call_conv, name, param, gen_param_count,
+ (PEAPI.Type[]) opt_list.ToArray (typeof (PEAPI.Type)),
+ code_gen);
+ }
+
+ is_resolved = true;
+
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/MethodTable.cs b/mcs/ilasm/codegen/MethodTable.cs
new file mode 100644
index 00000000000..2ac19d11aab
--- /dev/null
+++ b/mcs/ilasm/codegen/MethodTable.cs
@@ -0,0 +1,228 @@
+//
+// Mono.ILASM.MethodTable.cs
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+using PEAPI;
+using System;
+using System.Text;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+
+ public delegate void MethodDefinedEvent (object sender, MethodDefinedEventArgs args);
+ public delegate void MethodReferencedEvent (object sender, MethodReferencedEventArgs args);
+
+ public class MethodEventArgs : EventArgs {
+
+ public readonly string Signature;
+ public readonly string Name;
+ public readonly TypeRef ReturnType;
+ public readonly Param[] ParamList;
+ public readonly bool IsInTable;
+
+ public MethodEventArgs (string signature, string name,
+ TypeRef return_type, Param[] param_list, bool is_in_table)
+ {
+ Signature = signature;
+ Name = name;
+ ReturnType = return_type;
+ ParamList = param_list;
+ IsInTable = is_in_table;
+ }
+ }
+
+ public class MethodDefinedEventArgs : MethodEventArgs {
+
+ public readonly MethAttr MethodAttributes;
+ public readonly ImplAttr ImplAttributes;
+ public readonly CallConv CallConv;
+
+ public MethodDefinedEventArgs (string signature, string name,
+ TypeRef return_type, Param[] param_list, bool is_in_table, MethAttr method_attr,
+ ImplAttr impl_attr, CallConv call_conv) : base (signature, name,
+ return_type, param_list, is_in_table)
+ {
+ MethodAttributes = method_attr;
+ ImplAttributes = impl_attr;
+ CallConv = call_conv;
+ }
+ }
+
+ public class MethodReferencedEventArgs : MethodEventArgs {
+
+ public MethodReferencedEventArgs (string signature, string name,
+ TypeRef return_type, Param[] param_list, bool is_in_table) : base (signature, name,
+ return_type, param_list, is_in_table)
+ {
+
+ }
+ }
+
+
+ public class MethodTable {
+
+ private class MethodTableItem {
+
+ private static readonly int DefinedFlag = 2;
+
+ private int flags;
+
+ public ArrayList LocationList;
+ public MethodDef Method;
+
+ public MethodTableItem (MethodDef method, Location location)
+ {
+ flags = 0;
+ Method = method;
+ LocationList = new ArrayList ();
+ LocationList.Add (location);
+ }
+
+ public bool Defined {
+ get { return ((flags & DefinedFlag) != 0); }
+ set {
+ if (value)
+ flags |= DefinedFlag;
+ else
+ flags ^= DefinedFlag;
+ }
+ }
+ }
+
+ protected Hashtable table;
+ protected ClassDef parent_class;
+
+ public static event MethodReferencedEvent MethodReferencedEvent;
+ public static event MethodDefinedEvent MethodDefinedEvent;
+
+ public MethodTable (ClassDef parent_class)
+ {
+ this.parent_class = parent_class;
+ table = new Hashtable ();
+ }
+
+ public Method GetReference (string name, TypeRef return_type,
+ Param[] param_list, TypeRef[] param_type_list, Location location)
+ {
+ string signature = GetSignature (name, return_type, param_type_list);
+
+ if (MethodReferencedEvent != null)
+ MethodReferencedEvent (this, new MethodReferencedEventArgs (signature, name,
+ return_type, param_list, table.Contains (signature)));
+
+ MethodTableItem item = table[signature] as MethodTableItem;
+
+ if (item != null) {
+ item.LocationList.Add (location);
+ return item.Method;
+ }
+
+ MethodDef method = parent_class.AddMethod (name, return_type.Type,
+ param_list);
+
+ AddReferenced (signature, method, location);
+
+ return method;
+ }
+
+ public MethodDef AddDefinition (MethAttr method_attr, ImplAttr impl_attr, CallConv call_conv,
+ string name, TypeRef return_type, Param[] param_list,
+ TypeRef[] param_type_list, Location location)
+ {
+ string signature = GetSignature (name, return_type, param_type_list);
+
+ if (MethodDefinedEvent != null)
+ MethodDefinedEvent (this, new MethodDefinedEventArgs (signature, name,
+ return_type, param_list, table.Contains (signature), method_attr,
+ impl_attr, call_conv));
+
+ MethodTableItem item = (MethodTableItem) table[signature];
+
+ if (item == null) {
+ MethodDef method = parent_class.AddMethod (method_attr, impl_attr, name,
+ return_type.Type, param_list);
+ method.AddCallConv (call_conv);
+ AddDefined (signature, method, location);
+ return method;
+ }
+
+ item.Method.AddMethAttribute (method_attr);
+ item.Method.AddImplAttribute (impl_attr);
+ item.Method.AddCallConv (call_conv);
+ item.Defined = true;
+
+ return item.Method;
+ }
+
+ public bool CheckDefined ()
+ {
+ foreach (DictionaryEntry dic_entry in table) {
+ MethodTableItem table_item = (MethodTableItem) dic_entry.Value;
+ if (table_item.Defined)
+ continue;
+ Report.Error (String.Format ("Method: {0} is not defined.", dic_entry.Key));
+ }
+ return true;
+ }
+
+ protected string GetSignature (string name, TypeRef return_type,
+ TypeRef[] param_list)
+ {
+ StringBuilder builder = new StringBuilder ();
+
+ builder.Append (return_type.FullName);
+ builder.Append ('_');
+ builder.Append (name);
+ builder.Append ('(');
+
+ bool first = true;
+ foreach (TypeRef type_ref in param_list) {
+ if (!first)
+ builder.Append (',');
+ builder.Append (type_ref.FullName);
+ }
+ builder.Append (')');
+
+ return builder.ToString ();
+ }
+
+ protected void AddDefined (string signature, MethodDef method, Location location)
+ {
+ if (table.Contains (signature))
+ return;
+
+ MethodTableItem item = new MethodTableItem (method, location);
+ item.Defined = true;
+
+ table[signature] = item;
+ }
+
+ protected void AddReferenced (string signature, MethodDef method, Location location)
+ {
+ MethodTableItem item = new MethodTableItem (method, location);
+
+ table[signature] = item;
+ }
+
+ /// <summary>
+ /// If a method is allready defined throw an Error
+ /// </summary>
+ protected void CheckExists (string signature)
+ {
+ MethodTableItem item = table[signature] as MethodTableItem;
+
+ if ((item != null) && (item.Defined)) {
+ Report.Error (String.Format ("Method: {0} defined in multiple locations.",
+ signature));
+ }
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/MiscInstr.cs b/mcs/ilasm/codegen/MiscInstr.cs
new file mode 100644
index 00000000000..05555085e32
--- /dev/null
+++ b/mcs/ilasm/codegen/MiscInstr.cs
@@ -0,0 +1,25 @@
+//
+// Mono.ILASM.MiscInstr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public enum MiscInstr {
+ ldstr,
+ ldc_r4,
+ ldc_r8,
+ ldc_i8,
+ _switch,
+ calli,
+ ldtoken
+ }
+}
+
diff --git a/mcs/ilasm/codegen/ModifiableType.cs b/mcs/ilasm/codegen/ModifiableType.cs
new file mode 100644
index 00000000000..463f59235a3
--- /dev/null
+++ b/mcs/ilasm/codegen/ModifiableType.cs
@@ -0,0 +1,154 @@
+//
+// Mono.ILASM.ModifiableType
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper (Jackson@LatitudeGeo.com)
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public abstract class ModifiableType {
+
+ private ArrayList conversion_list;
+ private bool is_pinned;
+ private bool is_ref;
+ private bool is_array;
+ private bool use_type_spec;
+
+ private enum ConversionMethod {
+ MakeArray,
+ MakeBoundArray,
+ MakeManagedPointer,
+ MakeUnmanagedPointer,
+ MakeCustomModified
+ }
+
+ public ModifiableType ()
+ {
+ conversion_list = new ArrayList (5);
+ }
+
+ public abstract string SigMod {
+ get;
+ set;
+ }
+
+ protected ArrayList ConversionList {
+ get { return conversion_list; }
+ set { conversion_list = value; }
+ }
+
+ public bool IsPinned {
+ get { return is_pinned; }
+ }
+
+ public bool IsArray {
+ get { return is_array; }
+ }
+
+ public bool IsRef {
+ get { return is_ref; }
+ }
+
+ public bool UseTypeSpec {
+ get { return use_type_spec; }
+ }
+
+ public void MakeArray ()
+ {
+ use_type_spec = true;
+ conversion_list.Add (ConversionMethod.MakeArray);
+ is_array = true;
+ SigMod += "[]";
+ }
+
+ public void MakeBoundArray (ArrayList bounds)
+ {
+ use_type_spec = true;
+ conversion_list.Add (ConversionMethod.MakeBoundArray);
+ conversion_list.Add (bounds);
+ is_array = true;
+ SigMod += "[";
+ for (int i=0; i<bounds.Count; i++) {
+ DictionaryEntry e = (DictionaryEntry) bounds [i];
+ if (e.Key != TypeRef.Ellipsis)
+ SigMod += e.Key;
+ SigMod += "...";
+ if (e.Value != TypeRef.Ellipsis)
+ SigMod += e.Value;
+ if (i + 1 < bounds.Count)
+ SigMod += ", ";
+ }
+ SigMod += "]";
+ }
+
+ public void MakeManagedPointer ()
+ {
+ use_type_spec = true;
+ conversion_list.Add (ConversionMethod.MakeManagedPointer);
+ is_ref = true;
+ SigMod += "&";
+ }
+
+ public void MakeUnmanagedPointer ()
+ {
+ use_type_spec = true;
+ conversion_list.Add (ConversionMethod.MakeUnmanagedPointer);
+ SigMod += "*";
+ }
+
+ public void MakeCustomModified (CodeGen code_gen, PEAPI.CustomModifier modifier,
+ BaseClassRef klass)
+ {
+ use_type_spec = true;
+ conversion_list.Add (ConversionMethod.MakeCustomModified);
+ conversion_list.Add (modifier);
+ conversion_list.Add (klass);
+ }
+
+ public void MakePinned ()
+ {
+ use_type_spec = true;
+ is_pinned = true;
+ }
+
+ protected PEAPI.Type Modify (CodeGen code_gen, PEAPI.Type type)
+ {
+ PeapiTypeRef peapi_type = new PeapiTypeRef (type);
+ int count = conversion_list.Count;
+ for (int i=0; i<count; i++) {
+ switch ((ConversionMethod) conversion_list[i]) {
+ case ConversionMethod.MakeArray:
+ peapi_type.MakeArray ();
+ break;
+ case ConversionMethod.MakeBoundArray:
+ peapi_type.MakeBoundArray ((ArrayList) conversion_list[++i]);
+ break;
+ case ConversionMethod.MakeManagedPointer:
+ peapi_type.MakeManagedPointer ();
+ break;
+ case ConversionMethod.MakeUnmanagedPointer:
+ peapi_type.MakeUnmanagedPointer ();
+ break;
+ case ConversionMethod.MakeCustomModified:
+ peapi_type.MakeCustomModified (code_gen, (PEAPI.CustomModifier) conversion_list[++i],
+ (BaseClassRef) conversion_list[++i]);
+ break;
+ }
+
+ }
+
+ return peapi_type.PeapiType;
+ }
+
+ }
+
+}
+
+
diff --git a/mcs/ilasm/codegen/Module.cs b/mcs/ilasm/codegen/Module.cs
new file mode 100644
index 00000000000..32ca848fbd1
--- /dev/null
+++ b/mcs/ilasm/codegen/Module.cs
@@ -0,0 +1,58 @@
+//
+// Mono.ILASM.Module
+//
+// Author(s):
+// Ankit Jain <jankit@novell.com>
+//
+// Copyright 2006 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class Module : ExternRef {
+
+ PEAPI.Module module;
+
+ public Module (string name)
+ : base (name)
+ {
+ }
+
+ public PEAPI.Module PeapiModule {
+ get { return module; }
+ set { module = value; }
+ }
+
+ public override string FullName {
+ get {
+ //'name' field should not contain the [ ]
+ //as its used for resolving
+ return String.Format ("[{0}]", name);
+ }
+ }
+
+ public override PEAPI.IExternRef GetExternRef ()
+ {
+ return module;
+ }
+
+ public override void Resolve (CodeGen code_gen)
+ {
+ throw new InternalErrorException ("This should not get called");
+ }
+
+ public void Resolve (CodeGen code_gen, PEAPI.Module module)
+ {
+ this.module = module;
+
+ if (customattr_list == null)
+ return;
+
+ foreach (CustomAttr customattr in customattr_list)
+ customattr.AddTo (code_gen, module);
+ }
+ }
+}
diff --git a/mcs/ilasm/codegen/ParamDef.cs b/mcs/ilasm/codegen/ParamDef.cs
new file mode 100644
index 00000000000..ede5bec5036
--- /dev/null
+++ b/mcs/ilasm/codegen/ParamDef.cs
@@ -0,0 +1,106 @@
+//
+// Mono.ILASM.ParamDef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+using System.Collections;
+
+
+namespace Mono.ILASM {
+
+ /// <summary>
+ /// Definition of a parameter passed to a method
+ /// </summary>
+ public class ParamDef : ICustomAttrTarget {
+
+ private PEAPI.ParamAttr attr;
+ private string name;
+ private BaseTypeRef typeref;
+ private bool is_defined;
+ private PEAPI.Param peapi_param;
+ private PEAPI.Constant defval;
+ private ArrayList customattr_list;
+ private PEAPI.NativeType native_type;
+
+ public static readonly ParamDef Ellipsis = new ParamDef (new PEAPI.ParamAttr (), "ELLIPSIS", null);
+
+ public ParamDef (PEAPI.ParamAttr attr, string name,
+ BaseTypeRef typeref) {
+ this.attr = attr;
+ this.name = name;
+ this.typeref = typeref;
+ is_defined = false;
+ defval = null;
+ }
+
+ public void AddDefaultValue (PEAPI.Constant cVal)
+ {
+ defval = cVal;
+ }
+
+ public void AddCustomAttribute (CustomAttr customattr)
+ {
+ if (customattr_list == null)
+ customattr_list = new ArrayList ();
+
+ customattr_list.Add (customattr);
+ }
+
+ public void AddMarshalInfo (PEAPI.NativeType native_type)
+ {
+ this.native_type = native_type;
+ }
+
+ public BaseTypeRef Type {
+ get { return typeref; }
+ }
+
+ public string TypeName {
+ get { return typeref.FullName; }
+ }
+
+ public string Name {
+ get { return name; }
+ }
+
+ public PEAPI.Param PeapiParam {
+ get { return peapi_param; }
+ }
+
+ public bool IsSentinel ()
+ {
+ return (typeref is SentinelTypeRef && this != Ellipsis);
+ }
+
+ public void Define (CodeGen code_gen)
+ {
+ if (is_defined)
+ return;
+
+ typeref.Resolve (code_gen);
+
+ peapi_param = new PEAPI.Param (attr,
+ name, typeref.PeapiType);
+ if (defval != null) {
+ peapi_param.AddDefaultValue (defval);
+ }
+
+ if (customattr_list != null)
+ foreach (CustomAttr customattr in customattr_list)
+ customattr.AddTo (code_gen, peapi_param);
+
+ if (native_type != null)
+ peapi_param.AddMarshallInfo (native_type);
+
+ is_defined = true;
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/PeapiTypeRef.cs b/mcs/ilasm/codegen/PeapiTypeRef.cs
new file mode 100644
index 00000000000..704ba2df086
--- /dev/null
+++ b/mcs/ilasm/codegen/PeapiTypeRef.cs
@@ -0,0 +1,231 @@
+//
+// Mono.ILASM.PeapiTypeRef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+ public class Pair {
+ private PEAPI.Type type;
+ private string sig;
+
+ public Pair (PEAPI.Type type, string sig)
+ {
+ this.type = type;
+ this.sig = sig;
+ }
+
+ public override int GetHashCode ()
+ {
+ return type.GetHashCode () ^ sig.GetHashCode ();
+ }
+
+ public override bool Equals (Object o)
+ {
+ Pair p = o as Pair;
+
+ if (p == null)
+ return false;
+
+ return (p.type == this.type && p.sig == this.sig);
+ }
+ }
+
+ public class PeapiTypeRef {
+
+ private PEAPI.Type peapi_type;
+ private bool is_pinned;
+ private bool is_array;
+ private bool is_ref;
+ private bool use_type_spec;
+
+ private static Hashtable type_table = new Hashtable ();
+
+ public PeapiTypeRef (PEAPI.Type peapi_type)
+ {
+ this.peapi_type = peapi_type;
+ is_pinned = false;
+ is_array = false;
+ is_ref = false;
+ use_type_spec = false;
+ }
+
+ public bool IsPinned {
+ get { return is_pinned; }
+ }
+
+ public bool IsArray {
+ get { return is_array; }
+ }
+
+ public bool IsRef {
+ get { return is_ref; }
+ }
+
+ public bool UseTypeSpec {
+ get { return use_type_spec; }
+ }
+
+ public PEAPI.Type PeapiType {
+ get { return peapi_type; }
+ }
+
+ public void MakeArray ()
+ {
+ PEAPI.Type type;
+
+ use_type_spec = true;
+ is_array = true;
+
+ Pair p = new Pair (peapi_type, "[]");
+ type = type_table [p] as PEAPI.Type;
+ if (type == null) {
+ type = new PEAPI.ZeroBasedArray (peapi_type);
+ type_table [p] = type;
+ }
+ peapi_type = type;
+ }
+
+ public void MakeBoundArray (ArrayList bound_list)
+ {
+ use_type_spec = true;
+ is_array = true;
+
+ int dimen = bound_list.Count;
+ int[] lower_array = new int[dimen];
+ int[] size_array = new int[dimen];
+ int [] lobounds = null;
+ int [] sizes = null;
+ int num_lower, num_sizes;
+ string sigmod = "";
+ PEAPI.Type type;
+ Pair p;
+
+ sigmod += "[";
+ for (int i=0; i<bound_list.Count; i++) {
+ DictionaryEntry e = (DictionaryEntry) bound_list [i];
+ if (e.Key != TypeRef.Ellipsis)
+ sigmod += e.Key;
+ sigmod += "...";
+ if (e.Value != TypeRef.Ellipsis)
+ sigmod += e.Value;
+ if (i + 1 < bound_list.Count)
+ sigmod += ", ";
+ }
+ sigmod += "]";
+
+ p = new Pair (peapi_type, sigmod);
+ type = type_table [p] as PEAPI.Type;
+ if (type != null) {
+ peapi_type = type;
+ return;
+ }
+
+ num_sizes = num_lower = 0;
+ // TODO: There should probably be an error reported if
+ // something like [3...,3...5] is done
+ for (int i=0; i<dimen; i++) {
+ if (bound_list [i] == null)
+ continue;
+
+ DictionaryEntry bound = (DictionaryEntry) bound_list [i];
+
+ if (bound.Key != TypeRef.Ellipsis) {
+ /* Lower bound specified */
+ lower_array [i] = (int) bound.Key;
+ num_lower = i + 1;
+ }
+ if (bound.Value != TypeRef.Ellipsis) {
+ size_array [i] = (int) bound.Value;
+ if (bound.Key != TypeRef.Ellipsis)
+ /* .Value is Upper bound eg [1...5] */
+ size_array [i] -= lower_array [i] - 1;
+ num_sizes = i + 1;
+ }
+ }
+
+ if (num_lower > 0) {
+ lobounds = new int [num_lower];
+ Array.Copy (lower_array, lobounds, num_lower);
+ }
+
+ if (num_sizes > 0) {
+ sizes = new int [num_sizes];
+ Array.Copy (size_array, sizes, num_sizes);
+ }
+
+ peapi_type = new PEAPI.BoundArray (peapi_type,
+ (uint) dimen, lobounds, sizes);
+ type_table [p] = peapi_type;
+ }
+
+ public void MakeManagedPointer ()
+ {
+ PEAPI.Type type;
+ use_type_spec = true;
+ is_ref = true;
+
+ Pair p = new Pair (peapi_type, "&");
+ type = type_table [p] as PEAPI.Type;
+ if (type == null) {
+ type = new PEAPI.ManagedPointer (peapi_type);
+ type_table [p] = type;
+ }
+ peapi_type = type;
+ }
+
+ public void MakeUnmanagedPointer ()
+ {
+ PEAPI.Type type;
+ use_type_spec = true;
+
+ Pair p = new Pair (peapi_type, "*");
+ type = type_table [p] as PEAPI.Type;
+ if (type == null) {
+ type = new PEAPI.UnmanagedPointer (peapi_type);
+ type_table [p] = type;
+ }
+ peapi_type = type;
+ }
+
+ public void MakeCustomModified (CodeGen code_gen, PEAPI.CustomModifier modifier,
+ BaseClassRef klass)
+ {
+ PEAPI.Type type;
+
+ use_type_spec = true;
+
+ Pair p = new Pair (peapi_type, modifier.ToString ());
+ type = type_table [p] as PEAPI.Type;
+ if (type == null) {
+ klass.Resolve (code_gen);
+ type = new PEAPI.CustomModifiedType (peapi_type,
+ modifier, klass.PeapiClass);
+ type_table [p] = type;
+ }
+ peapi_type = type;
+ }
+
+ public void MakePinned ()
+ {
+ use_type_spec = true;
+ is_pinned = true;
+ }
+
+ public void Resolve (CodeGen code_gen)
+ {
+
+ }
+
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/PrimitiveTypeRef.cs b/mcs/ilasm/codegen/PrimitiveTypeRef.cs
new file mode 100644
index 00000000000..5df416f06d4
--- /dev/null
+++ b/mcs/ilasm/codegen/PrimitiveTypeRef.cs
@@ -0,0 +1,108 @@
+//
+// Mono.ILASM.PrimitiveTypeRef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ /// <summary>
+ /// Reference to a primitive type, ie string, object, char
+ /// </summary>
+ public class PrimitiveTypeRef : BaseTypeRef {
+
+ private static Hashtable s_method_table = new Hashtable ();
+
+ public PrimitiveTypeRef (PEAPI.PrimitiveType type, string full_name)
+ : base (full_name)
+ {
+ this.type = type;
+ SigMod = String.Empty;
+ }
+
+ public string Name {
+ get { return full_name; }
+ }
+
+ public override void Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ // Perform all of the types modifications
+ type = Modify (code_gen, type);
+
+ is_resolved = true;
+ }
+
+ /// <summary>
+ /// Primitive types can be created like this System.String instead
+ /// of like a normal type that would be [mscorlib]System.String This
+ /// method returns a proper primitive type if the supplied name is
+ /// the name of a primitive type.
+ /// </summary>
+ public static PrimitiveTypeRef GetPrimitiveType (string full_name)
+ {
+ switch (full_name) {
+ case "System.String":
+ return new PrimitiveTypeRef (PEAPI.PrimitiveType.String, full_name);
+ case "System.Object":
+ return new PrimitiveTypeRef (PEAPI.PrimitiveType.Object, full_name);
+ default:
+ return null;
+ }
+ }
+
+ protected override BaseMethodRef CreateMethodRef (BaseTypeRef ret_type,
+ PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count)
+ {
+ throw new InternalErrorException ("Should not be called");
+ }
+
+ public override BaseMethodRef GetMethodRef (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
+ string name, BaseTypeRef[] param, int gen_param_count)
+ {
+ /* Use FullName also here, as we are caching in a static hashtable */
+ string key = FullName + MethodDef.CreateSignature (ret_type, name, param, gen_param_count);
+ TypeSpecMethodRef mr = s_method_table [key] as TypeSpecMethodRef;
+ if (mr != null)
+ return mr;
+
+ //FIXME: generic methodref for primitive type?
+ mr = new TypeSpecMethodRef (this, call_conv, ret_type, name, param, gen_param_count);
+ s_method_table [key] = mr;
+ return mr;
+ }
+
+ protected override IFieldRef CreateFieldRef (BaseTypeRef ret_type, string name)
+ {
+ Report.Error ("PrimitiveType's can't have fields!");
+ return null;
+ }
+
+ public BaseClassRef AsClassRef (CodeGen code_gen)
+ {
+ /*
+ PEAPI.ClassRef class_ref = code_gen.ExternTable.GetValueClass ("corlib", FullName);
+ ExternTypeRef type_ref = new ExternTypeRef (class_ref, FullName);
+
+ // TODO: Need to do the rest of the conversion (in order)
+ if (IsArray)
+ type_ref.MakeArray ();
+
+ return type_ref;
+ */
+ throw new NotImplementedException ("This method is getting depricated.");
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/PropertyDef.cs b/mcs/ilasm/codegen/PropertyDef.cs
new file mode 100644
index 00000000000..ef35adcae30
--- /dev/null
+++ b/mcs/ilasm/codegen/PropertyDef.cs
@@ -0,0 +1,136 @@
+//
+// Mono.ILASM.PropertyDef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All right reserved
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class PropertyDef : ICustomAttrTarget {
+
+ private FeatureAttr attr;
+ private string name;
+ private BaseTypeRef type;
+ private ArrayList arg_list;
+ private PEAPI.Property prop_def;
+ private bool is_resolved;
+ private ArrayList customattr_list;
+
+ private MethodRef _get;
+ private MethodRef _set;
+ private MethodRef other;
+ private PEAPI.Constant init_value;
+
+ public PropertyDef (FeatureAttr attr, BaseTypeRef type, string name, ArrayList arg_list)
+ {
+ this.attr = attr;
+ this.name = name;
+ this.type = type;
+ this.arg_list = arg_list;
+ is_resolved = false;
+ }
+
+ public void AddCustomAttribute (CustomAttr customattr)
+ {
+ if (customattr_list == null)
+ customattr_list = new ArrayList ();
+
+ customattr_list.Add (customattr);
+ }
+
+ public PEAPI.Property Resolve (CodeGen code_gen, PEAPI.ClassDef classdef)
+ {
+ if (is_resolved)
+ return prop_def;
+
+ PEAPI.Type[] type_list = new PEAPI.Type[arg_list.Count];
+
+ for (int i=0; i<type_list.Length; i++) {
+ BaseTypeRef arg_type = (BaseTypeRef) arg_list[i];
+ arg_type.Resolve (code_gen);
+ type_list[i] = arg_type.PeapiType;
+ }
+
+ type.Resolve (code_gen);
+ prop_def = classdef.AddProperty (name, type.PeapiType, type_list);
+
+ if ((attr & FeatureAttr.Rtspecialname) != 0)
+ prop_def.SetRTSpecialName ();
+
+ if ((attr & FeatureAttr.Specialname) != 0)
+ prop_def.SetSpecialName ();
+
+ prop_def.SetInstance ((attr & FeatureAttr.Instance) != 0);
+
+ if (customattr_list != null)
+ foreach (CustomAttr customattr in customattr_list)
+ customattr.AddTo (code_gen, prop_def);
+
+
+ is_resolved = true;
+
+ return prop_def;
+ }
+
+ private PEAPI.MethodDef AsMethodDef (PEAPI.Method method, string type)
+ {
+ PEAPI.MethodDef methoddef = method as PEAPI.MethodDef;
+ if (methoddef == null)
+ Report.Error (type + " method of property " + name + " not found");
+ return methoddef;
+ }
+
+ public void Define (CodeGen code_gen, PEAPI.ClassDef classdef)
+ {
+ if (!is_resolved)
+ Resolve (code_gen, classdef);
+
+ if (_get != null) {
+ _get.Resolve (code_gen);
+ prop_def.AddGetter (AsMethodDef (_get.PeapiMethod, "get"));
+ }
+
+ if (_set != null) {
+ _set.Resolve (code_gen);
+ prop_def.AddSetter (AsMethodDef (_set.PeapiMethod, "set"));
+ }
+
+ if (other != null) {
+ other.Resolve (code_gen);
+ prop_def.AddOther (AsMethodDef (other.PeapiMethod, "other"));
+ }
+
+ if (init_value != null)
+ prop_def.AddInitValue (init_value);
+ }
+
+ public void AddGet (MethodRef _get)
+ {
+ this._get = _get;
+ }
+
+ public void AddSet (MethodRef _set)
+ {
+ this._set = _set;
+ }
+
+ public void AddOther (MethodRef other)
+ {
+ this.other = other;
+ }
+
+ public void AddInitValue (PEAPI.Constant init_value)
+ {
+ this.init_value = init_value;
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/Sentinel.cs b/mcs/ilasm/codegen/Sentinel.cs
new file mode 100644
index 00000000000..6bbaa38923e
--- /dev/null
+++ b/mcs/ilasm/codegen/Sentinel.cs
@@ -0,0 +1,50 @@
+//
+// Mono.ILASM.SentinelTypeRef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class SentinelTypeRef : BaseTypeRef {
+
+ public SentinelTypeRef ()
+ : base ("...")
+ {
+ }
+
+ public override void Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ type = new PEAPI.Sentinel ();
+ type = Modify (code_gen, type);
+
+ is_resolved = true;
+ }
+
+ protected override BaseMethodRef CreateMethodRef (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
+ string name, BaseTypeRef[] param, int gen_param_count)
+ {
+ return new TypeSpecMethodRef (this, call_conv, ret_type, name, param, gen_param_count);
+ }
+
+ protected override IFieldRef CreateFieldRef (BaseTypeRef ret_type, string name)
+ {
+ return new TypeSpecFieldRef (this, ret_type, name);
+ }
+
+ public override string ToString ()
+ {
+ return "Sentinel " + full_name;
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/SimpInstr.cs b/mcs/ilasm/codegen/SimpInstr.cs
new file mode 100644
index 00000000000..026a1079069
--- /dev/null
+++ b/mcs/ilasm/codegen/SimpInstr.cs
@@ -0,0 +1,34 @@
+//
+// Mono.ILASM.SimpInstr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class SimpInstr : IInstr {
+
+ private PEAPI.Op op;
+
+ public SimpInstr (PEAPI.Op op, Location loc)
+ : base (loc)
+ {
+ this.op = op;
+ }
+
+ public override void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
+ {
+ cil.Inst (op);
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/SwitchInstr.cs b/mcs/ilasm/codegen/SwitchInstr.cs
new file mode 100644
index 00000000000..5b6178ee15b
--- /dev/null
+++ b/mcs/ilasm/codegen/SwitchInstr.cs
@@ -0,0 +1,50 @@
+//
+// Mono.ILASM.SwitchInstr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class SwitchInstr : IInstr {
+
+ private ArrayList label_list;
+
+ public SwitchInstr (ArrayList label_list, Location loc)
+ : base (loc)
+ {
+ this.label_list = label_list;
+ }
+
+ public override void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
+ {
+ int count = 0;
+ PEAPI.CILLabel[] label_array;
+
+ if (label_list != null) {
+ label_array = new PEAPI.CILLabel[label_list.Count];
+ foreach (object lab in label_list) {
+ if (lab is string) {
+ label_array[count++] = meth.GetLabelDef ((string) lab);
+ } else {
+ throw new InternalErrorException ("offsets in switch statements.");
+ }
+ }
+ } else {
+ label_array = new PEAPI.CILLabel [0];
+ }
+
+ cil.Switch (label_array);
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/TryBlock.cs b/mcs/ilasm/codegen/TryBlock.cs
new file mode 100644
index 00000000000..9ec09d7a23b
--- /dev/null
+++ b/mcs/ilasm/codegen/TryBlock.cs
@@ -0,0 +1,49 @@
+//
+// Mono.ILASM.TryBlock
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class TryBlock : IInstr {
+
+ private HandlerBlock block;
+ private ArrayList clause_list;
+
+ public TryBlock (HandlerBlock block, Location loc)
+ : base (loc)
+ {
+ this.block = block;
+ clause_list = new ArrayList ();
+ }
+
+ public void AddSehClause (ISehClause clause)
+ {
+ clause_list.Add (clause);
+ }
+
+ public override void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
+ {
+ PEAPI.CILLabel from = block.GetFromLabel (code_gen, meth);
+ PEAPI.CILLabel to = block.GetToLabel (code_gen, meth);
+ PEAPI.TryBlock try_block = new PEAPI.TryBlock (from, to);
+
+ foreach (ISehClause clause in clause_list)
+ try_block.AddHandler (clause.Resolve (code_gen, meth));
+
+ cil.AddTryBlock (try_block);
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/TypeDef.cs b/mcs/ilasm/codegen/TypeDef.cs
new file mode 100644
index 00000000000..6dafb428c43
--- /dev/null
+++ b/mcs/ilasm/codegen/TypeDef.cs
@@ -0,0 +1,536 @@
+//
+// Mono.ILASM.TypeDef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+using System.Collections;
+using System.Security;
+
+namespace Mono.ILASM {
+
+ public class TypeDef : ICustomAttrTarget, IDeclSecurityTarget, IComparable {
+
+ private PEAPI.TypeAttr attr;
+ private string name_space;
+ private string name;
+ private bool is_defined;
+ private bool is_intransit;
+ private BaseClassRef parent;
+ private ArrayList impl_list;
+ private PEAPI.ClassDef classdef;
+ private Hashtable field_table;
+ private ArrayList field_list;
+ private Hashtable method_table;
+ private ArrayList customattr_list;
+ private DeclSecurity decl_sec;
+ private ArrayList event_list;
+ private ArrayList property_list;
+ private GenericParameters gen_params;
+ private ArrayList override_list;
+ private ArrayList override_long_list;
+ private TypeDef outer;
+
+ private EventDef current_event;
+ private PropertyDef current_property;
+
+ private int size;
+ private int pack;
+
+ private bool is_value_class;
+ private bool is_enum_class;
+
+ public TypeDef (PEAPI.TypeAttr attr, string name_space, string name,
+ BaseClassRef parent, ArrayList impl_list, Location location, GenericParameters gen_params, TypeDef outer)
+ {
+ this.attr = attr;
+ this.parent = parent;
+ this.impl_list = impl_list;
+ this.gen_params = gen_params;
+ this.outer = outer;
+
+ field_table = new Hashtable ();
+ field_list = new ArrayList ();
+
+ method_table = new Hashtable ();
+
+ size = -1;
+ pack = -1;
+
+ is_defined = false;
+ is_intransit = false;
+
+ is_value_class = false;
+ is_enum_class = false;
+
+ ResolveGenParams ();
+
+ int lastdot = name.LastIndexOf ('.');
+ /* Namespace . name split should not be done for nested classes */
+ if (lastdot >= 0 && outer == null) {
+ if (name_space == null || name_space == "")
+ this.name_space = name.Substring (0, lastdot);
+ else
+ this.name_space = name_space + "." + name.Substring (0, lastdot);
+ this.name = name.Substring (lastdot + 1);
+ } else {
+ this.name_space = name_space;
+ this.name = name;
+ }
+ }
+
+ public string Name {
+ get { return name; }
+ }
+
+ public string FullName {
+ get { return MakeFullName (); }
+ }
+
+ public string NestedFullName {
+ get { return (outer == null ? FullName : (outer.NestedFullName + "/" + FullName)); }
+ }
+
+ public TypeDef OuterType {
+ get { return outer; }
+ }
+
+ public PEAPI.ClassDef PeapiType {
+ get { return classdef; }
+ }
+
+ public PEAPI.ClassDef ClassDef {
+ get { return classdef; }
+ }
+
+ public bool IsGenericType {
+ get { return (gen_params == null); }
+ }
+
+ public bool IsDefined {
+ get { return is_defined; }
+ }
+
+ public EventDef CurrentEvent {
+ get { return current_event; }
+ }
+
+ public PropertyDef CurrentProperty {
+ get { return current_property; }
+ }
+
+ public bool IsInterface {
+ get { return (attr & PEAPI.TypeAttr.Interface) != 0; }
+ }
+
+ public GenericParameters TypeParameters {
+ get { return gen_params; }
+ }
+
+ public void AddOverride (MethodDef body, BaseTypeRef parent, string name)
+ {
+ if (override_list == null)
+ override_list = new ArrayList ();
+ override_list.Add (new DictionaryEntry (body,
+ new DictionaryEntry (parent, name)));
+ }
+
+ public void AddOverride (string sig, BaseMethodRef decl)
+ {
+ if (override_long_list == null)
+ override_long_list = new ArrayList ();
+ override_long_list.Add (new DictionaryEntry (sig,
+ decl));
+ }
+
+ public void MakeValueClass ()
+ {
+ is_value_class = true;
+ }
+
+ public void MakeEnumClass ()
+ {
+ is_enum_class = true;
+ }
+
+ public void SetSize (int size)
+ {
+ this.size = size;
+ }
+
+ public void SetPack (int pack)
+ {
+ this.pack = pack;
+ }
+
+ public void AddFieldDef (FieldDef fielddef)
+ {
+ if (IsInterface && !fielddef.IsStatic) {
+ Console.WriteLine ("warning -- Non-static field in interface, set to such");
+ fielddef.Attributes |= PEAPI.FieldAttr.Static;
+ }
+
+ DictionaryEntry entry = new DictionaryEntry (fielddef.Name, fielddef.Type.FullName);
+ if (field_table [entry] != null)
+ Report.Error ("Duplicate field declaration: " + fielddef.Type.FullName + " " + fielddef.Name);
+ field_table.Add (entry, fielddef);
+ field_list.Add (fielddef);
+ }
+
+ public void AddMethodDef (MethodDef methoddef)
+ {
+ if (IsInterface && !(methoddef.IsVirtual || methoddef.IsAbstract)) {
+ Console.WriteLine ("warning -- Non-virtual, non-abstract instance method in interface, set to such");
+ methoddef.Attributes |= PEAPI.MethAttr.Abstract | PEAPI.MethAttr.Virtual;
+ }
+
+ if (method_table [methoddef.Signature] != null)
+ Report.Error ("Duplicate method declaration: " + methoddef.Signature);
+
+ method_table.Add (methoddef.Signature, methoddef);
+ }
+
+ public void BeginEventDef (EventDef event_def)
+ {
+ if (current_event != null)
+ Report.Error ("An event definition was not closed.");
+
+ current_event = event_def;
+ }
+
+ public void EndEventDef ()
+ {
+ if (event_list == null)
+ event_list = new ArrayList ();
+
+ event_list.Add (current_event);
+ current_event = null;
+ }
+
+ public void BeginPropertyDef (PropertyDef property_def)
+ {
+ if (current_property != null)
+ Report.Error ("A property definition was not closed.");
+
+ current_property = property_def;
+ }
+
+ public void EndPropertyDef ()
+ {
+ if (property_list == null)
+ property_list = new ArrayList ();
+
+ property_list.Add (current_property);
+ current_property = null;
+ }
+
+ public void AddCustomAttribute (CustomAttr customattr)
+ {
+ if (customattr_list == null)
+ customattr_list = new ArrayList ();
+
+ customattr_list.Add (customattr);
+ }
+
+ public void AddPermissionSet (PEAPI.SecurityAction sec_action, PermissionSet ps)
+ {
+ if (decl_sec == null)
+ decl_sec = new DeclSecurity ();
+
+ decl_sec.AddPermissionSet (sec_action, ps);
+ }
+
+ public void AddPermission (PEAPI.SecurityAction sec_action, IPermission iper)
+ {
+ if (decl_sec == null)
+ decl_sec = new DeclSecurity ();
+
+ decl_sec.AddPermission (sec_action, iper);
+ }
+
+ public GenericParameter GetGenericParam (string id)
+ {
+ if (gen_params == null)
+ return null;
+
+ return gen_params.GetGenericParam (id);
+ }
+
+ public GenericParameter GetGenericParam (int index)
+ {
+ if (gen_params == null || index < 0 || index >= gen_params.Count)
+ return null;
+
+ return gen_params [index];
+ }
+
+ public int GetGenericParamNum (string id)
+ {
+ if (gen_params == null)
+ return -1;
+
+ return gen_params.GetGenericParamNum (id);
+ }
+
+ /* Resolve any GenParams in constraints, parent & impl_list */
+ private void ResolveGenParams ()
+ {
+ if (gen_params == null)
+ return;
+
+ gen_params.ResolveConstraints (gen_params, null);
+
+ BaseGenericTypeRef gtr = parent as BaseGenericTypeRef;
+ if (gtr != null)
+ gtr.Resolve (gen_params, null);
+
+ if (impl_list == null)
+ return;
+
+ foreach (BaseClassRef impl in impl_list) {
+ gtr = impl as BaseGenericTypeRef;
+ if (gtr != null)
+ gtr.Resolve (gen_params, null);
+ }
+ }
+
+ public void Define (CodeGen code_gen)
+ {
+ if (is_defined)
+ return;
+
+ if (is_intransit) {
+ // Circular definition
+ Report.Error ("Circular definition of class: " + FullName);
+ }
+
+ if (outer != null) {
+ PEAPI.TypeAttr vis = attr & PEAPI.TypeAttr.VisibilityMask;
+
+ if (vis == PEAPI.TypeAttr.Private || vis == PEAPI.TypeAttr.Public) {
+ /* Nested class, but attr not set accordingly. */
+ //FIXME: 'report' warning here
+ Console.WriteLine ("Warning -- Nested class '{0}' has non-nested visibility, set to such.", NestedFullName);
+ attr = attr ^ vis;
+ attr |= (vis == PEAPI.TypeAttr.Public ? PEAPI.TypeAttr.NestedPublic : PEAPI.TypeAttr.NestedPrivate);
+ }
+ }
+
+ if (parent != null) {
+ is_intransit = true;
+ parent.Resolve (code_gen);
+
+ is_intransit = false;
+ if (parent.PeapiClass == null) {
+ Report.Error ("this type can not be a base type: "
+ + parent);
+ }
+
+ if (parent.PeapiClass.nameSpace != null &&
+ parent.PeapiClass.nameSpace.CompareTo ("System") == 0) {
+
+ if (parent.PeapiClass.name.CompareTo ("ValueType") == 0)
+ is_value_class = true;
+ else
+ if (parent.PeapiClass.name.CompareTo ("Enum") == 0 )
+ is_enum_class = true;
+ }
+
+ if (is_value_class && (attr & PEAPI.TypeAttr.Sealed) == 0) {
+ Console.WriteLine ("Warning -- Non-sealed value class, made sealed.");
+ attr |= PEAPI.TypeAttr.Sealed;
+ }
+
+ if (outer != null) {
+ if (!outer.IsDefined)
+ outer.Define (code_gen);
+ classdef = outer.PeapiType.AddNestedClass (attr,
+ name_space, name, parent.PeapiClass);
+ } else {
+ if (is_value_class || is_enum_class) {
+ // Should probably confirm that the parent is System.ValueType
+ classdef = code_gen.PEFile.AddValueClass (attr,
+ name_space, name, is_value_class ? PEAPI.ValueClass.ValueType : PEAPI.ValueClass.Enum);
+ } else {
+ classdef = code_gen.PEFile.AddClass (attr,
+ name_space, name, parent.PeapiClass);
+ }
+ }
+ } else {
+ if (outer != null) {
+ if (!outer.IsDefined)
+ outer.Define (code_gen);
+ classdef = outer.PeapiType.AddNestedClass (attr,
+ name_space, name);
+ } else {
+ if (is_value_class || is_enum_class) {
+ classdef = code_gen.PEFile.AddValueClass (attr,
+ name_space, name, is_value_class ? PEAPI.ValueClass.ValueType : PEAPI.ValueClass.Enum);
+ } else {
+ classdef = code_gen.PEFile.AddClass (attr,
+ name_space, name);
+ }
+ }
+ if (FullName == "System.Object")
+ classdef.SpecialNoSuper ();
+ }
+
+ is_defined = true;
+
+ if (size != -1 || pack != -1)
+ classdef.AddLayoutInfo ( (pack == -1) ? 1 : pack, (size == -1) ? 0 : size);
+
+ if (impl_list != null) {
+ foreach (BaseClassRef impl in impl_list) {
+ impl.Resolve (code_gen);
+ classdef.AddImplementedInterface (impl.PeapiClass);
+ }
+ }
+
+ if (gen_params != null)
+ gen_params.Resolve (code_gen, classdef);
+
+ is_intransit = false;
+
+ code_gen.AddToDefineContentsList (this);
+ }
+
+ public void DefineContents (CodeGen code_gen)
+ {
+ ArrayList fielddef_list = new ArrayList ();
+ foreach (FieldDef fielddef in field_list) {
+ fielddef.Define (code_gen, classdef);
+ fielddef_list.Add (fielddef.PeapiFieldDef);
+ }
+
+ classdef.SetFieldOrder (fielddef_list);
+
+ foreach (MethodDef methoddef in method_table.Values) {
+ methoddef.Define (code_gen);
+ }
+
+ if (event_list != null) {
+ foreach (EventDef eventdef in event_list) {
+ eventdef.Define (code_gen, classdef);
+ }
+ }
+
+ if (property_list != null) {
+ foreach (PropertyDef propdef in property_list) {
+ propdef.Define (code_gen, classdef);
+ }
+
+ }
+
+ if (customattr_list != null) {
+ foreach (CustomAttr customattr in customattr_list) {
+ customattr.AddTo (code_gen, classdef);
+ if (customattr.IsSuppressUnmanaged (code_gen))
+ classdef.AddAttribute (PEAPI.TypeAttr.HasSecurity);
+ }
+ }
+
+ /// Add declarative security to this class
+ if (decl_sec != null) {
+ decl_sec.AddTo (code_gen, classdef);
+ classdef.AddAttribute (PEAPI.TypeAttr.HasSecurity);
+ }
+
+ if (override_list != null) {
+ foreach (DictionaryEntry entry in override_list) {
+ MethodDef body = (MethodDef) entry.Key;
+ DictionaryEntry decl = (DictionaryEntry) entry.Value;
+ BaseTypeRef parent_type = (BaseTypeRef) decl.Key;
+ parent_type.Resolve (code_gen);
+ string over_name = (string) decl.Value;
+ BaseMethodRef over_meth = parent_type.GetMethodRef (body.RetType,
+ body.CallConv, over_name, body.ParamTypeList (), body.GenParamCount);
+ over_meth.Resolve (code_gen);
+ classdef.AddMethodOverride (over_meth.PeapiMethod,
+ body.PeapiMethodDef);
+ }
+ }
+
+ if (override_long_list != null) {
+ foreach (DictionaryEntry entry in override_long_list) {
+ string sig = (string) entry.Key;
+ BaseMethodRef decl = (BaseMethodRef) entry.Value;
+ MethodDef body = (MethodDef) method_table[sig];
+ decl.Resolve (code_gen);
+ classdef.AddMethodOverride (decl.PeapiMethod,
+ body.PeapiMethodDef);
+ }
+ }
+ }
+
+ public PEAPI.Method ResolveMethod (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
+ string name, BaseTypeRef [] param, int gen_param_count, CodeGen code_gen)
+ {
+ string signature = MethodDef.CreateSignature (ret_type, name, param, gen_param_count);
+ MethodDef methoddef = (MethodDef) method_table[signature];
+
+ if (methoddef != null)
+ return methoddef.Resolve (code_gen, classdef);
+ return ResolveAsMethodRef (ret_type, call_conv, name, param, gen_param_count, code_gen);
+ }
+
+ public PEAPI.Method ResolveVarargMethod (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
+ string name, BaseTypeRef [] param, int gen_param_count, PEAPI.Type [] opt, CodeGen code_gen)
+ {
+ string signature = MethodDef.CreateVarargSignature (ret_type, name, param);
+ MethodDef methoddef = (MethodDef) method_table[signature];
+
+ if (methoddef != null) {
+ methoddef.Resolve (code_gen, classdef);
+ return methoddef.GetVarargSig (opt);
+ }
+
+ return ResolveAsMethodRef (ret_type, call_conv, name, param, gen_param_count, code_gen);
+ }
+
+ private PEAPI.Method ResolveAsMethodRef (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
+ string name, BaseTypeRef [] param, int gen_param_count, CodeGen code_gen)
+ {
+ ExternTypeRef type_ref = code_gen.ThisModule.GetTypeRef (FullName, false);
+ ExternMethodRef methodref = (ExternMethodRef) type_ref.GetMethodRef (ret_type, call_conv, name, param, gen_param_count);
+ methodref.Resolve (code_gen);
+
+ return methodref.PeapiMethod;
+ }
+
+ public PEAPI.Field ResolveField (string name, BaseTypeRef ret_type, CodeGen code_gen)
+ {
+ FieldDef fielddef = (FieldDef) field_table[new DictionaryEntry (name, ret_type.FullName)];
+ if (fielddef !=null)
+ return fielddef.Resolve (code_gen, classdef);
+
+ ExternTypeRef type_ref = code_gen.ThisModule.GetTypeRef (FullName, false);
+ IFieldRef fieldref = type_ref.GetFieldRef (ret_type, name);
+ fieldref.Resolve (code_gen);
+
+ return fieldref.PeapiField;
+ }
+
+ private string MakeFullName ()
+ {
+ if (name_space == null || name_space == String.Empty)
+ return name;
+
+ return name_space + "." + name;
+ }
+
+ public int CompareTo (object obj)
+ {
+ TypeDef type_def = (TypeDef) obj;
+
+ return FullName.CompareTo (type_def.FullName);
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/TypeInstr.cs b/mcs/ilasm/codegen/TypeInstr.cs
new file mode 100644
index 00000000000..1304e9a4cb7
--- /dev/null
+++ b/mcs/ilasm/codegen/TypeInstr.cs
@@ -0,0 +1,37 @@
+//
+// Mono.ILASM.TypeInstr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class TypeInstr : IInstr {
+
+ private PEAPI.TypeOp op;
+ private BaseTypeRef operand;
+
+ public TypeInstr (PEAPI.TypeOp op, BaseTypeRef operand, Location loc)
+ : base (loc)
+ {
+ this.op = op;
+ this.operand = operand;
+ }
+
+ public override void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
+ {
+ operand.Resolve (code_gen);
+ cil.TypeInst (op, operand.PeapiType);
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/TypeManager.cs b/mcs/ilasm/codegen/TypeManager.cs
new file mode 100644
index 00000000000..029b3144632
--- /dev/null
+++ b/mcs/ilasm/codegen/TypeManager.cs
@@ -0,0 +1,60 @@
+//
+// Mono.ILASM.TypeManager.cs
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class TypeManager {
+
+ private Hashtable type_table;
+ private CodeGen code_gen;
+
+ public TypeManager (CodeGen code_gen)
+ {
+ this.code_gen = code_gen;
+ type_table = new Hashtable ();
+ }
+
+ public TypeDef this[string full_name] {
+ get {
+ return (TypeDef) type_table[full_name];
+ }
+ set {
+ type_table[full_name] = value;
+ }
+ }
+
+ public PEAPI.Type GetPeapiType (string full_name)
+ {
+ TypeDef type_def = (TypeDef) type_table[full_name];
+
+ if (type_def == null)
+ return null;
+
+ if (!type_def.IsDefined)
+ type_def.Define (code_gen);
+
+ return type_def.PeapiType;
+ }
+
+ public void DefineAll ()
+ {
+ ArrayList type_list = new ArrayList (type_table.Values);
+ type_list.Sort ();
+ foreach (TypeDef typedef in type_list) {
+ typedef.Define (code_gen);
+ }
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/TypeRef.cs b/mcs/ilasm/codegen/TypeRef.cs
new file mode 100644
index 00000000000..08846715f99
--- /dev/null
+++ b/mcs/ilasm/codegen/TypeRef.cs
@@ -0,0 +1,86 @@
+//
+// Mono.ILASM.TypeRef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ /// <summary>
+ /// Reference to a type in the module being compiled.
+ /// </summary>
+ public class TypeRef : BaseClassRef {
+
+ private Location location;
+ public static readonly TypeRef Ellipsis = new TypeRef ("ELLIPSIS", false, null);
+ public static readonly TypeRef Any = new TypeRef ("any", false, null);
+
+ public TypeRef (string full_name, bool is_valuetype, Location location)
+ : this (full_name, is_valuetype, location, null, null)
+ {
+ }
+
+ public TypeRef (string full_name, bool is_valuetype, Location location, ArrayList conv_list, string sig_mod)
+ : base (full_name, is_valuetype, conv_list, sig_mod)
+ {
+ this.location = location;
+ }
+
+ public override BaseClassRef Clone ()
+ {
+ return new TypeRef (full_name, is_valuetype, location, (ArrayList) ConversionList.Clone (), sig_mod);
+ }
+
+ protected override BaseMethodRef CreateMethodRef (BaseTypeRef ret_type,
+ PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count)
+ {
+ if (SigMod == null | SigMod == "")
+ return new MethodRef (this, call_conv, ret_type, name, param, gen_param_count);
+ else
+ return new TypeSpecMethodRef (this, call_conv, ret_type, name, param, gen_param_count);
+ }
+
+ protected override IFieldRef CreateFieldRef (BaseTypeRef ret_type, string name)
+ {
+ return new FieldRef (this, ret_type, name);
+ }
+
+ public override void Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ PEAPI.Type base_type;
+
+ base_type = code_gen.TypeManager.GetPeapiType (full_name);
+
+ if (base_type == null) {
+ Report.Error ("Reference to undefined class '" +
+ FullName + "'");
+ return;
+ }
+ type = Modify (code_gen, base_type);
+
+ is_resolved = true;
+ }
+
+ public BaseClassRef AsClassRef (CodeGen code_gen)
+ {
+ return this;
+ }
+
+ public override string ToString ()
+ {
+ return FullName;
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/TypeSpecFieldRef.cs b/mcs/ilasm/codegen/TypeSpecFieldRef.cs
new file mode 100644
index 00000000000..734c9f16224
--- /dev/null
+++ b/mcs/ilasm/codegen/TypeSpecFieldRef.cs
@@ -0,0 +1,54 @@
+//
+// Mono.ILASM.TypeSpecFieldRef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 JacksonHarper, All rights reserved
+//
+
+
+using System;
+
+
+namespace Mono.ILASM {
+
+ public class TypeSpecFieldRef : IFieldRef {
+
+ private BaseTypeRef owner;
+ private BaseTypeRef type;
+ private string name;
+
+ private PEAPI.FieldRef peapi_field;
+ private bool is_resolved;
+
+ public TypeSpecFieldRef (BaseTypeRef owner, BaseTypeRef type, string name)
+ {
+ this.owner = owner;
+ this.type = type;
+ this.name = name;
+
+ is_resolved = false;
+ }
+
+ public PEAPI.Field PeapiField {
+ get { return peapi_field; }
+ }
+
+ public void Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ owner.Resolve (code_gen);
+
+ type.Resolve (code_gen);
+ peapi_field = code_gen.PEFile.AddFieldToTypeSpec (owner.PeapiType, name, type.PeapiType);
+
+ is_resolved = true;
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/codegen/TypeSpecMethodRef.cs b/mcs/ilasm/codegen/TypeSpecMethodRef.cs
new file mode 100644
index 00000000000..ee9cb144e41
--- /dev/null
+++ b/mcs/ilasm/codegen/TypeSpecMethodRef.cs
@@ -0,0 +1,59 @@
+//
+// Mono.ILASM.TypeSpecMethodRef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+
+namespace Mono.ILASM {
+
+ public class TypeSpecMethodRef : BaseMethodRef {
+
+ public TypeSpecMethodRef (BaseTypeRef owner,
+ PEAPI.CallConv call_conv, BaseTypeRef ret_type,
+ string name, BaseTypeRef[] param, int gen_param_count)
+ : base (owner, call_conv, ret_type, name, param, gen_param_count)
+ {
+ }
+
+ public override void Resolve (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ PEAPI.Type[] param_list = new PEAPI.Type[param.Length];
+ string write_name;
+
+ ret_type.Resolve (code_gen);
+
+ int count = 0;
+ foreach (BaseTypeRef typeref in param) {
+ typeref.Resolve (code_gen);
+ param_list[count++] = typeref.PeapiType;
+ }
+
+ if (name == "<init>")
+ write_name = ".ctor";
+ else
+ write_name = name;
+
+ owner.Resolve (code_gen);
+ peapi_method = code_gen.PEFile.AddMethodToTypeSpec (owner.PeapiType, write_name,
+ ret_type.PeapiType, param_list, gen_param_count);
+
+ peapi_method.AddCallConv (call_conv);
+
+ is_resolved = true;
+ }
+ }
+
+}
+
+
+
diff --git a/mcs/ilasm/codegen/Types.cs b/mcs/ilasm/codegen/Types.cs
new file mode 100644
index 00000000000..a4f930991f1
--- /dev/null
+++ b/mcs/ilasm/codegen/Types.cs
@@ -0,0 +1,82 @@
+// Types.cs
+// (C) Sergey Chaban (serge@wildwestsoftware.com)
+
+using System;
+using System.Collections;
+using System.Reflection;
+
+namespace Mono.ILASM {
+
+ public class Types {
+
+ // maps default types to their library equivalents
+ private static Hashtable defaultTypes;
+ private static readonly object dummy;
+ private Hashtable userTypes;
+
+ static Types ()
+ {
+ dummy = new Object ();
+
+ defaultTypes = new Hashtable ();
+ Hashtable t = defaultTypes;
+
+ t ["object"] = Type.GetType ("System.Object");
+ t ["string"] = Type.GetType ("System.String");
+ t ["char"] = Type.GetType ("System.Char");
+ t ["void"] = Type.GetType ("System.Void");
+ t ["bool"] = Type.GetType ("System.Boolean");
+ t ["int8"] = Type.GetType ("System.Byte");
+ t ["int16"] = Type.GetType ("System.Int16");
+ t ["int32"] = Type.GetType ("System.Int32");
+ t ["int64"] = Type.GetType ("System.Int64");
+ t ["float32"] = Type.GetType ("System.Single");
+ t ["float64"] = Type.GetType ("System.Double");
+ t ["uint8"] = Type.GetType ("System.SByte");
+ t ["uint16"] = Type.GetType ("System.UInt16");
+ t ["uint32"] = Type.GetType ("System.UInt32");
+ t ["uint64"] = Type.GetType ("System.UInt64");
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public Types ()
+ {
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="typeName"></param>
+ /// <returns></returns>
+ public Type Lookup (string typeName)
+ {
+ Type res = defaultTypes [typeName] as Type;
+ return res;
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="name"></param>
+ /// <param name="type"></param>
+ public void Add (string name, Type type)
+ {
+ if (defaultTypes.Contains (name)) return;
+
+ if (userTypes == null) userTypes = new Hashtable ();
+ userTypes [name] = (type != null) ? type : dummy;
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="name"></param>
+ public void Add (string name){
+ Add (name, null);
+ }
+
+ }
+}
+
diff --git a/mcs/ilasm/errors/ChangeLog b/mcs/ilasm/errors/ChangeLog
new file mode 100644
index 00000000000..76e281ed457
--- /dev/null
+++ b/mcs/ilasm/errors/ChangeLog
@@ -0,0 +1,19 @@
+2006-02-10 Ankit Jain <jankit@novell.com>
+
+ * err-global.il, err-global2.il: New. Tests for refs to non-existant
+ global method/field.
+
+2006-02-02 Ankit Jain <jankit@novell.com>
+
+ * err-invalid-array-bounds.il: New. Test for 'lower bound <= upper bound'
+
+2006-01-23 Ankit Jain <jankit@novell.com>
+
+ * err-*.il, test-perm_fail*.il: Move negative tests from tests/ to here.
+
+2004-06-10 Jackson Harper <jackson@ximian.com>
+
+ * errors: This directory will contain assembly files that should
+ not compile.
+ * bad_bytearray.il: A bad bytearray in a .data line. Should give a
+ syntax error.
diff --git a/mcs/ilasm/errors/bad-bytearray.il b/mcs/ilasm/errors/bad-bytearray.il
new file mode 100644
index 00000000000..8b829c46cee
--- /dev/null
+++ b/mcs/ilasm/errors/bad-bytearray.il
@@ -0,0 +1,21 @@
+//
+// Mono.ILASM.Tests.bad_bytearray
+//
+// Author(s):
+// Jackson Harper (jackson@ximian.com)
+//
+// Copyright 2004 Novell, Inc (http://www.novell.com)
+//
+
+//
+// This test should not compile as it has a bytearray that is evil
+//
+
+.assembly extern mscorlib { }
+.assembly bad_bytearray { }
+
+
+.data some_data = bytearray (00 0G)
+
+
+
diff --git a/mcs/ilasm/errors/err-assembly.il b/mcs/ilasm/errors/err-assembly.il
new file mode 100644
index 00000000000..0f46a60e24c
--- /dev/null
+++ b/mcs/ilasm/errors/err-assembly.il
@@ -0,0 +1,12 @@
+//Error: Multiple .assembly declarations
+.assembly extern mscorlib
+{
+ .ver 1:0:5000:0
+}
+.assembly 'test'
+{
+ .hash algorithm 0x00008004
+}
+.assembly 'one'
+{
+}
diff --git a/mcs/ilasm/errors/err-field-dup1.il b/mcs/ilasm/errors/err-field-dup1.il
new file mode 100644
index 00000000000..6b91cbada7a
--- /dev/null
+++ b/mcs/ilasm/errors/err-field-dup1.il
@@ -0,0 +1,19 @@
+//Test for duplicate field names with
+//Primitive types
+
+.assembly extern mscorlib
+{
+}
+.assembly 'field-dup-1'
+{
+ .ver 0:0:0:0
+}
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+ .field private static int32 i
+ .field private static int32 i
+
+ } // end of class test
+
diff --git a/mcs/ilasm/errors/err-field-dup2.il b/mcs/ilasm/errors/err-field-dup2.il
new file mode 100644
index 00000000000..7500a738792
--- /dev/null
+++ b/mcs/ilasm/errors/err-field-dup2.il
@@ -0,0 +1,18 @@
+//Test for duplicate field names with
+//extern TypeRef types
+
+.assembly extern mscorlib
+{
+}
+.assembly 'field-dup-2'
+{
+ .ver 0:0:0:0
+}
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+ .field private static class [mscorlib]System.Int32 i
+ .field private static class [mscorlib]System.Int32 i
+
+ } // end of class test
diff --git a/mcs/ilasm/errors/err-field-dup3.il b/mcs/ilasm/errors/err-field-dup3.il
new file mode 100644
index 00000000000..0a256915de7
--- /dev/null
+++ b/mcs/ilasm/errors/err-field-dup3.il
@@ -0,0 +1,21 @@
+//Test for duplicate field names with
+//primitive types (array)
+
+.assembly extern mscorlib
+{
+ .ver 1:0:5000:0
+}
+.assembly 'field-dup3'
+{
+ .ver 0:0:0:0
+}
+.module 'field-dup.exe'
+
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+ .field private int32[] i
+ .field private int32[] i
+ }
+
diff --git a/mcs/ilasm/errors/err-field-dup4.il b/mcs/ilasm/errors/err-field-dup4.il
new file mode 100644
index 00000000000..20855836c97
--- /dev/null
+++ b/mcs/ilasm/errors/err-field-dup4.il
@@ -0,0 +1,21 @@
+//Test for duplicate field names with
+//extern TypeRef (array)
+
+.assembly extern mscorlib
+{
+ .ver 1:0:5000:0
+}
+.assembly 'field-dup4'
+{
+ .ver 0:0:0:0
+}
+.module 'field-dup.exe'
+
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+ .field private class [mscorlib]System.Int32[] i
+ .field private class [mscorlib]System.Int32[] i
+ }
+
diff --git a/mcs/ilasm/errors/err-field-dup5.il b/mcs/ilasm/errors/err-field-dup5.il
new file mode 100644
index 00000000000..8d3a773326d
--- /dev/null
+++ b/mcs/ilasm/errors/err-field-dup5.il
@@ -0,0 +1,26 @@
+//Test for duplicate field names with
+//nested extern TypeRef
+
+.assembly extern mscorlib
+{
+ .ver 1:0:5000:0
+}
+.assembly extern one
+{
+ .ver 0:0:0:0
+}
+.assembly 'field-dup5'
+{
+ .ver 0:0:0:0
+}
+.module 'field-dup.exe'
+
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+ .field private class [one]outer/inner [][] n
+ .field private class [one]outer/inner [][] n
+
+ }
+
diff --git a/mcs/ilasm/errors/err-field-dup6-gen.il b/mcs/ilasm/errors/err-field-dup6-gen.il
new file mode 100644
index 00000000000..de10c43ef37
--- /dev/null
+++ b/mcs/ilasm/errors/err-field-dup6-gen.il
@@ -0,0 +1,22 @@
+//Test for fields with same name but different types
+//GenericTypeInst
+
+.assembly extern mscorlib
+{
+ .ver 1:0:5000:0
+}
+
+.assembly 'field-dup'
+{
+ .ver 0:0:0:0
+}
+.module 'field-dup.exe'
+
+
+ .class private auto ansi beforefieldinit test`1 <T>
+ extends [mscorlib]System.Object
+ {
+ .field private class foo`1<!T> p
+ .field private class foo`1<!0> p
+ }
+
diff --git a/mcs/ilasm/errors/err-field-dup7-gen.il b/mcs/ilasm/errors/err-field-dup7-gen.il
new file mode 100644
index 00000000000..e51b90a4eb6
--- /dev/null
+++ b/mcs/ilasm/errors/err-field-dup7-gen.il
@@ -0,0 +1,23 @@
+//Test for fields with same name but different types
+//GenericTypeInst
+
+.assembly extern mscorlib
+{
+ .ver 1:0:5000:0
+}
+
+.assembly 'field-dup'
+{
+ .ver 0:0:0:0
+}
+.module 'field-dup.exe'
+
+
+ .class private auto ansi beforefieldinit test`1 <T>
+ extends [mscorlib]System.Object
+ {
+ .field private !0 p
+ .field private !T p
+
+ }
+
diff --git a/mcs/ilasm/errors/err-gen-2.il b/mcs/ilasm/errors/err-gen-2.il
new file mode 100644
index 00000000000..32947f09067
--- /dev/null
+++ b/mcs/ilasm/errors/err-gen-2.il
@@ -0,0 +1,42 @@
+//Error: Invalid method type parameter 'T' (!!T)
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly 'gen-2'
+{
+ .ver 0:0:0:0
+}
+.module 'gen-2.dll'
+
+ .class private auto ansi beforefieldinit g`1<T>
+ extends [mscorlib]System.Object
+ {
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ .method public static hidebysig
+ default void foo<M> () cil managed
+ {
+ .maxstack 8
+ IL_0000: ret
+ }
+
+ .method private hidebysig
+ instance default void abc () cil managed
+ {
+ .maxstack 8
+ IL_0000: call void class g`1<int32>::foo<!!T> ()
+ IL_0005: ret
+ }
+
+ }
+
diff --git a/mcs/ilasm/errors/err-gen-3.il b/mcs/ilasm/errors/err-gen-3.il
new file mode 100644
index 00000000000..5837d3a955f
--- /dev/null
+++ b/mcs/ilasm/errors/err-gen-3.il
@@ -0,0 +1,42 @@
+//Error: Invalid type parameter 'A' (!A)
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly 'gen-2'
+{
+ .ver 0:0:0:0
+}
+.module 'gen-2.dll'
+
+ .class private auto ansi beforefieldinit g`1<T>
+ extends [mscorlib]System.Object
+ {
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ .method public static hidebysig
+ default void foo<M> () cil managed
+ {
+ .maxstack 8
+ IL_0000: ret
+ }
+
+ .method private hidebysig
+ instance default void abc <A> () cil managed
+ {
+ .maxstack 8
+ IL_0000: call void class g`1<int32>::foo<!A> ()
+ IL_0005: ret
+ }
+
+ }
+
diff --git a/mcs/ilasm/errors/err-gen-cattr-1.il b/mcs/ilasm/errors/err-gen-cattr-1.il
new file mode 100644
index 00000000000..53dd416e51e
--- /dev/null
+++ b/mcs/ilasm/errors/err-gen-cattr-1.il
@@ -0,0 +1,45 @@
+// Test for custom attributes on a 'undefined' type parameter name
+
+.assembly extern mscorlib
+{
+}
+.assembly 'err-gen-cattr-1'
+{
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module 'err-gen-cattr-1.exe'
+
+.class private auto ansi beforefieldinit GenParAttribute
+ extends [mscorlib]System.Attribute
+{
+ .custom instance void [mscorlib]System.AttributeUsageAttribute::.ctor(valuetype [mscorlib]System.AttributeTargets) = ( 01 00 00 40 00 00 00 00 )
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Attribute::.ctor()
+ IL_0006: ret
+ }
+
+}
+
+.class private auto ansi beforefieldinit cons`1<A>
+ extends [mscorlib]System.Object
+{
+ .param type M
+ .custom instance void GenParAttribute::.ctor() = ( 01 00 00 00 )
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ }
+
+}
+
diff --git a/mcs/ilasm/errors/err-gen-cattr-2.il b/mcs/ilasm/errors/err-gen-cattr-2.il
new file mode 100644
index 00000000000..e18131794bb
--- /dev/null
+++ b/mcs/ilasm/errors/err-gen-cattr-2.il
@@ -0,0 +1,53 @@
+// Test for custom attributes on a 'undefined' method type parameter
+
+.assembly extern mscorlib
+{
+}
+.assembly 'err-gen-cattr-2'
+{
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module 'err-gen-cattr-2.exe'
+
+.class private auto ansi beforefieldinit GenParAttribute
+ extends [mscorlib]System.Attribute
+{
+ .custom instance void [mscorlib]System.AttributeUsageAttribute::.ctor(valuetype [mscorlib]System.AttributeTargets) = ( 01 00 00 40 00 00 00 00 )
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Attribute::.ctor()
+ IL_0006: ret
+ }
+
+}
+
+.class private auto ansi beforefieldinit cons`1<A>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig instance void
+ abc<M>() cil managed
+ {
+ .param type A
+ .custom instance void GenParAttribute::.ctor() = ( 01 00 00 00 )
+
+ .maxstack 8
+ IL_0000: nop
+ IL_0001: ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ }
+
+}
+
diff --git a/mcs/ilasm/errors/err-gen-cattr-3.il b/mcs/ilasm/errors/err-gen-cattr-3.il
new file mode 100644
index 00000000000..94270621d27
--- /dev/null
+++ b/mcs/ilasm/errors/err-gen-cattr-3.il
@@ -0,0 +1,46 @@
+// Test for custom attributes on a 'undefined' type parameter index
+
+.assembly extern mscorlib
+{
+}
+.assembly 'err-gen-cattr-3'
+{
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module 'err-gen-cattr-3.exe'
+
+.class private auto ansi beforefieldinit GenParAttribute
+ extends [mscorlib]System.Attribute
+{
+ .custom instance void [mscorlib]System.AttributeUsageAttribute::.ctor(valuetype [mscorlib]System.AttributeTargets) = ( 01 00 00 40 00 00 00 00 )
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Attribute::.ctor()
+ IL_0006: ret
+ }
+
+}
+
+.class private auto ansi beforefieldinit cons`1<A>
+ extends [mscorlib]System.Object
+{
+ /* Type parameter index is 1-based */
+ .param type [2]
+ .custom instance void GenParAttribute::.ctor() = ( 01 00 00 00 )
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ }
+
+}
+
diff --git a/mcs/ilasm/errors/err-gen-cattr-4.il b/mcs/ilasm/errors/err-gen-cattr-4.il
new file mode 100644
index 00000000000..81e35978b55
--- /dev/null
+++ b/mcs/ilasm/errors/err-gen-cattr-4.il
@@ -0,0 +1,53 @@
+// Test for custom attributes on a 'undefined' method type parameter index
+
+.assembly extern mscorlib
+{
+}
+.assembly 'err-gen-cattr-4'
+{
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module 'err-gen-cattr-4.exe'
+
+.class private auto ansi beforefieldinit GenParAttribute
+ extends [mscorlib]System.Attribute
+{
+ .custom instance void [mscorlib]System.AttributeUsageAttribute::.ctor(valuetype [mscorlib]System.AttributeTargets) = ( 01 00 00 40 00 00 00 00 )
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Attribute::.ctor()
+ IL_0006: ret
+ }
+
+}
+
+.class private auto ansi beforefieldinit cons`1<A>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig instance void
+ abc<M>() cil managed
+ {
+ /* Type parameter index is 1-based */
+ .param type [0]
+ .custom instance void GenParAttribute::.ctor() = ( 01 00 00 00 )
+
+ .maxstack 8
+ IL_0000: nop
+ IL_0001: ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ }
+
+}
diff --git a/mcs/ilasm/errors/err-global.il b/mcs/ilasm/errors/err-global.il
new file mode 100644
index 00000000000..911fd58f559
--- /dev/null
+++ b/mcs/ilasm/errors/err-global.il
@@ -0,0 +1,33 @@
+//Tests global field ref to a non-existant field
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly 'err-global'
+{
+ .ver 0:0:0:0
+}
+.module 'err-global.dll'
+
+.class private auto ansi beforefieldinit abc
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ }
+
+ .method public hidebysig static void bar() cil managed
+ {
+ .maxstack 8
+ ldsfld int32 somefield
+ pop
+ ret
+ }
+
+}
diff --git a/mcs/ilasm/errors/err-global2.il b/mcs/ilasm/errors/err-global2.il
new file mode 100644
index 00000000000..97253803269
--- /dev/null
+++ b/mcs/ilasm/errors/err-global2.il
@@ -0,0 +1,32 @@
+//Tests global generic method ref to a non-existant method
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly 'err-global2'
+{
+ .ver 0:0:0:0
+}
+.module 'err-global2.dll'
+
+.class private auto ansi beforefieldinit abc
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ }
+
+ .method public hidebysig static void bar() cil managed
+ {
+ .maxstack 8
+ call void foo ()
+ ret
+ }
+
+}
diff --git a/mcs/ilasm/errors/err-invalid-array-bounds.il b/mcs/ilasm/errors/err-invalid-array-bounds.il
new file mode 100644
index 00000000000..c2ce0bb0df7
--- /dev/null
+++ b/mcs/ilasm/errors/err-invalid-array-bounds.il
@@ -0,0 +1,40 @@
+// Test for invalid array bounds, [5...1]
+// lower bound <= upper bound
+
+.assembly extern mscorlib
+{
+ .ver 1:0:5000:0
+ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+}
+.assembly 'err-invalid-array-bounds'
+{
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module 'err-invalid-array-bounds.exe'
+
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ .method public static hidebysig
+ default void Main () cil managed
+ {
+ .entrypoint
+ .maxstack 0
+ .locals init (
+ int32[5...1] V_0)
+ IL_0000: ret
+ }
+
+ }
diff --git a/mcs/ilasm/errors/error-label-a.il b/mcs/ilasm/errors/error-label-a.il
new file mode 100644
index 00000000000..0b3aa4b3a55
--- /dev/null
+++ b/mcs/ilasm/errors/error-label-a.il
@@ -0,0 +1,18 @@
+
+.assembly extern mscorlib { }
+.assembly 'error-label-a' { }
+
+.class public T {
+
+ .method public static void main ()
+ {
+ .entrypoint
+
+ ldc.i4.1
+ brfalse label_no_exist
+
+ ret
+ }
+
+}
+
diff --git a/mcs/ilasm/errors/test-perm_fail-1.il b/mcs/ilasm/errors/test-perm_fail-1.il
new file mode 100644
index 00000000000..6e02e11a795
--- /dev/null
+++ b/mcs/ilasm/errors/test-perm_fail-1.il
@@ -0,0 +1,19 @@
+.assembly extern mscorlib
+{
+}
+.assembly 'test-perm_fail-1'
+{
+}
+
+ .class interface public auto ansi abstract foo
+ {
+
+ .method public virtual hidebysig newslot abstract
+ instance default void abc () cil managed
+ {
+ //Invalid enum value
+ .permission demand [mscorlib]System.Security.Permissions.IsolatedStorageFilePermissionAttribute ("UsageAllowed"=[mscorlib]System.Security.Permissions.IsolatedStorageContainment (1))
+
+ }
+
+ }
diff --git a/mcs/ilasm/errors/test-perm_fail-2.il b/mcs/ilasm/errors/test-perm_fail-2.il
new file mode 100644
index 00000000000..64d977383ef
--- /dev/null
+++ b/mcs/ilasm/errors/test-perm_fail-2.il
@@ -0,0 +1,18 @@
+.assembly extern mscorlib
+{
+}
+.assembly 'test-perm_fail-2'
+{
+}
+
+ .class interface public auto ansi abstract foo
+ {
+
+ .method public virtual hidebysig newslot abstract
+ instance default void abc () cil managed
+ {
+ //reqopt allowed only for .assembly
+ .permission reqopt [mscorlib]System.Security.Permissions.IsolatedStorageFilePermissionAttribute ("UsageAllowed"=[mscorlib]System.Security.Permissions.IsolatedStorageContainment (16))
+
+ }
+ }
diff --git a/mcs/ilasm/errors/test-perm_fail-3.il b/mcs/ilasm/errors/test-perm_fail-3.il
new file mode 100644
index 00000000000..92c0611fbfc
--- /dev/null
+++ b/mcs/ilasm/errors/test-perm_fail-3.il
@@ -0,0 +1,18 @@
+.assembly extern mscorlib
+{
+}
+.assembly 'test-perm_fail-3'
+{
+}
+
+ .class interface public auto ansi abstract foo
+ {
+
+ .method public virtual hidebysig newslot abstract
+ instance default void abc () cil managed
+ {
+ //reqmin allowed only for .assembly
+ .permission reqmin [mscorlib]System.Security.Permissions.IsolatedStorageFilePermissionAttribute ("UsageAllowed"=[mscorlib]System.Security.Permissions.IsolatedStorageContainment (16))
+
+ }
+ }
diff --git a/mcs/ilasm/errors/test-perm_fail-4.il b/mcs/ilasm/errors/test-perm_fail-4.il
new file mode 100644
index 00000000000..b5f2bd5cc94
--- /dev/null
+++ b/mcs/ilasm/errors/test-perm_fail-4.il
@@ -0,0 +1,18 @@
+.assembly extern mscorlib
+{
+}
+.assembly 'test-perm_fail-4'
+{
+}
+
+ .class interface public auto ansi abstract foo
+ {
+
+ .method public virtual hidebysig newslot abstract
+ instance default void abc () cil managed
+ {
+ //reqrefuse allowed only for .assembly
+ .permission reqrefuse [mscorlib]System.Security.Permissions.IsolatedStorageFilePermissionAttribute ("UsageAllowed"=[mscorlib]System.Security.Permissions.IsolatedStorageContainment (16))
+
+ }
+ }
diff --git a/mcs/ilasm/ilasm.exe.sources b/mcs/ilasm/ilasm.exe.sources
new file mode 100644
index 00000000000..a2e78f04df7
--- /dev/null
+++ b/mcs/ilasm/ilasm.exe.sources
@@ -0,0 +1,81 @@
+Driver.cs
+Report.cs
+AssemblyInfo.cs
+codegen/CodeGen.cs
+codegen/Module.cs
+codegen/DebuggingInfo.cs
+codegen/ExternTable.cs
+codegen/InstrTable.cs
+codegen/FieldDef.cs
+codegen/ParamDef.cs
+codegen/MethodDef.cs
+codegen/LabelInfo.cs
+codegen/TypeDef.cs
+codegen/DataDef.cs
+codegen/BaseTypeRef.cs
+codegen/BaseClassRef.cs
+codegen/BaseGenericTypeRef.cs
+codegen/TypeRef.cs
+codegen/PeapiTypeRef.cs
+codegen/ExternTypeRef.cs
+codegen/PrimitiveTypeRef.cs
+codegen/TypeManager.cs
+codegen/IInstr.cs
+codegen/IntInstr.cs
+codegen/LdstrInstr.cs
+codegen/SimpInstr.cs
+codegen/MiscInstr.cs
+codegen/LdcInstr.cs
+codegen/BranchInstr.cs
+codegen/SwitchInstr.cs
+codegen/TypeInstr.cs
+codegen/MethodInstr.cs
+codegen/Local.cs
+codegen/BaseMethodRef.cs
+codegen/ExternMethodRef.cs
+codegen/MethodRef.cs
+codegen/GlobalMethodRef.cs
+codegen/GenericMethodRef.cs
+codegen/GenericMethodSig.cs
+codegen/IFieldRef.cs
+codegen/ExternFieldRef.cs
+codegen/GlobalFieldRef.cs
+codegen/FeatureAttr.cs
+codegen/EventDef.cs
+codegen/PropertyDef.cs
+codegen/FieldRef.cs
+codegen/FieldInstr.cs
+codegen/LdtokenInstr.cs
+codegen/CalliInstr.cs
+codegen/TryBlock.cs
+codegen/ISehClause.cs
+codegen/FilterBlock.cs
+codegen/FinallyBlock.cs
+codegen/HandlerBlock.cs
+codegen/FaultBlock.cs
+codegen/CatchBlock.cs
+codegen/CustomAttr.cs
+codegen/DeclSecurity.cs
+codegen/GenericParamRef.cs
+codegen/GenericTypeInst.cs
+codegen/TypeSpecMethodRef.cs
+codegen/TypeSpecFieldRef.cs
+codegen/ModifiableType.cs
+codegen/Sentinel.cs
+codegen/FileRef.cs
+codegen/MethodPointerTypeRef.cs
+codegen/GenericArguments.cs
+codegen/GenericParameters.cs
+parser/ScannerAdapter.cs
+scanner/ILReader.cs
+scanner/ILTokenizingException.cs
+scanner/ILTables.cs
+scanner/ILToken.cs
+scanner/ILTokenizer.cs
+scanner/InstrToken.cs
+scanner/ITokenStream.cs
+scanner/Location.cs
+scanner/NumberHelper.cs
+scanner/StringHelperBase.cs
+scanner/StringHelper.cs
+../build/common/Consts.cs
diff --git a/mcs/ilasm/parser/.cvsignore b/mcs/ilasm/parser/.cvsignore
new file mode 100644
index 00000000000..220eab16f03
--- /dev/null
+++ b/mcs/ilasm/parser/.cvsignore
@@ -0,0 +1,2 @@
+
+ILParser.cs
diff --git a/mcs/ilasm/parser/ChangeLog b/mcs/ilasm/parser/ChangeLog
new file mode 100644
index 00000000000..fbff48409d3
--- /dev/null
+++ b/mcs/ilasm/parser/ChangeLog
@@ -0,0 +1,965 @@
+2006-02-20 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay: Remove D_CONSTRAINT
+
+2006-02-20 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay: Update to use Report.Error instead of directly throwing
+ an exception.
+
+2006-02-09 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (bound | int32): Handle invalid -ve size.
+
+2006-02-02 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (bound | int32 ELLIPSIS int32): Throw exception if
+ lower_bound > upper_bound.
+
+2006-01-28 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (pinv_attr | ..): Fix typo.
+
+2006-01-28 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (method_ref): Remove 2 redundant productions.
+ (method_decl | D_OVERRIDE K_METHOD ..): New production for overriding
+ generic methods.
+
+2006-01-27 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (formal_typars_clause): Allow generics only for NET_2_0 profile.
+ (typars_clause): Likewise.
+
+2006-01-19 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (decl | customattr_decl): Add custom attributes.
+ (assembly_all | ..): Set CurrentCustomAttrTarget to null.
+
+2006-01-19 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (K_TYPE): New.
+ (param_type_decl): New. Rule for '.param type ..', for specifying custom attibutes
+ for type parameters.
+ (class_decl | param_type_decl):
+ (method_decl | param_type_decl): New.
+
+2006-01-16 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (K_BESTFIT):
+ (K_CHARMAPERROR):
+ (K_ON):
+ (K_OFF): New tokens.
+ (pinv_attr | ..): Add rules for the new tokens.
+
+2006-01-16 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (K_UINT): New token.
+ (type | K_NATIVE K_UINT): New.
+
+2006-01-15 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (method_decl): Add new "full" syntax specifying overrides.
+
+2006-01-13 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay: Update to use codegen.GetTypeRef instead of creating
+ TypeRefs.
+ Update to use BaseMethodRef.GetGenericMethodRef instead of creating them.
+
+2006-01-13 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay: Update to use CodeGen.GetGlobalMethodRef &
+ CodeGen.GetGlobalFieldRef instead of creating objects.
+
+2006-01-13 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay: Update to use Base* instead of ITypeRef, IClassRef
+ & IGenTypeRef.
+
+2006-01-10 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (type | BANG ..): Move !* and !!* rules to ..
+ (generic_class_ref): ..this, to allow using VAR/MVARs as class refs.
+ Eg. "extends !0"
+
+2006-01-09 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (type_spec : class_ref): Remove.
+
+2006-01-09 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay: Update to use GenericParamRef instead of GenericTypeRef.
+
+2006-01-08 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (constraint_decl): Remove. This syntax is no longer used.
+ (class_decl | constraint_decl): Remove.
+
+2006-01-07 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay: Update to use new GenericParameters class.
+ (generic_class_ref| K_CLASS class_ref typars_clause): New.
+ Update rules to use generic_class_ref instead of 'K_CLASS class_ref..'
+ (constraints_clause): New.
+ (constraints): New. Rules for constraints on generic parameters.
+ (formal_typar_attr): New. Generic param attributes (.ctor, valuetype, class).
+ (formal_typars): Update to use new constraints stuff.
+
+2006-01-06 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (field_init): Add rules for UINT8/UINT16/etc
+
+2006-01-06 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (sec_decl | D_PERMISSION sec_action comp_qstring): New. Support
+ new (2.0) syntax which uses string(xml) instead of a bytearray for specifying
+ value of the security attribute.
+
+2006-01-06 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (GetTypeRef): Use new IClassRef.Clone .
+ (extends_clause): Use new IClassRef.GetGenericTypeInst.
+ (impl_clause | K_IMPLEMENTS class_refs): Remove.
+ (impl_clause | impl_class_refs): New.
+ (impl_class_refs): New. Add rules for generic and non-generic interface
+ implementations.
+ (class_ref | slashed_name): Use new codegen.GetTypeRef so that the TypeRef
+ gets cached.
+ (type | K_CLASS class_ref): Add typars_clause to the rule and handle accordingly.
+ (type | K_VALUETYPE ...): Likewise.
+
+2005-12-24 Jb Evain <jbevain@gmail.com>
+
+ * ILParser.jay (prop_attr): Activate instance keyword on properties.
+
+2005-12-22 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (method_head | ..): Update usage of MethodDef.ctor to pass
+ codegen.CurrentTypeDef also. ResolveGenParams is called by MethodDef internally.
+ (instr | INSTR_FIELD ..): Update usage of MethodDef.ResolveGenParam .
+
+2005-12-21 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay: Update to use new GenericArguments class for 'typars'.
+
+2005-12-14 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay: Add K_UINT8, K_UINT16, K_UINT32 and K_UINT64 tokens.
+ (type): Add rule for the new keywords.
+ (native_type): Likewise.
+ Fix #76978.
+
+2005-12-13 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (class_head | D_CLASS ..): Use 'comp_name' instead of 'id' to allow
+ dotted names.
+
+2005-12-09 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (class_decl | D_OVERRIDE ..): Update usage of ITypeRef.GetMethodRef
+ and MethodDef.CreateSignature .
+ (method_head | D_METHOD ..): Update usage of MethodDef.ctor .
+ Use MethodDef.ResolveGenParams to resolve VARs/MVARs in parameter list.
+ (type | K_CLASS slashed_name ..): Remove redundant rule.
+ (type | BANG id): New. Generic type parameter.
+ (type | BANG BANG id): New. Generic method type parameter.
+ (instr | INSTR_FIELD type ..): Resolve generic param for 'type'.
+ (method_ref | call_conv ..): Set MethodRef's GenParamCount.
+ (method_ref | call_conv type ..): Update usage of TypeSpecMethodRef.ctor and GetMethodRef.
+ (method_ref | call_conv type ..): New. Rule for global generic method refs.
+ (custom_type | call_conv ..): Update usage of GlobalMethodRef.ctor .
+
+2005-12-05 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (type | BANG int32 .. ): Update to use GenParam instead of
+ PEAPI.MVar and PEAPI.GenericTypeSpec.
+ (method_head | D_METHOD ..): Set callConv to Generic if the method has type
+ parameters.
+ (method_ref | call_conv ...): Likewise.
+
+2005-09-15 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (ILParser.NameValuePair): New.
+ (ILParser.PermPair): New.
+ (ILParser.CheckSecurityActionValidity): New.
+ (ILParser.ClassRefToObject): New.
+ (ILParser.TypeSpecToPermPair): New.
+ (class_decl | sec_decl): Use the new codegen.AddPermission .
+ (method_decl | sec_decl): Use the new codegen.AddPermission .
+ (sec_decl | D_PERMISSION ..): Use the new TypeSpecToPermPair method.
+ (sec_decl | D_PERMISSIONSET ..): Use PermissionSetAttribute to create PermissionSet
+ which will validate the bytearray.
+ (nameval_pairs): Create ArrayList of NameValuePair.
+ (nameval_pair): Create NameValuePair.
+ (cavalue | class_ref): Use ClassRefToObject.
+ (assembly_decl | sec_decl): Use the new codegen.AddAssemblyPermission .
+
+2005-09-08 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (decl | D_STACKRESERVE int64): New. Set stack reserve.
+
+2005-08-29 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay : Comment out K_LCID token.
+
+2005-08-29 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (native_type | K_CUSTOM ..): Instantiate object of CustomMarshaller
+ class.
+
+2005-08-23 Ankit Jain <jankit@novell.com>
+
+ * ILParser (method_ref : call_conv..): Use TypeRef instead of PrimitiveTypeRef
+ if this assembly is mscorlib.
+ (type | ..): Correct names of primitive types.
+
+2005-08-18 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (instr | INSTR_R bytes_list): Convert bytes_list to single/double
+ and add the corresponding instruction.
+
+2005-08-18 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay: Comment out K_PUBLICKEY keyword, not used in the grammar.
+
+2005-08-16 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (native_type | K_FIXED K_SYSSTRING ..): Instantiate
+ object of PEAPI.FixedSysString.
+ (native_type | native_type OPEN_BRACKET ..): Instantiate object of
+ NativeArray with the proper arguments.
+ (native_type | K_METHOD): Use NativeType.FuncPtr.
+ (native_type | K_FIXED K_ARRAY ..): Instantiate object of FixedArray.
+ (native_type | K_SAFEARRAY ..): Instantiate object of SafeArray.
+ (variant_type): Use appropriate values from SafeArrayType enum.
+ (field_decl | D_FIELD ..): Cast repeat_opt to int before casting to uint
+ as repeat_opt is int32.
+ (field_attr | field_attr K_MARSHAL ..): Add Marshal info for field.
+ Set field attr to HasFieldMarshal.
+ (method_head): Add Marshal info for return type if specified.
+ (sig_arg | param_attr ..): Create ParamDef and add marshal info.
+
+2005-08-11 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (class_ref | slashed_name): Don't use PrimitiveTypeRef for
+ primitive types if the assembly being compiled is 'mscorlib'.
+ (seh_clause | K_CATCH ..): Report error if exception(class_ref) is a
+ PrimitiveTypeRef.
+
+2005-08-08 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (method_decl | D_ENTRYPOINT): Set codegen.HasEntryPoint
+ to true.
+
+2005-08-05 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (class_decl, method_decl | sec_decl): Use
+ codegen.CurrentDeclSecurityTarget for adding DeclSecurity info.
+ (assembly_decl | sec_decl): Use codegen.AddAssemblyDeclSecurity
+ for adding DeclSecurity info.
+ (sec_decl): Instantiate DeclSecurity object.
+ (sec_action | K_REQUEST, K_DEMAND, .. etc): Use the corresponding
+ value from PEAPI.SecurityAction enum.
+
+2005-05-12 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Handle lists of data items correctly.
+
+2005-05-10 Ankit Jain <ankit@corewars.org>
+
+ Fix #74768.
+ * ILParser.jay (type): Emit TypeRefs instead of TypeSpecs for valuetypes,
+ so don't create ExternTypeRefInst.
+ Hack along with Hari.
+
+2005-04-30 Ankit Jain <ankit@corewars.org>
+
+ * ILParser.jay (event_decl): Add custom attribute.
+
+2005-04-27 Ankit Jain <ankit@corewars.org>
+
+ * ILParser.jay (method_ref): Let owner.GetMethodRef handle the
+ creation of TypeSpecMethodRef.
+
+2005-04-26 Ankit Jain <ankit@corewars.org>
+
+ * ILParser.jay (comp_name): Allow n.a.'b' .
+
+2005-04-18 Ankit Jain <ankit@corewars.org>
+
+ * ILParser.jay (manifestres_head): Read resource file and
+ add ManifestResource with CodeGen.
+ (manres_attr): Set visibility flag of the resource.
+
+2005-04-12 Ankit Jain <ankit@corewars.org>
+
+ * ILParser.jay (class_decl, method_decl, prop_decl,
+ assemblyref_decl | customattr_decl): Use
+ codegen.CurrentCustomAttrTarget for adding custom
+ attributes.
+ (field_decl, method_decl, event_head, prop_head):
+ Set codegen.CurrentCustomAttrTarget
+
+2005-04-08 Ankit Jain <radical@corewars.org>
+
+ * ILParser.jay (type): When parsing K_VALUETYPE, mark the typeref
+ as a value type.
+ (field_init): The float32 and float64 constructor argument is
+ the hex representation, not the integer equivalent value.
+
+2005-03-17 Ankit Jain <radical@corewars.org>
+
+ * ILParser.jay(method_decl): Add default value for a method param.
+
+2004-12-02 Miguel de Icaza <miguel@ximian.com>
+
+ * ILParser.jay(field_init): Explicit cast to the target type, this
+ is what ilasm does (0xFFFFFFFF) as an int gets translated
+
+ Added D_STACKRESERVE token.
+
+ (prop_head, event_head): Allow it to take a compound name (for explicit
+ interface implementations of properties).
+
+2004-07-21 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Clones ExternTypeRefInsts as well as
+ ExternTypeRefs, wrap this check into a method so things are
+ somewhat clean.
+
+2004-07-08 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Add custom attributes to assemblyrefs.
+
+2004-06-26 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: vtable fixups use the int32 or int64 keyword, not
+ actual int values. When adding modules for pinvoke info use the
+ ExternTable so we dont get duplicate modules.
+
+2004-06-19 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Resolve method pointers that are being treated as
+ typerefs.
+
+2004-06-19 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Resolve other modules global 'type'.
+
+2004-06-14 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Add file refs.
+
+2004-06-14 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Add module refs, allow them to be referenced.
+
+2004-06-14 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Set module names.
+
+2004-05-25 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Fix casting for data type constants.
+
+2004-05-22 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: [,] is short form for [...,...] this fixes bug
+ number 58569.
+
+2004-05-22 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Handle wchar, it is just an alias for char. This
+ fixes bug #58523.
+
+2004-05-05 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Handle endian issues when converting numeric
+ types.
+
+2004-04-14 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Correct args for version numbers.
+
+2004-04-03 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Dont use hash alg enum its too restrictive
+
+2004-04-02 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Set assembly info.
+
+2004-04-01 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Set a flag in the tokenizer when parsing byte
+ arrays. Otherwise we can't tell WTF they are. Set assemblyref
+ attributes.
+
+2004-03-28 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Fix typo.
+
+2004-03-28 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Set true and false literals properly. Add instance
+ property attribute.
+
+2004-02-18 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Create ExternTypeRefInsts when a valuetype
+ extern_class is encountered. This way the underlying type is not
+ changed to a value type.
+
+
+2003-12-10 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: When modifying extern types, clone them and modify
+ the clone.
+
+2003-12-10 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Use the extern table for all extern type
+ creations.
+
+2003-12-10 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Add COMP_NAME token.
+
+2003-12-10 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: vtable fixups can be int32s
+
+2003-11-18 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Add zeroinit.
+
+2003-11-17 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Create strings from byte arrays. Fix parsing of
+ bytes that are passed as INT64.
+
+2003-11-16 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Handle string instructions that are given byte
+ arrays. This fixes bug #51039.
+
+2003-10-28 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Use the ExternTable to create external type
+ references. Remove some ultra top secret debugging code.
+
+2003-10-17 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Set value types, set enums as value types. Use
+ correct var for call conv in method signatures.
+
+2003-10-10 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Create generic method refs.
+
+2003-10-08 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Attach generic type parameters to methods.
+
+2003-09-27 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Set pinvoke info. Allow param attributes in type
+ lists.
+
+2003-09-21 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Define data
+
+2003-09-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: dashed names aren't legal for file names, if the
+ name has a dash in it it needs to be quoted ie 'gtk-sharp'.
+
+2003-09-12 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Fix typo in field inits. Methods attached to
+ modified types should be type spec method refs.
+
+2003-08-19 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Implement address constants and string
+ constants. Add data definitions to their types, and create data
+ item lists. Also implement long form overrides.
+
+2003-08-19 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add override methods.
+
+2003-08-10 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Create an empty array list for empty type
+ lists. Start phasing out INT32 because the tokenizer will no
+ longer create this token.
+
+2003-08-03 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Use new sentinel type. Create valuetypes.
+
+2003-08-03 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Make value types and enum types.
+
+2003-08-03 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Create label references where appropriate instead
+ of adding labels.
+
+2003-08-02 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Set from label, not to label for filter block handlers
+
+2003-07-30 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Create branch instructions with explicit offsets
+
+2003-07-29 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Use new labeling system for handler blocks.
+
+2003-07-29 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: No longer need to supply method references
+ to instructions, they get that when emitting now.
+
+2003-07-28 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Use TypeRef.Ellipsis instead of null for a
+ placeholder in bound arrays. Do not use AsClassRef anymore.
+
+2003-07-21 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Set maxstack
+
+2003-07-20 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Do not use the AsClassRef method anymore to attach
+ methods and fields to types. All types can do this now. Create
+ generic type refs and generic type instances.
+
+2003-07-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add generic type refs, and fake generic class refs.
+
+2003-07-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add generic type constraints and tokens used to
+ create them
+
+2003-07-16 Peter Williams <peter@newton.cx>
+
+ * .cvsignore: ILParser.cs has been moved.
+
+2003-07-14 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Seperate generic constraints from generic parameters.
+
+2003-06-14 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add set imagebase, subsystem, and corflags.
+
+2003-06-14 Jackson Harper <jackson@latitidegeo.com>
+
+ * ILParser.jay: Implement custom modified types.
+
+2003-06-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Implement properties
+
+2003-06-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add generic type parameters to types. Implement events.
+
+2003-06-04 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Assembly and module names may have dashes in them
+ (like gtk-sharp.dll).
+
+2003-05-31 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Set assembly names. When looking up types in the
+ form [assembly]name first check if the assembly is this
+ assembly. Implement scope_blocks, and implement scope block form
+ exception handling.
+
+2003-05-31 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Use type instead of params for calli signatures.
+
+2003-05-31 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: When looking up types first check to see if this
+ is actually a primitive object type (System.String,
+ System.Object). Add custom attributes to types. Handle the il
+ keyword the exact same way as cil. Add ellipsises to param and sig
+ lists. Add an optional name to typelists, this is just parsed it
+ is not implemented properly. Add custom attributes to
+ methods. Implement custom types (just methodrefs to ctors).
+
+2003-05-25 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Pass call conv to methoref constructors. Add the
+ ELLIPSIS to type_lists, this is for vararg methods
+
+2003-05-23 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Remove top secret debugging code.
+
+2003-05-23 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Implement label form structured exception handling.
+
+2003-05-22 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Comment out K_IMF and K_NAN these are not used in
+ the grammar.
+
+2003-05-21 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add ldc.r4 to INSTR_R int also fix cast to double.
+
+2003-05-21 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: When converting from int32 to int64 do an exact
+ bit conversion, not a numerical conversion.
+
+2003-05-21 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: INT_I8s are not int instructions, currently the
+ only INT_I8 instruction is ldc.i8 so this new code does more
+ checks then needed but is written in anticipation of some new long
+ instructions being found. Implement signature instructions, token
+ instructions, and signatures. Convert INT32s masquerading as
+ INT64s to Int64.
+
+2003-05-19 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Same as below but with float64 ()
+
+2003-05-19 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: When the float32 (0xFFFFFF) syntax is used the hex
+ value represents the exact byte value of a float NOT an integer
+ value that is converted to a float.
+
+2003-05-18 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Use new methods for converting types to
+ classrefs. Expand grammar for locals.
+
+
+2003-05-18 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Convert cast integers to floats.
+
+2003-05-11 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add tokens for instructions that take param and
+ local args. Do not create empty lists for sig_args and
+ type_lists. Add param and local instructions.
+
+2003-05-11 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Set size and packing information for types
+
+2003-05-10 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add field instructions
+
+2003-05-10 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add global method references
+
+2003-05-10 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add locals, method references, and method instructions
+
+2003-05-07 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add type instructions. NOTE - type_spec is not
+ fully implemented yet, so this has some explosive potential.
+
+2003-05-07 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Remove dotted_name, it is not used at all
+ anymore. vtattr only take an int64 param, this fix gets rid of all
+ of the remaining reduce/reduce conflicts
+
+2003-05-07 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Remove extraneous dotted_name, also make comp_name
+ contain dotted_name logic. Oh how I will miss the 301
+ reduce/reduce conflicts these small changes fixed :-)
+
+2003-05-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Emit INSTR_I8 instructions as int
+ instructions. Implement label lists, emit switch instruction.
+
+2003-05-05 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add labels to methods, add branching instructions.
+
+2003-05-04 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Use new MiscInstr.ldstr for ldstr, add INSTR_Rs
+
+2003-05-04 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Set int64's masquerading as int32 to upper and
+ lower bounds if neccasary. NEED TO TEST this behavoir on windows.
+
+2003-05-01 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Fix a bunch of conversions, implement hexbytes
+
+2003-04-30 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Implement non marshalled methodheads, method
+ attributes, impl attributes, imit simple int and ldstr instructions.
+
+2003-04-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Define data, fix repeat_opt allways being set.
+
+2003-04-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add external types to the extern type table.
+
+2003-04-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Use new types and methods to build a tree.
+
+2003-04-07 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Implement data items
+
+2003-04-07 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Implement most field features
+
+2003-04-05 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Set type parameter index
+
+2003-04-05 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Emit parameterized types
+
+2003-04-04 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add parameterized method declarations.
+
+2003-04-03 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add parameterized types to classes.
+
+2003-04-02 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Support most non-obsolete native types.
+
+2003-04-02 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Proper names for native int and native uint
+
+2003-04-01 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add Call conventions, fix primitive spelling.
+
+2003-04-01 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add TypedRef primative type.
+
+2003-04-01 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Support pinned, modreq, and modopt types.
+
+2003-04-01 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Use the CodeGen CompleteClass method when a class
+ is completed instead of setting the current class to null. This
+ does some extra cleanup
+
+2003-03-31 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add bound arrays
+
+2003-03-30 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Concat slashed names properly
+
+2003-03-30 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Implement most of type
+
+2003-03-30 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add code from old parser to declare and define classes.
+
+2003-03-30 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: New grammar that I haven't made a mess of, this
+ takes all the special cases into account much better.
+
+2003-03-19 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: .hash algorithm can be followed by bytes
+
+2003-03-19 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Allow assembly refs to have dots in name.
+
+2003-03-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add object to primative types
+
+2003-03-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Set CallConv for opcodes that have a call conv,
+ like call and newobj
+
+2003-03-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Set CallConvs properly, use type_ref instead of type for
+ method overrides.
+
+2003-03-16 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: .ctor and .cctor can also be method names.
+
+2003-03-16 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Use assembly_ref for extern assemblies so names with dashes can be used.
+
+2003-03-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Define local variables
+
+2003-03-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add param_list definition, use param_list for method refs
+
+2003-03-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: de-bacwardificate values passed to add method,
+ I was setting the return to the parent before, but the parent
+ value was being set to the return type value so it all worked
+ out but was very confusing.
+
+2003-03-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add external field references
+
+2003-03-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add fields to the field table, add field references,
+ emit instructions that take a field param
+
+2003-03-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Emit ldstr instruction
+
+2003-03-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Create external method references
+
+2003-03-14 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Emit instructions that take a method def as a single param
+
+2003-03-14 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Emit instructions that take a single type as a param
+
+2003-03-14 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Emit instructions that take a single int32 as a param
+
+2003-03-13 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Remove unused references
+
+2003-03-13 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Emit simple instructions
+
+2003-03-13 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Set MaxStack, clean up some typos
+
+2003-03-13 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Set entrypoint
+
+2003-03-11 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Create TypeRefs instead of types, define methods.
+
+2003-03-09 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Set Call Conventions and Implementation Flags
+
+2003-03-09 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add implemented interfaces
+
+2003-03-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Create method attributes
+
+2003-03-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Reference external assemblies.
+
+2003-03-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Implemented class inheritence
+
+2003-03-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Pass null Location when adding class, concat dottedName pieces
+
+2003-03-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Reconfigure to work with new PEAPI emission system
+
+2003-02-10 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Use arg_list for method signatures, set method parameters
+
+2003-02-09 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: full names can be short names too (for members)
+
+2003-02-09 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Use full names for calling instructions
+
+2003-02-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Create type names properly
+
+2003-02-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Handle argument lists better
+
+2003-02-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Handle .local and newobj
+
+2003-02-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Allow assembly names to have lots of dashes.
+
+2003-02-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add dash token, allow assembly refs to have dashes in their names.
+
+2003-02-02 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILParser.jay: Add call instruction, other little fixes and additions
diff --git a/mcs/ilasm/parser/ILParser.jay b/mcs/ilasm/parser/ILParser.jay
new file mode 100644
index 00000000000..95cba438734
--- /dev/null
+++ b/mcs/ilasm/parser/ILParser.jay
@@ -0,0 +1,3202 @@
+%{
+//
+// Mono::ILASM::ILParser
+//
+// (C) Sergey Chaban (serge@wildwestsoftware.com)
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+using PEAPI;
+using System;
+using System.IO;
+using System.Collections;
+using System.Globalization;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+
+namespace Mono.ILASM {
+
+ public class ILParser {
+
+ private CodeGen codegen;
+
+ private bool is_value_class;
+ private bool is_enum_class;
+ private bool pinvoke_info;
+ private string pinvoke_mod;
+ private string pinvoke_meth;
+ private PEAPI.PInvokeAttr pinvoke_attr;
+ private ILTokenizer tokenizer;
+ static int yacc_verbose_flag;
+
+ class NameValuePair {
+ public string Name;
+ public object Value;
+
+ public NameValuePair (string name, object value)
+ {
+ this.Name = name;
+ this.Value = value;
+ }
+ }
+
+ class PermPair {
+ public PEAPI.SecurityAction sec_action;
+ public object perm;
+
+ public PermPair (PEAPI.SecurityAction sec_action, object perm)
+ {
+ this.sec_action = sec_action;
+ this.perm = perm;
+ }
+ }
+
+ public bool CheckSecurityActionValidity (System.Security.Permissions.SecurityAction action, bool for_assembly)
+ {
+ if ((action == System.Security.Permissions.SecurityAction.RequestMinimum ||
+ action == System.Security.Permissions.SecurityAction.RequestOptional ||
+ action == System.Security.Permissions.SecurityAction.RequestRefuse) && !for_assembly) {
+ Console.Error.WriteLine (String.Format ("System.Security.Permissions.SecurityAction '{0}' is not valid for this declaration", action));
+ return false;
+ }
+
+ return true;
+ }
+
+ public object ClassRefToObject (object class_ref, object val)
+ {
+ ExternTypeRef etr = class_ref as ExternTypeRef;
+ if (etr == null)
+ /* FIXME: report error? can be PrimitiveTypeRef or TypeRef */
+ return null;
+
+ System.Type t = etr.GetReflectedType ();
+ return (t.IsEnum ? Enum.Parse (t, String.Format ("{0}", val)) : val);
+ }
+
+ /* Converts a type_spec to a corresponding PermPair */
+ PermPair TypeSpecToPermPair (object action, object type_spec, ArrayList pairs)
+ {
+ ExternTypeRef etr = type_spec as ExternTypeRef;
+ if (etr == null)
+ /* FIXME: could be PrimitiveTypeRef or TypeRef
+ Report what error? */
+ return null;
+
+ System.Type t = etr.GetReflectedType ();
+ object obj = Activator.CreateInstance (t,
+ new object [] {(System.Security.Permissions.SecurityAction) (short) action});
+
+ if (pairs != null)
+ foreach (NameValuePair pair in pairs) {
+ PropertyInfo pi = t.GetProperty (pair.Name);
+ pi.SetValue (obj, pair.Value, null);
+ }
+
+ IPermission iper = (IPermission) t.GetMethod ("CreatePermission").Invoke (obj, null);
+ return new PermPair ((PEAPI.SecurityAction) action, iper);
+ }
+
+ public ILParser (CodeGen codegen, ILTokenizer tokenizer)
+ {
+ this.codegen = codegen;
+ this.tokenizer = tokenizer;
+ }
+
+ public CodeGen CodeGen {
+ get { return codegen; }
+ }
+
+ private BaseTypeRef GetTypeRef (BaseTypeRef b)
+ {
+ if (b is BaseClassRef)
+ return ((BaseClassRef) b).Clone ();
+ return b;
+ }
+
+%}
+
+%token EOF
+
+/* ID - alpha-numeric identifier */
+%token ID
+
+/* QSTRING - quoted string */
+%token QSTRING
+
+/* SQSTRING - single quoted string */
+%token SQSTRING
+
+/* COMP_NAME - A name with dots */
+%token COMP_NAME
+
+/* INT32 - 32 bit integer */
+%token INT32
+
+/* INT64 - 64 bit integer */
+%token INT64
+
+/* FLOAT64 - floating point number */
+%token FLOAT64
+
+/* HEXBYTE - two digit hex number */
+%token HEXBYTE
+
+
+/* Punctuation */
+%token DOT "."
+%token OPEN_BRACE "{"
+%token CLOSE_BRACE "}"
+%token OPEN_BRACKET "["
+%token CLOSE_BRACKET "]"
+%token OPEN_PARENS "("
+%token CLOSE_PARENS ")"
+%token COMMA ","
+%token COLON ":"
+%token DOUBLE_COLON "::"
+%token SEMICOLON ";"
+%token ASSIGN "="
+%token STAR "*"
+%token AMPERSAND "&"
+%token PLUS "+"
+%token SLASH "/"
+%token BANG "!"
+%token ELLIPSIS "..."
+%token DASH "-"
+%token OPEN_ANGLE_BRACKET "<"
+%token CLOSE_ANGLE_BRACKET ">"
+
+
+
+%token UNKNOWN
+
+
+/* INSTR_* instruction types */
+%token INSTR_NONE
+%token INSTR_VAR
+%token INSTR_I
+%token INSTR_I8
+%token INSTR_R
+%token INSTR_BRTARGET
+%token INSTR_METHOD
+%token INSTR_NEWOBJ
+%token INSTR_FIELD
+%token INSTR_TYPE
+%token INSTR_STRING
+%token INSTR_SIG
+%token INSTR_RVA
+%token INSTR_TOK
+%token INSTR_SWITCH
+%token INSTR_PHI
+%token INSTR_LOCAL
+%token INSTR_PARAM
+
+
+
+
+
+/* Mechanically generated - DO NOT EDIT! */
+
+
+/* Directives */
+%token D_ADDON
+%token D_ALGORITHM
+%token D_ASSEMBLY
+%token D_BACKING
+%token D_BLOB
+%token D_CAPABILITY
+%token D_CCTOR
+%token D_CLASS
+%token D_COMTYPE
+%token D_CONFIG
+%token D_IMAGEBASE
+%token D_CORFLAGS
+%token D_CTOR
+%token D_CUSTOM
+%token D_DATA
+%token D_EMITBYTE
+%token D_ENTRYPOINT
+%token D_EVENT
+%token D_EXELOC
+%token D_EXPORT
+%token D_FIELD
+%token D_FILE
+%token D_FIRE
+%token D_GET
+%token D_HASH
+%token D_IMPLICITCOM
+%token D_LANGUAGE
+%token D_LINE
+%token D_XLINE
+%token D_LOCALE
+%token D_LOCALS
+%token D_MANIFESTRES
+%token D_MAXSTACK
+%token D_METHOD
+%token D_MIME
+%token D_MODULE
+%token D_MRESOURCE
+%token D_NAMESPACE
+%token D_ORIGINATOR
+%token D_OS
+%token D_OTHER
+%token D_OVERRIDE
+%token D_PACK
+%token D_PARAM
+%token D_PERMISSION
+%token D_PERMISSIONSET
+%token D_PROCESSOR
+%token D_PROPERTY
+%token D_PUBLICKEY
+%token D_PUBLICKEYTOKEN
+%token D_REMOVEON
+%token D_SET
+%token D_SIZE
+%token D_STACKRESERVE
+%token D_SUBSYSTEM
+%token D_TITLE
+%token D_TRY
+%token D_VER
+%token D_VTABLE
+%token D_VTENTRY
+%token D_VTFIXUP
+%token D_ZEROINIT
+
+
+/* Keywords */
+%token K_AT
+%token K_AS
+%token K_IMPLICITCOM
+%token K_IMPLICITRES
+%token K_NOAPPDOMAIN
+%token K_NOPROCESS
+%token K_NOMACHINE
+%token K_EXTERN
+%token K_INSTANCE
+%token K_EXPLICIT
+%token K_DEFAULT
+%token K_VARARG
+%token K_UNMANAGED
+%token K_CDECL
+%token K_STDCALL
+%token K_THISCALL
+%token K_FASTCALL
+%token K_MARSHAL
+%token K_IN
+%token K_OUT
+%token K_OPT
+// %token K_LCID
+%token K_RETVAL
+%token K_STATIC
+%token K_PUBLIC
+%token K_PRIVATE
+%token K_FAMILY
+%token K_INITONLY
+%token K_RTSPECIALNAME
+%token K_SPECIALNAME
+%token K_ASSEMBLY
+%token K_FAMANDASSEM
+%token K_FAMORASSEM
+%token K_PRIVATESCOPE
+%token K_LITERAL
+%token K_NOTSERIALIZED
+%token K_VALUE
+%token K_NOT_IN_GC_HEAP
+%token K_INTERFACE
+%token K_SEALED
+%token K_ABSTRACT
+%token K_AUTO
+%token K_SEQUENTIAL
+%token K_ANSI
+%token K_UNICODE
+%token K_AUTOCHAR
+%token K_BESTFIT
+%token K_IMPORT
+%token K_SERIALIZABLE
+%token K_NESTED
+%token K_LATEINIT
+%token K_EXTENDS
+%token K_IMPLEMENTS
+%token K_FINAL
+%token K_VIRTUAL
+%token K_HIDEBYSIG
+%token K_NEWSLOT
+%token K_UNMANAGEDEXP
+%token K_PINVOKEIMPL
+%token K_NOMANGLE
+%token K_OLE
+%token K_LASTERR
+%token K_WINAPI
+%token K_NATIVE
+%token K_IL
+%token K_CIL
+%token K_OPTIL
+%token K_MANAGED
+%token K_FORWARDREF
+%token K_RUNTIME
+%token K_INTERNALCALL
+%token K_SYNCHRONIZED
+%token K_NOINLINING
+%token K_CUSTOM
+%token K_FIXED
+%token K_SYSSTRING
+%token K_ARRAY
+%token K_VARIANT
+%token K_CURRENCY
+%token K_SYSCHAR
+%token K_VOID
+%token K_BOOL
+%token K_INT8
+%token K_INT16
+%token K_INT32
+%token K_INT64
+%token K_FLOAT32
+%token K_FLOAT64
+%token K_ERROR
+%token K_UNSIGNED
+%token K_UINT
+%token K_UINT8
+%token K_UINT16
+%token K_UINT32
+%token K_UINT64
+%token K_DECIMAL
+%token K_DATE
+%token K_BSTR
+%token K_LPSTR
+%token K_LPWSTR
+%token K_LPTSTR
+%token K_OBJECTREF
+%token K_IUNKNOWN
+%token K_IDISPATCH
+%token K_STRUCT
+%token K_SAFEARRAY
+%token K_INT
+%token K_BYVALSTR
+%token K_TBSTR
+%token K_LPVOID
+%token K_ANY
+%token K_FLOAT
+%token K_LPSTRUCT
+%token K_NULL
+%token K_PTR
+%token K_VECTOR
+%token K_HRESULT
+%token K_CARRAY
+%token K_USERDEFINED
+%token K_RECORD
+%token K_FILETIME
+%token K_BLOB
+%token K_STREAM
+%token K_STORAGE
+%token K_STREAMED_OBJECT
+%token K_STORED_OBJECT
+%token K_BLOB_OBJECT
+%token K_CF
+%token K_CLSID
+%token K_METHOD
+%token K_CLASS
+%token K_PINNED
+%token K_MODREQ
+%token K_MODOPT
+%token K_TYPEDREF
+%token K_TYPE
+%token K_WCHAR
+%token K_CHAR
+%token K_FROMUNMANAGED
+%token K_CALLMOSTDERIVED
+%token K_BYTEARRAY
+%token K_WITH
+%token K_INIT
+%token K_TO
+%token K_CATCH
+%token K_FILTER
+%token K_FINALLY
+%token K_FAULT
+%token K_HANDLER
+%token K_TLS
+%token K_FIELD
+%token K_REQUEST
+%token K_DEMAND
+%token K_ASSERT
+%token K_DENY
+%token K_PERMITONLY
+%token K_LINKCHECK
+%token K_INHERITCHECK
+%token K_REQMIN
+%token K_REQOPT
+%token K_REQREFUSE
+%token K_PREJITGRANT
+%token K_PREJITDENY
+%token K_NONCASDEMAND
+%token K_NONCASLINKDEMAND
+%token K_NONCASINHERITANCE
+%token K_READONLY
+%token K_NOMETADATA
+%token K_ALGORITHM
+%token K_FULLORIGIN
+// %token K_NAN
+// %token K_INF
+// %token K_PUBLICKEY
+%token K_ENABLEJITTRACKING
+%token K_DISABLEJITOPTIMIZER
+%token K_PRESERVESIG
+%token K_BEFOREFIELDINIT
+%token K_ALIGNMENT
+%token K_NULLREF
+%token K_VALUETYPE
+%token K_COMPILERCONTROLLED
+%token K_REQSECOBJ
+%token K_ENUM
+%token K_OBJECT
+%token K_STRING
+%token K_TRUE
+%token K_FALSE
+%token K_IS
+%token K_ON
+%token K_OFF
+%token K_CHARMAPERROR
+
+/* end generated */
+
+
+
+
+
+%start il_file
+
+%%
+
+il_file : decls
+ ;
+
+decls : /* EMPTY */
+ | decls decl
+ ;
+
+decl : class_all
+ | namespace_all
+ | method_all
+ | field_decl
+ | data_decl
+ | vtfixup_decl
+ | file_decl
+ | assembly_all
+ | assemblyref_all
+ | exptype_all
+ | manifestres_all
+ | module_head
+ | sec_decl
+ | customattr_decl
+ {
+ if (codegen.CurrentCustomAttrTarget != null)
+ codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
+ }
+ | D_SUBSYSTEM int32
+ {
+ codegen.SetSubSystem ((int) $2);
+ }
+ | D_CORFLAGS int32
+ {
+ codegen.SetCorFlags ((int) $2);
+ }
+ | D_FILE K_ALIGNMENT int32
+ | D_IMAGEBASE int64
+ {
+ codegen.SetImageBase ((long) $2);
+ }
+ | D_STACKRESERVE int64
+ {
+ codegen.SetStackReserve ((long) $2);
+ }
+ | extsource_spec
+ | language_decl
+ ;
+
+extsource_spec : D_LINE int32 SQSTRING
+ | D_LINE int32
+ | D_LINE int32 COLON int32 SQSTRING
+ | D_LINE int32 COLON int32
+ ;
+
+language_decl : D_LANGUAGE SQSTRING
+ | D_LANGUAGE SQSTRING COMMA SQSTRING
+ | D_LANGUAGE SQSTRING COMMA SQSTRING COMMA SQSTRING
+ ;
+
+
+vtfixup_decl : D_VTFIXUP OPEN_BRACKET int32 CLOSE_BRACKET
+ vtfixup_attr K_AT id
+ ;
+
+vtfixup_attr : /* EMPTY */
+ | vtfixup_attr K_INT32
+ | vtfixup_attr K_INT64
+ | vtfixup_attr K_FROMUNMANAGED
+ | vtfixup_attr K_CALLMOSTDERIVED
+ ;
+
+namespace_all : namespace_head OPEN_BRACE decls CLOSE_BRACE
+ {
+ codegen.CurrentNameSpace = null;
+ }
+ ;
+
+namespace_head : D_NAMESPACE comp_name
+ {
+ codegen.CurrentNameSpace = (string) $2;
+ }
+ ;
+
+class_all : class_head OPEN_BRACE class_decls CLOSE_BRACE
+ {
+ codegen.EndTypeDef ();
+ }
+ ;
+
+class_head : D_CLASS class_attr comp_name formal_typars_clause extends_clause
+ impl_clause
+ {
+ codegen.BeginTypeDef ((TypeAttr) $2, (string) $3,
+ $5 as BaseClassRef, $6 as ArrayList, null, (GenericParameters) $4);
+
+ if (is_value_class)
+ codegen.CurrentTypeDef.MakeValueClass ();
+ if (is_enum_class)
+ codegen.CurrentTypeDef.MakeEnumClass ();
+ }
+ ;
+
+class_attrs : class_attrs class_attr
+ ;
+
+class_attr : /* EMPTY */
+ {
+ // Reset some flags
+ is_value_class = false;
+ is_enum_class = false;
+ $$ = new TypeAttr ();
+ }
+ | class_attr K_PUBLIC { $$ = (TypeAttr)$1 | TypeAttr.Public; }
+ | class_attr K_PRIVATE { $$ = (TypeAttr)$1 | TypeAttr.Private; }
+ | class_attr K_NESTED K_PRIVATE { $$ = (TypeAttr)$1 | TypeAttr.NestedPrivate; }
+ | class_attr K_NESTED K_PUBLIC { $$ = (TypeAttr)$1 | TypeAttr.NestedPublic; }
+ | class_attr K_NESTED K_FAMILY { $$ = (TypeAttr)$1 | TypeAttr.NestedFamily; }
+ | class_attr K_NESTED K_ASSEMBLY { $$ = (TypeAttr)$1 | TypeAttr.NestedAssembly;}
+ | class_attr K_NESTED K_FAMANDASSEM { $$ = (TypeAttr)$1 | TypeAttr.NestedFamAndAssem; }
+ | class_attr K_NESTED K_FAMORASSEM { $$ = (TypeAttr)$1 | TypeAttr.NestedFamOrAssem; }
+ | class_attr K_VALUE { is_value_class = true; }
+ | class_attr K_ENUM { is_enum_class = true; is_value_class = true;
+ }
+ | class_attr K_INTERFACE { $$ = (TypeAttr)$1 | TypeAttr.Interface; }
+ | class_attr K_SEALED { $$ = (TypeAttr)$1 | TypeAttr.Sealed; }
+ | class_attr K_ABSTRACT { $$ = (TypeAttr)$1 | TypeAttr.Abstract; }
+ | class_attr K_AUTO { }
+ | class_attr K_SEQUENTIAL { $$ = (TypeAttr)$1 | TypeAttr.SequentialLayout; }
+ | class_attr K_EXPLICIT { $$ = (TypeAttr)$1 | TypeAttr.ExplicitLayout; }
+ | class_attr K_ANSI { }
+ | class_attr K_UNICODE { $$ = (TypeAttr)$1 | TypeAttr.UnicodeClass; }
+ | class_attr K_AUTOCHAR { $$ = (TypeAttr)$1 | TypeAttr.AutoClass; }
+ | class_attr K_IMPORT { $$ = (TypeAttr)$1 | TypeAttr.Import; }
+ | class_attr K_SERIALIZABLE { $$ = (TypeAttr)$1 | TypeAttr.Serializable; }
+ | class_attr K_BEFOREFIELDINIT { $$ = (TypeAttr)$1 | TypeAttr.BeforeFieldInit; }
+ | class_attr K_SPECIALNAME { $$ = (TypeAttr)$1 | TypeAttr.SpecialName; }
+ | class_attr K_RTSPECIALNAME { $$ = (TypeAttr)$1 | TypeAttr.RTSpecialName; }
+ ;
+
+extends_clause : /* EMPTY */
+ | K_EXTENDS generic_class_ref
+ {
+ $$ = $2;
+ }
+ ;
+
+impl_clause : /* EMPTY */
+ | impl_class_refs
+ ;
+
+impl_class_refs : K_IMPLEMENTS generic_class_ref
+ {
+ ArrayList al = new ArrayList ();
+ al.Add ($2);
+ $$ = al;
+ }
+ | impl_class_refs COMMA generic_class_ref
+ {
+ ArrayList al = (ArrayList) $1;
+
+ al.Insert (0, $3);
+ $$ = al;
+ }
+ ;
+
+formal_typars_clause : /* EMPTY */
+ | OPEN_ANGLE_BRACKET formal_typars CLOSE_ANGLE_BRACKET
+ {
+#if NET_2_0 || BOOTSTRAP_NET_2_0
+ $$ = $2;
+#else
+ Report.Error ("Use ilasm2 for generics support.");
+#endif
+ }
+ ;
+
+typars_clause : /* EMPTY */
+ | OPEN_ANGLE_BRACKET typars CLOSE_ANGLE_BRACKET
+ {
+#if NET_2_0 || BOOTSTRAP_NET_2_0
+ $$ = $2;
+#else
+ Report.Error ("Use ilasm2 for generics support.");
+#endif
+ }
+ ;
+
+typars : type
+ {
+ GenericArguments ga = new GenericArguments ();
+ ga.Add ((BaseTypeRef) $1);
+ $$ = ga;
+ }
+ | typars COMMA type
+ {
+ ((GenericArguments) $1).Add ((BaseTypeRef) $3);
+ $$ = $1;
+ }
+ ;
+
+constraints_clause : /* EMTPY */
+ | OPEN_PARENS constraints CLOSE_PARENS
+ {
+ $$ = $2;
+ }
+ ;
+
+
+constraints : generic_class_ref
+ {
+ ArrayList al = new ArrayList ();
+ al.Add ($1);
+ $$ = al;
+ }
+ | constraints COMMA generic_class_ref
+ {
+ ArrayList al = (ArrayList) $1;
+ al.Add ($3);
+ $$ = al;
+ }
+ ;
+
+generic_class_ref : class_ref
+ {
+ $$ = $1;
+ }
+ | K_CLASS class_ref typars_clause
+ {
+ if ($3 != null)
+ $$ = ((BaseClassRef) $2).GetGenericTypeInst ((GenericArguments) $3);
+ else
+ $$ = $2;
+ }
+ | BANG int32
+ {
+ GenParam gpar = new GenParam ((int) $2, "", GenParamType.Var);
+ $$ = new GenericParamRef (gpar, $2.ToString ());
+ }
+ | BANG BANG int32
+ {
+ GenParam gpar = new GenParam ((int) $3, "", GenParamType.MVar);
+ $$ = new GenericParamRef (gpar, $3.ToString ());
+ }
+ | BANG id
+ {
+ int num = -1;
+ string name = (string) $2;
+ if (codegen.CurrentTypeDef != null)
+ num = codegen.CurrentTypeDef.GetGenericParamNum (name);
+ GenParam gpar = new GenParam (num, name, GenParamType.Var);
+ $$ = new GenericParamRef (gpar, name);
+ }
+ | BANG BANG id
+ {
+ int num = -1;
+ string name = (string) $3;
+ if (codegen.CurrentMethodDef != null)
+ num = codegen.CurrentMethodDef.GetGenericParamNum (name);
+ GenParam gpar = new GenParam (num, name, GenParamType.MVar);
+ $$ = new GenericParamRef (gpar, name);
+ }
+ ;
+
+formal_typars : formal_typar_attr constraints_clause formal_typar
+ {
+ GenericParameter gp = new GenericParameter ((string) $3, (PEAPI.GenericParamAttributes) $1, (ArrayList) $2);
+
+ GenericParameters colln = new GenericParameters ();
+ colln.Add (gp);
+ $$ = colln;
+ }
+ | formal_typars COMMA formal_typar_attr constraints_clause formal_typar
+ {
+ GenericParameters colln = (GenericParameters) $1;
+ colln.Add (new GenericParameter ((string) $5, (PEAPI.GenericParamAttributes) $3, (ArrayList) $4));
+ $$ = colln;
+ }
+ ;
+
+formal_typar_attr : /* EMPTY */
+ {
+ $$ = new PEAPI.GenericParamAttributes ();
+ }
+ | formal_typar_attr D_CTOR
+ {
+ $$ = (PEAPI.GenericParamAttributes) $1 | PEAPI.GenericParamAttributes.DefaultConstructorConstrait;
+ }
+ | formal_typar_attr K_VALUETYPE
+ {
+ $$ = (PEAPI.GenericParamAttributes) $1 | PEAPI.GenericParamAttributes.NotNullableValueTypeConstraint;
+ }
+ | formal_typar_attr K_CLASS
+ {
+ $$ = (PEAPI.GenericParamAttributes) $1 | PEAPI.GenericParamAttributes.ReferenceTypeConstraint;
+ }
+ ;
+
+formal_typar : id
+ {
+ $$ = $1;
+ }
+ ;
+
+param_type_decl : D_PARAM K_TYPE id
+ {
+ if (codegen.CurrentMethodDef != null)
+ codegen.CurrentCustomAttrTarget = codegen.CurrentMethodDef.GetGenericParam ((string) $3);
+ else
+ codegen.CurrentCustomAttrTarget = codegen.CurrentTypeDef.GetGenericParam ((string) $3);
+ if (codegen.CurrentCustomAttrTarget == null)
+ Report.Error (String.Format ("Type parameter '{0}' undefined.", (string) $3));
+ }
+ | D_PARAM K_TYPE OPEN_BRACKET int32 CLOSE_BRACKET
+ {
+ int index = ((int) $4);
+ if (codegen.CurrentMethodDef != null)
+ codegen.CurrentCustomAttrTarget = codegen.CurrentMethodDef.GetGenericParam (index - 1);
+ else
+ codegen.CurrentCustomAttrTarget = codegen.CurrentTypeDef.GetGenericParam (index - 1);
+ if (codegen.CurrentCustomAttrTarget == null)
+ Report.Error (String.Format ("Type parameter '{0}' index out of range.", index));
+ }
+ ;
+
+class_refs : class_ref
+ {
+ ArrayList class_list = new ArrayList ();
+ class_list.Add ($1);
+ $$ = class_list;
+ }
+ | class_refs COMMA class_ref
+ {
+ ArrayList class_list = (ArrayList) $1;
+ class_list.Add ($3);
+ }
+ ;
+
+slashed_name : comp_name
+ | slashed_name SLASH comp_name
+ {
+ $$ = String.Format ("{0}/{1}", $1, $3);
+ }
+ ;
+
+class_ref : OPEN_BRACKET slashed_name CLOSE_BRACKET slashed_name
+ {
+ if (codegen.IsThisAssembly ((string) $2)) {
+ $$ = codegen.GetTypeRef ((string) $4);
+ } else {
+ $$ = codegen.ExternTable.GetTypeRef ((string) $2, (string) $4, false);
+ }
+ }
+ | OPEN_BRACKET D_MODULE slashed_name CLOSE_BRACKET slashed_name
+ {
+ if (codegen.IsThisModule ((string) $3)) {
+ $$ = codegen.GetTypeRef ((string) $5);
+ } else {
+ $$ = codegen.ExternTable.GetModuleTypeRef ((string) $3, (string) $5, false);
+ }
+ }
+ | slashed_name
+ {
+ PrimitiveTypeRef prim = PrimitiveTypeRef.GetPrimitiveType ((string) $1);
+
+ if (prim != null && !codegen.IsThisAssembly ("mscorlib"))
+ $$ = prim;
+ else
+ $$ = codegen.GetTypeRef ((string) $1);
+ }
+
+ ;
+
+class_decls : /* EMPTY */
+ | class_decls class_decl
+ ;
+
+class_decl : method_all
+ | class_all
+ | event_all
+ | prop_all
+ | field_decl
+ | data_decl
+ | sec_decl
+ {
+ PermPair pp = (PermPair) $1;
+ if (!CheckSecurityActionValidity ((System.Security.Permissions.SecurityAction) (short) pp.sec_action, false))
+ Report.Error (String.Format ("Invalid security action : {0}", pp.sec_action));
+
+ codegen.AddPermission (pp.sec_action, pp.perm);
+ }
+ | extsource_spec
+ | customattr_decl
+ {
+ codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
+ }
+ | param_type_decl
+ | D_SIZE int32
+ {
+ codegen.CurrentTypeDef.SetSize ((int) $2);
+ }
+ | D_PACK int32
+ {
+ codegen.CurrentTypeDef.SetPack ((int) $2);
+ }
+ | D_OVERRIDE type_spec DOUBLE_COLON method_name K_WITH call_conv type
+ type_spec DOUBLE_COLON method_name type_list
+ {
+ //
+ // My copy of the spec didn't have a type_list but
+ // it seems pretty crucial
+ //
+ BaseTypeRef owner = (BaseTypeRef) $2;
+ ArrayList arg_list = (ArrayList) $11;
+ BaseTypeRef[] param_list;
+ BaseMethodRef decl;
+
+ if (arg_list != null)
+ param_list = (BaseTypeRef[]) arg_list.ToArray (typeof (BaseTypeRef));
+ else
+ param_list = new BaseTypeRef[0];
+
+ decl = owner.GetMethodRef ((BaseTypeRef) $7,
+ (CallConv) $6, (string) $4, param_list, 0);
+
+ // NOTICE: `owner' here might be wrong
+ string sig = MethodDef.CreateSignature (owner, (string) $10,
+ param_list, 0);
+ codegen.CurrentTypeDef.AddOverride (sig, decl);
+ }
+ OPEN_PARENS sig_args CLOSE_PARENS
+ | language_decl
+ ;
+
+type : generic_class_ref
+ {
+ $$ = $1;
+ }
+ | K_OBJECT
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.Object, "System.Object");
+ }
+ | K_STRING
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.String, "System.String");
+ }
+ | K_VALUE K_CLASS class_ref
+ {
+ BaseClassRef class_ref = (BaseClassRef) $3;
+ class_ref.MakeValueClass ();
+ $$ = class_ref;
+ }
+ | K_VALUETYPE OPEN_BRACKET slashed_name CLOSE_BRACKET slashed_name typars_clause
+ {
+ ExternTypeRef ext_ref = codegen.ExternTable.GetTypeRef ((string) $3, (string) $5, true);
+ if ($6 != null)
+ $$ = ext_ref.GetGenericTypeInst ((GenericArguments) $6);
+ else
+ $$ = ext_ref;
+ }
+ | K_VALUETYPE slashed_name typars_clause
+ {
+ TypeRef t_ref = codegen.GetTypeRef ((string) $2);
+ t_ref.MakeValueClass ();
+ if ($3 != null)
+ $$ = t_ref.GetGenericTypeInst ((GenericArguments) $3);
+ else
+ $$ = t_ref;
+ }
+ | type OPEN_BRACKET CLOSE_BRACKET
+ {
+ BaseTypeRef base_type = GetTypeRef ((BaseTypeRef) $1);
+ base_type.MakeArray ();
+ $$ = base_type;
+ }
+ | type OPEN_BRACKET bounds CLOSE_BRACKET
+ {
+ BaseTypeRef base_type = GetTypeRef ((BaseTypeRef) $1);
+ ArrayList bound_list = (ArrayList) $3;
+ base_type.MakeBoundArray (bound_list);
+ $$ = base_type;
+ }
+ | type AMPERSAND
+ {
+ BaseTypeRef base_type = GetTypeRef ((BaseTypeRef) $1);
+ base_type.MakeManagedPointer ();
+ $$ = base_type;
+ }
+ | type STAR
+ {
+ BaseTypeRef base_type = GetTypeRef ((BaseTypeRef) $1);
+ base_type.MakeUnmanagedPointer ();
+ $$ = base_type;
+ }
+ | type K_PINNED
+ {
+ BaseTypeRef base_type = GetTypeRef ((BaseTypeRef) $1);
+ base_type.MakePinned ();
+ $$ = base_type;
+ }
+ | type K_MODREQ OPEN_PARENS class_ref CLOSE_PARENS
+ {
+ BaseTypeRef base_type = GetTypeRef ((BaseTypeRef) $1);
+ BaseClassRef class_ref = (BaseClassRef) $4;
+ base_type.MakeCustomModified (codegen,
+ CustomModifier.modopt, class_ref);
+ $$ = base_type;
+ }
+ | type K_MODOPT OPEN_PARENS class_ref CLOSE_PARENS
+ {
+ BaseTypeRef base_type = GetTypeRef ((BaseTypeRef) $1);
+ BaseClassRef class_ref = (BaseClassRef) $4;
+ base_type.MakeCustomModified (codegen,
+ CustomModifier.modopt, class_ref);
+ $$ = base_type;
+ }
+ | K_METHOD call_conv type STAR OPEN_PARENS sig_args CLOSE_PARENS
+ {
+ $$ = new MethodPointerTypeRef ((CallConv) $2, (BaseTypeRef) $3, (ArrayList) $6);
+ }
+ | K_TYPEDREF
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.TypedRef,
+ "System.TypedReference");
+ }
+ | K_CHAR
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.Char, "System.Char");
+ }
+ | K_WCHAR
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.Char, "System.Char");
+ }
+ | K_VOID
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.Void, "System.Void");
+ }
+ | K_BOOL
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.Boolean, "System.Boolean");
+ }
+ | K_INT8
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.Int8, "System.SByte");
+ }
+ | K_INT16
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.Int16, "System.Int16");
+ }
+ | K_INT32
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.Int32, "System.Int32");
+ }
+ | K_INT64
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.Int64, "System.Int64");
+ }
+ | K_FLOAT32
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.Float32, "System.Single");
+ }
+ | K_FLOAT64
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.Float64, "System.Double");
+ }
+ | K_UNSIGNED K_INT8
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.UInt8, "System.Byte");
+ }
+ | K_UINT8
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.UInt8, "System.Byte");
+ }
+ | K_UNSIGNED K_INT16
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.UInt16, "System.UInt16");
+ }
+ | K_UINT16
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.UInt16, "System.UInt16");
+ }
+
+ | K_UNSIGNED K_INT32
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.UInt32, "System.UInt32");
+ }
+ | K_UINT32
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.UInt32, "System.UInt32");
+ }
+ | K_UNSIGNED K_INT64
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.UInt64, "System.UInt64");
+ }
+ | K_UINT64
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.UInt64, "System.UInt64");
+ }
+ | K_NATIVE K_INT
+ {
+ // TODO: Is this the proper full name
+ $$ = new PrimitiveTypeRef (PrimitiveType.NativeInt, "System.IntPtr");
+ }
+
+ | K_NATIVE K_UNSIGNED K_INT
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.NativeUInt, "System.UIntPtr");
+ }
+ | K_NATIVE K_UINT
+ {
+ $$ = new PrimitiveTypeRef (PrimitiveType.NativeUInt, "System.UIntPtr");
+ }
+ ;
+
+bounds : bound
+ {
+ ArrayList bound_list = new ArrayList ();
+ bound_list.Add ($1);
+ $$ = bound_list;
+ }
+ | bounds COMMA bound
+ {
+ ArrayList bound_list = (ArrayList) $1;
+ bound_list.Add ($3);
+ }
+ ;
+
+bound : /* EMPTY */
+ {
+ // This is shortref for no lowerbound or size
+ $$ = new DictionaryEntry (TypeRef.Ellipsis, TypeRef.Ellipsis);
+ }
+ | ELLIPSIS
+ {
+ // No lower bound or size
+ $$ = new DictionaryEntry (TypeRef.Ellipsis, TypeRef.Ellipsis);
+ }
+ | int32
+ {
+ /* Only size specified */
+ int size = (int) $1;
+ if (size < 0)
+ /* size cannot be < 0, so emit as (0, ...)
+ ilasm.net emits it like this */
+ $$ = new DictionaryEntry (0, TypeRef.Ellipsis);
+ else
+ $$ = new DictionaryEntry (TypeRef.Ellipsis, size);
+ }
+ | int32 ELLIPSIS int32
+ {
+ // lower and upper bound
+ int lower = (int) $1;
+ int upper = (int) $3;
+ if (lower > upper)
+ Report.Error ("Lower bound " + lower + " must be <= upper bound " + upper);
+
+ $$ = new DictionaryEntry ($1, $3);
+ }
+ | int32 ELLIPSIS
+ {
+ // Just lower bound
+ $$ = new DictionaryEntry ($1, TypeRef.Ellipsis);
+ }
+ ;
+
+call_conv : K_INSTANCE call_conv
+ {
+ $$ = (CallConv) $2 | CallConv.Instance;
+ }
+ | K_EXPLICIT call_conv
+ {
+ $$ = (CallConv) $2 | CallConv.InstanceExplicit;
+ }
+ | call_kind
+ ;
+
+call_kind : /* EMPTY */
+ {
+ $$ = new CallConv ();
+ }
+ | K_DEFAULT
+ {
+ $$ = CallConv.Default;
+ }
+ | K_VARARG
+ {
+ $$ = CallConv.Vararg;
+ }
+ | K_UNMANAGED K_CDECL
+ {
+ $$ = CallConv.Cdecl;
+ }
+ | K_UNMANAGED K_STDCALL
+ {
+ $$ = CallConv.Stdcall;
+ }
+ | K_UNMANAGED K_THISCALL
+ {
+ $$ = CallConv.Thiscall;
+ }
+ | K_UNMANAGED K_FASTCALL
+ {
+ $$ = CallConv.Fastcall;
+ }
+ ;
+
+native_type : /* EMPTY */
+ | K_CUSTOM OPEN_PARENS comp_qstring COMMA comp_qstring CLOSE_PARENS
+ {
+ $$ = new CustomMarshaller ((string) $3, (string) $5);
+ }
+ | K_FIXED K_SYSSTRING OPEN_BRACKET int32 CLOSE_BRACKET
+ {
+ $$ = new FixedSysString ((uint) (int)$4);
+ }
+ | K_FIXED K_ARRAY OPEN_BRACKET int32 CLOSE_BRACKET
+ {
+ $$ = new FixedArray ((int) $4);
+ }
+ | K_VARIANT
+ | K_CURRENCY
+ {
+ $$ = NativeType.Currency;
+ }
+ | K_SYSCHAR
+ | K_VOID
+ {
+ $$ = NativeType.Void;
+ }
+ | K_BOOL
+ {
+ $$ = NativeType.Boolean;
+ }
+ | K_INT8
+ {
+ $$ = NativeType.Int8;
+ }
+ | K_INT16
+ {
+ $$ = NativeType.Int16;
+ }
+ | K_INT32
+ {
+ $$ = NativeType.Int32;
+ }
+ | K_INT64
+ {
+ $$ = NativeType.Int64;
+ }
+ | K_FLOAT32
+ {
+ $$ = NativeType.Float32;
+ }
+ | K_FLOAT64
+ {
+ $$ = NativeType.Float64;
+ }
+ | K_ERROR
+ | K_UNSIGNED K_INT8
+ {
+ $$ = NativeType.UInt8;
+ }
+ | K_UINT8
+ {
+ $$ = NativeType.UInt8;
+ }
+ | K_UNSIGNED K_INT16
+ {
+ $$ = NativeType.UInt16;
+ }
+ | K_UINT16
+ {
+ $$ = NativeType.UInt16;
+ }
+ | K_UNSIGNED K_INT32
+ {
+ $$ = NativeType.UInt32;
+ }
+ | K_UINT32
+ {
+ $$ = NativeType.UInt32;
+ }
+ | K_UNSIGNED K_INT64
+ {
+ $$ = NativeType.UInt64;
+ }
+ | K_UINT64
+ {
+ $$ = NativeType.UInt64;
+ }
+ | native_type STAR
+ | native_type OPEN_BRACKET CLOSE_BRACKET
+ {
+ $$ = new NativeArray ((NativeType) $1);
+ }
+ | native_type OPEN_BRACKET int32 CLOSE_BRACKET
+ {
+ $$ = new NativeArray ((NativeType) $1, (int) $3, 0, 0);
+ }
+ | native_type OPEN_BRACKET int32 PLUS int32 CLOSE_BRACKET
+ {
+ //FIXME: Allowed only for methods, !fields
+ $$ = new NativeArray ((NativeType) $1, (int) $3, (int) $5);
+ }
+ | native_type OPEN_BRACKET PLUS int32 CLOSE_BRACKET
+ {
+ //FIXME: Allowed only for methods, !fields
+ $$ = new NativeArray ((NativeType) $1, -1, (int) $4);
+ }
+ | K_DECIMAL
+ | K_DATE
+ | K_BSTR
+ {
+ $$ = NativeType.BStr;
+ }
+ | K_LPSTR
+ {
+ $$ = NativeType.LPStr;
+ }
+ | K_LPWSTR
+ {
+ $$ = NativeType.LPWStr;
+ }
+ | K_LPTSTR
+ {
+ $$ = NativeType.LPTStr;
+ }
+ | K_OBJECTREF
+ | K_IUNKNOWN
+ {
+ $$ = NativeType.IUnknown;
+ }
+ | K_IDISPATCH
+ {
+ $$ = NativeType.IDispatch;
+ }
+ | K_STRUCT
+ {
+ $$ = NativeType.Struct;
+ }
+ | K_INTERFACE
+ {
+ $$ = NativeType.Interface;
+ }
+ | K_SAFEARRAY variant_type
+ {
+ if ($2 == null)
+ $$ = new SafeArray ();
+ else
+ $$ = new SafeArray ((SafeArrayType) $2);
+ }
+ | K_SAFEARRAY variant_type COMMA comp_qstring
+ | K_INT
+ {
+ $$ = NativeType.Int;
+ }
+ | K_UNSIGNED K_INT
+ {
+ $$ = NativeType.UInt;
+ }
+ | K_NESTED K_STRUCT
+ | K_BYVALSTR
+ {
+ $$ = NativeType.ByValStr;
+ }
+ | K_ANSI K_BSTR
+ {
+ $$ = NativeType.AnsiBStr;
+ }
+ | K_TBSTR
+ {
+ $$ = NativeType.TBstr;
+ }
+ | K_VARIANT K_BOOL
+ {
+ $$ = NativeType.VariantBool;
+ }
+ | K_METHOD
+ {
+ $$ = NativeType.FuncPtr;
+ }
+ | K_AS K_ANY
+ {
+ $$ = NativeType.AsAny;
+ }
+ | K_LPSTRUCT
+ ;
+
+variant_type : /* EMPTY */
+ | K_NULL
+ | K_VARIANT
+ {
+ $$ = SafeArrayType.variant;
+ }
+ | K_CURRENCY
+ {
+ $$ = SafeArrayType.currency;
+ }
+ | K_VOID
+ | K_BOOL
+ {
+ $$ = SafeArrayType.boolean;
+ }
+ | K_INT8
+ {
+ $$ = SafeArrayType.int8;
+ }
+ | K_INT16
+ {
+ $$ = SafeArrayType.int16;
+ }
+ | K_INT32
+ {
+ $$ = SafeArrayType.int32;
+ }
+ | K_INT64
+ | K_FLOAT32
+ {
+ $$ = SafeArrayType.float32;
+ }
+ | K_FLOAT64
+ {
+ $$ = SafeArrayType.float64;
+ }
+ | K_UNSIGNED K_INT8
+ {
+ $$ = SafeArrayType.uint8;
+ }
+ | K_UNSIGNED K_INT16
+ {
+ $$ = SafeArrayType.uint16;
+ }
+ | K_UNSIGNED K_INT32
+ {
+ $$ = SafeArrayType.uint32;
+ }
+ | K_UNSIGNED K_INT64
+ | STAR
+ | variant_type OPEN_BRACKET CLOSE_BRACKET
+ | variant_type K_VECTOR
+ | variant_type AMPERSAND
+ | K_DECIMAL
+ {
+ $$ = SafeArrayType.Decimal;
+ }
+ | K_DATE
+ {
+ $$ = SafeArrayType.date;
+ }
+ | K_BSTR
+ {
+ $$ = SafeArrayType.bstr;
+ }
+ | K_LPSTR
+ | K_LPWSTR
+ | K_IUNKNOWN
+ {
+ $$ = SafeArrayType.unknown;
+ }
+ | K_IDISPATCH
+ {
+ $$ = SafeArrayType.unknown;
+ }
+ | K_SAFEARRAY
+ | K_INT
+ {
+ $$ = SafeArrayType.Int;
+ }
+ | K_UNSIGNED K_INT
+ {
+ $$ = SafeArrayType.UInt;
+ }
+ | K_ERROR
+ {
+ $$ = SafeArrayType.error;
+ }
+ | K_HRESULT
+ | K_CARRAY
+ | K_USERDEFINED
+ | K_RECORD
+ | K_FILETIME
+ | K_BLOB
+ | K_STREAM
+ | K_STORAGE
+ | K_STREAMED_OBJECT
+ | K_STORED_OBJECT
+ | K_BLOB_OBJECT
+ | K_CF
+ | K_CLSID
+ ;
+
+field_decl : D_FIELD repeat_opt field_attr type id at_opt init_opt
+ {
+ FieldDef field_def = new FieldDef((FieldAttr) $3,
+ (string) $5, (BaseTypeRef) $4);
+ codegen.AddFieldDef (field_def);
+ codegen.CurrentCustomAttrTarget = field_def;
+
+ if ($2 != null) {
+ field_def.SetOffset ((uint) (int)$2);
+ }
+
+ if ($6 != null) {
+ field_def.AddDataValue ((string) $6);
+ }
+
+ if ($7 != null) {
+ field_def.SetValue ((Constant) $7);
+ }
+ }
+ ;
+
+repeat_opt : /* EMPTY */
+ | OPEN_BRACKET int32 CLOSE_BRACKET
+ {
+ $$ = $2;
+ }
+ ;
+
+field_attr : /* EMPTY */
+ {
+ $$ = new FieldAttr ();
+ }
+ | field_attr K_PUBLIC
+ {
+ $$ = (FieldAttr) $1 | FieldAttr.Public;
+ }
+ | field_attr K_PRIVATE
+ {
+ $$ = (FieldAttr) $1 | FieldAttr.Private;
+ }
+ | field_attr K_FAMILY
+ {
+ $$ = (FieldAttr) $1 | FieldAttr.Family;
+ }
+ | field_attr K_ASSEMBLY
+ {
+ $$ = (FieldAttr) $1 | FieldAttr.Assembly;
+ }
+ | field_attr K_FAMANDASSEM
+ {
+ $$ = (FieldAttr) $1 | FieldAttr.FamAndAssem;
+ }
+ | field_attr K_FAMORASSEM
+ {
+ $$ = (FieldAttr) $1 | FieldAttr.FamOrAssem;
+ }
+ | field_attr K_PRIVATESCOPE
+ {
+ // This is just 0x0000
+ }
+ | field_attr K_STATIC
+ {
+ $$ = (FieldAttr) $1 | FieldAttr.Static;
+ }
+ | field_attr K_INITONLY
+ {
+ $$ = (FieldAttr) $1 | FieldAttr.Initonly;
+ }
+ | field_attr K_RTSPECIALNAME
+ {
+ $$ = (FieldAttr) $1 | FieldAttr.RTSpecialName;
+ }
+ | field_attr K_SPECIALNAME
+ {
+ $$ = (FieldAttr) $1 | FieldAttr.SpecialName;
+ }
+ | field_attr K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS
+ {
+ codegen.AddFieldMarshalInfo ((NativeType) $4);
+ $$ = (FieldAttr) $1 | FieldAttr.HasFieldMarshal;
+ }
+ | field_attr K_LITERAL
+ {
+ $$ = (FieldAttr) $1 | FieldAttr.Literal;
+ }
+ | field_attr K_NOTSERIALIZED
+ {
+ $$ = (FieldAttr) $1 | FieldAttr.Notserialized;
+ }
+ ;
+
+at_opt : /* EMPTY */
+ | K_AT id
+ {
+ $$ = $2;
+ }
+ ;
+
+init_opt : /* EMPTY */
+ | ASSIGN field_init
+ {
+ $$ = $2;
+ }
+ ;
+
+field_init : K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS
+ {
+ $$ = new FloatConst (Convert.ToSingle ($3));
+ }
+ | K_FLOAT64 OPEN_PARENS float64 CLOSE_PARENS
+ {
+ $$ = new DoubleConst (Convert.ToDouble ($3));
+ }
+ | K_FLOAT32 OPEN_PARENS int64 CLOSE_PARENS
+ {
+ $$ = new FloatConst (BitConverter.ToSingle (BitConverter.GetBytes ((long)$3), BitConverter.IsLittleEndian ? 0 : 4));
+ }
+ | K_FLOAT64 OPEN_PARENS int64 CLOSE_PARENS
+ {
+ $$ = new DoubleConst (BitConverter.Int64BitsToDouble ((long)$3));
+ }
+ | K_INT64 OPEN_PARENS int64 CLOSE_PARENS
+ {
+ $$ = new IntConst (Convert.ToInt64 ($3));
+ }
+ | K_UINT64 OPEN_PARENS int64 CLOSE_PARENS
+ {
+ $$ = new UIntConst (Convert.ToUInt64 ((ulong)(long) $3));
+ }
+ | K_INT32 OPEN_PARENS int64 CLOSE_PARENS
+ {
+ $$ = new IntConst ((int)((long)$3));
+ }
+ | K_UINT32 OPEN_PARENS int64 CLOSE_PARENS
+ {
+ $$ = new UIntConst ((uint)((long)$3));
+ }
+ | K_INT16 OPEN_PARENS int64 CLOSE_PARENS
+ {
+ $$ = new IntConst ((short)((long) $3));
+ }
+ | K_UINT16 OPEN_PARENS int64 CLOSE_PARENS
+ {
+ $$ = new UIntConst ((ushort)((long) $3));
+ }
+ | K_CHAR OPEN_PARENS int64 CLOSE_PARENS
+ {
+ $$ = new CharConst (Convert.ToChar ($3));
+ }
+ | K_WCHAR OPEN_PARENS int64 CLOSE_PARENS
+ {
+ $$ = new CharConst (Convert.ToChar ($3));
+ }
+ | K_INT8 OPEN_PARENS int64 CLOSE_PARENS
+ {
+ $$ = new IntConst ((sbyte)((long) ($3)));
+ }
+ | K_UINT8 OPEN_PARENS int64 CLOSE_PARENS
+ {
+ $$ = new UIntConst ((byte)((long) ($3)));
+ }
+ | K_BOOL OPEN_PARENS truefalse CLOSE_PARENS
+ {
+ $$ = new BoolConst ((bool) $3);
+ }
+ | K_BYTEARRAY bytes_list
+ {
+ $$ = new ByteArrConst ((byte[]) $2);
+ }
+ | comp_qstring
+ {
+ // ******** THIS IS NOT IN THE DOCUMENTATION ******** //
+ $$ = new StringConst ((string) $1);
+ }
+ | K_NULLREF
+ {
+ $$ = new NullConst ();
+ }
+ ;
+
+data_decl : data_head data_body
+ {
+ DataDef datadef = (DataDef) $1;
+
+ if ($2 is ArrayList) {
+ ArrayList const_list = (ArrayList) $2;
+ DataConstant[] const_arr = new DataConstant[const_list.Count];
+
+ for (int i=0; i<const_arr.Length; i++)
+ const_arr[i] = (DataConstant) const_list[i];
+
+ datadef.PeapiConstant = new ArrayConstant (const_arr);
+ } else {
+ datadef.PeapiConstant = (PEAPI.Constant) $2;
+ }
+ codegen.AddDataDef (datadef);
+ }
+ ;
+
+data_head : D_DATA tls id ASSIGN
+ {
+ $$ = new DataDef ((string) $3, (bool) $2);
+ }
+ | D_DATA tls
+ {
+ $$ = new DataDef (String.Empty, (bool) $2);
+ }
+ ;
+
+tls : /* EMPTY */ { $$ = false; }
+ | K_TLS { $$ = true; }
+ ;
+
+data_body : OPEN_BRACE dataitem_list CLOSE_BRACE
+ {
+ $$ = $2;
+ }
+ | dataitem
+ ;
+
+dataitem_list : dataitem
+ {
+ ArrayList dataitem_list = new ArrayList ();
+ dataitem_list.Add ($1);
+ $$ = dataitem_list;
+ }
+ | dataitem_list COMMA dataitem
+ {
+ ArrayList list = (ArrayList) $1;
+ list.Add ($3);
+ }
+ ;
+
+dataitem : K_CHAR STAR OPEN_PARENS comp_qstring CLOSE_PARENS
+ {
+ $$ = new StringConst ((string) $4);
+ }
+ | K_WCHAR STAR OPEN_PARENS comp_qstring CLOSE_PARENS
+ {
+ $$ = new StringConst ((string) $4);
+ }
+ | AMPERSAND OPEN_PARENS id CLOSE_PARENS
+ {
+ // DataDef def = codegen.CurrentTypeDef.GetDataDef ((string) $3);
+ // $$ = new AddressConstant ((DataConstant) def.PeapiConstant);
+ }
+ | K_BYTEARRAY ASSIGN bytes_list
+ {
+ $$ = new ByteArrConst ((byte[]) $3);
+ }
+ | K_BYTEARRAY bytes_list
+ {
+ // ******** THIS IS NOT IN THE SPECIFICATION ******** //
+ $$ = new ByteArrConst ((byte[]) $2);
+ }
+ | K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS repeat_opt
+ {
+ double d = (double) $3;
+ FloatConst float_const = new FloatConst ((float) d);
+
+ if ($5 != null)
+ $$ = new RepeatedConstant (float_const, (int) $5);
+ else
+ $$ = float_const;
+ }
+ | K_FLOAT64 OPEN_PARENS float64 CLOSE_PARENS repeat_opt
+ {
+ DoubleConst double_const = new DoubleConst ((double) $3);
+
+ if ($5 != null)
+ $$ = new RepeatedConstant (double_const, (int) $5);
+ else
+ $$ = double_const;
+ }
+ | K_INT64 OPEN_PARENS int64 CLOSE_PARENS repeat_opt
+ {
+ IntConst int_const = new IntConst ((long) $3);
+
+ if ($5 != null)
+ $$ = new RepeatedConstant (int_const, (int) $5);
+ else
+ $$ = int_const;
+ }
+ | K_INT32 OPEN_PARENS int32 CLOSE_PARENS repeat_opt
+ {
+ IntConst int_const = new IntConst ((int) $3);
+
+ if ($5 != null)
+ $$ = new RepeatedConstant (int_const, (int) $5);
+ else
+ $$ = int_const;
+ }
+ | K_INT16 OPEN_PARENS int32 CLOSE_PARENS repeat_opt
+ {
+ int i = (int) $3;
+ IntConst int_const = new IntConst ((short) i);
+
+ if ($5 != null)
+ $$ = new RepeatedConstant (int_const, (int) $5);
+ else
+ $$ = int_const;
+ }
+ | K_INT8 OPEN_PARENS int32 CLOSE_PARENS repeat_opt
+ {
+ int i = (int) $3;
+ IntConst int_const = new IntConst ((sbyte) i);
+
+ if ($5 != null)
+ $$ = new RepeatedConstant (int_const, (int) $5);
+ else
+ $$ = int_const;
+ }
+ | K_FLOAT32 repeat_opt
+ {
+ FloatConst float_const = new FloatConst (0F);
+
+ if ($2 != null)
+ $$ = new RepeatedConstant (float_const, (int) $2);
+ else
+ $$ = float_const;
+ }
+ | K_FLOAT64 repeat_opt
+ {
+ DoubleConst double_const = new DoubleConst (0);
+
+ if ($2 != null)
+ $$ = new RepeatedConstant (double_const, (int) $2);
+ else
+ $$ = double_const;
+ }
+ | K_INT64 repeat_opt
+ {
+ IntConst int_const = new IntConst ((long) 0);
+
+ if ($2 != null)
+ $$ = new RepeatedConstant (int_const, (int) $2);
+ else
+ $$ = int_const;
+ }
+ | K_INT32 repeat_opt
+ {
+ IntConst int_const = new IntConst ((int) 0);
+
+ if ($2 != null)
+ $$ = new RepeatedConstant (int_const, (int) $2);
+ else
+ $$ = int_const;
+ }
+ | K_INT16 repeat_opt
+ {
+ IntConst int_const = new IntConst ((short) 0);
+
+ if ($2 != null)
+ $$ = new RepeatedConstant (int_const, (int) $2);
+ else
+ $$ = int_const;
+ }
+ | K_INT8 repeat_opt
+ {
+ IntConst int_const = new IntConst ((sbyte) 0);
+
+ if ($2 != null)
+ $$ = new RepeatedConstant (int_const, (int) $2);
+ else
+ $$ = int_const;
+ }
+ ;
+
+method_all : method_head OPEN_BRACE method_decls CLOSE_BRACE
+ {
+ codegen.EndMethodDef (tokenizer.Location);
+ }
+ ;
+
+method_head : D_METHOD meth_attr call_conv param_attr type method_name
+ formal_typars_clause OPEN_PARENS sig_args CLOSE_PARENS impl_attr
+ {
+ CallConv cc = (CallConv) $3;
+ if ($7 != null)
+ cc |= CallConv.Generic;
+
+ MethodDef methdef = new MethodDef (
+ codegen, (MethAttr) $2, cc,
+ (ImplAttr) $11, (string) $6, (BaseTypeRef) $5,
+ (ArrayList) $9, tokenizer.Reader.Location, (GenericParameters) $7, codegen.CurrentTypeDef);
+ if (pinvoke_info) {
+ ExternModule mod = codegen.ExternTable.AddModule (pinvoke_mod);
+ methdef.AddPInvokeInfo (pinvoke_attr, mod, pinvoke_meth);
+ pinvoke_info = false;
+ }
+ }
+ | D_METHOD meth_attr call_conv param_attr type
+ K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS method_name
+ OPEN_PARENS sig_args CLOSE_PARENS impl_attr
+ {
+ MethodDef methdef = new MethodDef (
+ codegen, (MethAttr) $2, (CallConv) $3,
+ (ImplAttr) $14, (string) $10, (BaseTypeRef) $5,
+ (ArrayList) $12, tokenizer.Reader.Location, null, codegen.CurrentTypeDef);
+
+ if (pinvoke_info) {
+ ExternModule mod = codegen.ExternTable.AddModule (pinvoke_mod);
+ methdef.AddPInvokeInfo (pinvoke_attr, mod, pinvoke_meth);
+ pinvoke_info = false;
+ }
+
+ methdef.AddRetTypeMarshalInfo ((NativeType) $8);
+ }
+ ;
+
+meth_attr : /* EMPTY */ { $$ = new MethAttr (); }
+ | meth_attr K_STATIC { $$ = (MethAttr) $1 | MethAttr.Static; }
+ | meth_attr K_PUBLIC { $$ = (MethAttr) $1 | MethAttr.Public; }
+ | meth_attr K_PRIVATE { $$ = (MethAttr) $1 | MethAttr.Private; }
+ | meth_attr K_FAMILY { $$ = (MethAttr) $1 | MethAttr.Family; }
+ | meth_attr K_ASSEMBLY { $$ = (MethAttr) $1 | MethAttr.Assembly; }
+ | meth_attr K_FAMANDASSEM { $$ = (MethAttr) $1 | MethAttr.FamAndAssem; }
+ | meth_attr K_FAMORASSEM { $$ = (MethAttr) $1 | MethAttr.FamOrAssem; }
+ | meth_attr K_PRIVATESCOPE { /* CHECK HEADERS */ }
+ | meth_attr K_FINAL { $$ = (MethAttr) $1 | MethAttr.Final; }
+ | meth_attr K_VIRTUAL { $$ = (MethAttr) $1 | MethAttr.Virtual; }
+ | meth_attr K_ABSTRACT { $$ = (MethAttr) $1 | MethAttr.Abstract; }
+ | meth_attr K_HIDEBYSIG { $$ = (MethAttr) $1 | MethAttr.HideBySig; }
+ | meth_attr K_NEWSLOT { $$ = (MethAttr) $1 | MethAttr.NewSlot; }
+ | meth_attr K_REQSECOBJ { $$ = (MethAttr) $1 | MethAttr.RequireSecObject; }
+ | meth_attr K_SPECIALNAME { $$ = (MethAttr) $1 | MethAttr.SpecialName; }
+ | meth_attr K_RTSPECIALNAME { $$ = (MethAttr) $1 | MethAttr.RTSpecialName; }
+ | meth_attr K_COMPILERCONTROLLED { /* Do nothing */ }
+ | meth_attr K_UNMANAGEDEXP
+ | meth_attr K_PINVOKEIMPL OPEN_PARENS comp_qstring K_AS
+ comp_qstring pinv_attr CLOSE_PARENS
+ {
+ pinvoke_info = true;
+ pinvoke_mod = (string) $4;
+ pinvoke_meth = (string) $6;
+ pinvoke_attr = (PInvokeAttr) $7;
+ }
+ | meth_attr K_PINVOKEIMPL OPEN_PARENS comp_qstring pinv_attr CLOSE_PARENS
+ {
+ pinvoke_info = true;
+ pinvoke_mod = (string) $4;
+ pinvoke_meth = null;
+ pinvoke_attr = (PInvokeAttr) $5;
+ }
+ | meth_attr K_PINVOKEIMPL OPEN_PARENS pinv_attr CLOSE_PARENS
+ {
+ pinvoke_info = true;
+ pinvoke_mod = null;
+ pinvoke_meth = null;
+ pinvoke_attr = (PInvokeAttr) $4;
+ }
+ ;
+
+pinv_attr : /* EMPTY */ { $$ = new PInvokeAttr (); }
+ | pinv_attr K_NOMANGLE { $$ = (PInvokeAttr) $1 | PInvokeAttr.nomangle; }
+ | pinv_attr K_ANSI { $$ = (PInvokeAttr) $1 | PInvokeAttr.ansi; }
+ | pinv_attr K_UNICODE { $$ = (PInvokeAttr) $1 | PInvokeAttr.unicode; }
+ | pinv_attr K_AUTOCHAR { $$ = (PInvokeAttr) $1 | PInvokeAttr.autochar; }
+ | pinv_attr K_LASTERR { $$ = (PInvokeAttr) $1 | PInvokeAttr.lasterr; }
+ | pinv_attr K_WINAPI { $$ = (PInvokeAttr) $1 | PInvokeAttr.winapi; }
+ | pinv_attr K_CDECL { $$ = (PInvokeAttr) $1 | PInvokeAttr.cdecl; }
+ | pinv_attr K_STDCALL { $$ = (PInvokeAttr) $1 | PInvokeAttr.stdcall; }
+ | pinv_attr K_THISCALL { $$ = (PInvokeAttr) $1 | PInvokeAttr.thiscall; }
+ | pinv_attr K_FASTCALL { $$ = (PInvokeAttr) $1 | PInvokeAttr.fastcall; }
+ | pinv_attr K_BESTFIT COLON K_ON { $$ = (PInvokeAttr) $1 | PInvokeAttr.bestfit_on; }
+ | pinv_attr K_BESTFIT COLON K_OFF { $$ = (PInvokeAttr) $1 | PInvokeAttr.bestfit_off; }
+ | pinv_attr K_CHARMAPERROR COLON K_ON { $$ = (PInvokeAttr) $1 | PInvokeAttr.charmaperror_on; }
+ | pinv_attr K_CHARMAPERROR COLON K_OFF { $$ = (PInvokeAttr) $1 | PInvokeAttr.charmaperror_off; }
+ ;
+
+method_name : D_CTOR
+ | D_CCTOR
+ | comp_name
+ ;
+
+param_attr : /* EMPTY */ { $$ = new ParamAttr (); }
+ | param_attr OPEN_BRACKET K_IN CLOSE_BRACKET { $$ = (ParamAttr) $1 | ParamAttr.In; }
+ | param_attr OPEN_BRACKET K_OUT CLOSE_BRACKET { $$ = (ParamAttr) $1 | ParamAttr.Out; }
+ | param_attr OPEN_BRACKET K_OPT CLOSE_BRACKET { $$ = (ParamAttr) $1 | ParamAttr.Opt; }
+ ;
+
+impl_attr : /* EMPTY */ { $$ = new ImplAttr (); }
+ | impl_attr K_NATIVE { $$ = (ImplAttr) $1 | ImplAttr.Native; }
+ | impl_attr K_CIL { $$ = (ImplAttr) $1 | ImplAttr.IL; }
+ | impl_attr K_IL { $$ = (ImplAttr) $1 | ImplAttr.IL; }
+ | impl_attr K_OPTIL { $$ = (ImplAttr) $1 | ImplAttr.Optil; }
+ | impl_attr K_MANAGED { /* should this reset? */ }
+ | impl_attr K_UNMANAGED { $$ = (ImplAttr) $1 | ImplAttr.Unmanaged; }
+ | impl_attr K_FORWARDREF { $$ = (ImplAttr) $1 | ImplAttr.ForwardRef; }
+ | impl_attr K_PRESERVESIG { $$ = (ImplAttr) $1 | ImplAttr.PreserveSig; }
+ | impl_attr K_RUNTIME { $$ = (ImplAttr) $1 | ImplAttr.Runtime; }
+ | impl_attr K_INTERNALCALL { $$ = (ImplAttr) $1 | ImplAttr.InternalCall; }
+ | impl_attr K_SYNCHRONIZED { $$ = (ImplAttr) $1 | ImplAttr.Synchronised; }
+ | impl_attr K_NOINLINING { $$ = (ImplAttr) $1 | ImplAttr.NoInLining; }
+ ;
+
+sig_args : /* EMPTY */
+ | sig_arg_list
+ ;
+
+sig_arg_list : sig_arg
+ {
+ ArrayList sig_list = new ArrayList ();
+ sig_list.Add ($1);
+ $$ = sig_list;
+ }
+ | sig_arg_list COMMA sig_arg
+ {
+ ArrayList sig_list = (ArrayList) $1;
+ sig_list.Add ($3);
+ $$ = sig_list;
+ }
+ ;
+
+sig_arg : param_attr type
+ {
+ $$ = new ParamDef ((ParamAttr) $1, null, (BaseTypeRef) $2);
+ }
+ | param_attr type id
+ {
+ $$ = new ParamDef ((ParamAttr) $1, (string) $3, (BaseTypeRef) $2);
+ }
+ | ELLIPSIS
+ {
+ $$ = new ParamDef ((ParamAttr) 0, "...", new SentinelTypeRef ());
+ // $$ = ParamDef.Ellipsis;
+ }
+ | param_attr type K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS
+ {
+ ParamDef param_def = new ParamDef ((ParamAttr) $1, null, (BaseTypeRef) $2);
+ param_def.AddMarshalInfo ((PEAPI.NativeType) $5);
+
+ $$ = param_def;
+ }
+ | param_attr type K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS id
+ {
+ ParamDef param_def = new ParamDef ((ParamAttr) $1, (string) $7, (BaseTypeRef) $2);
+ param_def.AddMarshalInfo ((PEAPI.NativeType) $5);
+
+ $$ = param_def;
+ }
+ ;
+
+type_list : /* EMPTY */
+ {
+ $$ = new ArrayList (0);
+ }
+ | ELLIPSIS
+ {
+ ArrayList type_list = new ArrayList ();
+ // type_list.Add (TypeRef.Ellipsis);
+ type_list.Add (new SentinelTypeRef ());
+ $$ = type_list;
+ }
+ | type_list COMMA ELLIPSIS
+ {
+ ArrayList type_list = (ArrayList) $1;
+ // type_list.Add (TypeRef.Ellipsis);
+ type_list.Add (new SentinelTypeRef ());
+ $$ = type_list;
+ }
+ | param_attr type opt_id
+ {
+ ArrayList type_list = new ArrayList ();
+ type_list.Add ($2);
+ $$ = type_list;
+ }
+ | type_list COMMA param_attr type opt_id
+ {
+ ArrayList type_list = (ArrayList) $1;
+ type_list.Add ($4);
+ }
+ ;
+
+opt_id : /* EMPTY */
+ | id
+ ;
+
+method_decls : /* EMPTY */
+ | method_decls method_decl
+ ;
+
+method_decl : D_EMITBYTE int32
+ | D_MAXSTACK int32
+ {
+ codegen.CurrentMethodDef.SetMaxStack ((int) $2);
+ }
+ | D_LOCALS OPEN_PARENS local_list CLOSE_PARENS
+ {
+ if ($3 != null) {
+ codegen.CurrentMethodDef.AddLocals (
+ (ArrayList) $3);
+ }
+ }
+ | D_LOCALS K_INIT OPEN_PARENS local_list CLOSE_PARENS
+ {
+ if ($4 != null) {
+ codegen.CurrentMethodDef.AddLocals (
+ (ArrayList) $4);
+ codegen.CurrentMethodDef.InitLocals ();
+ }
+ }
+ | D_ENTRYPOINT
+ {
+ codegen.CurrentMethodDef.EntryPoint ();
+ codegen.HasEntryPoint = true;
+ }
+ | D_ZEROINIT
+ {
+ codegen.CurrentMethodDef.ZeroInit ();
+ }
+ | D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET
+ | D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET K_AS id
+ | D_VTENTRY int32 COLON int32
+ | D_OVERRIDE type_spec DOUBLE_COLON method_name
+ {
+ codegen.CurrentTypeDef.AddOverride (codegen.CurrentMethodDef,
+ (BaseTypeRef) $2, (string) $4);
+
+ }
+ | D_OVERRIDE K_METHOD method_ref
+ {
+ codegen.CurrentTypeDef.AddOverride (codegen.CurrentMethodDef.Signature,
+ (BaseMethodRef) $3);
+ }
+ | D_OVERRIDE K_METHOD call_conv type type_spec DOUBLE_COLON method_name
+ OPEN_ANGLE_BRACKET OPEN_BRACKET int32 CLOSE_BRACKET CLOSE_ANGLE_BRACKET
+ OPEN_PARENS type_list CLOSE_PARENS
+ {
+ BaseTypeRef owner = (BaseTypeRef) $5;
+ ArrayList arg_list = (ArrayList) $14;
+ BaseTypeRef[] param_list;
+ BaseMethodRef methref;
+
+ if (arg_list != null)
+ param_list = (BaseTypeRef[]) arg_list.ToArray (typeof (BaseTypeRef));
+ else
+ param_list = new BaseTypeRef[0];
+
+ if (owner.UseTypeSpec) {
+ methref = new TypeSpecMethodRef (owner, (CallConv) $3, (BaseTypeRef) $4,
+ (string) $7, param_list, (int) $10);
+ } else {
+ methref = owner.GetMethodRef ((BaseTypeRef) $4,
+ (CallConv) $3, (string) $7, param_list, (int) $10);
+ }
+
+ codegen.CurrentTypeDef.AddOverride (codegen.CurrentMethodDef.Signature,
+ methref);
+ }
+ | scope_block
+ | D_PARAM OPEN_BRACKET int32 CLOSE_BRACKET init_opt
+ {
+ codegen.CurrentMethodDef.AddParamDefaultValue ((int)$3 - 1, (Constant)$5);
+ codegen.CurrentCustomAttrTarget = codegen.CurrentMethodDef.GetParam ((int)$3 - 1);
+ }
+ | param_type_decl
+ | id COLON
+ {
+ codegen.CurrentMethodDef.AddLabel ((string) $1);
+ }
+ | seh_block
+ | instr
+ | sec_decl
+ {
+ PermPair pp = (PermPair) $1;
+ if (!CheckSecurityActionValidity ((System.Security.Permissions.SecurityAction) (short) pp.sec_action, false))
+ Report.Error (String.Format ("Invalid security action : {0}", pp.sec_action));
+
+ codegen.AddPermission (pp.sec_action, pp.perm);
+ }
+ | extsource_spec
+ | language_decl
+ | customattr_decl
+ {
+ codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
+ }
+ | data_decl
+ ;
+
+local_list : /* EMPTY */
+ | local
+ {
+ ArrayList local_list = new ArrayList ();
+ local_list.Add ($1);
+ $$ = local_list;
+ }
+ | local_list COMMA local
+ {
+ ArrayList local_list = (ArrayList) $1;
+ local_list.Add ($3);
+ }
+ ;
+
+local : type
+ {
+ $$ = new Local (-1, (BaseTypeRef) $1);
+ }
+ | type id
+ {
+ $$ = new Local (-1, (string) $2, (BaseTypeRef) $1);
+ }
+ | slot_num type
+ {
+ $$ = new Local ((int) $1, (BaseTypeRef) $2);
+ }
+ | slot_num type id
+ {
+ $$ = new Local ((int) $1, (string) $3, (BaseTypeRef) $2);
+ }
+ ;
+
+slot_num : OPEN_BRACKET int32 CLOSE_BRACKET
+ {
+ $$ = $2;
+ }
+ ;
+
+type_spec : OPEN_BRACKET slashed_name CLOSE_BRACKET
+ {
+ // This is a reference to a global method in another
+ // assembly. This is not supported in the MS version of ilasm
+ }
+ | OPEN_BRACKET D_MODULE slashed_name CLOSE_BRACKET
+ {
+ string module = (string) $3;
+
+ if (codegen.IsThisModule (module)) {
+ // This is not handled yet.
+ } else {
+ $$ = codegen.ExternTable.GetModuleTypeRef ((string) $3, "<Module>", false);
+ }
+
+ }
+ | type
+ ;
+
+scope_block : scope_block_begin method_decls CLOSE_BRACE
+ {
+ $$ = new HandlerBlock ((LabelInfo) $1,
+ codegen.CurrentMethodDef.AddLabel ());
+ }
+ ;
+
+scope_block_begin : OPEN_BRACE
+ {
+ $$ = codegen.CurrentMethodDef.AddLabel ();
+ }
+ ;
+
+
+seh_block : try_block seh_clauses
+ {
+ TryBlock try_block = (TryBlock) $1;
+
+ ArrayList clause_list = (ArrayList) $2;
+ foreach (object clause in clause_list)
+ try_block.AddSehClause ((ISehClause) clause);
+
+ codegen.CurrentMethodDef.AddInstr (try_block);
+ }
+ ;
+
+try_block : D_TRY scope_block
+ {
+ $$ = new TryBlock ((HandlerBlock) $2, tokenizer.Location);
+ }
+ | D_TRY id K_TO id
+ {
+ LabelInfo from = codegen.CurrentMethodDef.AddLabelRef ((string) $2);
+ LabelInfo to = codegen.CurrentMethodDef.AddLabelRef ((string) $4);
+
+ $$ = new TryBlock (new HandlerBlock (from, to), tokenizer.Location);
+ }
+ | D_TRY int32 K_TO int32
+ {
+ LabelInfo from = codegen.CurrentMethodDef.AddLabel ((int) $2);
+ LabelInfo to = codegen.CurrentMethodDef.AddLabel ((int) $4);
+
+ $$ = new TryBlock (new HandlerBlock (from, to), tokenizer.Location);
+ }
+ ;
+
+seh_clauses : seh_clause
+ {
+ ArrayList clause_list = new ArrayList ();
+ clause_list.Add ($1);
+ $$ = clause_list;
+ }
+ | seh_clauses seh_clause
+ {
+ ArrayList clause_list = (ArrayList) $1;
+ clause_list.Add ($2);
+ }
+ ;
+
+seh_clause : K_CATCH class_ref handler_block
+ {
+ if ($2.GetType () == typeof (PrimitiveTypeRef))
+ Report.Error ("Exception not be of a primitive type.");
+
+ BaseClassRef type = (BaseClassRef) $2;
+ CatchBlock cb = new CatchBlock (type);
+ cb.SetHandlerBlock ((HandlerBlock) $3);
+ $$ = cb;
+ }
+ | K_FINALLY handler_block
+ {
+ FinallyBlock fb = new FinallyBlock ();
+ fb.SetHandlerBlock ((HandlerBlock) $2);
+ $$ = fb;
+ }
+ | K_FAULT handler_block
+ {
+ FaultBlock fb = new FaultBlock ();
+ fb.SetHandlerBlock ((HandlerBlock) $2);
+ $$ = fb;
+ }
+ | filter_clause handler_block
+ {
+ FilterBlock fb = (FilterBlock) $1;
+ fb.SetHandlerBlock ((HandlerBlock) $2);
+ }
+ ;
+
+filter_clause : K_FILTER scope_block
+ {
+ HandlerBlock block = (HandlerBlock) $2;
+ FilterBlock fb = new FilterBlock (block);
+ $$ = fb;
+ }
+ | K_FILTER id
+ {
+ LabelInfo from = codegen.CurrentMethodDef.AddLabelRef ((string) $2);
+ FilterBlock fb = new FilterBlock (new HandlerBlock (from, null));
+ $$ = fb;
+ }
+ | K_FILTER int32
+ {
+ LabelInfo from = codegen.CurrentMethodDef.AddLabel ((int) $2);
+ FilterBlock fb = new FilterBlock (new HandlerBlock (from, null));
+ $$ = fb;
+ }
+ ;
+
+handler_block : scope_block
+ {
+
+ }
+ | K_HANDLER id K_TO id
+ {
+ LabelInfo from = codegen.CurrentMethodDef.AddLabelRef ((string) $2);
+ LabelInfo to = codegen.CurrentMethodDef.AddLabelRef ((string) $4);
+
+ $$ = new HandlerBlock (from, to);
+ }
+ | K_HANDLER int32 K_TO int32
+ {
+ LabelInfo from = codegen.CurrentMethodDef.AddLabelRef ((string) $2);
+ LabelInfo to = codegen.CurrentMethodDef.AddLabelRef ((string) $4);
+
+ $$ = new HandlerBlock (from, to);
+ }
+ ;
+
+instr : INSTR_NONE
+ {
+ codegen.CurrentMethodDef.AddInstr (
+ new SimpInstr ((Op) $1, tokenizer.Location));
+ }
+ | INSTR_LOCAL int32
+ {
+ codegen.CurrentMethodDef.AddInstr (
+ new IntInstr ((IntOp) $1, (int) $2, tokenizer.Location));
+ }
+ | INSTR_LOCAL id
+ {
+ int slot = codegen.CurrentMethodDef.GetNamedLocalSlot ((string) $2);
+ codegen.CurrentMethodDef.AddInstr (
+ new IntInstr ((IntOp) $1, slot, tokenizer.Location));
+ }
+ | INSTR_PARAM int32
+ {
+ codegen.CurrentMethodDef.AddInstr (
+ new IntInstr ((IntOp) $1, (int) $2, tokenizer.Location));
+ }
+ | INSTR_PARAM id
+ {
+ int pos = codegen.CurrentMethodDef.GetNamedParamPos ((string) $2);
+ codegen.CurrentMethodDef.AddInstr (
+ new IntInstr ((IntOp) $1, pos, tokenizer.Location));
+ }
+ | INSTR_I int32
+ {
+ codegen.CurrentMethodDef.AddInstr (new
+ IntInstr ((IntOp) $1, (int) $2, tokenizer.Location));
+ }
+ | INSTR_I id
+ {
+ int slot = codegen.CurrentMethodDef.GetNamedLocalSlot ((string) $2);
+ codegen.CurrentMethodDef.AddInstr (new
+ IntInstr ((IntOp) $1, slot, tokenizer.Location));
+ }
+ | INSTR_I8 int64
+ {
+ if ($1 is MiscInstr) {
+ switch ((MiscInstr) $1) {
+ case MiscInstr.ldc_i8:
+ codegen.CurrentMethodDef.AddInstr (new LdcInstr ((MiscInstr) $1,
+ (long) $2, tokenizer.Location));
+ break;
+ }
+ }
+ }
+ | INSTR_R float64
+ {
+ switch ((MiscInstr) $1) {
+ case MiscInstr.ldc_r4:
+ case MiscInstr.ldc_r8:
+ codegen.CurrentMethodDef.AddInstr (new LdcInstr ((MiscInstr) $1, (double) $2, tokenizer.Location));
+ break;
+ }
+ }
+ | INSTR_R int64
+ {
+ long l = (long) $2;
+
+ switch ((MiscInstr) $1) {
+ case MiscInstr.ldc_r4:
+ case MiscInstr.ldc_r8:
+ codegen.CurrentMethodDef.AddInstr (new LdcInstr ((MiscInstr) $1, (double) l, tokenizer.Location));
+ break;
+ }
+ }
+ | INSTR_R bytes_list
+ {
+ switch ((MiscInstr) $1) {
+ case MiscInstr.ldc_r4:
+ float s = BitConverter.ToSingle ((byte []) $2, 0);
+ codegen.CurrentMethodDef.AddInstr (new LdcInstr ((MiscInstr) $1, s, tokenizer.Location));
+ break;
+ case MiscInstr.ldc_r8:
+ double d = BitConverter.ToDouble ((byte []) $2, 0);
+ codegen.CurrentMethodDef.AddInstr (new LdcInstr ((MiscInstr) $1, d, tokenizer.Location));
+ break;
+ }
+ }
+ | INSTR_BRTARGET int32
+ {
+ LabelInfo target = codegen.CurrentMethodDef.AddLabel ((int) $2);
+ codegen.CurrentMethodDef.AddInstr (new BranchInstr ((BranchOp) $1,
+ target, tokenizer.Location));
+ }
+ | INSTR_BRTARGET id
+ {
+ LabelInfo target = codegen.CurrentMethodDef.AddLabelRef ((string) $2);
+ codegen.CurrentMethodDef.AddInstr (new BranchInstr ((BranchOp) $1,
+ target, tokenizer.Location));
+ }
+ | INSTR_METHOD method_ref
+ {
+ codegen.CurrentMethodDef.AddInstr (new MethodInstr ((MethodOp) $1,
+ (BaseMethodRef) $2, tokenizer.Location));
+ }
+ | INSTR_FIELD type type_spec DOUBLE_COLON id
+ {
+
+ BaseTypeRef owner = (BaseTypeRef) $3;
+ GenericParamRef gpr = $2 as GenericParamRef;
+ if (gpr != null && codegen.CurrentMethodDef != null)
+ codegen.CurrentMethodDef.ResolveGenParam ((PEAPI.GenParam) gpr.PeapiType);
+ IFieldRef fieldref = owner.GetFieldRef (
+ (BaseTypeRef) $2, (string) $5);
+
+ codegen.CurrentMethodDef.AddInstr (new FieldInstr ((FieldOp) $1, fieldref, tokenizer.Location));
+ }
+ | INSTR_FIELD type id
+ {
+ GlobalFieldRef fieldref = codegen.GetGlobalFieldRef ((BaseTypeRef) $2, (string) $3);
+
+ codegen.CurrentMethodDef.AddInstr (new FieldInstr ((FieldOp) $1, fieldref, tokenizer.Location));
+ }
+ | INSTR_TYPE type_spec
+ {
+ codegen.CurrentMethodDef.AddInstr (new TypeInstr ((TypeOp) $1,
+ (BaseTypeRef) $2, tokenizer.Location));
+ }
+ | INSTR_STRING comp_qstring
+ {
+ if ((MiscInstr) $1 == MiscInstr.ldstr)
+ codegen.CurrentMethodDef.AddInstr (new LdstrInstr ((string) $2, tokenizer.Location));
+ }
+ | INSTR_STRING K_BYTEARRAY ASSIGN bytes_list
+ {
+ byte[] bs = (byte[]) $4;
+ if ((MiscInstr) $1 == MiscInstr.ldstr)
+ codegen.CurrentMethodDef.AddInstr (new LdstrInstr (bs, tokenizer.Location));
+ }
+ | INSTR_STRING K_BYTEARRAY bytes_list
+ {
+ byte[] bs = (byte[]) $3;
+ if ((MiscInstr) $1 == MiscInstr.ldstr)
+ codegen.CurrentMethodDef.AddInstr (new LdstrInstr (bs, tokenizer.Location));
+ }
+ | INSTR_SIG call_conv type OPEN_PARENS type_list CLOSE_PARENS
+ {
+ ArrayList arg_list = (ArrayList) $5;
+ BaseTypeRef[] arg_array = null;
+
+ if (arg_list != null)
+ arg_array = (BaseTypeRef[]) arg_list.ToArray (typeof (BaseTypeRef));
+
+ codegen.CurrentMethodDef.AddInstr (new CalliInstr ((CallConv) $2,
+ (BaseTypeRef) $3, arg_array, tokenizer.Location));
+ }
+ | INSTR_TOK owner_type
+ {
+ if ((MiscInstr) $1 == MiscInstr.ldtoken) {
+ if ($2 is BaseMethodRef)
+ codegen.CurrentMethodDef.AddInstr (new LdtokenInstr ((BaseMethodRef) $2, tokenizer.Location));
+ else if ($2 is IFieldRef)
+ codegen.CurrentMethodDef.AddInstr (new LdtokenInstr ((IFieldRef) $2, tokenizer.Location));
+ else
+ codegen.CurrentMethodDef.AddInstr (new LdtokenInstr ((BaseTypeRef) $2, tokenizer.Location));
+
+ }
+ }
+ | INSTR_SWITCH OPEN_PARENS labels CLOSE_PARENS
+ {
+ codegen.CurrentMethodDef.AddInstr (new SwitchInstr ((ArrayList) $3, tokenizer.Location));
+ }
+ ;
+
+method_ref : call_conv type method_name typars_clause
+ OPEN_PARENS type_list CLOSE_PARENS
+ {
+ ArrayList arg_list = (ArrayList) $6;
+ GenericArguments ga = (GenericArguments) $4;
+ BaseTypeRef[] param_list;
+
+ if (arg_list != null)
+ param_list = (BaseTypeRef[]) arg_list.ToArray (typeof (BaseTypeRef));
+ else
+ param_list = new BaseTypeRef[0];
+
+ BaseMethodRef methref = codegen.GetGlobalMethodRef ((BaseTypeRef) $2, (CallConv) $1,
+ (string) $3, param_list, (ga != null ? ga.Count : 0));
+
+ if (ga != null)
+ methref = methref.GetGenericMethodRef (ga);
+
+ $$ = methref;
+ }
+ | call_conv type type_spec DOUBLE_COLON method_name
+ typars_clause OPEN_PARENS type_list CLOSE_PARENS
+ {
+ BaseTypeRef owner = (BaseTypeRef) $3;
+ ArrayList arg_list = (ArrayList) $8;
+ GenericArguments ga = (GenericArguments) $6;
+ BaseTypeRef[] param_list;
+ BaseMethodRef methref;
+
+ if (arg_list != null)
+ param_list = (BaseTypeRef[]) arg_list.ToArray (typeof (BaseTypeRef));
+ else
+ param_list = new BaseTypeRef[0];
+
+ if (codegen.IsThisAssembly ("mscorlib")) {
+ PrimitiveTypeRef prim = owner as PrimitiveTypeRef;
+ if (prim != null && prim.SigMod == "")
+ owner = codegen.GetTypeRef (prim.Name);
+ }
+
+ if (owner.UseTypeSpec) {
+ methref = new TypeSpecMethodRef (owner, (CallConv) $1, (BaseTypeRef) $2,
+ (string) $5, param_list, (ga != null ? ga.Count : 0));
+ } else {
+ methref = owner.GetMethodRef ((BaseTypeRef) $2,
+ (CallConv) $1, (string) $5, param_list, (ga != null ? ga.Count : 0));
+ }
+
+ if (ga != null)
+ methref = methref.GetGenericMethodRef (ga);
+
+ $$ = methref;
+ }
+ ;
+
+labels : /* EMPTY */
+ | id
+ {
+ ArrayList label_list = new ArrayList ();
+ label_list.Add ($1);
+ $$ = label_list;
+ }
+ | int32
+ {
+ ArrayList label_list = new ArrayList ();
+ label_list.Add ($1);
+ $$ = label_list;
+ }
+ | labels COMMA id
+ {
+ ArrayList label_list = (ArrayList) $1;
+ label_list.Add ($3);
+ }
+ | labels COMMA int32
+ {
+ ArrayList label_list = (ArrayList) $1;
+ label_list.Add ($3);
+ }
+ ;
+
+owner_type : type_spec
+ | member_ref
+ ;
+
+member_ref : K_METHOD method_ref
+ {
+ $$ = $2;
+ }
+ | K_FIELD type type_spec DOUBLE_COLON id
+ {
+ BaseTypeRef owner = (BaseTypeRef) $3;
+
+ $$ = owner.GetFieldRef (
+ (BaseTypeRef) $2, (string) $5);
+ }
+ | K_FIELD type id
+ {
+ $$ = codegen.GetGlobalFieldRef ((BaseTypeRef) $2, (string) $3);
+ }
+ ;
+
+event_all : event_head OPEN_BRACE event_decls CLOSE_BRACE
+ {
+ codegen.CurrentTypeDef.EndEventDef ();
+ }
+ ;
+
+event_head : D_EVENT event_attr type_spec comp_name
+ {
+ EventDef event_def = new EventDef ((FeatureAttr) $2,
+ (BaseTypeRef) $3, (string) $4);
+ codegen.CurrentTypeDef.BeginEventDef (event_def);
+ codegen.CurrentCustomAttrTarget = event_def;
+ }
+ | D_EVENT event_attr id
+ ;
+
+event_attr : /* EMPTY */
+ {
+ $$ = new FeatureAttr ();
+ }
+ | event_attr K_RTSPECIALNAME
+ {
+ $$ = (FeatureAttr) $1 & FeatureAttr.Rtspecialname;
+ }
+ | event_attr K_SPECIALNAME
+ {
+ $$ = (FeatureAttr) $1 & FeatureAttr.Specialname;
+ }
+ ;
+
+event_decls : /* EMPTY */
+ | event_decls event_decl
+ ;
+
+event_decl : D_ADDON method_ref
+ {
+ codegen.CurrentTypeDef.CurrentEvent.AddAddon (
+ (MethodRef) $2);
+ }
+ | D_REMOVEON method_ref
+ {
+ codegen.CurrentTypeDef.CurrentEvent.AddRemoveon (
+ (MethodRef) $2);
+ }
+ | D_FIRE method_ref
+ {
+ codegen.CurrentTypeDef.CurrentEvent.AddFire (
+ (MethodRef) $2);
+ }
+ | D_OTHER method_ref
+ {
+ codegen.CurrentTypeDef.CurrentEvent.AddOther (
+ (MethodRef) $2);
+ }
+ | customattr_decl
+ {
+ codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
+ }
+ | extsource_spec
+ | language_decl
+ ;
+
+prop_all : prop_head OPEN_BRACE prop_decls CLOSE_BRACE
+ {
+ codegen.CurrentTypeDef.EndPropertyDef ();
+ }
+ ;
+
+prop_head : D_PROPERTY prop_attr type comp_name OPEN_PARENS type_list CLOSE_PARENS init_opt
+ {
+ PropertyDef prop_def = new PropertyDef ((FeatureAttr) $2, (BaseTypeRef) $3,
+ (string) $4, (ArrayList) $6);
+ codegen.CurrentTypeDef.BeginPropertyDef (prop_def);
+ codegen.CurrentCustomAttrTarget = prop_def;
+
+ if ($8 != null) {
+ prop_def.AddInitValue ((Constant) $8);
+ }
+ }
+ ;
+
+prop_attr : /* EMPTY */
+ {
+ $$ = new FeatureAttr ();
+ }
+ | prop_attr K_RTSPECIALNAME
+ {
+ $$ = (FeatureAttr) $1 | FeatureAttr.Rtspecialname;
+ }
+ | prop_attr K_SPECIALNAME
+ {
+ $$ = (FeatureAttr) $1 | FeatureAttr.Specialname;
+ }
+ | prop_attr K_INSTANCE
+ {
+ $$ = (FeatureAttr) $1 | FeatureAttr.Instance;
+ }
+ ;
+
+prop_decls : /* EMPTY */
+ | prop_decls prop_decl
+ ;
+
+prop_decl : D_SET method_ref
+ {
+ codegen.CurrentTypeDef.CurrentProperty.AddSet ((MethodRef) $2);
+ }
+ | D_GET method_ref
+ {
+ codegen.CurrentTypeDef.CurrentProperty.AddGet ((MethodRef) $2);
+ }
+ | D_OTHER method_ref
+ {
+ codegen.CurrentTypeDef.CurrentProperty.AddOther ((MethodRef) $2);
+ }
+ | customattr_decl
+ {
+ codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
+ }
+ | extsource_spec
+ | language_decl
+ ;
+
+customattr_decl : D_CUSTOM custom_type
+ {
+ $$ = new CustomAttr ((BaseMethodRef) $2, null);
+ }
+ | D_CUSTOM custom_type ASSIGN comp_qstring
+ | D_CUSTOM custom_type ASSIGN bytes_list
+ {
+ $$ = new CustomAttr ((BaseMethodRef) $2,
+ (byte[]) $4);
+ }
+ | D_CUSTOM OPEN_PARENS owner_type CLOSE_PARENS custom_type
+ | D_CUSTOM OPEN_PARENS owner_type CLOSE_PARENS custom_type ASSIGN comp_qstring
+ | D_CUSTOM OPEN_PARENS owner_type CLOSE_PARENS custom_type ASSIGN
+ bytes_list
+ ;
+
+custom_type : call_conv type type_spec DOUBLE_COLON D_CTOR OPEN_PARENS type_list CLOSE_PARENS
+ {
+ BaseTypeRef owner = (BaseTypeRef) $3;
+ ArrayList arg_list = (ArrayList) $7;
+ BaseTypeRef[] param_list;
+
+ if (arg_list != null)
+ param_list = (BaseTypeRef[]) arg_list.ToArray (typeof (BaseTypeRef));
+ else
+ param_list = new BaseTypeRef[0];
+
+ $$ = owner.GetMethodRef ((BaseTypeRef) $2,
+ (CallConv) $1, (string) $5, param_list, 0);
+ }
+ | call_conv type D_CTOR OPEN_PARENS type_list CLOSE_PARENS
+ {
+ ArrayList arg_list = (ArrayList) $5;
+ BaseTypeRef[] param_list;
+
+ if (arg_list != null)
+ param_list = (BaseTypeRef[]) arg_list.ToArray (typeof (BaseTypeRef));
+ else
+ param_list = new BaseTypeRef[0];
+
+ $$ = codegen.GetGlobalMethodRef ((BaseTypeRef) $2, (CallConv) $1,
+ (string) $3, param_list, 0);
+ }
+ ;
+
+sec_decl : D_PERMISSION sec_action type_spec OPEN_PARENS nameval_pairs CLOSE_PARENS
+ {
+ $$ = TypeSpecToPermPair ($2, $3, (ArrayList) $5);
+ }
+ | D_PERMISSION sec_action type_spec
+ {
+ $$ = TypeSpecToPermPair ($2, $3, null);
+ }
+ | D_PERMISSIONSET sec_action ASSIGN bytes_list
+ {
+ System.Text.UnicodeEncoding ue = new System.Text.UnicodeEncoding ();
+ PermissionSetAttribute psa = new PermissionSetAttribute ((System.Security.Permissions.SecurityAction) (short) $2);
+ psa.XML = ue.GetString ((byte []) $4);
+ $$ = new PermPair ((PEAPI.SecurityAction) $2, psa.CreatePermissionSet ());
+ }
+ | D_PERMISSIONSET sec_action comp_qstring
+ {
+ PermissionSetAttribute psa = new PermissionSetAttribute ((System.Security.Permissions.SecurityAction) (short) $2);
+ psa.XML = (string) $3;
+ $$ = new PermPair ((PEAPI.SecurityAction) $2, psa.CreatePermissionSet ());
+ }
+ ;
+
+nameval_pairs : nameval_pair
+ {
+ ArrayList pairs = new ArrayList ();
+ pairs.Add ($1);
+ $$ = pairs;
+ }
+ | nameval_pairs COMMA nameval_pair
+ {
+ ArrayList pairs = (ArrayList) $1;
+ pairs.Add ($3);
+ $$ = pairs;
+ }
+ ;
+
+nameval_pair : comp_qstring ASSIGN cavalue
+ {
+ $$ = new NameValuePair ((string) $1, $3);
+ }
+ ;
+
+cavalue : truefalse
+ | int32
+ | int32 OPEN_PARENS int32 CLOSE_PARENS
+ {
+ $$ = $3;
+ }
+ | comp_qstring
+ | class_ref OPEN_PARENS K_INT8 COLON int32 CLOSE_PARENS
+ {
+ $$ = ClassRefToObject ($1, (byte) (int) $5);
+ }
+ | class_ref OPEN_PARENS K_INT16 COLON int32 CLOSE_PARENS
+ {
+ $$ = ClassRefToObject ($1, (short) (int) $5);
+ }
+ | class_ref OPEN_PARENS K_INT32 COLON int32 CLOSE_PARENS
+ {
+ $$ = ClassRefToObject ($1, (int) $5);
+ }
+ | class_ref OPEN_PARENS int32 CLOSE_PARENS
+ {
+ $$ = ClassRefToObject ($1, (int) $3);
+ }
+ ;
+
+sec_action : K_REQUEST
+ {
+ $$ = PEAPI.SecurityAction.Request;
+ }
+ | K_DEMAND
+ {
+ $$ = PEAPI.SecurityAction.Demand;
+ }
+ | K_ASSERT
+ {
+ $$ = PEAPI.SecurityAction.Assert;
+ }
+ | K_DENY
+ {
+ $$ = PEAPI.SecurityAction.Deny;
+ }
+ | K_PERMITONLY
+ {
+ $$ = PEAPI.SecurityAction.PermitOnly;
+ }
+ | K_LINKCHECK
+ {
+ $$ = PEAPI.SecurityAction.LinkDemand;
+ }
+ | K_INHERITCHECK
+ {
+ $$ = PEAPI.SecurityAction.InheritDemand;
+ }
+ | K_REQMIN
+ {
+ $$ = PEAPI.SecurityAction.RequestMinimum;
+ }
+ | K_REQOPT
+ {
+ $$ = PEAPI.SecurityAction.RequestOptional;
+ }
+ | K_REQREFUSE
+ {
+ $$ = PEAPI.SecurityAction.RequestRefuse;
+ }
+ | K_PREJITGRANT
+ {
+ $$ = PEAPI.SecurityAction.PreJitGrant;
+ }
+ | K_PREJITDENY
+ {
+ $$ = PEAPI.SecurityAction.PreJitDeny;
+ }
+ | K_NONCASDEMAND
+ {
+ $$ = PEAPI.SecurityAction.NonCasDemand;
+ }
+ | K_NONCASLINKDEMAND
+ {
+ $$ = PEAPI.SecurityAction.NonCasLinkDemand;
+ }
+ | K_NONCASINHERITANCE
+ {
+ $$ = PEAPI.SecurityAction.NonCasInheritance;
+ }
+ /* FIXME: Should we have LinkDemandChoice, InheritDemandChoice and DemandChoice ? */
+ ;
+
+module_head : D_MODULE
+ {
+ }
+ | D_MODULE comp_name
+ {
+ codegen.SetModuleName ((string) $2);
+ }
+ | D_MODULE K_EXTERN comp_name
+ {
+ codegen.ExternTable.AddModule ((string) $3);
+ }
+ ;
+
+file_decl : D_FILE file_attr comp_name file_entry D_HASH ASSIGN
+ bytes_list file_entry
+ {
+ codegen.SetFileRef (new FileRef ((string) $3, (byte []) $7, (bool) $2, (bool) $8));
+ }
+ | D_FILE file_attr comp_name file_entry
+ {
+ // We need to compute the hash ourselves. :-(
+ // AssemblyName an = AssemblyName.GetName ((string) $3);
+ }
+ ;
+
+file_attr : /* EMPTY */
+ {
+ $$ = true;
+ }
+ | file_attr K_NOMETADATA
+ {
+ $$ = false;
+ }
+ ;
+
+file_entry : /* EMPTY */
+ {
+ $$ = false;
+ }
+ | D_ENTRYPOINT
+ {
+ $$ = true;
+ }
+ ;
+
+assembly_all : assembly_head OPEN_BRACE assembly_decls CLOSE_BRACE
+ {
+ codegen.CurrentCustomAttrTarget = null;
+ }
+ ;
+
+assembly_head : D_ASSEMBLY asm_attr slashed_name
+ {
+ codegen.SetAssemblyName ((string) $3);
+ }
+ ;
+
+asm_attr : /* EMPTY */
+ | asm_attr K_NOAPPDOMAIN
+ | asm_attr K_NOPROCESS
+ | asm_attr K_NOMACHINE
+ ;
+
+assembly_decls : /* EMPTY */
+ | assembly_decls assembly_decl
+ ;
+
+assembly_decl : D_PUBLICKEY ASSIGN bytes_list
+ {
+ codegen.SetAssemblyPublicKey ((byte []) $3);
+ }
+ | D_VER int32 COLON int32 COLON int32 COLON int32
+ {
+ codegen.SetAssemblyVersion ((int) $2, (int) $4, (int) $6, (int) $8);
+ }
+ | D_LOCALE comp_qstring
+ {
+ codegen.SetAssemblyLocale ((string) $2);
+ }
+ | D_LOCALE ASSIGN bytes_list
+ | D_HASH K_ALGORITHM int32
+ {
+ codegen.SetAssemblyHashAlgorithm ((int) $3);
+ }
+ | customattr_decl
+ {
+ codegen.AddAssemblyCustomAttribute ((CustomAttr) $1);
+ }
+ | sec_decl
+ {
+ PermPair pp = (PermPair) $1;
+ if (!CheckSecurityActionValidity ((System.Security.Permissions.SecurityAction) (short) pp.sec_action, true))
+ Report.Error (String.Format ("Invalid security action : {0}", pp.sec_action));
+
+ codegen.AddAssemblyPermission (pp.sec_action, pp.perm);
+ }
+ ;
+
+asm_or_ref_decl : D_PUBLICKEY ASSIGN bytes_list
+ | D_VER int32 COLON int32 COLON int32 COLON int32
+ | D_LOCALE comp_qstring
+ | D_LOCALE ASSIGN bytes_list
+ | customattr_decl
+ ;
+
+assemblyref_all : assemblyref_head OPEN_BRACE assemblyref_decls CLOSE_BRACE
+ ;
+
+assemblyref_head : D_ASSEMBLY K_EXTERN slashed_name
+ {
+ System.Reflection.AssemblyName asmb_name =
+ new System.Reflection.AssemblyName ();
+ asmb_name.Name = (string) $3;
+ codegen.BeginAssemblyRef ((string) $3, asmb_name);
+ }
+ | D_ASSEMBLY K_EXTERN slashed_name K_AS slashed_name
+ {
+ System.Reflection.AssemblyName asmb_name =
+ new System.Reflection.AssemblyName ();
+ asmb_name.Name = (string) $3;
+ codegen.BeginAssemblyRef ((string) $5, asmb_name);
+ }
+ ;
+
+assemblyref_decls : /* EMPTY */
+ | assemblyref_decls assemblyref_decl
+ ;
+
+assemblyref_decl : D_VER int32 COLON int32 COLON int32 COLON int32
+ {
+ codegen.CurrentAssemblyRef.SetVersion ((int) $2, (int) $4, (int) $6, (int) $8);
+ }
+ | D_PUBLICKEY ASSIGN bytes_list
+ {
+ codegen.CurrentAssemblyRef.SetPublicKey ((byte []) $3);
+ }
+ | D_PUBLICKEYTOKEN ASSIGN bytes_list
+ {
+ codegen.CurrentAssemblyRef.SetPublicKeyToken ((byte []) $3);
+ }
+ | D_LOCALE comp_qstring
+ {
+ codegen.CurrentAssemblyRef.SetLocale ((string) $2);
+ }
+ | D_LOCALE ASSIGN bytes_list
+
+ | D_HASH ASSIGN bytes_list
+ {
+ codegen.CurrentAssemblyRef.SetHash ((byte []) $3);
+ }
+ | customattr_decl
+ {
+ codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
+ }
+ ;
+
+exptype_all : exptype_head OPEN_BRACE exptype_decls CLOSE_BRACE
+ ;
+
+exptype_head : D_CLASS K_EXTERN expt_attr comp_name
+ ;
+
+expt_attr : /* EMPTY */
+ | expt_attr K_PRIVATE
+ | expt_attr K_PUBLIC
+ | expt_attr K_NESTED K_PUBLIC
+ | expt_attr K_NESTED K_PRIVATE
+ | expt_attr K_NESTED K_FAMILY
+ | expt_attr K_NESTED K_ASSEMBLY
+ | expt_attr K_NESTED K_FAMANDASSEM
+ | expt_attr K_NESTED K_FAMORASSEM
+ ;
+
+exptype_decls : /* EMPTY */
+ | exptype_decls exptype_decl
+ ;
+
+exptype_decl : D_FILE comp_name
+ | D_CLASS K_EXTERN comp_name
+ | D_CLASS int32
+ | customattr_decl
+ ;
+
+manifestres_all : manifestres_head OPEN_BRACE manifestres_decls CLOSE_BRACE
+ ;
+
+manifestres_head : D_MRESOURCE manres_attr comp_name
+ {
+ FileStream s = new FileStream ((string) $3, FileMode.Open, FileAccess.Read);
+ byte [] buff = new byte [s.Length];
+ s.Read (buff, 0, (int) s.Length);
+ s.Close ();
+
+ codegen.AddManifestResource (new ManifestResource ((string) $3, buff, ($2 == null) ? 0 : (uint) $2));
+ }
+ ;
+
+manres_attr : /* EMPTY */
+ | manres_attr K_PUBLIC { $$ = ManifestResource.PublicResource; }
+ | manres_attr K_PRIVATE { $$ = ManifestResource.PrivateResource; }
+ ;
+
+manifestres_decls : /* EMPTY */
+ | manifestres_decls manifestres_decl
+ ;
+
+manifestres_decl : D_FILE comp_name K_AT int32
+ | D_ASSEMBLY K_EXTERN slashed_name
+ | customattr_decl
+ ;
+
+comp_qstring : QSTRING
+ | comp_qstring PLUS QSTRING { $$ = String.Format ("{0}{1}", $1, $3); }
+ ;
+
+int32 : INT64
+ {
+ long l = (long) $1;
+ byte[] intb = BitConverter.GetBytes (l);
+ $$ = BitConverter.ToInt32 (intb, BitConverter.IsLittleEndian ? 0 : 4);
+ }
+ ;
+
+int64 : INT64
+ ;
+
+float64 : FLOAT64
+ | K_FLOAT32 OPEN_PARENS INT32 CLOSE_PARENS
+ {
+ int i = (int) $3;
+ byte[] intb = BitConverter.GetBytes (i);
+ $$ = (double) BitConverter.ToSingle (intb, BitConverter.IsLittleEndian ? 0 : 4);
+ }
+ | K_FLOAT32 OPEN_PARENS INT64 CLOSE_PARENS
+ {
+ long l = (long) $3;
+ byte[] intb = BitConverter.GetBytes (l);
+ $$ = (double) BitConverter.ToSingle (intb, BitConverter.IsLittleEndian ? 0 : 4);
+ }
+ | K_FLOAT64 OPEN_PARENS INT64 CLOSE_PARENS
+ {
+ byte[] intb = BitConverter.GetBytes ((long) $3);
+ $$ = BitConverter.ToDouble (intb, BitConverter.IsLittleEndian ? 0 : 4);
+ }
+ | K_FLOAT64 OPEN_PARENS INT32 CLOSE_PARENS
+ {
+ byte[] intb = BitConverter.GetBytes ((int) $3);
+ $$ = (double) BitConverter.ToSingle (intb, BitConverter.IsLittleEndian ? 0 : 4);
+ }
+ ;
+
+hexbyte : HEXBYTE { }
+ ;
+
+bytes_list : OPEN_PARENS
+ {
+ tokenizer.InByteArray = true;
+ }
+ bytes CLOSE_PARENS
+ {
+ $$ = $3;
+ tokenizer.InByteArray = false;
+ }
+ ;
+
+bytes : /* EMPTY */ { $$ = new byte[0]; }
+ | hexbytes
+ {
+ ArrayList byte_list = (ArrayList) $1;
+ $$ = byte_list.ToArray (typeof (byte));
+ }
+ ;
+
+hexbytes : hexbyte
+ {
+ ArrayList byte_list = new ArrayList ();
+ byte_list.Add (Convert.ToByte ($1));
+ $$ = byte_list;
+ }
+ | hexbytes hexbyte
+ {
+ ArrayList byte_list = (ArrayList) $1;
+ byte_list.Add (Convert.ToByte ($2));
+ }
+ ;
+
+truefalse : K_TRUE
+ {
+ $$ = true;
+ }
+ | K_FALSE
+ {
+ $$ = false;
+ }
+ ;
+
+id : ID
+ | SQSTRING
+ ;
+
+comp_name : id
+ | comp_name DOT comp_name
+ {
+ $$ = (string) $1 + '.' + (string) $3;
+ }
+ | COMP_NAME
+ ;
+
+%%
+
+}
+
diff --git a/mcs/ilasm/parser/ScannerAdapter.cs b/mcs/ilasm/parser/ScannerAdapter.cs
new file mode 100644
index 00000000000..45a0cc89744
--- /dev/null
+++ b/mcs/ilasm/parser/ScannerAdapter.cs
@@ -0,0 +1,60 @@
+// ScannerAdapter.cs
+// (C) Sergey Chaban (serge@wildwestsoftware.com)
+
+using System;
+
+namespace Mono.ILASM {
+
+ /// <summary>
+ /// </summary>
+ public class ScannerAdapter : yyParser.yyInput {
+
+ private ITokenStream tokens;
+
+ /// <summary>
+ /// </summary>
+ /// <param name="tokens"></param>
+ public ScannerAdapter (ITokenStream tokens)
+ {
+ this.tokens = tokens;
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public ITokenStream BaseStream {
+ get {
+ return tokens;
+ }
+ }
+
+ //
+ // yyParser.yyInput interface
+ //
+
+ /// <summary>
+ /// </summary>
+ /// <returns></returns>
+ public bool advance ()
+ {
+ return (tokens.NextToken != ILToken.EOF);
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <returns></returns>
+ public int token ()
+ {
+ return tokens.LastToken.TokenId;
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <returns></returns>
+ public object value ()
+ {
+ return tokens.LastToken.Value;
+ }
+ }
+}
+
diff --git a/mcs/ilasm/scanner/ChangeLog b/mcs/ilasm/scanner/ChangeLog
new file mode 100644
index 00000000000..2ecfb30733a
--- /dev/null
+++ b/mcs/ilasm/scanner/ChangeLog
@@ -0,0 +1,254 @@
+2006-02-20 Ankit Jain <jankit@novell.com>
+
+ * ILTable.cs (directives): Remove .constraint
+
+2006-02-20 Ankit Jain <jankit@novell.com>
+
+ * ILTokenizingException.cs (ILTokenizingException): Derive from
+ ILAsmException.
+
+2006-01-31 Ankit Jain <jankit@novell.com>
+
+ * ILTables.cs (keywords): Enable keyword 'type' only for NET_2_0 profile.
+
+2006-01-28 Ankit Jain <jankit@novell.com>
+
+ * ILTables.cs (keywords): Fix typos in entry for 'charmaperror'.
+
+2006-01-19 Ankit Jain <jankit@novell.com>
+
+ * ILTables.cs (keywords): Add 'type' keyword.
+
+2006-01-16 Ankit Jain <jankit@novell.com>
+
+ * NumberHelper.cs (NumberHelper.Build): Try parsing numeric value as UInt64 or
+ double if Int64.Parse fails.
+
+2006-01-16 Ankit Jain <jankit@novell.com>
+
+ * ILTables.cs (keywords): Add 'bestfit', 'charmaperror', 'on' & 'off'.
+
+2006-01-16 Ankit Jain <jankit@novell.com>
+
+ * ILTables.cs (keywords): Add 'uint', this is a native UIntPtr type.
+
+2006-01-03 Ankit Jain <jankit@novell.com>
+
+ * ILTokenizer.cs (ILTokenizer.idchars): Add ` to the list.
+
+2005-12-14 Ankit Jain <jankit@novell.com>
+
+ * NumberHelper.cs (NumberHelper.Build): Set dec_found to false, if a '..' is
+ found after a number so that it is parsed as INT64 and not FLOAT64.
+ Fix #76977.
+
+2005-12-14 Ankit Jain <jankit@novell.com>
+
+ * ILTables.cs (keywords): Add uint8, uint16, uint32 and uint64 keywords.
+
+2005-11-28 Ankit Jain <jankit@novell.com>
+
+ * StringHelper.cs (idChars): Add ` to the list.
+
+2005-08-29 Ankit Jain <jankit@novell.com>
+
+ * ILTables.cs (keywords): Comment out lcid keyword. Its not recognised as a
+ keyword by ilasm (ms.net) 1.1
+
+2005-08-18 Ankit Jain <jankit@novell.com>
+
+ * ILTables.cs: Comment out publickey keyword.
+
+2005-04-27 Raja R Harinath <rharinath@novell.com>
+
+ * ILTokenizer.cs (GetNextToken): Handle 'tail.' and 'unaligned.'
+ instructions.
+
+2004-04-26 Ankit Jain <ankit@corewars.org>
+
+ * ILTokenizer.cs (ILTokenizer.GetNextToken): Advance reader to look at
+ char after a '.' .
+ (ILTokenizer.BuildId): Never end an id on a DOT.
+ Parts of the patch from Harinath & Jackson.
+
+2004-12-02 Miguel de Icaza <miguel@ximian.com>
+
+ * ILTable.cs: Add new .stackreserve token.
+
+2004-07-27 Martin Baulig <martin@ximian.com>
+
+ * ILTokenizer.cs (ILTokenizer.Location): New public property.
+
+2004-07-16 Jackson Harper <jackson@ximian.com>
+
+ * ILTokenizer.cs: Handle slashes in multiline comments
+ properly. Make the multiline comment eater loop a little more
+ readable.
+
+2004-07-06 Jackson Harper <jackson@ximian.com>
+
+ * NumberHelper.cs: Handle real numbers. Thanks to steve brown for
+ pointing this out. Also don't bother scanning the string again,
+ its allready been scanned.
+
+2004-06-10 Jackson Harper <jackson@ximian.com>
+
+ * ILTables.cs: Remove opcodes, these are contained in codegen/IntrTable.cs
+ * ILTokenizer.cs: Dont refer to ILTables::Opcodes
+
+2004-06-10 Jackson Harper <jackson@ximian.com>
+
+ * ILTokenizingExpcetion.cs: New exception thrown by the tokenizer
+ if any tokenizing errors occur.
+ * ILTokenizer.cs:
+ * NumberHelper.cs: Use the new exception.
+
+2004-06-04 Jackson Harper <jackson@ximian.com>
+
+ * ILTokenizer.cs: Handle comments first, handle whitespace in hex
+ blocks properly.
+
+2004-04-21 Jackson Harper <jackson@ximian.com>
+
+ * ILTokenizer.cs: Handle whitespace in hexbytes.
+
+2004-04-01 Jackson Harper <jackson@ximian.com>
+
+ * ILTokenizer.cs: Add flag and special parsing routine for byte
+ arrays.
+
+2003-12-10 Jackson Harper <jackson@ximian.com>
+
+ * ILTokenizer.cs: Handle dotted ids as a single token. This allows
+ keywords at the end of a dotted name.
+
+2003-10-14 Jackson Harper <jackson@ximian.com>
+
+ * ILTokenizer.cs: Fix /* */ comment blocks.
+
+2003-09-16 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILTables.cs: compilercontrolled is lowercase. I am guessing this
+ was an emacs introduced bug ;-).
+
+2003-08-10 Jackson Harper <jackson@latitudegeo.com>
+
+ * StringHelper.cs: If an escape is not valid just use the \
+ character. Fix bug where escape char was not getting set.
+
+2003-08-03 Jackson Harper <jackson@latitudegeo.com>
+
+ * NumberHelper.cs: All numbers should allways be Int64
+
+2003-07-30 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILReader.cs: Incremint colums while reading
+ * Location.cs: Display column numbers
+
+2003-07-29 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILReader.cs: Incriment line numbers
+ * Location.cs: Do not reset line number when moving to a previous
+ column. Add ToString method.
+
+2003-07-15 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILTables.cs: Add tokens for generic constraints.
+
+2003-06-14 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILTables.cs: Add imagebase keyword.
+
+2003-05-31 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILTables.cs: Add refany keyword which is just an alias for typedref.
+
+2003-05-22 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILTokenizer.cs: When building instructions allow the '.' char so
+ complex instructions like conv.ovf.u.un can be created.
+
+2003-05-22 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILTables.cs: Comment out nan and inf keywords, these are not
+ referenced in the grammar. need to check if these keywords work on
+ MS ilasm.
+ * NumberHelper.cs: Parse numbers as Unsigned then cast to long
+ otherwise an overflow exception is thrown. (is this a classlib bug?)
+
+2003-05-18 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILTokenizer.cs: If token.token does not create a keyword return
+ the first token as an id, not a keyword ie (add.exe should return
+ "ID period ID" not "ADD period ID"
+
+2003-04-28 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILTokenizer.cs: Get instructions from table and check if they
+ are null instead of checking if they exist then getting them.
+
+2003-04-03 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILToken.cs: Add open angle bracket, and close angle bracket tokens.
+
+2003-03-31 Jackson Harper <jackson@latitudegeo.com>
+
+ * NumberHelper.cs: handle situations like this 21452. properly
+
+2003-03-31 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILTokenizer.cs: Handle Ellipsis
+ * NUmberHelper.cs: Handle situations like this 0... properly
+
+2003-03-31 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILTokenizer.cs: Take some special cases into account.
+
+2003-03-31 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILTables.cs: Remove 'ptr' I can't find documentation for this
+ keyword and ildasm does not esacpe it.
+
+2003-03-31 Jackson Harper <jackson@latitudegeo.com>
+
+ * NumberHelper.cs: handle sci, hex, and byte
+ do not handle all corner case
+ will optimize soon
+
+2003-03-30 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILReader.cs: Instead of mainting a buffer let the reader handle
+ that, and use a stack for putting chars back. This is probably
+ much slower and not nearly as cool but the old method was a little
+ buggy and I was having trouble tracking things down. This can be
+ optimized someday.
+
+2003-03-19 Jackson Harper <jackson@latitudegeo.com>
+
+ * NumberHelper.cs: Handle strange number situations like 8:99:0
+
+2003-03-16 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILTokenizer.cs: Append tail to values so opcodes like ldarg.s
+ are resolved properly
+
+2003-03-16 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILTokenizer.cs: Fire an event when a new token is ready.
+
+2003-03-14 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILTokenizer.cs: Use the IsInstr method for checking if a string is an instruction
+
+2003-03-13 Jackson Harper <jackson@latitudegeo.com>
+
+ * ILTokenizer.cs: Use InstrTable for looking up and getting Opcodes
+
+2003-02-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * IlToken.cs: Add Dash Token (this is used for assembly names)
+ * ILTokenizer.cs: Return Dash token
+
+2003-02-02 Jackson Harper <jackson@latitudegeo.com>
+
+ * ChangeLog: Add ChangeLog
diff --git a/mcs/ilasm/scanner/ILReader.cs b/mcs/ilasm/scanner/ILReader.cs
new file mode 100644
index 00000000000..72de8861b43
--- /dev/null
+++ b/mcs/ilasm/scanner/ILReader.cs
@@ -0,0 +1,166 @@
+// ILReader.cs
+// Author: Sergey Chaban (serge@wildwestsoftware.com)
+
+using System;
+using System.IO;
+using System.Text;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+
+ /// <summary>
+ /// </summary>
+ public class ILReader {
+
+ private StreamReader reader;
+ private Stack putback_stack;
+ private Location location;
+ private Location markedLocation;
+
+ public ILReader (StreamReader reader)
+ {
+ this.reader = reader;
+ putback_stack = new Stack ();
+
+ location = new Location ();
+ markedLocation = Location.Unknown;
+ }
+
+
+
+ /// <summary>
+ /// </summary>
+ public Location Location {
+ get {
+ return location;
+ }
+ }
+
+
+ /// <summary>
+ /// Provides access to underlying StreamReader.
+ /// </summary>
+ public StreamReader BaseReader {
+ get {
+ return reader;
+ }
+ }
+
+ private int DoRead ()
+ {
+ if (putback_stack.Count > 0)
+ return (char) putback_stack.Pop ();
+
+ return reader.Read ();
+ }
+
+ private int DoPeek ()
+ {
+ if (putback_stack.Count > 0)
+ return (char) putback_stack.Peek ();
+
+ return reader.Peek ();
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <returns></returns>
+ public int Read ()
+ {
+ int read = DoRead ();
+ if (read == '\n')
+ location.NewLine ();
+ else
+ location.NextColumn ();
+ return read;
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <returns></returns>
+ public int Peek ()
+ {
+ return DoPeek ();
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public void Unread (char c)
+ {
+ putback_stack.Push (c);
+
+ if ('\n' == c)
+ location.PreviousLine ();
+
+ location.PreviousColumn ();
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="chars"></param>
+ public void Unread (char [] chars)
+ {
+ for (int i=chars.Length-1; i>=0; i--)
+ Unread (chars[i]);
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <param name="c"></param>
+ public void Unread (int c)
+ {
+ Unread ((char)c);
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public void SkipWhitespace ()
+ {
+ int ch = Read ();
+ for (; ch != -1 && Char.IsWhiteSpace((char) ch); ch = Read ());
+ if (ch != -1) Unread (ch);
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <returns></returns>
+ public string ReadToWhitespace ()
+ {
+ StringBuilder sb = new StringBuilder ();
+ int ch = Read ();
+ for (; ch != -1 && !Char.IsWhiteSpace((char) ch); sb.Append ((char) ch), ch = Read ());
+ if (ch != -1) Unread (ch);
+ return sb.ToString ();
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public void MarkLocation ()
+ {
+ if (markedLocation == Location.Unknown) {
+ markedLocation = new Location (location);
+ } else {
+ markedLocation.CopyFrom (location);
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public void RestoreLocation ()
+ {
+ if (markedLocation != Location.Unknown) {
+ location.CopyFrom (markedLocation);
+ }
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/scanner/ILSyntaxError.cs b/mcs/ilasm/scanner/ILSyntaxError.cs
new file mode 100644
index 00000000000..96457463833
--- /dev/null
+++ b/mcs/ilasm/scanner/ILSyntaxError.cs
@@ -0,0 +1,26 @@
+// ILSyntaxError.cs
+// Author: Sergey Chaban (serge@wildwestsoftware.com)
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class ILSyntaxError : Exception {
+ private Location loc = Location.Unknown;
+
+ public ILSyntaxError () : base ()
+ {
+ }
+
+ public ILSyntaxError (string msg) : base (msg)
+ {
+ }
+
+
+ public ILSyntaxError (string msg, Location loc) : base (msg)
+ {
+ this.loc = loc.Clone () as Location;
+ }
+ }
+}
+
diff --git a/mcs/ilasm/scanner/ILTables.cs b/mcs/ilasm/scanner/ILTables.cs
new file mode 100644
index 00000000000..602f0c38bd3
--- /dev/null
+++ b/mcs/ilasm/scanner/ILTables.cs
@@ -0,0 +1,331 @@
+// ILTables.cs
+// Mechanically generated - DO NOT EDIT!
+//
+// (C) Sergey Chaban (serge@wildwestsoftware.com)
+
+using System;
+using System.Collections;
+using System.Reflection.Emit;
+
+namespace Mono.ILASM {
+
+
+
+
+
+ public sealed class ILTables {
+
+ private static Hashtable keywords = null;
+ private static Hashtable directives = null;
+ private static readonly object mutex;
+
+
+ private ILTables ()
+ {
+ }
+
+ static ILTables ()
+ {
+ mutex = new object ();
+ }
+
+ private static void AllocTable (ref Hashtable tbl, int size)
+ {
+ lock (mutex) {
+ if (tbl == null)
+ tbl = new Hashtable (size);
+ }
+ }
+
+ public static Hashtable Directives
+ {
+ get {
+ if (directives != null) return directives;
+
+ AllocTable (ref directives, 300);
+
+ directives [".addon"] = new ILToken (Token.D_ADDON, ".addon");
+ directives [".algorithm"] = new ILToken (Token.D_ALGORITHM, ".algorithm");
+ directives [".assembly"] = new ILToken (Token.D_ASSEMBLY, ".assembly");
+ directives [".backing"] = new ILToken (Token.D_BACKING, ".backing");
+ directives [".blob"] = new ILToken (Token.D_BLOB, ".blob");
+ directives [".capability"] = new ILToken (Token.D_CAPABILITY, ".capability");
+ directives [".cctor"] = new ILToken (Token.D_CCTOR, ".cctor");
+ directives [".class"] = new ILToken (Token.D_CLASS, ".class");
+ directives [".comtype"] = new ILToken (Token.D_COMTYPE, ".comtype");
+ directives [".config"] = new ILToken (Token.D_CONFIG, ".config");
+ directives [".imagebase"] = new ILToken (Token.D_IMAGEBASE, ".imagebase");
+ directives [".corflags"] = new ILToken (Token.D_CORFLAGS, ".corflags");
+ directives [".ctor"] = new ILToken (Token.D_CTOR, ".ctor");
+ directives [".custom"] = new ILToken (Token.D_CUSTOM, ".custom");
+ directives [".data"] = new ILToken (Token.D_DATA, ".data");
+ directives [".emitbyte"] = new ILToken (Token.D_EMITBYTE, ".emitbyte");
+ directives [".entrypoint"] = new ILToken (Token.D_ENTRYPOINT, ".entrypoint");
+ directives [".event"] = new ILToken (Token.D_EVENT, ".event");
+ directives [".exeloc"] = new ILToken (Token.D_EXELOC, ".exeloc");
+ directives [".export"] = new ILToken (Token.D_EXPORT, ".export");
+ directives [".field"] = new ILToken (Token.D_FIELD, ".field");
+ directives [".file"] = new ILToken (Token.D_FILE, ".file");
+ directives [".fire"] = new ILToken (Token.D_FIRE, ".fire");
+ directives [".get"] = new ILToken (Token.D_GET, ".get");
+ directives [".hash"] = new ILToken (Token.D_HASH, ".hash");
+ directives [".implicitcom"] = new ILToken (Token.D_IMPLICITCOM, ".implicitcom");
+ directives [".language"] = new ILToken (Token.D_LANGUAGE, ".language");
+ directives [".line"] = new ILToken (Token.D_LINE, ".line");
+ directives ["#line"] = new ILToken (Token.D_XLINE, "#line");
+ directives [".locale"] = new ILToken (Token.D_LOCALE, ".locale");
+ directives [".locals"] = new ILToken (Token.D_LOCALS, ".locals");
+ directives [".manifestres"] = new ILToken (Token.D_MANIFESTRES, ".manifestres");
+ directives [".maxstack"] = new ILToken (Token.D_MAXSTACK, ".maxstack");
+ directives [".method"] = new ILToken (Token.D_METHOD, ".method");
+ directives [".mime"] = new ILToken (Token.D_MIME, ".mime");
+ directives [".module"] = new ILToken (Token.D_MODULE, ".module");
+ directives [".mresource"] = new ILToken (Token.D_MRESOURCE, ".mresource");
+ directives [".namespace"] = new ILToken (Token.D_NAMESPACE, ".namespace");
+ directives [".originator"] = new ILToken (Token.D_ORIGINATOR, ".originator");
+ directives [".os"] = new ILToken (Token.D_OS, ".os");
+ directives [".other"] = new ILToken (Token.D_OTHER, ".other");
+ directives [".override"] = new ILToken (Token.D_OVERRIDE, ".override");
+ directives [".pack"] = new ILToken (Token.D_PACK, ".pack");
+ directives [".param"] = new ILToken (Token.D_PARAM, ".param");
+ directives [".permission"] = new ILToken (Token.D_PERMISSION, ".permission");
+ directives [".permissionset"] = new ILToken (Token.D_PERMISSIONSET, ".permissionset");
+ directives [".processor"] = new ILToken (Token.D_PROCESSOR, ".processor");
+ directives [".property"] = new ILToken (Token.D_PROPERTY, ".property");
+ directives [".publickey"] = new ILToken (Token.D_PUBLICKEY, ".publickey");
+ directives [".publickeytoken"] = new ILToken (Token.D_PUBLICKEYTOKEN, ".publickeytoken");
+ directives [".removeon"] = new ILToken (Token.D_REMOVEON, ".removeon");
+ directives [".set"] = new ILToken (Token.D_SET, ".set");
+ directives [".size"] = new ILToken (Token.D_SIZE, ".size");
+ directives [".stackreserve"] = new ILToken (Token.D_STACKRESERVE, ".stackreserve");
+ directives [".subsystem"] = new ILToken (Token.D_SUBSYSTEM, ".subsystem");
+ directives [".title"] = new ILToken (Token.D_TITLE, ".title");
+ directives [".try"] = new ILToken (Token.D_TRY, ".try");
+ directives [".ver"] = new ILToken (Token.D_VER, ".ver");
+ directives [".vtable"] = new ILToken (Token.D_VTABLE, ".vtable");
+ directives [".vtentry"] = new ILToken (Token.D_VTENTRY, ".vtentry");
+ directives [".vtfixup"] = new ILToken (Token.D_VTFIXUP, ".vtfixup");
+ directives [".zeroinit"] = new ILToken (Token.D_ZEROINIT, ".zeroinit");
+
+ return directives;
+ }
+ }
+
+
+
+ public static Hashtable Keywords
+ {
+ get {
+ if (keywords != null) return keywords;
+
+ AllocTable (ref keywords, 300);
+
+ keywords ["at"] = new ILToken (Token.K_AT, "at");
+ keywords ["as"] = new ILToken (Token.K_AS, "as");
+ keywords ["implicitcom"] = new ILToken (Token.K_IMPLICITCOM, "implicitcom");
+ keywords ["implicitres"] = new ILToken (Token.K_IMPLICITRES, "implicitres");
+ keywords ["noappdomain"] = new ILToken (Token.K_NOAPPDOMAIN, "noappdomain");
+ keywords ["noprocess"] = new ILToken (Token.K_NOPROCESS, "noprocess");
+ keywords ["nomachine"] = new ILToken (Token.K_NOMACHINE, "nomachine");
+ keywords ["extern"] = new ILToken (Token.K_EXTERN, "extern");
+ keywords ["instance"] = new ILToken (Token.K_INSTANCE, "instance");
+ keywords ["explicit"] = new ILToken (Token.K_EXPLICIT, "explicit");
+ keywords ["default"] = new ILToken (Token.K_DEFAULT, "default");
+ keywords ["vararg"] = new ILToken (Token.K_VARARG, "vararg");
+ keywords ["unmanaged"] = new ILToken (Token.K_UNMANAGED, "unmanaged");
+ keywords ["cdecl"] = new ILToken (Token.K_CDECL, "cdecl");
+ keywords ["stdcall"] = new ILToken (Token.K_STDCALL, "stdcall");
+ keywords ["thiscall"] = new ILToken (Token.K_THISCALL, "thiscall");
+ keywords ["fastcall"] = new ILToken (Token.K_FASTCALL, "fastcall");
+ keywords ["marshal"] = new ILToken (Token.K_MARSHAL, "marshal");
+ keywords ["in"] = new ILToken (Token.K_IN, "in");
+ keywords ["out"] = new ILToken (Token.K_OUT, "out");
+ keywords ["opt"] = new ILToken (Token.K_OPT, "opt");
+ // Not a keyword according to ilasm 1.1
+ // keywords ["lcid"] = new ILToken (Token.K_LCID, "lcid");
+ keywords ["retval"] = new ILToken (Token.K_RETVAL, "retval");
+ keywords ["static"] = new ILToken (Token.K_STATIC, "static");
+ keywords ["public"] = new ILToken (Token.K_PUBLIC, "public");
+ keywords ["private"] = new ILToken (Token.K_PRIVATE, "private");
+ keywords ["family"] = new ILToken (Token.K_FAMILY, "family");
+ keywords ["initonly"] = new ILToken (Token.K_INITONLY, "initonly");
+ keywords ["rtspecialname"] = new ILToken (Token.K_RTSPECIALNAME, "rtspecialname");
+ keywords ["specialname"] = new ILToken (Token.K_SPECIALNAME, "specialname");
+ keywords ["assembly"] = new ILToken (Token.K_ASSEMBLY, "assembly");
+ keywords ["famandassem"] = new ILToken (Token.K_FAMANDASSEM, "famandassem");
+ keywords ["famorassem"] = new ILToken (Token.K_FAMORASSEM, "famorassem");
+ keywords ["privatescope"] = new ILToken (Token.K_PRIVATESCOPE, "privatescope");
+ keywords ["literal"] = new ILToken (Token.K_LITERAL, "literal");
+ keywords ["notserialized"] = new ILToken (Token.K_NOTSERIALIZED, "notserialized");
+ keywords ["value"] = new ILToken (Token.K_VALUE, "value");
+ keywords ["not_in_gc_heap"] = new ILToken (Token.K_NOT_IN_GC_HEAP, "not_in_gc_heap");
+ keywords ["interface"] = new ILToken (Token.K_INTERFACE, "interface");
+ keywords ["sealed"] = new ILToken (Token.K_SEALED, "sealed");
+ keywords ["abstract"] = new ILToken (Token.K_ABSTRACT, "abstract");
+ keywords ["auto"] = new ILToken (Token.K_AUTO, "auto");
+ keywords ["sequential"] = new ILToken (Token.K_SEQUENTIAL, "sequential");
+ keywords ["ansi"] = new ILToken (Token.K_ANSI, "ansi");
+ keywords ["unicode"] = new ILToken (Token.K_UNICODE, "unicode");
+ keywords ["autochar"] = new ILToken (Token.K_AUTOCHAR, "autochar");
+ keywords ["bestfit"] = new ILToken (Token.K_BESTFIT, "bestfit");
+ keywords ["charmaperror"] = new ILToken (Token.K_CHARMAPERROR, "charmaperror");
+ keywords ["import"] = new ILToken (Token.K_IMPORT, "import");
+ keywords ["serializable"] = new ILToken (Token.K_SERIALIZABLE, "serializable");
+ keywords ["nested"] = new ILToken (Token.K_NESTED, "nested");
+ keywords ["lateinit"] = new ILToken (Token.K_LATEINIT, "lateinit");
+ keywords ["extends"] = new ILToken (Token.K_EXTENDS, "extends");
+ keywords ["implements"] = new ILToken (Token.K_IMPLEMENTS, "implements");
+ keywords ["final"] = new ILToken (Token.K_FINAL, "final");
+ keywords ["virtual"] = new ILToken (Token.K_VIRTUAL, "virtual");
+ keywords ["hidebysig"] = new ILToken (Token.K_HIDEBYSIG, "hidebysig");
+ keywords ["newslot"] = new ILToken (Token.K_NEWSLOT, "newslot");
+ keywords ["unmanagedexp"] = new ILToken (Token.K_UNMANAGEDEXP, "unmanagedexp");
+ keywords ["pinvokeimpl"] = new ILToken (Token.K_PINVOKEIMPL, "pinvokeimpl");
+ keywords ["nomangle"] = new ILToken (Token.K_NOMANGLE, "nomangle");
+ keywords ["ole"] = new ILToken (Token.K_OLE, "ole");
+ keywords ["lasterr"] = new ILToken (Token.K_LASTERR, "lasterr");
+ keywords ["winapi"] = new ILToken (Token.K_WINAPI, "winapi");
+ keywords ["native"] = new ILToken (Token.K_NATIVE, "native");
+ keywords ["il"] = new ILToken (Token.K_IL, "il");
+ keywords ["cil"] = new ILToken (Token.K_CIL, "cil");
+ keywords ["optil"] = new ILToken (Token.K_OPTIL, "optil");
+ keywords ["managed"] = new ILToken (Token.K_MANAGED, "managed");
+ keywords ["forwardref"] = new ILToken (Token.K_FORWARDREF, "forwardref");
+ keywords ["runtime"] = new ILToken (Token.K_RUNTIME, "runtime");
+ keywords ["internalcall"] = new ILToken (Token.K_INTERNALCALL, "internalcall");
+ keywords ["synchronized"] = new ILToken (Token.K_SYNCHRONIZED, "synchronized");
+ keywords ["noinlining"] = new ILToken (Token.K_NOINLINING, "noinlining");
+ keywords ["custom"] = new ILToken (Token.K_CUSTOM, "custom");
+ keywords ["fixed"] = new ILToken (Token.K_FIXED, "fixed");
+ keywords ["sysstring"] = new ILToken (Token.K_SYSSTRING, "sysstring");
+ keywords ["array"] = new ILToken (Token.K_ARRAY, "array");
+ keywords ["variant"] = new ILToken (Token.K_VARIANT, "variant");
+ keywords ["currency"] = new ILToken (Token.K_CURRENCY, "currency");
+ keywords ["syschar"] = new ILToken (Token.K_SYSCHAR, "syschar");
+ keywords ["void"] = new ILToken (Token.K_VOID, "void");
+ keywords ["bool"] = new ILToken (Token.K_BOOL, "bool");
+ keywords ["int8"] = new ILToken (Token.K_INT8, "int8");
+ keywords ["int16"] = new ILToken (Token.K_INT16, "int16");
+ keywords ["int32"] = new ILToken (Token.K_INT32, "int32");
+ keywords ["int64"] = new ILToken (Token.K_INT64, "int64");
+ keywords ["float32"] = new ILToken (Token.K_FLOAT32, "float32");
+ keywords ["float64"] = new ILToken (Token.K_FLOAT64, "float64");
+ keywords ["error"] = new ILToken (Token.K_ERROR, "error");
+ keywords ["unsigned"] = new ILToken (Token.K_UNSIGNED, "unsigned");
+ keywords ["uint"] = new ILToken (Token.K_UINT, "uint");
+ keywords ["uint8"] = new ILToken (Token.K_UINT8, "uint8");
+ keywords ["uint16"] = new ILToken (Token.K_UINT16, "uint16");
+ keywords ["uint32"] = new ILToken (Token.K_UINT32, "uint32");
+ keywords ["uint64"] = new ILToken (Token.K_UINT64, "uint64");
+ keywords ["decimal"] = new ILToken (Token.K_DECIMAL, "decimal");
+ keywords ["date"] = new ILToken (Token.K_DATE, "date");
+ keywords ["bstr"] = new ILToken (Token.K_BSTR, "bstr");
+ keywords ["lpstr"] = new ILToken (Token.K_LPSTR, "lpstr");
+ keywords ["lpwstr"] = new ILToken (Token.K_LPWSTR, "lpwstr");
+ keywords ["lptstr"] = new ILToken (Token.K_LPTSTR, "lptstr");
+ keywords ["objectref"] = new ILToken (Token.K_OBJECTREF, "objectref");
+ keywords ["iunknown"] = new ILToken (Token.K_IUNKNOWN, "iunknown");
+ keywords ["idispatch"] = new ILToken (Token.K_IDISPATCH, "idispatch");
+ keywords ["struct"] = new ILToken (Token.K_STRUCT, "struct");
+ keywords ["safearray"] = new ILToken (Token.K_SAFEARRAY, "safearray");
+ keywords ["int"] = new ILToken (Token.K_INT, "int");
+ keywords ["byvalstr"] = new ILToken (Token.K_BYVALSTR, "byvalstr");
+ keywords ["tbstr"] = new ILToken (Token.K_TBSTR, "tbstr");
+ keywords ["lpvoid"] = new ILToken (Token.K_LPVOID, "lpvoid");
+ keywords ["any"] = new ILToken (Token.K_ANY, "any");
+ keywords ["float"] = new ILToken (Token.K_FLOAT, "float");
+ keywords ["lpstruct"] = new ILToken (Token.K_LPSTRUCT, "lpstruct");
+ keywords ["null"] = new ILToken (Token.K_NULL, "null");
+ // keywords ["ptr"] = new ILToken (Token.K_PTR, "ptr");
+ keywords ["vector"] = new ILToken (Token.K_VECTOR, "vector");
+ keywords ["hresult"] = new ILToken (Token.K_HRESULT, "hresult");
+ keywords ["carray"] = new ILToken (Token.K_CARRAY, "carray");
+ keywords ["userdefined"] = new ILToken (Token.K_USERDEFINED, "userdefined");
+ keywords ["record"] = new ILToken (Token.K_RECORD, "record");
+ keywords ["filetime"] = new ILToken (Token.K_FILETIME, "filetime");
+ keywords ["blob"] = new ILToken (Token.K_BLOB, "blob");
+ keywords ["stream"] = new ILToken (Token.K_STREAM, "stream");
+ keywords ["storage"] = new ILToken (Token.K_STORAGE, "storage");
+ keywords ["streamed_object"] = new ILToken (Token.K_STREAMED_OBJECT, "streamed_object");
+ keywords ["stored_object"] = new ILToken (Token.K_STORED_OBJECT, "stored_object");
+ keywords ["blob_object"] = new ILToken (Token.K_BLOB_OBJECT, "blob_object");
+ keywords ["cf"] = new ILToken (Token.K_CF, "cf");
+ keywords ["clsid"] = new ILToken (Token.K_CLSID, "clsid");
+ keywords ["method"] = new ILToken (Token.K_METHOD, "method");
+ keywords ["class"] = new ILToken (Token.K_CLASS, "class");
+ keywords ["pinned"] = new ILToken (Token.K_PINNED, "pinned");
+ keywords ["modreq"] = new ILToken (Token.K_MODREQ, "modreq");
+ keywords ["modopt"] = new ILToken (Token.K_MODOPT, "modopt");
+ keywords ["typedref"] = new ILToken (Token.K_TYPEDREF, "typedref");
+#if NET_2_0 || BOOTSTRAP_NET_2_0
+ keywords ["type"] = new ILToken (Token.K_TYPE, "type");
+#endif
+ keywords ["refany"] = new ILToken (Token.K_TYPEDREF, "typedref");
+ keywords ["wchar"] = new ILToken (Token.K_WCHAR, "wchar");
+ keywords ["char"] = new ILToken (Token.K_CHAR, "char");
+ keywords ["fromunmanaged"] = new ILToken (Token.K_FROMUNMANAGED, "fromunmanaged");
+ keywords ["callmostderived"] = new ILToken (Token.K_CALLMOSTDERIVED, "callmostderived");
+ keywords ["bytearray"] = new ILToken (Token.K_BYTEARRAY, "bytearray");
+ keywords ["with"] = new ILToken (Token.K_WITH, "with");
+ keywords ["init"] = new ILToken (Token.K_INIT, "init");
+ keywords ["to"] = new ILToken (Token.K_TO, "to");
+ keywords ["catch"] = new ILToken (Token.K_CATCH, "catch");
+ keywords ["filter"] = new ILToken (Token.K_FILTER, "filter");
+ keywords ["finally"] = new ILToken (Token.K_FINALLY, "finally");
+ keywords ["fault"] = new ILToken (Token.K_FAULT, "fault");
+ keywords ["handler"] = new ILToken (Token.K_HANDLER, "handler");
+ keywords ["tls"] = new ILToken (Token.K_TLS, "tls");
+ keywords ["field"] = new ILToken (Token.K_FIELD, "field");
+ keywords ["request"] = new ILToken (Token.K_REQUEST, "request");
+ keywords ["demand"] = new ILToken (Token.K_DEMAND, "demand");
+ keywords ["assert"] = new ILToken (Token.K_ASSERT, "assert");
+ keywords ["deny"] = new ILToken (Token.K_DENY, "deny");
+ keywords ["permitonly"] = new ILToken (Token.K_PERMITONLY, "permitonly");
+ keywords ["linkcheck"] = new ILToken (Token.K_LINKCHECK, "linkcheck");
+ keywords ["inheritcheck"] = new ILToken (Token.K_INHERITCHECK, "inheritcheck");
+ keywords ["reqmin"] = new ILToken (Token.K_REQMIN, "reqmin");
+ keywords ["reqopt"] = new ILToken (Token.K_REQOPT, "reqopt");
+ keywords ["reqrefuse"] = new ILToken (Token.K_REQREFUSE, "reqrefuse");
+ keywords ["prejitgrant"] = new ILToken (Token.K_PREJITGRANT, "prejitgrant");
+ keywords ["prejitdeny"] = new ILToken (Token.K_PREJITDENY, "prejitdeny");
+ keywords ["noncasdemand"] = new ILToken (Token.K_NONCASDEMAND, "noncasdemand");
+ keywords ["noncaslinkdemand"] = new ILToken (Token.K_NONCASLINKDEMAND, "noncaslinkdemand");
+ keywords ["noncasinheritance"] = new ILToken (Token.K_NONCASINHERITANCE, "noncasinheritance");
+ keywords ["readonly"] = new ILToken (Token.K_READONLY, "readonly");
+ keywords ["nometadata"] = new ILToken (Token.K_NOMETADATA, "nometadata");
+ keywords ["algorithm"] = new ILToken (Token.K_ALGORITHM, "algorithm");
+ keywords ["fullorigin"] = new ILToken (Token.K_FULLORIGIN, "fullorigin");
+ // keywords ["nan"] = new ILToken (Token.K_NAN, "nan");
+ // keywords ["inf"] = new ILToken (Token.K_INF, "inf");
+ // keywords ["publickey"] = new ILToken (Token.K_PUBLICKEY, "publickey");
+ keywords ["enablejittracking"] = new ILToken (Token.K_ENABLEJITTRACKING, "enablejittracking");
+ keywords ["disablejitoptimizer"] = new ILToken (Token.K_DISABLEJITOPTIMIZER, "disablejitoptimizer");
+ keywords ["preservesig"] = new ILToken (Token.K_PRESERVESIG, "preservesig");
+ keywords ["beforefieldinit"] = new ILToken (Token.K_BEFOREFIELDINIT, "beforefieldinit");
+ keywords ["alignment"] = new ILToken (Token.K_ALIGNMENT, "alignment");
+ keywords ["nullref"] = new ILToken (Token.K_NULLREF, "nullref");
+ keywords ["valuetype"] = new ILToken (Token.K_VALUETYPE, "valuetype");
+ keywords ["compilercontrolled"] = new ILToken (Token.K_COMPILERCONTROLLED, "compilercontrolled");
+ keywords ["reqsecobj"] = new ILToken (Token.K_REQSECOBJ, "reqsecobj");
+ keywords ["enum"] = new ILToken (Token.K_ENUM, "enum");
+ keywords ["object"] = new ILToken (Token.K_OBJECT, "object");
+ keywords ["string"] = new ILToken (Token.K_STRING, "string");
+ keywords ["true"] = new ILToken (Token.K_TRUE, "true");
+ keywords ["false"] = new ILToken (Token.K_FALSE, "false");
+ keywords ["is"] = new ILToken (Token.K_IS, "is");
+ keywords ["on"] = new ILToken (Token.K_ON, "on");
+ keywords ["off"] = new ILToken (Token.K_OFF, "off");
+
+ return keywords;
+ }
+ }
+
+
+
+
+ } // class ILTables
+
+
+
+
+} // namespace Mono.ILASM
diff --git a/mcs/ilasm/scanner/ILToken.cs b/mcs/ilasm/scanner/ILToken.cs
new file mode 100644
index 00000000000..78cabb6cd07
--- /dev/null
+++ b/mcs/ilasm/scanner/ILToken.cs
@@ -0,0 +1,241 @@
+// ILToken.cs
+// Author: Sergey Chaban (serge@wildwestsoftware.com)
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class ILToken : ICloneable {
+ internal int token;
+ internal object val;
+
+ public static readonly ILToken Invalid;
+ public static readonly ILToken EOF;
+
+ public static readonly ILToken Dot;
+
+ public static readonly ILToken OpenBrace;
+ public static readonly ILToken CloseBrace;
+ public static readonly ILToken OpenBracket;
+ public static readonly ILToken CloseBracket;
+ public static readonly ILToken OpenParens;
+ public static readonly ILToken CloseParens;
+ public static readonly ILToken Comma;
+ public static readonly ILToken Colon;
+ public static readonly ILToken DoubleColon;
+ public static readonly ILToken Semicolon;
+ public static readonly ILToken Assign;
+ public static readonly ILToken Star;
+ public static readonly ILToken Ampersand;
+ public static readonly ILToken Plus;
+ public static readonly ILToken Slash;
+ public static readonly ILToken Bang;
+ public static readonly ILToken Ellipsis;
+ public static readonly ILToken Dash;
+ public static readonly ILToken OpenAngleBracket;
+ public static readonly ILToken CloseAngleBracket;
+
+ private static readonly ILToken [] punctuations;
+
+ /// <summary>
+ /// </summary>
+ static ILToken ()
+ {
+ Invalid = new ILToken (-1, "invalid");
+ EOF = new ILToken (Token.EOF, "eof");
+
+ Dot = new ILToken (Token.DOT, ".");
+ OpenBrace = new ILToken (Token.OPEN_BRACE, "{");
+ CloseBrace = new ILToken (Token.CLOSE_BRACE, "}");
+ OpenBracket = new ILToken (Token.OPEN_BRACKET, "[");
+ CloseBracket = new ILToken (Token.CLOSE_BRACKET, "]");
+ OpenParens = new ILToken (Token.OPEN_PARENS, "(");
+ CloseParens = new ILToken (Token.CLOSE_PARENS, ")");
+ Comma = new ILToken (Token.COMMA, ",");
+ Colon = new ILToken (Token.COLON, ":");
+ DoubleColon = new ILToken (Token.DOUBLE_COLON, "::");
+ Semicolon = new ILToken (Token.SEMICOLON, ";");
+ Assign = new ILToken (Token.ASSIGN, "=");
+ Star = new ILToken (Token.STAR, "*");
+ Ampersand = new ILToken (Token.AMPERSAND, "&");
+ Plus = new ILToken (Token.PLUS, "+");
+ Slash = new ILToken (Token.SLASH, "/");
+ Bang = new ILToken (Token.BANG, "!");
+ Ellipsis = new ILToken (Token.ELLIPSIS, "...");
+ Dash = new ILToken (Token.DASH, "-");
+ OpenAngleBracket = new ILToken (Token.OPEN_ANGLE_BRACKET, "<");
+ CloseAngleBracket = new ILToken (Token.CLOSE_ANGLE_BRACKET, ">");
+
+ punctuations = new ILToken [] {
+ OpenBrace, CloseBrace,
+ OpenBracket, CloseBracket,
+ OpenParens, CloseParens,
+ Comma, Colon, Semicolon,
+ Assign, Star, Ampersand,
+ Plus, Slash, Bang,
+ OpenAngleBracket, CloseAngleBracket
+ };
+ }
+
+ /// <summary>
+ /// </summary>
+ public ILToken ()
+ {
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <param name="token"></param>
+ /// <param name="val"></param>
+ public ILToken (int token, object val)
+ {
+ this.token = token;
+ this.val = val;
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="that"></param>
+ public ILToken (ILToken that)
+ {
+ this.token = that.token;
+ this.val = that.val;
+ }
+
+
+
+ /// <summary>
+ /// </summary>
+ public int TokenId {
+ get {
+ return token;
+ }
+ }
+
+ /// <summary>
+ /// </summary>
+ public object Value {
+ get {
+ return val;
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="that"></param>
+ public virtual void CopyFrom (ILToken that)
+ {
+ this.token = that.token;
+ this.val = that.val;
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <returns></returns>
+ public virtual object Clone ()
+ {
+ return new ILToken (this);
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <returns></returns>
+ public override int GetHashCode ()
+ {
+ int h = token;
+ if (val != null) h ^= val.GetHashCode ();
+ return h;
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <returns></returns>
+ public override string ToString ()
+ {
+ return (token.ToString() + " : " + (val != null ? val.ToString () : "<null>"));
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="o"></param>
+ /// <returns></returns>
+ public override bool Equals (object o)
+ {
+ bool res = (o != null);
+
+ if (res) {
+ res = Object.ReferenceEquals (this, o);
+ if (!res) {
+ res = o is ILToken;
+ if (res) {
+ ILToken that = o as ILToken;
+ res = (this.token == that.token) && (this.val.Equals (that.val));
+ }
+ }
+ }
+
+ return res;
+ }
+
+
+ private static bool EqImpl (ILToken t1, ILToken t2)
+ {
+ bool res = false;
+ if ((t1 as object) != null) {
+ res = t1.Equals (t2);
+ } else {
+ res = ((t2 as object) == null);
+ }
+
+ return res;
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="t1"></param>
+ /// <param name="t2"></param>
+ /// <returns></returns>
+ public static bool operator == (ILToken t1, ILToken t2)
+ {
+ return EqImpl (t1, t2);
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <param name="t1"></param>
+ /// <param name="t2"></param>
+ /// <returns></returns>
+ public static bool operator != (ILToken t1, ILToken t2)
+ {
+ return !EqImpl (t1, t2);
+ }
+
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="ch"></param>
+ /// <returns></returns>
+ public static ILToken GetPunctuation (int ch)
+ {
+ int id = "{}[](),:;=*&+/!<>".IndexOf ((char) ch);
+ ILToken res = null;
+
+ if (id != -1) {
+ res = punctuations [id];
+ }
+
+ return res;
+ }
+
+
+ }
+}
diff --git a/mcs/ilasm/scanner/ILTokenizer.cs b/mcs/ilasm/scanner/ILTokenizer.cs
new file mode 100644
index 00000000000..0d2730d6cee
--- /dev/null
+++ b/mcs/ilasm/scanner/ILTokenizer.cs
@@ -0,0 +1,371 @@
+// ILTokenizer.cs
+// Author: Sergey Chaban (serge@wildwestsoftware.com)
+
+using System;
+using System.IO;
+using System.Text;
+using System.Collections;
+using System.Globalization;
+
+namespace Mono.ILASM {
+
+ public delegate void NewTokenEvent (object sender, NewTokenEventArgs args);
+
+ public class NewTokenEventArgs : EventArgs {
+
+ public readonly ILToken Token;
+
+ public NewTokenEventArgs (ILToken token)
+ {
+ Token = token;
+ }
+ }
+
+ /// <summary>
+ /// </summary>
+ public class ILTokenizer : ITokenStream {
+
+ private static readonly string idchars = "_$@?.`";
+
+ private static Hashtable keywords;
+ private static Hashtable directives;
+
+ private ILToken lastToken;
+ private ILReader reader;
+ private StringHelper strBuilder;
+ private NumberHelper numBuilder;
+ private bool in_byte_array;
+
+ public event NewTokenEvent NewTokenEvent;
+
+ static ILTokenizer()
+ {
+ keywords = ILTables.Keywords;
+ directives = ILTables.Directives;
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <param name="reader"></param>
+ public ILTokenizer (StreamReader reader)
+ {
+ this.reader = new ILReader (reader);
+ strBuilder = new StringHelper (this);
+ numBuilder = new NumberHelper (this);
+ lastToken = ILToken.Invalid.Clone () as ILToken;
+ }
+
+ public ILReader Reader {
+ get {
+ return reader;
+ }
+ }
+
+ public Location Location {
+ get {
+ return reader.Location;
+ }
+ }
+
+ public bool InByteArray {
+ get { return in_byte_array; }
+ set { in_byte_array = value; }
+ }
+
+ public ILToken GetNextToken ()
+ {
+ if (lastToken == ILToken.EOF) return ILToken.EOF;
+
+ int ch;
+ int next;
+ ILToken res = ILToken.EOF.Clone () as ILToken;
+
+
+ while ((ch = reader.Read ()) != -1) {
+
+ // Comments
+ if (ch == '/') {
+ next = reader.Peek ();
+ if (next == '/') {
+ // double-slash comment, skip to the end of the line.
+ for (reader.Read ();
+ next != -1 && next != '\n';
+ next = reader.Read ());
+ continue;
+ } else if (next == '*') {
+ reader.Read ();
+ for (next = reader.Read (); next != -1; next = reader.Read ()) {
+ if (next == '*' && reader.Peek () == '/') {
+ reader.Read ();
+ goto end;
+ }
+ }
+ end:
+ continue;
+ }
+ }
+
+ // HEXBYTES are flagged by the parser otherwise it is
+ // impossible to figure them out
+ if (in_byte_array) {
+ string hx = String.Empty;
+
+ if (Char.IsWhiteSpace ((char) ch))
+ continue;
+
+ if (ch == ')') {
+ res = ILToken.CloseParens;
+ break;
+ }
+
+ if (!is_hex (ch))
+ throw new ILTokenizingException (reader.Location, ((char) ch).ToString ());
+ hx += (char) ch;
+ if (is_hex (reader.Peek ()))
+ hx += (char) reader.Read ();
+ else if (!Char.IsWhiteSpace ((char) reader.Peek ()) && reader.Peek () != ')')
+ throw new ILTokenizingException (reader.Location,
+ ((char) reader.Peek ()).ToString ());
+ res.token = Token.HEXBYTE;
+ res.val = Byte.Parse (hx, NumberStyles.HexNumber);
+
+ while (Char.IsWhiteSpace ((char) reader.Peek ()))
+ reader.Read ();
+ break;
+ }
+
+ // Ellipsis
+ if (ch == '.' && reader.Peek () == '.') {
+ reader.MarkLocation ();
+ int ch2 = reader.Read ();
+ if (reader.Peek () == '.') {
+ res = ILToken.Ellipsis;
+ reader.Read ();
+ break;
+ }
+ reader.Unread (ch2);
+ reader.RestoreLocation ();
+ }
+
+ if (ch == '.' || ch == '#') {
+ next = reader.Peek ();
+ if (ch == '.' && Char.IsDigit((char) next)) {
+ numBuilder.Start (ch);
+ reader.Unread (ch);
+ numBuilder.Build ();
+ if (numBuilder.ResultToken != ILToken.Invalid) {
+ res.CopyFrom (numBuilder.ResultToken);
+ break;
+ }
+ } else {
+ if (strBuilder.Start (next) && strBuilder.TokenId == Token.ID) {
+ reader.MarkLocation ();
+ string dirBody = strBuilder.Build ();
+ string dir = new string ((char) ch, 1) + dirBody;
+ if (IsDirective (dir)) {
+ res = ILTables.Directives [dir] as ILToken;
+ } else {
+ reader.Unread (dirBody.ToCharArray ());
+ reader.RestoreLocation ();
+ res = ILToken.Dot;
+ }
+ } else {
+ res = ILToken.Dot;
+ }
+ break;
+ }
+ }
+
+ // Numbers && Hexbytes
+ if (numBuilder.Start (ch)) {
+ if ((ch == '-') && !(Char.IsDigit ((char) reader.Peek ()))) {
+ res = ILToken.Dash;
+ break;
+ } else {
+ reader.Unread (ch);
+ numBuilder.Build ();
+ if (numBuilder.ResultToken != ILToken.Invalid) {
+ res.CopyFrom (numBuilder.ResultToken);
+ break;
+ }
+ }
+ }
+
+ // Punctuation
+ ILToken punct = ILToken.GetPunctuation (ch);
+ if (punct != null) {
+ if (punct == ILToken.Colon && reader.Peek () == ':') {
+ reader.Read ();
+ res = ILToken.DoubleColon;
+ } else {
+ res = punct;
+ }
+ break;
+ }
+
+ // ID | QSTRING | SQSTRING | INSTR_* | KEYWORD
+ if (strBuilder.Start (ch)) {
+ reader.Unread (ch);
+ string val = strBuilder.Build ();
+ if (strBuilder.TokenId == Token.ID) {
+ ILToken opcode;
+ next = reader.Peek ();
+ if (next == '.') {
+ reader.MarkLocation ();
+ reader.Read ();
+ next = reader.Peek ();
+ if (IsIdChar ((char) next)) {
+ string opTail = BuildId ();
+ string full_str = String.Format ("{0}.{1}", val, opTail);
+ opcode = InstrTable.GetToken (full_str);
+
+ if (opcode == null) {
+ if (strBuilder.TokenId != Token.ID) {
+ reader.Unread (opTail.ToCharArray ());
+ reader.Unread ('.');
+ reader.RestoreLocation ();
+ res.val = val;
+ } else {
+ res.token = Token.COMP_NAME;
+ res.val = full_str;
+ }
+ break;
+ } else {
+ res = opcode;
+ break;
+ }
+
+ } else if (Char.IsWhiteSpace ((char) next)) {
+ // Handle 'tail.' and 'unaligned.'
+ opcode = InstrTable.GetToken (val + ".");
+ if (opcode != null) {
+ res = opcode;
+ break;
+ }
+ // Let the parser handle the dot
+ reader.Unread ('.');
+ }
+ }
+ opcode = InstrTable.GetToken (val);
+ if (opcode != null) {
+ res = opcode;
+ break;
+ }
+ if (IsKeyword (val)) {
+ res = ILTables.Keywords [val] as ILToken;
+ break;
+ }
+ }
+
+ res.token = strBuilder.TokenId;
+ res.val = val;
+ break;
+ }
+ }
+
+ OnNewToken (res);
+ lastToken.CopyFrom (res);
+ return res;
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public ILToken NextToken {
+ get {
+ return GetNextToken ();
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public ILToken LastToken {
+ get {
+ return lastToken;
+ }
+ }
+
+ bool is_hex (int e)
+ {
+ return (e >= '0' && e <= '9') || (e >= 'A' && e <= 'F') || (e >= 'a' && e <= 'f');
+ }
+
+ private static bool IsIdStartChar (char ch)
+ {
+ return (Char.IsLetter (ch) || (idchars.IndexOf (ch) != -1));
+ }
+
+
+ private static bool IsIdChar (char ch)
+ {
+ return (Char.IsLetterOrDigit (ch) || (idchars.IndexOf (ch) != -1));
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <param name="name"></param>
+ /// <returns></returns>
+ public static bool IsOpcode (string name)
+ {
+ return InstrTable.IsInstr (name);
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="name"></param>
+ /// <returns></returns>
+ public static bool IsDirective (string name)
+ {
+ char ch = name [0];
+ bool res = (ch == '.' || ch == '#');
+
+ if (res) {
+ res = directives.Contains (name);
+ }
+
+ return res;
+ }
+
+ private string BuildId ()
+ {
+ StringBuilder idsb = new StringBuilder ();
+ int ch, last;
+
+ last = -1;
+ while ((ch = reader.Read ()) != -1) {
+ if (IsIdChar ((char) ch) || ch == '.') {
+ idsb.Append ((char) ch);
+ } else {
+ reader.Unread (ch);
+ // Never end an id on a DOT
+ if (last == '.') {
+ reader.Unread (last);
+ idsb.Length -= 1;
+ }
+ break;
+ }
+ last = ch;
+ }
+
+ return idsb.ToString ();
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <param name="name"></param>
+ /// <returns></returns>
+ public static bool IsKeyword (string name)
+ {
+ return keywords.Contains (name);
+ }
+
+ private void OnNewToken (ILToken token)
+ {
+ if (NewTokenEvent != null)
+ NewTokenEvent (this, new NewTokenEventArgs (token));
+ }
+
+ }
+}
diff --git a/mcs/ilasm/scanner/ILTokenizingException.cs b/mcs/ilasm/scanner/ILTokenizingException.cs
new file mode 100644
index 00000000000..64d2dcb480e
--- /dev/null
+++ b/mcs/ilasm/scanner/ILTokenizingException.cs
@@ -0,0 +1,30 @@
+//
+// Mono.ILASM.ILTokenizingException
+//
+// Author(s):
+// Jackson Harper (jackson@ximian.com)
+//
+// Copyright 2004 Novell, Inc (http://www.novell.com)
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class ILTokenizingException : ILAsmException {
+
+ public readonly Location Location;
+ public readonly string Token;
+
+ public ILTokenizingException (Location location, string token)
+ : base (location, token)
+ {
+ Location = location;
+ Token = token;
+ }
+ }
+
+}
+
+
diff --git a/mcs/ilasm/scanner/ITokenStream.cs b/mcs/ilasm/scanner/ITokenStream.cs
new file mode 100644
index 00000000000..c10232c8695
--- /dev/null
+++ b/mcs/ilasm/scanner/ITokenStream.cs
@@ -0,0 +1,13 @@
+// ITokenStream.cs
+// (C) Sergey Chaban (serge@wildwestsoftware.com)
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+ public interface ITokenStream {
+ ILToken NextToken {get;}
+ ILToken LastToken {get;}
+ }
+}
+
diff --git a/mcs/ilasm/scanner/InstrToken.cs b/mcs/ilasm/scanner/InstrToken.cs
new file mode 100644
index 00000000000..edd6db37398
--- /dev/null
+++ b/mcs/ilasm/scanner/InstrToken.cs
@@ -0,0 +1,105 @@
+// InstrToken.cs
+// Author: Sergey Chaban (serge@wildwestsoftware.com)
+
+using System;
+using System.Reflection.Emit;
+
+namespace Mono.ILASM {
+
+ public class InstrToken : ILToken {
+
+
+ /// <summary>
+ /// </summary>
+ public InstrToken (OpCode opcode)
+ {
+ this.val = opcode;
+ token = GetInstrType (opcode);
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="opcode"></param>
+ /// <returns></returns>
+ public static int GetInstrType (OpCode opcode)
+ {
+ OperandType t = opcode.OperandType;
+ int token = Token.UNKNOWN;
+
+ switch (t) {
+
+ case OperandType.InlineBrTarget:
+ case OperandType.ShortInlineBrTarget:
+ token = Token.INSTR_BRTARGET;
+ break;
+
+ case OperandType.InlineField:
+ token = Token.INSTR_FIELD;
+ break;
+
+ case OperandType.InlineI:
+ case OperandType.ShortInlineI:
+ token = Token.INSTR_I;
+ break;
+
+ case OperandType.InlineI8:
+ token = Token.INSTR_I8;
+ break;
+
+ case OperandType.InlineMethod:
+ token = Token.INSTR_METHOD;
+ break;
+
+ case OperandType.InlineNone:
+ token = Token.INSTR_NONE;
+ break;
+
+ case OperandType.InlinePhi:
+ token = Token.INSTR_PHI;
+ break;
+
+ case OperandType.InlineR:
+ case OperandType.ShortInlineR:
+ token = Token.INSTR_R;
+ break;
+
+ /*
+ case OperandType.InlineRVA:
+ token = Token.INSTR_RVA;
+ break;
+ */
+
+ case OperandType.InlineSig:
+ token = Token.INSTR_SIG;
+ break;
+
+ case OperandType.InlineString:
+ token = Token.INSTR_STRING;
+ break;
+
+ case OperandType.InlineSwitch:
+ token = Token.INSTR_SWITCH;
+ break;
+
+ case OperandType.InlineTok:
+ token = Token.INSTR_TOK;
+ break;
+
+ case OperandType.InlineType:
+ token = Token.INSTR_TYPE;
+ break;
+
+ case OperandType.InlineVar:
+ case OperandType.ShortInlineVar:
+ token = Token.INSTR_VAR;
+ break;
+ }
+
+ return token;
+ }
+
+
+ }
+
+}
diff --git a/mcs/ilasm/scanner/Location.cs b/mcs/ilasm/scanner/Location.cs
new file mode 100644
index 00000000000..d0933360817
--- /dev/null
+++ b/mcs/ilasm/scanner/Location.cs
@@ -0,0 +1,103 @@
+// Location.cs
+// Author: Sergey Chaban (serge@wildwestsoftware.com)
+
+using System;
+
+namespace Mono.ILASM {
+
+
+ /// <summary>
+ /// </summary>
+ public class Location : ICloneable {
+ internal int line;
+ internal int column;
+
+
+ /// <summary>
+ /// </summary>
+ public static readonly Location Unknown = new Location (-1, -1);
+
+ /// <summary>
+ /// </summary>
+ public Location () {
+ line = 1;
+ column = 1;
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <param name="line"></param>
+ /// <param name="column"></param>
+ public Location (int line, int column)
+ {
+ this.line = line;
+ this.column = column;
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="that"></param>
+ public Location (Location that)
+ {
+ this.line = that.line;
+ this.column = that.column;
+ }
+
+
+
+
+ /// <summary>
+ /// </summary>
+ public void NewLine ()
+ {
+ ++line;
+ column = 1;
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public void PreviousLine ()
+ {
+ --line;
+ column = 1;
+ }
+
+ /// <summary>
+ /// </summary>
+ public void NextColumn ()
+ {
+ ++column;
+ }
+
+ /// <summary>
+ /// </summary>
+ public void PreviousColumn ()
+ {
+ --column;
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <param name="other"></param>
+ public void CopyFrom (Location other)
+ {
+ this.line = other.line;
+ this.column = other.column;
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <returns></returns>
+ public virtual object Clone () {
+ return new Location (this);
+ }
+
+ public override string ToString ()
+ {
+ return "line (" + line + ") column (" + column + ")";
+ }
+ }
+}
diff --git a/mcs/ilasm/scanner/NumberHelper.cs b/mcs/ilasm/scanner/NumberHelper.cs
new file mode 100644
index 00000000000..022dacbd627
--- /dev/null
+++ b/mcs/ilasm/scanner/NumberHelper.cs
@@ -0,0 +1,221 @@
+// NumberHelper.cs
+// Author: Sergey Chaban (serge@wildwestsoftware.com)
+
+using System;
+using System.Text;
+using System.Globalization;
+
+namespace Mono.ILASM {
+
+ /// <summary>
+ /// </summary>
+ internal class NumberHelper : StringHelperBase {
+
+ private ILToken result;
+
+ /// <summary>
+ /// </summary>
+ /// <param name="host"></param>
+ public NumberHelper (ILTokenizer host) : base (host)
+ {
+ Reset ();
+ }
+
+
+ private void Reset ()
+ {
+ result = ILToken.Invalid.Clone() as ILToken;
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <returns></returns>
+ public override bool Start (char ch)
+ {
+ bool res = (Char.IsDigit (ch) || ch == '-' || (ch == '.' && Char.IsDigit ((char) host.Reader.Peek ())));
+ Reset ();
+ return res;
+ }
+
+ bool is_hex (int e)
+ {
+ return (e >= '0' && e <= '9') || (e >= 'A' && e <= 'F') || (e >= 'a' && e <= 'f');
+ }
+
+ bool is_sign (int ch)
+ {
+ return ((ch == '+') || (ch == '-'));
+ }
+
+ bool is_e (int ch)
+ {
+ return ((ch == 'e') || (ch == 'E'));
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <returns></returns>
+ public override string Build ()
+ {
+ ILReader reader = host.Reader;
+ reader.MarkLocation ();
+ StringBuilder num_builder = new StringBuilder ();
+ string num;
+ int ch;
+ int peek;
+ bool is_real = false;
+ bool dec_found = false;
+
+ NumberStyles nstyles = NumberStyles.AllowExponent | NumberStyles.AllowDecimalPoint |
+ NumberStyles.AllowLeadingSign;
+
+ ch = reader.Read ();
+ peek = reader.Peek ();
+ reader.Unread (ch);
+
+ if (ch == '0' && (peek == 'x' || peek == 'X'))
+ return BuildHex ();
+
+ if (is_sign (reader.Peek ()))
+ num_builder.Append ((char) reader.Read ());
+
+ do {
+ ch = reader.Read ();
+ peek = reader.Peek ();
+ num_builder.Append ((char) ch);
+
+ if (is_e (ch)) {
+ if (is_real)
+ throw new ILTokenizingException (reader.Location, num_builder.ToString ());
+
+ is_real = true;
+ }
+ if (ch == '.')
+ dec_found = true;
+ if (!is_hex(peek) &&
+ !(peek == '.' && !dec_found) && !is_e (peek) &&
+ !(is_sign (peek) && is_real)) {
+ break;
+ }
+ } while (ch != -1);
+
+ num = num_builder.ToString ();
+
+ // Check for hexbytes
+ if (num.Length == 2) {
+ if (Char.IsLetter (num[0]) || Char.IsLetter (num[1])) {
+ result.token = Token.HEXBYTE;
+ result.val = Byte.Parse (num, NumberStyles.HexNumber);
+ return num;
+ }
+ }
+
+ if (ch == '.' && peek == '.') {
+ num = num.Substring (0, num.Length-1);
+ reader.Unread ('.');
+ dec_found = false;
+ } else if (ch == '.') {
+ num += '0';
+ }
+
+ if (!dec_found && !is_real) {
+ try {
+ long i = Int64.Parse (num, nstyles);
+ result.token = Token.INT64;
+ result.val = i;
+
+ return num;
+ } catch {
+ }
+
+ try {
+ long i = (long) UInt64.Parse (num, nstyles);
+ result.token = Token.INT64;
+ result.val = i;
+
+ return num;
+ } catch {
+ }
+ }
+
+ try {
+ double d = Double.Parse (num, nstyles, NumberFormatInfo.InvariantInfo);
+ result.token = Token.FLOAT64;
+ result.val = d;
+ } catch {
+ reader.Unread (num.ToCharArray ());
+ reader.RestoreLocation ();
+ num = String.Empty;
+ Reset ();
+ throw new ILTokenizingException (reader.Location, num_builder.ToString ());
+ }
+ return num;
+ }
+
+ public string BuildHex ()
+ {
+ ILReader reader = host.Reader;
+ reader.MarkLocation ();
+ StringBuilder num_builder = new StringBuilder ();
+ NumberStyles nstyles = NumberStyles.HexNumber;
+
+ string num;
+ int ch;
+ int peek;
+
+ ch = reader.Read ();
+ if (ch != '0')
+ throw new ILTokenizingException (reader.Location, ((char) ch).ToString ());
+
+ ch = reader.Read ();
+
+ if (ch != 'x' && ch != 'X')
+ throw new ILTokenizingException (reader.Location, "0" + (char) ch);
+
+ do {
+ ch = reader.Read ();
+ peek = reader.Peek ();
+ num_builder.Append ((char) ch);
+
+ if (!is_hex ((char) peek))
+ break;
+
+ if (num_builder.Length == 32)
+ throw new ILTokenizingException (reader.Location, num_builder.ToString ());
+
+ } while (ch != -1);
+
+ num = num_builder.ToString ();
+
+ try {
+ long i = (long) UInt64.Parse (num, nstyles);
+ //if (i < Int32.MinValue || i > Int32.MaxValue) {
+ result.token = Token.INT64;
+ result.val = i;
+ //} else {
+ // result.token = Token.INT32;
+ // result.val = (int) i;
+ //}
+ } catch {
+ string tnum = num;
+ reader.Unread (num.ToCharArray ());
+ reader.RestoreLocation ();
+ num = String.Empty;
+ Reset ();
+ throw new ILTokenizingException (reader.Location, tnum);
+ }
+ return num;
+ }
+
+ /// <summary>
+ /// </summary>
+ public ILToken ResultToken {
+ get {
+ return result;
+ }
+ }
+
+
+ }
+
+}
diff --git a/mcs/ilasm/scanner/StringHelper.cs b/mcs/ilasm/scanner/StringHelper.cs
new file mode 100644
index 00000000000..e1e13e02b07
--- /dev/null
+++ b/mcs/ilasm/scanner/StringHelper.cs
@@ -0,0 +1,132 @@
+// StringHelper.cs
+// Author: Sergey Chaban (serge@wildwestsoftware.com)
+
+using System;
+using System.Text;
+
+namespace Mono.ILASM {
+
+ /// <summary>
+ /// </summary>
+ internal class StringHelper : StringHelperBase {
+
+ private static readonly string idChars = "_$@?`";
+
+ /// <summary>
+ /// </summary>
+ /// <param name="host"></param>
+ public StringHelper (ILTokenizer host) : base (host)
+ {
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <returns></returns>
+ public override bool Start (char ch)
+ {
+ mode = Token.UNKNOWN;
+
+ if (Char.IsLetter (ch) || idChars.IndexOf (ch) != -1) {
+ mode = Token.ID;
+ } else if (ch == '\'') {
+ mode = Token.SQSTRING;
+ } else if (ch == '"') {
+ mode = Token.QSTRING;
+ }
+
+ return (mode != Token.UNKNOWN);
+ }
+
+
+ private static bool IsIdChar (int c)
+ {
+ char ch = (char) c;
+ return (Char.IsLetterOrDigit(ch) || idChars.IndexOf (ch) != -1);
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <returns></returns>
+ public override string Build ()
+ {
+ if (mode == Token.UNKNOWN) return String.Empty;
+ int ch = 0;
+
+ ILReader reader = host.Reader;
+
+ StringBuilder idsb = new StringBuilder ();
+ if (mode == Token.SQSTRING || mode == Token.QSTRING) {
+ int term = (mode == Token.SQSTRING) ? '\'' : '"';
+ reader.Read (); // skip quote
+ for (ch = reader.Read (); ch != -1; ch = reader.Read ()) {
+ if (ch == term) {
+ break;
+ }
+
+ if (ch == '\\') {
+ ch = reader.Read ();
+
+ /*
+ * Long string can be broken across multiple lines
+ * by using '\' as the last char in line.
+ * Any white space chars between '\' and the first
+ * char on the next line are ignored.
+ */
+ if (ch == '\n') {
+ reader.SkipWhitespace ();
+ continue;
+ }
+
+ int escaped = Escape (ch);
+ if (escaped == -1) {
+ reader.Unread (ch);
+ ch = '\\';
+ } else {
+ ch = escaped;
+ }
+ }
+
+ idsb.Append((char)ch);
+ }
+ } else { // ID
+ while ((ch = reader.Read ()) != -1) {
+ if (IsIdChar (ch)) {
+ idsb.Append ((char) ch);
+ } else {
+ reader.Unread (ch);
+ break;
+ }
+ }
+ }
+ return idsb.ToString ();
+ }
+
+
+
+
+ /// <summary>
+ /// </summary>
+ /// <param name="ch"></param>
+ /// <returns></returns>
+ public static int Escape (int ch)
+ {
+ int res = -1;
+
+ if (ch >= '0' && ch <='7') {
+ //TODO : octal code
+ } else {
+ int id = "abfnrtv\"'\\".IndexOf ((char)ch);
+ if (id != -1) {
+ res = "\a\b\f\n\r\t\v\"'\\" [id];
+ }
+ }
+
+ return res;
+ }
+
+ }
+
+
+}
+
diff --git a/mcs/ilasm/scanner/StringHelperBase.cs b/mcs/ilasm/scanner/StringHelperBase.cs
new file mode 100644
index 00000000000..6b88768aee0
--- /dev/null
+++ b/mcs/ilasm/scanner/StringHelperBase.cs
@@ -0,0 +1,63 @@
+// StringHelperBase.cs
+// Author: Sergey Chaban (serge@wildwestsoftware.com)
+
+using System;
+using System.Text;
+
+namespace Mono.ILASM {
+
+ /// <summary>
+ /// </summary>
+ internal abstract class StringHelperBase {
+
+ protected ILTokenizer host;
+ protected int mode;
+
+ /// <summary>
+ /// </summary>
+ /// <param name="host"></param>
+ public StringHelperBase (ILTokenizer host) {
+ this.host = host;
+ mode = Token.UNKNOWN;
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <returns></returns>
+ public abstract bool Start (char ch);
+
+
+ /// <summary>
+ /// </summary>
+ /// <returns></returns>
+ public bool Start (int ch)
+ {
+ return Start ((char)ch);
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <returns></returns>
+ public bool Start ()
+ {
+ return Start (host.Reader.Peek ());
+ }
+
+
+ /// <summary>
+ /// </summary>
+ /// <returns></returns>
+ public abstract string Build ();
+
+
+ /// <summary>
+ /// </summary>
+ public int TokenId {
+ get {
+ return mode;
+ }
+ }
+
+ }
+
+} \ No newline at end of file
diff --git a/mcs/ilasm/tests/ChangeLog b/mcs/ilasm/tests/ChangeLog
new file mode 100644
index 00000000000..4bff294d226
--- /dev/null
+++ b/mcs/ilasm/tests/ChangeLog
@@ -0,0 +1,287 @@
+2006-02-22 Ankit Jain <jankit@novell.com>
+
+ * test-nonsealed-valueclass.il: New. Value class should be sealed.
+
+2006-02-20 Ankit Jain <jankit@novell.com>
+
+ * generics-al.i, test-29.il: Remove. These use invalid style of
+ specifying generic constraints.
+
+2006-02-19 Ankit Jain <jankit@novell.com>
+
+ * invalid-method.il: New. Reference to undefined method.
+ * invalid-field.il: New. Reference to undefined field.
+
+2006-01-31 Ankit Jain <jankit@novell.com>
+
+ * test-assembly2.il: New. Test for referencing undeclared external assembly.
+
+2006-01-23 Ankit Jain <jankit@novell.com>
+
+ * err-*.il, test-perm_fail*.il: Move negative tests from here to errors/ .
+
+2006-01-19 Ankit Jain <jankit@novell.com>
+
+ * test-module-cattr.il: New. Test for custom attributes on .module
+ * test-array-2.i: Add the missing closing brace.
+
+2006-01-19 Ankit Jain <jankit@novell.com>
+
+ * err-gen-cattr-1.il: New.
+ * err-gen-cattr-2.il: New.
+ * err-gen-cattr-3.il: New.
+ * err-gen-cattr-4.il: New.
+
+2006-01-16 Ankit Jain <jankit@novell.com>
+
+ * test-int64.il: New. Test for large numeric values.
+
+2006-01-16 Ankit Jain <jankit@novell.com>
+
+ * test-array-2.il: New. Test for methodref to Array's methods.
+ eg. class test [,]::.ctor (int32, int32)
+
+2006-01-15 Ankit Jain <jankit@novell.com>
+
+ * test-override-1.il:
+ * test-override-2.il: New. Test for 'full' syntax of specifying
+ overrides. (.override method ..full sig.. )
+
+2006-01-14 Ankit Jain <jankit@novell.com>
+
+ * gen-instr1.il: New. Test for using GenericParams as operands to
+ type instructions.
+
+2006-01-11 Ankit Jain <jankit@novell.com>
+
+ * gen-nested2.il: New.
+ * gen-nested3.il: New. Test for new syntax for specifying namespace ie.,
+ as part of the type name instead of using '.namespace' directive.
+
+2006-01-10 Ankit Jain <jankit@novell.com>
+
+ * gen-nested.il: New. Test for a generic type nested in a non-generic
+ one.
+
+2006-01-10 Ankit Jain <jankit@novell.com>
+
+ * gen-meth3.il: New. Test for abstract generic method.
+
+2006-01-10 Ankit Jain <jankit@novell.com>
+
+ * gen-meth1.il: New. Test for use of VAR/MVAR by name (!!A)
+ * gen-meth2.il: New. Test for using VAR/MVAR as class ref.
+
+2006-01-09 Ankit Jain <jankit@novell.com>
+
+ * gen-recur.il: New. Test for a class implementing a generic interface
+ with the class itself as the argument.
+
+2006-01-07 Ankit Jain <jankit@novell.com>
+
+ * gen-constraints1.il: New. Test for constraints on generic parameters.
+
+2006-01-06 Ankit Jain <jankit@novell.com>
+
+ * test-field-init.il: New. Test for field initialization (simple signed/unsigned
+ int variants).
+
+2006-01-06 Ankit Jain <jankit@novell.com>
+
+ * test-perm_pass-2.il: New. Test for new(2.0) syntax of specifying value
+ of a permissionset, which uses string instead of a bytearray.
+
+2006-01-05 Ankit Jain <jankit@novell.com>
+
+ * gen-extern-type.il: New. Test for ref to an external generic type.
+ * gen-array1.il, gen-array-2.il: New. Test for duplicate typespecs for
+ generic types and arrays of the same.
+ * gen-interf-1.il, gen-interf-2.il: New. Test for inheriting from a generic
+ base class and implementing generic interfaces.
+ * gen-struct.il: New. Test for generic valuetype.
+ * gen-local.il: New. No entry in the TypeSpec table should be emitted if a
+ generic type is referenced only as a local var.
+ * one.cs, two.cs: Updated to include types required the new tests.
+
+2006-01-03 Ankit Jain <jankit@novell.com>
+
+ * gen-dotted-name.il: New. Test for dotted-name of a generic type.
+
+2005-12-16 Ankit Jain <jankit@novell.com>
+
+ Tests for fields with same name but different types.
+ * field-dup1.il, field-dup-gen2.il: Positive tests.
+ * err-field-dup1.il, err-field-dup2.il, err-field-dup3.il,
+ err-field-dup4.il, err-field-dup5.il, err-field-dup6-gen.il,
+ err-field-dup7-gen.il: Negative tests.
+ * one.cs, two.cs, oneg.cs: Required for use by above test cases.
+
+2005-12-15 Ankit Jain <jankit@novell.com>
+
+ * test-array.il: Oops, contained two copies of the test case.
+
+2005-12-15 Ankit Jain <jankit@novell.com>
+
+ * assembly.il: New. Test for multiple .assembly declarations.
+ * err-assembly.il: New. Negative test for the same.
+
+2005-12-14 Ankit Jain <jankit@novell.com>
+
+ * test-bounded-array.il: New. Test for [0...], should not lose its
+ lower bound info.
+
+2005-12-14 Ankit Jain <jankit@novell.com>
+
+ * test-array.il: New. Test for tokenizing 0...8
+
+2005-12-14 Ankit Jain <jankit@novell.com>
+
+ * test-uint.il: New. Test for keywords uint8, uint16, uint32 & uint64.
+
+2005-12-14 Ankit Jain <jankit@novell.com>
+
+ * dotted-names.il: Add test for class with no explicit namespace.
+
+2005-12-13 Ankit Jain <jankit@novell.com>
+
+ * dotted-names.il: New. Test for dotted names in namespace, class.
+
+2005-12-12 Ankit Jain <jankit@novell.com>
+
+ * nested.il: New. Ensure nested visibility for nested types.
+
+2005-12-12 Ankit Jain <jankit@novell.com>
+
+ * gen-1.il:New. Generic method reference.
+ * err-gen-2.il:
+ * err-gen-3.il: New. Negative tests for generic method refernce.
+ * global.il: New. Global generic method ref.
+ * gen-field.il: New. Generic field reference. (Compiles fine, but
+ will have PEVerify errors)
+
+2005-11-23 Ankit Jain <jankit@novell.com>
+
+ * test-33.il:
+ * test-34.il: New. Tests for custom attributes on type parameters.
+
+2005-09-15 Ankit Jain <jankit@novell.com>
+
+ * test-perm_fail-[1234].il: New. Negative Tests for .permission directive.
+ * test-perm_pass-1.il: New. Test for .permission directive.
+
+2005-08-23 Ankit Jain <jankit@novell.com>
+
+ * test-byref.il: New. Test for a call with byref return type.
+
+2005-08-18 Ankit Jain <jankit@novell.com>
+
+ * test-sec-suppress.il: New. Test for SuppressUnmanagedCodeSecurity
+ custom attribute, type or method should get a HasSecurity attribute.
+
+2005-08-18 Ankit Jain <jankit@novell.com>
+
+ * test-ldcr-bytes.il: New. Test for "ldc.r8/r4" followed by a byte array.
+
+2005-08-18 Ankit Jain <jankit@novell.com>
+
+ * test-cattr-declsec.il: New. Added test for custom attrs and decl sec
+ on interface methods.
+
+2005-08-16 Ankit Jain <jankit@novell.com>
+
+ * test-marshal-array.il: New. Added test for marshalling as native type array.
+ * test-marshal.il: New. Added test for marshal info for method params.
+ * test-fixedarray.il: New. Added test for marshalling as fixed array.
+ * test-safearray.il: New. Added test for marshalling as safe array.
+
+2004-12-10 Sebastien Pouliot <sebastien@ximian.com>
+
+ * test-sn.il: New. Added test when including a public key to test for
+ strongnaming an assembly (/key option).
+ * sn.snk: New. Strongname key for the test-sn.il test.
+
+2003-07-12 Zoltan Varga <vargaz@freemail.hu>
+
+ * test-31.il: Added tests for static properties. Also made the code
+ for methods verifiable IL.
+
+Fri Jul 25 12:27:24 CEST 2003 Paolo Molaro <lupus@ximian.com>
+
+ * generics-c.il, generics-b.il: add constructors and fix code.
+
+2003-07-14 Jackson Harper <jackson@latitudegeo.com>
+
+ * test-11.il: Don't specify constraints with ids anymore
+ * test-29.il: Remove uneeded class, add constraint
+
+2003-03-31 Jackson Harper <jackson@latitudegeo.com>
+
+ * test-10.il: New test, does some bounded array stuff
+
+2003-03-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * tests: Update to valid il code.
+
+2003-03-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * test-9.il: Add output to the constructor so I know it is called, give
+ the constructor the instance call conv.
+
+2003-03-16 Jackson Harper <jackson@latitudegeo.com>
+
+ * test-9.il: New test, test instaniating a class
+
+2003-03-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * test-8.il: New test, test creating a class that inherits from something other then System.Object
+
+2003-03-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * test-6.il: Define class that field references
+
+2003-03-06 Jackson Harper <jackson@latitudegeo.com>
+
+ * makefile: add some tests
+ * test-5.il, test-6.il, test-7.il: New tests, test field declaration
+
+2003-02-10 Jackson Harper <jackson@latitudegeo.com>
+
+ * makefile: remove unneeded rm's
+
+2003-02-10 Jackson Harper <jackson@latitudegeo.com>
+
+ * test-4.il: Add file
+ * makefile: Add new test
+
+2003-02-09 Jackson Harper <jackson@latitudegeo.com>
+
+ * test-3.il: Add file
+ * makefile: Add new test
+
+2003-02-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * test-1.il: Change class name
+
+2003-02-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * test-2.il: Add new test
+ * makefile: Use new test
+
+2003-02-04 Jackson Harper <jackson@latitudegeo.com>
+
+ * test-1.il: Add header, put in a namespace
+
+2003-02-04 Jackson Harper <jackson@latitudegeo.com>
+
+ * makefile: Use .il files not .cs ;-)
+
+2003-02-04 Jackson Harper <jackson@latitudegeo.com>
+
+ * HelloWorld.il: Remove
+ * test-1.il: New test
+ * makefile: Added file
+
+2003-02-02 Jackson Harper <jackson@latitudegeo.com>
+
+ * HelloWorld.il: Add HelloWorld test
+ * ChangeLog: Add ChangeLog
diff --git a/mcs/ilasm/tests/assembly.il b/mcs/ilasm/tests/assembly.il
new file mode 100644
index 00000000000..30f2fe7ff19
--- /dev/null
+++ b/mcs/ilasm/tests/assembly.il
@@ -0,0 +1,13 @@
+//Multiple .assembly declarations but with same name (valid)
+.assembly extern mscorlib
+{
+ .ver 1:0:5000:0
+}
+.assembly 'test'
+{
+ .hash algorithm 0x00008004
+}
+.assembly 'test'
+{
+}
+
diff --git a/mcs/ilasm/tests/dotted-names.il b/mcs/ilasm/tests/dotted-names.il
new file mode 100644
index 00000000000..b67741497c4
--- /dev/null
+++ b/mcs/ilasm/tests/dotted-names.il
@@ -0,0 +1,28 @@
+//Tests dotted names (namespace, class names)
+//It should emit namespace = A.B.C and type name = D
+//For E.F, namespace = E, name = F
+
+.assembly extern mscorlib
+{
+}
+
+.assembly Output
+{
+}
+
+.module Output
+
+.namespace A.B {
+
+.class public auto autochar sealed beforefieldinit C.D
+ extends [mscorlib]System.Object
+{
+}
+
+}
+
+.class public auto autochar sealed beforefieldinit E.F
+ extends [mscorlib]System.Object
+{
+}
+
diff --git a/mcs/ilasm/tests/field-dup-gen2.il b/mcs/ilasm/tests/field-dup-gen2.il
new file mode 100644
index 00000000000..b45b1f35ccf
--- /dev/null
+++ b/mcs/ilasm/tests/field-dup-gen2.il
@@ -0,0 +1,34 @@
+//Test for fields with same name but different types
+
+.assembly extern mscorlib
+{
+ .ver 1:0:5000:0
+}
+.assembly extern 'oneg'
+{
+}
+.assembly 'field-dup'
+{
+ .ver 0:0:0:0
+}
+.module 'field-dup.exe'
+
+ .class private auto ansi beforefieldinit boo`1 <T>
+ extends [mscorlib]System.Object
+ {
+ }
+
+ .class private auto ansi beforefieldinit foo`1 <T>
+ extends [mscorlib]System.Object
+ {
+ .field private !0 p
+
+ .field private class foo`1<!T> p
+ .field private class boo`1<!T> p
+
+ .field private class foo`1<int32> p
+
+ .field private class [oneg]outer/inner`1<!0> p
+ .field private class [oneg]outer/inner`1<int32> p
+ }
+
diff --git a/mcs/ilasm/tests/field-dup1.il b/mcs/ilasm/tests/field-dup1.il
new file mode 100644
index 00000000000..eb95d562753
--- /dev/null
+++ b/mcs/ilasm/tests/field-dup1.il
@@ -0,0 +1,42 @@
+//Test for fields with same name but different types
+
+.assembly extern mscorlib
+{
+ .ver 1:0:5000:0
+}
+.assembly extern one
+{
+ .ver 0:0:0:0
+}
+.assembly extern two
+{
+ .ver 0:0:0:0
+}
+.assembly 'field-dup'
+{
+ .ver 0:0:0:0
+}
+.module 'field-dup.exe'
+
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+ .field private int32 i
+ .field private int32[] i
+ .field private class [mscorlib]System.Int32 i
+ .field private class [mscorlib]System.Int32[] i
+
+ .field private class [one]outer n
+ .field private class [one]outer[] n
+ .field private class [one]outer[][] n
+ .field private class [two]outer[][] n
+
+ .field private class [one]outer/inner i
+ .field private class [two]outer/inner i
+
+ .field private class [one]outer/inner [] i
+ .field private class [two]outer/inner [] i
+
+ }
+
diff --git a/mcs/ilasm/tests/gen-1.il b/mcs/ilasm/tests/gen-1.il
new file mode 100644
index 00000000000..91ba1a58a08
--- /dev/null
+++ b/mcs/ilasm/tests/gen-1.il
@@ -0,0 +1,69 @@
+//Tests generic method reference
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly pp
+{
+ .ver 0:0:0:0
+}
+
+.class private auto ansi beforefieldinit 'A`1'<T>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig static !T foo<X,Y>(!T _t,
+ !!X _x) cil managed
+ {
+ .maxstack 1
+ .locals init (!T V_0)
+ IL_0000: nop
+ IL_0001: ldarg.0
+ IL_0002: stloc.0
+ IL_0003: br.s IL_0005
+
+ IL_0005: ldloc.0
+ IL_0006: ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ }
+
+}
+
+.class private auto ansi beforefieldinit 'B`1'<U>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig static void bar<Z>() cil managed
+ {
+ // Code size 18 (0x12)
+ .maxstack 2
+ .locals init (!U V_0)
+ IL_0000: nop
+ IL_0001: ldloca.s V_0
+ IL_0003: initobj !U
+ IL_0009: ldloc.0
+ IL_000a: ldc.i4.5
+ IL_000b: call !0 class 'A`1'<!U>::foo<int32,!U>(!0,
+ !!Z)
+ IL_0010: pop
+ IL_0011: ret
+ } // end of method B`1::bar
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ } // end of method B`1::.ctor
+
+}
diff --git a/mcs/ilasm/tests/gen-array1.il b/mcs/ilasm/tests/gen-array1.il
new file mode 100644
index 00000000000..51dec68d014
--- /dev/null
+++ b/mcs/ilasm/tests/gen-array1.il
@@ -0,0 +1,62 @@
+// Test that no duplicate TypeSpec entries are emitted
+//
+// Multiple instaces of generic type class g<T>, with the same
+// argument (int32). Only one typespec should be emitted and shared by all these.
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly 'gen-array-1'
+{
+ .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = (
+ 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
+
+ .ver 0:0:0:0
+}
+.module arr.exe
+
+ .class private auto ansi beforefieldinit g`1<T>
+ extends [mscorlib]System.Object
+ {
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+ }
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+ .method public static hidebysig
+ default void Main () cil managed
+ {
+ .entrypoint
+ .maxstack 3
+ .locals init (
+ /* Multiple generic instances with same argument */
+ class g`1<int32>[] V_0,
+ class g`1<int32>[][] V_1,
+ class g`1<int32> V_2,
+ class g`1<int32>[] V_3,
+ class g`1<class g`1<int32>> V_4,
+ class g`1<class g`1<int32>>[] V_5,
+ class g`1<class g`1<int32>>[][] V_6,
+ class g`1<class g`1<int32>[]>[][] V_7,
+ class g`1<class g`1<int32>[][]>[][] V_8)
+ IL_0000: ldc.i4.s 0x36
+ IL_0002: newarr class g`1<int32>
+ IL_0007: stloc.0
+ IL_0008: ldloc.0
+ IL_0009: ldc.i4.0
+ IL_000a: newobj instance void class g`1<int32>::.ctor()
+ IL_000f: stelem.ref
+ IL_0010: ret
+ }
+
+ }
diff --git a/mcs/ilasm/tests/gen-array2.il b/mcs/ilasm/tests/gen-array2.il
new file mode 100644
index 00000000000..4528bb0f796
--- /dev/null
+++ b/mcs/ilasm/tests/gen-array2.il
@@ -0,0 +1,52 @@
+// Test that no duplicate TypeSpec entries are emitted
+//
+// Multiple instaces of generic type class [one]gen<T> from an *external* assembly, with the same
+// argument (int32). Only one typespec should be emitted and shared by all these.
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly extern one
+{
+}
+.assembly 'gen-array2'
+{
+ .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = (
+ 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
+
+ .ver 0:0:0:0
+}
+.module arr.exe
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+ .method public static hidebysig
+ default void Main () cil managed
+ {
+ .entrypoint
+ .maxstack 3
+ .locals init (
+ /* Multiple generic instances with same argument */
+ class [one]gen`1<int32>[] V_0,
+ class [one]gen`1<int32>[][] V_1,
+ class [one]gen`1<int32> V_2,
+ class [one]gen`1<int32>[] V_3,
+ class [one]gen`1<class [one]gen`1<int32>> V_4,
+ class [one]gen`1<class [one]gen`1<int32>>[] V_5,
+ class [one]gen`1<class [one]gen`1<int32>>[][] V_6,
+ class [one]gen`1<class [one]gen`1<int32>[]>[][] V_7,
+ class [one]gen`1<class [one]gen`1<int32>[][]>[][] V_8)
+ IL_0000: ldc.i4.s 0x36
+ IL_0002: newarr class [one]gen`1<int32>
+ IL_0007: stloc.0
+ IL_0008: ldloc.0
+ IL_0009: ldc.i4.0
+ IL_000a: newobj instance void class [one]gen`1<int32>::.ctor()
+ IL_000f: stelem.ref
+ IL_0010: ret
+ }
+
+ }
diff --git a/mcs/ilasm/tests/gen-constraints1.il b/mcs/ilasm/tests/gen-constraints1.il
new file mode 100644
index 00000000000..1c791f75290
--- /dev/null
+++ b/mcs/ilasm/tests/gen-constraints1.il
@@ -0,0 +1,106 @@
+// Test for constraints on generic parameters
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly 'const'
+{
+ .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = (
+ 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 )
+
+ .ver 0:0:0:0
+}
+.module const.dll
+
+ .class interface private auto ansi abstract ITest1
+ {
+ }
+
+ .class interface private auto ansi abstract ITest
+ {
+ }
+
+ .class private auto ansi beforefieldinit bb
+ extends [mscorlib]System.Object
+ {
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ }
+
+ /* Constraints : .ctor, base class, interfaces */
+ .class private auto ansi beforefieldinit gen`1 <.ctor (class bb, class [mscorlib]System.Collections.Generic.ICollection`1<!T>, class [mscorlib]System.Collections.ICollection, class ITest1) T>
+ extends [mscorlib]System.Object
+ {
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ /* Constraints on a method's generic params */
+ .method public hidebysig
+ instance default void foo<.ctor (class [mscorlib]System.Collections.Generic.ICollection`1<!!0>) M> () cil managed
+ {
+ .maxstack 8
+ IL_0000: ret
+ }
+
+ }
+
+ /* Constraint : class */
+ .class private auto ansi beforefieldinit foo`1<class M>
+ extends [mscorlib]System.Object
+ {
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ }
+
+ /* Constraint : valuetype */
+ .class private auto ansi beforefieldinit bar`1<valuetype M>
+ extends [mscorlib]System.Object
+ {
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ }
+
+ /* Constraint : generic constraint */
+ .class private auto ansi beforefieldinit abc`1 <(class foo`1<class bb>) M>
+ extends [mscorlib]System.Object
+ {
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ }
+
diff --git a/mcs/ilasm/tests/gen-dotted-name.il b/mcs/ilasm/tests/gen-dotted-name.il
new file mode 100644
index 00000000000..cfc8a9cce17
--- /dev/null
+++ b/mcs/ilasm/tests/gen-dotted-name.il
@@ -0,0 +1,25 @@
+//Test for dotted-name for a generic type
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly 'dottedname'
+{
+}
+
+.module dottedname.dll
+
+ .class private auto ansi beforefieldinit ns.gen`1<T>
+ extends [mscorlib]System.Object
+ {
+
+ }
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+ .field private class ns.gen`1<int32> g
+
+ }
+
diff --git a/mcs/ilasm/tests/gen-extern-type.il b/mcs/ilasm/tests/gen-extern-type.il
new file mode 100644
index 00000000000..215cb529f1c
--- /dev/null
+++ b/mcs/ilasm/tests/gen-extern-type.il
@@ -0,0 +1,51 @@
+// Test for Ref to external generic types
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly extern one
+{
+ .ver 0:0:0:0
+}
+.assembly 'gen-extern-type'
+{
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 )
+ .ver 0:0:0:0
+}
+
+.module use.exe
+
+.class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ }
+
+ .method public hidebysig static void Main() cil managed
+ {
+ .entrypoint
+ .maxstack 3
+ .locals init (class [one]ns.gen_m`1<int32>[] V_0)
+ IL_0000: ldc.i4.5
+ IL_0001: newarr class [one]ns.gen_m`1<int32>
+ IL_0006: stloc.0
+ IL_0007: ldloc.0
+ IL_0008: ldc.i4.0
+ IL_0009: newobj instance void class [one]ns.gen_m`1<int32>::.ctor()
+ IL_000e: stelem.ref
+ IL_000f: ldstr "asd"
+ IL_0014: call void class [one]ns.gen_m`1<int32>::foo<string>(!!0)
+ IL_0019: ldc.i4.5
+ IL_001a: call void class [one]ns.gen_m`1<int32>::foo<int32,string>(!!0)
+ IL_001f: ret
+ }
+
+}
diff --git a/mcs/ilasm/tests/gen-field.il b/mcs/ilasm/tests/gen-field.il
new file mode 100644
index 00000000000..5940aaa994b
--- /dev/null
+++ b/mcs/ilasm/tests/gen-field.il
@@ -0,0 +1,79 @@
+//Test generic field ref: should compile fine, but should give
+//PEVerify error:
+// f`1[T]::foo][offset 0x00000014] Field is not visible.
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly 'f2'
+{
+ .ver 0:0:0:0
+}
+.module f2.dll
+
+
+ .class private auto ansi beforefieldinit 'f`1'<T>
+ extends [mscorlib]System.Object
+ {
+ .field public static !0 _t
+ .field public static !0[] _tarr
+ .field public static bool b
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ .method public static hidebysig
+ default void foo () cil managed
+ {
+ .maxstack 2
+ .locals init (
+ !T V_0)
+ IL_0000: ldloca.s 0
+ IL_0002: initobj !0
+ IL_0008: ldloc.0
+ IL_0009: stsfld !0 class 'f`1'<!0>::_t
+ IL_000e: ldc.i4.5
+ IL_000f: newarr !0
+ IL_0014: stsfld !!0[] class 'f`1'<!0>::_tarr
+ IL_0019: ldc.i4.1
+ IL_001a: stsfld bool class 'f`1'<!0>::b
+ IL_001f: ret
+ }
+
+ }
+
+ .class private auto ansi beforefieldinit g
+ extends [mscorlib]System.Object
+ {
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ .method private hidebysig
+ instance default void foo2 () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldc.i4.4
+ IL_0001: stsfld !0 class 'f`1'<int32>::_t
+ IL_0006: ldc.i4.5
+ IL_0007: newarr [mscorlib]System.String
+ IL_000c: stsfld !0[] class 'f`1'<string>::_tarr
+ IL_0011: ldc.i4.1
+ IL_0012: stsfld bool class 'f`1'<string>::b
+ IL_0017: ret
+ }
+
+ }
diff --git a/mcs/ilasm/tests/gen-instr1.il b/mcs/ilasm/tests/gen-instr1.il
new file mode 100644
index 00000000000..e71cf9f75a8
--- /dev/null
+++ b/mcs/ilasm/tests/gen-instr1.il
@@ -0,0 +1,48 @@
+// Test for type parameter as an operand for
+// a type instr
+// Here, initobj and box have operand : !0
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly 'gpr'
+{
+ .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = (
+ 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
+
+ .ver 0:0:0:0
+}
+.module gpr.dll
+
+ .class private auto ansi beforefieldinit g`1<T>
+ extends [mscorlib]System.Object
+ {
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ .method public static hidebysig
+ default void foo () cil managed
+ {
+ .maxstack 2
+ .locals init (
+ !0 V_0,
+ object V_1,
+ !0 V_2)
+ IL_0000: ldloca.s 2
+ IL_0002: initobj !0
+ IL_0008: ldloc.2
+ IL_0009: box !0
+ IL_000e: stloc.1
+ IL_000f: ret
+ }
+
+ }
+
diff --git a/mcs/ilasm/tests/gen-interf-1.il b/mcs/ilasm/tests/gen-interf-1.il
new file mode 100644
index 00000000000..8e650a0daa0
--- /dev/null
+++ b/mcs/ilasm/tests/gen-interf-1.il
@@ -0,0 +1,57 @@
+// Test for : inheriting generic base class and implementing generic interfaces
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly 'gen-interf-1'
+{
+ .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = (
+ 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
+
+ .ver 0:0:0:0
+}
+.module interf.exe
+
+ .class interface private auto ansi abstract IGen`1<T>
+ {
+ }
+
+ .class interface private auto ansi abstract IFen`1<T>
+ {
+ }
+
+ .class interface private auto ansi abstract ISimple
+ {
+ }
+
+ .class private auto ansi beforefieldinit cbase`1<Z>
+ extends [mscorlib]System.Object
+ {
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .locals init (class cbase`1<int32>[] c)
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ }
+
+ /* Inherits a generic base class and implements generic interfaces */
+ .class private auto ansi beforefieldinit gen_another`2<A,B>
+ extends class cbase`1<!1>
+ implements class IGen`1<!0>, class IFen`1<!1>, ISimple {
+
+ }
+
+ /* Inherits a generic base class and implements generic interfaces,
+ but uses !A (type param name) instead of index */
+ .class private auto ansi beforefieldinit badname`2<A,B>
+ extends class cbase`1<!B>
+ implements class IGen`1<!A>, class IFen`1<!B>, ISimple {
+
+ }
diff --git a/mcs/ilasm/tests/gen-interf-2.il b/mcs/ilasm/tests/gen-interf-2.il
new file mode 100644
index 00000000000..e2ce9fee163
--- /dev/null
+++ b/mcs/ilasm/tests/gen-interf-2.il
@@ -0,0 +1,36 @@
+// Test for : inheriting generic (external) base class and implementing (external) generic interfaces
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly extern one
+{
+}
+.assembly 'gen-interf-2'
+{
+ .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = (
+ 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
+
+ .ver 0:0:0:0
+}
+.module interf.exe
+
+
+ .class interface private auto ansi abstract ISimple
+ {
+
+ }
+
+ .class private auto ansi beforefieldinit gen_another`2<A,B>
+ extends class [one]gen`1<!0>
+ implements class [one]If1`1<!0>, class [one]If2`1<!1>, ISimple, [one]If3 {
+
+ }
+
+ .class private auto ansi beforefieldinit badname`2<A,B>
+ extends class [one]gen`1<!A>
+ implements class [one]If1`1<!A>, class [one]If2`1<!B>, ISimple, [one]If3 {
+
+ }
diff --git a/mcs/ilasm/tests/gen-local.il b/mcs/ilasm/tests/gen-local.il
new file mode 100644
index 00000000000..9fb08211f41
--- /dev/null
+++ b/mcs/ilasm/tests/gen-local.il
@@ -0,0 +1,49 @@
+// No entry in the TypeSpec table should be emitted for generic types (g<> and gen<>)
+// referenced in local var sig as it(GenericInst) is emitted the sig itself, and not a TypeSpec token
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly extern one
+{
+}
+
+.assembly 'gen-local'
+{
+ .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = (
+ 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
+
+ .ver 0:0:0:0
+}
+.module 'gen-local.exe'
+
+ .class private auto ansi beforefieldinit g`1<T>
+ extends [mscorlib]System.Object
+ {
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+ }
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+ .method public static hidebysig
+ default void Main () cil managed
+ {
+ .entrypoint
+ .maxstack 3
+ .locals init (
+ class g`1<string> V_0,
+ class [one]gen`1<string> V_1)
+ IL_0010: ret
+ }
+
+ }
diff --git a/mcs/ilasm/tests/gen-meth1.il b/mcs/ilasm/tests/gen-meth1.il
new file mode 100644
index 00000000000..0824f3066d3
--- /dev/null
+++ b/mcs/ilasm/tests/gen-meth1.il
@@ -0,0 +1,65 @@
+// Test: Use of !!A, gen param ref by name in method signature,
+// or in constraints
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly 'gen-meth1'
+{
+ .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = (
+ 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
+
+ .ver 0:0:0:0
+}
+.module meth1.dll
+
+ .class interface private auto ansi abstract IFoo`1<A>
+ {
+ }
+
+ .class private auto ansi beforefieldinit g`1<T>
+ extends [mscorlib]System.Object
+ {
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ .method public static hidebysig
+ default !!A foo<(class g`1<!!B>)A,B> (!!B _b, !T _t, !!A _a) cil managed
+ {
+ .maxstack 1
+ .locals init (
+ !!A V_0)
+ IL_0000: ldloca.s 0
+ IL_0002: initobj !!0
+ IL_0008: ldloc.0
+ IL_0009: ret
+ }
+
+ .method public static hidebysig
+ default void meth1 () cil managed
+ {
+ .maxstack 4
+ .locals init (
+ !T V_0,
+ !T[] V_1)
+ IL_0000: ldtoken !T
+ IL_0005: call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
+ IL_000a: call object class [mscorlib]System.Activator::CreateInstance(class [mscorlib]System.Type)
+ IL_000f: unbox.any !0
+ IL_0014: stloc.0
+ IL_0015: ldc.i4.5
+ IL_0016: newarr !0
+ IL_001b: stloc.1
+ IL_001c: ret
+ }
+ }
+
diff --git a/mcs/ilasm/tests/gen-meth2.il b/mcs/ilasm/tests/gen-meth2.il
new file mode 100644
index 00000000000..9d2b47cb9ae
--- /dev/null
+++ b/mcs/ilasm/tests/gen-meth2.il
@@ -0,0 +1,49 @@
+// Test : Using VAR/MVAR as class ref
+// Eg. !!B as a constraint
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly 'gen-meth2'
+{
+ .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = (
+ 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
+
+ .ver 0:0:0:0
+}
+.module meth2.dll
+
+
+ /* Incorrect, meaning-less code, but this is just to
+ check support for using VAR/MVAR as class refs */
+ .class private auto ansi beforefieldinit g`1<T>
+ extends !T
+ implements !T
+ {
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ /* Using !!B as a constraint */
+ .method public static hidebysig
+ default !!A foo< (!!B) A,B> (!!B _b, !T _t, !!A _a) cil managed
+ {
+ .maxstack 1
+ .locals init (
+ !!A V_0)
+ IL_0000: ldloca.s 0
+ IL_0002: initobj !!0
+ IL_0008: ldloc.0
+ IL_0009: ret
+ }
+
+ }
+
diff --git a/mcs/ilasm/tests/gen-meth3.il b/mcs/ilasm/tests/gen-meth3.il
new file mode 100644
index 00000000000..402e3d43a2d
--- /dev/null
+++ b/mcs/ilasm/tests/gen-meth3.il
@@ -0,0 +1,36 @@
+// Test for an abstract generic method
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly 'gen-meth3'
+{
+ .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = (
+ 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
+
+ .ver 0:0:0:0
+}
+.module 'gen-meth3.dll'
+
+ .class private auto ansi abstract beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+
+ .method family hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ .method public virtual hidebysig newslot abstract
+ instance default void foo<A> () cil managed
+ {
+ }
+
+ }
+
diff --git a/mcs/ilasm/tests/gen-nested.il b/mcs/ilasm/tests/gen-nested.il
new file mode 100644
index 00000000000..ab443eeebff
--- /dev/null
+++ b/mcs/ilasm/tests/gen-nested.il
@@ -0,0 +1,54 @@
+// Test for a generic class nested in a non-generic type
+// with interface using named generic param ref (!B)
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly 'gen-nested'
+{
+ .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = (
+ 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
+
+ .ver 0:0:0:0
+}
+.module 'gen-nested.dll'
+
+
+ .class interface private auto ansi abstract IFoo`1<T>
+ {
+
+ }
+
+ .class private auto ansi beforefieldinit outer
+ extends [mscorlib]System.Object
+ {
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ /* Generic class nested in a non-generic class */
+ .class nested private auto ansi beforefieldinit inner`2<A,B>
+ extends [mscorlib]System.Object
+ implements class IFoo`1<!B> {
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ }
+
+ }
+
diff --git a/mcs/ilasm/tests/gen-nested2.il b/mcs/ilasm/tests/gen-nested2.il
new file mode 100644
index 00000000000..681511e9a06
--- /dev/null
+++ b/mcs/ilasm/tests/gen-nested2.il
@@ -0,0 +1,55 @@
+// Test for specifying namespace as part of the type name,
+// instead of using .namespace directive. ildasm 2.0 uses
+// this style
+
+.assembly extern mscorlib
+{
+ .ver 1:0:5000:0
+}
+.assembly 'nested'
+{
+ .ver 0:0:0:0
+}
+.module nested.exe
+
+ .class private auto ansi beforefieldinit A.B
+ extends [mscorlib]System.Object
+ {
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ .class nested public auto ansi beforefieldinit C
+ extends [mscorlib]System.Object
+ {
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+ }
+
+ }
+ .class private auto ansi beforefieldinit test
+ extends A.B/C
+ {
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void class A.B/C::.ctor()
+ IL_0006: ret
+ }
+
+ }
+
diff --git a/mcs/ilasm/tests/gen-nested3.il b/mcs/ilasm/tests/gen-nested3.il
new file mode 100644
index 00000000000..8a247fcce1b
--- /dev/null
+++ b/mcs/ilasm/tests/gen-nested3.il
@@ -0,0 +1,60 @@
+// Test for specifying namespace as part of the type name,
+// AND also using .namespace
+
+.assembly extern mscorlib
+{
+ .ver 1:0:5000:0
+}
+.assembly 'nested'
+{
+ .ver 0:0:0:0
+}
+.module nested.exe
+
+.namespace ns {
+ .class private auto ansi beforefieldinit A.B
+ extends [mscorlib]System.Object
+ {
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ .class nested public auto ansi beforefieldinit C.D
+ extends [mscorlib]System.Object
+ {
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+ .class nested public auto ansi beforefieldinit further
+ extends [mscorlib]System.Object
+ {
+ }
+ }
+
+ }
+}
+ .class private auto ansi beforefieldinit test
+ extends ns.A.B/C.D
+ {
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void class ns.A.B/C.D::.ctor()
+ IL_0006: ret
+ }
+
+ }
+
diff --git a/mcs/ilasm/tests/gen-recur.il b/mcs/ilasm/tests/gen-recur.il
new file mode 100644
index 00000000000..c4184e15254
--- /dev/null
+++ b/mcs/ilasm/tests/gen-recur.il
@@ -0,0 +1,34 @@
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly 'gen-recur'
+{
+ .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = (
+ 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
+
+ .ver 0:0:0:0
+}
+.module 'gen-recur.dll'
+
+ .class interface private auto ansi abstract IFace`1<T>
+ {
+ }
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ /* class test, implements an interface whose generic arg is
+ test itself */
+ implements class IFace`1<class test> {
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ }
diff --git a/mcs/ilasm/tests/gen-struct.il b/mcs/ilasm/tests/gen-struct.il
new file mode 100644
index 00000000000..de33fcb3a87
--- /dev/null
+++ b/mcs/ilasm/tests/gen-struct.il
@@ -0,0 +1,47 @@
+// Test for generic valuetypes
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly extern one
+{
+ .ver 0:0:0:0
+}
+.assembly 'gen-struct'
+{
+ .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = (
+ 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
+
+ .ver 0:0:0:0
+}
+.module 'gen-struct.exe'
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ .method public static hidebysig
+ default void Main () cil managed
+ {
+ .entrypoint
+ .maxstack 1
+ .locals init (
+ valuetype [one]gen_struct`1<string> V_0)
+ IL_0000: ldloca.s 0
+ IL_0002: initobj valuetype [one]gen_struct`1<string>
+ IL_0008: call void valuetype [one]gen_struct`1<int32>::foo()
+ IL_000d: ret
+ }
+
+ }
diff --git a/mcs/ilasm/tests/generics-b.il b/mcs/ilasm/tests/generics-b.il
new file mode 100644
index 00000000000..0f23b9cc57f
--- /dev/null
+++ b/mcs/ilasm/tests/generics-b.il
@@ -0,0 +1,39 @@
+//
+// Test instantiating a generic type
+//
+
+.assembly extern mscorlib { }
+
+
+.namespace Mono.ILASM.Tests {
+
+ .class public Set<T> extends [mscorlib]System.Object {
+
+ .method public instance void .ctor () cil managed
+ {
+ ldarg.0
+ call instance void class [mscorlib]System.Object::.ctor()
+ ret
+ }
+ }
+
+ .class public GenericsB extends [mscorlib]System.Object {
+
+ .method public static void Main ()
+ {
+ .entrypoint
+ .locals init (class Mono.ILASM.Tests.Set<int32>)
+
+ newobj instance void class Mono.ILASM.Tests.Set<int32>::.ctor ()
+ stloc.0
+
+ ldloc.0
+ call void [mscorlib]System.Console::WriteLine (object)
+
+ ret
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/tests/generics-c.il b/mcs/ilasm/tests/generics-c.il
new file mode 100644
index 00000000000..71595d39e00
--- /dev/null
+++ b/mcs/ilasm/tests/generics-c.il
@@ -0,0 +1,42 @@
+//
+// Test a generic type type param field
+//
+
+.assembly extern mscorlib { }
+
+
+.namespace Mono.ILASM.Tests {
+
+ .class public Set<T> extends [mscorlib]System.Object {
+
+ .field public !0 val
+
+ .method public instance void .ctor () {
+ ret
+ }
+ }
+
+ .class public Driver extends [mscorlib]System.Object {
+
+ .method public static void Main ()
+ {
+ .entrypoint
+ .locals init (class Mono.ILASM.Tests.Set<int32>)
+
+ newobj instance void class Mono.ILASM.Tests.Set<int32>::.ctor ()
+ stloc.0
+
+ ldloc.0
+ ldc.i4.1
+ stfld int32 class Mono.ILASM.Tests.Set<int32>::val
+
+ ldloc.0
+ ldfld int32 class Mono.ILASM.Tests.Set<int32>::val
+ call void [mscorlib]System.Console::WriteLine (int32)
+
+ ret
+ }
+
+ }
+}
+
diff --git a/mcs/ilasm/tests/generics-d.il b/mcs/ilasm/tests/generics-d.il
new file mode 100644
index 00000000000..4186938bd8e
--- /dev/null
+++ b/mcs/ilasm/tests/generics-d.il
@@ -0,0 +1,59 @@
+//
+// Test a generic type type param field
+//
+
+.assembly extern mscorlib { }
+
+
+.namespace Mono.ILASM.Tests {
+
+ .class public Set<T> extends [mscorlib]System.Object {
+
+ .field public !0 val
+
+ .method public instance void .ctor (!0 arg) {
+ ldarg.0
+ ldarg.1
+ stfld !0 class Mono.ILASM.Tests.Set::val
+ ret
+ }
+
+ .method public instance !0 access () {
+ .locals init (!0)
+ ldarg.0
+ ldfld !0 class Mono.ILASM.Tests.Set::val
+ // just to make sure locals work, too
+ stloc.0
+ ldloc.0
+ ret
+ }
+ }
+
+ .class public Driver extends [mscorlib]System.Object {
+
+ .method public static void Main ()
+ {
+ .entrypoint
+ .locals init ( class Mono.ILASM.Tests.Set<int32>,
+ class Mono.ILASM.Tests.Set<float64>)
+
+ ldc.i4.4
+ newobj instance void class Mono.ILASM.Tests.Set<int32>::.ctor (int32)
+ stloc.0
+
+ ldloc.0
+ call instance int32 class Mono.ILASM.Tests.Set<int32>::access ()
+ call void [mscorlib]System.Console::WriteLine (int32)
+
+ ldc.r8 35.6
+ newobj instance void class Mono.ILASM.Tests.Set<float64>::.ctor (float64)
+ stloc.1
+
+ ldloc.1
+ call instance float64 class Mono.ILASM.Tests.Set<float64>::access ()
+ call void [mscorlib]System.Console::WriteLine (float64) ret
+ }
+
+ }
+}
+
diff --git a/mcs/ilasm/tests/global.il b/mcs/ilasm/tests/global.il
new file mode 100644
index 00000000000..7a87090da94
--- /dev/null
+++ b/mcs/ilasm/tests/global.il
@@ -0,0 +1,39 @@
+//Tests global generic methods
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly ca
+{
+ .ver 0:0:0:0
+}
+.module ca.dll
+
+//Global Method
+ .method public hidebysig static void foo<A,B>() cil managed
+ {
+ .maxstack 8
+ IL_0000: ret
+ }
+
+.class private auto ansi beforefieldinit abc`1<Z>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ }
+
+ .method public hidebysig static void bar() cil managed
+ {
+ .maxstack 8
+ IL_0000: call void foo<!Z,string>()
+ IL_0005: ret
+ }
+
+}
diff --git a/mcs/ilasm/tests/invalid-field.il b/mcs/ilasm/tests/invalid-field.il
new file mode 100644
index 00000000000..f2f16ace050
--- /dev/null
+++ b/mcs/ilasm/tests/invalid-field.il
@@ -0,0 +1,34 @@
+// Test for ref to an non-existant field
+
+.assembly extern mscorlib
+{
+ .ver 1:0:5000:0
+}
+.assembly 'invalid-field'
+{
+}
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ .method public hidebysig
+ instance default void foo () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: ldc.i4.5
+ IL_0002: stfld int32 test::invalid
+ IL_0007: ret
+ }
+
+ }
+
diff --git a/mcs/ilasm/tests/invalid-method.il b/mcs/ilasm/tests/invalid-method.il
new file mode 100644
index 00000000000..9075db86b8e
--- /dev/null
+++ b/mcs/ilasm/tests/invalid-method.il
@@ -0,0 +1,33 @@
+// Test for ref to an non-existant method
+
+.assembly extern mscorlib
+{
+ .ver 1:0:5000:0
+}
+.assembly 'invalid-method'
+{
+}
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ .method public hidebysig
+ instance default void foo () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void class test::bar()
+ IL_0006: ret
+ }
+
+ }
diff --git a/mcs/ilasm/tests/nested.il b/mcs/ilasm/tests/nested.il
new file mode 100644
index 00000000000..16fbf37e745
--- /dev/null
+++ b/mcs/ilasm/tests/nested.il
@@ -0,0 +1,70 @@
+//nested classes 'nested_private' and 'nested_public' don't have
+//nested visibility set. ilasm should it accordingly.
+
+.assembly extern mscorlib
+{
+ .ver 1:0:5000:0
+ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+}
+.assembly 'nested'
+{
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module nested.dll // GUID = {3C1BE155-805F-4170-ACEB-D97A86B467A2}
+
+
+ .class private auto ansi beforefieldinit outer
+ extends [mscorlib]System.Object
+ {
+
+ // method line 1
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ // Method begins at RVA 0x20ec
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ } // end of method outer::instance default void .ctor ()
+
+ .class auto ansi beforefieldinit nested_private
+ extends [mscorlib]System.Object
+ {
+
+ // method line 2
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ // Method begins at RVA 0x20f4
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ } // end of method nested_private::instance default void .ctor ()
+
+ } // end of class nested_private
+
+ .class public auto ansi beforefieldinit nested_public
+ extends [mscorlib]System.Object
+ {
+
+ // method line 3
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ // Method begins at RVA 0x20fc
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ } // end of method nested_public::instance default void .ctor ()
+
+ } // end of class nested_public
+
+ } // end of class outer
+
diff --git a/mcs/ilasm/tests/one.cs b/mcs/ilasm/tests/one.cs
new file mode 100644
index 00000000000..e0037294fd4
--- /dev/null
+++ b/mcs/ilasm/tests/one.cs
@@ -0,0 +1,39 @@
+public class outer {
+ public class inner {
+ }
+}
+
+public class gen <T> {
+ public static void foo ()
+ {
+ }
+}
+
+namespace ns {
+ public class gen_m <T> {
+ public static void foo ()
+ {
+ }
+ public static void foo <A> (A _a)
+ {
+ }
+ public static void foo <A, B> (A _a)
+ {
+ }
+ }
+}
+
+public interface If1 <T> {
+}
+
+public interface If2 <T> {
+}
+
+public interface If3 {
+}
+
+public struct gen_struct <T> {
+ public static void foo ()
+ {
+ }
+}
diff --git a/mcs/ilasm/tests/oneg.cs b/mcs/ilasm/tests/oneg.cs
new file mode 100644
index 00000000000..5f895258ada
--- /dev/null
+++ b/mcs/ilasm/tests/oneg.cs
@@ -0,0 +1,4 @@
+public class outer {
+ public class inner<T> {
+ }
+}
diff --git a/mcs/ilasm/tests/sn.snk b/mcs/ilasm/tests/sn.snk
new file mode 100755
index 00000000000..c6f4f7bf2c2
--- /dev/null
+++ b/mcs/ilasm/tests/sn.snk
Binary files differ
diff --git a/mcs/ilasm/tests/test-1.il b/mcs/ilasm/tests/test-1.il
new file mode 100644
index 00000000000..d1503a10479
--- /dev/null
+++ b/mcs/ilasm/tests/test-1.il
@@ -0,0 +1,27 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern mscorlib { }
+
+//
+// Declare a namespace, a class, and a method
+//
+
+.namespace Mono.ILASM.Tests {
+
+ .class public auto ansi Test_1 extends [mscorlib]System.Object {
+
+ .method public static void check(string) cil managed {
+ .entrypoint
+ .maxstack 1
+
+ nop
+ }
+ }
+}
+
diff --git a/mcs/ilasm/tests/test-10.il b/mcs/ilasm/tests/test-10.il
new file mode 100644
index 00000000000..b48487d22ae
--- /dev/null
+++ b/mcs/ilasm/tests/test-10.il
@@ -0,0 +1,28 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern mscorlib { }
+
+
+//
+// Create some bound arrays
+//
+
+.namespace Mono.ILASM.Tests {
+
+ .class public auto ansi Test_10 extends [mscorlib]System.Object {
+
+ .method public static void check(string) cil managed {
+ .entrypoint
+ .locals init (int32[0...,0...] local_0,
+ int32[...,...] local_1, int32[2...5],
+ int32[0,0], int32 [0...2,1...4,1...])
+ ret
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/ilasm/tests/test-11.il b/mcs/ilasm/tests/test-11.il
new file mode 100644
index 00000000000..37c76eaaab7
--- /dev/null
+++ b/mcs/ilasm/tests/test-11.il
@@ -0,0 +1,21 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern mscorlib { }
+
+//
+// Create a generic type
+//
+
+.namespace Mono.ILASM.Tests {
+
+ .class public Test_11<T> extends [mscorlib]System.Object {
+
+ }
+
+} \ No newline at end of file
diff --git a/mcs/ilasm/tests/test-12.il b/mcs/ilasm/tests/test-12.il
new file mode 100644
index 00000000000..66a26e1d93c
--- /dev/null
+++ b/mcs/ilasm/tests/test-12.il
@@ -0,0 +1,23 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern mscorlib { }
+
+//
+// Create a generic type and a generic method
+//
+
+.namespace Mono.ILASM.Tests {
+
+ .class public Test_12<int32> extends [mscorlib]System.Object {
+
+ .method void meth<int32> () {
+
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/ilasm/tests/test-13.il b/mcs/ilasm/tests/test-13.il
new file mode 100644
index 00000000000..46990001f5e
--- /dev/null
+++ b/mcs/ilasm/tests/test-13.il
@@ -0,0 +1,19 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern mscorlib { }
+
+//
+// Create a global field
+//
+
+.namespace Mono.ILASM.Tests {
+
+ .field object global_field
+
+} \ No newline at end of file
diff --git a/mcs/ilasm/tests/test-14.il b/mcs/ilasm/tests/test-14.il
new file mode 100644
index 00000000000..d9b39ecd44f
--- /dev/null
+++ b/mcs/ilasm/tests/test-14.il
@@ -0,0 +1,25 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern corlib { }
+
+
+.namespace Mono.ILASM.Tests {
+
+ .class public auto ansi Test_14 extends [corlib]System.Object {
+
+ .method public static void check (string[] args) cil managed {
+ ldarg 0
+ ldarg 1
+
+ pop
+ pop
+ }
+
+ }
+}
diff --git a/mcs/ilasm/tests/test-15.il b/mcs/ilasm/tests/test-15.il
new file mode 100644
index 00000000000..e10a6d2f2f3
--- /dev/null
+++ b/mcs/ilasm/tests/test-15.il
@@ -0,0 +1,28 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern corlib { }
+
+.namespace Mono.ILASM.Tests {
+
+ .class public auto ansi Test_14 extends [corlib]System.Object {
+
+ }
+
+
+ .class public auto ansi A extends [corlib]System.Object {
+
+ .field public class Mono.ILASM.Tests.B b
+ }
+
+ .class public auto ansi B extends Mono.ILASM.Tests.A {
+
+ .field public class Mono.ILASM.Tests.A a
+ }
+
+}
diff --git a/mcs/ilasm/tests/test-16.il b/mcs/ilasm/tests/test-16.il
new file mode 100644
index 00000000000..186bce7bcc6
--- /dev/null
+++ b/mcs/ilasm/tests/test-16.il
@@ -0,0 +1,25 @@
+
+
+.namespace System {
+
+ .class public Type extends System.Reflection.MemberInfo
+ {
+
+ }
+}
+
+
+.namespace System.Reflection {
+
+ .class public MemberInfo extends [mscorlib]System.Object
+ {
+
+ .method instance class System.Type get_ReflectedType() cil managed
+ {
+
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/tests/test-17.il b/mcs/ilasm/tests/test-17.il
new file mode 100644
index 00000000000..7601d271f5a
--- /dev/null
+++ b/mcs/ilasm/tests/test-17.il
@@ -0,0 +1,27 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern corlib { }
+
+.namespace Mono.ILASM.Tests {
+
+ .class public auto ansi Test_17 extends [corlib]System.Object {
+
+ .method public static void check( ) cil managed {
+ br IL_TRUE
+
+ IL_LABEL: nop
+ IL_FALSE: nop
+ IL_TRUE: nop
+
+ ret
+ }
+
+ }
+
+}
diff --git a/mcs/ilasm/tests/test-18.il b/mcs/ilasm/tests/test-18.il
new file mode 100644
index 00000000000..7c3d484a883
--- /dev/null
+++ b/mcs/ilasm/tests/test-18.il
@@ -0,0 +1,30 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern corlib { }
+
+.namespace Mono.ILASM.Tests {
+
+ .class public auto ansi Test_18 extends [corlib]System.Object {
+
+ .method public static void check( ) cil managed {
+
+ switch (label1, label2, label3)
+ label1:
+ nop
+ label2:
+ nop
+ label3:
+ nop
+
+ ret
+ }
+
+ }
+
+}
diff --git a/mcs/ilasm/tests/test-19.il b/mcs/ilasm/tests/test-19.il
new file mode 100644
index 00000000000..69c21f60659
--- /dev/null
+++ b/mcs/ilasm/tests/test-19.il
@@ -0,0 +1,24 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern corlib { }
+
+.namespace Mono.ILASM.Tests {
+
+ .class public auto ansi Test_19 extends [corlib]System.Object {
+
+ .method public static void check( ) cil managed {
+ .locals init ([3]float32 ff, [2]float64 dd,
+ [1]object oo, [0]string ss)
+
+ ret
+ }
+
+ }
+
+}
diff --git a/mcs/ilasm/tests/test-2.il b/mcs/ilasm/tests/test-2.il
new file mode 100644
index 00000000000..9e3db00a5ce
--- /dev/null
+++ b/mcs/ilasm/tests/test-2.il
@@ -0,0 +1,33 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern mscorlib { }
+
+//
+// Declare a local object instantiate it and print it to stdout
+//
+
+.namespace Mono.ILASM.Tests {
+
+ .class public auto ansi Test_2 extends [mscorlib]System.Object {
+
+ .method public static void main () cil managed {
+ .entrypoint
+ .maxstack 1
+ .locals init (object obj)
+
+ newobj instance void [mscorlib]System.Object::.ctor()
+ stloc.0
+ ldloc.0
+ call void [mscorlib]System.Console::WriteLine(object)
+
+ ret
+ }
+ }
+}
+
diff --git a/mcs/ilasm/tests/test-20.il b/mcs/ilasm/tests/test-20.il
new file mode 100644
index 00000000000..989f4259e4e
--- /dev/null
+++ b/mcs/ilasm/tests/test-20.il
@@ -0,0 +1,29 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern corlib { }
+
+.namespace Mono.ILASM.Tests {
+
+ .method public static void global_method () {
+ ldstr "PASS"
+ call void [corlib]System.Console::WriteLine (string)
+ ret
+ }
+
+ .class public auto ansi Test_20 extends [corlib]System.Object {
+
+ .method public static void check( ) cil managed {
+ .entrypoint
+ call void global_method ()
+ ret
+ }
+
+ }
+
+}
diff --git a/mcs/ilasm/tests/test-21.il b/mcs/ilasm/tests/test-21.il
new file mode 100644
index 00000000000..5dfdd1cfba1
--- /dev/null
+++ b/mcs/ilasm/tests/test-21.il
@@ -0,0 +1,27 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern corlib { }
+
+.namespace Mono.ILASM.Tests {
+
+
+ .class public auto ansi Test_21 extends [corlib]System.Object {
+
+ .method public static void check( ) cil managed {
+ .entrypoint
+ ldsflda string [corlib]System.String::Empty
+
+ call void [corlib]System.Console::WriteLine (string)
+
+ ret
+ }
+
+ }
+
+}
diff --git a/mcs/ilasm/tests/test-22.il b/mcs/ilasm/tests/test-22.il
new file mode 100644
index 00000000000..4f88d6e4ba3
--- /dev/null
+++ b/mcs/ilasm/tests/test-22.il
@@ -0,0 +1,28 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern corlib { }
+
+.namespace Mono.ILASM.Tests {
+
+ .field public static string global_field = "jackson"
+
+ .class public auto ansi Test_22 extends [corlib]System.Object {
+
+ .method public static void check( ) cil managed {
+ .entrypoint
+
+ ldfld string global_field
+ call void [corlib]System.Console::WriteLine (string)
+
+ ret
+ }
+
+ }
+
+}
diff --git a/mcs/ilasm/tests/test-23.il b/mcs/ilasm/tests/test-23.il
new file mode 100644
index 00000000000..7d88ce4a0fc
--- /dev/null
+++ b/mcs/ilasm/tests/test-23.il
@@ -0,0 +1,18 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern corlib { }
+
+.namespace Mono.ILASM.Tests {
+
+ .class public explicit ansi Test_23 extends [corlib]System.Object {
+ .pack 0
+ .size 10
+ }
+
+}
diff --git a/mcs/ilasm/tests/test-24.il b/mcs/ilasm/tests/test-24.il
new file mode 100644
index 00000000000..7153cf383a5
--- /dev/null
+++ b/mcs/ilasm/tests/test-24.il
@@ -0,0 +1,34 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+.assembly extern corlib { }
+
+.namespace Mono.ILASM.Tests {
+
+ .field private static string global_string
+
+ .method private static void .cctor ()
+ {
+ ldstr "PASS"
+ stsfld string global_string
+ ret
+ }
+
+ .method public static void Main ()
+ {
+ .entrypoint
+
+ ldsfld string global_string
+
+ call void [mscorlib]System.Console::WriteLine (string)
+
+ ret
+ }
+
+}
diff --git a/mcs/ilasm/tests/test-25.il b/mcs/ilasm/tests/test-25.il
new file mode 100644
index 00000000000..a9419604571
--- /dev/null
+++ b/mcs/ilasm/tests/test-25.il
@@ -0,0 +1,30 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern corlib { }
+
+.namespace Mono.ILASM.Tests {
+
+ .class public Test_25 {
+
+ .method public static void Main ()
+ {
+
+ .entrypoint
+ .locals init (char[] cha)
+
+ ldc.i4 10
+ newobj instance void valuetype
+ [mscorlib]System.Char[]::.ctor (int32)
+ pop
+
+ ret
+ }
+ }
+}
+
diff --git a/mcs/ilasm/tests/test-26.il b/mcs/ilasm/tests/test-26.il
new file mode 100644
index 00000000000..61325fda766
--- /dev/null
+++ b/mcs/ilasm/tests/test-26.il
@@ -0,0 +1,33 @@
+
+
+.assembly extern mscorlib {
+
+}
+
+
+.class public Test {
+
+ .method public static void main ()
+ {
+ .entrypoint
+
+ try_begin:
+ ldstr "BEGIN TRY"
+ call void [mscorlib]System.Console::WriteLine (string)
+
+ leave try_end
+ exc_handler:
+ ldstr "IN HANDLER"
+ call void [mscorlib]System.Console::WriteLine (string)
+
+ leave try_end
+ try_end:
+ ldstr "END TRY"
+ call void [mscorlib]System.Console::WriteLine (string)
+
+ .try try_begin to try_end catch [mscorlib]System.Exception handler exc_handler to try_end
+
+ }
+
+}
+
diff --git a/mcs/ilasm/tests/test-27.il b/mcs/ilasm/tests/test-27.il
new file mode 100644
index 00000000000..93ca36f6c8b
--- /dev/null
+++ b/mcs/ilasm/tests/test-27.il
@@ -0,0 +1,41 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Ben Maurer
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Ben Maurer, All rights reserved
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+.class public Bug {
+.method public static int32 main(class [mscorlib]System.String[]) {
+.entrypoint
+.maxstack 8
+ ldc.i4 0
+ ldc.i4 0
+ ceq
+ brfalse FAIL
+
+try_start:
+ leave try_end
+try_end:
+
+handler:
+ leave FAIL
+end_handler:
+ br PASS
+
+PASS:
+ ldc.i4 0
+ ret
+FAIL:
+ ldc.i4 1
+ ret
+.try try_start to try_end catch [mscorlib]System.Exception handler
+handler to end_handler
+}
+}
+
+
diff --git a/mcs/ilasm/tests/test-28.il b/mcs/ilasm/tests/test-28.il
new file mode 100644
index 00000000000..7a5ce413ab2
--- /dev/null
+++ b/mcs/ilasm/tests/test-28.il
@@ -0,0 +1,25 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+.class public Test {
+
+ .custom instance void [mscorlib]System.CLSCompliantAttribute::.ctor(bool) = ( 01 00 01 00 00 )
+
+ .method public static int32 main () {
+ .custom instance void [mscorlib]System.CLSCompliantAttribute::.ctor(bool) = ( 01 00 01 00 00 )
+
+ .entrypoint
+ .maxstack 20
+
+ nop
+ }
+
+}
+
diff --git a/mcs/ilasm/tests/test-3.il b/mcs/ilasm/tests/test-3.il
new file mode 100644
index 00000000000..8724c3fe138
--- /dev/null
+++ b/mcs/ilasm/tests/test-3.il
@@ -0,0 +1,35 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern corlib { }
+
+//
+// Define a method and execute that method
+//
+
+.namespace Mono.ILASM.Tests {
+
+ .class public auto ansi Test_3 extends [corlib]System.Object {
+
+ .method public static void check( ) cil managed {
+ .entrypoint
+ .maxstack 1
+
+ call void Mono.ILASM.Tests.Test_3::print_hello()
+
+ ret
+ }
+
+ .method private static void print_hello() cil managed {
+ ldstr "PASS"
+ call void [corlib]System.Console::WriteLine(string)
+ }
+
+ }
+}
+
diff --git a/mcs/ilasm/tests/test-30.il b/mcs/ilasm/tests/test-30.il
new file mode 100644
index 00000000000..ccbaba715ff
--- /dev/null
+++ b/mcs/ilasm/tests/test-30.il
@@ -0,0 +1,40 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern corlib { }
+
+.namespace Mono.ILASM.Tests {
+
+ .class public EventTest {
+
+ .method public void Subscribe ()
+ {
+ ldstr "Mono.ILASM.Tests.EventTest::Subscribe ()"
+ call void [mscorlib]System.Console::WriteLine (string)
+ }
+
+ .method public void Unsubscribe ()
+ {
+ ldstr "Mono.ILASM.Tests.EventTest::Unsubscribe ()"
+ call void [mscorlib]System.Console::WriteLine (string)
+ }
+
+ .method public void Raise ()
+ {
+ ldstr "Mono.ILASM.Tests.EventTest::Raise ()"
+ call void [mscorlib]System.Console::WriteLine (string)
+ }
+
+ .event [mscorlib]System.Delegate LeEvent
+ {
+ .addon instance void Mono.ILASM.Tests.EventTest::Subscribe ()
+ .removeon instance void Mono.ILASM.Tests.EventTest::Unsubscribe ()
+ .fire instance void Mono.ILASM.Tests.EventTest::Raise ()
+ }
+ }
+}
diff --git a/mcs/ilasm/tests/test-31.il b/mcs/ilasm/tests/test-31.il
new file mode 100644
index 00000000000..19d7b454dc0
--- /dev/null
+++ b/mcs/ilasm/tests/test-31.il
@@ -0,0 +1,61 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern corlib { }
+
+.namespace Mono.ILASM.Tests {
+
+ .class public PropertyTest {
+
+ .method public int32 get_foo ()
+ {
+ ldc.i4.1
+ ret
+ }
+
+ .method public void set_foo (int32)
+ {
+ ret
+ }
+
+ .method public void other_foo ()
+ {
+ ret
+ }
+
+ .method static public int32 get_static_foo ()
+ {
+ ldc.i4.1
+ ret
+ }
+
+ .method static public void set_static_foo (int32)
+ {
+ ret
+ }
+
+ .method static public void other_static_foo ()
+ {
+ ret
+ }
+
+ .property int32 foo (int32) = int32 (0xFFFFFFFF)
+ {
+ .get instance int32 Mono.ILASM.Tests.PropertyTest::get_foo ()
+ .set instance void Mono.ILASM.Tests.PropertyTest::set_foo (int32)
+ .other instance void Mono.ILASM.Tests.PropertyTest::other_foo ()
+ }
+
+ .property int32 static_foo ()
+ {
+ .get int32 Mono.ILASM.Tests.PropertyTest::get_static_foo ()
+ .set int32 Mono.ILASM.Tests.PropertyTest::set_static_foo (int32)
+ .other void Mono.ILASM.Tests.PropertyTest::other_foo ()
+ }
+ }
+}
diff --git a/mcs/ilasm/tests/test-32.il b/mcs/ilasm/tests/test-32.il
new file mode 100644
index 00000000000..b225f9de11b
--- /dev/null
+++ b/mcs/ilasm/tests/test-32.il
@@ -0,0 +1,42 @@
+//
+// Mono.ILASM.Tests.Test32
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+.assembly extern mscorlib { }
+
+.namespace Mono.ILASM.Tests {
+
+ .class public Test32 {
+
+
+ //
+ // Test using explicit offsets for branch labels
+ //
+ .method public static int32 main ()
+ {
+ .entrypoint
+
+ ldc.i4.1
+ brtrue 15
+
+ ldstr "FAIL"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.1
+ ret
+
+ ldstr "PASS"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.0
+
+ ret
+ }
+
+ }
+
+}
+
diff --git a/mcs/ilasm/tests/test-33.il b/mcs/ilasm/tests/test-33.il
new file mode 100644
index 00000000000..3e74b26e344
--- /dev/null
+++ b/mcs/ilasm/tests/test-33.il
@@ -0,0 +1,75 @@
+.assembly extern mscorlib
+{
+}
+.assembly bb
+{
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module bb.exe
+
+.class private auto ansi beforefieldinit GenParAttribute
+ extends [mscorlib]System.Attribute
+{
+ .custom instance void [mscorlib]System.AttributeUsageAttribute::.ctor(valuetype [mscorlib]System.AttributeTargets) = ( 01 00 00 40 00 00 00 00 )
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Attribute::.ctor()
+ IL_0006: ret
+ }
+
+}
+
+.class private auto ansi beforefieldinit cons`1<A>
+ extends [mscorlib]System.Object
+{
+ .param type A
+ .custom instance void GenParAttribute::.ctor() = ( 01 00 00 00 )
+
+ .method public hidebysig instance void
+ abc<M>() cil managed
+ {
+ .param type M
+ .custom instance void GenParAttribute::.ctor() = ( 01 00 00 00 )
+
+ .maxstack 8
+ IL_0000: nop
+ IL_0001: ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ }
+
+}
+
+.class private auto ansi beforefieldinit Test
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig static void Main() cil managed
+ {
+ .entrypoint
+ .maxstack 8
+ IL_0000: nop
+ IL_0001: ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ }
+
+}
diff --git a/mcs/ilasm/tests/test-34.il b/mcs/ilasm/tests/test-34.il
new file mode 100644
index 00000000000..739edad7867
--- /dev/null
+++ b/mcs/ilasm/tests/test-34.il
@@ -0,0 +1,76 @@
+.assembly extern mscorlib
+{
+}
+.assembly bb
+{
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module bb.exe
+
+.class private auto ansi beforefieldinit GenParAttribute
+ extends [mscorlib]System.Attribute
+{
+ .custom instance void [mscorlib]System.AttributeUsageAttribute::.ctor(valuetype [mscorlib]System.AttributeTargets) = ( 01 00 00 40 00 00 00 00 )
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Attribute::.ctor()
+ IL_0006: ret
+ }
+
+}
+
+.class private auto ansi beforefieldinit cons`1<A>
+ extends [mscorlib]System.Object
+{
+ .param type [1]
+ .custom instance void GenParAttribute::.ctor() = ( 01 00 00 00 )
+ .method public hidebysig instance void
+ abc<M>() cil managed
+ {
+ .param type [1]
+ .custom instance void GenParAttribute::.ctor() = ( 01 00 00 00 )
+ // Code size 2 (0x2)
+ .maxstack 8
+ IL_0000: nop
+ IL_0001: ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ }
+
+}
+
+.class private auto ansi beforefieldinit Test
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig static void Main() cil managed
+ {
+ .entrypoint
+ // Code size 2 (0x2)
+ .maxstack 8
+ IL_0000: nop
+ IL_0001: ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ }
+
+}
+
diff --git a/mcs/ilasm/tests/test-4.il b/mcs/ilasm/tests/test-4.il
new file mode 100644
index 00000000000..b79a85beed3
--- /dev/null
+++ b/mcs/ilasm/tests/test-4.il
@@ -0,0 +1,36 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern corlib { }
+
+//
+// Pass a param to a method
+//
+
+.namespace Mono.ILASM.Tests {
+
+ .class public auto ansi Test_4 extends [corlib]System.Object {
+
+ .method public static void check( ) cil managed {
+ .entrypoint
+ .maxstack 1
+
+ ldstr "PASS"
+ call void Mono.ILASM.Tests.Test_4::print_string(string)
+
+ ret
+ }
+
+ .method private static void print_string(string) cil managed {
+ ldarg.0
+ call void [corlib]System.Console::WriteLine(string)
+ }
+
+ }
+}
+
diff --git a/mcs/ilasm/tests/test-5.il b/mcs/ilasm/tests/test-5.il
new file mode 100644
index 00000000000..223d36244a3
--- /dev/null
+++ b/mcs/ilasm/tests/test-5.il
@@ -0,0 +1,25 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern mscorlib { }
+
+//
+// Define a field
+//
+
+.namespace Mono.ILASM.Tests {
+
+ .class public auto ansi Test_5 extends [mscorlib]System.Object {
+
+ /// <summary>
+ /// field that references a primative type
+ /// </summary>
+ .field public string int_field
+ }
+}
+
diff --git a/mcs/ilasm/tests/test-6.il b/mcs/ilasm/tests/test-6.il
new file mode 100644
index 00000000000..bb809cae502
--- /dev/null
+++ b/mcs/ilasm/tests/test-6.il
@@ -0,0 +1,26 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern mscorlib { }
+
+//
+// Define classes outside of namespaces, also define a field that
+// references a type in this assembly
+//
+
+.class public auto ansi Test_6 extends [mscorlib]System.Object {
+
+ /// <summary>
+ /// Field that references a type in this assembly
+ /// </summary>
+ .field public class A a_field
+}
+
+.class public auto ansi A extends [mscorlib]System.Object {
+
+}
diff --git a/mcs/ilasm/tests/test-7.il b/mcs/ilasm/tests/test-7.il
new file mode 100644
index 00000000000..8de95a0d1a6
--- /dev/null
+++ b/mcs/ilasm/tests/test-7.il
@@ -0,0 +1,28 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern mscorlib { }
+.assembly extern Cscompmgd { }
+
+
+//
+// Define a method that references a type in another assembly (that is
+// not corlib)
+//
+
+.namespace Mono.ILASM.Tests {
+
+ .class public auto ansi Test_7 extends [mscorlib]System.Object {
+
+ /// <summary>
+ /// field that references an external type
+ /// </summary>
+ .field public [Cscompmgd]Microsoft.CSharp.Compiler a_compiler
+ }
+}
+
diff --git a/mcs/ilasm/tests/test-8.il b/mcs/ilasm/tests/test-8.il
new file mode 100644
index 00000000000..9e6fd1ae538
--- /dev/null
+++ b/mcs/ilasm/tests/test-8.il
@@ -0,0 +1,23 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern mscorlib { }
+
+//
+// Implement an interface
+//
+
+.namespace Mono.ILASM.Tests {
+
+ .class public auto ansi Test_8
+ extends [mscorlib]System.Collections.ArrayList
+ implements [mscorlib]System.Collections.IList {
+
+ }
+}
+
diff --git a/mcs/ilasm/tests/test-9.il b/mcs/ilasm/tests/test-9.il
new file mode 100644
index 00000000000..db967816569
--- /dev/null
+++ b/mcs/ilasm/tests/test-9.il
@@ -0,0 +1,41 @@
+//
+// Mono.ILASM.Tests
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+.assembly extern mscorlib { }
+
+//
+// Call a constructor for a type defined in this assembly
+//
+
+.namespace Mono.ILASM.Tests {
+
+ .class public auto ansi A extends [mscorlib]System.Object
+ {
+
+ .method public instance void .ctor () cil managed
+ {
+ ldstr "In Constructor"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ret
+ }
+
+ }
+
+ .class public auto ansi Test_9 extends [mscorlib]System.Object
+ {
+
+ .method public static void main (string) cil managed {
+ .entrypoint
+ newobj void Mono.ILASM.Tests.A::.ctor ()
+ pop
+ ret
+ }
+ }
+
+}
+
diff --git a/mcs/ilasm/tests/test-array-2.il b/mcs/ilasm/tests/test-array-2.il
new file mode 100644
index 00000000000..91dd8f9965b
--- /dev/null
+++ b/mcs/ilasm/tests/test-array-2.il
@@ -0,0 +1,41 @@
+// Test for methodref for array methods
+// Eg. class test [,]::.ctor (int32, int32)
+
+.assembly extern mscorlib
+{
+ .ver 1:0:5000:0
+}
+.assembly 'test-array'
+{
+ .ver 0:0:0:0
+}
+.module 'test-array.exe'
+
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ .method public static hidebysig
+ default void Main () cil managed
+ {
+ .entrypoint
+ .maxstack 3
+ .locals init (
+ class test[,] V_0)
+ IL_0000: ldc.i4.1
+ IL_0001: ldc.i4.1
+ IL_0002: newobj instance void class test[,]::.ctor(int32, int32)
+ IL_0007: stloc.0
+ IL_0008: ret
+ }
+
+ }
diff --git a/mcs/ilasm/tests/test-array.il b/mcs/ilasm/tests/test-array.il
new file mode 100644
index 00000000000..7b3ab29af45
--- /dev/null
+++ b/mcs/ilasm/tests/test-array.il
@@ -0,0 +1,20 @@
+//Test for tokenizing : 0...8
+//Bug# 76977
+
+.namespace MonoTest
+{
+.class private auto autochar beforefieldinit ConsoleApp extends
+[mscorlib]System.Object
+{
+ .method assembly hidebysig static void
+ Test() cil managed
+ {
+ // Code size 74 (0x4a)
+ .maxstack 2
+
+ .locals init (unsigned int8[0...8] V_0)
+
+ ret
+ }
+}
+}
diff --git a/mcs/ilasm/tests/test-assembly2.il b/mcs/ilasm/tests/test-assembly2.il
new file mode 100644
index 00000000000..953d8e9cdd2
--- /dev/null
+++ b/mcs/ilasm/tests/test-assembly2.il
@@ -0,0 +1,16 @@
+// Referencing an undeclared external assembly
+
+.assembly extern mscorlib
+{
+}
+.assembly 'test-fixedarray'
+{
+}
+
+ .class public sequential ansi beforefieldinit Dummy
+ extends [mscorlib]System.Object
+ {
+ .pack 0
+ .size 1024
+ .field public class [not_referenced]Test t
+ }
diff --git a/mcs/ilasm/tests/test-bounded-array.il b/mcs/ilasm/tests/test-bounded-array.il
new file mode 100644
index 00000000000..64e7651a6df
--- /dev/null
+++ b/mcs/ilasm/tests/test-bounded-array.il
@@ -0,0 +1,28 @@
+//Test case for #76976
+//uint8[0...] should not lose its lower-bound info
+
+.assembly extern mscorlib
+{
+}
+.assembly Output
+{
+ .ver 1:0:0:0
+}
+.module Output
+
+.class private auto autochar beforefieldinit Test
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig static void Main() cil managed
+ {
+ .entrypoint
+ .maxstack 2
+ .locals init (uint8[8] V_0,
+ int32 V_1)
+ ldc.i4.8
+ newobj instance void uint8[0...]::.ctor(int32)
+ pop
+ ret
+ }
+
+}
diff --git a/mcs/ilasm/tests/test-byref.il b/mcs/ilasm/tests/test-byref.il
new file mode 100644
index 00000000000..838a7b20f10
--- /dev/null
+++ b/mcs/ilasm/tests/test-byref.il
@@ -0,0 +1,39 @@
+//Test for call to a method returning a byref
+.assembly extern mscorlib
+{
+}
+.assembly 'test-byref'
+{
+}
+
+ .class public auto ansi beforefieldinit Test
+ extends [mscorlib]System.Object
+ {
+ .field private float64[,] _data
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ .method public hidebysig
+ instance default void multByTwo () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: ldfld float64[,] Test::_data
+ IL_0006: ldc.i4.0
+ IL_0007: ldc.i4.0
+ IL_0008: call instance float64& float64[,]::Address(int32, int32)
+ IL_000d: dup
+ IL_000e: ldind.r8
+ IL_000f: ldc.r8 4
+ IL_0018: mul
+ IL_0019: stind.r8
+ IL_001a: ret
+ }
+ }
diff --git a/mcs/ilasm/tests/test-cattr-declsec.il b/mcs/ilasm/tests/test-cattr-declsec.il
new file mode 100644
index 00000000000..d3c87c30ff4
--- /dev/null
+++ b/mcs/ilasm/tests/test-cattr-declsec.il
@@ -0,0 +1,109 @@
+// Test to make sure that .permissionset and the custom attribute
+// survive ilasm for abstract methods and interfaces
+
+.assembly extern mscorlib
+{
+}
+.assembly 'dispid'
+{
+}
+.module dispid.dll
+
+
+ .class interface public auto ansi abstract foo
+ {
+ .custom instance void class [mscorlib]System.Runtime.InteropServices.DispIdAttribute::.ctor(int32) = (01 00 FC FF FF FF 00 00 ) // ........
+
+ .permissionset deny = (
+ 3C 00 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 // <.P.e.r.m.i.s.s.
+ 69 00 6F 00 6E 00 53 00 65 00 74 00 20 00 63 00 // i.o.n.S.e.t. .c.
+ 6C 00 61 00 73 00 73 00 3D 00 22 00 53 00 79 00 // l.a.s.s.=.".S.y.
+ 73 00 74 00 65 00 6D 00 2E 00 53 00 65 00 63 00 // s.t.e.m...S.e.c.
+ 75 00 72 00 69 00 74 00 79 00 2E 00 50 00 65 00 // u.r.i.t.y...P.e.
+ 72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
+ 53 00 65 00 74 00 22 00 0A 00 20 00 20 00 20 00 // S.e.t."... . . .
+ 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // . . . . . . . .
+ 20 00 20 00 20 00 20 00 76 00 65 00 72 00 73 00 // . . . .v.e.r.s.
+ 69 00 6F 00 6E 00 3D 00 22 00 31 00 22 00 3E 00 // i.o.n.=.".1.".>.
+ 0A 00 20 00 20 00 20 00 3C 00 49 00 50 00 65 00 // .. . . .<.I.P.e.
+ 72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
+ 20 00 63 00 6C 00 61 00 73 00 73 00 3D 00 22 00 // .c.l.a.s.s.=.".
+ 53 00 79 00 73 00 74 00 65 00 6D 00 2E 00 53 00 // S.y.s.t.e.m...S.
+ 65 00 63 00 75 00 72 00 69 00 74 00 79 00 2E 00 // e.c.u.r.i.t.y...
+ 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 69 00 // P.e.r.m.i.s.s.i.
+ 6F 00 6E 00 73 00 2E 00 53 00 65 00 63 00 75 00 // o.n.s...S.e.c.u.
+ 72 00 69 00 74 00 79 00 50 00 65 00 72 00 6D 00 // r.i.t.y.P.e.r.m.
+ 69 00 73 00 73 00 69 00 6F 00 6E 00 2C 00 20 00 // i.s.s.i.o.n.,. .
+ 6D 00 73 00 63 00 6F 00 72 00 6C 00 69 00 62 00 // m.s.c.o.r.l.i.b.
+ 2C 00 20 00 56 00 65 00 72 00 73 00 69 00 6F 00 // ,. .V.e.r.s.i.o.
+ 6E 00 3D 00 31 00 2E 00 30 00 2E 00 35 00 30 00 // n.=.1...0...5.0.
+ 30 00 30 00 2E 00 30 00 2C 00 20 00 43 00 75 00 // 0.0...0.,. .C.u.
+ 6C 00 74 00 75 00 72 00 65 00 3D 00 6E 00 65 00 // l.t.u.r.e.=.n.e.
+ 75 00 74 00 72 00 61 00 6C 00 2C 00 20 00 50 00 // u.t.r.a.l.,. .P.
+ 75 00 62 00 6C 00 69 00 63 00 4B 00 65 00 79 00 // u.b.l.i.c.K.e.y.
+ 54 00 6F 00 6B 00 65 00 6E 00 3D 00 62 00 37 00 // T.o.k.e.n.=.b.7.
+ 37 00 61 00 35 00 63 00 35 00 36 00 31 00 39 00 // 7.a.5.c.5.6.1.9.
+ 33 00 34 00 65 00 30 00 38 00 39 00 22 00 0A 00 // 3.4.e.0.8.9."...
+ 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // . . . . . . . .
+ 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // . . . . . . . .
+ 76 00 65 00 72 00 73 00 69 00 6F 00 6E 00 3D 00 // v.e.r.s.i.o.n.=.
+ 22 00 31 00 22 00 0A 00 20 00 20 00 20 00 20 00 // ".1."... . . . .
+ 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // . . . . . . . .
+ 20 00 20 00 20 00 20 00 46 00 6C 00 61 00 67 00 // . . . .F.l.a.g.
+ 73 00 3D 00 22 00 55 00 6E 00 6D 00 61 00 6E 00 // s.=.".U.n.m.a.n.
+ 61 00 67 00 65 00 64 00 43 00 6F 00 64 00 65 00 // a.g.e.d.C.o.d.e.
+ 22 00 2F 00 3E 00 0A 00 3C 00 2F 00 50 00 65 00 // "./.>...<./.P.e.
+ 72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
+ 53 00 65 00 74 00 3E 00 0A 00 ) // S.e.t.>...
+
+ .method public virtual hidebysig newslot abstract
+ instance default void abc () cil managed
+ {
+ .custom instance void class [mscorlib]System.Runtime.InteropServices.DispIdAttribute::.ctor(int32) = (01 00 FC FF FF FF 00 00 ) // ........
+
+ .permissionset deny = (
+ 3C 00 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 // <.P.e.r.m.i.s.s.
+ 69 00 6F 00 6E 00 53 00 65 00 74 00 20 00 63 00 // i.o.n.S.e.t. .c.
+ 6C 00 61 00 73 00 73 00 3D 00 22 00 53 00 79 00 // l.a.s.s.=.".S.y.
+ 73 00 74 00 65 00 6D 00 2E 00 53 00 65 00 63 00 // s.t.e.m...S.e.c.
+ 75 00 72 00 69 00 74 00 79 00 2E 00 50 00 65 00 // u.r.i.t.y...P.e.
+ 72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
+ 53 00 65 00 74 00 22 00 0A 00 20 00 20 00 20 00 // S.e.t."... . . .
+ 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // . . . . . . . .
+ 20 00 20 00 20 00 20 00 76 00 65 00 72 00 73 00 // . . . .v.e.r.s.
+ 69 00 6F 00 6E 00 3D 00 22 00 31 00 22 00 3E 00 // i.o.n.=.".1.".>.
+ 0A 00 20 00 20 00 20 00 3C 00 49 00 50 00 65 00 // .. . . .<.I.P.e.
+ 72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
+ 20 00 63 00 6C 00 61 00 73 00 73 00 3D 00 22 00 // .c.l.a.s.s.=.".
+ 53 00 79 00 73 00 74 00 65 00 6D 00 2E 00 53 00 // S.y.s.t.e.m...S.
+ 65 00 63 00 75 00 72 00 69 00 74 00 79 00 2E 00 // e.c.u.r.i.t.y...
+ 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 69 00 // P.e.r.m.i.s.s.i.
+ 6F 00 6E 00 73 00 2E 00 53 00 65 00 63 00 75 00 // o.n.s...S.e.c.u.
+ 72 00 69 00 74 00 79 00 50 00 65 00 72 00 6D 00 // r.i.t.y.P.e.r.m.
+ 69 00 73 00 73 00 69 00 6F 00 6E 00 2C 00 20 00 // i.s.s.i.o.n.,. .
+ 6D 00 73 00 63 00 6F 00 72 00 6C 00 69 00 62 00 // m.s.c.o.r.l.i.b.
+ 2C 00 20 00 56 00 65 00 72 00 73 00 69 00 6F 00 // ,. .V.e.r.s.i.o.
+ 6E 00 3D 00 31 00 2E 00 30 00 2E 00 35 00 30 00 // n.=.1...0...5.0.
+ 30 00 30 00 2E 00 30 00 2C 00 20 00 43 00 75 00 // 0.0...0.,. .C.u.
+ 6C 00 74 00 75 00 72 00 65 00 3D 00 6E 00 65 00 // l.t.u.r.e.=.n.e.
+ 75 00 74 00 72 00 61 00 6C 00 2C 00 20 00 50 00 // u.t.r.a.l.,. .P.
+ 75 00 62 00 6C 00 69 00 63 00 4B 00 65 00 79 00 // u.b.l.i.c.K.e.y.
+ 54 00 6F 00 6B 00 65 00 6E 00 3D 00 62 00 37 00 // T.o.k.e.n.=.b.7.
+ 37 00 61 00 35 00 63 00 35 00 36 00 31 00 39 00 // 7.a.5.c.5.6.1.9.
+ 33 00 34 00 65 00 30 00 38 00 39 00 22 00 0A 00 // 3.4.e.0.8.9."...
+ 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // . . . . . . . .
+ 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // . . . . . . . .
+ 76 00 65 00 72 00 73 00 69 00 6F 00 6E 00 3D 00 // v.e.r.s.i.o.n.=.
+ 22 00 31 00 22 00 0A 00 20 00 20 00 20 00 20 00 // ".1."... . . . .
+ 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // . . . . . . . .
+ 20 00 20 00 20 00 20 00 46 00 6C 00 61 00 67 00 // . . . .F.l.a.g.
+ 73 00 3D 00 22 00 55 00 6E 00 6D 00 61 00 6E 00 // s.=.".U.n.m.a.n.
+ 61 00 67 00 65 00 64 00 43 00 6F 00 64 00 65 00 // a.g.e.d.C.o.d.e.
+ 22 00 2F 00 3E 00 0A 00 3C 00 2F 00 50 00 65 00 // "./.>...<./.P.e.
+ 72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
+ 53 00 65 00 74 00 3E 00 0A 00 ) // S.e.t.>...
+
+ } // end of method foo::instance default void abc ()
+
+ } // end of class foo
+
diff --git a/mcs/ilasm/tests/test-comment-a.il b/mcs/ilasm/tests/test-comment-a.il
new file mode 100644
index 00000000000..e0ed489789a
--- /dev/null
+++ b/mcs/ilasm/tests/test-comment-a.il
@@ -0,0 +1,38 @@
+//
+// Test to make sure comments are being handled properly
+//
+// Author(s):
+// Jackson Harper (jackson@ximian.com)
+//
+// (C) 2003 Ximian, Inc (http://www.ximian.com)
+//
+
+.assembly extern mscorlib { }
+.assembly 'test-comment-a' { }
+
+
+.class public T {
+
+ .method public static int32 Main ()
+ {
+ .entrypoint
+
+ ldc.i4.0
+
+ // ldc.i4.1
+ /**/
+ /* ldc.i4.1 */
+ /*
+ ldc.i4.1
+ */
+
+ /*
+ //
+ */
+
+ ret
+ }
+
+}
+
+
diff --git a/mcs/ilasm/tests/test-data-a.il b/mcs/ilasm/tests/test-data-a.il
new file mode 100644
index 00000000000..7ee7c1e1233
--- /dev/null
+++ b/mcs/ilasm/tests/test-data-a.il
@@ -0,0 +1,38 @@
+//
+// Test emitting data and the field mapping
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+.assembly extern mscorlib { }
+.assembly 'test-data-a' { }
+
+
+.class public T extends [mscorlib]System.Object {
+
+ .data some_data = int32 (1)
+ .field private static int32 some_field at some_data
+
+ .method public static int32 main ()
+ {
+ .entrypoint
+
+ ldsfld int32 T::some_field
+ brfalse fail
+
+ pass:
+ ldstr "PASS"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.0
+ ret
+ fail:
+ ldstr "FAIL"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.1
+ ret
+ }
+}
+
diff --git a/mcs/ilasm/tests/test-data-b.il b/mcs/ilasm/tests/test-data-b.il
new file mode 100644
index 00000000000..f7a7969c1fe
--- /dev/null
+++ b/mcs/ilasm/tests/test-data-b.il
@@ -0,0 +1,41 @@
+//
+// Test emitting data and the field mapping with the data
+// defined after the field (and in global scope)
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+.assembly extern mscorlib { }
+.assembly 'test-data-b' { }
+
+
+.class public T extends [mscorlib]System.Object {
+
+
+ .field private static int32 some_field at some_data
+
+ .method public static int32 main ()
+ {
+ .entrypoint
+
+ ldsfld int32 T::some_field
+ brfalse fail
+
+ pass:
+ ldstr "PASS"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.0
+ ret
+ fail:
+ ldstr "FAIL"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.1
+ ret
+ }
+}
+
+.data some_data = int32 (1)
+
diff --git a/mcs/ilasm/tests/test-data-c.il b/mcs/ilasm/tests/test-data-c.il
new file mode 100644
index 00000000000..8fd47cd7492
--- /dev/null
+++ b/mcs/ilasm/tests/test-data-c.il
@@ -0,0 +1,41 @@
+//
+// Test emitting data and the field mapping with the data
+// defined in another class. (Actually all .data is global,
+// even if it is defined in a class)
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+.assembly extern mscorlib { }
+.assembly 'test-data-b' { }
+
+.class public Stub extends [mscorlib]System.Object {
+ .data some_data = int32 (1)
+}
+
+.class public T extends [mscorlib]System.Object {
+
+ .field private static int32 some_field at some_data
+
+ .method public static int32 main ()
+ {
+ .entrypoint
+
+ ldsfld int32 T::some_field
+ brfalse fail
+
+ pass:
+ ldstr "PASS"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.0
+ ret
+ fail:
+ ldstr "FAIL"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.1
+ ret
+ }
+}
diff --git a/mcs/ilasm/tests/test-field-init.il b/mcs/ilasm/tests/test-field-init.il
new file mode 100644
index 00000000000..2d0bd220b94
--- /dev/null
+++ b/mcs/ilasm/tests/test-field-init.il
@@ -0,0 +1,40 @@
+// Test for field initialization, for the syntax
+// .. = int8 (value)
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly 'test-field-init'
+{
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
+ .ver 0:0:0:0
+}
+.module 'test-field-init.dll'
+
+.class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+{
+ .field public static literal int8 tf = int8(-3)
+ .field public static literal uint8 tf = int8(3)
+
+ .field public static literal int16 tf = int16(-3)
+ .field public static literal uint16 tf = uint16(3)
+
+ .field public static literal int32 tf = int32(-3)
+ .field public static literal uint32 tf = uint32(3)
+
+ .field public static literal int64 tf = int64(12345)
+ .field public static literal uint64 tf = uint64(0xFFFFFFFFFFFFFFFF)
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ }
+
+}
diff --git a/mcs/ilasm/tests/test-fixedarray.il b/mcs/ilasm/tests/test-fixedarray.il
new file mode 100644
index 00000000000..768a6cc926e
--- /dev/null
+++ b/mcs/ilasm/tests/test-fixedarray.il
@@ -0,0 +1,15 @@
+.assembly extern mscorlib
+{
+}
+.assembly 'test-fixedarray'
+{
+}
+
+ .class public sequential ansi beforefieldinit Dummy
+ extends [mscorlib]System.Object
+ {
+ .pack 0
+ .size 1024
+ .field public marshal (fixed array [16]) unsigned int8[] a
+
+ }
diff --git a/mcs/ilasm/tests/test-gen-meth-a.il b/mcs/ilasm/tests/test-gen-meth-a.il
new file mode 100644
index 00000000000..93536cabc68
--- /dev/null
+++ b/mcs/ilasm/tests/test-gen-meth-a.il
@@ -0,0 +1,29 @@
+//
+// Define a generic method
+//
+// Author(s):
+// Jackson Harper (jackson@ximian.com)
+//
+// (C) 2003 Ximian, Inc (http://www.ximian.com)
+//
+
+.assembly extern mscorlib { }
+.assembly 'test-gen-meth-a' { }
+
+.class public T {
+
+ .method public static int32 Main ()
+ {
+ .entrypoint
+
+ ldc.i4.1
+ ret
+ }
+
+ .method private static int32 M<I> ()
+ {
+ ldc.i4.1
+ ret
+ }
+}
+
diff --git a/mcs/ilasm/tests/test-int64.il b/mcs/ilasm/tests/test-int64.il
new file mode 100644
index 00000000000..298e866c847
--- /dev/null
+++ b/mcs/ilasm/tests/test-int64.il
@@ -0,0 +1,42 @@
+// Test for large numbers
+
+.assembly extern mscorlib
+{
+ .ver 1:0:5000:0
+}
+.assembly 'max'
+{
+ .ver 0:0:0:0
+}
+.module max.exe
+
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ .method public static hidebysig
+ default void Main () cil managed
+ {
+ .entrypoint
+ .maxstack 1
+ .locals init (
+ unsigned int64 V_0)
+ ldc.i8 9223372036854775810
+ pop
+ ldc.r8 9223372036854775810
+ pop
+ ldc.i8 -9223372036854775808
+ IL_0009: stloc.0
+ IL_000a: ret
+ }
+
+ }
diff --git a/mcs/ilasm/tests/test-ldcr-bytes.il b/mcs/ilasm/tests/test-ldcr-bytes.il
new file mode 100644
index 00000000000..ae07d7b270f
--- /dev/null
+++ b/mcs/ilasm/tests/test-ldcr-bytes.il
@@ -0,0 +1,44 @@
+.assembly extern mscorlib
+{
+}
+.assembly 'test-ldcr-bytes'
+{
+}
+.module ldcr8.exe
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ .method private static hidebysig
+ default float64 foo () cil managed
+ {
+ .maxstack 8
+ ldc.r4 (00 01 02 03)
+ pop
+ ldc.r8 (00 01 02 03 04 05 06 07)
+ IL_0009: ret
+ }
+
+ .method public static hidebysig
+ default void Main (string[] args) cil managed
+ {
+ .entrypoint
+ .maxstack 8
+ IL_0000: ldstr "{0}"
+ IL_0005: call float64 class test::foo()
+ IL_000a: box [mscorlib]System.Double
+ IL_000f: call void class [mscorlib]System.Console::WriteLine(string, object)
+ IL_0014: ret
+ }
+
+ }
diff --git a/mcs/ilasm/tests/test-marshal-array.il b/mcs/ilasm/tests/test-marshal-array.il
new file mode 100644
index 00000000000..567dc0706d6
--- /dev/null
+++ b/mcs/ilasm/tests/test-marshal-array.il
@@ -0,0 +1,32 @@
+.assembly extern mscorlib
+{
+}
+.assembly 'test-marshal-array.il'
+{
+}
+
+ .class public auto ansi beforefieldinit Tests
+ extends [mscorlib]System.Object
+ {
+
+ .method public virtual hidebysig
+ instance default int32 Invoke ([in] string[] marshal (lpstr[+ 3]) arr_ad1) runtime managed
+ {
+ }
+
+ .method public virtual hidebysig
+ instance default int32 Invoke2([in] string[] marshal (lpstr[2]) arr_ad2) runtime managed
+ {
+ }
+
+ .method public virtual hidebysig
+ instance default int32 Invoke3 ([in] string[] marshal (lpstr[2 + 3]) arr_ad3) runtime managed
+ {
+ }
+
+ .method public virtual hidebysig
+ instance default int32 Invoke4 ([in] string[] marshal (lpstr[]) arr_ad4) runtime managed
+ {
+ }
+ }
+
diff --git a/mcs/ilasm/tests/test-marshal.il b/mcs/ilasm/tests/test-marshal.il
new file mode 100644
index 00000000000..2325c4b8fbf
--- /dev/null
+++ b/mcs/ilasm/tests/test-marshal.il
@@ -0,0 +1,37 @@
+.assembly extern mscorlib
+{
+}
+.assembly 'test-marshal'
+{
+}
+
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+ .field private marshal (int32[]) int32 a
+
+ .method private hidebysig
+ instance default void marshal (as any) xyz () cil managed
+ {
+ .maxstack 8
+ IL_0000: ret
+ }
+
+ .method private hidebysig
+ instance default object marshal (interface) abc (class test 'assembly', string marshal (bool) str, string str2, int32 i4) cil managed
+ {
+ .maxstack 8
+ IL_0000: ldnull
+ IL_0001: ret
+ }
+
+ .method private hidebysig
+ instance default void marshal (as any) def (class test 'assembly', string str, string str2, int32 marshal (bool) i4) cil managed
+ {
+ .maxstack 8
+ IL_0000: ret
+ }
+
+ }
+
diff --git a/mcs/ilasm/tests/test-module-cattr.il b/mcs/ilasm/tests/test-module-cattr.il
new file mode 100644
index 00000000000..8b77c200520
--- /dev/null
+++ b/mcs/ilasm/tests/test-module-cattr.il
@@ -0,0 +1,60 @@
+// Test for custom attributes on this .module
+
+.assembly extern mscorlib
+{
+ .ver 1:0:5000:0
+}
+.assembly extern System
+{
+ .ver 1:0:5000:0
+}
+.assembly 'test-module-cattr'
+{
+ .ver 0:0:0:0
+}
+.module 'test-module-cattr.exe'
+
+.custom instance void class [System]System.ComponentModel.DescriptionAttribute::.ctor(string) = (01 00 0A 53 6F 6D 65 4D 6F 64 75 6C 65 00 00 ) // ...SomeModule..
+
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ .method public static hidebysig
+ default void Main () cil managed
+ {
+ .entrypoint
+ .maxstack 7
+ .locals init (
+ class [mscorlib]System.Reflection.Module V_0)
+ IL_0000: ldtoken test
+ IL_0005: call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
+ IL_000a: callvirt instance class [mscorlib]System.Reflection.Module class [mscorlib]System.Type::get_Module()
+ IL_000f: stloc.0
+ IL_0010: ldloc.0
+ IL_0011: call class [mscorlib]System.Attribute[] class [mscorlib]System.Attribute::GetCustomAttributes(class [mscorlib]System.Reflection.Module)
+ IL_0016: ldlen
+ IL_0017: conv.i4
+ IL_0018: ldc.i4.1
+ IL_0019: bne.un IL_002d
+
+ IL_001e: ldstr "OK"
+ IL_0023: call void class [mscorlib]System.Console::WriteLine(string)
+ IL_0028: br IL_0037
+
+ IL_002d: ldstr "Error"
+ IL_0032: call void class [mscorlib]System.Console::WriteLine(string)
+ IL_0037: ret
+ }
+
+ }
diff --git a/mcs/ilasm/tests/test-nonsealed-valueclass.il b/mcs/ilasm/tests/test-nonsealed-valueclass.il
new file mode 100644
index 00000000000..368031bc0e3
--- /dev/null
+++ b/mcs/ilasm/tests/test-nonsealed-valueclass.il
@@ -0,0 +1,7 @@
+// Test for a non-sealed value class
+// ilasm gives a warning and seals the class
+
+.class public test
+ extends [mscorlib]System.ValueType
+{
+}
diff --git a/mcs/ilasm/tests/test-override-1.il b/mcs/ilasm/tests/test-override-1.il
new file mode 100644
index 00000000000..f4970b1c596
--- /dev/null
+++ b/mcs/ilasm/tests/test-override-1.il
@@ -0,0 +1,53 @@
+// Test for "full" syntax of specifying overrides.
+// This has non-generic types & methods
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly 'test-override-1'
+{
+ .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = (
+ 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 )
+
+ .custom instance void class [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = (01 00 08 00 00 00 00 00 )
+
+ .ver 0:0:0:0
+}
+.module 'test-override-1.dll'
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ implements IFoo {
+
+ .method public final virtual hidebysig newslot
+ instance default void bar (string si) cil managed
+ {
+ .override method instance void class IFoo::foo(string)
+
+ .maxstack 8
+ IL_0000: nop
+ IL_0001: ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ }
+
+ .class interface private auto ansi abstract IFoo
+ {
+ .method public virtual hidebysig newslot abstract
+ instance default void foo (string s) cil managed
+ {
+
+ }
+ }
+
diff --git a/mcs/ilasm/tests/test-override-2.il b/mcs/ilasm/tests/test-override-2.il
new file mode 100644
index 00000000000..13c9437d686
--- /dev/null
+++ b/mcs/ilasm/tests/test-override-2.il
@@ -0,0 +1,52 @@
+// Test for "full" syntax of specifying overrides.
+// This has method in a generic type
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly 'test-override-2'
+{
+ .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = (
+ 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
+
+ .custom instance void class [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = (01 00 08 00 00 00 00 00 ) // ........
+
+ .ver 0:0:0:0
+}
+.module 'test-override-2.dll'
+
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ implements class IFoo`1<string> {
+
+ .method public final virtual hidebysig newslot
+ instance default void foo (class IFoo`1<string> _f) cil managed
+ {
+ .override method instance void class IFoo`1<string>::foo(class IFoo`1<string>)
+ .maxstack 8
+ IL_0000: nop
+ IL_0001: ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ }
+
+ .class interface private auto ansi abstract IFoo`1<T>
+ {
+ .method public virtual hidebysig newslot abstract
+ instance default void foo (class IFoo`1<!T> _f) cil managed
+ {
+ }
+
+ }
diff --git a/mcs/ilasm/tests/test-perm_pass-1.il b/mcs/ilasm/tests/test-perm_pass-1.il
new file mode 100644
index 00000000000..31bcc283525
--- /dev/null
+++ b/mcs/ilasm/tests/test-perm_pass-1.il
@@ -0,0 +1,165 @@
+// Test for Syntactically valid .permission usage
+// The combination of security action and the permissions might not make sense
+
+.assembly extern mscorlib
+{
+}
+.assembly 'test-perm_pass-1'
+{
+ .permissionset reqopt = (
+ 3C 00 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 // <.P.e.r.m.i.s.s.
+ 69 00 6F 00 6E 00 53 00 65 00 74 00 20 00 63 00 // i.o.n.S.e.t. .c.
+ 6C 00 61 00 73 00 73 00 3D 00 22 00 53 00 79 00 // l.a.s.s.=.".S.y.
+ 73 00 74 00 65 00 6D 00 2E 00 53 00 65 00 63 00 // s.t.e.m...S.e.c.
+ 75 00 72 00 69 00 74 00 79 00 2E 00 50 00 65 00 // u.r.i.t.y...P.e.
+ 72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
+ 53 00 65 00 74 00 22 00 0A 00 20 00 20 00 20 00 // S.e.t."... . . .
+ 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // . . . . . . . .
+ 20 00 20 00 20 00 20 00 76 00 65 00 72 00 73 00 // . . . .v.e.r.s.
+ 69 00 6F 00 6E 00 3D 00 22 00 31 00 22 00 3E 00 // i.o.n.=.".1.".>.
+ 0A 00 20 00 20 00 20 00 3C 00 49 00 50 00 65 00 // .. . . .<.I.P.e.
+ 72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
+ 20 00 63 00 6C 00 61 00 73 00 73 00 3D 00 22 00 // .c.l.a.s.s.=.".
+ 53 00 79 00 73 00 74 00 65 00 6D 00 2E 00 53 00 // S.y.s.t.e.m...S.
+ 65 00 63 00 75 00 72 00 69 00 74 00 79 00 2E 00 // e.c.u.r.i.t.y...
+ 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 69 00 // P.e.r.m.i.s.s.i.
+ 6F 00 6E 00 73 00 2E 00 53 00 65 00 63 00 75 00 // o.n.s...S.e.c.u.
+ 72 00 69 00 74 00 79 00 50 00 65 00 72 00 6D 00 // r.i.t.y.P.e.r.m.
+ 69 00 73 00 73 00 69 00 6F 00 6E 00 2C 00 20 00 // i.s.s.i.o.n.,. .
+ 6D 00 73 00 63 00 6F 00 72 00 6C 00 69 00 62 00 // m.s.c.o.r.l.i.b.
+ 2C 00 20 00 56 00 65 00 72 00 73 00 69 00 6F 00 // ,. .V.e.r.s.i.o.
+ 6E 00 3D 00 32 00 2E 00 30 00 2E 00 30 00 2E 00 // n.=.2...0...0...
+ 30 00 2C 00 20 00 43 00 75 00 6C 00 74 00 75 00 // 0.,. .C.u.l.t.u.
+ 72 00 65 00 3D 00 6E 00 65 00 75 00 74 00 72 00 // r.e.=.n.e.u.t.r.
+ 61 00 6C 00 2C 00 20 00 50 00 75 00 62 00 6C 00 // a.l.,. .P.u.b.l.
+ 69 00 63 00 4B 00 65 00 79 00 54 00 6F 00 6B 00 // i.c.K.e.y.T.o.k.
+ 65 00 6E 00 3D 00 62 00 37 00 37 00 61 00 35 00 // e.n.=.b.7.7.a.5.
+ 63 00 35 00 36 00 31 00 39 00 33 00 34 00 65 00 // c.5.6.1.9.3.4.e.
+ 30 00 38 00 39 00 22 00 0A 00 20 00 20 00 20 00 // 0.8.9."... . . .
+ 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // . . . . . . . .
+ 20 00 20 00 20 00 20 00 20 00 76 00 65 00 72 00 // . . . . .v.e.r.
+ 73 00 69 00 6F 00 6E 00 3D 00 22 00 31 00 22 00 // s.i.o.n.=.".1.".
+ 0A 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // .. . . . . . . .
+ 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // . . . . . . . .
+ 20 00 46 00 6C 00 61 00 67 00 73 00 3D 00 22 00 // .F.l.a.g.s.=.".
+ 53 00 6B 00 69 00 70 00 56 00 65 00 72 00 69 00 // S.k.i.p.V.e.r.i.
+ 66 00 69 00 63 00 61 00 74 00 69 00 6F 00 6E 00 // f.i.c.a.t.i.o.n.
+ 22 00 2F 00 3E 00 0A 00 3C 00 2F 00 50 00 65 00 // "./.>...<./.P.e.
+ 72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
+ 53 00 65 00 74 00 3E 00 0A 00 ) // S.e.t.>...
+
+.permissionset demand = (
+ 3C 00 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 // <.P.e.r.m.i.s.s.
+ 69 00 6F 00 6E 00 53 00 65 00 74 00 20 00 63 00 // i.o.n.S.e.t. .c.
+ 6C 00 61 00 73 00 73 00 3D 00 22 00 53 00 79 00 // l.a.s.s.=.".S.y.
+ 73 00 74 00 65 00 6D 00 2E 00 53 00 65 00 63 00 // s.t.e.m...S.e.c.
+ 75 00 72 00 69 00 74 00 79 00 2E 00 50 00 65 00 // u.r.i.t.y...P.e.
+ 72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
+ 53 00 65 00 74 00 22 00 0A 00 20 00 20 00 20 00 // S.e.t."... . . .
+ 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // . . . . . . . .
+ 20 00 20 00 20 00 20 00 76 00 65 00 72 00 73 00 // . . . .v.e.r.s.
+ 69 00 6F 00 6E 00 3D 00 22 00 31 00 22 00 3E 00 // i.o.n.=.".1.".>.
+ 0A 00 20 00 20 00 20 00 3C 00 49 00 50 00 65 00 // .. . . .<.I.P.e.
+ 72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
+ 20 00 63 00 6C 00 61 00 73 00 73 00 3D 00 22 00 // .c.l.a.s.s.=.".
+ 53 00 79 00 73 00 74 00 65 00 6D 00 2E 00 53 00 // S.y.s.t.e.m...S.
+ 65 00 63 00 75 00 72 00 69 00 74 00 79 00 2E 00 // e.c.u.r.i.t.y...
+ 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 69 00 // P.e.r.m.i.s.s.i.
+ 6F 00 6E 00 73 00 2E 00 53 00 65 00 63 00 75 00 // o.n.s...S.e.c.u.
+ 72 00 69 00 74 00 79 00 50 00 65 00 72 00 6D 00 // r.i.t.y.P.e.r.m.
+ 69 00 73 00 73 00 69 00 6F 00 6E 00 2C 00 20 00 // i.s.s.i.o.n.,. .
+ 6D 00 73 00 63 00 6F 00 72 00 6C 00 69 00 62 00 // m.s.c.o.r.l.i.b.
+ 2C 00 20 00 56 00 65 00 72 00 73 00 69 00 6F 00 // ,. .V.e.r.s.i.o.
+ 6E 00 3D 00 32 00 2E 00 30 00 2E 00 30 00 2E 00 // n.=.2...0...0...
+ 30 00 2C 00 20 00 43 00 75 00 6C 00 74 00 75 00 // 0.,. .C.u.l.t.u.
+ 72 00 65 00 3D 00 6E 00 65 00 75 00 74 00 72 00 // r.e.=.n.e.u.t.r.
+ 61 00 6C 00 2C 00 20 00 50 00 75 00 62 00 6C 00 // a.l.,. .P.u.b.l.
+ 69 00 63 00 4B 00 65 00 79 00 54 00 6F 00 6B 00 // i.c.K.e.y.T.o.k.
+ 65 00 6E 00 3D 00 62 00 37 00 37 00 61 00 35 00 // e.n.=.b.7.7.a.5.
+ 63 00 35 00 36 00 31 00 39 00 33 00 34 00 65 00 // c.5.6.1.9.3.4.e.
+ 30 00 38 00 39 00 22 00 0A 00 20 00 20 00 20 00 // 0.8.9."... . . .
+ 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // . . . . . . . .
+ 20 00 20 00 20 00 20 00 20 00 76 00 65 00 72 00 // . . . . .v.e.r.
+ 73 00 69 00 6F 00 6E 00 3D 00 22 00 31 00 22 00 // s.i.o.n.=.".1.".
+ 0A 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // .. . . . . . . .
+ 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // . . . . . . . .
+ 20 00 46 00 6C 00 61 00 67 00 73 00 3D 00 22 00 // .F.l.a.g.s.=.".
+ 53 00 6B 00 69 00 70 00 56 00 65 00 72 00 69 00 // S.k.i.p.V.e.r.i.
+ 66 00 69 00 63 00 61 00 74 00 69 00 6F 00 6E 00 // f.i.c.a.t.i.o.n.
+ 22 00 2F 00 3E 00 0A 00 3C 00 2F 00 50 00 65 00 // "./.>...<./.P.e.
+ 72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
+ 53 00 65 00 74 00 3E 00 0A 00 ) // S.e.t.>...
+
+}
+
+ .class interface public auto ansi abstract foo
+ {
+
+ .method public virtual hidebysig newslot abstract
+ instance default void abc () cil managed
+ {
+ //.permission demand [mscorlib]System.Security.Permissions.FileIOPermissionAttribute ("Write"="/tmp", "Read"="/tmp")
+ .permission demand [mscorlib]System.Security.Permissions.ReflectionPermissionAttribute ("MemberAccess"=true)
+ .permission deny [mscorlib]System.Security.Permissions.ReflectionPermissionAttribute
+
+ //IsolatedStorageContainment - enum
+ .permission demand [mscorlib]System.Security.Permissions.IsolatedStorageFilePermissionAttribute ("UsageAllowed"=[mscorlib]System.Security.Permissions.IsolatedStorageContainment (16))
+ .permission deny [mscorlib]System.Security.Permissions.IsolatedStorageFilePermissionAttribute ("UsageAllowed"=[mscorlib]System.Security.Permissions.IsolatedStorageContainment (int32:16))
+ .permission assert [mscorlib]System.Security.Permissions.IsolatedStorageFilePermissionAttribute ("UsageAllowed"=[mscorlib]System.Security.Permissions.IsolatedStorageContainment (int16:16))
+ .permission permitonly [mscorlib]System.Security.Permissions.IsolatedStorageFilePermissionAttribute ("UsageAllowed"=[mscorlib]System.Security.Permissions.IsolatedStorageContainment (int8:16))
+
+ // UserQuota - long
+ // This is the *correct* way to specify the value for UserQuota ...
+ .permission linkcheck [mscorlib]System.Security.Permissions.IsolatedStorageFilePermissionAttribute ("UserQuota"=70000)
+
+ // ... but the following are also valid
+ .permission demand [mscorlib]System.Security.Permissions.IsolatedStorageFilePermissionAttribute ("UserQuota"=[mscorlib]System.Security.Permissions.IsolatedStorageContainment (70000))
+ .permission deny [mscorlib]System.Security.Permissions.IsolatedStorageFilePermissionAttribute ("UserQuota"=[mscorlib]System.Security.Permissions.IsolatedStorageContainment (int32:70000))
+ .permission assert [mscorlib]System.Security.Permissions.IsolatedStorageFilePermissionAttribute ("UserQuota"=[mscorlib]System.Security.Permissions.IsolatedStorageContainment (int16:70000))
+ .permission permitonly [mscorlib]System.Security.Permissions.IsolatedStorageFilePermissionAttribute ("UserQuota"=[mscorlib]System.Security.Permissions.IsolatedStorageContainment (int8:1000))
+
+ .permissionset deny = (
+ 3C 00 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 // <.P.e.r.m.i.s.s.
+ 69 00 6F 00 6E 00 53 00 65 00 74 00 20 00 63 00 // i.o.n.S.e.t. .c.
+ 6C 00 61 00 73 00 73 00 3D 00 22 00 53 00 79 00 // l.a.s.s.=.".S.y.
+ 73 00 74 00 65 00 6D 00 2E 00 53 00 65 00 63 00 // s.t.e.m...S.e.c.
+ 75 00 72 00 69 00 74 00 79 00 2E 00 50 00 65 00 // u.r.i.t.y...P.e.
+ 72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
+ 53 00 65 00 74 00 22 00 0A 00 20 00 20 00 20 00 // S.e.t."... . . .
+ 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // . . . . . . . .
+ 20 00 20 00 20 00 20 00 76 00 65 00 72 00 73 00 // . . . .v.e.r.s.
+ 69 00 6F 00 6E 00 3D 00 22 00 31 00 22 00 3E 00 // i.o.n.=.".1.".>.
+ 0A 00 20 00 20 00 20 00 3C 00 49 00 50 00 65 00 // .. . . .<.I.P.e.
+ 72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
+ 20 00 63 00 6C 00 61 00 73 00 73 00 3D 00 22 00 // .c.l.a.s.s.=.".
+ 53 00 79 00 73 00 74 00 65 00 6D 00 2E 00 53 00 // S.y.s.t.e.m...S.
+ 65 00 63 00 75 00 72 00 69 00 74 00 79 00 2E 00 // e.c.u.r.i.t.y...
+ 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 69 00 // P.e.r.m.i.s.s.i.
+ 6F 00 6E 00 73 00 2E 00 53 00 65 00 63 00 75 00 // o.n.s...S.e.c.u.
+ 72 00 69 00 74 00 79 00 50 00 65 00 72 00 6D 00 // r.i.t.y.P.e.r.m.
+ 69 00 73 00 73 00 69 00 6F 00 6E 00 2C 00 20 00 // i.s.s.i.o.n.,. .
+ 6D 00 73 00 63 00 6F 00 72 00 6C 00 69 00 62 00 // m.s.c.o.r.l.i.b.
+ 2C 00 20 00 56 00 65 00 72 00 73 00 69 00 6F 00 // ,. .V.e.r.s.i.o.
+ 6E 00 3D 00 31 00 2E 00 30 00 2E 00 35 00 30 00 // n.=.1...0...5.0.
+ 30 00 30 00 2E 00 30 00 2C 00 20 00 43 00 75 00 // 0.0...0.,. .C.u.
+ 6C 00 74 00 75 00 72 00 65 00 3D 00 6E 00 65 00 // l.t.u.r.e.=.n.e.
+ 75 00 74 00 72 00 61 00 6C 00 2C 00 20 00 50 00 // u.t.r.a.l.,. .P.
+ 75 00 62 00 6C 00 69 00 63 00 4B 00 65 00 79 00 // u.b.l.i.c.K.e.y.
+ 54 00 6F 00 6B 00 65 00 6E 00 3D 00 62 00 37 00 // T.o.k.e.n.=.b.7.
+ 37 00 61 00 35 00 63 00 35 00 36 00 31 00 39 00 // 7.a.5.c.5.6.1.9.
+ 33 00 34 00 65 00 30 00 38 00 39 00 22 00 0A 00 // 3.4.e.0.8.9."...
+ 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // . . . . . . . .
+ 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // . . . . . . . .
+ 76 00 65 00 72 00 73 00 69 00 6F 00 6E 00 3D 00 // v.e.r.s.i.o.n.=.
+ 22 00 31 00 22 00 0A 00 20 00 20 00 20 00 20 00 // ".1."... . . . .
+ 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 // . . . . . . . .
+ 20 00 20 00 20 00 20 00 46 00 6C 00 61 00 67 00 // . . . .F.l.a.g.
+ 73 00 3D 00 22 00 55 00 6E 00 6D 00 61 00 6E 00 // s.=.".U.n.m.a.n.
+ 61 00 67 00 65 00 64 00 43 00 6F 00 64 00 65 00 // a.g.e.d.C.o.d.e.
+ 22 00 2F 00 3E 00 0A 00 3C 00 2F 00 50 00 65 00 // "./.>...<./.P.e.
+ 72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
+ 53 00 65 00 74 00 3E 00 0A 00 ) // S.e.t.>...
+
+ }
+
+ }
diff --git a/mcs/ilasm/tests/test-perm_pass-2.il b/mcs/ilasm/tests/test-perm_pass-2.il
new file mode 100644
index 00000000000..53695f3c423
--- /dev/null
+++ b/mcs/ilasm/tests/test-perm_pass-2.il
@@ -0,0 +1,42 @@
+// Test for new(2.0) syntax for specifying permissionset
+// (Uses string instead of a bytearray or namevalue pairs)
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+}
+.assembly 'test-perm_pass-2'
+{
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module 'test-perm_pass-2.dll'
+
+.class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ }
+
+ .method public hidebysig static void foo() cil managed
+ {
+ .permissionset linkcheck
+ "<PermissionSet class=\"System.Security.PermissionSe"
+ + "t\"\nversion=\"1\">\n<IPermission class=\"System.Security.Permissi"
+ + "ons.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=n"
+ + "eutral, PublicKeyToken=b77a5c561934e089\"\nversion=\"1\"\nUnrestr"
+ + "icted=\"true\"/>\n</PermissionSet>\n"
+ // Code size 1 (0x1)
+ .maxstack 8
+ IL_0000: ret
+ }
+
+}
diff --git a/mcs/ilasm/tests/test-pinvoke-a.il b/mcs/ilasm/tests/test-pinvoke-a.il
new file mode 100644
index 00000000000..30e7b282b46
--- /dev/null
+++ b/mcs/ilasm/tests/test-pinvoke-a.il
@@ -0,0 +1,40 @@
+//
+// Test pinvoking unmanaged code
+//
+// Author(s):
+// Jackson Harper (jackson@ximian.com)
+//
+// (C) 2003 Ximian Inc, (http://www.ximian.com)
+//
+
+.assembly extern mscorlib { }
+.assembly 'test-pinvoke-a' { }
+
+
+.class public T {
+
+ .method public static pinvokeimpl ("test-pinvoke" as "ret_one" cdecl)
+ int32 RetOne () cil managed { }
+
+ .method public static int32 test ()
+ {
+ .entrypoint
+
+ call int32 T::RetOne ()
+ brfalse FAIL
+
+ PASS:
+ ldstr "PASS"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.0
+ ret
+
+ FAIL:
+ ldstr "FAIL"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.1
+ ret
+ }
+
+}
+
diff --git a/mcs/ilasm/tests/test-pinvoke-b.il b/mcs/ilasm/tests/test-pinvoke-b.il
new file mode 100644
index 00000000000..c0837d0d866
--- /dev/null
+++ b/mcs/ilasm/tests/test-pinvoke-b.il
@@ -0,0 +1,40 @@
+//
+// Test pinvoking unmanaged code
+//
+// Author(s):
+// Jackson Harper (jackson@ximian.com)
+//
+// (C) 2003 Ximian Inc, (http://www.ximian.com)
+//
+
+.assembly extern mscorlib { }
+.assembly 'test-pinvoke-b' { }
+
+
+.class public T {
+
+ .method public static pinvokeimpl ("test-pinvoke" cdecl)
+ int32 ret_one () cil managed { }
+
+ .method public static int32 test ()
+ {
+ .entrypoint
+
+ call int32 T::ret_one ()
+ brfalse FAIL
+
+ PASS:
+ ldstr "PASS"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.0
+ ret
+
+ FAIL:
+ ldstr "FAIL"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.1
+ ret
+ }
+
+}
+
diff --git a/mcs/ilasm/tests/test-pinvoke.c b/mcs/ilasm/tests/test-pinvoke.c
new file mode 100644
index 00000000000..0436ac56cab
--- /dev/null
+++ b/mcs/ilasm/tests/test-pinvoke.c
@@ -0,0 +1,19 @@
+/**
+ * test-pinvoke.c: native functions for testing ilasm pinvoke
+ *
+ * Author(s):
+ * Jackson Harper (jackson@ximian.com)
+ *
+ * (C) 2003 Ximian, Inc (http://www.ximian.com)
+ *
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+ret_one ()
+{
+ return 1;
+}
diff --git a/mcs/ilasm/tests/test-safearray.il b/mcs/ilasm/tests/test-safearray.il
new file mode 100644
index 00000000000..15b5f489910
--- /dev/null
+++ b/mcs/ilasm/tests/test-safearray.il
@@ -0,0 +1,27 @@
+.assembly extern mscorlib
+{
+}
+.assembly 'test-safearray'
+{
+}
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+
+ .method private hidebysig
+ instance default void ret_safearray_int (int32 marshal (safearray int) a1) cil managed
+ {
+ .maxstack 8
+ IL_0000: ret
+ }
+
+ .method private hidebysig
+ instance default void ret_safearray (int32 marshal (safearray ) a2) cil managed
+ {
+ .maxstack 8
+ IL_0000: ret
+ }
+
+ }
+
diff --git a/mcs/ilasm/tests/test-sec-suppress.il b/mcs/ilasm/tests/test-sec-suppress.il
new file mode 100644
index 00000000000..08562b42c47
--- /dev/null
+++ b/mcs/ilasm/tests/test-sec-suppress.il
@@ -0,0 +1,36 @@
+// a Type or method with a custom attribute SuppressUnmanagedCodeSecurityAttribute
+// automatically gets a HasSecurity attribute set.
+
+.assembly extern mscorlib
+{
+}
+.assembly 'sec'
+{
+}
+.module sec.dll
+
+
+ .class private auto ansi beforefieldinit test
+ extends [mscorlib]System.Object
+ {
+ .custom instance void class [mscorlib]System.Security.SuppressUnmanagedCodeSecurityAttribute::.ctor() = (01 00 00 00 )
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void object::.ctor()
+ IL_0006: ret
+ }
+
+ .method private hidebysig
+ instance default void abc () cil managed
+ {
+ .custom instance void class [mscorlib]System.Security.SuppressUnmanagedCodeSecurityAttribute::.ctor() = (01 00 00 00 )
+
+ .maxstack 8
+ IL_0000: ret
+ }
+
+ }
diff --git a/mcs/ilasm/tests/test-seh-a.il b/mcs/ilasm/tests/test-seh-a.il
new file mode 100644
index 00000000000..63f69178672
--- /dev/null
+++ b/mcs/ilasm/tests/test-seh-a.il
@@ -0,0 +1,76 @@
+//
+// Test catch and finally blocks
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+.assembly extern mscorlib { }
+.assembly extern System { }
+.assembly 'test-seh-a' { }
+
+
+.class public T {
+
+ .field private static int32 exc_caught
+ .field private static int32 fin_caught
+
+ .method public static specialname void .cctor ()
+ {
+ ldc.i4.0
+ stsfld int32 T::exc_caught
+
+ ldc.i4.0
+ stsfld int32 T::fin_caught
+
+ ret
+ }
+
+ .method public static int32 Main ()
+ {
+ .entrypoint
+
+ .try {
+ .try {
+ ldstr "#jibba!!jabba"
+ newobj void [System]System.Uri::.ctor (string)
+ leave outer
+ } catch [mscorlib]System.Exception {
+ ldc.i4.1
+ stsfld int32 T::exc_caught
+ leave outer
+ }
+ leave outer
+ } finally {
+ ldc.i4.1
+ stsfld int32 T::fin_caught
+ endfinally
+ }
+
+
+ outer:
+ ldsfld int32 T::exc_caught
+ brfalse fail
+
+ ldsfld int32 T::fin_caught
+ brfalse fail
+
+ pass:
+ ldstr "PASS"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.0
+ ret
+
+ fail:
+ ldstr "FAIL"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.1
+ ret
+
+ }
+
+}
+
+
diff --git a/mcs/ilasm/tests/test-seh-b.il b/mcs/ilasm/tests/test-seh-b.il
new file mode 100644
index 00000000000..f667399e9bc
--- /dev/null
+++ b/mcs/ilasm/tests/test-seh-b.il
@@ -0,0 +1,75 @@
+//
+// Test catch and fault blocks
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+.assembly extern mscorlib { }
+.assembly extern System { }
+.assembly 'test-seh-b' { }
+
+
+.class public T {
+
+ .field private static int32 exc_caught
+ .field private static int32 flt_caught
+
+ .method public static specialname void .cctor ()
+ {
+ ldc.i4.0
+ stsfld int32 T::exc_caught
+
+ ldc.i4.0
+ stsfld int32 T::flt_caught
+
+ ret
+ }
+
+ .method public static int32 Main ()
+ {
+ .entrypoint
+
+ .try {
+ .try {
+ ldstr "#jibba!!jabba"
+ newobj void [System]System.Uri::.ctor (string)
+ leave outer
+ } catch [mscorlib]System.Exception {
+ ldc.i4.1
+ stsfld int32 T::exc_caught
+ leave outer
+ }
+ } fault {
+ ldc.i4.1
+ stsfld int32 T::flt_caught
+ endfault
+ }
+
+
+ outer:
+ ldsfld int32 T::exc_caught
+ brfalse fail
+
+ ldsfld int32 T::flt_caught
+ brfalse fail
+
+ pass:
+ ldstr "PASS"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.0
+ ret
+
+ fail:
+ ldstr "FAIL"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.1
+ ret
+
+ }
+
+}
+
+
diff --git a/mcs/ilasm/tests/test-seh-c.il b/mcs/ilasm/tests/test-seh-c.il
new file mode 100644
index 00000000000..aeb7262ff31
--- /dev/null
+++ b/mcs/ilasm/tests/test-seh-c.il
@@ -0,0 +1,76 @@
+//
+// Test catch and filter blocks
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+.assembly extern mscorlib { }
+.assembly 'test-seh-b' { }
+
+
+.class public T {
+
+ .field private static int32 exc_not_thrown
+ .field private static int32 flt_caught
+
+ .method public static specialname void .cctor ()
+ {
+ ldc.i4.0
+ stsfld int32 T::exc_not_thrown
+
+ ldc.i4.0
+ stsfld int32 T::flt_caught
+
+ ret
+ }
+
+ .method public static int32 Main ()
+ {
+ .entrypoint
+
+ .try {
+ ldc.i4.0
+ ldc.i4.0
+ div
+
+ ldc.i4.1
+ stsfld int32 T::exc_not_thrown
+
+ leave outer
+ } filter {
+ pop
+ ldc.i4.1
+ endfilter
+ } {
+ ldc.i4.1
+ stsfld int32 T::flt_caught
+ leave outer
+ }
+
+ outer:
+ ldsfld int32 T::exc_not_thrown
+ brtrue fail
+
+ ldsfld int32 T::flt_caught
+ brfalse fail
+
+ pass:
+ ldstr "PASS"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.0
+ ret
+
+ fail:
+ ldstr "FAIL"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.1
+ ret
+
+ }
+
+}
+
+
diff --git a/mcs/ilasm/tests/test-seh-d.il b/mcs/ilasm/tests/test-seh-d.il
new file mode 100644
index 00000000000..0122b210b0f
--- /dev/null
+++ b/mcs/ilasm/tests/test-seh-d.il
@@ -0,0 +1,92 @@
+//
+// Test catch and filter blocks
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+.assembly extern mscorlib { }
+.assembly 'test-seh-b' { }
+
+
+.class public T {
+
+ .field private static int32 exc_not_thrown
+ .field private static int32 flt_1_caught
+ .field private static int32 flt_2_caught
+
+ .method public static specialname void .cctor ()
+ {
+ ldc.i4.0
+ stsfld int32 T::exc_not_thrown
+
+ ldc.i4.0
+ stsfld int32 T::flt_1_caught
+
+ ldc.i4 0
+ stsfld int32 T::flt_2_caught
+
+ ret
+ }
+
+ .method public static int32 Main ()
+ {
+ .entrypoint
+
+ .try {
+ ldc.i4.0
+ ldc.i4.0
+ div
+
+ ldc.i4.1
+ stsfld int32 T::exc_not_thrown
+
+ leave outer
+ } filter {
+ pop
+ ldc.i4.0
+ endfilter
+ } {
+ ldc.i4.1
+ stsfld int32 T::flt_1_caught
+ leave outer
+ } filter {
+ pop
+ ldc.i4.1
+ endfilter
+ } {
+ ldc.i4.1
+ stsfld int32 T::flt_2_caught
+ leave outer
+ }
+
+
+ outer:
+ ldsfld int32 T::exc_not_thrown
+ brtrue fail
+
+ ldsfld int32 T::flt_1_caught
+ brtrue fail
+
+ ldsfld int32 T::flt_2_caught
+ brfalse fail
+
+ pass:
+ ldstr "PASS"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.0
+ ret
+
+ fail:
+ ldstr "FAIL"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.1
+ ret
+
+ }
+
+}
+
+
diff --git a/mcs/ilasm/tests/test-seh-e.il b/mcs/ilasm/tests/test-seh-e.il
new file mode 100644
index 00000000000..24d623361b6
--- /dev/null
+++ b/mcs/ilasm/tests/test-seh-e.il
@@ -0,0 +1,100 @@
+//
+// Test multiple catch blocks
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+.assembly extern mscorlib { }
+.assembly extern System { }
+.assembly 'test-seh-b' { }
+
+
+.class public T {
+
+ .field private static int32 exc_not_thrown
+ .field private static int32 catch_1
+ .field private static int32 catch_2
+ .field private static int32 catch_3
+
+ .method public static specialname void .cctor ()
+ {
+ ldc.i4.0
+ stsfld int32 T::exc_not_thrown
+
+ ldc.i4.0
+ stsfld int32 T::catch_1
+
+ ldc.i4.0
+ stsfld int32 T::catch_2
+
+ ldc.i4.0
+ stsfld int32 T::catch_3
+
+ ret
+ }
+
+ .method public static int32 Main ()
+ {
+ .entrypoint
+
+ //
+ // Only the second catch block should be executed
+ //
+
+ .try {
+ ldc.i4.0
+ ldc.i4.0
+ div
+
+ ldc.i4.1
+ stsfld int32 T::exc_not_thrown
+
+ leave outer
+ } catch [mscorlib]System.InvalidCastException {
+ ldc.i4.1
+ stsfld int32 T::catch_1
+ leave outer
+ } catch [mscorlib]System.DivideByZeroException {
+ ldc.i4.1
+ stsfld int32 T::catch_2
+ leave outer
+ } catch [mscorlib]System.Exception {
+ ldc.i4.1
+ stsfld int32 T::catch_3
+ leave outer
+ }
+
+
+ outer:
+ ldsfld int32 T::exc_not_thrown
+ brtrue fail
+
+ ldsfld int32 T::catch_1
+ brtrue fail
+
+ ldsfld int32 T::catch_2
+ brfalse fail
+
+ ldsfld int32 T::catch_3
+ brtrue fail
+
+ pass:
+ ldstr "PASS"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.0
+ ret
+
+ fail:
+ ldstr "FAIL"
+ call void [mscorlib]System.Console::WriteLine (string)
+ ldc.i4.1
+ ret
+
+ }
+
+}
+
+
diff --git a/mcs/ilasm/tests/test-sn.il b/mcs/ilasm/tests/test-sn.il
new file mode 100644
index 00000000000..d0b8e9833e7
--- /dev/null
+++ b/mcs/ilasm/tests/test-sn.il
@@ -0,0 +1,59 @@
+// TEST #1
+// 1. Assemble (with signing)
+// ilasm /key=sn.snk test-sn.il
+//
+// 2. Verify public key in signed assembly
+// sn -Tp test-sn.exe
+//
+// Public Key:
+// 00240000048000009400000006020000002400005253413100040000010001002d02a2e377ce62
+// 3f6c888a5707f1ca48f0e226fe89ff953ddb5fb1fa5ecaeee3a8cd00bc99b12dd5a7d5f532298b
+// 9d9d4a59909affb006eb79b6667a99bf5268e913883e2ef7e9110b408ac2f1e10ff1c357e13ab6
+// 26155bb966a513c1cddcd29ece19e7d2af1303771cb9878846ac53cb9d70b599cda6a63dd8b278
+// f1909bb9
+//
+// Public Key Token: 30b3f489250b41bd
+//
+// 3. Verify strongname signature (valid)
+// sn -v test-sn.exe
+
+
+// TEST #2
+// 1. Assemble (without signing - creating a delay signed assembly)
+// ilasm test-sn.il
+//
+// 2. Verify public key in signed assembly
+// sn -Tp test-sn.exe
+// (see results above)
+//
+// 4. Verify strongname signature (not signed!)
+// sn -v test-sn.exe
+//
+// 5. Strongname the assembly
+// sn -R test-sn.exe sn.snk
+//
+// 6. Verify strongname signature (valid)
+// sn -v test-sn.exe
+
+
+.assembly extern mscorlib {}
+
+.assembly hello {
+ .publickey = (
+ 00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00 00 24 00 00 52 53 41 31 00 04 00 00 01 00 01 00
+ 2D 02 A2 E3 77 CE 62 3F 6C 88 8A 57 07 F1 CA 48 F0 E2 26 FE 89 FF 95 3D DB 5F B1 FA 5E CA EE E3
+ A8 CD 00 BC 99 B1 2D D5 A7 D5 F5 32 29 8B 9D 9D 4A 59 90 9A FF B0 06 EB 79 B6 66 7A 99 BF 52 68
+ E9 13 88 3E 2E F7 E9 11 0B 40 8A C2 F1 E1 0F F1 C3 57 E1 3A B6 26 15 5B B9 66 A5 13 C1 CD DC D2
+ 9E CE 19 E7 D2 AF 13 03 77 1C B9 87 88 46 AC 53 CB 9D 70 B5 99 CD A6 A6 3D D8 B2 78 F1 90 9B B9
+ )
+}
+
+.class private auto ansi beforefieldinit Program extends [mscorlib]System.Object {
+ .method private hidebysig static void Main() cil managed {
+ .entrypoint
+ .maxstack 8
+ ldstr "Hello Mono!"
+ call void [mscorlib]System.Console::WriteLine(string)
+ ret
+ }
+}
diff --git a/mcs/ilasm/tests/test-uint.il b/mcs/ilasm/tests/test-uint.il
new file mode 100644
index 00000000000..9d65b0ebc53
--- /dev/null
+++ b/mcs/ilasm/tests/test-uint.il
@@ -0,0 +1,32 @@
+//Test for keywords : uint8, uint16, uint32 & uint64
+//Should get parsed as unsigned int8 .. etc
+//
+//uint8 in marshal (..) should get parsed as native types
+
+.assembly Test
+{
+}
+
+.namespace MonoTest
+{
+ .class private auto autochar beforefieldinit ConsoleApp
+ extends [mscorlib]System.Object
+ {
+ .field private marshal (uint8) int32 a0
+ .field private marshal (uint16) int32 a1
+ .field private marshal (uint32) int32 a2
+ .field private marshal (uint64) int64 a3
+
+ .method assembly hidebysig static void Test() cil managed
+ {
+ // Code size 74 (0x4a)
+ .maxstack 2
+
+ .locals init (uint8 V_0,
+ uint16 V_1,
+ uint32 V_2,
+ uint64 V_3)
+ ret
+ }
+ }
+}
diff --git a/mcs/ilasm/tests/two.cs b/mcs/ilasm/tests/two.cs
new file mode 100644
index 00000000000..9f84911b769
--- /dev/null
+++ b/mcs/ilasm/tests/two.cs
@@ -0,0 +1,7 @@
+public class outer {
+ public class inner {
+ }
+}
+
+public class gen <T> {
+}